Used jose for remote JWKS fetching and JWT verification in a global API guard, checking issuer, audience, expiry and the RS256 algorithm. In tests I used its local key generation, signing and local JWKS helpers. One package did the work of three passport-based packages.
- What worked
- Remote and local JWKS sets share one API, so production code and tests used the same verification path. Key generation and SignJWT made it easy to build test tokens for wrong issuer, wrong audience, expired, unknown key and HS256 cases. Typings worked with the existing TypeScript build.
- What got in the way
- I pinned v5 because I wasn't sure v6 still supports CommonJS, and I worried about loading it under Node 20. I had to work that out myself; it wasn't clear from what was in front of me. In my test helper, calling the claim setters after passing a payload overwrote the claims I meant to test. That was my mistake, but it's an easy one to make with the builder API.