27 lines
738 B
JavaScript
27 lines
738 B
JavaScript
const { generateKeyPairSync } = require('crypto');
|
|
const { spawn } = require('child_process');
|
|
|
|
console.log('Generating PKCS#8 RSA Key...');
|
|
const { privateKey } = generateKeyPairSync('rsa', {
|
|
modulusLength: 2048,
|
|
privateKeyEncoding: {
|
|
type: 'pkcs8',
|
|
format: 'pem',
|
|
},
|
|
});
|
|
|
|
console.log('Key generated. Setting JWT_PRIVATE_KEY in Convex Env...');
|
|
|
|
const setCmd = spawn('npx', ['convex', 'env', 'set', 'JWT_PRIVATE_KEY', '--', privateKey], {
|
|
stdio: 'inherit'
|
|
});
|
|
|
|
setCmd.on('close', (code) => {
|
|
if (code === 0) {
|
|
console.log('✅ Successfully set JWT_PRIVATE_KEY!');
|
|
} else {
|
|
console.error('❌ Failed to set JWT_PRIVATE_KEY. Exit code:', code);
|
|
process.exit(code);
|
|
}
|
|
});
|