import { FetchRetrierInterface } from './fetch-retry/fetch-retrier'; import type { FetchHandlerInterface } from './fetch-handler-interface'; import type { ApiFetchOptions, FetchOptions } from './fetch-options'; export type FetchHandlerConstructorOptions = { /** @deprecated Use `apiBaseUrl` instead. */ iaApiBaseUrl?: string; apiBaseUrl?: string; fetchRetrier?: FetchRetrierInterface; searchParams?: string; /** * Optional CSRF token source. When provided, callers can opt individual * `POST`/`PUT`/`DELETE` requests into an automatic `X-CSRF-Token` header * by passing `includeCsrfToken: true` (see `ApiFetchOptions`/ * `FetchOptions`). Requests that don't opt in are unaffected — this is * off by default because not every backend endpoint's CORS policy * allow-lists that header yet. */ getCsrfToken?: () => Promise; }; /** * The FetchHandler adds some common helpers: * - retry the request if it fails * - add `reCache=1` to the request if it's in the current url so the backend sees it * - add convenience method for fetching/decoding an API response by just the path */ export declare class FetchHandler implements FetchHandlerInterface { private apiBaseUrl; private fetchRetrier; private searchParams?; private getCsrfToken?; constructor(options?: FetchHandlerConstructorOptions); /** @inheritdoc */ fetch(request: RequestInfo, options?: RequestInit | FetchOptions): Promise; /** @inheritdoc */ fetchApiResponse(url: string, options?: ApiFetchOptions): Promise; /** @inheritdoc */ fetchApiPathResponse(path: string, options?: ApiFetchOptions): Promise; /** @inheritdoc */ fetchIAApiResponse(path: string, options?: ApiFetchOptions): Promise; /** * If a CSRF token source was configured, the caller opted in via * `includeCsrfToken: true`, and the request method needs one, resolve the * token and attach it as an `X-CSRF-Token` header. Off by default: not * every backend endpoint's CORS policy allow-lists that header yet, so * each caller opts in only once its endpoint is known to support it. * Requests that already carry that header are left untouched. * * @param request - The request being made, used to infer the method * @param options - The options passed in to `fetch` * @returns Options with the CSRF header attached, or the original options */ private withCsrfToken; /** * Construct a new URL with the given search params added * * Works on the URL string rather than parsing it into a `URL`, so a * base-relative or scheme-relative input (`/services/foo`, * `www.example.com/foo`) comes back in the form it went in instead of being * resolved against the current page. * * @param urlString - Original URL string * @param params - Params to add, replacing any of the same name already on the URL * @returns New URL string with params added */ private addSearchParams; /** * Normalize the record form of `QueryParams` into `URLSearchParams`, * dropping `undefined`/`null` values so callers can pass optional params * without guarding each one. * * @param params - Params in either accepted form * @returns The params as `URLSearchParams` */ private static asSearchParams; } /** * Backwards compatibility class * * @deprecated Use `FetchHandler` instead. */ export declare class IaFetchHandler extends FetchHandler { constructor(options?: FetchHandlerConstructorOptions); }