@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.
@@ -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
- if (pairKey) {
398
- authState.creds.pairingCode = pairKey.toUpperCase();
399
- }
400
- else {
401
- authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
402
- }
403
- authState.creds.me = {
404
- id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
405
- name: '~'
406
- };
407
- ev.emit('creds.update', authState.creds);
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
- // eslint-disable-next-line camelcase
423
- should_show_push_notification: 'true'
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
- content: [
426
- {
427
- tag: 'link_code_pairing_wrapped_companion_ephemeral_pub',
428
- attrs: {},
429
- content: await generatePairingKey()
430
- },
431
- {
432
- tag: 'companion_server_auth_key_pub',
433
- attrs: {},
434
- content: authState.creds.noiseKey.public
435
- },
436
- {
437
- tag: 'companion_platform_id',
438
- attrs: {},
439
- content: (0, Utils_1.getPlatformId)(browser[1])
440
- },
441
- {
442
- tag: 'companion_platform_display',
443
- attrs: {},
444
- content: `${browser[1]} (${browser[0]})`
445
- },
446
- {
447
- tag: 'link_code_pairing_nonce',
448
- attrs: {},
449
- content: '0'
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()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rexxhayanasi/elaina-baileys",
3
- "version": "1.1.0-rc.2",
3
+ "version": "1.1.0-rc.3",
4
4
  "description": "Custom Baileys WhatsApp API",
5
5
  "keywords": [
6
6
  "baileys",