How to embed public key in JWK format in JWS / JWT header?
1 min readMar 6, 2019
It is easy with node-jose library when you know how to do it.
It took me some time to learn, because this information is missing in the documentation. Luckily it was in tests.
The missing example (creates a JWT with an embedded ‘jwk’):
// {input} is a String
// {key} is from jwk keystorejose.JWS.createSign(
{
fields: {
typ: 'JWT',
},
format: 'compact',
opts: { protect: false },
},
{
key,
reference: 'jwk', // MISSING in documentation
},
).update(input, 'utf-8')
.final()
.then((result) => {
// {result} is a JSON object -- JWT using the JSON General Serialization
});
I hope I saved you some time.