@contentauth/c2pa-js
    Preparing search index...

    Interface TrustFetchOptions

    Options for resolving trust-resource URLs in a Context.

    In-flight request sharing is enabled by default. Completed responses are not cached. HTTP URLs remain accepted by default for compatibility; set requireHttps to reject them and all redirects.

    interface TrustFetchOptions {
        deduplicateInFlight?: boolean;
        fetch?: (input: string, init?: RequestInit) => Promise<Response>;
        initialRetryDelayMs?: number;
        isRetryableError?: (error: unknown) => boolean;
        isRetryableStatus?: (status: number) => boolean;
        maxResponseBytes?: number;
        maxRetries?: number;
        maxRetryAfterMs?: number;
        maxRetryDelayMs?: number;
        requireHttps?: boolean;
        signal?: AbortSignal;
    }

    Hierarchy (View Summary)

    Index

    Properties

    deduplicateInFlight?: boolean

    Share a pending request for the same URL and fetch policy when using the global fetch. Defaults to true; custom fetch implementations are always isolated.

    fetch?: (input: string, init?: RequestInit) => Promise<Response>

    The underlying fetch implementation to use. Defaults to the global fetch when omitted. Useful for dependency injection, such as wrapping another HTTP client's own request pipeline (like wretch middleware's next, or a test mock). Trust-resource resolution does not deduplicate calls with a custom implementation: a wrapper's request context may change without changing its function identity.

    initialRetryDelayMs?: number

    Initial delay, in milliseconds, before the first retry's exponential backoff. Zero removes the exponential component (jitter still applies). Defaults to DEFAULT_INITIAL_RETRY_DELAY_MS when omitted.

    isRetryableError?: (error: unknown) => boolean

    Predicate contributing to decision on whether a given network error (thrown by the underlying fetch call) should be retried.

    Defaults to always retrying when omitted. Regardless of this predicate, an AbortError is never retried, since retrying a deliberate cancellation is never correct.

    isRetryableStatus?: (status: number) => boolean

    Predicate contributing to decision on whether a given HTTP response status should be retried. Defaults to defaultIsRetryableStatus (429 or any 5xx) when omitted.

    maxResponseBytes?: number

    Maximum allowed response size, in bytes, for fetchWithRetry's text response. Zero permits only an empty response. Defaults to DEFAULT_MAX_RESPONSE_BYTES when omitted. Not enforced by fetchWithRetryRaw.

    maxRetries?: number

    Maximum number of retry attempts for a retryable network error or HTTP response. Must be a safe integer. Zero disables retries; infinity is not supported. Defaults to DEFAULT_MAX_RETRIES when omitted.

    maxRetryAfterMs?: number

    Maximum Retry-After delay, in milliseconds, that will be honored. A Retry-After value exceeding this throws immediately rather than waiting. Defaults to DEFAULT_MAX_RETRY_AFTER_MS when omitted. Zero rejects positive delays.

    maxRetryDelayMs?: number

    Maximum delay, in milliseconds, that the exponential backoff (before jitter) can reach. Zero disables backoff delays, including jitter. Defaults to DEFAULT_MAX_RETRY_DELAY_MS when omitted.

    requireHttps?: boolean

    Reject non-HTTPS trust-resource URLs and all redirects. Defaults to false. Uses Fetch's redirect: 'error' mode to prevent HTTPS-to-HTTP downgrades before contacting the redirect target. Custom fetch implementations must honor this mode.

    signal?: AbortSignal

    Optional cancellation signal. Aborting it cancels the request and any pending retry delay.