fix app key errors

This commit is contained in:
b1ek 2023-03-19 19:10:05 +10:00
parent d0e38ace0e
commit 668dccdb71
Signed by: blek
GPG Key ID: 14546221E3595D0C
4 changed files with 8 additions and 10 deletions

View File

@ -1,12 +1,14 @@
const express = require('express');
const router = express.Router();
const base = require('js-base64');
const cookie_parse = require('cookie-parser');
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));
module.exports = router

View File

@ -19,8 +19,8 @@
"connect-redis": "^6.1.3",
"cookie-encrypter": "^1.0.1",
"cookie-parser": "^1.4.6",
"crc-32": "^1.2.2",
"dotenv": "^16.0.3",
"easy-crc": "^1.1.0",
"express": "^4.18.2",
"express-async-handler": "^1.2.0",
"express-minify": "^1.0.0",

View File

@ -8,7 +8,7 @@ if (not os.path.exists('.env')):
print('No .env file found. Please create a dotenv to proceed.');
exit(-1);
key_bytes = secrets.token_bytes(32 * 8);
key_bytes = secrets.token_bytes(32);
dotenv_text = '';
with open('.env', 'tr', encoding='utf-8') as f:

View File

@ -1,7 +1,7 @@
console.log('Executing startup jobs...');
const fs = require('fs');
const crc32 = require('crc-32');
const { crc32 } = require('easy-crc');
const glob = require('glob');
const { exec } = require('child_process');
@ -59,11 +59,7 @@ glob('data/userdata/*_gpgkey', async (err, files) => {
});
// TODO: perhaps a better approach to storing it????
// ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
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));
console.log('Using a key with CRC32: ' + crc32('CRC-32', process.env.APP_KEY));
async function startup() {
let t1 = hrt();