whalibmob 5.5.41 → 5.5.42
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/DeviceManager.js +20 -18
- package/package.json +1 -1
package/lib/DeviceManager.js
CHANGED
|
@@ -423,44 +423,48 @@ class DeviceManager {
|
|
|
423
423
|
//
|
|
424
424
|
// APK-confirmed format (extracted from WhatsApp DEX string tables):
|
|
425
425
|
//
|
|
426
|
+
// Correct wire format (verified against live WA server):
|
|
427
|
+
//
|
|
426
428
|
// <iq to="s.whatsapp.net" type="get" xmlns="usync">
|
|
427
|
-
// <usync sid="..." mode="query" last="true" index="0" context="
|
|
429
|
+
// <usync sid="..." mode="query" last="true" index="0" context="interactive">
|
|
428
430
|
// <query>
|
|
429
|
-
// <devices version="2"
|
|
431
|
+
// <devices version="2"/>
|
|
430
432
|
// <lid/>
|
|
433
|
+
// <contact/>
|
|
431
434
|
// </query>
|
|
432
435
|
// <list>
|
|
433
|
-
// <user><contact>+phone</contact></user> ← Buffer,
|
|
436
|
+
// <user><contact>+phone</contact></user> ← Buffer, NOT jid attr
|
|
434
437
|
// </list>
|
|
435
438
|
// <side_list/>
|
|
436
439
|
// </usync>
|
|
437
440
|
// </iq>
|
|
438
441
|
//
|
|
439
|
-
//
|
|
442
|
+
// Key findings vs original buggy whalibmob implementation:
|
|
443
|
+
//
|
|
444
|
+
// Fix A — User list format was wrong (jid attr → server ignored IQ):
|
|
445
|
+
// Correct: <user><contact>+phone</contact></user> (Buffer content, same as _doContactUsync)
|
|
446
|
+
// Wrong: <user jid="phone@s.whatsapp.net"/> (jid attr — server silently drops IQ)
|
|
440
447
|
//
|
|
441
|
-
// Fix
|
|
442
|
-
//
|
|
443
|
-
// fetch_options
|
|
444
|
-
//
|
|
448
|
+
// Fix B — Extra <devices> attributes break the IQ:
|
|
449
|
+
// device_orientation="0" and fetch_options="5" both cause the server to ignore the IQ.
|
|
450
|
+
// fetch_options is not in the binary token dict → encoded as BINARY_8 → server parse error.
|
|
451
|
+
// Use only version="2" on <devices>. Server returns ALL linked devices without extra attrs.
|
|
445
452
|
//
|
|
446
|
-
// Fix
|
|
453
|
+
// Fix C — context and side_list must match _doContactUsync (the working format):
|
|
454
|
+
// context="interactive" + <side_list/> is REQUIRED. context="message" → server ignores IQ.
|
|
447
455
|
async _doUsyncIq(phones) {
|
|
448
456
|
const iqId = this._client._genMsgId();
|
|
449
457
|
const sid = this._client._genMsgId();
|
|
450
458
|
|
|
451
|
-
// User list:
|
|
452
|
-
// This is the ONLY format the server responds to for phone-based usync.
|
|
453
|
-
// The <user jid="..."/> attribute format is silently ignored by the server.
|
|
459
|
+
// User list: identical to contact usync format that the server responds to.
|
|
454
460
|
const listChildren = phones.map(p =>
|
|
455
461
|
new BinaryNode('user', {}, [
|
|
456
462
|
new BinaryNode('contact', {}, Buffer.from('+' + p, 'utf8'))
|
|
457
463
|
])
|
|
458
464
|
);
|
|
459
465
|
|
|
460
|
-
//
|
|
461
|
-
//
|
|
462
|
-
// Query includes <devices>, <lid>, AND <contact> so the server returns
|
|
463
|
-
// the full device list + LID mapping + contact presence in one round-trip.
|
|
466
|
+
// Same structure as _doContactUsync (which works) but with <devices> and <lid>
|
|
467
|
+
// added to the query. context="interactive" + side_list matches the working format.
|
|
464
468
|
const iqNode = new BinaryNode('iq',
|
|
465
469
|
{ id: iqId, to: 's.whatsapp.net', type: 'get', xmlns: 'usync' },
|
|
466
470
|
[new BinaryNode('usync',
|
|
@@ -824,8 +828,6 @@ class DeviceManager {
|
|
|
824
828
|
[
|
|
825
829
|
new BinaryNode('query', {},
|
|
826
830
|
[
|
|
827
|
-
// context="interactive" is REQUIRED — server silently ignores
|
|
828
|
-
// "message" context usync IQs (same as _doUsyncIq).
|
|
829
831
|
new BinaryNode('devices', { version: '2' }, null),
|
|
830
832
|
new BinaryNode('lid', {}, null)
|
|
831
833
|
]
|