mirror of
https://github.com/wukko/cobalt.git
synced 2025-06-13 05:37:44 +02:00
api/util: add script to generate secure JWT_SECRET
This commit is contained in:
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))}`)
|
Reference in New Issue
Block a user