# `BaileysEx.Auth.State`
[🔗](https://github.com/jeffhuen/baileys_ex/blob/main/lib/baileys_ex/auth/state.ex#L1)

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:

- `BaileysEx.Auth.NativeFilePersistence` roundtrips general BEAM terms
- `BaileysEx.Auth.FilePersistence` accepts JSON-safe values only

# `account_settings`

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

# `key_pair`

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

# `signal_identity`

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

# `signed_key_pair`

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

# `t`

```elixir
@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()
}
```

# `creds_view`

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

Returns a `creds` viewing projection mapping suitable for saving standalone.

# `get`

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

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

# `me_id`

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

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

# `me_lid`

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

Returns the current LID from the auth state when present.

# `me_name`

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

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

# `merge_updates`

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

Deeply merges arbitrary map updates into the authentication state struct.

# `new`

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

Initializes a new authentication state with generated keys.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
