Function finAuthFetch

  • An enhanced fetch API for a pluggable authentication mechanism.

    Transparently handles pre-authentication, authentication fault detection, authentication, and will replay the requested resource upon successful authentication.

    By default, this fetch function will utilize the finCsrfFetch function internally to execute the request.

    For example...

    const result = finAuthFetch(request, {
    authenticator: {
    isAuthenticated: (response: Response) => response.status !== 401,
    preauthenticate: async (request: RequestInfo) => new Request(request, {headers: {auth_header: '12345'}}),
    authenticate: (response: Response) => return execute_authentication(username, password),
    maxTries: 3
    }
    })

    Parameters

    • resource: RequestInfo

      The resource to request.

    • Optionaloptions: RequestInit | RequestInitAuth

      Optional object containing custom settings and the authenticator.

    Returns Promise<Response>

    A promise that resolves to a response object.