import { AxiosError, AxiosInstance } from "axios"; //#region src/authenticate-interceptor/index.d.ts type AuthenticateInterceptorOptions = { /** 重新授权, 一般实现是跳转到登录页面 */ doReAuthenticate: (error: AxiosError) => Promise; /** 是否开启 token 刷新功能 */ enableRefreshToken: boolean; /** 刷新 token, 一般实现是调用后端接口刷新 token。如果失败,建议抛出异常,这样会触发 doReAuthenticate */ doRefreshToken?: (error: AxiosError) => Promise; /** 判断是否登录失效,默认: 判断 401 状态码 */ isAuthenticateFailed?: (error: AxiosError) => boolean; }; declare module "axios" { interface AxiosRequestConfig { /** [createAuthenticateInterceptor] 标识请求是否已经重试过(防止刷新成功后再次重放原请求:如果后端仍返回 401,会再次触发刷新逻辑 → 死循环). 请不要手动设置这个属性!!!这个属性由拦截器内部设置 */ __retry__?: boolean; } } /** * 授权失效-响应拦截器 * @param axiosInstance axios 实例 * @param options 拦截器配置 * @returns 响应拦截器 ID, 用于移除拦截器 */ declare function createAuthenticateInterceptor(axiosInstance: AxiosInstance, { doReAuthenticate, doRefreshToken, enableRefreshToken, isAuthenticateFailed }: AuthenticateInterceptorOptions): number; //#endregion export { AuthenticateInterceptorOptions, createAuthenticateInterceptor as createAuthenticateInterceptor$1 }; //# sourceMappingURL=index-DFfSw5xn.d.ts.map