BaileysEx.Message.Wire (baileys_ex v0.1.0-alpha.8)

Copy Markdown View Source

Wire helpers for padded WAProto message payloads and Baileys-style message IDs.

Summary

Functions

Unpads and deserializes a WAProto message from binary.

Serializes and adds random WhatsApp XMPP padding to a WAProto message.

Generates a 3EB0... random message ID that WhatsApp Web typically uses.

Produces the device participant hash indicating which E2E key copies were distributed.

Strips WAProto padding block, returning only the underlying protobuf.

Pads a binary buffer dynamically using deterministic/cryptographic randomness.

Types

proto_message()

@type proto_message() :: struct()

Functions

decode(binary)

@spec decode(binary()) :: {:ok, proto_message()} | {:error, term()}

Unpads and deserializes a WAProto message from binary.

encode(message, opts \\ [])

@spec encode(
  proto_message(),
  keyword()
) :: binary()

Serializes and adds random WhatsApp XMPP padding to a WAProto message.

generate_message_id(user_id \\ nil, opts \\ [])

@spec generate_message_id(
  String.t() | nil,
  keyword()
) :: String.t()

Generates a 3EB0... random message ID that WhatsApp Web typically uses.

generate_participant_hash(participants)

@spec generate_participant_hash([String.t()]) :: String.t()

Produces the device participant hash indicating which E2E key copies were distributed.

unpad_random_max16(binary)

@spec unpad_random_max16(binary()) :: {:ok, binary()} | {:error, term()}

Strips WAProto padding block, returning only the underlying protobuf.

write_random_pad_max16(binary, opts \\ [])

@spec write_random_pad_max16(
  binary(),
  keyword()
) :: binary()

Pads a binary buffer dynamically using deterministic/cryptographic randomness.