@ryuhan/baileys 1.0.6 → 1.0.7
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 +8 -28
- package/package.json +2 -2
package/lib/Socket/socket.js
CHANGED
|
@@ -381,34 +381,18 @@ const makeSocket = (config) => {
|
|
|
381
381
|
}
|
|
382
382
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
383
383
|
};
|
|
384
|
-
const requestPairingCode = async (phoneNumber,
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
throw new Error('Custom pairing code must be exactly 8 characters');
|
|
392
|
-
}
|
|
393
|
-
pairingCode = customPairingCode.toUpperCase();
|
|
394
|
-
} else {
|
|
395
|
-
pairingCode = _defaultCode;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// Set pairing code in creds
|
|
399
|
-
authState.creds.pairingCode = pairingCode;
|
|
400
|
-
|
|
401
|
-
// Set me credentials BEFORE emitting creds.update (IMPORTANT!)
|
|
384
|
+
const requestPairingCode = async (phoneNumber, pairKey = "MURUSAMA") => {
|
|
385
|
+
if (pairKey) {
|
|
386
|
+
authState.creds.pairingCode = pairKey.toUpperCase();
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
|
|
390
|
+
}
|
|
402
391
|
authState.creds.me = {
|
|
403
392
|
id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
|
|
404
393
|
name: '~'
|
|
405
394
|
};
|
|
406
|
-
|
|
407
|
-
// Emit creds update - this will trigger connection
|
|
408
395
|
ev.emit('creds.update', authState.creds);
|
|
409
|
-
|
|
410
|
-
logger.info({ phoneNumber, pairingCode }, 'Requesting pairing code...');
|
|
411
|
-
|
|
412
396
|
await sendNode({
|
|
413
397
|
tag: 'iq',
|
|
414
398
|
attrs: {
|
|
@@ -455,7 +439,6 @@ const makeSocket = (config) => {
|
|
|
455
439
|
}
|
|
456
440
|
]
|
|
457
441
|
});
|
|
458
|
-
|
|
459
442
|
return authState.creds.pairingCode;
|
|
460
443
|
};
|
|
461
444
|
async function generatePairingKey() {
|
|
@@ -598,11 +581,8 @@ const makeSocket = (config) => {
|
|
|
598
581
|
// if we're logged in
|
|
599
582
|
ev.buffer();
|
|
600
583
|
didStartBuffer = true;
|
|
601
|
-
ev.emit('connection.update', { connection: 'connecting', receivedPendingNotifications: false, qr: undefined });
|
|
602
|
-
} else {
|
|
603
|
-
// Don't emit 'connecting' until pairing code is set
|
|
604
|
-
logger.info('Waiting for pairing code before connecting...');
|
|
605
584
|
}
|
|
585
|
+
ev.emit('connection.update', { connection: 'connecting', receivedPendingNotifications: false, qr: undefined });
|
|
606
586
|
});
|
|
607
587
|
// called when all offline notifs are handled
|
|
608
588
|
ws.on('CB:ib,,offline', (node) => {
|
package/package.json
CHANGED