Skip to main content

JWTInterface

Represents the contents of a JWT token, providing access to its payload contents.

Hierarchy

Implemented by

Index

Properties

readonlyallClaims

allClaims: String[]

Returns the collection of custom claims this object contains.

Unlike the claims property, this returns values as strings.

readonlyclaims

claims: (() => string | (radix?: number) => string | () => string | () => number)[]

readonlycustomClaims

customClaims: String[]

Returns the collection of custom claims this object contains.

Unlike the `claims` property, this returns values as strings.

optionalreadonlyexpiresAt

expiresAt?: Date

The calculated date at which this object will expire.

readonlyexpiresIn

expiresIn: Number

Time interval from the issue date when the object will expire.

readonlyheader

header: JWTHeader

The header portion of the JWT token.

readonlyisExpired

isExpired: Boolean

Indicates if this object has expired.

readonlyisValid

isValid: Boolean

Indicates if this object is valid.

optionalreadonlyissuedAt

issuedAt?: Date

The date this object was issued, from which the expiration time will be calculated.

readonlypayload

payload: [String: any]

Raw payload of claims, as a dictionary representation.

Methods

optionalarrayValue

  • arrayValue<ValueType>(type: ValueType, key: String): ValueType[]
  • arrayValue<ValueType>(type: ValueType, claim: JWTClaim): ValueType[]
  • Returns an array of claim values from this JWT token, with the given key and expected return type.


    Type parameters

    Parameters

    • type: ValueType

      The type the value is expected to be, or should be converted to (using ClaimConvertible).

    • key: String

      The key to use when extracting the claim.

    Returns ValueType[]

    The value for the supplied claim of the requested type.

validate

  • validate(using: JWKS): Boolean
  • Verifies the JWT token using the given `JWK` key.

    @throws

    JWTError


    Parameters

    Returns Boolean

    Returns whether or not signing passes for this token/key combination.

optionalvalue

  • value<ValueType>(type: ValueType, key: String): ValueType
  • value<ValueType>(type: ValueType, claim: JWTClaim): ValueType
  • Returns a claim value from this JWT token, with the given key and expected return type.


    Type parameters

    Parameters

    • type: ValueType

      The type the value is expected to be, or should be converted to (using ClaimConvertible).

    • key: String

      The key to use when extracting the claim.

    Returns ValueType

    The value for the supplied claim of the requested type.