Class TokenStorage

Hierarchy

Constructors

  • Parameters

    • origin: string

      The origin where the token belongs to

    • Optional token: null | string

      The initial token

    • Optional temporary: boolean

      If the token should be saved temporary or permanently

    Returns TokenStorage

Properties

origin: string

The origin of the token

temporary: boolean

Indicates if the token should keep temporary only or should be persisted for later sessions

tokenData: null | TokenData

The actual stored token

GLOBAL: typeof GlobalStorage
WEB_STORAGE: typeof WebStorage
hmac: ((message: string, key: string) => Promise<string>) = hmac

Type declaration

    • (message: string, key: string): Promise<string>
    • Calculates a Keyed-Hash Message Authentication Code (HMAC) from a message and a key.

      Returns

      Parameters

      • message: string
      • key: string

      Returns Promise<string>

Accessors

  • get token(): string
  • Get the stored token

    Returns

    The token or undefined, if no token is available

    Returns string

Methods

  • Protected

    Use the underlying storage implementation to save the token

    Returns

    Deprecated

    Use TokenStorage#saveToken instead

    Parameters

    • origin: string

      The origin where the token belongs to

    • token: null | string

      The initial token

    • temporary: boolean

      If the token should be saved temporary or permanently

    Returns void

  • Use the underlying storage implementation to save the token

    Returns

    Parameters

    • origin: string

      The origin where the token belongs to

    • token: null | string

      The initial token

    • temporary: boolean

      If the token should be saved temporary or permanently

    Returns void

  • Derives a resource token from the stored origin token and signs the resource with the generated resource token

    Returns

    A resource token which can only be used to access the specified resource

    Parameters

    • resource: string

      The resource which will be accessible with the returned token

    • sign: boolean = true

      Sign the given resource with a token, if sign is false the resource will only be encoded to a path

    Returns Promise<string>

  • Update the token for the givin origin, the operation may be asynchronous

    Parameters

    • token: null | string

      The token to store or null to remove the token

    Returns void

  • Parameters

    • origin: string

    Returns Promise<TokenStorage>

  • Parse a token string in its components

    Returns

    The parsed token data

    Parameters

    • token: string

      The token string to parse, time values are returned as timestamps

    Returns TokenData

Generated using TypeDoc