Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface JwtConfig<Credentials, AuthResponse, UserInfo, UserId>

Main configuration object. Describes, how to retrieve JWT, UserInfo, what to do when JWTs are invalid, how JwtGuard will handle routes.

Type Parameters

  • Credentials

  • AuthResponse

  • UserInfo

  • UserId = number

Hierarchy

  • JwtConfig

Index

Properties

actionToWaitUntilAuth?: ActionCreator<string, Creator<any[], object>>

If provided, no calls to the JwtApi.login will be made, until the action is dispatched. The action is expected to come after dispatching login action of this package. Used to wait until, for example, the socket is open, if the auth request is supposed to be sent through the socket.

authHeader: { name: string; createValue: any }

Used by the JwtInterceptor http interceptor to set the auth header with jwt pinned for every request.

Type declaration

excludeUrls?: (string | RegExp)[]

Urls, which will not be intercepted. If string, the url should start with that string to be excluded. If RegExp, the url will be tested with .match and excluded if matches.

jwtApi: JwtApiConstructor<Credentials, AuthResponse, UserId>

Provides methods to interact with backend. Must implement JwtApi.

jwtGuard?: { actionAppNotReady?: ActionCreator<string, Creator<any[], object>>; actionAppReady?: ActionCreator<string, Creator<any[], object>>; jwtToCredentials: any }

if set, the JwtGuard, used to restrict access for unauthorized users, will be provided and available to be used in the routing. To implement redirection, when no JWT available, use noFreshJwt field of this config.

Type declaration

  • Optional actionAppNotReady?: ActionCreator<string, Creator<any[], object>>

    The action on which navigation will be cancelled. The default is loginAgainErrored.

  • Optional actionAppReady?: ActionCreator<string, Creator<any[], object>>

    The action on which navigation will be continued. The default is loginAgainSucceed.

  • jwtToCredentials:function
    • jwtToCredentials(jwt: JwtInfo): Credentials
jwtStorageKey?: string

the key to be used in the localStorage.

noFreshJwt: { callWhen: { guardNotFoundJwt: boolean; interceptorNotFoundJwt: boolean; loginAsJwtNotFound: boolean }; service: NoFreshJwtListenerConstructor }

Used to start actions, when refresh jwt failed. Usually you want to redirect user to the login page.

Type declaration

  • callWhen: { guardNotFoundJwt: boolean; interceptorNotFoundJwt: boolean; loginAsJwtNotFound: boolean }

    If all fields are false, NoFreshJwtListener is never called. If you want to navigate to the auth page every time a JWT needed, but there was none, set all fields to true.

    • guardNotFoundJwt: boolean
    • interceptorNotFoundJwt: boolean
    • loginAsJwtNotFound: boolean
  • service: NoFreshJwtListenerConstructor

Methods

  • authResponseToJwt(authResponse: AuthResponse): undefined | JwtGroup<JwtInfo>
  • authResponseToUserInfo(authResponse: AuthResponse): UserInfo

Generated using TypeDoc