mirror of
https://github.com/imputnet/cobalt.git
synced 2025-01-01 12:46:07 +00:00
api/util: add script to generate secure JWT_SECRET
This commit is contained in:
parent
5ce3a941f9
commit
c3f3499a42
|
@ -12,7 +12,8 @@
|
||||||
"start": "node src/cobalt",
|
"start": "node src/cobalt",
|
||||||
"setup": "node src/util/setup",
|
"setup": "node src/util/setup",
|
||||||
"test": "node src/util/test",
|
"test": "node src/util/test",
|
||||||
"token:youtube": "node src/util/generate-youtube-tokens"
|
"token:youtube": "node src/util/generate-youtube-tokens",
|
||||||
|
"token:jwt": "node src/util/generate-jwt-secret"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
13
api/src/util/generate-jwt-secret.js
Normal file
13
api/src/util/generate-jwt-secret.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// run with `pnpm -r token:jwt`
|
||||||
|
|
||||||
|
const makeSecureString = (length = 64) => {
|
||||||
|
const alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-';
|
||||||
|
const out = [];
|
||||||
|
|
||||||
|
for (const byte of crypto.getRandomValues(new Uint8Array(length)))
|
||||||
|
out.push(alphabet[byte % alphabet.length]);
|
||||||
|
|
||||||
|
return out.join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`JWT_SECRET: ${JSON.stringify(makeSecureString(64))}`)
|
Loading…
Reference in a new issue