Skip to content

Tring to convert JWT to JWE but facing some error, Here are my code and output #422

@mudasarali88

Description

@mudasarali88

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();`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions