@rexxhayanasi/elaina-baileys 1.1.0-rc.1 → 1.1.0-rc.2

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.
@@ -455,12 +455,31 @@ const end = (error) => {
455
455
  return authState.creds.pairingCode;
456
456
  };
457
457
  async function generatePairingKey() {
458
- const salt = (0, crypto_1.randomBytes)(32);
459
- const randomIv = (0, crypto_1.randomBytes)(16);
460
- const key = await (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
461
- const ciphered = (0, Utils_1.aesEncryptCTR)(authState.creds.pairingEphemeralKeyPair.public, key, randomIv);
462
- return Buffer.concat([salt, randomIv, ciphered]);
458
+ if (!authState?.creds?.pairingEphemeralKeyPair) {
459
+ authState.creds.pairingEphemeralKeyPair = require("../Utils").Curve.generateKeyPair()
460
+ ev.emit('creds.update', authState.creds)
463
461
  }
462
+
463
+ if (!authState?.creds?.pairingCode) {
464
+ throw new Error("Pairing code belum tersedia")
465
+ }
466
+
467
+ const salt = (0, crypto_1.randomBytes)(32)
468
+ const randomIv = (0, crypto_1.randomBytes)(16)
469
+
470
+ const key = await (0, Utils_1.derivePairingCodeKey)(
471
+ authState.creds.pairingCode,
472
+ salt
473
+ )
474
+
475
+ const ciphered = (0, Utils_1.aesEncryptCTR)(
476
+ authState.creds.pairingEphemeralKeyPair.public,
477
+ key,
478
+ randomIv
479
+ )
480
+
481
+ return Buffer.concat([salt, randomIv, ciphered])
482
+ }
464
483
  const sendWAMBuffer = (wamBuffer) => {
465
484
  return query({
466
485
  tag: 'iq',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rexxhayanasi/elaina-baileys",
3
- "version": "1.1.0-rc.1",
3
+ "version": "1.1.0-rc.2",
4
4
  "description": "Custom Baileys WhatsApp API",
5
5
  "keywords": [
6
6
  "baileys",