/** * Default edge relay addresses (fallback when WASM is not available or fails) * Prefer DNS-based addresses for production deployments. * IP addresses should only be used for development/testing. */ export declare const SPACEAWARE_RELAY_PEER_ID = "16Uiu2HAm1LbvwjEHW2GDP2ZQZvwHLZrz2jbYoRLQmJEQ3wZ5Fm45"; /** * The celestrak.eth ingest node (host-02). Promoted to a browser-dialable * bootstrap on 2026-08-06 (owner ruling, graph task * `ops-host02-browser-relay-promotion`) because the fleet advertised exactly * ONE CA-authenticated browser-dialable address and this list could not * honestly hold a second one. */ export declare const CELESTRAK_RELAY_PEER_ID = "16Uiu2HAmGjaPxkWFSXBbmhs9K5x1Zo6euJw95VjS6Jj2bcPpYr2U"; export declare const DEFAULT_EDGE_RELAYS: string[]; /** * Fallback relays for regional availability */ export declare const REGIONAL_FALLBACK_RELAYS: Record; /** * True when a multiaddr pins a self-signed certificate hash, which is * guaranteed to rot in a shipped browser bundle. */ export declare function pinsCerthash(addr: string): boolean; /** * True when a multiaddr is dialable from a browser on an HTTPS origin: it must * be authenticated by the public web PKI (/wss or /tls/ws on a DNS name, which * covers AutoTLS libp2p.direct addresses) or carry its own certificate hash * (webrtc-direct / webtransport), which is only acceptable when freshly * resolved. Plain /ws is excluded: an HTTPS page cannot open an insecure * WebSocket (mixed content), which is exactly why browsers were left with only * a relayed/transient connection to the full node. */ export declare function isBrowserDialableAddr(addr: string): boolean; /** * Rank bootstrap addresses best-first for a browser: * 1. CA-authenticated /wss or /tls/ws (survives certificate rotation) * 2. freshly resolved certhash transports (webrtc-direct / webtransport) * Anything a browser cannot dial from an HTTPS origin is dropped. */ export declare function rankBrowserBootstrapAddrs(addrs: string[]): string[]; /** Options for runtime bootstrap-address resolution. */ export interface ResolveBootstrapOptions { /** * Delegated routing endpoint (IPIP-337 /routing/v1). REQUIRED — there is no * baked-in default on purpose: the SDN node UI must load ZERO external-origin * bytes, so the caller (or the host node) decides which router to trust. * Point this at the node's own /routing/v1 to stay same-origin. */ routingEndpoint: string; /** Abort/timeout control. */ signal?: AbortSignal; fetchImpl?: typeof fetch; } /** * Resolve a peer's CURRENT bootstrap addresses from a delegated routing * endpoint, best-first for browser dialing. * * This is the rot-proof half of the fix: instead of shipping a certificate * hash that expires, ask the router what the peer advertises right now. The * peer ID is the only stable pin, and it is verified by the libp2p handshake. * Returns [] on any failure so the caller falls back to DEFAULT_EDGE_RELAYS. */ export declare function resolvePeerBootstrapAddrs(peerId: string, options: ResolveBootstrapOptions): Promise; /** * Metrics for relay discovery and WASM loading */ export interface DiscoveryMetrics { wasmLoadAttempts: number; wasmLoadSuccesses: number; wasmLoadFailures: number; wasmVerificationSuccesses: number; wasmVerificationFailures: number; relaysDiscovered: number; fallbacksUsed: number; lastLoadTime: number | null; lastLoadDuration: number | null; lastError: string | null; } /** Response from /api/relay/status */ export interface RelayStatus { peer_id: string; connections: number; max_connections: number; load: number; mode: string; version: string; uptime_seconds: number; } /** Relay probe result enriched with latency measurement */ export interface RelayProbeResult { multiaddr: string; status: RelayStatus | null; latencyMs: number; probeTime: number; error: string | null; } /** * Convert a libp2p multiaddr to an HTTP(S) URL for the relay status endpoint. * * - /dns4/example.com/tcp/443/wss/p2p/... → https://example.com/api/relay/status * - /ip4/1.2.3.4/tcp/8080/ws/p2p/... → http://1.2.3.4:8080/api/relay/status * * Returns null if the multiaddr cannot be converted (e.g., QUIC-only). */ export declare function multiaddrToStatusURL(ma: string): string | null; /** * Get current discovery metrics */ export declare function getDiscoveryMetrics(): Readonly; /** * Reset discovery metrics (useful for testing) */ export declare function resetDiscoveryMetrics(): void; /** * Load edge relays from the encrypted WASM module */ export declare function loadEdgeRelays(): Promise; /** * Get bootstrap relay addresses * This is the main entry point for SDNNode initialization */ export declare function getBootstrapRelays(options?: Partial & { peerIds?: string[]; }): Promise; /** * Check if the WASM module was verified */ export declare function isWasmVerified(): boolean; /** * Get relays for a specific region (fallback) */ export declare function getRegionalRelays(region?: string): string[]; /** * Get all fallback relays (default + regional) */ export declare function getAllFallbackRelays(): string[]; /** * Edge relay discovery class for dynamic relay management */ export declare class EdgeDiscovery { private knownRelays; private failedRelays; private refreshInterval; private maxFailures; private probeResults; private probeInterval; private probeTimeoutMs; private probeStalenessMs; constructor(initialRelays?: string[]); /** * Get all known relay addresses */ getRelays(): string[]; /** * Add a new relay address */ addRelay(addr: string): void; /** * Remove a relay address */ removeRelay(addr: string): void; /** * Check if a relay is known */ hasRelay(addr: string): boolean; /** * Mark a relay as failed (tracks failures for reliability scoring) */ markFailed(addr: string): void; /** * Mark a relay as successful (resets failure count) */ markSuccess(addr: string): void; /** * Probe a single relay's /api/relay/status endpoint. * Measures latency and caches the result. */ probeRelay(addr: string): Promise; /** * Probe all known relays concurrently. */ probeAllRelays(): Promise>; /** * Start periodic relay probing for load balancing. */ startProbing(intervalMs?: number): void; /** * Stop periodic relay probing. */ stopProbing(): void; /** * Get cached probe result for a relay. */ getProbeResult(addr: string): RelayProbeResult | undefined; /** * Get the best relays scored by load, latency, and failure history. * * Score (lower is better): * score = (load * 50) + (normalizedLatency * 30) + (failureScore * 20) * * When no probe data exists, falls back to failure-count-only sorting. */ getBestRelays(count?: number): string[]; /** * Ensure we have minimum number of relays by adding fallbacks. * * The default floor is 2 and STAYS 2. As of 2026-08-06 the fleet advertises * exactly TWO CA-authenticated browser-dialable bootstrap addresses — * sdn.spaceaware.io (host-01, Cloudflare-fronted) and the celestrak.eth node * (host-02, AutoTLS/libp2p.direct, promoted by owner ruling under graph task * `ops-host02-browser-relay-promotion`). A caller asking for 3 will still * come up one short, and that is REPORTED, not papered over: this method * adds real addresses only. Raising the floor to 3 requires a third node with * a browser-dialable transport, not a code change — and inventing an address * to satisfy a counter is how the two dead certhash entries this list used to * ship got there in the first place. */ ensureMinimumRelays(minimum?: number): void; /** * Start periodic refresh from WASM */ startRefresh(intervalMs?: number): void; /** * Stop periodic refresh */ stopRefresh(): void; /** * Get a circuit relay address for a target peer. * Picks randomly from the top 3 scored relays for load-aware jitter. */ getCircuitAddress(targetPeerId: string): string | null; } //# sourceMappingURL=edge-discovery.d.ts.map