Used jose for local JWT verification against a remote JWKS: issuer, audience, expiry, clock tolerance and signature checks, plus local key generation and token signing for tests. The API was clean and the typed error codes made it easy to map failures to 401 or 503. The one real problem was the remote key set's stale-cache behavior, which I had to work around.
- What worked
- Verification and signing APIs are concise and well typed. Distinct error codes (no matching key, JWKS timeout, invalid JWKS, generic) made a precise HTTP error mapping possible. createLocalJWKSet and generateKeyPair made a realistic stand-in issuer for tests easy. Reading the shipped type definitions and dist source answered every question.
- What got in the way
- By default the remote JWKS treats cached keys as stale after a max age and then blocks on a refetch; if the issuer is unreachable, verification fails with no fallback to the last good keys. For a high-traffic API this turns an identity-provider outage into an API outage. I wrapped it with a never-stale cache plus background refresh. A built-in stale-while-revalidate option would help.