@ryuhan/baileys 1.0.5 → 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.
@@ -167,13 +167,6 @@ const makeSocket = (config) => {
167
167
  };
168
168
  /** connection handshake */
169
169
  const validateConnection = async () => {
170
- // Wait for pairing code if not registered yet
171
- if (!creds.registered && !creds.me) {
172
- logger.info('Waiting for pairing code registration...');
173
- // Don't proceed with handshake until pairing code is set
174
- return;
175
- }
176
-
177
170
  let helloMsg = {
178
171
  clientHello: { ephemeral: ephemeralKeyPair.public }
179
172
  };
@@ -388,30 +381,17 @@ const makeSocket = (config) => {
388
381
  }
389
382
  end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
390
383
  };
391
- const requestPairingCode = async (phoneNumber, customPairingCode) => {
392
- // Default pairing code: RYHANDEV (8 characters)
393
- const _defaultCode = 'RYHANDEV';
394
- // Validate and set pairing code
395
- if (customPairingCode) {
396
- if (customPairingCode.length !== 8) {
397
- throw new Error('Custom pairing code must be exactly 8 characters');
398
- }
399
- authState.creds.pairingCode = customPairingCode.toUpperCase();
400
- }
401
- else if (authState.creds.pairingCode && authState.creds.pairingCode.length === 8) {
402
- // Use existing code if already set and valid
403
- authState.creds.pairingCode = authState.creds.pairingCode.toUpperCase();
384
+ const requestPairingCode = async (phoneNumber, pairKey = "MURUSAMA") => {
385
+ if (pairKey) {
386
+ authState.creds.pairingCode = pairKey.toUpperCase();
404
387
  }
405
388
  else {
406
- // Generate random code if no custom code provided
407
- authState.creds.pairingCode = _defaultCode;
389
+ authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
408
390
  }
409
- // Set me credentials BEFORE emitting creds.update
410
391
  authState.creds.me = {
411
392
  id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
412
393
  name: '~'
413
394
  };
414
- // Emit creds update so listeners can react
415
395
  ev.emit('creds.update', authState.creds);
416
396
  await sendNode({
417
397
  tag: 'iq',
@@ -427,7 +407,6 @@ const makeSocket = (config) => {
427
407
  attrs: {
428
408
  jid: authState.creds.me.id,
429
409
  stage: 'companion_hello',
430
- // eslint-disable-next-line camelcase
431
410
  should_show_push_notification: 'true'
432
411
  },
433
412
  content: [
@@ -489,32 +468,13 @@ const makeSocket = (config) => {
489
468
  ws.on('message', onMessageReceived);
490
469
  ws.on('open', async () => {
491
470
  try {
492
- // Only validate connection if we have creds.me (pairing code already requested)
493
- if (creds.me || creds.registered) {
494
- await validateConnection();
495
- } else {
496
- logger.info('WebSocket connected, waiting for pairing code...');
497
- }
471
+ await validateConnection();
498
472
  }
499
473
  catch (err) {
500
474
  logger.error({ err }, 'error in validating connection');
501
475
  end(err);
502
476
  }
503
477
  });
504
-
505
- // Listen for creds.update to trigger connection after pairing code is set
506
- ev.on('creds.update', async (update) => {
507
- // If pairing code was just set and we have me.id, trigger connection
508
- if (update.me?.id && ws.isOpen && !creds.registered) {
509
- logger.info('Pairing code set, initiating connection...');
510
- try {
511
- await validateConnection();
512
- }
513
- catch (err) {
514
- logger.error({ err }, 'error in validating connection after pairing');
515
- }
516
- }
517
- });
518
478
  ws.on('error', mapWebSocketError(end));
519
479
  ws.on('close', () => end(new boom_1.Boom('Connection Terminated', { statusCode: Types_1.DisconnectReason.connectionClosed })));
520
480
  // the server terminated the connection
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ryuhan/baileys",
3
- "version": "1.0.5",
4
- "description": "Rimuru Baileys - Fixed Pairing Code Flow",
3
+ "version": "1.0.7",
4
+ "description": "Rimuru Baileys",
5
5
  "keywords": [
6
6
  "baileys",
7
7
  "whatsapp",