UNPKG

@arizeai/phoenix-client

Version:
30 lines 1.38 kB
export interface AuthFetchOptions { /** * Return an access token for a request. * * When `forceRefresh` is true, the previous token was rejected with a 401 * and the provider should refresh it before returning. Providers own token * storage and refresh-token rotation. */ getAccessToken: (options: { forceRefresh: boolean; }) => string | Promise<string>; /** Fetch implementation used to send requests. Defaults to global fetch. */ fetch?: typeof fetch; /** Called when the request is still unauthorized after one refresh. */ onUnauthorized?: (response: Response) => void | Promise<void>; } /** * Create a fetch implementation that supplies a bearer token and refreshes it * after a 401 response. * * Refresh calls are coalesced so concurrent unauthorized requests rotate a * refresh token only once. Each request is retried at most once. * * @param options - Authentication behavior for the fetch implementation. * @param options.getAccessToken - Returns the current token or refreshes it. * @param options.fetch - Fetch implementation used to send requests. * @param options.onUnauthorized - Handles a second unauthorized response. */ export declare function createAuthFetch({ getAccessToken, fetch: fetchImpl, onUnauthorized, }: AuthFetchOptions): typeof fetch; //# sourceMappingURL=authFetch.d.ts.map