@zephkiel/wbails 2.0.8 → 2.0.9
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/Socket/socket.js +67 -60
- package/package.json +1 -1
package/lib/Socket/socket.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeSocket = void 0;
|
|
4
4
|
const boom_1 = require("@hapi/boom");
|
|
@@ -385,68 +385,75 @@ const makeSocket = (config) => {
|
|
|
385
385
|
};
|
|
386
386
|
|
|
387
387
|
const requestPairingCode = async (phoneNumber, pairKey) => {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
388
|
+
|
|
389
|
+
if (!ws.isOpen) {
|
|
390
|
+
await waitForSocketOpen()
|
|
391
|
+
}
|
|
393
392
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
393
|
+
if (pairKey) {
|
|
394
|
+
authState.creds.pairingCode = pairKey.toUpperCase();
|
|
395
|
+
} else {
|
|
396
|
+
authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
|
|
397
|
+
}
|
|
398
398
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
399
|
+
authState.creds.me = {
|
|
400
|
+
id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
|
|
401
|
+
name: '~'
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
ev.emit('creds.update', authState.creds);
|
|
405
|
+
|
|
406
|
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
|
407
|
+
|
|
408
|
+
await sendNode({
|
|
409
|
+
tag: 'iq',
|
|
410
|
+
attrs: {
|
|
411
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
412
|
+
type: 'set',
|
|
413
|
+
id: generateMessageTag(),
|
|
414
|
+
xmlns: 'md'
|
|
415
|
+
},
|
|
416
|
+
content: [
|
|
417
|
+
{
|
|
418
|
+
tag: 'link_code_companion_reg',
|
|
419
|
+
attrs: {
|
|
420
|
+
jid: authState.creds.me.id,
|
|
421
|
+
stage: 'companion_hello',
|
|
422
|
+
should_show_push_notification: 'true'
|
|
423
|
+
},
|
|
424
|
+
content: [
|
|
425
|
+
{
|
|
426
|
+
tag: 'link_code_pairing_wrapped_companion_ephemeral_pub',
|
|
427
|
+
attrs: {},
|
|
428
|
+
content: await generatePairingKey()
|
|
416
429
|
},
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
]
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
return authState.creds.pairingCode;
|
|
449
|
-
}
|
|
430
|
+
{
|
|
431
|
+
tag: 'companion_server_auth_key_pub',
|
|
432
|
+
attrs: {},
|
|
433
|
+
content: authState.creds.noiseKey.public
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
tag: 'companion_platform_id',
|
|
437
|
+
attrs: {},
|
|
438
|
+
content: (0, Utils_1.getPlatformId)(browser[1])
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
tag: 'companion_platform_display',
|
|
442
|
+
attrs: {},
|
|
443
|
+
content: `${browser[1]} (${browser[0]})`
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
tag: 'link_code_pairing_nonce',
|
|
447
|
+
attrs: {},
|
|
448
|
+
content: "0"
|
|
449
|
+
}
|
|
450
|
+
]
|
|
451
|
+
}
|
|
452
|
+
]
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
return authState.creds.pairingCode;
|
|
456
|
+
}
|
|
450
457
|
async function generatePairingKey() {
|
|
451
458
|
const salt = (0, crypto_1.randomBytes)(32);
|
|
452
459
|
const randomIv = (0, crypto_1.randomBytes)(16);
|