/** * TokenFile Authentication - reuse tokens produced by external login tools (e.g., CLIProxyAPI) * * For providers that don't expose public client credentials, we can piggyback on an * external login tool that stores OAuth tokens locally. This auth provider reads * the token JSON and injects `Authorization: Bearer `. * */ import type { IAuthProvider, AuthStatus } from './auth-interface.js'; import type { OAuthAuth } from '../core/api/provider-config.js'; import type { UnknownObject } from '../../modules/pipeline/types/common-types.js'; type TokenPayload = UnknownObject & { access_token?: string; AccessToken?: string; token?: string; api_key?: string; APIKey?: string; apiKey?: string; expires_at?: number | string; ExpiresAt?: number | string; }; export declare class TokenFileAuthProvider implements IAuthProvider { readonly type: "oauth"; private readonly config; private status; private isInitialized; private token; constructor(config: OAuthAuth); initialize(): Promise; buildHeaders(): Record; validateCredentials(): Promise; cleanup(): Promise; getStatus(): AuthStatus; /** * 返回当前缓存的 token 内容快照。 * 会尝试与磁盘上的最新内容同步一次,但不会抛出异常。 * 主要用于需要从 token 中读取附加字段(如 project_id)的 Provider。 */ getTokenPayload(): TokenPayload | null; private pickTokenFileIfItContainsApiKey; private getConfiguredProviderId; private ensureTokenFileExists; private resolveTokenFile; private expandHome; private readJson; private hasAccessToken; private hasApiKey; private extractAccessToken; private extractApiKey; private resolveBearerCredential; private extractExpiresAt; private updateStatus; } export {};