BaileysEx.Auth.State (baileys_ex v0.1.0-alpha.7)

Copy Markdown View Source

Authentication credential state matching the Baileys rc.9 auth envelope.

Most fields roundtrip across both built-in persistence backends. The :additional_data field is backend-dependent:

Summary

Functions

Returns a creds viewing projection mapping suitable for saving standalone.

Fetches a value from the auth state or its nested credentials structure.

Returns the current account JID from the auth state when present.

Returns the current LID from the auth state when present.

Returns the current account name from the auth state when present.

Deeply merges arbitrary map updates into the authentication state struct.

Initializes a new authentication state with generated keys.

Types

account_settings()

@type account_settings() :: %{
  unarchive_chats: boolean(),
  default_disappearing_mode: map() | nil
}

key_pair()

@type key_pair() :: %{public: binary(), private: binary()}

signal_identity()

@type signal_identity() :: %{
  identifier: %{name: binary(), device_id: non_neg_integer()},
  identifier_key: binary()
}

signed_key_pair()

@type signed_key_pair() :: %{
  key_pair: key_pair(),
  key_id: non_neg_integer(),
  signature: binary()
}

t()

@type t() :: %BaileysEx.Auth.State{
  account: map() | nil,
  account_settings: account_settings(),
  account_sync_counter: non_neg_integer(),
  additional_data: term() | nil,
  adv_secret_key: binary(),
  first_unuploaded_pre_key_id: term(),
  last_account_sync_timestamp: integer() | nil,
  last_prop_hash: binary() | nil,
  me: map() | nil,
  my_app_state_key_id: binary() | nil,
  next_pre_key_id: term(),
  noise_key: key_pair(),
  pairing_code: binary() | nil,
  pairing_ephemeral_key: key_pair() | nil,
  platform: binary() | nil,
  processed_history_messages: [map()],
  registered: boolean(),
  registration_id: non_neg_integer(),
  routing_info: binary() | nil,
  signal_identities: [signal_identity()],
  signed_identity_key: key_pair(),
  signed_pre_key: signed_key_pair()
}

Functions

creds_view(state)

@spec creds_view(t() | map()) :: map()

Returns a creds viewing projection mapping suitable for saving standalone.

get(state, key, default \\ nil)

@spec get(t() | map(), atom(), term()) :: term()

Fetches a value from the auth state or its nested credentials structure.

me_id(state)

@spec me_id(t() | map()) :: binary() | nil

Returns the current account JID from the auth state when present.

me_lid(state)

@spec me_lid(t() | map()) :: binary() | nil

Returns the current LID from the auth state when present.

me_name(state)

@spec me_name(t() | map()) :: binary() | nil

Returns the current account name from the auth state when present.

merge_updates(state, updates)

@spec merge_updates(t() | map(), map()) :: t() | map()

Deeply merges arbitrary map updates into the authentication state struct.

new(opts \\ [])

@spec new(keyword()) :: t()

Initializes a new authentication state with generated keys.