Amarula.Connection.Pairing (amarula v0.4.1)
View SourcePure pairing builders for Amarula.Connection — the node-building and
creds-transform parts of the QR/multi-device handshake.
The orchestrating handlers (handle_pair_device, handle_pair_success,
emit_next_qr) stay on Connection: they send frames, run timers, persist
creds, and emit events. What lives here is pure and testable directly — the
two reply IQ nodes, the QR-ref extraction, and the post-pairing creds merge.
Summary
Functions
The <iq type=result> ack for a received pair-device IQ.
The <iq><pair-device-sign> reply counter-signing the device identity.
Extract the QR ref payloads from a pair-device IQ node, in order. Returns
[] when the <pair-device> wrapper or its <ref> children are absent.
Merge the paired-device fields into creds. me.name defaults to "~" (Baileys)
when there's no business name — presence-available requires a non-nil me.name.
Functions
@spec pair_device_ack_node(String.t()) :: Amarula.Protocol.Binary.Node.t()
The <iq type=result> ack for a received pair-device IQ.
@spec pair_device_sign_reply(String.t(), integer(), binary()) :: Amarula.Protocol.Binary.Node.t()
The <iq><pair-device-sign> reply counter-signing the device identity.
@spec qr_refs(Amarula.Protocol.Binary.Node.t()) :: [binary()]
Extract the QR ref payloads from a pair-device IQ node, in order. Returns
[] when the <pair-device> wrapper or its <ref> children are absent.
@spec update_credentials_after_pairing( map(), term(), String.t(), String.t(), term(), term(), term() ) :: map()
Merge the paired-device fields into creds. me.name defaults to "~" (Baileys)
when there's no business name — presence-available requires a non-nil me.name.