@ryuhan/baileys 1.0.4 → 1.0.6
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 +20 -14
- package/package.json +2 -2
package/lib/Socket/socket.js
CHANGED
|
@@ -385,27 +385,30 @@ const makeSocket = (config) => {
|
|
|
385
385
|
// Default pairing code: RYHANDEV (8 characters)
|
|
386
386
|
const _defaultCode = 'RYHANDEV';
|
|
387
387
|
// Validate and set pairing code
|
|
388
|
+
let pairingCode;
|
|
388
389
|
if (customPairingCode) {
|
|
389
390
|
if (customPairingCode.length !== 8) {
|
|
390
391
|
throw new Error('Custom pairing code must be exactly 8 characters');
|
|
391
392
|
}
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
// Set me credentials BEFORE emitting creds.update
|
|
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!)
|
|
403
402
|
authState.creds.me = {
|
|
404
403
|
id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
|
|
405
404
|
name: '~'
|
|
406
405
|
};
|
|
407
|
-
|
|
406
|
+
|
|
407
|
+
// Emit creds update - this will trigger connection
|
|
408
408
|
ev.emit('creds.update', authState.creds);
|
|
409
|
+
|
|
410
|
+
logger.info({ phoneNumber, pairingCode }, 'Requesting pairing code...');
|
|
411
|
+
|
|
409
412
|
await sendNode({
|
|
410
413
|
tag: 'iq',
|
|
411
414
|
attrs: {
|
|
@@ -420,7 +423,6 @@ const makeSocket = (config) => {
|
|
|
420
423
|
attrs: {
|
|
421
424
|
jid: authState.creds.me.id,
|
|
422
425
|
stage: 'companion_hello',
|
|
423
|
-
// eslint-disable-next-line camelcase
|
|
424
426
|
should_show_push_notification: 'true'
|
|
425
427
|
},
|
|
426
428
|
content: [
|
|
@@ -453,6 +455,7 @@ const makeSocket = (config) => {
|
|
|
453
455
|
}
|
|
454
456
|
]
|
|
455
457
|
});
|
|
458
|
+
|
|
456
459
|
return authState.creds.pairingCode;
|
|
457
460
|
};
|
|
458
461
|
async function generatePairingKey() {
|
|
@@ -595,8 +598,11 @@ const makeSocket = (config) => {
|
|
|
595
598
|
// if we're logged in
|
|
596
599
|
ev.buffer();
|
|
597
600
|
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...');
|
|
598
605
|
}
|
|
599
|
-
ev.emit('connection.update', { connection: 'connecting', receivedPendingNotifications: false, qr: undefined });
|
|
600
606
|
});
|
|
601
607
|
// called when all offline notifs are handled
|
|
602
608
|
ws.on('CB:ib,,offline', (node) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryuhan/baileys",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Rimuru Baileys - Fixed
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "Rimuru Baileys - Fixed Pairing Code Flow (blck-baileys compatible)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"baileys",
|
|
7
7
|
"whatsapp",
|