API Core - v2.4.1
    Preparing search index...

    Class AuthRetryPolicy

    Unit of cross-cutting resilience logic around a request attempt.

    Each policy owns exactly one concern (rate-limiting, auth retry, transient-error retry…) and wraps the caller's attempt with its own semantics. Policies are composed via CompositePolicy to build the request pipeline declaratively; a consumer with a shorter chain may also nest run calls directly.

    Implementations MUST:

    • run the caller's attempt at most once per run invocation per success path (retries are explicit loops the policy owns);
    • propagate errors they don't own — a policy handles only the concern it was built for; anything else flows through untouched;
    • be stateless across run calls (shared state — guards, gates — goes through constructor injection so it's visible + swappable).

    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.

      • vocabulary: AuthFailureVocabulary | readonly number[] = ...

        The auth-failure statuses that trigger the retry ([401] by default), or the statuses with a refinement that narrows them by the response itself.

      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).