import type { OAuthRefreshReason } from "../../auth/types.js"; import type { OAuthCredentials, OAuthProvider, OAuthProviderId, OAuthProviderInfo, OAuthProviderInterface } from "./types.js"; export * from "./anthropic.js"; export * from "./device-code.js"; export type * from "./types.js"; /** * Counter that moves whenever which providers are paused may have changed: the * unpaused list, or an extension login taking or releasing a paused id. Caches * that filter on {@link providerPauseReason} compare it to know when to refilter. */ export declare function providerPauseRevision(): number; /** * Turns paused providers back on: each listed id ignores its `disabled ""` * auth rule, so it is a login choice again and its stored or env credentials resolve. * Replaces the previous list; ids that are not paused are ignored. Loaded credential * pools pick the change up on their next read. */ export declare function setUnpausedProviders(providers: Iterable): void; /** * Register a custom OAuth provider. */ export declare function registerOAuthProvider(provider: OAuthProviderInterface): void; /** * Remove a custom OAuth provider by ID. */ export declare function unregisterOAuthProvider(id: string): void; /** * Get a custom OAuth provider by ID. */ export declare function getOAuthProvider(id: OAuthProviderId): OAuthProviderInterface | undefined; /** * Why `provider` is paused by its auth rules (`disabled ""`), or * undefined when it may be reached. An extension that registers its own OAuth * login under the paused id, or listing it in {@link setUnpausedProviders}, * takes the id back: that is the end user's choice. */ export declare function providerPauseReason(provider: string): string | undefined; /** Throws {@link AIError.ProviderDisabledError} when {@link providerPauseReason} pauses `provider`. */ export declare function assertProviderEnabled(provider: string): void; /** * The account risk a new built-in login of `provider` must accept first * (`login-warning ""`), or undefined. An extension that registers its * own OAuth login under the id owns that prompt instead. */ export declare function loginRiskWarning(provider: string): string | undefined; /** * Remove all custom OAuth providers registered by a source. */ export declare function unregisterOAuthProviders(sourceId: string): void; /** * Refresh a built-in OAuth grant, cancelling provider work when refresh ownership ends. */ export declare function refreshOAuthToken(provider: OAuthProviderId, credentials: OAuthCredentials, signal?: AbortSignal, reason?: OAuthRefreshReason): Promise; /** * Refresh `credentials` through the login that owns `provider`: an extension's registered * OAuth provider, else the built-in one ({@link refreshOAuthToken}). This is the local token * exchange AuthStorage runs when no store or caller refresh hook owns the credential. */ export declare function refreshProviderOAuthToken(provider: OAuthProviderId, credentials: OAuthCredentials, signal?: AbortSignal, reason?: OAuthRefreshReason): Promise; export declare function normalizeOAuthCredentialExpiry(provider: string, credentials: T): T; /** * Build API-key bytes for a provider from an already-fresh OAuth credential. * * Refresh is owned by AuthStorage. This helper deliberately refuses expired * credentials so it cannot POST broker redaction sentinels to upstream token * endpoints as a side channel. * * For providers that need credential metadata at request time, returns * JSON-encoded credentials plus expiry metadata for diagnostics/edge guards. * @returns API key string, or null if no credentials * @throws Error if the credential is expired and must be refreshed upstream */ export declare function getOAuthApiKey(provider: OAuthProvider, credentials: Record): Promise<{ newCredentials: OAuthCredentials; apiKey: string; } | null>; /** * Get list of OAuth providers. */ export declare function getOAuthProviders(): OAuthProviderInfo[]; /** Provider id that stores `providerId`'s credentials: login aliases (`openai-codex-device`) map to their target (`openai-codex`). */ export declare function getOAuthCredentialProvider(providerId: string): string;