Last active
May 10, 2021 16:47
-
-
Save steverhall/bb93cde348097e8ee02f9f6cd0bc4a81 to your computer and use it in GitHub Desktop.
Create a JWK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jose, { JWK } from 'node-jose'; | |
const encryptionKeyProps = { | |
"kty": "EC", | |
"crv": "P-256", | |
"alg": 'ECDH-ES', | |
"use": "enc" | |
} | |
const signingKeyProps = { | |
"kty": "EC", | |
"crv": "P-256", | |
"alg": 'ES256', | |
"use": "sig" | |
} | |
async function generate() { | |
let sign = await jose.JWK.createKey("EC", "P-256", signingKeyProps); | |
let encrypt = await jose.JWK.createKey("EC", "P-256", encryptionKeyProps); | |
console.log(JSON.stringify({ | |
keys: [ | |
sign.toJSON(true), | |
encrypt.toJSON(true), | |
] | |
}, null, 2)); | |
console.log('--------PEM---------'); | |
console.log(sign.toPEM(true)); | |
console.log('---------THUMBPRINT--------'); | |
console.log(sign.thumbprint); | |
} | |
generate(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment