import type { Envelope } from '../protocol'; export interface RoomMetadata { maxClients?: number | undefined; [key: string]: unknown; } export type SignalEnvelope = | { readonly kind: 'host-register'; readonly roomName: string; readonly metadata?: RoomMetadata | undefined; readonly from?: string | undefined; readonly ipHash?: string | undefined; readonly accessToken?: string | undefined; } | { readonly kind: 'host-registered'; readonly roomId: string; readonly hostSignalId: string } | { readonly kind: 'join-request'; readonly roomName: string; readonly roomId?: string | undefined; readonly options?: unknown; readonly from?: string | undefined; readonly ipHash?: string | undefined; readonly accessToken?: string | undefined; } | { readonly kind: 'join-routed'; readonly roomId: string; readonly hostSignalId: string; readonly clientSignalId: string; } | { readonly kind: 'rtc-offer'; readonly roomId: string; readonly target: string; readonly from?: string | undefined; readonly ipHash?: string | undefined; readonly sdp: RTCSessionDescriptionInit; } | { readonly kind: 'rtc-answer'; readonly roomId: string; readonly target: string; readonly from?: string | undefined; readonly ipHash?: string | undefined; readonly sdp: RTCSessionDescriptionInit; } | { readonly kind: 'rtc-ice'; readonly roomId: string; readonly target: string; readonly from?: string | undefined; readonly ipHash?: string | undefined; readonly candidate: RTCIceCandidateInit; } | { readonly kind: 'relay-open'; readonly roomId: string; readonly target: string; readonly from?: string | undefined; readonly ipHash?: string | undefined; } | { readonly kind: 'relay-data'; readonly roomId: string; readonly target: string; readonly from?: string | undefined; readonly ipHash?: string | undefined; // The session's managed access token, attached by the forced-relay client // transports (`HttpRelayPacketChannel`/`HostRelayPacketChannel`). It is the // ONLY trustworthy sender identity a POST relay-data frame carries, so // under account enforcement the relay meters bytes against its verified // `userId` — never the spoofable `from`. Absent for self-host / BYOK. readonly accessToken?: string | undefined; readonly envelope: Envelope; } | { readonly kind: 'relay-drain'; readonly peerId: string } | { readonly kind: 'relay-drained'; readonly messages: readonly SignalEnvelope[] } | { readonly kind: 'heartbeat'; readonly roomId: string; readonly from?: string | undefined } | { readonly kind: 'error'; readonly message: string };