Interface RequestAuthenticator

Request Authenticator

interface RequestAuthenticator {
    authenticate: (
        request: RequestInfo,
        response?: Response,
        options?: RequestInit,
    ) => Promise<boolean>;
    isAuthenticated: (response: Response) => Promise<boolean>;
    maxTries?: number;
    preAuthenticate?: (
        request: RequestInfo,
        options?: RequestInit,
    ) => Promise<Request>;
}

Properties

authenticate: (
    request: RequestInfo,
    response?: Response,
    options?: RequestInit,
) => Promise<boolean>

Authenticate

This function is used to request authentication. This is where the authentication mechanism is handled.

Type declaration

    • (
          request: RequestInfo,
          response?: Response,
          options?: RequestInit,
      ): Promise<boolean>
    • Parameters

      • request: RequestInfo
      • Optionalresponse: Response
      • Optionaloptions: RequestInit

      Returns Promise<boolean>

      true if authentication was successful

isAuthenticated: (response: Response) => Promise<boolean>

Is Authenticated

This function checkes the response and should determine if the response is returning an authentication fault

Type declaration

    • (response: Response): Promise<boolean>
    • Parameters

      • response: Response

        Response that authentication test should be ran against

      Returns Promise<boolean>

true if the response is already authenticated

maxTries?: number

Maximum Tries

Number of failed authentication attempts before giving up.

3
preAuthenticate?: (
    request: RequestInfo,
    options?: RequestInit,
) => Promise<Request>

Pre-Authenticate

This optional function is used to pre authenticate a request. For example in the case the request is authenticated via a token.

Type declaration

    • (request: RequestInfo, options?: RequestInit): Promise<Request>
    • Parameters

      • request: RequestInfo

        to pre authenticate

      • Optionaloptions: RequestInit

      Returns Promise<Request>

      Pre authenticated Request Object