import type { AxiosRequestConfig } from "axios"; import type { AuthStorage, AuthStorageOptions, AuthEventBus, AuthEventMap as SharedAuthEventMap } from "@jt-home/jt-auth-tools"; export interface RefreshTokenResult { accessToken: string; refreshToken?: string; expiresIn?: number; [key: string]: unknown; } export type LocalStorageAuth = AuthStorage; export type LocalStorageAuthOptions = AuthStorageOptions; export type PathPattern = string | RegExp; export interface WhitelistConfig { noTokenPaths?: PathPattern[]; skipRefreshPaths?: PathPattern[]; } export interface CustomAxiosRequestConfig extends AxiosRequestConfig { /** * 标记当前请求走子应用本地 dev server 代理。 * 只影响本次请求,不改变实例默认 baseURL。 */ local?: boolean; /** * 单次请求覆盖本地代理 origin,例如 http://localhost:9000。 * 这里指向子应用 dev server,不直接指向后端本地服务。 * 后端本地地址由子应用自己的 Vite proxy 或 Nginx 配置维护。 */ localApi?: string; skipTokenRefresh?: boolean; _loginExpiredRetried?: number; _localProxyApplied?: boolean; } export interface CreateAxiosConfig extends AxiosRequestConfig, WhitelistConfig { getToken?: () => string | null; setToken?: (token: string) => void; getRefreshToken?: () => string | null; setRefreshToken?: (token: string) => void; clearAuth?: () => void; loginExpiredCodes?: (number | string)[]; /** * 默认本地代理 origin,例如 http://localhost:9000。 * 这里是微前端子应用本地 dev server 地址,不是后端本地服务地址。 */ localProxyOrigin?: string; /** * 子应用 dev server 上配置的 proxy 匹配入口,默认 /api-local。 * sdk-tools 只负责把 local 请求打到这个入口;真实 target 和 rewrite * 由子应用自己的 proxy 配置决定。 */ localProxyPrefix?: string; } export interface CreateAxiosInstance { on(event: "auth:token-changed", handler: (token: string | null) => void): () => void; on(event: "auth:user-info-changed", handler: (userInfo: unknown) => void): () => void; on(event: "auth:unauthorized", handler: (message?: string) => void): () => void; on(event: "auth:forbidden", handler: (message?: string) => void): () => void; off?(event: "auth:token-changed", handler: (token: string | null) => void): void; off?(event: "auth:user-info-changed", handler: (userInfo: unknown) => void): void; off?(event: "auth:unauthorized", handler: (message?: string) => void): void; off?(event: "auth:forbidden", handler: (message?: string) => void): void; bus?: AuthEventBus; } export type AuthEventMap = SharedAuthEventMap; //# sourceMappingURL=types.d.ts.map