import { type ClaudeInvoker } from '../invoker.js'; export type AuthorizeOutcome = 'authorized' | 'left-open' | 'failed'; /** Abstracts the browser step so login orchestration is testable without Chrome. */ export interface BrowserAuthorizer { authorize(input: { url?: string; email?: string; debugPort: number; }): Promise; } /** A running `claude auth login` process, abstracted for testability. */ export interface AuthLoginProcess { /** The auth URL printed early, or undefined if the CLI auto-opens the browser. */ urlHint(): Promise; /** The process exit code once the login completes. */ done(): Promise; /** Stop the process. Called when the wait is given up on. */ cancel?: () => void; } export type StartAuthLogin = (invoker: ClaudeInvoker, args: string[], env: NodeJS.ProcessEnv) => AuthLoginProcess; export interface LoginDeps { claude: ClaudeInvoker; browser: BrowserAuthorizer; startAuthLogin: StartAuthLogin; debugPort: number; /** Told what is happening while the login runs, so the person is not left guessing. */ notify?: (message: string) => void; /** * Fingerprint of the login stored for an account, for telling whether the * sign-in actually produced a new one. Injected for tests. */ fingerprint?: (dir: string) => string | null; /** * How long to wait for the sign-in before giving up. Generous, because a real * one goes through a browser at human speed, but not unbounded: a sign-in * nobody finishes used to hold the caller forever, and the dashboard hands its * screen away while it waits. */ timeoutMs?: number; } export interface LoginAccountInput { name: string; dir: string; email?: string; } export interface LoginResult { account: string; ok: boolean; detail: string; } /** * Orchestrate a single account login: start `claude auth login`, drive the * browser to click Authorize, then wait for the login process to finish. The * browser and process are injected so this decision logic is fully testable * without a real Chrome or a real login. */ export declare function loginAccount(account: LoginAccountInput, deps: LoginDeps): Promise; /** Generous: a real sign-in goes through a browser at human speed. */ export declare const DEFAULT_LOGIN_TIMEOUT_MS: number;