whalibmob 5.5.75 → 5.5.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/messages/MessageSender.js +41 -35
- package/package.json +1 -1
|
@@ -42,12 +42,12 @@ function phoneFromJid(jid) {
|
|
|
42
42
|
return colon >= 0 ? user.slice(0, colon) : user;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// ───
|
|
45
|
+
// ─── ADVSignedDeviceIdentity ─────────────────────────────────────────────────
|
|
46
46
|
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
47
|
+
// Received from the server in the pair-success IQ when a companion device is
|
|
48
|
+
// linked. A primary device registered over SMS never gets one and must not
|
|
49
|
+
// invent one — see _buildOrGetAdvIdentity. The encoders below remain for
|
|
50
|
+
// working with a real identity when the server does supply it.
|
|
51
51
|
//
|
|
52
52
|
// ADVDeviceIdentityDetails (protobuf):
|
|
53
53
|
// field 1 (rawId, uint32): registration ID
|
|
@@ -110,33 +110,26 @@ function _getCurve() {
|
|
|
110
110
|
// Returns Buffer of encoded proto WITH accountSignatureKey included.
|
|
111
111
|
// Result is cached in store.advIdentity so we only build it once per registration.
|
|
112
112
|
function _buildOrGetAdvIdentity(store) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const adv = _encodeADVSignedIdentity(details, pub32, acctSig, devSig);
|
|
133
|
-
store.advIdentity = adv;
|
|
134
|
-
_whaDbg('[DBG] ADV_BUILT from primary iOS keys (' + adv.length + 'b)\n');
|
|
135
|
-
return adv;
|
|
136
|
-
} catch (e) {
|
|
137
|
-
_whaDbg('[DBG] ADV_BUILD_ERR: ' + e.message);
|
|
138
|
-
return null;
|
|
113
|
+
// Only ever return an identity the server actually issued.
|
|
114
|
+
//
|
|
115
|
+
// ADVSignedDeviceIdentity is minted during companion pairing: it proves a
|
|
116
|
+
// linked device's identity key was authorised by the primary, and its
|
|
117
|
+
// accountSignature is made with the primary's key. This client registers
|
|
118
|
+
// over SMS as the primary, so no pairing IQ ever runs and there is nothing
|
|
119
|
+
// to attach — which is what the comment above allowPkmsg already says
|
|
120
|
+
// primaries do.
|
|
121
|
+
//
|
|
122
|
+
// This used to fabricate one by self-signing with our own identity key when
|
|
123
|
+
// the store had none. That identity cannot validate: nothing authorised it.
|
|
124
|
+
// Attaching it to every pkmsg is a plausible cause of the server rejecting
|
|
125
|
+
// sends with ack 479 while still delivering messages to us, and it
|
|
126
|
+
// contradicted the documented behaviour a few lines up. If a real
|
|
127
|
+
// device-identity is ever received on <success> it is stored and used here;
|
|
128
|
+
// otherwise the node is simply omitted.
|
|
129
|
+
if (store && store.advIdentity && store.advIdentity.length > 0) {
|
|
130
|
+
return store.advIdentity;
|
|
139
131
|
}
|
|
132
|
+
return null;
|
|
140
133
|
}
|
|
141
134
|
|
|
142
135
|
function makeJid(input, server) {
|
|
@@ -716,14 +709,27 @@ class MessageSender {
|
|
|
716
709
|
// For LID-migrated accounts, the message `to` field AND Signal participants
|
|
717
710
|
// must use the LID JID. Phone-JID messages are silently accepted by the
|
|
718
711
|
// server but never delivered to the recipient's LID-registered device.
|
|
719
|
-
|
|
720
|
-
|
|
712
|
+
//
|
|
713
|
+
// WA_DM_ROUTE overrides the choice for diagnosis, because both routes have
|
|
714
|
+
// been observed failing in different ways and only a live account can tell
|
|
715
|
+
// them apart:
|
|
716
|
+
// pn — always address the phone JID (how this worked before LID JIDs
|
|
717
|
+
// started being decoded at all)
|
|
718
|
+
// lid — always address the LID when one is known (the default below)
|
|
719
|
+
// auto — same as lid; the default
|
|
720
|
+
const routeMode = (process.env.WA_DM_ROUTE || 'auto').toLowerCase();
|
|
721
|
+
const lidUser = this._client._pnToLid && this._client._pnToLid.get(recipientPhone);
|
|
722
|
+
const useLidRoute = lidUser && routeMode !== 'pn';
|
|
723
|
+
const routingToJid = useLidRoute ? `${lidUser}@lid` : toJid;
|
|
721
724
|
|
|
722
725
|
_whaDbg('[DBG] DM_ROUTE phone=' + recipientPhone +
|
|
723
|
-
' routing=' + routingToJid + (
|
|
726
|
+
' routing=' + routingToJid + (useLidRoute ? ' (LID)' : ' (PN)') +
|
|
727
|
+
' mode=' + routeMode);
|
|
724
728
|
|
|
725
729
|
let otherJids;
|
|
726
|
-
|
|
730
|
+
// Follow the same address family as the routing JID — the participants and
|
|
731
|
+
// the `to` must agree, so WA_DM_ROUTE=pn has to switch both.
|
|
732
|
+
if (useLidRoute) {
|
|
727
733
|
// Fetch bundle + build Signal session for the LID JID.
|
|
728
734
|
// skipUsync=true: we already know the LID from _pnToLid — skip a second
|
|
729
735
|
// 15 s usync round-trip and go straight to bundle fetch (device 0 primary).
|