import type { MemWalCredentials } from "./auth.js"; export interface LoginOptions { /** Base URL of the dashboard's connect page (must accept `?port=&publicKey=`). */ webUrl?: string; /** Relayer URL the credentials should be configured for. */ relayerUrl?: string; /** Friendly label saved on-chain + in credentials.json — e.g. "Cursor MCP". */ label?: string; /** Abort the flow if no callback received within this many ms. */ timeoutMs?: number; /** Open the URL ourselves vs print it (`false` is useful in headless CI). */ openBrowser?: boolean; /** * Fired exactly once with the fully-built `connectUrl` as soon as the * localhost listener is ready. Lets callers surface the URL through their * own channel (e.g. an MCP `notifications/progress` so the agent shows it * inline) in case `open()` fails or runs in a context where the user * can't see the spawned browser tab. */ onUrl?: (connectUrl: string) => void; freshKey?: boolean; /** When set, `startOrReuseLoginFlow` aborts this listener so a newer * sign-in can mint a key without the old timeout or callback writing * over it. */ signal?: AbortSignal; /** Fired when `freshKey` drops a pending record. The public key is no * longer in the write-ahead file after the replacement is saved. */ onDiscarded?: (key: { publicKey: string; address: string; }) => void; } export declare function isLoginSuperseded(err: unknown): boolean; /** How long the background login listener stays bound, shared by every * caller (auth-required mode and the bridge) so one env var controls the * same deadline everywhere instead of each call site hard-coding its own. * Override via `MEMWAL_MCP_LOGIN_TIMEOUT_MS`, mostly for tests — waiting the * full 5 min to observe a failed sign-in is not a testable deadline. */ export declare function resolveLoginTimeoutMs(): number; /** * Run the login flow. Resolves with saved credentials. Caller is expected * to call this only when no valid credentials exist on disk. */ export declare function loginFlow(opts?: LoginOptions): Promise; export interface InflightLogin { url: Promise; result: Promise; } /** * Start a login flow, or join one already in progress in this process. * Concurrent `memwal_login` calls share the same listener and URL so a * second call cannot race the first and leave the bridge on a stale session. * `onSuccess` and `onFailure` are attached only when this call starts the * flow, so a join cannot emit a second timeout warning. */ export declare function startOrReuseLoginFlow(opts?: LoginOptions, onSuccess?: (creds: MemWalCredentials) => Promise | void, /** Called when the flow fails after the caller has already been handed the * URL and returned. Without this the failure is unobservable — see the * catch below. */ onFailure?: (err: unknown) => void): InflightLogin; /** Drop the in-flight handle and close its listener. A late callback or * timeout on that listener must not save credentials or clear the pending * record a newer login just wrote. */ export declare function resetInflightLogin(): void; //# sourceMappingURL=login.d.ts.map