first commit
This commit is contained in:
24
scripts/generate-jwt-keys.mjs
Normal file
24
scripts/generate-jwt-keys.mjs
Normal file
@@ -0,0 +1,24 @@
|
||||
import { generateKeyPairSync, randomUUID } from 'node:crypto'
|
||||
|
||||
const { privateKey, publicKey } = generateKeyPairSync('rsa', {
|
||||
modulusLength: 2048,
|
||||
publicKeyEncoding: {
|
||||
type: 'spki',
|
||||
format: 'pem'
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
type: 'pkcs8',
|
||||
format: 'pem'
|
||||
}
|
||||
})
|
||||
|
||||
const kid = `auth-${randomUUID()}`
|
||||
|
||||
function toEnvValue(pem) {
|
||||
return pem.trim().replace(/\n/g, '\\n')
|
||||
}
|
||||
|
||||
console.log('# Copy these values to your .env file')
|
||||
console.log(`JWT_KID="${kid}"`)
|
||||
console.log(`JWT_PRIVATE_KEY_PEM="${toEnvValue(privateKey)}"`)
|
||||
console.log(`JWT_PUBLIC_KEY_PEM="${toEnvValue(publicKey)}"`)
|
||||
Reference in New Issue
Block a user