@rexxhayanasi/elaina-baileys 1.1.0-rc.2 → 1.1.0-rc.3
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 +71 -59
- package/package.json +1 -1
package/lib/Socket/socket.js
CHANGED
|
@@ -394,66 +394,78 @@ const end = (error) => {
|
|
|
394
394
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
395
395
|
};
|
|
396
396
|
const requestPairingCode = async (phoneNumber, pairKey = "ELAINAMD") => {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
authState.creds.
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
397
|
+
if (!authState.creds.noiseKey?.public) {
|
|
398
|
+
authState.creds.noiseKey = Utils_1.Curve.generateKeyPair()
|
|
399
|
+
ev.emit('creds.update', authState.creds)
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (!authState.creds.pairingEphemeralKeyPair?.public) {
|
|
403
|
+
authState.creds.pairingEphemeralKeyPair = Utils_1.Curve.generateKeyPair()
|
|
404
|
+
ev.emit('creds.update', authState.creds)
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (pairKey) {
|
|
408
|
+
authState.creds.pairingCode = pairKey.toUpperCase()
|
|
409
|
+
} else {
|
|
410
|
+
authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5))
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
authState.creds.me = {
|
|
414
|
+
id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
|
|
415
|
+
name: '~'
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
ev.emit('creds.update', authState.creds)
|
|
419
|
+
|
|
420
|
+
await sendNode({
|
|
421
|
+
tag: 'iq',
|
|
422
|
+
attrs: {
|
|
423
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
424
|
+
type: 'set',
|
|
425
|
+
id: generateMessageTag(),
|
|
426
|
+
xmlns: 'md'
|
|
427
|
+
},
|
|
428
|
+
content: [
|
|
429
|
+
{
|
|
430
|
+
tag: 'link_code_companion_reg',
|
|
431
|
+
attrs: {
|
|
432
|
+
jid: authState.creds.me.id,
|
|
433
|
+
stage: 'companion_hello',
|
|
434
|
+
should_show_push_notification: 'true'
|
|
435
|
+
},
|
|
436
|
+
content: [
|
|
437
|
+
{
|
|
438
|
+
tag: 'link_code_pairing_wrapped_companion_ephemeral_pub',
|
|
439
|
+
attrs: {},
|
|
440
|
+
content: await generatePairingKey()
|
|
424
441
|
},
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
}
|
|
453
|
-
]
|
|
454
|
-
});
|
|
455
|
-
return authState.creds.pairingCode;
|
|
456
|
-
};
|
|
442
|
+
{
|
|
443
|
+
tag: 'companion_server_auth_key_pub',
|
|
444
|
+
attrs: {},
|
|
445
|
+
content: authState.creds.noiseKey.public
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
tag: 'companion_platform_id',
|
|
449
|
+
attrs: {},
|
|
450
|
+
content: (0, Utils_1.getPlatformId)(browser[1])
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
tag: 'companion_platform_display',
|
|
454
|
+
attrs: {},
|
|
455
|
+
content: `${browser[1]} (${browser[0]})`
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
tag: 'link_code_pairing_nonce',
|
|
459
|
+
attrs: {},
|
|
460
|
+
content: '0'
|
|
461
|
+
}
|
|
462
|
+
]
|
|
463
|
+
}
|
|
464
|
+
]
|
|
465
|
+
})
|
|
466
|
+
|
|
467
|
+
return authState.creds.pairingCode
|
|
468
|
+
}
|
|
457
469
|
async function generatePairingKey() {
|
|
458
470
|
if (!authState?.creds?.pairingEphemeralKeyPair) {
|
|
459
471
|
authState.creds.pairingEphemeralKeyPair = require("../Utils").Curve.generateKeyPair()
|