1 import { getUIDHeaderValue, withAuthHeaders, withUIDHeaders } from '@proton/shared/lib/fetch/headers';
3 import type { Api } from '../../interfaces';
5 export const getSilentApi = (api: Api) => {
6 return <T>(config: any) => api<T>({ ...config, silence: true });
9 export const getApiWithAbort = (api: Api, signal: AbortSignal) => {
10 return <T>(config: any) => api<T>({ ...config, signal });
13 export const getSilentApiWithAbort = (api: Api, signal: AbortSignal) => {
14 return <T>(config: any) => api<T>({ ...config, signal, silence: true });
17 export const getUIDApi = (UID: string, api: Api) => {
18 return <T>(config: any) => {
19 // Note: requestUID !== UID means that this config is already set with a UID, so ignore the original one.
20 const requestUID = getUIDHeaderValue(config.headers) ?? UID;
21 if (requestUID !== UID) {
24 return api<T>(withUIDHeaders(UID, config));
28 export const getAuthAPI = (UID: string, AccessToken: string, api: Api) => {
29 return <T>(config: any) => api<T>(withAuthHeaders(UID, AccessToken, config));