node-jose
node-jose copied to clipboard
Tring to convert JWT to JWE but facing some error, Here are my code and output
After phone auth from firebase I got idToken from it that is a JWT as according to my R&D and I want to convert it into JWE but all my tries are failed. I am trying React JS. Here is my code. I also tried in Express JS but same error faced. Kindly guide me where I am wrong. I have used Node-Jose for my tries.
`const createJWE = async () => { // Payload to be included in the JWT const payload = { idToken: 'token', }; try { // Sign the JWT const jwt = await jose.JWS.createSign({ format: 'compact' }, { key: rsaPublicKey }).update(JSON.stringify(payload)).final();
// Encrypt the JWT to create a JWE
const jwe = await jose.JWE.createEncrypt({ format: 'compact' }, { key: rsaPublicKey }).update(jwt).final();
console.log(jwe);
} catch (error) {
console.error('JWE Creation Error:', error);
}
} createJWE();`