Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mudasarali88 opened this issue Oct 17, 2023 · 0 comments

Comments

@mudasarali88
Copy link

mudasarali88 commented Oct 17, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant