Zaubrik / djwt

Create and verify JSON Web Tokens (JWT) with Deno or the browser.
MIT License
228 stars 23 forks source link

verify method is behaving strangely #89

Closed mohankoppuravuri closed 1 month ago

mohankoppuravuri commented 1 month ago

I created a jwt token using create method. I exported the cryptoKey and stored in the session storage.

Whenever deno server gets request it takes the jwt token and decode it for the unique ID of the user presents at JWT body.

With the help of user id, I fetch the cryptoKey in string format convert it to cryptoKey type

Final step is verify method.

Initially it was working. Not sure what happened suddenly. Though passing correct data it is throwing error.

Strange thing here is, I copied the cryptoKey and jwt token in console. And ran the test in separate deno file. When I run it independently it is working.

Is this verify function a pure function? Does this depends on class or require this context ?
It stopped working when moved functions to arrow functions.

mohankoppuravuri commented 1 month ago

Sorry, I was passing wrong data!

There is a hardcoded prefix in the jwt token