fix app key errors
This commit is contained in:
parent
d0e38ace0e
commit
668dccdb71
|
@ -1,12 +1,14 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
const base = require('js-base64');
|
||||||
|
|
||||||
const cookie_parse = require('cookie-parser');
|
const cookie_parse = require('cookie-parser');
|
||||||
const cookie_encrypt = require('cookie-encrypter');
|
const cookie_encrypt = require('cookie-encrypter');
|
||||||
|
|
||||||
const { APP_KEY } = process.env;
|
const APP_KEY = Buffer.from(process.env.APP_KEY, 'base64');
|
||||||
|
|
||||||
router.use(cookie_parse(APP_KEY))
|
router.use(cookie_parse(APP_KEY));
|
||||||
router.use(cookie_encrypt(APP_KEY));
|
router.use(cookie_encrypt(APP_KEY));
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
|
@ -19,8 +19,8 @@
|
||||||
"connect-redis": "^6.1.3",
|
"connect-redis": "^6.1.3",
|
||||||
"cookie-encrypter": "^1.0.1",
|
"cookie-encrypter": "^1.0.1",
|
||||||
"cookie-parser": "^1.4.6",
|
"cookie-parser": "^1.4.6",
|
||||||
"crc-32": "^1.2.2",
|
|
||||||
"dotenv": "^16.0.3",
|
"dotenv": "^16.0.3",
|
||||||
|
"easy-crc": "^1.1.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"express-async-handler": "^1.2.0",
|
"express-async-handler": "^1.2.0",
|
||||||
"express-minify": "^1.0.0",
|
"express-minify": "^1.0.0",
|
||||||
|
|
|
@ -8,7 +8,7 @@ if (not os.path.exists('.env')):
|
||||||
print('No .env file found. Please create a dotenv to proceed.');
|
print('No .env file found. Please create a dotenv to proceed.');
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
|
||||||
key_bytes = secrets.token_bytes(32 * 8);
|
key_bytes = secrets.token_bytes(32);
|
||||||
dotenv_text = '';
|
dotenv_text = '';
|
||||||
|
|
||||||
with open('.env', 'tr', encoding='utf-8') as f:
|
with open('.env', 'tr', encoding='utf-8') as f:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
console.log('Executing startup jobs...');
|
console.log('Executing startup jobs...');
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const crc32 = require('crc-32');
|
const { crc32 } = require('easy-crc');
|
||||||
const glob = require('glob');
|
const glob = require('glob');
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
|
|
||||||
|
@ -59,11 +59,7 @@ glob('data/userdata/*_gpgkey', async (err, files) => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: perhaps a better approach to storing it????
|
console.log('Using a key with CRC32: ' + crc32('CRC-32', process.env.APP_KEY));
|
||||||
// ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
|
||||||
process.env.APP_KEY = Buffer.from(process.env.APP_KEY, 'base64').toString('ascii');
|
|
||||||
|
|
||||||
console.log('Using a key with CRC32: ' + crc32.str(process.env.APP_KEY).toString(16));
|
|
||||||
|
|
||||||
async function startup() {
|
async function startup() {
|
||||||
let t1 = hrt();
|
let t1 = hrt();
|
||||||
|
|
Loading…
Reference in New Issue