Back to Jose

Class: JWTClaimValidationFailed

docs/util/errors/classes/JWTClaimValidationFailed.md

6.2.121.7 KB
Original Source

Class: JWTClaimValidationFailed

šŸ’— 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.

Thrown when JWT claim or header validation fails. Expiration is reported separately as JWTExpired.

Examples

Checking thrown error is this one using a stable error code

js
if (err.code === 'ERR_JWT_CLAIM_VALIDATION_FAILED') {
  // ...
}

Checking thrown error is this one using instanceof

js
if (err instanceof jose.errors.JWTClaimValidationFailed) {
  // ...
}

Properties

cause

• cause: JWTClaimValidationFailure

The JWTClaimValidationFailure details carried by this error.


claim

• claim: string

Claim or header that failed validation.


code

• code: string = 'ERR_JWT_CLAIM_VALIDATION_FAILED'

A unique error code for JWTClaimValidationFailed.


payload

• payload: JWTPayload

The parsed JWT Claims Set; validation of other claims may be incomplete. With jwtVerify and jwtDecrypt, token authentication precedes claim validation. jwt/unsecured.UnsecuredJWT.decode does not authenticate tokens.


reason

• reason: string

Reason code for the validation failure.