Options
All
  • Public
  • Public/Protected
  • All
Menu

Default entrypoint for auth-toolbox module.

Load tokens from TokenStorage, support authentication methods like login and logout, and automates the authentication of client provided with ClientAdapter.

Options can be defined with AuthOptions.

Type parameters

Hierarchy

  • IAuth

Implemented by

Index

Properties

Readonly storageSync

storageSync: boolean

Check if underlying storage is synchronous.

usePersistentStorage

usePersistentStorage: boolean

Define if tokens should be stored in persistent storage.

Methods

addExclude

  • addExclude(...excludes: Exclude[]): void
  • Add a request type to be excluded from authentication interceptors.

    Parameters

    Returns void

addListener

decodeAccessToken

  • decodeAccessToken(): any | undefined
  • Decode the access token from Tokens if defined.

    Returns any | undefined

    The decoded access token payload.

getTokens

  • getTokens(): Tokens<C> | undefined

isAuthenticated

  • isAuthenticated(): boolean
  • Check if user is authenticated.

    Returns boolean

    true if user is authenticated.

isExpiredAccessToken

  • isExpiredAccessToken(offset?: number): boolean | undefined
  • Check if access token has expired.

    Parameters

    • Optional offset: number

      Offset in millisecond to apply on browser current date.

    Returns boolean | undefined

loadTokensFromStorage

  • loadTokensFromStorage(): Tokens<C> | undefined
  • Load tokens from storage synchronously.

    throws

    Error when underlying storage is not synchronous.

    see

    storageSync

    Returns Tokens<C> | undefined

    Loaded tokens

loadTokensFromStorageAsync

  • loadTokensFromStorageAsync(): Promise<Tokens<C> | undefined>
  • Load tokens from storage asynchronously.

    Returns Promise<Tokens<C> | undefined>

    Loaded tokens

login

  • login(credentials: C): Promise<R>
  • Authenticate the user with given credentials.

    throws

    Error if fail to renew tokens.

    Parameters

    • credentials: C

      Credentials to use.

    Returns Promise<R>

    Client response if it has occured.

logout

  • logout(): Promise<R | void>
  • Forget the user authentication.

    throws

    Error if fail to renew tokens.

    Returns Promise<R | void>

    Client response if it has occured.

release

  • release(): void

removeListener

renew

  • renew(): Promise<R | void>
  • Renew tokens.

    throws

    Error if fail to renew tokens.

    Returns Promise<R | void>

    Client response if it has occured.

setTokens

  • setTokens(tokens: Tokens<C> | undefined | null): void
  • Manually store tokens synchronously. It may be used to authenticated a user with a token instead of using login with credentials.

    throws

    Error when underlying storage is not synchronous.

    see

    storageSync

    Parameters

    • tokens: Tokens<C> | undefined | null

      Tokens to save.

    Returns void

setTokensAsync

  • setTokensAsync(tokens: Tokens<C> | undefined | null): Promise<void>
  • Manually store tokens asynchronously. It may be used to authenticated a user with a token instead of using login with credentials.

    Parameters

    • tokens: Tokens<C> | undefined | null

      Tokens to save.

    Returns Promise<void>

Legend

  • Interface
  • Interface with type parameter
  • Property
  • Method
  • Function
  • Function with type parameter
  • Type alias
  • Class
  • Class with type parameter

Generated using TypeDoc