Line data Source code
1 : import type { AuthHeader } from './authTypes'
2 : import type { RetryPolicy } from './retryPolicy'
3 :
4 : export interface RetrySignalLifecycle {
5 : clearInitialTimeout: () => void
6 : createSignal: () => AbortSignal | undefined
7 : }
8 :
9 : /**
10 : * Credentials and retry policy the API client applies to every request.
11 : * The client itself knows nothing about Firebase or workspace sessions;
12 : * the composition root installs a provider for the current distribution.
13 : */
14 : export interface ApiAuthProvider {
15 : waitForInitialization(): Promise<void>
16 : getAuthHeader(): Promise<AuthHeader | null>
17 : getAuthToken(): Promise<string | undefined>
18 : shouldRetryOn401(): Promise<boolean>
19 : fetch(
20 : input: RequestInfo | URL,
21 : init: RequestInit,
22 : retryOn401: boolean,
23 : retrySignalLifecycle?: RetrySignalLifecycle,
24 : retryPolicy?: RetryPolicy
25 : ): Promise<Response>
26 : }
27 :
28 2356 : export const anonymousApiAuthProvider: ApiAuthProvider = {
29 : waitForInitialization: async () => {},
30 : getAuthHeader: async () => null,
31 : getAuthToken: async () => undefined,
32 : shouldRetryOn401: async () => false,
33 : fetch: (input, init) => fetch(input, init)
34 : }
|