tsndr / cloudflare-worker-jwt

A lightweight JWT implementation with ZERO dependencies for Cloudflare Workers.
MIT License
649 stars 51 forks source link

Verify always returns false. #53

Closed Codename-404 closed 9 months ago

Codename-404 commented 9 months ago

Hi, verify returns false, always. It was working in the middleware files but now it's not working. Note I update my node js to the latest version, and now it's not working. However it was working when I had node v18. Not sure if it's related.

Here'e my code:
const jwt_token = await jwt.sign( { ...filteredData, expires: expires }, process.env.AUTH_SECRET );

const verifyRes = await jwt.verify(jwt_token, process.env.AUTH_SECRET); // returns false here

tsndr commented 9 months ago

This library is explicitly designed to be used with Cloudflare Workers, and is therefore not compatible with Node.js.

switz commented 5 months ago

I get that it's explicitly designed to be used with cloudflare workers, but some of us write code that runs in both environments and it would be nice to rely on a single implementation. If it's firmly out of scope for you, then okay (its your lib), but is there any downside to ensuring compatibility across node and workers? It worked back in 2.2.3.

Happy to send a PR fixing it if that's okay.