mirror of
https://github.com/danbulant/jose
synced 2026-05-20 12:58:36 +00:00
12 lines
606 B
JavaScript
12 lines
606 B
JavaScript
const { generateKeyPairSync, createSecretKey } = require('crypto')
|
|
|
|
// TODO: reach out to @tniessen to request constructors being exposed for this exact purpose
|
|
// (verifying inputs are already KeyObjects)
|
|
// TODO: what's the least blocking way to get to the constructors
|
|
const { publicKey, privateKey } = generateKeyPairSync('ec', { namedCurve: 'P-256' })
|
|
|
|
const PrivateKeyObject = privateKey.constructor
|
|
const PublicKeyObject = publicKey.constructor
|
|
const SecretKeyObject = createSecretKey(Buffer.allocUnsafe(1)).constructor
|
|
|
|
module.exports = { PrivateKeyObject, PublicKeyObject, SecretKeyObject }
|