/**
 * ChatGPT / Codex subscription auth: OpenAI device code flow and token management.
 * Uses OpenAI's custom device code flow (NOT RFC 8628).
 * @see https://github.com/sst/opencode (reference implementation)
 *
 * CLIENT_ID: OpenAI's Codex CLI OAuth client (app_EMoamEEZ73f0CkXaXp7hrann).
 * External dependency; changing it may break device flow compatibility.
 */
export interface CodexDeviceFlowResult {
    userCode: string;
    deviceAuthId: string;
    verificationUrl: string;
}
/**
 * Step 1: Request a device code from OpenAI.
 */
export declare function requestCodexDeviceCode(fetchFn?: typeof fetch): Promise<CodexDeviceFlowResult>;
/**
 * Step 2: Poll until user completes authorization. On success, exchanges the
 * authorization code for access + refresh tokens and saves credentials.
 */
export declare function pollForCodexAuthorization(deviceAuthId: string, userCode: string, saveFn: (tokens: CodexTokens) => void, fetchFn?: typeof fetch): Promise<void>;
export interface CodexTokens {
    accessToken: string;
    refreshToken: string | undefined;
    expiresAt: number | undefined;
    accountId: string | undefined;
}
/**
 * Refresh an expired access token using the stored refresh token.
 * Returns the new access token, or null if refresh failed.
 */
export declare function refreshCodexAccessToken(refreshToken: string, fetchFn?: typeof fetch): Promise<CodexTokens | null>;
/**
 * Get a valid access token, refreshing if necessary.
 * Returns {accessToken, accountId} or throws if no valid credential.
 */
export declare function getValidCodexToken(credential: {
    accessToken: string;
    refreshToken?: string;
    expiresAt?: number;
    accountId?: string;
}, onUpdate: (tokens: Partial<CodexTokens>) => void, fetchFn?: typeof fetch): Promise<{
    accessToken: string;
    accountId: string;
}>;
/**
 * Run the full Codex device-flow login: request code, show to user, poll, save.
 * Shared by CLI (cli.tsx) and in-chat UI (codex-login.tsx).
 */
export declare function runCodexLoginFlow(providerName: string, options: {
    onShowCode: (verificationUrl: string, userCode: string) => void;
    onPollingStart?: () => void;
    delayBeforePollMs?: number;
    fetchFn?: typeof fetch;
}): Promise<void>;
//# sourceMappingURL=chatgpt-codex.d.ts.map