Last active
June 22, 2022 08:32
-
-
Save zetxx/f009eb33101f7ebf3131b387427468a0 to your computer and use it in GitHub Desktop.
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
// jose version v2.x | |
const jose = require('jose'); | |
const simpleJWKgen = async({ | |
kty = 'OKP', | |
crvOrSize = 'Ed25519', | |
options: { | |
alg = 'EdDSA', | |
kid, | |
key_ops, | |
use = 'sig' | |
} = {} | |
} = {}) => { | |
const data = await jose.JWK.generate(kty, crvOrSize, { | |
alg, | |
kid, | |
key_ops, | |
use | |
}); | |
return ['kty', 'd', 'use', 'crv', 'kid', 'x', 'alg'] | |
.reduce((rdy, prop) => ( | |
(data[prop] && {...rdy, [prop]: data[prop]}) || rdy | |
), {}); | |
}; | |
(async() => console.log(await simpleJWKgen()))(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment