0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00
logto/packages/core/jest.global-setup.ts

26 lines
524 B
TypeScript
Raw Normal View History

/**
* Generate private key for tests
*/
import { generateKeyPairSync } from 'crypto';
import { writeFileSync } from 'fs';
export const privateKeyPath = 'oidc-private-key.test.pem';
const globalSetup = () => {
const { privateKey } = generateKeyPairSync('rsa', {
modulusLength: 4096,
publicKeyEncoding: {
type: 'spki',
format: 'pem',
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
},
});
writeFileSync(privateKeyPath, privateKey);
};
export default globalSetup;