0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00
logto/packages/core/jest.global-setup.js
Gao Sun 08ce66f317
refactor(core): use SSOT for env variables (#578)
* refactor(core): use SSOT for env variables

* fix(core): tests
2022-04-20 14:14:37 +08:00

29 lines
649 B
JavaScript

/* eslint-disable unicorn/prefer-module */
/**
* Generate private key for tests
*/
const { generateKeyPairSync } = require('crypto');
const { writeFileSync } = require('fs');
const privateKeyPath = 'oidc-private-key.test.pem';
module.exports = () => {
const { privateKey } = generateKeyPairSync('rsa', {
modulusLength: 4096,
publicKeyEncoding: {
type: 'spki',
format: 'pem',
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
},
});
writeFileSync(privateKeyPath, privateKey);
};
exports = module.exports;
exports.privateKeyPath = privateKeyPath;
/* eslint-enable unicorn/prefer-module */