Options
All
  • Public
  • Public/Protected
  • All
Menu

Tracks the Authentication State for the SDK

Hierarchy

  • AuthState

Index

Constructors

constructor

  • new AuthState(authokClient: default): AuthState

Properties

Readonly error$

error$: Observable<Error> = ...

Emits errors that occur during login, or when checking for an active session on startup.

Readonly idTokenClaims$

idTokenClaims$: Observable<undefined | null | IdToken> = ...

Emits ID token claims when authenticated, or null if not authenticated.

Readonly isAuthenticated$

isAuthenticated$: Observable<boolean> = ...

Emits boolean values indicating the authentication state of the user. If true, it means a user has authenticated. This depends on the value of isLoading$, so there is no need to manually check the loading state of the SDK.

Readonly isLoading$

isLoading$: Observable<boolean> = ...

Emits boolean values indicating the loading state of the SDK.

Readonly user$

user$: Observable<undefined | null | User> = ...

Emits details about the authenticated user, or null if not authenticated.

Methods

refresh

  • refresh(): void
  • Refresh the state to ensure the isAuthenticated, user$ and idTokenClaims$ reflect the most up-to-date values from AuthokClient.

    Returns void

setAccessToken

  • setAccessToken(accessToken: string): void
  • Update the access token, doing so will also refresh the state.

    Parameters

    • accessToken: string

      The new Access Token

    Returns void

setError

  • setError(error: any): void
  • Emits the error in the error$ observable.

    Parameters

    • error: any

      The new error

    Returns void

setIsLoading

  • setIsLoading(isLoading: boolean): void
  • Update the isLoading state using the provided value

    Parameters

    • isLoading: boolean

      The new value for isLoading

    Returns void