import * as forge from 'node-forge' ; import { PublicKeyPem , PrivateKeyPem } from '../../types' ; function param { object } options param { number } bits export const generateKeyPair = ( { bits = 1024 } = { } ) : { publicKey : PublicKeyPem ; privateKey : PrivateKeyPem ; } => { const keypair = forge . pki . rsa . generateKeyPair ( { bits } ) ; const publicKey = forge . pki . publicKeyToPem ( keypair . publicKey ) ; const privateKey = forge . pki . privateKeyToPem ( keypair . privateKey ) ; return { publicKey , privateKey } ; } ;