Add dotenv and config instructions
This commit is contained in:
parent
efdd2c933f
commit
3d0f505961
1
.env.example
Normal file
1
.env.example
Normal file
@ -0,0 +1 @@
|
|||||||
|
REGISTRATION_SHARED_SECRET='look in your synapses homeserver.yaml'
|
||||||
@ -35,6 +35,10 @@ curl --request POST \
|
|||||||
> src/config/synapse_access_token.json
|
> src/config/synapse_access_token.json
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Copy over `.env.example` to `.env` and insert your values.
|
||||||
|
|
||||||
## Design Decisions
|
## Design Decisions
|
||||||
|
|
||||||
- Getting data from Rocket.Chat via (currently) manual mongodb export
|
- Getting data from Rocket.Chat via (currently) manual mongodb export
|
||||||
|
|||||||
14
package-lock.json
generated
14
package-lock.json
generated
@ -10,6 +10,7 @@
|
|||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
"winston": "^3.8.2"
|
"winston": "^3.8.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -921,6 +922,14 @@
|
|||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/dotenv": {
|
||||||
|
"version": "16.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
|
||||||
|
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/eastasianwidth": {
|
"node_modules/eastasianwidth": {
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
|
||||||
@ -4513,6 +4522,11 @@
|
|||||||
"esutils": "^2.0.2"
|
"esutils": "^2.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dotenv": {
|
||||||
|
"version": "16.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
|
||||||
|
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="
|
||||||
|
},
|
||||||
"eastasianwidth": {
|
"eastasianwidth": {
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
|
||||||
|
|||||||
@ -45,6 +45,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
"winston": "^3.8.2"
|
"winston": "^3.8.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
|
import dotenv from 'dotenv'
|
||||||
|
dotenv.config()
|
||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import readline from 'node:readline'
|
|
||||||
import log from './logger'
|
import log from './logger'
|
||||||
import { whoami } from './synapse'
|
import readline from 'node:readline'
|
||||||
import { storage } from './storage'
|
|
||||||
import { RcUser, createUser } from './users'
|
import { RcUser, createUser } from './users'
|
||||||
|
import { storage } from './storage'
|
||||||
|
import { whoami } from './synapse'
|
||||||
|
|
||||||
log.info('rocketchat2matrix starts.')
|
log.info('rocketchat2matrix starts.')
|
||||||
|
|
||||||
|
|||||||
@ -30,8 +30,12 @@ export function mapUser(rcUser: RcUser): MatrixUser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const registration_shared_secret =
|
const registration_shared_secret = process.env.REGISTRATION_SHARED_SECRET || ''
|
||||||
'vkq7zfBDt4A1NmMN6jJ*g+,G~.R:QuC_xI:~7~jQ_6kJ6O~JrG'
|
if (!registration_shared_secret) {
|
||||||
|
const message = 'No REGISTRATION_SHARED_SECRET found in .env.'
|
||||||
|
log.error(message)
|
||||||
|
throw new Error(message)
|
||||||
|
}
|
||||||
|
|
||||||
function generateHmac(user: MatrixUser): string {
|
function generateHmac(user: MatrixUser): string {
|
||||||
const hmac = createHmac('sha1', registration_shared_secret)
|
const hmac = createHmac('sha1', registration_shared_secret)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user