Safety
Handle what goes wrong, check what a token claims, and know the bounds every call works within.
Every token, key and session function in unjwt throws one kind of error when something goes wrong: a JWTError with a short code your code can branch on. Claims are checked by default, so an expired token never verifies unless you say so. And the work one token can make your server do is bounded: when a token asks for more, the call refuses it instead of trying harder.
Handle errors
Catch JWTError, tell a bad token from a bug on your side by its code, and answer each one.
Validate claims
Check issuer, audience, subject, age and type, and write iat, exp and nbf when you sign.
Limits
The bounds on signatures, recipients, key trials and password work, and when to raise one.
Utilities
Strict base64url, secure random bytes, and type guards for keys and key sets.