Files
Filip Skokan abec502715 refactor(types): add discriminated JOSE error types
Pair each JOSE error subclass with its stable code so code switches can
narrow safely without closing subclass code values.

Share typed causes and reasons across JWT claim-validation errors, and
make consumer-created multiple-match errors safely iterable. Add
compile-time coverage for the public type surface.

Signed-off-by: Filip Skokan <[email protected]>
2026-07-29 18:50:54 +02:00

1.5 KiB

Class: JWTExpired

💗 Help the project

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by becoming a sponsor.

An error subclass thrown when a JWT is expired.

Examples

Checking thrown error is this one using a stable error code

if (err.code === 'ERR_JWT_EXPIRED') {
  // ...
}

Checking thrown error is this one using instanceof

if (err instanceof jose.errors.JWTExpired) {
  // ...
}

Properties

cause

• cause: JWTClaimValidationFailure

The JWTClaimValidationFailure carried by every instance of this error.


claim

• claim: string

The Claim for which the validation failed.


code

• code: string = 'ERR_JWT_EXPIRED'

A unique error code for JWTExpired.


payload

• payload: JWTPayload

The parsed JWT Claims Set (aka payload). Other JWT claims may or may not have been verified at this point. The JSON Web Signature (JWS) or a JSON Web Encryption (JWE) structures' integrity has however been verified. Claims Set verification happens after the JWS Signature or JWE Decryption processes.


reason

• reason: string

Reason code for the validation failure.