@rexxhayanasi/elaina-baileys 1.1.0-rc.3 → 1.1.0-rc.4

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.
@@ -40,6 +40,19 @@ const makeSocket = (config) => {
40
40
  routingInfo: (_b = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _b === void 0 ? void 0 : _b.routingInfo
41
41
  });
42
42
  const { creds } = authState;
43
+ if (!creds.noiseKey?.public) {
44
+ creds.noiseKey = Utils_1.Curve.generateKeyPair()
45
+ }
46
+
47
+ if (!creds.signedIdentityKey?.public) {
48
+ creds.signedIdentityKey = Utils_1.Curve.generateKeyPair()
49
+ }
50
+
51
+ if (!creds.advSecretKey) {
52
+ creds.advSecretKey = (0, crypto_1.randomBytes)(32).toString('base64')
53
+ }
54
+
55
+ ev.emit('creds.update', creds)
43
56
  // add transaction capability
44
57
  const keys = (0, Utils_1.addTransactionCapability)(authState.keys, logger, transactionOpts);
45
58
  const signalRepository = makeSignalRepository({ creds, keys });
@@ -53,20 +66,26 @@ const makeSocket = (config) => {
53
66
  const sendPromise = (0, util_1.promisify)(ws.send);
54
67
  /** send a raw buffer */
55
68
  const sendRawMessage = async (data) => {
56
- if (!ws.isOpen) {
57
- throw new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed });
58
- }
59
- const bytes = noise.encodeFrame(data);
60
- await (0, Utils_1.promiseTimeout)(connectTimeoutMs, async (resolve, reject) => {
69
+ if (!ws || ws.isClosed || ws.isClosing || !ws.isOpen) {
70
+ throw new boom_1.Boom('Connection Closed', {
71
+ statusCode: Types_1.DisconnectReason.connectionClosed
72
+ })
73
+ }
74
+
75
+ const bytes = noise.encodeFrame(data)
76
+
77
+ await (0, Utils_1.promiseTimeout)(
78
+ connectTimeoutMs,
79
+ async (resolve, reject) => {
61
80
  try {
62
- await sendPromise.call(ws, bytes);
63
- resolve();
64
- }
65
- catch (error) {
66
- reject(error);
81
+ await sendPromise.call(ws, bytes)
82
+ resolve()
83
+ } catch (error) {
84
+ reject(error)
67
85
  }
68
- });
69
- };
86
+ }
87
+ )
88
+ };
70
89
  /** send a binary node */
71
90
  const sendNode = (frame) => {
72
91
  if (logger.level === 'trace') {
@@ -467,12 +486,12 @@ const end = (error) => {
467
486
  return authState.creds.pairingCode
468
487
  }
469
488
  async function generatePairingKey() {
470
- if (!authState?.creds?.pairingEphemeralKeyPair) {
471
- authState.creds.pairingEphemeralKeyPair = require("../Utils").Curve.generateKeyPair()
489
+ if (!authState.creds.pairingEphemeralKeyPair?.public) {
490
+ authState.creds.pairingEphemeralKeyPair = Utils_1.Curve.generateKeyPair()
472
491
  ev.emit('creds.update', authState.creds)
473
492
  }
474
493
 
475
- if (!authState?.creds?.pairingCode) {
494
+ if (!authState.creds.pairingCode) {
476
495
  throw new Error("Pairing code belum tersedia")
477
496
  }
478
497
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rexxhayanasi/elaina-baileys",
3
- "version": "1.1.0-rc.3",
3
+ "version": "1.1.0-rc.4",
4
4
  "description": "Custom Baileys WhatsApp API",
5
5
  "keywords": [
6
6
  "baileys",