/** * LAYER-1: TLS enforcement guard — pure decision logic. * * Mirrors `edge-client/src/network/tls_guard.rs`. * * Refuses to connect to a plaintext `ws://` URL when `NODE_ENV=production` * (or `EDGEAI_REQUIRE_TLS=1`). Defense-in-depth: even if an operator * misconfigures the deploy, a mis-pinned cert cannot silently downgrade * to plaintext over the wire. * * Rules: * - `wss://` → Allow (TLS path) * - `ws://` + `NODE_ENV=production` → Refuse (hard fail) * - `ws://` + `EDGEAI_REQUIRE_TLS=1` → Refuse (operator forced TLS) * - `ws://` + dev/test → Allow (dev escape hatch) */ /** Decision for whether the configured URL is acceptable. */ export type TlsGuardDecision = { readonly kind: 'Allow'; } | { readonly kind: 'Refuse'; readonly reason: string; }; /** * Pure decision function. Takes explicit env values (not `process.env`) * so it is race-free to unit-test. * * @param url The relay WebSocket URL. * @param nodeEnv The `NODE_ENV` env value (undefined if unset). * @param requireTls Whether `EDGEAI_REQUIRE_TLS=1` is set. */ export declare function decideTls(url: string, nodeEnv: string | undefined, requireTls: boolean): TlsGuardDecision; /** * Convenience wrapper that reads `process.env`. Mirrors Rust `decide_tls(url)`. */ export declare function decideTlsFromEnv(url: string): TlsGuardDecision;