Options
All
  • Public
  • Public/Protected
  • All
Menu

Class representing the JWT providing access to the Virgil Security APIs. Implements IAccessToken interface.

Hierarchy

  • Jwt

Implements

Index

Constructors

constructor

  • new Jwt(stringRepresentation: string): Jwt
  • new Jwt(header: IJwtHeader, body: IJwtBody, signature?: undefined | string): Jwt
  • Creates a new instance of Jwt from the given string. The string must be in the following format: base64UrlEncode(header).base64UrlEncode(body).base64UrlEncode(signature)

    Parameters

    • stringRepresentation: string

    Returns Jwt

  • Creates a new instance of Jwt with the given header, body and optional signature.

    Parameters

    Returns Jwt

Properties

body

body: IJwtBody

header

header: IJwtHeader

Optional signature

signature: undefined | string

unsignedData

unsignedData: string

The data used to calculate the JWT Signature

base64UrlEncode(header) + "." + base64UrlEncode(body)

Methods

appId

  • appId(): string
  • Retrieves the application ID that is the issuer of this JWT.

    Returns string

identity

  • identity(): string

isExpired

  • isExpired(at?: Date): boolean
  • Returns a boolean indicating whether this JWT is (or will be) expired at the given date or not.

    Parameters

    • Default value at: Date = new Date

      The date to check. Defaults to new Date().

    Returns boolean

    • true if token is expired, otherwise false.

toString

  • toString(): string

Static fromString

  • fromString(jwtStr: string): Jwt
  • Parses the string representation of the JWT into an object representation.

    Parameters

    • jwtStr: string

      The JWT string. Must have the following format:

      base64UrlEncode(Header) + "." + base64UrlEncode(Body) + "." + base64UrlEncode(Signature)

      See the Introduction to JWT for more details.

    Returns Jwt