Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
t.test('should sign a jwt', (assert) => {
assert.plan(2)
const keyPair = createKeyPair()
const jwtPayload = {
iss: 'SOMETHING',
}
const token = signJwt(keyPair.privateKey, jwtPayload)
assert.ok(token)
assert.ok(verify(token, pki.publicKeyToPem(keyPair.publicKey)))
})
})
private generateKeyPair(key: string) {
const keypair = pki.rsa.generateKeyPair({ bits: 1024 });
const privateKey = pki.privateKeyToPem(keypair.privateKey);
const publicKey = pki.publicKeyToPem(keypair.publicKey);
this.keyPairs[key] = { publicKey, privateKey };
return publicKey;
}
}
sendClientKeyExchange () {
this.sendHandshakeMessage(HandshakeType.CLIENT_KEY_EXCHANGE,
prepend16(publicEncrypt({
key: pki.publicKeyToPem(this.serverCertificates[0].publicKey),
padding: RSA_PKCS1_PADDING
}, this.preMasterSecret)))
}
export const generateRsaKeyPems = () => {
const keyPair = generateRsaKeyPair()
return {
publicKey: pki.publicKeyToPem(keyPair.publicKey),
privateKey: pki.privateKeyToPem(keyPair.privateKey),
}
}