Options
All
  • Public
  • Public/Protected
  • All
Menu

Class JwtService<Credentials, AuthResponse, UserInfo, UserId>

Type Parameters

  • Credentials

  • AuthResponse

  • UserInfo

  • UserId = number

Hierarchy

  • JwtService

Index

Constructors

  • new JwtService<Credentials, AuthResponse, UserInfo, UserId>(jwtApi: JwtApi<Credentials, AuthResponse, UserId>, config: JwtConfig<Credentials, AuthResponse, UserInfo, UserId>, noFreshJwtListener: NoFreshJwtListener): JwtService<Credentials, AuthResponse, UserInfo, UserId>

Properties

freshJwt: ((doNotCallNoFreshJwt: boolean) => Observable<undefined | JwtGroup<JwtInfo>>) = ...

Type declaration

    • Refreshes the tokens if needed and emits them as a value. If no fresh tokens available, will emit undefined. The first subscription will call withFreshJwt, but later subscribers will receive the same value.

      Parameters

      • doNotCallNoFreshJwt: boolean

        In most cases is false. If true, NoFreshJwtListener will not be notified about the JWT absence.

      Returns Observable<undefined | JwtGroup<JwtInfo>>

Accessors

  • get isMasterUser(): boolean
  • get loginAsDepth(): number

Methods

  • deleteJwt(): void
  • login(credentials: Credentials): Observable<AuthResponse>
  • loginAs(userId: UserId): Observable<AuthResponse>
  • logout(fromAllDevices?: boolean): Observable<void>
  • withFreshJwt(callback: ((jwt?: JwtGroup<JwtInfo>) => void), callWithFreshOnly?: boolean, doNotCallNoFreshJwt?: boolean): void
  • Refreshes the tokens if needed and calls the callback, when the tokens refreshed successfully. If the tokens are not refreshable, the callback is called without any arguments and the JwtConfig.noFreshJwt is also called

    If you want the callback to be called only with fresh tokens, pass true as the second parameter.

    Parameters

    • callback: ((jwt?: JwtGroup<JwtInfo>) => void)

      The function to be called after JWT were refreshed.

    • Optional callWithFreshOnly: boolean

      If true, the callback will not be called when JWT are not refreshable.

    • Optional doNotCallNoFreshJwt: boolean

      If true, NoFreshJwtListener will not be notified about the JWT absence.

    Returns void

Generated using TypeDoc