Skip to content

Latest commit

 

History

History
145 lines (87 loc) · 4.43 KB

jwt_verify.JWTVerifyOptions.md

File metadata and controls

145 lines (87 loc) · 4.43 KB

Interface: JWTVerifyOptions

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.


Combination of JWS Verification options and JWT Claims Set verification options.

Table of contents

Properties

Properties

algorithms

Optional algorithms: string[]

A list of accepted JWS "alg" (Algorithm) Header Parameter values. By default all "alg" (Algorithm) values applicable for the used key/secret are allowed.

Note: Unsecured JWTs ({ "alg": "none" }) are never accepted by this API.


audience

Optional audience: string | string[]

Expected JWT "aud" (Audience) Claim value(s).

This option makes the JWT "aud" (Audience) Claim presence required.


clockTolerance

Optional clockTolerance: string | number

Expected clock tolerance

  • In seconds when number (e.g. 5)
  • Parsed as seconds when a string (e.g. "5 seconds", "10 minutes", "2 hours").

crit

Optional crit: Object

An object with keys representing recognized "crit" (Critical) Header Parameter names. The value for those is either true or false. true when the Header Parameter MUST be integrity protected, false when it's irrelevant.

This makes the "Extension Header Parameter "..." is not recognized" error go away.

Use this when a given JWS/JWT/JWE profile requires the use of proprietary non-registered "crit" (Critical) Header Parameters. This will only make sure the Header Parameter is syntactically correct when provided and that it is optionally integrity protected. It will not process the Header Parameter in any way or reject the operation if it is missing. You MUST still verify the Header Parameter was present and process it according to the profile's validation steps after the operation succeeds.

The JWS extension Header Parameter b64 is always recognized and processed properly. No other registered Header Parameters that need this kind of default built-in treatment are currently available.


currentDate

Optional currentDate: Date

Date to use when comparing NumericDate claims, defaults to new Date().


issuer

Optional issuer: string | string[]

Expected JWT "iss" (Issuer) Claim value(s).

This option makes the JWT "iss" (Issuer) Claim presence required.


maxTokenAge

Optional maxTokenAge: string | number

Maximum time elapsed (in seconds) from the JWT "iat" (Issued At) Claim value.

  • In seconds when number (e.g. 5)
  • Parsed as seconds when a string (e.g. "5 seconds", "10 minutes", "2 hours").

This option makes the JWT "iat" (Issued At) Claim presence required.


requiredClaims

Optional requiredClaims: string[]

Array of required Claim Names that must be present in the JWT Claims Set. Default is that: if the issuer option is set, then JWT "iss" (Issuer) Claim must be present; if the audience option is set, then JWT "aud" (Audience) Claim must be present; if the subject option is set, then JWT "sub" (Subject) Claim must be present; if the maxTokenAge option is set, then JWT "iat" (Issued At) Claim must be present.


subject

Optional subject: string

Expected JWT "sub" (Subject) Claim value.

This option makes the JWT "sub" (Subject) Claim presence required.


typ

Optional typ: string

Expected JWT "typ" (Type) Header Parameter value.

This option makes the JWT "typ" (Type) Header Parameter presence required.