/** * Buddy client wire-format codec for the binary realtime relay * (`crowdy-relay-v1`). * * Mirrors the game-api's `UdpMessageParserService` byte-for-byte: uplink * serializers build the complete client→Buddy datagram (spatial header + * payload + HMAC + gameTokenId + sequence) and downlink parsing produces the * same `__typename`-tagged notification objects the GraphQL * `udpNotifications` subscription delivers, so handler code is transport * agnostic. * * The per-message HMAC key is the 64-octet game token string itself — the * same bearer token the SDK already holds — computed with WebCrypto * (HMAC-SHA256). Buddy verifies it server-side; the relay does not. */ import type { UdpNotification } from './realtime.js'; export declare const RELAY_MAX_DATAGRAM_BYTES = 1232; /** Wire opcodes (mirror of game-api / Buddy `UdpMessageType`). */ export declare const WireMessageType: { readonly MESSAGE_BUNDLE: 2; readonly GENERIC_ERROR_MESSAGE: 3; readonly CHANNEL_MESSAGE_REQUEST: 17; readonly CHANNEL_MESSAGE_NOTIFICATION: 18; readonly ACTOR_UPDATE_REQUEST_2: 128; readonly ACTOR_UPDATE_RESPONSE_2: 129; readonly ACTOR_UPDATE_NOTIFICATION_2: 130; readonly VOXEL_UPDATE_REQUEST_2: 131; readonly VOXEL_UPDATE_RESPONSE_2: 132; readonly VOXEL_UPDATE_NOTIFICATION_2: 133; readonly CLIENT_AUDIO_PACKET_2: 134; readonly CLIENT_AUDIO_NOTIFICATION_2: 135; readonly CLIENT_TEXT_PACKET_2: 136; readonly CLIENT_TEXT_NOTIFICATION_2: 137; readonly CLIENT_EVENT_NOTIFICATION_2: 138; readonly SERVER_EVENT_NOTIFICATION_2: 139; readonly SINGLE_ACTOR_MESSAGE: 142; }; /** * Per-session signing context: the game token id (from the relay `ready` * frame) plus the token bytes and imported WebCrypto HMAC key. */ export interface RelaySignContext { gameTokenId: bigint; tokenBytes: Uint8Array; key: CryptoKey; } /** Import the game token as an HMAC-SHA256 WebCrypto key (once per session). */ export declare function createSignContext(gameTokenId: bigint, gameTokenString: string): Promise; export interface SpatialSendBase { appId: string; chunk: { x: string; y: string; z: string; }; uuid: string; distance?: number | null; decayRate?: number | null; sequenceNumber?: number | null; } export declare function serializeActorUpdate(ctx: RelaySignContext, input: SpatialSendBase & { state: string; }): Promise; export declare function serializeVoxelUpdate(ctx: RelaySignContext, input: SpatialSendBase & { voxel: { x: number; y: number; z: number; }; voxelType: number; voxelState: string; }): Promise; export declare function serializeAudioPacket(ctx: RelaySignContext, input: SpatialSendBase & { audioData: string; }): Promise; export declare function serializeTextPacket(ctx: RelaySignContext, input: SpatialSendBase & { text: string; }): Promise; export declare function serializeClientEvent(ctx: RelaySignContext, input: SpatialSendBase & { eventType: number; state: string; }): Promise; export declare function serializeSingleActorMessage(ctx: RelaySignContext, input: { appId: string; chunk: { x: string; y: string; z: string; }; targetUuid: string; payload?: string | null; sequenceNumber?: number | null; }): Promise; /** * CHANNEL_MESSAGE_REQUEST: * `[1B type=17][8B channelId][32B uuid][2B payloadLen][payload][1B containsAuth] * [32B HMAC][8B gameTokenId][1B seq]` — HMAC over everything before it. */ export declare function serializeChannelMessage(ctx: RelaySignContext, input: { channelId: string; uuid: string; payload?: string | null; sequenceNumber?: number | null; }): Promise; /** * Parse one relay BINARY frame (one Buddy datagram, possibly a * MESSAGE_BUNDLE) into notification objects. Unparseable inner messages are * skipped, mirroring the server-side bundle behavior. */ export declare function parseRelayFrame(bytes: Uint8Array): UdpNotification[]; //# sourceMappingURL=binary-wire.d.ts.map