/** * One desktop connection to the box session host. * * The host listens on the box's loopback address, which the desktop app reaches * through the Outpost's private port-forward. On the Mac that forward is a * localhost port, and a web page in a browser can send requests to localhost * too — so the protocol is deliberately not HTTP, and the very first line has * to be a JSON hello carrying the person's HQ sign-in. A browser's request * cannot be that, and neither can anything else that wanders in: the connection * is answered with one error and closed, before any session is touched. * * Once signed in, a single connection can drive several sessions at once, and * dropping it never stops one — the Mac reconnects and asks for everything * after the last message it saw. */ import type { VerifyToken } from "./session-host-auth.js"; import type { SessionManager } from "./session-host-sessions.js"; export interface ConnectionPort { write(line: string): void; close(): void; /** Bytes written but not yet taken by the peer. */ pendingBytes(): number; } export interface ConnectionDeps { sessions: SessionManager; verifyToken: VerifyToken; /** Only this person's sign-in may drive sessions on this box. */ ownerSub: string; hostName: string; version: string; helloTimeoutMs?: number; /** Before the hello, a peer is held to a line barely larger than a token. */ maxPreAuthLineBytes?: number; maxLineBytes?: number; maxPendingBytes?: number; log?: (line: string) => void; } export interface Connection { push(chunk: Buffer): void; /** The peer went away. Sessions keep running. */ end(): void; } export declare function handleConnection(port: ConnectionPort, deps: ConnectionDeps): Connection; //# sourceMappingURL=session-host-connection.d.ts.map