interface SessionServiceInitializer {
    customHeaders?: Record<string, string | string[]>;
    logger?: Logger;
    onApiError?: ((error, request, attempts) => Promise<boolean>);
    onApiResponse?: ((response) => void);
    onRefreshFailure?: ((error) => void);
    onSessionStateUpdate?: ((state) => void);
}

Properties

customHeaders?: Record<string, string | string[]>

Custom headers that can be passed with axios requests

logger?: Logger

Logger service

onApiError?: ((error, request, attempts) => Promise<boolean>)

Type declaration

    • (error, request, attempts): Promise<boolean>
    • Callback when an api error occurs (useful for logging). Return boolean to retry refresh token.

      Parameters

      • error: NBError
      • request: AxiosRequestConfig<any>
      • attempts: number

      Returns Promise<boolean>

onApiResponse?: ((response) => void)

Type declaration

    • (response): void
    • Callback when an api request returns (usually for testing))

      Parameters

      • response: AxiosResponse<any, any>

      Returns void

onRefreshFailure?: ((error) => void)

Type declaration

    • (error): void
    • Callback when refresh fails (session has expired)

      Parameters

      Returns void

onSessionStateUpdate?: ((state) => void)

Type declaration

    • (state): void
    • Callback when the session changes state (e.g. after a refresh)

      Parameters

      Returns void

Generated using TypeDoc