/** * Launched-server identity check * Issue #3087: `remote` published whatever answered on the port * * A TCP connect only proves that SOMETHING listens. In #3087 an orphaned server from an * earlier `start --daemon` (no authentication) kept the port, the server `remote` launched * died on EADDRINUSE, and `remote` put the orphan behind a public tunnel. * * Before anything is published, this asks the endpoint two questions over plain HTTP(S): * * 1. A request carrying a token nobody holds must be refused with 401. Anything else means * authentication is off (or the answer is not CommandMate's middleware), so the server * would be reachable without pairing. * 2. A request carrying the session token `remote` minted moments ago must succeed. Only * the server launched with that token's hash can accept it, so this proves the listener * is the one this invocation started — no new API route or nonce is needed. * * Question 1 is asked first so the session token is never sent to a server already shown to * be the wrong one. Every outcome that is not a clear "yes" to both is a refusal (fail-closed); * only connection errors and 5xx (a server still warming up) are retried until the deadline. * * @module server-identity */ /** Path probed: authenticated like every API route, and it reads nothing (Issue #1925). */ export declare const IDENTITY_PROBE_PATH = "/api/capabilities"; export declare const DEFAULT_IDENTITY_TIMEOUT_MS = 30000; export declare const DEFAULT_IDENTITY_INTERVAL_MS = 300; export interface VerifyLaunchedServerOptions { protocol: 'http' | 'https'; host: string; port: number; /** Plaintext session token whose hash the launched server was given */ sessionToken: string; timeoutMs?: number; intervalMs?: number; } export type LaunchedServerVerdict = { ok: true; } | { ok: false; reason: string; }; /** * Verify that the endpoint is the authenticated server this invocation launched. * * @returns `{ ok: true }` only when an unknown token is refused with 401 AND the session * token is accepted; otherwise `{ ok: false, reason }`. Never throws. */ export declare function verifyLaunchedServer(options: VerifyLaunchedServerOptions): Promise; //# sourceMappingURL=server-identity.d.ts.map