@ubedsockets/baileys 1.7.1 → 1.7.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.
@@ -99,47 +99,50 @@ const makeSocket = (config) => {
99
99
  const buff = (0, WABinary_1.encodeBinaryNode)(frame);
100
100
  return sendRawMessage(buff);
101
101
  };
102
- /* log & process any unexpected errors /
102
+
103
+ /* log & process any unexpected errors */
103
104
  const onUnexpectedError = (err, msg) => {
104
- logger.error({ err }, unexpected error in '${msg}');
105
- const message = (err && ((err.stack || err.message) || String(err))).toLowerCase();
106
- // auto recover from cryptographic desyncs by re-uploading prekeys
107
- if (message.includes('bad mac') || (message.includes('mac') && message.includes('invalid'))) {
108
- try {
109
- uploadPreKeysToServerIfRequired(true)
110
- .catch(e => logger.warn({ e }, 'failed to re-upload prekeys after bad mac'));
111
- }
112
- catch (_e) {
113
- // ignore
114
- }
115
- }
105
+ logger.error({ err }, `unexpected error in '${msg}'`);
106
+ const message = (err && ((err.stack || err.message) || String(err))).toLowerCase();
107
+ // auto recover from cryptographic desyncs by re-uploading prekeys
108
+ if (message.includes('bad mac') || (message.includes('mac') && message.includes('invalid'))) {
109
+ try {
110
+ uploadPreKeysToServerIfRequired(true)
111
+ .catch(e => logger.warn({ e }, 'failed to re-upload prekeys after bad mac'));
112
+ }
113
+ catch (_e) {
114
+ // ignore
115
+ }
116
+ }
116
117
  };
117
- /* await the next incoming message /
118
+
119
+ /* await the next incoming message */
118
120
  const awaitNextMessage = async (sendMsg) => {
119
- if (!ws.isOpen) {
120
- throw new boom_1.Boom('Connection Closed', {
121
- statusCode: Types_1.DisconnectReason.connectionClosed
122
- });
123
- }
124
- let onOpen;
125
- let onClose;
126
- const result = (0, Utils_1.promiseTimeout)(connectTimeoutMs, (resolve, reject) => {
127
- onOpen = resolve;
128
- onClose = mapWebSocketError(reject);
129
- ws.on('frame', onOpen);
130
- ws.on('close', onClose);
131
- ws.on('error', onClose);
132
- })
133
- .finally(() => {
134
- ws.off('frame', onOpen);
135
- ws.off('close', onClose);
136
- ws.off('error', onClose);
137
- });
138
- if (sendMsg) {
139
- sendRawMessage(sendMsg).catch(onClose);
140
- }
141
- return result;
121
+ if (!ws.isOpen) {
122
+ throw new boom_1.Boom('Connection Closed', {
123
+ statusCode: Types_1.DisconnectReason.connectionClosed
124
+ });
125
+ }
126
+ let onOpen;
127
+ let onClose;
128
+ const result = (0, Utils_1.promiseTimeout)(connectTimeoutMs, (resolve, reject) => {
129
+ onOpen = resolve;
130
+ onClose = mapWebSocketError(reject);
131
+ ws.on('frame', onOpen);
132
+ ws.on('close', onClose);
133
+ ws.on('error', onClose);
134
+ })
135
+ .finally(() => {
136
+ ws.off('frame', onOpen);
137
+ ws.off('close', onClose);
138
+ ws.off('error', onClose);
139
+ });
140
+ if (sendMsg) {
141
+ sendRawMessage(sendMsg).catch(onClose);
142
+ }
143
+ return result;
142
144
  };
145
+
143
146
  /*
144
147
  Wait for a message with a certain tag to be received
145
148
  @param msgId the message tag to await
@@ -259,7 +262,7 @@ const makeSocket = (config) => {
259
262
  logger.trace({ xml: (0, WABinary_1.binaryNodeToString)(frame), msg: 'recv xml' });
260
263
  }
261
264
  /* Check if this is a response to a message we sent */
262
- anyTriggered = ws.emit(`${Defaults_1.DEF_TAG_PREFIX}${msgId}, frame`) || anyTriggered;
265
+ anyTriggered = ws.emit(`${Defaults_1.DEF_TAG_PREFIX}${msgId}`, frame) || anyTriggered;
263
266
  /* Check if this is a response to a message we are expecting */
264
267
  const l0 = frame.tag;
265
268
  const l1 = frame.attrs || {};
@@ -664,4 +667,4 @@ function mapWebSocketError(handler) {
664
667
  return (error) => {
665
668
  handler(new boom_1.Boom(`WebSocket Error (${error === null || error === void 0 ? void 0 : error.message})`, { statusCode: (0, Utils_1.getCodeFromWSError)(error), data: error }));
666
669
  };
667
- }
670
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubedsockets/baileys",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "@ubedsockets/baileys,baileys A high-performance WhatsApp Web API wrapper based on Baileys, optimized for bot developers with integrated utility scrapers.",
5
5
  "keywords": [
6
6
  "baileys",