BaileysEx.Feature.TcToken (baileys_ex v0.1.0-alpha.9)

Copy Markdown View Source

Trusted-contact token helpers aligned with Baileys' privacy-token flow.

Summary

Functions

Append a stored TC token node to the provided content list.

Build a tctoken child node for a JID when a stored token exists.

Fetch trusted-contact privacy tokens for the given JIDs.

Handle a privacy_token notification by persisting trusted-contact tokens.

Issue a fresh trusted-contact token after an eligible outgoing 1:1 message.

Returns true for user JIDs that can participate in trusted-contact token flows.

Re-issue trusted-contact tokens after a peer identity changes.

Store trusted-contact tokens returned by a privacy-token IQ result.

Functions

build_content(store, jid, base_content \\ [], opts \\ [])

@spec build_content(
  BaileysEx.Signal.Store.t() | nil,
  String.t(),
  [BaileysEx.BinaryNode.t()],
  keyword()
) ::
  [BaileysEx.BinaryNode.t()] | nil

Append a stored TC token node to the provided content list.

Mirrors Baileys buildTcTokenFromJid: if no token exists, returns the existing content when present or nil when it is empty.

build_node(store, jid, opts \\ [])

@spec build_node(BaileysEx.Signal.Store.t() | nil, String.t(), keyword()) ::
  BaileysEx.BinaryNode.t() | nil

Build a tctoken child node for a JID when a stored token exists.

get_privacy_tokens(queryable, jids, opts \\ [])

@spec get_privacy_tokens(term(), [String.t()], keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}

Fetch trusted-contact privacy tokens for the given JIDs.

handle_notification(node, opts \\ [])

@spec handle_notification(
  BaileysEx.BinaryNode.t(),
  keyword()
) :: :ok

Handle a privacy_token notification by persisting trusted-contact tokens.

issue_after_outgoing_message(queryable, store, jid, opts \\ [])

@spec issue_after_outgoing_message(
  term(),
  BaileysEx.Signal.Store.t() | nil,
  String.t(),
  keyword()
) ::
  :ok | {:error, term()}

Issue a fresh trusted-contact token after an eligible outgoing 1:1 message.

regular_user?(jid)

@spec regular_user?(String.t() | nil) :: boolean()

Returns true for user JIDs that can participate in trusted-contact token flows.

reissue_after_identity_change(queryable, store, jid, opts \\ [])

@spec reissue_after_identity_change(
  term(),
  BaileysEx.Signal.Store.t() | nil,
  String.t(),
  keyword()
) ::
  :ok | {:error, term()}

Re-issue trusted-contact tokens after a peer identity changes.

store_from_iq_result(result, fallback_jid, opts \\ [])

@spec store_from_iq_result(BaileysEx.BinaryNode.t(), String.t() | nil, keyword()) ::
  :ok

Store trusted-contact tokens returned by a privacy-token IQ result.