export declare const PACKET_TYPE_USERINFO = 3; export declare const PACKET_TYPE_FRIEND_REQUEST = 6; export declare const PACKET_TYPE_MESSAGE = 33; export declare const PACKET_TYPE_INVITE_REQUEST = 34; export declare const PACKET_TYPE_INVITE_RESPONSE = 35; export declare const PACKET_TYPE_BULKMSG = 36; export declare const CARRIER_MAX_APP_MESSAGE_LEN = 1024; export declare const CARRIER_MAX_APP_BULKMSG_LEN: number; export declare const INVITE_DATA_UNIT = 1280; export declare const CARRIER_MAX_INVITE_DATA_LEN = 8192; export declare const CARRIER_MAX_BUNDLE_LEN = 511; export declare const CARRIER_MAX_EXTENSION_NAME_LEN = 31; export declare const CARRIER_EXTENSION_NAME = "carrier"; export type UserInfoPacket = { type: typeof PACKET_TYPE_USERINFO; avatar: boolean; name: string; descr: string; phone: string; gender: string; email: string; region: string; /** AgentNet wire-protocol version (userinfo field 7, appended). 0 = a legacy * peer that predates the field (native C SDK before the extension, or an old * JS peer). Non-zero lets peers negotiate capabilities (e.g. toxcore file * transfer for large files vs. inline bulkmsg). */ protoVersion: number; /** Client platform (field 8): "ios" | "android" | "js" | "linux" | "darwin" * | "win32" | "" (unknown/legacy). */ platform: string; /** OS/runtime version string (field 9), e.g. "17.5", "14", "node-24.2.0". */ osVersion: string; /** Application/SDK version (field 10), e.g. "beagle-2.3.1", "lan-0.1.166". */ appVersion: string; }; export type FriendRequestPacket = { type: typeof PACKET_TYPE_FRIEND_REQUEST; name: string; descr: string; hello: string; }; export type FriendMessagePacket = { type: typeof PACKET_TYPE_MESSAGE; ext?: string; data: Uint8Array; }; export type BulkMsgPacket = { type: typeof PACKET_TYPE_BULKMSG; ext?: string; /** Full message length — set on the FIRST fragment only, 0 on the rest. */ totalsz: number; /** Shared id linking all fragments of one message. */ tid: bigint; data: Uint8Array; }; /** * One `invitereq` fragment (PACKET_TYPE_INVITE_REQUEST = 34). Field layout per * carrier/packet.fbs: 0=ext string, 1=tid long, 2=bundle string, 3=totalsz * uint, 4=data [uint8]. Mirrors carrier_invite_friend's per-fragment packet. */ export type InviteReqPacket = { type: typeof PACKET_TYPE_INVITE_REQUEST; ext?: string; tid: bigint; bundle?: string; /** Full data length — set on the FIRST fragment only, 0 on the rest. */ totalsz: number; data: Uint8Array; }; /** * One `invitersp` fragment (PACKET_TYPE_INVITE_RESPONSE = 35). Field layout: * 0=ext, 1=tid, 2=bundle, 3=totalsz, 4=status int, 5=reason string, 6=data. * A non-zero status means "refused" (reason set, no data); status 0 means * "confirmed" and carries data. The iOS WebRTC receiver never sends these * (each RtcSignal is a one-way invitereq), but we decode them for completeness * and can emit them if a peer does reply. */ export type InviteRspPacket = { type: typeof PACKET_TYPE_INVITE_RESPONSE; ext?: string; tid: bigint; bundle?: string; totalsz: number; status: number; reason?: string; data: Uint8Array; }; export type CarrierPacket = UserInfoPacket | FriendRequestPacket | FriendMessagePacket | InviteReqPacket | InviteRspPacket | BulkMsgPacket; /** * Encode a Carrier `userinfo` packet (FB type 3). The Carrier C SDK sends * this every time the local user's name / status message / profile fields * change, transported via toxcore's PACKET_ID_STATUSMESSAGE (49). * * Field layout per src/carrier/packet.fbs: * field 0 = avatar : bool (default false) * field 1 = name : string * field 2 = descr : string * field 3 = phone : string * field 4 = gender : string * field 5 = email : string * field 6 = region : string * * AgentNet extends the table with appended fields (FlatBuffers is forward/ * backward compatible — a peer that predates a field just reads its default): * field 7 = proto_version : uint (AgentNet wire-protocol version, 0=legacy) * field 8 = platform : string ("ios"/"android"/"js"/"darwin"/"linux"/…) * field 9 = os_version : string * field 10 = app_version : string */ export declare function encodeUserInfoPacket(opts: { avatar?: boolean; name?: string; descr?: string; phone?: string; gender?: string; email?: string; region?: string; protoVersion?: number; platform?: string; osVersion?: string; appVersion?: string; }): Uint8Array; export declare function encodeFriendRequestPacket(opts: { name?: string; descr?: string; hello?: string; }): Uint8Array; export declare function encodeFriendMessagePacket(data: Uint8Array | string, ext?: string): Uint8Array; /** * Encode one Carrier `bulkmsg` fragment (PACKET_TYPE_BULKMSG = 36). Field * layout per src/carrier/packet.fbs: 0=ext string, 1=totalsz uint, * 2=tid long, 3=data [ubyte]. Mirrors the C SDK's send_bulk_message. */ export declare function encodeBulkMsgPacket(opts: { ext?: string; totalsz: number; tid: bigint; data: Uint8Array; }): Uint8Array; /** * Encode ONE `invitereq` fragment (PACKET_TYPE_INVITE_REQUEST = 34). Field * layout per packet.fbs invitereq: 0=ext, 1=tid, 2=bundle, 3=totalsz, 4=data. * Callers fragment the payload (INVITE_DATA_UNIT) and share one tid; only the * first fragment sets totalsz (and the optional bundle). Mirrors the do/while * in carrier_invite_friend. */ export declare function encodeInviteReqPacket(opts: { ext?: string; tid: bigint; bundle?: string; totalsz: number; data: Uint8Array; }): Uint8Array; /** * Encode ONE `invitersp` fragment (PACKET_TYPE_INVITE_RESPONSE = 35). Field * layout: 0=ext, 1=tid, 2=bundle, 3=totalsz, 4=status, 5=reason, 6=data. * status !== 0 → refused (reason set, no data); status === 0 → confirmed * (carries data). Mirrors carrier_reply_friend_invite. */ export declare function encodeInviteRspPacket(opts: { ext?: string; tid: bigint; bundle?: string; totalsz: number; status: number; reason?: string; data?: Uint8Array; }): Uint8Array; export declare function decodeCarrierPacket(bytes: Uint8Array): CarrierPacket; /** * Encode a toxcore net_crypto PACKET_ID_REQUEST payload requesting retransmit * of the packets MISSING in the receive window `[low, high]` (inclusive). This * is the exact inverse of the decoder in peer.ts `#handleRetransmitRequest`: * walk each number from `low`, keep a running counter `n` (starts at 1), and * emit `n` at every MISSING number (then reset it), inserting a 0 filler byte * whenever the counter reaches 255. `have(num)` returns true if we already hold * that packet number. `low` is always treated as missing by construction (it is * the low-water mark — the first not-yet-delivered number). Numbers are 32-bit * and wrap; the window is small so the walk is bounded. * * Returned bytes do NOT include the leading PACKET_ID_REQUEST kind byte — the * caller prepends it. */ export declare function encodeRetransmitRequest(low: number, high: number, have: (num: number) => boolean): Uint8Array;