Amarula.Protocol.Signal.SessionInjector (amarula v0.1.0)

View Source

Parse an encrypt/get prekey-bundle IQ result and build outgoing sessions, ported from Baileys parseAndInjectE2ESessions (src/Utils/signal.ts) + repository.injectE2ESession.

The IQ result looks like:

<iq type=result><list>
  <user jid=...>
    <registration/>           (4-byte big-endian)
    <identity/>               (32-byte raw pubkey)
    <skey><id/><value/><signature/></skey>   (signed prekey)
    <key><id/><value/></key>                 (one-time prekey, optional)
    <error/>                  (present if no bundle for this device)
  </user>
  ...
</list></iq>

For each error-free <user> we run SessionBuilder.init_outgoing against the bundle and persist the session under the user's signal address.

Summary

Functions

Inject every session in the IQ result node. creds supplies our identity (via SessionStore.build/1); conn (Amarula.Conn) scopes where sessions persist.

Functions

inject(result, creds, conn)

@spec inject(map(), map(), Amarula.Conn.t()) :: non_neg_integer()

Inject every session in the IQ result node. creds supplies our identity (via SessionStore.build/1); conn (Amarula.Conn) scopes where sessions persist.

Returns the number of sessions injected.