export type Environment = 'production' | 'stage' | 'development'; interface UserData { id: string; email: string; name?: string; } interface EnvironmentConfig { authUrl: string; apiUrl: string; storeDomain: string; clientId: string; } export declare const ENV_CONFIG: Record; /** * 直接从 token.json 读取 access_token,绕过 OPTIMA_TOKEN 环境变量 * 用于 401 重试时获取由 ws-bridge 本地写入的最新 token */ export declare function getTokenFromFile(): string | null; /** * 获取当前环境 * 优先级:OPTIMA_ENV 环境变量 > token.json 的 env 字段 > 默认 production */ export declare function getCurrentEnvironment(): Environment; /** * 获取当前环境的配置信息 */ export declare function getCurrentEnvConfig(): EnvironmentConfig; /** * 保存认证令牌 */ export declare function saveTokens(access_token: string, refresh_token: string, expires_in: number, env: Environment, user?: UserData): void; /** * 获取访问令牌 * 容器环境:优先 token.json(ws-bridge 实时更新)> OPTIMA_TOKEN 环境变量(spawn 时快照,可能过期) * 本地环境:优先 OPTIMA_TOKEN 环境变量 > token.json */ export declare function getAccessToken(): string | null; /** * 获取 token 过期时间 */ export declare function getTokenExpiresAt(): number | null; /** * 检查 token 是否过期 */ export declare function isTokenExpired(): boolean; /** * 检查是否已认证(不检查过期) */ export declare function isAuthenticated(): boolean; /** * 确保有效的访问令牌 * 容器环境:优先 token.json(ws-bridge 实时更新),env var 作为 fallback * 本地环境:优先 OPTIMA_TOKEN 环境变量(跳过过期检查),否则读 token.json * @returns 有效的访问令牌,如果无法获取则返回 null * @throws AuthenticationError 当 token 过期时 */ export declare function ensureValidToken(): Promise; /** * 保存用户信息到 token.json */ export declare function saveUser(user: UserData): void; /** * 获取当前用户信息 */ export declare function getUser(): UserData | null; /** * 清除配置(登出)- 删除 token.json */ export declare function clearConfig(): void; /** * 获取配置文件路径 */ export declare function getConfigPath(): string; /** * 获取 Commerce API URL * 优先级:环境变量 > 当前环境配置 */ export declare function getApiUrl(): string; /** * 获取 Auth API URL * 优先级:环境变量 > 当前环境配置 */ export declare function getAuthUrl(): string; /** * 获取店铺前端域名 */ export declare function getStoreDomain(): string; export {}; //# sourceMappingURL=config.d.ts.map