import type { DeviceCodeResult, DeviceTokenResult } from "./types.js"; export interface LoginResult { token: string; expires_at: number; email: string; } /** 32 hex chars of randomness, round-tripped through the callback URL to guard against a * mismatched or stale request hitting the local server. */ export declare function randomState(): string; /** Builds the browser login URL. `claim` (the local trial key's account_id, when one exists) * tells the server which trial account to attach the confirmed email to. */ export declare function buildLoginUrl(site: string, port: number, state: string, claim?: string): string; /** Best-effort opens `url` in the user's default browser. Never throws; the URL is always * printed too, so a failure here is silently harmless. */ export declare function openBrowser(url: string): void; export interface CallbackServerHandle { port: number; /** Resolves with the login result on a matching callback; rejects on a state mismatch, a * malformed callback, or the timeout. */ result: Promise; close: () => Promise; } /** Starts a localhost-only HTTP server on an OS-assigned port. Resolves once listening; the * returned `result` promise settles when GET /callback arrives (or the timeout elapses). The * server closes itself after handling one request, success or failure. */ export declare function startCallbackServer(opts: { state: string; timeoutMs: number; }): Promise; export interface RunBrowserLoginOptions { site: string; claim?: string; openInBrowser: boolean; timeoutMs: number; write: (s: string) => void; } /** Runs the full browser-callback flow: start the local server, print (and try to open) the * login URL, then wait for the callback. */ export declare function runBrowserLogin(opts: RunBrowserLoginOptions): Promise; /** The subset of VeezeeClient that device login needs; lets tests pass a fake client. */ export interface DeviceLoginClient { createDeviceCode(): Promise; pollDeviceToken(args: { device_code: string; }): Promise; } export interface RunDeviceLoginOptions { write: (s: string) => void; sleep: (ms: number) => Promise; } /** Runs the headless device-code flow (gh-style): print the code and verification URL, then * poll until "complete". Honors the server's advertised poll interval and backs off on * RATE_LIMITED using its retry_after_seconds. */ export declare function runDeviceLogin(client: DeviceLoginClient, opts: RunDeviceLoginOptions): Promise;