@vinzsocket/baileys 2.8.30 → 3.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 (102) hide show
  1. package/WAProto/fix-imports.js +7 -16
  2. package/WAProto/index.js +1 -37306
  3. package/lib/Defaults/index.js +37 -33
  4. package/lib/Signal/Group/ciphertext-message.js +6 -2
  5. package/lib/Signal/Group/group-session-builder.js +12 -7
  6. package/lib/Signal/Group/group_cipher.js +18 -13
  7. package/lib/Signal/Group/index.js +77 -12
  8. package/lib/Signal/Group/keyhelper.js +15 -8
  9. package/lib/Signal/Group/queue-job.js +7 -2
  10. package/lib/Signal/Group/sender-chain-key.js +11 -6
  11. package/lib/Signal/Group/sender-key-distribution-message.js +10 -6
  12. package/lib/Signal/Group/sender-key-message.js +14 -9
  13. package/lib/Signal/Group/sender-key-name.js +6 -2
  14. package/lib/Signal/Group/sender-key-record.js +13 -9
  15. package/lib/Signal/Group/sender-key-state.js +10 -6
  16. package/lib/Signal/Group/sender-message-key.js +9 -4
  17. package/lib/Signal/libsignal.js +34 -28
  18. package/lib/Signal/lid-mapping.js +24 -19
  19. package/lib/Socket/Client/index.js +25 -3
  20. package/lib/Socket/Client/types.js +8 -4
  21. package/lib/Socket/Client/websocket.js +16 -11
  22. package/lib/Socket/business.js +38 -34
  23. package/lib/Socket/chats.js +100 -95
  24. package/lib/Socket/communities.js +55 -49
  25. package/lib/Socket/groups.js +56 -51
  26. package/lib/Socket/index.js +9 -6
  27. package/lib/Socket/messages-recv.js +150 -145
  28. package/lib/Socket/messages-send.js +109 -104
  29. package/lib/Socket/mex.js +12 -8
  30. package/lib/Socket/newsletter.js +27 -23
  31. package/lib/Socket/socket.js +111 -107
  32. package/lib/Store/index.js +47 -4
  33. package/lib/Store/make-cache-manager-store.js +17 -11
  34. package/lib/Store/make-in-memory-store.js +31 -29
  35. package/lib/Store/make-ordered-dictionary.js +7 -2
  36. package/lib/Store/object-repository.js +7 -2
  37. package/lib/Types/Auth.js +3 -2
  38. package/lib/Types/Bussines.js +3 -2
  39. package/lib/Types/Call.js +3 -2
  40. package/lib/Types/Chat.js +5 -2
  41. package/lib/Types/Contact.js +3 -2
  42. package/lib/Types/Events.js +1 -2
  43. package/lib/Types/GroupMetadata.js +3 -2
  44. package/lib/Types/Label.js +6 -3
  45. package/lib/Types/LabelAssociation.js +6 -3
  46. package/lib/Types/Message.js +16 -7
  47. package/lib/Types/Newsletter.js +8 -5
  48. package/lib/Types/Product.js +3 -2
  49. package/lib/Types/Signal.js +1 -2
  50. package/lib/Types/Socket.js +2 -3
  51. package/lib/Types/State.js +7 -4
  52. package/lib/Types/USync.js +1 -2
  53. package/lib/Types/index.js +153 -15
  54. package/lib/Utils/auth-utils.js +32 -25
  55. package/lib/Utils/baileys-event-stream.js +21 -15
  56. package/lib/Utils/business.js +71 -61
  57. package/lib/Utils/chat-utils.js +91 -77
  58. package/lib/Utils/crypto.js +54 -32
  59. package/lib/Utils/decode-wa-message.js +46 -39
  60. package/lib/Utils/event-buffer.js +24 -19
  61. package/lib/Utils/extended-messages.js +14 -9
  62. package/lib/Utils/generics.js +100 -64
  63. package/lib/Utils/history.js +30 -23
  64. package/lib/Utils/index.js +234 -22
  65. package/lib/Utils/lid-resolver.js +12 -5
  66. package/lib/Utils/link-preview.js +11 -7
  67. package/lib/Utils/logger.js +8 -4
  68. package/lib/Utils/lt-hash.js +8 -5
  69. package/lib/Utils/make-mutex.js +8 -3
  70. package/lib/Utils/mention.js +12 -4
  71. package/lib/Utils/message-retry-manager.js +10 -6
  72. package/lib/Utils/messages-media.js +127 -95
  73. package/lib/Utils/messages.js +122 -98
  74. package/lib/Utils/noise-handler.js +25 -21
  75. package/lib/Utils/process-message.js +72 -63
  76. package/lib/Utils/signal.js +45 -33
  77. package/lib/Utils/use-multi-file-auth-state.js +24 -20
  78. package/lib/Utils/validate-connection.js +54 -47
  79. package/lib/WABinary/constants.js +9 -6
  80. package/lib/WABinary/decode.js +17 -10
  81. package/lib/WABinary/encode.js +11 -6
  82. package/lib/WABinary/generic-utils.js +31 -17
  83. package/lib/WABinary/index.js +58 -6
  84. package/lib/WABinary/jid-utils.js +36 -20
  85. package/lib/WABinary/types.js +2 -2
  86. package/lib/WAM/BinaryInfo.js +6 -2
  87. package/lib/WAM/constants.js +1 -1
  88. package/lib/WAM/encode.js +16 -12
  89. package/lib/WAM/index.js +36 -4
  90. package/lib/WAUSync/Protocols/USyncContactProtocol.js +9 -5
  91. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +10 -6
  92. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +8 -4
  93. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +8 -4
  94. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +9 -4
  95. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +23 -19
  96. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +6 -2
  97. package/lib/WAUSync/Protocols/index.js +58 -6
  98. package/lib/WAUSync/USyncQuery.js +21 -17
  99. package/lib/WAUSync/USyncUser.js +6 -2
  100. package/lib/WAUSync/index.js +36 -4
  101. package/lib/index.js +112 -12
  102. package/package.json +8 -6
@@ -1,7 +1,13 @@
1
- import { Boom } from '@hapi/boom';
2
- import { proto } from '../../WAProto/index.js';
3
- import { areJidsSameUser, isJidBroadcast, isJidGroup, isJidMetaAI, isJidNewsletter, isJidStatusBroadcast, isLidUser, isPnUser, transferDevice } from '../WABinary/index.js';
4
- import { unpadRandomMax16 } from './generics.js';
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: true
3
+ });
4
+ exports.NO_MESSAGE_FOUND_ERROR_TEXT = exports.NACK_REASONS = exports.MISSING_KEYS_ERROR_TEXT = exports.DECRYPTION_RETRY_CONFIG = void 0;
5
+ exports.decodeMessageNode = decodeMessageNode;
6
+ exports.extractAddressingContext = exports.decryptMessageNode = void 0;
7
+ var _boom = require("@hapi/boom");
8
+ var _index = require("../../WAProto/index.js");
9
+ var _index2 = require("../WABinary/index.js");
10
+ var _generics = require("./generics.js");
5
11
  const getDecryptionJid = async (sender, repository) => {
6
12
  if (!sender.includes('@s.whatsapp.net')) {
7
13
  return sender;
@@ -12,7 +18,7 @@ const storeMappingFromEnvelope = async (stanza, sender, decryptionJid, repositor
12
18
  const {
13
19
  senderAlt
14
20
  } = extractAddressingContext(stanza);
15
- if (senderAlt && isLidUser(senderAlt) && isPnUser(sender) && decryptionJid === sender) {
21
+ if (senderAlt && (0, _index2.isLidUser)(senderAlt) && (0, _index2.isPnUser)(sender) && decryptionJid === sender) {
16
22
  try {
17
23
  await repository.storeLIDPNMapping(senderAlt, sender);
18
24
  logger.debug({
@@ -28,15 +34,15 @@ const storeMappingFromEnvelope = async (stanza, sender, decryptionJid, repositor
28
34
  }
29
35
  }
30
36
  };
31
- export const NO_MESSAGE_FOUND_ERROR_TEXT = 'Message absent from node';
32
- export const MISSING_KEYS_ERROR_TEXT = 'Key used already or never filled';
37
+ const NO_MESSAGE_FOUND_ERROR_TEXT = exports.NO_MESSAGE_FOUND_ERROR_TEXT = 'Message absent from node';
38
+ const MISSING_KEYS_ERROR_TEXT = exports.MISSING_KEYS_ERROR_TEXT = 'Key used already or never filled';
33
39
  // Retry configuration for failed decryption
34
- export const DECRYPTION_RETRY_CONFIG = {
40
+ const DECRYPTION_RETRY_CONFIG = exports.DECRYPTION_RETRY_CONFIG = {
35
41
  maxRetries: 3,
36
42
  baseDelayMs: 100,
37
43
  sessionRecordErrors: ['No session record', 'SessionError: No session record']
38
44
  };
39
- export const NACK_REASONS = {
45
+ const NACK_REASONS = exports.NACK_REASONS = {
40
46
  ParsingError: 487,
41
47
  UnrecognizedStanza: 488,
42
48
  UnrecognizedStanzaClass: 489,
@@ -51,7 +57,7 @@ export const NACK_REASONS = {
51
57
  UnsupportedLIDGroup: 551,
52
58
  DBOperationFailed: 552
53
59
  };
54
- export const extractAddressingContext = stanza => {
60
+ const extractAddressingContext = stanza => {
55
61
  const addressingMode = stanza.attrs.addressing_mode || 'pn';
56
62
  let senderAlt;
57
63
  let recipientAlt;
@@ -62,14 +68,14 @@ export const extractAddressingContext = stanza => {
62
68
  senderAlt = stanza.attrs.participant_pn || stanza.attrs.sender_pn || stanza.attrs.peer_recipient_pn;
63
69
  recipientAlt = stanza.attrs.recipient_pn;
64
70
  // with device data
65
- if (sender && senderAlt) senderAlt = transferDevice(sender, senderAlt);
71
+ if (sender && senderAlt) senderAlt = (0, _index2.transferDevice)(sender, senderAlt);
66
72
  } else {
67
73
  // Message is PN-addressed: sender is PN, extract corresponding LID
68
74
  // without device data
69
75
  senderAlt = stanza.attrs.participant_lid || stanza.attrs.sender_lid || stanza.attrs.peer_recipient_lid;
70
76
  recipientAlt = stanza.attrs.recipient_lid;
71
77
  //with device data
72
- if (sender && senderAlt) senderAlt = transferDevice(sender, senderAlt);
78
+ if (sender && senderAlt) senderAlt = (0, _index2.transferDevice)(sender, senderAlt);
73
79
  }
74
80
  return {
75
81
  addressingMode,
@@ -81,7 +87,8 @@ export const extractAddressingContext = stanza => {
81
87
  * Decode the received node as a message.
82
88
  * @note this will only parse the message, not decrypt it
83
89
  */
84
- export function decodeMessageNode(stanza, meId, meLid) {
90
+ exports.extractAddressingContext = extractAddressingContext;
91
+ function decodeMessageNode(stanza, meId, meLid) {
85
92
  let msgType;
86
93
  let chatId;
87
94
  let author;
@@ -90,12 +97,12 @@ export function decodeMessageNode(stanza, meId, meLid) {
90
97
  const participant = stanza.attrs.participant;
91
98
  const recipient = stanza.attrs.recipient;
92
99
  const addressingContext = extractAddressingContext(stanza);
93
- const isMe = jid => areJidsSameUser(jid, meId);
94
- const isMeLid = jid => areJidsSameUser(jid, meLid);
95
- if (isPnUser(from) || isLidUser(from)) {
96
- if (recipient && !isJidMetaAI(recipient)) {
100
+ const isMe = jid => (0, _index2.areJidsSameUser)(jid, meId);
101
+ const isMeLid = jid => (0, _index2.areJidsSameUser)(jid, meLid);
102
+ if ((0, _index2.isPnUser)(from) || (0, _index2.isLidUser)(from)) {
103
+ if (recipient && !(0, _index2.isJidMetaAI)(recipient)) {
97
104
  if (!isMe(from) && !isMeLid(from)) {
98
- throw new Boom('receipient present, but msg not from me', {
105
+ throw new _boom.Boom('receipient present, but msg not from me', {
99
106
  data: stanza
100
107
  });
101
108
  }
@@ -105,43 +112,43 @@ export function decodeMessageNode(stanza, meId, meLid) {
105
112
  }
106
113
  msgType = 'chat';
107
114
  author = from;
108
- } else if (isJidGroup(from)) {
115
+ } else if ((0, _index2.isJidGroup)(from)) {
109
116
  if (!participant) {
110
- throw new Boom('No participant in group message');
117
+ throw new _boom.Boom('No participant in group message');
111
118
  }
112
119
  msgType = 'group';
113
120
  author = participant;
114
121
  chatId = from;
115
- } else if (isJidBroadcast(from)) {
122
+ } else if ((0, _index2.isJidBroadcast)(from)) {
116
123
  if (!participant) {
117
- throw new Boom('No participant in group message');
124
+ throw new _boom.Boom('No participant in group message');
118
125
  }
119
126
  const isParticipantMe = isMe(participant);
120
- if (isJidStatusBroadcast(from)) {
127
+ if ((0, _index2.isJidStatusBroadcast)(from)) {
121
128
  msgType = isParticipantMe ? 'direct_peer_status' : 'other_status';
122
129
  } else {
123
130
  msgType = isParticipantMe ? 'peer_broadcast' : 'other_broadcast';
124
131
  }
125
132
  chatId = from;
126
133
  author = participant;
127
- } else if (isJidNewsletter(from)) {
134
+ } else if ((0, _index2.isJidNewsletter)(from)) {
128
135
  msgType = 'newsletter';
129
136
  chatId = from;
130
137
  author = from;
131
138
  } else {
132
- throw new Boom('Unknown message type', {
139
+ throw new _boom.Boom('Unknown message type', {
133
140
  data: stanza
134
141
  });
135
142
  }
136
- const fromMe = (isLidUser(from) ? isMeLid : isMe)(stanza.attrs.participant || stanza.attrs.from);
143
+ const fromMe = ((0, _index2.isLidUser)(from) ? isMeLid : isMe)(stanza.attrs.participant || stanza.attrs.from);
137
144
  const pushname = stanza?.attrs?.notify;
138
145
  const key = {
139
146
  remoteJid: chatId,
140
- remoteJidAlt: !isJidGroup(chatId) ? addressingContext.senderAlt : undefined,
147
+ remoteJidAlt: !(0, _index2.isJidGroup)(chatId) ? addressingContext.senderAlt : undefined,
141
148
  fromMe,
142
149
  id: msgId,
143
150
  participant,
144
- participantAlt: isJidGroup(chatId) ? addressingContext.senderAlt : undefined,
151
+ participantAlt: (0, _index2.isJidGroup)(chatId) ? addressingContext.senderAlt : undefined,
145
152
  ...(msgType === 'newsletter' && stanza.attrs.server_id ? {
146
153
  server_id: stanza.attrs.server_id
147
154
  } : {})
@@ -150,10 +157,10 @@ export function decodeMessageNode(stanza, meId, meLid) {
150
157
  key,
151
158
  messageTimestamp: +stanza.attrs.t,
152
159
  pushName: pushname,
153
- broadcast: isJidBroadcast(from)
160
+ broadcast: (0, _index2.isJidBroadcast)(from)
154
161
  };
155
162
  if (key.fromMe) {
156
- fullMessage.status = proto.WebMessageInfo.Status.SERVER_ACK;
163
+ fullMessage.status = _index.proto.WebMessageInfo.Status.SERVER_ACK;
157
164
  }
158
165
  return {
159
166
  fullMessage,
@@ -161,7 +168,7 @@ export function decodeMessageNode(stanza, meId, meLid) {
161
168
  sender: msgType === 'chat' ? author : chatId
162
169
  };
163
170
  }
164
- export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
171
+ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
165
172
  const {
166
173
  fullMessage,
167
174
  author,
@@ -180,8 +187,8 @@ export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
180
187
  content
181
188
  } of stanza.content) {
182
189
  if (tag === 'verified_name' && content instanceof Uint8Array) {
183
- const cert = proto.VerifiedNameCertificate.decode(content);
184
- const details = proto.VerifiedNameCertificate.Details.decode(cert.details);
190
+ const cert = _index.proto.VerifiedNameCertificate.decode(content);
191
+ const details = _index.proto.VerifiedNameCertificate.Details.decode(cert.details);
185
192
  fullMessage.verifiedBizName = details.verifiedName;
186
193
  }
187
194
  if (tag === 'unavailable' && attrs.type === 'view_once') {
@@ -195,7 +202,7 @@ export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
195
202
  }
196
203
  decryptables += 1;
197
204
  let msgBuffer;
198
- const user = isPnUser(sender) ? sender : author; // TODO: flaky logic
205
+ const user = (0, _index2.isPnUser)(sender) ? sender : author; // TODO: flaky logic
199
206
  const decryptionJid = await getDecryptionJid(user, repository);
200
207
  if (tag !== 'plaintext') {
201
208
  await storeMappingFromEnvelope(stanza, user, decryptionJid, repository, logger);
@@ -224,7 +231,7 @@ export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
224
231
  default:
225
232
  throw new Error(`Unknown e2e type: ${e2eType}`);
226
233
  }
227
- let msg = proto.Message.decode(e2eType !== 'plaintext' ? unpadRandomMax16(msgBuffer) : msgBuffer);
234
+ let msg = _index.proto.Message.decode(e2eType !== 'plaintext' ? (0, _generics.unpadRandomMax16)(msgBuffer) : msgBuffer);
228
235
  msg = msg.deviceSentMessage?.message || msg;
229
236
  if (msg.senderKeyDistributionMessage) {
230
237
  //eslint-disable-next-line max-depth
@@ -255,14 +262,14 @@ export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
255
262
  isSessionRecordError: isSessionRecordError(err)
256
263
  };
257
264
  logger.error(errorContext, 'failed to decrypt message');
258
- fullMessage.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT;
265
+ fullMessage.messageStubType = _index.proto.WebMessageInfo.StubType.CIPHERTEXT;
259
266
  fullMessage.messageStubParameters = [err.message.toString()];
260
267
  }
261
268
  }
262
269
  }
263
270
  // if nothing was found to decrypt
264
271
  if (!decryptables) {
265
- fullMessage.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT;
272
+ fullMessage.messageStubType = _index.proto.WebMessageInfo.StubType.CIPHERTEXT;
266
273
  fullMessage.messageStubParameters = [NO_MESSAGE_FOUND_ERROR_TEXT];
267
274
  }
268
275
  }
@@ -271,8 +278,8 @@ export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
271
278
  /**
272
279
  * Utility function to check if an error is related to missing session record
273
280
  */
281
+ exports.decryptMessageNode = decryptMessageNode;
274
282
  function isSessionRecordError(error) {
275
283
  const errorMessage = error?.message || error?.toString() || '';
276
284
  return DECRYPTION_RETRY_CONFIG.sessionRecordErrors.some(errorPattern => errorMessage.includes(errorPattern));
277
- }
278
- //# sourceMappingURL=decode-wa-message.js.map
285
+ }
@@ -1,17 +1,22 @@
1
- import EventEmitter from 'events';
2
- import { proto } from '../../WAProto/index.js';
3
- import { WAMessageStatus } from '../Types/index.js';
4
- import { trimUndefined } from './generics.js';
5
- import { updateMessageWithReaction, updateMessageWithReceipt } from './messages.js';
6
- import { isRealMessage, shouldIncrementChatUnread } from './process-message.js';
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: true
3
+ });
4
+ exports.makeEventBuffer = void 0;
5
+ var _events = _interopRequireDefault(require("events"));
6
+ var _index = require("../../WAProto/index.js");
7
+ var _index2 = require("../Types/index.js");
8
+ var _generics = require("./generics.js");
9
+ var _messages = require("./messages.js");
10
+ var _processMessage = require("./process-message.js");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
12
  const BUFFERABLE_EVENT = ['messaging-history.set', 'chats.upsert', 'chats.update', 'chats.delete', 'contacts.upsert', 'contacts.update', 'messages.upsert', 'messages.update', 'messages.delete', 'messages.reaction', 'message-receipt.update', 'groups.update'];
8
13
  const BUFFERABLE_EVENT_SET = new Set(BUFFERABLE_EVENT);
9
14
  /**
10
15
  * The event buffer logically consolidates different events into a single event
11
16
  * making the data processing more efficient.
12
17
  */
13
- export const makeEventBuffer = logger => {
14
- const ev = new EventEmitter();
18
+ const makeEventBuffer = logger => {
19
+ const ev = new _events.default();
15
20
  const historyCache = new Set();
16
21
  let data = makeBufferData();
17
22
  let isBuffering = false;
@@ -139,6 +144,7 @@ export const makeEventBuffer = logger => {
139
144
  removeAllListeners: (...args) => ev.removeAllListeners(...args)
140
145
  };
141
146
  };
147
+ exports.makeEventBuffer = makeEventBuffer;
142
148
  const makeBufferData = () => {
143
149
  return {
144
150
  historySets: {
@@ -180,7 +186,7 @@ eventData, logger) {
180
186
  for (const contact of eventData.contacts) {
181
187
  const existingContact = data.historySets.contacts[contact.id];
182
188
  if (existingContact) {
183
- Object.assign(existingContact, trimUndefined(contact));
189
+ Object.assign(existingContact, (0, _generics.trimUndefined)(contact));
184
190
  } else {
185
191
  const historyContactId = `c:${contact.id}`;
186
192
  const hasAnyName = contact.notify || contact.name || contact.verifiedName;
@@ -283,13 +289,13 @@ eventData, logger) {
283
289
  }
284
290
  }
285
291
  if (upsert) {
286
- upsert = Object.assign(upsert, trimUndefined(contact));
292
+ upsert = Object.assign(upsert, (0, _generics.trimUndefined)(contact));
287
293
  } else {
288
294
  upsert = contact;
289
295
  data.contactUpserts[contact.id] = upsert;
290
296
  }
291
297
  if (data.contactUpdates[contact.id]) {
292
- upsert = Object.assign(data.contactUpdates[contact.id], trimUndefined(contact));
298
+ upsert = Object.assign(data.contactUpdates[contact.id], (0, _generics.trimUndefined)(contact));
293
299
  delete data.contactUpdates[contact.id];
294
300
  }
295
301
  }
@@ -356,7 +362,7 @@ eventData, logger) {
356
362
  // if the message was received & read by us
357
363
  // the chat counter must have been incremented
358
364
  // so we need to decrement it
359
- if (update.status === WAMessageStatus.READ && !key.fromMe) {
365
+ if (update.status === _index2.WAMessageStatus.READ && !key.fromMe) {
360
366
  decrementChatReadCounterIfMsgDidUnread(existing);
361
367
  }
362
368
  } else {
@@ -400,13 +406,13 @@ eventData, logger) {
400
406
  const keyStr = stringifyMessageKey(key);
401
407
  const existing = data.messageUpserts[keyStr];
402
408
  if (existing) {
403
- updateMessageWithReaction(existing.message, reaction);
409
+ (0, _messages.updateMessageWithReaction)(existing.message, reaction);
404
410
  } else {
405
411
  data.messageReactions[keyStr] = data.messageReactions[keyStr] || {
406
412
  key,
407
413
  reactions: []
408
414
  };
409
- updateMessageWithReaction(data.messageReactions[keyStr], reaction);
415
+ (0, _messages.updateMessageWithReaction)(data.messageReactions[keyStr], reaction);
410
416
  }
411
417
  }
412
418
  break;
@@ -419,13 +425,13 @@ eventData, logger) {
419
425
  const keyStr = stringifyMessageKey(key);
420
426
  const existing = data.messageUpserts[keyStr];
421
427
  if (existing) {
422
- updateMessageWithReceipt(existing.message, receipt);
428
+ (0, _messages.updateMessageWithReceipt)(existing.message, receipt);
423
429
  } else {
424
430
  data.messageReceipts[keyStr] = data.messageReceipts[keyStr] || {
425
431
  key,
426
432
  userReceipt: []
427
433
  };
428
- updateMessageWithReceipt(data.messageReceipts[keyStr], receipt);
434
+ (0, _messages.updateMessageWithReceipt)(data.messageReceipts[keyStr], receipt);
429
435
  }
430
436
  }
431
437
  break;
@@ -467,7 +473,7 @@ eventData, logger) {
467
473
  // if the message has already been marked read by us
468
474
  const chatId = message.key.remoteJid;
469
475
  const chat = data.chatUpdates[chatId] || data.chatUpserts[chatId];
470
- if (isRealMessage(message, '') && shouldIncrementChatUnread(message) && typeof chat?.unreadCount === 'number' && chat.unreadCount > 0) {
476
+ if ((0, _processMessage.isRealMessage)(message, '') && (0, _processMessage.shouldIncrementChatUnread)(message) && typeof chat?.unreadCount === 'number' && chat.unreadCount > 0) {
471
477
  logger.debug({
472
478
  chatId: chat.id
473
479
  }, 'decrementing chat counter');
@@ -572,5 +578,4 @@ function concatChats(a, b) {
572
578
  }
573
579
  return Object.assign(a, b);
574
580
  }
575
- const stringifyMessageKey = key => `${key.remoteJid},${key.id},${key.fromMe ? '1' : '0'}`;
576
- //# sourceMappingURL=event-buffer.js.map
581
+ const stringifyMessageKey = key => `${key.remoteJid},${key.id},${key.fromMe ? '1' : '0'}`;
@@ -1,6 +1,11 @@
1
- import { randomBytes } from 'crypto';
2
- import { proto } from '../../WAProto/index.js';
3
- import { normalizeMentions } from './mention.js';
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: true
3
+ });
4
+ exports.detectExtendedMessageType = detectExtendedMessageType;
5
+ exports.makeExtendedMessageHandlers = makeExtendedMessageHandlers;
6
+ var _crypto = require("crypto");
7
+ var _index = require("../../WAProto/index.js");
8
+ var _mention = require("./mention.js");
4
9
  /**
5
10
  * Detects which "extended" message type a sendMessage() content object is
6
11
  * asking for, if any. These are content shapes that need custom assembly
@@ -8,7 +13,7 @@ import { normalizeMentions } from './mention.js';
8
13
  * interactive messages with a rich media header, multi-image/video albums,
9
14
  * poll result snapshots, and group status/story posts).
10
15
  */
11
- export function detectExtendedMessageType(content) {
16
+ function detectExtendedMessageType(content) {
12
17
  if (!content || typeof content !== 'object') return null;
13
18
  if (content.requestPaymentMessage) return 'PAYMENT';
14
19
  if (content.interactiveMessage) return 'INTERACTIVE';
@@ -24,7 +29,7 @@ export function detectExtendedMessageType(content) {
24
29
  * but is only ever instantiated once, inside makeMessagesSocket(), with the
25
30
  * live socket's own waUploadToServer/relayMessage.
26
31
  */
27
- export function makeExtendedMessageHandlers({
32
+ function makeExtendedMessageHandlers({
28
33
  generateWAMessage,
29
34
  generateWAMessageContent,
30
35
  generateWAMessageFromContent,
@@ -62,7 +67,7 @@ export function makeExtendedMessageHandlers({
62
67
  };
63
68
  }
64
69
  return {
65
- requestPaymentMessage: proto.Message.RequestPaymentMessage.create({
70
+ requestPaymentMessage: _index.proto.Message.RequestPaymentMessage.create({
66
71
  expiryTimestamp: data.expiry || 0,
67
72
  amount1000: data.amount || 0,
68
73
  currencyCodeIso4217: data.currency || 'IDR',
@@ -159,7 +164,7 @@ export function makeExtendedMessageHandlers({
159
164
  forwardingScore: contextInfo.forwardingScore || 0,
160
165
  isForwarded: contextInfo.isForwarded || false,
161
166
  ...contextInfo,
162
- mentionedJid: normalizeMentions(contextInfo.mentionedJid || options.mentions || [])
167
+ mentionedJid: (0, _mention.normalizeMentions)(contextInfo.mentionedJid || options.mentions || [])
163
168
  };
164
169
  if (externalAdReply) {
165
170
  finalContextInfo.externalAdReply = {
@@ -189,7 +194,7 @@ export function makeExtendedMessageHandlers({
189
194
  const array = content.albumMessage;
190
195
  const album = generateWAMessageFromContent(jid, {
191
196
  messageContextInfo: {
192
- messageSecret: randomBytes(32)
197
+ messageSecret: (0, _crypto.randomBytes)(32)
193
198
  },
194
199
  albumMessage: {
195
200
  expectedImageCount: array.filter(a => a.hasOwnProperty('image')).length,
@@ -207,7 +212,7 @@ export function makeExtendedMessageHandlers({
207
212
  upload: waUploadToServer
208
213
  });
209
214
  img.message.messageContextInfo = {
210
- messageSecret: randomBytes(32),
215
+ messageSecret: (0, _crypto.randomBytes)(32),
211
216
  messageAssociation: {
212
217
  associationType: 1,
213
218
  parentMessageKey: album.key