API Core - v1.5.0
    Preparing search index...

    Class AuthRetryPolicy

    Reactive authentication retry. On an auth-failure status:

    1. Gate the retry via a shared RetryGuard — only one retry per guard window, so a repeatedly-rejected credential doesn't spin forever.
    2. Reauthenticate through the injected hook. The hook returns true if the session was successfully refreshed (token exchange or full resumeSession) and false if it failed.
    3. Replay the original attempt exactly once on a successful reauth. Any other outcome re-throws the original error.

    Ownership: only the injected auth-failure statuses (401 by default; a wire that reports an expired token as 400 passes both). Other HTTP errors, network errors, and anything not from HttpError propagate unchanged so inner / outer policies can handle them in isolation.

    Implements

    Index
    • Builds the policy from its guard, reauth hook and status vocabulary.

      Parameters

      • guard: RetryGuard

        Shared retry-budget limiter.

      • reauthenticate: () => Promise<boolean>

        Hook that refreshes the session; resolves true on success.

      • statuses: readonly number[] = ...

        Auth-failure statuses that trigger the retry; defaults to [401].

      Returns AuthRetryPolicy

    • Whether a rejection is an auth failure this policy owns: an HttpError whose status is in the injected vocabulary. The one read of that vocabulary outside the retry itself — SessionAPI's sign-in normalization consults it so the statuses are spelled once per protocol.

      Parameters

      • error: unknown

        The rejection to inspect.

      Returns error is HttpError

      true for an owned auth failure, narrowing it.

    • Runs the attempt, replaying it once after a successful reauth.

      Type Parameters

      • T

      Parameters

      • attempt: () => Promise<T>

        The request attempt to decorate.

      Returns Promise<T>

      The attempt's resolved value.

      HttpError The original error, when the guard refuses the window or the reauth hook fails (anything not an owned auth failure propagates unchanged).