UNPKG

@auth0/auth0-spa-js

Version:

Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE

49 lines (48 loc) 2.45 kB
export type ResponseHeaders = Record<string, string | null | undefined> | [string, string][] | { get(name: string): string | null | undefined; }; export type CustomFetchMinimalOutput = { status: number; headers: ResponseHeaders; }; export type CustomFetchImpl<TOutput extends CustomFetchMinimalOutput> = (req: Request) => Promise<TOutput>; type AccessTokenFactory = () => Promise<string>; export type FetcherConfig<TOutput extends CustomFetchMinimalOutput> = { getAccessToken?: AccessTokenFactory; baseUrl?: string; fetch?: CustomFetchImpl<TOutput>; dpopNonceId?: string; }; export type FetcherHooks = { isDpopEnabled: () => boolean; getAccessToken: () => Promise<string>; getDpopNonce: () => Promise<string | undefined>; setDpopNonce: (nonce: string) => Promise<void>; generateDpopProof: (params: { url: string; method: string; nonce?: string; accessToken: string; }) => Promise<string>; }; export type FetchWithAuthCallbacks<TOutput> = { onUseDpopNonceError?(): Promise<TOutput>; }; export declare class Fetcher<TOutput extends CustomFetchMinimalOutput> { protected readonly config: Omit<FetcherConfig<TOutput>, 'fetch'> & Required<Pick<FetcherConfig<TOutput>, 'fetch'>>; protected readonly hooks: FetcherHooks; constructor(config: FetcherConfig<TOutput>, hooks: FetcherHooks); protected isAbsoluteUrl(url: string): boolean; protected buildUrl(baseUrl: string | undefined, url: string | undefined): string; protected getAccessToken(): Promise<string>; protected buildBaseRequest(info: RequestInfo | URL, init: RequestInit | undefined): Request; protected setAuthorizationHeader(request: Request, accessToken: string): Promise<void>; protected setDpopProofHeader(request: Request, accessToken: string): Promise<void>; protected prepareRequest(request: Request): Promise<void>; protected getHeader(headers: ResponseHeaders, name: string): string; protected hasUseDpopNonceError(response: TOutput): boolean; protected handleResponse(response: TOutput, callbacks: FetchWithAuthCallbacks<TOutput>): Promise<TOutput>; protected internalFetchWithAuth(info: RequestInfo | URL, init: RequestInit | undefined, callbacks: FetchWithAuthCallbacks<TOutput>): Promise<TOutput>; fetchWithAuth(info: RequestInfo | URL, init?: RequestInit): Promise<TOutput>; } export {};