whalibmob 5.1.11 → 5.1.12
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/Client.js +2 -0
- package/lib/DeviceManager.js +2 -2
- package/lib/messages/MessageSender.js +4 -3
- package/package.json +1 -1
package/lib/Client.js
CHANGED
|
@@ -124,6 +124,7 @@ class WhalibmobClient extends EventEmitter {
|
|
|
124
124
|
this._pendingIqs = new Map(); // id → resolve fn
|
|
125
125
|
this._pendingAcks = new Map(); // msgId → resolve fn
|
|
126
126
|
this._groupMembers = new Map(); // groupJid → Set<memberJid>
|
|
127
|
+
this._lidToPn = new Map(); // LID user → phone number
|
|
127
128
|
this._retryPending = new Map(); // msgId → {node, retryCount}
|
|
128
129
|
this._retryPreKeyIdx = 0; // rotating index for assigning unique prekeys to retries
|
|
129
130
|
this._appStateVersions = {}; // collectionName → version (int)
|
|
@@ -522,6 +523,7 @@ class WhalibmobClient extends EventEmitter {
|
|
|
522
523
|
const participant = String(attrs.participant || from);
|
|
523
524
|
// sender_pn is the real phone-based JID when `from` is a LID (linked identity)
|
|
524
525
|
const senderPn = attrs.sender_pn ? String(attrs.sender_pn) : null;
|
|
526
|
+
if (senderPn) { const lidUser = from.split('@')[0].split(':')[0]; const pnUser = senderPn.split('@')[0].split(':')[0]; if (lidUser && pnUser && lidUser !== pnUser) this._lidToPn.set(lidUser, pnUser); }
|
|
525
527
|
// Debug: log every incoming message node
|
|
526
528
|
process.stderr.write('[DBG] _handleMessage from=' + from + ' participant=' + participant + ' senderPn=' + senderPn + ' id=' + id + '\n');
|
|
527
529
|
// Debug: log message content structure
|
package/lib/DeviceManager.js
CHANGED
|
@@ -123,7 +123,7 @@ class DeviceManager {
|
|
|
123
123
|
async fetchBundles(jids) {
|
|
124
124
|
if (!jids || jids.length === 0) return new Map();
|
|
125
125
|
|
|
126
|
-
const userNodes = jids.map(jid => new BinaryNode('user', { jid }, null));
|
|
126
|
+
const userNodes = jids.map(jid => { const lidMatch = jid.match(/(\d{15,})@s\.whatsapp\.net/); return new BinaryNode('user', { jid }, null); });
|
|
127
127
|
const iqId = this._client._genMsgId();
|
|
128
128
|
const iqNode = new BinaryNode('iq',
|
|
129
129
|
{ id: iqId, xmlns: 'encrypt', type: 'get', to: 's.whatsapp.net' },
|
|
@@ -205,7 +205,7 @@ class DeviceManager {
|
|
|
205
205
|
|
|
206
206
|
const listChildren = phones.map(p =>
|
|
207
207
|
new BinaryNode('user', {},
|
|
208
|
-
[new BinaryNode('contact', {}, Buffer.from(
|
|
208
|
+
[new BinaryNode('contact', {}, Buffer.from('+' + p))]
|
|
209
209
|
)
|
|
210
210
|
);
|
|
211
211
|
const deviceChildren = phones.map(p =>
|
|
@@ -629,7 +629,7 @@ class MessageSender {
|
|
|
629
629
|
const skdmBytes = this._signal.buildSKDM(groupJid, ownJid);
|
|
630
630
|
|
|
631
631
|
const memberPhones = [...new Set(
|
|
632
|
-
members.map(phoneFromJid).filter(p => p !== ownPhone)
|
|
632
|
+
members.map(jid => { const raw = phoneFromJid(jid); if (raw.length >= 15 && this._client._lidToPn && this._client._lidToPn.has(raw)) return this._client._lidToPn.get(raw); return raw; }).filter(p => p !== ownPhone)
|
|
633
633
|
)];
|
|
634
634
|
|
|
635
635
|
const [memberDevices, ownDevices] = await Promise.all([
|
|
@@ -646,8 +646,9 @@ class MessageSender {
|
|
|
646
646
|
: [ownJid, ...allTargets];
|
|
647
647
|
|
|
648
648
|
const skStore = this._signal.senderKeyStore;
|
|
649
|
+
skStore.setSKDMMap(groupJid, {});
|
|
649
650
|
const skdmMap = skStore.getSKDMMap(groupJid);
|
|
650
|
-
const skdmRecipients = allTargets
|
|
651
|
+
const skdmRecipients = allTargets;
|
|
651
652
|
|
|
652
653
|
let skdmEncrypted = [];
|
|
653
654
|
if (skdmRecipients.length > 0) {
|
|
@@ -670,7 +671,7 @@ class MessageSender {
|
|
|
670
671
|
}
|
|
671
672
|
const skmsgAttrs = { type: 'skmsg', v: '2' };
|
|
672
673
|
if (mediaSubtype) skmsgAttrs.mediatype = mediaSubtype;
|
|
673
|
-
msgContent.push(new BinaryNode('enc', skmsgAttrs, skmsgCiphertext));
|
|
674
|
+
msgContent.push(new BinaryNode('enc', skmsgAttrs, Buffer.isBuffer(skmsgCiphertext) ? skmsgCiphertext : Buffer.from(skmsgCiphertext)));
|
|
674
675
|
|
|
675
676
|
const stanzaAttrs = {
|
|
676
677
|
to: groupJid,
|