mirror of
https://github.com/imputnet/cobalt.git
synced 2024-12-29 11:06:10 +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",
|
||||
"setup": "node src/util/setup",
|
||||
"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": {
|
||||
"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