export type SignalMessageBase = { type: T; payload: P; timestamp: number; }; /** * Flash message * Sent to initiate handshake by non-host */ export type SignalMessageFlash = SignalMessageBase<"flash", object>; export type SignalMessagePubkey = SignalMessageBase<"pubkey", { publicKey: string; }>; /** Optional self-description shown in the other peer's UI. */ export type PeerInfo = { /** Reverse-DNS application identifier, e.g. "com.example.wallet". */ identity: string; name: string; /** * A data URI or an image URL. Only size is enforced on the wire -- anyone * rendering or fetching it is responsible for sanity-checking it first. */ icon?: string; }; export type PeerCapabilities = { /** Supported transport identifiers, in preference order. */ transports: string[]; info?: PeerInfo; }; /** * Completes the handshake: acknowledges the previous step, negotiates the * transport, and shares peer metadata in a single packet. */ export type SignalMessageCapabilities = SignalMessageBase<"capabilities", PeerCapabilities>; export type SignalMessageData = SignalMessageBase<"data", object>; export type SignalMessage = SignalMessageFlash | SignalMessagePubkey | SignalMessageCapabilities | SignalMessageData; export declare const MAX_ICON_LENGTH = 8192; /** * Check outgoing peer info against the wire limits enforced by receivers. * Returns a human-readable problem, or undefined when the info is sendable. * Senders must use this: a receiver silently drops an oversized packet, which * would otherwise surface only as a generic handshake timeout. */ export declare const validatePeerInfo: (info: PeerInfo) => string | undefined; export declare const parseCapabilities: (raw: unknown) => PeerCapabilities | undefined; /** * Parse and shape-check a decrypted signaling payload. The relay topic is * public, so decrypted JSON is still untrusted input: anything that does not * match one of the four message shapes is dropped (returns undefined). */ export declare const parseSignalMessage: (raw: string) => SignalMessage | undefined;