Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Token

This class represents a sense NET JWT Token instance.

Hierarchy

  • Token

Index

Constructors

Private constructor

  • new Token(headerEncoded: string, payloadEncoded: string): Token
  • Parameters

    • headerEncoded: string
    • payloadEncoded: string

    Returns Token

Properties

Private headerEncoded

headerEncoded: string

Private payloadEncoded

payloadEncoded: string

Accessors

ExpirationTime

  • get ExpirationTime(): Date
  • The Date when the token will expire

    Returns Date

IssuedDate

  • get IssuedDate(): Date
  • The date when the Token was issued

    Returns Date

NotBefore

  • get NotBefore(): Date
  • The token will be valid only after this date

    Returns Date

Username

  • get Username(): string
  • The Username from the current Token payload

    Returns string

Private _tokenPayload

Methods

GetPayload

IsValid

  • IsValid(): boolean
  • Indicates if the Token is valid based on it's ExpirationTime and NotBefore values.

    Returns boolean

Private fromEpoch

  • fromEpoch(epoch: number): Date
  • Parameters

    • epoch: number

    Returns Date

toString

  • toString(): string
  • Returns the Token in string format (in a base64 encoded, dot separated header and payload)

    Returns string

Static CreateEmpty

  • Factory method for creating empty (invalid) tokens

    const invalidToken = Token.CreateEmpty();
    

    Token

    Returns Token

Static FromHeadAndPayload

  • FromHeadAndPayload(headAndPayload: string): Token
  • Factory method to create a token from a sense NET specific base64 encoded header and payload string, e.g.:

    const myToken = Token.FromHeadAndPayload("e30=.eyJhdWQiOiIiLCJleHAiOjE0OTQ1NzkwOTUuMTIsImlhdCI6MCwiaXNzIjoiIiwibmFtZSI6IiIsIm5iZiI6MSwic3ViIjoiIn0=");
    

    Token

    Parameters

    • headAndPayload: string

    Returns Token

Generated using TypeDoc