@baileys-md/baileys 10.1.0 → 11.0.0

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.
Files changed (122) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1303 -2
  3. package/WAProto/GenerateStatics.sh +3 -0
  4. package/WAProto/WAProto.proto +4633 -0
  5. package/WAProto/fix-imports.js +29 -0
  6. package/WAProto/index.js +13516 -4182
  7. package/lib/Defaults/baileys-version.js +1 -0
  8. package/lib/Defaults/index.js +51 -72
  9. package/lib/Signal/Group/ciphertext-message.js +12 -0
  10. package/lib/Signal/Group/group-session-builder.js +30 -0
  11. package/lib/Signal/Group/group_cipher.js +94 -0
  12. package/lib/Signal/Group/index.js +12 -0
  13. package/lib/Signal/Group/keyhelper.js +19 -0
  14. package/lib/Signal/Group/queue-job.js +54 -0
  15. package/lib/Signal/Group/sender-chain-key.js +32 -0
  16. package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
  17. package/lib/Signal/Group/sender-key-message.js +67 -0
  18. package/lib/Signal/Group/sender-key-name.js +48 -0
  19. package/lib/Signal/Group/sender-key-record.js +50 -0
  20. package/lib/Signal/Group/sender-key-state.js +96 -0
  21. package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +4 -16
  22. package/lib/Signal/libsignal.js +41 -61
  23. package/lib/Socket/Client/index.js +3 -19
  24. package/lib/Socket/Client/types.js +11 -0
  25. package/lib/Socket/Client/websocket.js +50 -0
  26. package/lib/Socket/business.js +37 -42
  27. package/lib/Socket/chats.js +194 -187
  28. package/lib/Socket/communities.js +351 -0
  29. package/lib/Socket/groups.js +87 -90
  30. package/lib/Socket/index.js +7 -8
  31. package/lib/Socket/messages-recv.js +360 -335
  32. package/lib/Socket/messages-send.js +156 -279
  33. package/lib/Socket/mex.js +42 -0
  34. package/lib/Socket/newsletter.js +144 -213
  35. package/lib/Socket/socket.js +128 -161
  36. package/lib/Socket/usync.js +19 -26
  37. package/lib/Types/Auth.js +2 -2
  38. package/lib/Types/Call.js +2 -2
  39. package/lib/Types/Chat.js +8 -4
  40. package/lib/Types/Contact.js +2 -2
  41. package/lib/Types/Events.js +2 -2
  42. package/lib/Types/GroupMetadata.js +2 -2
  43. package/lib/Types/Label.js +3 -5
  44. package/lib/Types/LabelAssociation.js +3 -5
  45. package/lib/Types/Message.js +7 -7
  46. package/lib/Types/Newsletter.js +30 -17
  47. package/lib/Types/Product.js +2 -2
  48. package/lib/Types/Signal.js +2 -2
  49. package/lib/Types/Socket.js +3 -2
  50. package/lib/Types/State.js +2 -2
  51. package/lib/Types/USync.js +2 -2
  52. package/lib/Types/index.js +15 -31
  53. package/lib/Utils/auth-utils.js +31 -47
  54. package/lib/Utils/baileys-event-stream.js +15 -22
  55. package/lib/Utils/business.js +66 -69
  56. package/lib/Utils/chat-utils.js +200 -195
  57. package/lib/Utils/crypto.js +70 -85
  58. package/lib/Utils/decode-wa-message.js +47 -51
  59. package/lib/Utils/event-buffer.js +36 -46
  60. package/lib/Utils/generics.js +116 -188
  61. package/lib/Utils/history.js +37 -46
  62. package/lib/Utils/index.js +19 -33
  63. package/lib/Utils/link-preview.js +14 -55
  64. package/lib/Utils/logger.js +3 -7
  65. package/lib/Utils/lt-hash.js +23 -26
  66. package/lib/{Store → Utils}/make-in-memory-store.js +19 -27
  67. package/lib/Utils/make-mutex.js +7 -10
  68. package/lib/{Store → Utils}/make-ordered-dictionary.js +1 -3
  69. package/lib/Utils/messages-media.js +236 -368
  70. package/lib/Utils/messages.js +278 -510
  71. package/lib/Utils/noise-handler.js +22 -31
  72. package/lib/{Store → Utils}/object-repository.js +1 -4
  73. package/lib/Utils/process-message.js +144 -148
  74. package/lib/Utils/signal.js +71 -64
  75. package/lib/Utils/use-multi-file-auth-state.js +112 -84
  76. package/lib/Utils/validate-connection.js +72 -115
  77. package/lib/WABinary/constants.js +1281 -20
  78. package/lib/WABinary/decode.js +15 -52
  79. package/lib/WABinary/encode.js +14 -48
  80. package/lib/WABinary/generic-utils.js +31 -39
  81. package/lib/WABinary/index.js +6 -21
  82. package/lib/WABinary/jid-utils.js +23 -40
  83. package/lib/WABinary/types.js +2 -2
  84. package/lib/WAM/BinaryInfo.js +2 -5
  85. package/lib/WAM/constants.js +2257 -2366
  86. package/lib/WAM/encode.js +17 -21
  87. package/lib/WAM/index.js +4 -19
  88. package/lib/WAUSync/Protocols/USyncContactProtocol.js +8 -11
  89. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +11 -14
  90. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -12
  91. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +9 -13
  92. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +20 -22
  93. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +3 -6
  94. package/lib/WAUSync/Protocols/index.js +5 -20
  95. package/lib/WAUSync/USyncQuery.js +34 -32
  96. package/lib/WAUSync/USyncUser.js +2 -5
  97. package/lib/WAUSync/index.js +4 -19
  98. package/lib/index.js +11 -33
  99. package/package.json +25 -54
  100. package/WASignalGroup/GroupProtocol.js +0 -1697
  101. package/WASignalGroup/ciphertext_message.js +0 -16
  102. package/WASignalGroup/group_cipher.js +0 -120
  103. package/WASignalGroup/group_session_builder.js +0 -46
  104. package/WASignalGroup/index.js +0 -5
  105. package/WASignalGroup/keyhelper.js +0 -21
  106. package/WASignalGroup/protobufs.js +0 -3
  107. package/WASignalGroup/queue_job.js +0 -69
  108. package/WASignalGroup/sender_chain_key.js +0 -50
  109. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  110. package/WASignalGroup/sender_key_message.js +0 -92
  111. package/WASignalGroup/sender_key_name.js +0 -70
  112. package/WASignalGroup/sender_key_record.js +0 -56
  113. package/WASignalGroup/sender_key_state.js +0 -129
  114. package/lib/Defaults/baileys-version.json +0 -3
  115. package/lib/Defaults/phonenumber-mcc.json +0 -223
  116. package/lib/Socket/Client/abstract-socket-client.js +0 -13
  117. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  118. package/lib/Socket/Client/web-socket-client.js +0 -62
  119. package/lib/Socket/registration.js +0 -166
  120. package/lib/Store/index.js +0 -8
  121. package/lib/Store/make-cache-manager-store.js +0 -83
  122. package/lib/Store/make-mongo-store.js +0 -567
@@ -1,46 +1,41 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.makeMessagesSocket = void 0;
7
- const boom_1 = require("@hapi/boom");
8
- const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
9
- const WAProto_1 = require("../../WAProto");
10
- const Defaults_1 = require("../Defaults");
11
- const Utils_1 = require("../Utils");
12
- const link_preview_1 = require("../Utils/link-preview");
13
- const WABinary_1 = require("../WABinary");
14
- const WAUSync_1 = require("../WAUSync");
15
- const newsletter_1 = require("./newsletter");
16
- var ListType = WAProto_1.proto.Message.ListMessage.ListType;
17
- const makeMessagesSocket = (config) => {
18
- const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, cachedGroupMetadata, } = config;
19
- const sock = (0, newsletter_1.makeNewsletterSocket)(config);
20
- const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, sendNode, groupMetadata, groupToggleEphemeral, } = sock;
21
- const userDevicesCache = config.userDevicesCache || new node_cache_1.default({
22
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES, // 5 minutes
23
- useClones: false
24
- });
1
+ import NodeCache from '@cacheable/node-cache';
2
+ import { Boom } from '@hapi/boom';
3
+ import { proto } from '../../WAProto/index.js';
4
+ import { DEFAULT_CACHE_TTLS, WA_DEFAULT_EPHEMERAL } from '../Defaults/index.js';
5
+ import { aggregateMessageKeysNotFromMe, assertMediaContent, bindWaitForEvent, decryptMediaRetryData, encodeNewsletterMessage, encodeSignedDeviceIdentity, encodeWAMessage, encryptMediaRetryRequest, extractDeviceJids, generateMessageIDV2, generateWAMessage, getStatusCodeForMediaRetry, getUrlFromDirectPath, getWAUploadToServer, normalizeMessageContent, parseAndInjectE2ESessions, unixTimestampSeconds } from '../Utils/index.js';
6
+ import { getUrlInfo } from '../Utils/link-preview.js';
7
+ import { areJidsSameUser, getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, isJidUser, jidDecode, jidEncode, jidNormalizedUser, S_WHATSAPP_NET } from '../WABinary/index.js';
8
+ import { USyncQuery, USyncUser } from '../WAUSync/index.js';
9
+ import { makeGroupsSocket } from './groups.js';
10
+ import { makeNewsletterSocket } from './newsletter.js';
11
+ export const makeMessagesSocket = (config) => {
12
+ const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, cachedGroupMetadata } = config;
13
+ const sock = makeNewsletterSocket(makeGroupsSocket(config));
14
+ const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, sendNode, groupMetadata, groupToggleEphemeral } = sock;
15
+ const userDevicesCache = config.userDevicesCache ||
16
+ new NodeCache({
17
+ stdTTL: DEFAULT_CACHE_TTLS.USER_DEVICES, // 5 minutes
18
+ useClones: false
19
+ });
25
20
  let mediaConn;
26
21
  const refreshMediaConn = async (forceGet = false) => {
27
22
  const media = await mediaConn;
28
- if (!media || forceGet || (new Date().getTime() - media.fetchDate.getTime()) > media.ttl * 1000) {
23
+ if (!media || forceGet || new Date().getTime() - media.fetchDate.getTime() > media.ttl * 1000) {
29
24
  mediaConn = (async () => {
30
25
  const result = await query({
31
26
  tag: 'iq',
32
27
  attrs: {
33
28
  type: 'set',
34
29
  xmlns: 'w:m',
35
- to: WABinary_1.S_WHATSAPP_NET,
30
+ to: S_WHATSAPP_NET
36
31
  },
37
32
  content: [{ tag: 'media_conn', attrs: {} }]
38
33
  });
39
- const mediaConnNode = (0, WABinary_1.getBinaryNodeChild)(result, 'media_conn');
34
+ const mediaConnNode = getBinaryNodeChild(result, 'media_conn');
40
35
  const node = {
41
- hosts: (0, WABinary_1.getBinaryNodeChildren)(mediaConnNode, 'host').map(({ attrs }) => ({
36
+ hosts: getBinaryNodeChildren(mediaConnNode, 'host').map(({ attrs }) => ({
42
37
  hostname: attrs.hostname,
43
- maxContentLengthBytes: +attrs.maxContentLengthBytes,
38
+ maxContentLengthBytes: +attrs.maxContentLengthBytes
44
39
  })),
45
40
  auth: mediaConnNode.attrs.auth,
46
41
  ttl: +mediaConnNode.attrs.ttl,
@@ -57,17 +52,20 @@ const makeMessagesSocket = (config) => {
57
52
  * used for receipts of phone call, read, delivery etc.
58
53
  * */
59
54
  const sendReceipt = async (jid, participant, messageIds, type) => {
55
+ if (!messageIds || messageIds.length === 0) {
56
+ throw new Boom('missing ids in receipt');
57
+ }
60
58
  const node = {
61
59
  tag: 'receipt',
62
60
  attrs: {
63
- id: messageIds[0],
64
- },
61
+ id: messageIds[0]
62
+ }
65
63
  };
66
64
  const isReadReceipt = type === 'read' || type === 'read-self';
67
65
  if (isReadReceipt) {
68
- node.attrs.t = (0, Utils_1.unixTimestampSeconds)().toString();
66
+ node.attrs.t = unixTimestampSeconds().toString();
69
67
  }
70
- if (type === 'sender' && (0, WABinary_1.isJidUser)(jid)) {
68
+ if (type === 'sender' && isJidUser(jid)) {
71
69
  node.attrs.recipient = jid;
72
70
  node.attrs.to = participant;
73
71
  }
@@ -78,7 +76,7 @@ const makeMessagesSocket = (config) => {
78
76
  }
79
77
  }
80
78
  if (type) {
81
- node.attrs.type = (0, WABinary_1.isJidNewsletter)(jid) ? 'read-self' : type;
79
+ node.attrs.type = type;
82
80
  }
83
81
  const remainingMessageIds = messageIds.slice(1);
84
82
  if (remainingMessageIds.length) {
@@ -98,7 +96,7 @@ const makeMessagesSocket = (config) => {
98
96
  };
99
97
  /** Correctly bulk send receipts to multiple chats, participants */
100
98
  const sendReceipts = async (keys, type) => {
101
- const recps = (0, Utils_1.aggregateMessageKeysNotFromMe)(keys);
99
+ const recps = aggregateMessageKeysNotFromMe(keys);
102
100
  for (const { jid, participant, messageIds } of recps) {
103
101
  await sendReceipt(jid, participant, messageIds, type);
104
102
  }
@@ -112,7 +110,6 @@ const makeMessagesSocket = (config) => {
112
110
  };
113
111
  /** Fetch all the devices we've to send a message to */
114
112
  const getUSyncDevices = async (jids, useCache, ignoreZeroDevices) => {
115
- var _a;
116
113
  const deviceResults = [];
117
114
  if (!useCache) {
118
115
  logger.debug('not using cache for devices');
@@ -120,8 +117,8 @@ const makeMessagesSocket = (config) => {
120
117
  const toFetch = [];
121
118
  jids = Array.from(new Set(jids));
122
119
  for (let jid of jids) {
123
- const user = (_a = (0, WABinary_1.jidDecode)(jid)) === null || _a === void 0 ? void 0 : _a.user;
124
- jid = (0, WABinary_1.jidNormalizedUser)(jid);
120
+ const user = jidDecode(jid)?.user;
121
+ jid = jidNormalizedUser(jid);
125
122
  if (useCache) {
126
123
  const devices = userDevicesCache.get(user);
127
124
  if (devices) {
@@ -139,19 +136,17 @@ const makeMessagesSocket = (config) => {
139
136
  if (!toFetch.length) {
140
137
  return deviceResults;
141
138
  }
142
- const query = new WAUSync_1.USyncQuery()
143
- .withContext('message')
144
- .withDeviceProtocol();
139
+ const query = new USyncQuery().withContext('message').withDeviceProtocol();
145
140
  for (const jid of toFetch) {
146
- query.withUser(new WAUSync_1.USyncUser().withId(jid));
141
+ query.withUser(new USyncUser().withId(jid));
147
142
  }
148
143
  const result = await sock.executeUSyncQuery(query);
149
144
  if (result) {
150
- const extracted = (0, Utils_1.extractDeviceJids)(result === null || result === void 0 ? void 0 : result.list, authState.creds.me.id, ignoreZeroDevices);
145
+ const extracted = extractDeviceJids(result?.list, authState.creds.me.id, ignoreZeroDevices);
151
146
  const deviceMap = {};
152
147
  for (const item of extracted) {
153
148
  deviceMap[item.user] = deviceMap[item.user] || [];
154
- deviceMap[item.user].push(item);
149
+ deviceMap[item.user]?.push(item);
155
150
  deviceResults.push(item);
156
151
  }
157
152
  for (const key in deviceMap) {
@@ -167,12 +162,10 @@ const makeMessagesSocket = (config) => {
167
162
  jidsRequiringFetch = jids;
168
163
  }
169
164
  else {
170
- const addrs = jids.map(jid => (signalRepository
171
- .jidToSignalProtocolAddress(jid)));
165
+ const addrs = jids.map(jid => signalRepository.jidToSignalProtocolAddress(jid));
172
166
  const sessions = await authState.keys.get('session', addrs);
173
167
  for (const jid of jids) {
174
- const signalId = signalRepository
175
- .jidToSignalProtocolAddress(jid);
168
+ const signalId = signalRepository.jidToSignalProtocolAddress(jid);
176
169
  if (!sessions[signalId]) {
177
170
  jidsRequiringFetch.push(jid);
178
171
  }
@@ -185,7 +178,7 @@ const makeMessagesSocket = (config) => {
185
178
  attrs: {
186
179
  xmlns: 'encrypt',
187
180
  type: 'get',
188
- to: WABinary_1.S_WHATSAPP_NET,
181
+ to: S_WHATSAPP_NET
189
182
  },
190
183
  content: [
191
184
  {
@@ -193,35 +186,33 @@ const makeMessagesSocket = (config) => {
193
186
  attrs: {},
194
187
  content: jidsRequiringFetch.map(jid => ({
195
188
  tag: 'user',
196
- attrs: { jid },
189
+ attrs: { jid }
197
190
  }))
198
191
  }
199
192
  ]
200
193
  });
201
- await (0, Utils_1.parseAndInjectE2ESessions)(result, signalRepository);
194
+ await parseAndInjectE2ESessions(result, signalRepository);
202
195
  didFetchNewSession = true;
203
196
  }
204
197
  return didFetchNewSession;
205
198
  };
206
199
  const sendPeerDataOperationMessage = async (pdoMessage) => {
207
- var _a;
208
200
  //TODO: for later, abstract the logic to send a Peer Message instead of just PDO - useful for App State Key Resync with phone
209
- if (!((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id)) {
210
- throw new boom_1.Boom('Not authenticated');
201
+ if (!authState.creds.me?.id) {
202
+ throw new Boom('Not authenticated');
211
203
  }
212
204
  const protocolMessage = {
213
205
  protocolMessage: {
214
206
  peerDataOperationRequestMessage: pdoMessage,
215
- type: WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_MESSAGE
207
+ type: proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_MESSAGE
216
208
  }
217
209
  };
218
- const meJid = (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id);
210
+ const meJid = jidNormalizedUser(authState.creds.me.id);
219
211
  const msgId = await relayMessage(meJid, protocolMessage, {
220
212
  additionalAttributes: {
221
213
  category: 'peer',
222
- // eslint-disable-next-line camelcase
223
- push_priority: 'high_force',
224
- },
214
+ push_priority: 'high_force'
215
+ }
225
216
  });
226
217
  return msgId;
227
218
  };
@@ -236,51 +227,52 @@ const makeMessagesSocket = (config) => {
236
227
  if (!jid) {
237
228
  return {};
238
229
  }
239
- const bytes = (0, Utils_1.encodeWAMessage)(patchedMessage);
240
- const { type, ciphertext } = await signalRepository
241
- .encryptMessage({ jid, data: bytes });
230
+ const bytes = encodeWAMessage(patchedMessage);
231
+ const { type, ciphertext } = await signalRepository.encryptMessage({ jid, data: bytes });
242
232
  if (type === 'pkmsg') {
243
233
  shouldIncludeDeviceIdentity = true;
244
234
  }
245
235
  const node = {
246
236
  tag: 'to',
247
237
  attrs: { jid },
248
- content: [{
238
+ content: [
239
+ {
249
240
  tag: 'enc',
250
241
  attrs: {
251
242
  v: '2',
252
243
  type,
253
- ...extraAttrs || {}
244
+ ...(extraAttrs || {})
254
245
  },
255
246
  content: ciphertext
256
- }]
247
+ }
248
+ ]
257
249
  };
258
250
  return node;
259
251
  }));
260
252
  return { nodes, shouldIncludeDeviceIdentity };
261
253
  };
262
254
  const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }) => {
263
- var _a;
264
255
  const meId = authState.creds.me.id;
265
256
  let shouldIncludeDeviceIdentity = false;
266
- const { user, server } = (0, WABinary_1.jidDecode)(jid);
257
+ const { user, server } = jidDecode(jid);
267
258
  const statusJid = 'status@broadcast';
268
259
  const isGroup = server === 'g.us';
269
- const isNewsletter = server == 'newsletter';
270
260
  const isStatus = jid === statusJid;
271
261
  const isLid = server === 'lid';
272
- msgId = msgId || (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id);
262
+ const isNewsletter = server === 'newsletter';
263
+ msgId = msgId || generateMessageIDV2(sock.user?.id);
273
264
  useUserDevicesCache = useUserDevicesCache !== false;
274
265
  useCachedGroupMetadata = useCachedGroupMetadata !== false && !isStatus;
275
266
  const participants = [];
276
- const destinationJid = (!isStatus) ? (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : isGroup ? 'g.us' : isNewsletter ? 'newsletter' : 's.whatsapp.net') : statusJid;
267
+ const destinationJid = !isStatus ? jidEncode(user, isLid ? 'lid' : isGroup ? 'g.us' : 's.whatsapp.net') : statusJid;
277
268
  const binaryNodeContent = [];
278
269
  const devices = [];
279
270
  const meMsg = {
280
271
  deviceSentMessage: {
281
272
  destinationJid,
282
273
  message
283
- }
274
+ },
275
+ messageContextInfo: message.messageContextInfo
284
276
  };
285
277
  const extraAttrs = {};
286
278
  if (participant) {
@@ -288,25 +280,47 @@ const makeMessagesSocket = (config) => {
288
280
  // only send to the specific device that asked for a retry
289
281
  // otherwise the message is sent out to every device that should be a recipient
290
282
  if (!isGroup && !isStatus) {
291
- additionalAttributes = { ...additionalAttributes, 'device_fanout': 'false' };
283
+ additionalAttributes = { ...additionalAttributes, device_fanout: 'false' };
292
284
  }
293
- const { user, device } = (0, WABinary_1.jidDecode)(participant.jid);
285
+ const { user, device } = jidDecode(participant.jid);
294
286
  devices.push({ user, device });
295
287
  }
296
288
  await authState.keys.transaction(async () => {
297
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
298
289
  const mediaType = getMediaType(message);
299
290
  if (mediaType) {
300
291
  extraAttrs['mediatype'] = mediaType;
301
292
  }
302
- if ((_a = (0, Utils_1.normalizeMessageContent)(message)) === null || _a === void 0 ? void 0 : _a.pinInChatMessage) {
293
+ if (isNewsletter) {
294
+ // Patch message if needed, then encode as plaintext
295
+ const patched = patchMessageBeforeSending ? await patchMessageBeforeSending(message, []) : message;
296
+ const bytes = encodeNewsletterMessage(patched);
297
+ binaryNodeContent.push({
298
+ tag: 'plaintext',
299
+ attrs: {},
300
+ content: bytes
301
+ });
302
+ const stanza = {
303
+ tag: 'message',
304
+ attrs: {
305
+ to: jid,
306
+ id: msgId,
307
+ type: getMessageType(message),
308
+ ...(additionalAttributes || {})
309
+ },
310
+ content: binaryNodeContent
311
+ };
312
+ logger.debug({ msgId }, `sending newsletter message to ${jid}`);
313
+ await sendNode(stanza);
314
+ return;
315
+ }
316
+ if (normalizeMessageContent(message)?.pinInChatMessage) {
303
317
  extraAttrs['decrypt-fail'] = 'hide';
304
318
  }
305
319
  if (isGroup || isStatus) {
306
320
  const [groupData, senderKeyMap] = await Promise.all([
307
321
  (async () => {
308
322
  let groupData = useCachedGroupMetadata && cachedGroupMetadata ? await cachedGroupMetadata(jid) : undefined;
309
- if (groupData && Array.isArray(groupData === null || groupData === void 0 ? void 0 : groupData.participants)) {
323
+ if (groupData && Array.isArray(groupData?.participants)) {
310
324
  logger.trace({ jid, participants: groupData.participants.length }, 'using cached group metadata');
311
325
  }
312
326
  else if (!isStatus) {
@@ -323,15 +337,14 @@ const makeMessagesSocket = (config) => {
323
337
  })()
324
338
  ]);
325
339
  if (!participant) {
326
- const participantsList = (groupData && !isStatus) ? groupData.participants.map(p => p.id) : [];
340
+ const participantsList = groupData && !isStatus ? groupData.participants.map(p => p.id) : [];
327
341
  if (isStatus && statusJidList) {
328
342
  participantsList.push(...statusJidList);
329
343
  }
330
344
  if (!isStatus) {
331
345
  additionalAttributes = {
332
346
  ...additionalAttributes,
333
- // eslint-disable-next-line camelcase
334
- addressing_mode: (groupData === null || groupData === void 0 ? void 0 : groupData.addressingMode) || 'pn'
347
+ addressing_mode: groupData?.addressingMode || 'pn'
335
348
  };
336
349
  }
337
350
  const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false);
@@ -339,18 +352,18 @@ const makeMessagesSocket = (config) => {
339
352
  }
340
353
  const patched = await patchMessageBeforeSending(message);
341
354
  if (Array.isArray(patched)) {
342
- throw new boom_1.Boom('Per-jid patching is not supported in groups');
355
+ throw new Boom('Per-jid patching is not supported in groups');
343
356
  }
344
- const bytes = (0, Utils_1.encodeWAMessage)(patched);
357
+ const bytes = encodeWAMessage(patched);
345
358
  const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage({
346
359
  group: destinationJid,
347
360
  data: bytes,
348
- meId,
361
+ meId
349
362
  });
350
363
  const senderKeyJids = [];
351
364
  // ensure a connection is established with every device
352
365
  for (const { user, device } of devices) {
353
- const jid = (0, WABinary_1.jidEncode)(user, (groupData === null || groupData === void 0 ? void 0 : groupData.addressingMode) === 'lid' ? 'lid' : 's.whatsapp.net', device);
366
+ const jid = jidEncode(user, groupData?.addressingMode === 'lid' ? 'lid' : 's.whatsapp.net', device);
354
367
  if (!senderKeyMap[jid] || !!participant) {
355
368
  senderKeyJids.push(jid);
356
369
  // store that this person has had the sender keys sent to them
@@ -379,37 +392,14 @@ const makeMessagesSocket = (config) => {
379
392
  });
380
393
  await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
381
394
  }
382
- else if (isNewsletter) {
383
- // Message edit
384
- if ((_b = message.protocolMessage) === null || _b === void 0 ? void 0 : _b.editedMessage) {
385
- msgId = (_c = message.protocolMessage.key) === null || _c === void 0 ? void 0 : _c.id;
386
- message = message.protocolMessage.editedMessage;
387
- }
388
- // Message delete
389
- if (((_d = message.protocolMessage) === null || _d === void 0 ? void 0 : _d.type) === WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE) {
390
- msgId = (_e = message.protocolMessage.key) === null || _e === void 0 ? void 0 : _e.id;
391
- message = {};
392
- }
393
- const patched = await patchMessageBeforeSending(message, []);
394
- if (Array.isArray(patched)) {
395
- throw new boom_1.Boom('Per-jid patching is not supported in channel');
396
- }
397
- const bytes = (0, Utils_1.encodeNewsletterMessage)(patched);
398
- binaryNodeContent.push({
399
- tag: 'plaintext',
400
- attrs: mediaType ? { mediatype: mediaType } : {},
401
- content: bytes
402
- });
403
- }
404
395
  else {
405
- const { user: meUser, device: meDevice } = (0, WABinary_1.jidDecode)(meId);
396
+ const { user: meUser } = jidDecode(meId);
406
397
  if (!participant) {
407
398
  devices.push({ user });
408
- // do not send message to self if the device is 0 (mobile)
409
- if (!((additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes['category']) === 'peer' && user === meUser)) {
410
- if (meDevice !== undefined && meDevice !== 0) {
411
- devices.push({ user: meUser });
412
- }
399
+ if (user !== meUser) {
400
+ devices.push({ user: meUser });
401
+ }
402
+ if (additionalAttributes?.['category'] !== 'peer') {
413
403
  const additionalDevices = await getUSyncDevices([meId, jid], !!useUserDevicesCache, true);
414
404
  devices.push(...additionalDevices);
415
405
  }
@@ -419,7 +409,7 @@ const makeMessagesSocket = (config) => {
419
409
  const otherJids = [];
420
410
  for (const { user, device } of devices) {
421
411
  const isMe = user === meUser;
422
- const jid = (0, WABinary_1.jidEncode)(isMe && isLid ? ((_g = (_f = authState.creds) === null || _f === void 0 ? void 0 : _f.me) === null || _g === void 0 ? void 0 : _g.lid.split(':')[0]) || user : user, isLid ? 'lid' : 's.whatsapp.net', device);
412
+ const jid = jidEncode(isMe && isLid ? authState.creds?.me?.lid.split(':')[0] || user : user, isLid ? 'lid' : 's.whatsapp.net', device);
423
413
  if (isMe) {
424
414
  meJids.push(jid);
425
415
  }
@@ -438,8 +428,8 @@ const makeMessagesSocket = (config) => {
438
428
  shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || s1 || s2;
439
429
  }
440
430
  if (participants.length) {
441
- if ((additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes['category']) === 'peer') {
442
- const peerNode = (_j = (_h = participants[0]) === null || _h === void 0 ? void 0 : _h.content) === null || _j === void 0 ? void 0 : _j[0];
431
+ if (additionalAttributes?.['category'] === 'peer') {
432
+ const peerNode = participants[0]?.content?.[0];
443
433
  if (peerNode) {
444
434
  binaryNodeContent.push(peerNode); // push only enc
445
435
  }
@@ -456,7 +446,7 @@ const makeMessagesSocket = (config) => {
456
446
  tag: 'message',
457
447
  attrs: {
458
448
  id: msgId,
459
- type: isNewsletter ? getTypeMessage(message) : 'text',//getTypeMessage(message),
449
+ type: getMessageType(message),
460
450
  ...(additionalAttributes || {})
461
451
  },
462
452
  content: binaryNodeContent
@@ -465,11 +455,11 @@ const makeMessagesSocket = (config) => {
465
455
  // ensure the message is only sent to that person
466
456
  // if a retry receipt is sent to everyone -- it'll fail decryption for everyone else who received the msg
467
457
  if (participant) {
468
- if ((0, WABinary_1.isJidGroup)(destinationJid)) {
458
+ if (isJidGroup(destinationJid)) {
469
459
  stanza.attrs.to = destinationJid;
470
460
  stanza.attrs.participant = participant.jid;
471
461
  }
472
- else if ((0, WABinary_1.areJidsSameUser)(participant.jid, meId)) {
462
+ else if (areJidsSameUser(participant.jid, meId)) {
473
463
  stanza.attrs.to = participant.jid;
474
464
  stanza.attrs.recipient = destinationJid;
475
465
  }
@@ -481,88 +471,28 @@ const makeMessagesSocket = (config) => {
481
471
  stanza.attrs.to = destinationJid;
482
472
  }
483
473
  if (shouldIncludeDeviceIdentity) {
474
+ ;
484
475
  stanza.content.push({
485
476
  tag: 'device-identity',
486
477
  attrs: {},
487
- content: (0, Utils_1.encodeSignedDeviceIdentity)(authState.creds.account, true)
478
+ content: encodeSignedDeviceIdentity(authState.creds.account, true)
488
479
  });
489
480
  logger.debug({ jid }, 'adding device identity');
490
481
  }
491
- const buttonType = getButtonType(message);
492
- if (buttonType) {
493
- stanza.content.push({
494
- tag: 'biz',
495
- attrs: {},
496
- content: [
497
- {
498
- tag: buttonType,
499
- attrs: getButtonArgs(message),
500
- }
501
- ]
502
- });
503
- logger.debug({ jid }, 'adding business node');
504
- }
505
482
  if (additionalNodes && additionalNodes.length > 0) {
483
+ ;
506
484
  stanza.content.push(...additionalNodes);
507
485
  }
508
- else {
509
- if (((0, WABinary_1.isJidGroup)(jid) || (0, WABinary_1.isJidUser)(jid)) && (((_l = (_k = message === null || message === void 0 ? void 0 : message.viewOnceMessage) === null || _k === void 0 ? void 0 : _k.message) === null || _l === void 0 ? void 0 : _l.interactiveMessage) || ((_o = (_m = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2) === null || _m === void 0 ? void 0 : _m.message) === null || _o === void 0 ? void 0 : _o.interactiveMessage) || ((_q = (_p = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension) === null || _p === void 0 ? void 0 : _p.message) === null || _q === void 0 ? void 0 : _q.interactiveMessage) || (message === null || message === void 0 ? void 0 : message.interactiveMessage)) || (((_s = (_r = message === null || message === void 0 ? void 0 : message.viewOnceMessage) === null || _r === void 0 ? void 0 : _r.message) === null || _s === void 0 ? void 0 : _s.buttonsMessage) || ((_u = (_t = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2) === null || _t === void 0 ? void 0 : _t.message) === null || _u === void 0 ? void 0 : _u.buttonsMessage) || ((_w = (_v = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension) === null || _v === void 0 ? void 0 : _v.message) === null || _w === void 0 ? void 0 : _w.buttonsMessage) || (message === null || message === void 0 ? void 0 : message.buttonsMessage))) {
510
- stanza.content.push({
511
- tag: 'biz',
512
- attrs: {},
513
- content: [{
514
- tag: 'interactive',
515
- attrs: {
516
- type: 'native_flow',
517
- v: '1'
518
- },
519
- content: [{
520
- tag: 'native_flow',
521
- attrs: { name: 'quick_reply' }
522
- }]
523
- }]
524
- });
525
- }
526
- }
527
486
  logger.debug({ msgId }, `sending message to ${participants.length} devices`);
528
487
  await sendNode(stanza);
529
488
  });
530
489
  return msgId;
531
490
  };
532
- /*const getMessageType = (message) => {
533
- if (message.pollCreationMessage || message.pollCreationMessageV2 || message.pollCreationMessageV3 || message.pollUpdateMessage) {
491
+ const getMessageType = (message) => {
492
+ if (message.pollCreationMessage || message.pollCreationMessageV2 || message.pollCreationMessageV3) {
534
493
  return 'poll';
535
494
  }
536
495
  return 'text';
537
- };*/
538
- const getTypeMessage = (msg) => {
539
- if (msg.viewOnceMessage) {
540
- return getTypeMessage(msg.viewOnceMessage.message);
541
- }
542
- else if (msg.viewOnceMessageV2) {
543
- return getTypeMessage(msg.viewOnceMessageV2.message);
544
- }
545
- else if (msg.viewOnceMessageV2Extension) {
546
- return getTypeMessage(msg.viewOnceMessageV2Extension.message);
547
- }
548
- else if (msg.ephemeralMessage) {
549
- return getTypeMessage(msg.ephemeralMessage.message);
550
- }
551
- else if (msg.documentWithCaptionMessage) {
552
- return getTypeMessage(msg.documentWithCaptionMessage.message);
553
- }
554
- else if (msg.reactionMessage) {
555
- return 'reaction';
556
- }
557
- else if (msg.pollCreationMessage || msg.pollCreationMessageV2 || msg.pollCreationMessageV3 || msg.pollUpdateMessage) {
558
- return 'reaction';
559
- }
560
- else if (getMediaType(msg)) {
561
- return 'media';
562
- }
563
- else {
564
- return 'text';
565
- }
566
496
  };
567
497
  const getMediaType = (message) => {
568
498
  if (message.imageMessage) {
@@ -611,45 +541,12 @@ const makeMessagesSocket = (config) => {
611
541
  return 'url';
612
542
  }
613
543
  };
614
- const getButtonType = (message) => {
615
- if (message.buttonsMessage) {
616
- return 'buttons';
617
- }
618
- else if (message.buttonsResponseMessage) {
619
- return 'buttons_response';
620
- }
621
- else if (message.interactiveResponseMessage) {
622
- return 'interactive_response';
623
- }
624
- else if (message.listMessage) {
625
- return 'list';
626
- }
627
- else if (message.listResponseMessage) {
628
- return 'list_response';
629
- }
630
- };
631
- const getButtonArgs = (message) => {
632
- if (message.templateMessage) {
633
- // TODO: Add attributes
634
- return {};
635
- }
636
- else if (message.listMessage) {
637
- const type = message.listMessage.listType;
638
- if (!type) {
639
- throw new boom_1.Boom('Expected list type inside message');
640
- }
641
- return { v: '2', type: ListType[type].toLowerCase() };
642
- }
643
- else {
644
- return {};
645
- }
646
- };
647
544
  const getPrivacyTokens = async (jids) => {
648
- const t = (0, Utils_1.unixTimestampSeconds)().toString();
545
+ const t = unixTimestampSeconds().toString();
649
546
  const result = await query({
650
547
  tag: 'iq',
651
548
  attrs: {
652
- to: WABinary_1.S_WHATSAPP_NET,
549
+ to: S_WHATSAPP_NET,
653
550
  type: 'set',
654
551
  xmlns: 'privacy'
655
552
  },
@@ -660,7 +557,7 @@ const makeMessagesSocket = (config) => {
660
557
  content: jids.map(jid => ({
661
558
  tag: 'token',
662
559
  attrs: {
663
- jid: (0, WABinary_1.jidNormalizedUser)(jid),
560
+ jid: jidNormalizedUser(jid),
664
561
  t,
665
562
  type: 'trusted_contact'
666
563
  }
@@ -670,8 +567,8 @@ const makeMessagesSocket = (config) => {
670
567
  });
671
568
  return result;
672
569
  };
673
- const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
674
- const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
570
+ const waUploadToServer = getWAUploadToServer(config, refreshMediaConn);
571
+ const waitForMsgMediaUpdate = bindWaitForEvent(ev, 'messages.media-update');
675
572
  return {
676
573
  ...sock,
677
574
  getPrivacyTokens,
@@ -679,19 +576,18 @@ const makeMessagesSocket = (config) => {
679
576
  relayMessage,
680
577
  sendReceipt,
681
578
  sendReceipts,
682
- getButtonArgs,
683
579
  readMessages,
684
580
  refreshMediaConn,
685
581
  waUploadToServer,
686
582
  fetchPrivacySettings,
687
- getUSyncDevices,
688
- createParticipantNodes,
689
583
  sendPeerDataOperationMessage,
584
+ createParticipantNodes,
585
+ getUSyncDevices,
690
586
  updateMediaMessage: async (message) => {
691
- const content = (0, Utils_1.assertMediaContent)(message.message);
587
+ const content = assertMediaContent(message.message);
692
588
  const mediaKey = content.mediaKey;
693
589
  const meId = authState.creds.me.id;
694
- const node = await (0, Utils_1.encryptMediaRetryRequest)(message.key, mediaKey, meId);
590
+ const node = await encryptMediaRetryRequest(message.key, mediaKey, meId);
695
591
  let error = undefined;
696
592
  await Promise.all([
697
593
  sendNode(node),
@@ -703,13 +599,16 @@ const makeMessagesSocket = (config) => {
703
599
  }
704
600
  else {
705
601
  try {
706
- const media = await (0, Utils_1.decryptMediaRetryData)(result.media, mediaKey, result.key.id);
707
- if (media.result !== WAProto_1.proto.MediaRetryNotification.ResultType.SUCCESS) {
708
- const resultStr = WAProto_1.proto.MediaRetryNotification.ResultType[media.result];
709
- throw new boom_1.Boom(`Media re-upload failed by device (${resultStr})`, { data: media, statusCode: (0, Utils_1.getStatusCodeForMediaRetry)(media.result) || 404 });
602
+ const media = await decryptMediaRetryData(result.media, mediaKey, result.key.id);
603
+ if (media.result !== proto.MediaRetryNotification.ResultType.SUCCESS) {
604
+ const resultStr = proto.MediaRetryNotification.ResultType[media.result];
605
+ throw new Boom(`Media re-upload failed by device (${resultStr})`, {
606
+ data: media,
607
+ statusCode: getStatusCodeForMediaRetry(media.result) || 404
608
+ });
710
609
  }
711
610
  content.directPath = media.directPath;
712
- content.url = (0, Utils_1.getUrlFromDirectPath)(content.directPath);
611
+ content.url = getUrlFromDirectPath(content.directPath);
713
612
  logger.debug({ directPath: media.directPath, key: result.key }, 'media update successful');
714
613
  }
715
614
  catch (err) {
@@ -723,109 +622,87 @@ const makeMessagesSocket = (config) => {
723
622
  if (error) {
724
623
  throw error;
725
624
  }
726
- ev.emit('messages.update', [
727
- { key: message.key, update: { message: message.message } }
728
- ]);
625
+ ev.emit('messages.update', [{ key: message.key, update: { message: message.message } }]);
729
626
  return message;
730
627
  },
731
628
  sendMessage: async (jid, content, options = {}) => {
732
- var _a, _b, _c;
733
629
  const userJid = authState.creds.me.id;
734
630
  if (typeof content === 'object' &&
735
631
  'disappearingMessagesInChat' in content &&
736
632
  typeof content['disappearingMessagesInChat'] !== 'undefined' &&
737
- (0, WABinary_1.isJidGroup)(jid)) {
633
+ isJidGroup(jid)) {
738
634
  const { disappearingMessagesInChat } = content;
739
- const value = typeof disappearingMessagesInChat === 'boolean' ?
740
- (disappearingMessagesInChat ? Defaults_1.WA_DEFAULT_EPHEMERAL : 0) :
741
- disappearingMessagesInChat;
635
+ const value = typeof disappearingMessagesInChat === 'boolean'
636
+ ? disappearingMessagesInChat
637
+ ? WA_DEFAULT_EPHEMERAL
638
+ : 0
639
+ : disappearingMessagesInChat;
742
640
  await groupToggleEphemeral(jid, value);
743
641
  }
744
642
  else {
745
- let mediaHandle;
746
- const fullMsg = await (0, Utils_1.generateWAMessage)(jid, content, {
643
+ const fullMsg = await generateWAMessage(jid, content, {
747
644
  logger,
748
645
  userJid,
749
- getUrlInfo: text => (0, link_preview_1.getUrlInfo)(text, {
646
+ getUrlInfo: text => getUrlInfo(text, {
750
647
  thumbnailWidth: linkPreviewImageThumbnailWidth,
751
648
  fetchOpts: {
752
649
  timeout: 3000,
753
- ...axiosOptions || {}
650
+ ...(axiosOptions || {})
754
651
  },
755
652
  logger,
756
- uploadImage: generateHighQualityLinkPreview
757
- ? waUploadToServer
758
- : undefined
653
+ uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
759
654
  }),
655
+ //TODO: CACHE
760
656
  getProfilePicUrl: sock.profilePictureUrl,
761
- upload: async (readStream, opts) => {
762
- const up = await waUploadToServer(readStream, { ...opts, newsletter: (0, WABinary_1.isJidNewsletter)(jid) });
763
- mediaHandle = up.handle;
764
- return up;
765
- },
657
+ upload: waUploadToServer,
766
658
  mediaCache: config.mediaCache,
767
659
  options: config.options,
768
- messageId: (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
769
- ...options,
660
+ messageId: generateMessageIDV2(sock.user?.id),
661
+ ...options
770
662
  });
771
663
  const isDeleteMsg = 'delete' in content && !!content.delete;
772
664
  const isEditMsg = 'edit' in content && !!content.edit;
773
665
  const isPinMsg = 'pin' in content && !!content.pin;
774
- const isKeepMsg = 'keep' in content && content.keep;
775
666
  const isPollMessage = 'poll' in content && !!content.poll;
776
- const isAiMsg = 'ai' in content && !!content.ai;
777
667
  const additionalAttributes = {};
778
668
  const additionalNodes = [];
779
669
  // required for delete
780
670
  if (isDeleteMsg) {
781
671
  // if the chat is a group, and I am not the author, then delete the message as an admin
782
- if (((0, WABinary_1.isJidGroup)((_b = content.delete) === null || _b === void 0 ? void 0 : _b.remoteJid) && !((_c = content.delete) === null || _c === void 0 ? void 0 : _c.fromMe)) || (0, WABinary_1.isJidNewsletter)(jid)) {
672
+ if (isJidGroup(content.delete?.remoteJid) && !content.delete?.fromMe) {
783
673
  additionalAttributes.edit = '8';
784
674
  }
785
675
  else {
786
676
  additionalAttributes.edit = '7';
787
677
  }
788
- // required for edit message
789
678
  }
790
679
  else if (isEditMsg) {
791
- additionalAttributes.edit = (0, WABinary_1.isJidNewsletter)(jid) ? '3' : '1';
792
- // required for pin message
680
+ additionalAttributes.edit = '1';
793
681
  }
794
682
  else if (isPinMsg) {
795
683
  additionalAttributes.edit = '2';
796
- // required for keep message
797
- }
798
- else if (isKeepMsg) {
799
- additionalAttributes.edit = '6';
800
- // required for polling message
801
684
  }
802
685
  else if (isPollMessage) {
803
686
  additionalNodes.push({
804
687
  tag: 'meta',
805
688
  attrs: {
806
689
  polltype: 'creation'
807
- },
808
- });
809
- // required to display AI icon on message
810
- }
811
- else if (isAiMsg) {
812
- additionalNodes.push({
813
- attrs: {
814
- biz_bot: '1'
815
- },
816
- tag: "bot"
690
+ }
817
691
  });
818
692
  }
819
- if (mediaHandle) {
820
- additionalAttributes['media_id'] = mediaHandle;
821
- }
822
693
  if ('cachedGroupMetadata' in options) {
823
694
  console.warn('cachedGroupMetadata in sendMessage are deprecated, now cachedGroupMetadata is part of the socket config.');
824
695
  }
825
- await relayMessage(jid, fullMsg.message, { messageId: fullMsg.key.id, useCachedGroupMetadata: options.useCachedGroupMetadata, additionalAttributes, additionalNodes: isAiMsg ? additionalNodes : options.additionalNodes, statusJidList: options.statusJidList });
696
+ await relayMessage(jid, fullMsg.message, {
697
+ messageId: fullMsg.key.id,
698
+ useCachedGroupMetadata: options.useCachedGroupMetadata,
699
+ additionalAttributes,
700
+ statusJidList: options.statusJidList,
701
+ additionalNodes
702
+ });
826
703
  if (config.emitOwnEvents) {
827
704
  process.nextTick(() => {
828
- processingMutex.mutex(() => (upsertMessage(fullMsg, 'append')));
705
+ processingMutex.mutex(() => upsertMessage(fullMsg, 'append'));
829
706
  });
830
707
  }
831
708
  return fullMsg;
@@ -833,4 +710,4 @@ const makeMessagesSocket = (config) => {
833
710
  }
834
711
  };
835
712
  };
836
- exports.makeMessagesSocket = makeMessagesSocket;
713
+ //# sourceMappingURL=messages-send.js.map