import { type TLSSocket } from 'node:tls'; import { Duplex } from 'node:stream'; export declare const RELAY_PROTOCOL = "vault-relay.v1"; /** DNS SAN every gateway server certificate carries; used when there is no real hostname (relay). */ export declare const GATEWAY_SERVERNAME = "vault-pair-gateway"; /** The Vault relay accepts frames up to 1 MiB; stay well below it. */ export declare const MAX_FRAME_BYTES: number; export type Route = { kind: 'direct'; host: string; port: number; servername: string; } | { kind: 'relay'; relayUrl: string; hostId: string; bearer: () => Promise; servername: string; }; export declare class RelayUnavailableError extends Error { } /** A Duplex over a WebSocket (global WebSocket: Bun, Node >= 22). Resolves once open. */ export declare function websocketDuplex(url: string, protocols: string[], timeoutMs?: number): Promise; export declare function relaySocketUrl(relayUrl: string, path: string): string; /** Opens the raw byte stream to the gateway. */ export declare function openRaw(route: Route): Promise; export type TlsOptions = { servername: string; ca?: string; cert?: string; key?: string; rejectUnauthorized: boolean; }; export declare function openTls(raw: Duplex, options: TlsOptions): Promise; export type WireResponse = { status: number; headers: Record; body: unknown; }; /** Sequential HTTP/1.1 requests (keep-alive) on one stream. */ export declare class HttpSession { private readonly socket; private readonly host; private buffer; private ended; private wake; private failure; constructor(socket: Duplex, host: string); private notify; private more; private take; private line; request(method: 'GET' | 'POST', path: string, options?: { body?: string; headers?: Record; timeoutMs?: number; }): Promise; close(): void; } /** Opens raw stream + TLS and returns an HTTP session plus the peer leaf certificate (DER). */ export declare function openGatewaySession(route: Route, tls: Omit): Promise<{ http: HttpSession; leaf: Buffer | undefined; close: () => void; }>;