@hbmodsofc/baileys 1.5.2 → 1.7.7

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 (155) hide show
  1. package/LICENSE +1 -1
  2. package/WAProto/index.js +19671 -152026
  3. package/lib/Defaults/index.d.ts +12 -8
  4. package/lib/Defaults/index.js +90 -124
  5. package/lib/Signal/Group/group_cipher.d.ts +0 -1
  6. package/lib/Signal/Group/group_cipher.js +28 -39
  7. package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
  8. package/lib/Signal/Group/sender-chain-key.js +9 -2
  9. package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
  10. package/lib/Signal/Group/sender-key-message.js +3 -3
  11. package/lib/Signal/Group/sender-key-state.d.ts +4 -4
  12. package/lib/Signal/Group/sender-key-state.js +47 -16
  13. package/lib/Signal/libsignal.d.ts +7 -3
  14. package/lib/Signal/libsignal.js +224 -39
  15. package/lib/Signal/lid-mapping.d.ts +26 -0
  16. package/lib/Signal/lid-mapping.js +146 -0
  17. package/lib/Socket/Client/index.d.ts +2 -3
  18. package/lib/Socket/Client/index.js +2 -3
  19. package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -3
  20. package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
  21. package/lib/Socket/Client/{web-socket-client.js → websocket.js} +10 -16
  22. package/lib/Socket/business.d.ts +94 -78
  23. package/lib/Socket/business.js +130 -11
  24. package/lib/Socket/chats.d.ts +63 -233
  25. package/lib/Socket/chats.js +234 -184
  26. package/lib/Socket/communities.d.ts +232 -0
  27. package/lib/Socket/communities.js +402 -0
  28. package/lib/Socket/groups.d.ts +62 -41
  29. package/lib/Socket/groups.js +76 -64
  30. package/lib/Socket/index.d.ts +129 -83
  31. package/lib/Socket/index.js +13 -6
  32. package/lib/Socket/messages-recv.d.ts +59 -48
  33. package/lib/Socket/messages-recv.js +516 -371
  34. package/lib/Socket/messages-send.d.ts +86 -67
  35. package/lib/Socket/messages-send.js +1091 -1
  36. package/lib/Socket/mex.d.ts +2 -0
  37. package/lib/Socket/mex.js +45 -0
  38. package/lib/Socket/newsletter.d.ts +76 -64
  39. package/lib/Socket/newsletter.js +184 -1
  40. package/lib/Socket/socket.d.ts +19 -13
  41. package/lib/Socket/socket.js +805 -1
  42. package/lib/Types/Auth.d.ts +4 -10
  43. package/lib/Types/Bussines.d.ts +24 -0
  44. package/lib/Types/Bussines.js +2 -0
  45. package/lib/Types/Call.d.ts +1 -1
  46. package/lib/Types/Chat.d.ts +29 -9
  47. package/lib/Types/Chat.js +7 -1
  48. package/lib/Types/Contact.d.ts +5 -1
  49. package/lib/Types/Events.d.ts +55 -14
  50. package/lib/Types/GroupMetadata.d.ts +15 -5
  51. package/lib/Types/Label.d.ts +11 -0
  52. package/lib/Types/Label.js +1 -1
  53. package/lib/Types/LabelAssociation.js +1 -1
  54. package/lib/Types/Message.d.ts +75 -49
  55. package/lib/Types/Message.js +10 -7
  56. package/lib/Types/Newsletter.d.ts +129 -98
  57. package/lib/Types/Newsletter.js +33 -38
  58. package/lib/Types/Product.d.ts +1 -1
  59. package/lib/Types/Signal.d.ts +29 -1
  60. package/lib/Types/Socket.d.ts +48 -22
  61. package/lib/Types/State.d.ts +13 -2
  62. package/lib/Types/State.js +12 -0
  63. package/lib/Types/USync.d.ts +1 -1
  64. package/lib/Types/index.d.ts +10 -3
  65. package/lib/Types/index.js +2 -2
  66. package/lib/Utils/auth-utils.d.ts +3 -3
  67. package/lib/Utils/auth-utils.js +378 -102
  68. package/lib/Utils/baileys-event-stream.js +1 -1
  69. package/lib/Utils/business.d.ts +2 -2
  70. package/lib/Utils/business.js +19 -13
  71. package/lib/Utils/chat-utils.d.ts +21 -22
  72. package/lib/Utils/chat-utils.js +201 -154
  73. package/lib/Utils/crypto.d.ts +18 -19
  74. package/lib/Utils/crypto.js +78 -37
  75. package/lib/Utils/decode-wa-message.d.ts +34 -7
  76. package/lib/Utils/decode-wa-message.js +138 -66
  77. package/lib/Utils/event-buffer.d.ts +6 -8
  78. package/lib/Utils/event-buffer.js +81 -43
  79. package/lib/Utils/generics.d.ts +27 -27
  80. package/lib/Utils/generics.js +128 -133
  81. package/lib/Utils/history.d.ts +9 -5
  82. package/lib/Utils/history.js +17 -23
  83. package/lib/Utils/index.d.ts +2 -0
  84. package/lib/Utils/index.js +2 -0
  85. package/lib/Utils/lidToJid-test.d.ts +11 -0
  86. package/lib/Utils/lidToJid-test.js +27 -0
  87. package/lib/Utils/link-preview.d.ts +4 -4
  88. package/lib/Utils/link-preview.js +40 -12
  89. package/lib/Utils/logger.d.ts +11 -3
  90. package/lib/Utils/lt-hash.d.ts +8 -8
  91. package/lib/Utils/lt-hash.js +23 -24
  92. package/lib/Utils/make-mutex.d.ts +2 -2
  93. package/lib/Utils/make-mutex.js +3 -2
  94. package/lib/Utils/message-retry-manager.d.ts +81 -0
  95. package/lib/Utils/message-retry-manager.js +152 -0
  96. package/lib/Utils/messages-media.d.ts +37 -41
  97. package/lib/Utils/messages-media.js +252 -368
  98. package/lib/Utils/messages.d.ts +13 -15
  99. package/lib/Utils/messages.js +274 -261
  100. package/lib/Utils/noise-handler.d.ts +13 -15
  101. package/lib/Utils/noise-handler.js +20 -26
  102. package/lib/Utils/process-message.d.ts +9 -8
  103. package/lib/Utils/process-message.js +157 -93
  104. package/lib/Utils/signal.d.ts +6 -5
  105. package/lib/Utils/signal.js +37 -29
  106. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
  107. package/lib/Utils/use-multi-file-auth-state.js +12 -7
  108. package/lib/Utils/validate-connection.d.ts +5 -6
  109. package/lib/Utils/validate-connection.js +39 -97
  110. package/lib/WABinary/constants.d.ts +24 -27
  111. package/lib/WABinary/constants.js +1276 -13
  112. package/lib/WABinary/decode.d.ts +3 -4
  113. package/lib/WABinary/decode.js +28 -14
  114. package/lib/WABinary/encode.d.ts +1 -2
  115. package/lib/WABinary/encode.js +134 -147
  116. package/lib/WABinary/generic-utils.d.ts +4 -7
  117. package/lib/WABinary/generic-utils.js +40 -125
  118. package/lib/WABinary/jid-utils.d.ts +13 -8
  119. package/lib/WABinary/jid-utils.js +27 -16
  120. package/lib/WAM/BinaryInfo.d.ts +2 -11
  121. package/lib/WAM/constants.d.ts +3 -2
  122. package/lib/WAM/constants.js +2252 -2359
  123. package/lib/WAM/encode.d.ts +1 -2
  124. package/lib/WAM/encode.js +8 -11
  125. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
  126. package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -4
  127. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
  128. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
  129. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
  130. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
  131. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
  132. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +5 -6
  133. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
  134. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
  135. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +4 -3
  136. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +11 -3
  137. package/lib/WAUSync/USyncQuery.d.ts +2 -2
  138. package/lib/WAUSync/USyncQuery.js +19 -15
  139. package/lib/WAUSync/USyncUser.d.ts +5 -5
  140. package/lib/WAUSync/index.d.ts +1 -1
  141. package/lib/WAUSync/index.js +1 -1
  142. package/package.json +102 -102
  143. package/lib/Defaults/baileys-version.json +0 -3
  144. package/lib/Defaults/phonenumber-mcc.json +0 -223
  145. package/lib/Signal/Group/queue-job.d.ts +0 -1
  146. package/lib/Signal/Group/queue-job.js +0 -57
  147. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  148. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  149. package/lib/Socket/hbmods.d.ts +0 -253
  150. package/lib/Socket/hbmods.js +0 -1
  151. package/lib/Socket/registration.d.ts +0 -267
  152. package/lib/Socket/registration.js +0 -166
  153. package/lib/Socket/usync.d.ts +0 -36
  154. package/lib/Socket/usync.js +0 -70
  155. /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
@@ -21,19 +21,22 @@ const BUFFERABLE_EVENT = [
21
21
  'messages.delete',
22
22
  'messages.reaction',
23
23
  'message-receipt.update',
24
- 'groups.update',
24
+ 'groups.update'
25
25
  ];
26
26
  const BUFFERABLE_EVENT_SET = new Set(BUFFERABLE_EVENT);
27
27
  /**
28
28
  * The event buffer logically consolidates different events into a single event
29
29
  * making the data processing more efficient.
30
- * @param ev the baileys event emitter
31
30
  */
32
31
  const makeEventBuffer = (logger) => {
33
32
  const ev = new events_1.default();
34
33
  const historyCache = new Set();
35
34
  let data = makeBufferData();
36
- let buffersInProgress = 0;
35
+ let isBuffering = false;
36
+ let bufferTimeout = null;
37
+ let bufferCount = 0;
38
+ const MAX_HISTORY_CACHE_SIZE = 10000; // Limit the history cache size to prevent memory bloat
39
+ const BUFFER_TIMEOUT_MS = 30000; // 30 seconds
37
40
  // take the generic event and fire it as a baileys event
38
41
  ev.on('event', (map) => {
39
42
  for (const event in map) {
@@ -41,25 +44,44 @@ const makeEventBuffer = (logger) => {
41
44
  }
42
45
  });
43
46
  function buffer() {
44
- buffersInProgress += 1;
47
+ if (!isBuffering) {
48
+ logger.debug('Event buffer activated');
49
+ isBuffering = true;
50
+ bufferCount++;
51
+ // Auto-flush after a timeout to prevent infinite buffering
52
+ if (bufferTimeout) {
53
+ clearTimeout(bufferTimeout);
54
+ }
55
+ bufferTimeout = setTimeout(() => {
56
+ if (isBuffering) {
57
+ logger.warn('Buffer timeout reached, auto-flushing');
58
+ flush();
59
+ }
60
+ }, BUFFER_TIMEOUT_MS);
61
+ }
62
+ else {
63
+ bufferCount++;
64
+ }
45
65
  }
46
- function flush(force = false) {
47
- // no buffer going on
48
- if (!buffersInProgress) {
66
+ function flush() {
67
+ if (!isBuffering) {
49
68
  return false;
50
69
  }
51
- if (!force) {
52
- // reduce the number of buffers in progress
53
- buffersInProgress -= 1;
54
- // if there are still some buffers going on
55
- // then we don't flush now
56
- if (buffersInProgress) {
57
- return false;
58
- }
70
+ logger.debug({ bufferCount }, 'Flushing event buffer');
71
+ isBuffering = false;
72
+ bufferCount = 0;
73
+ // Clear timeout
74
+ if (bufferTimeout) {
75
+ clearTimeout(bufferTimeout);
76
+ bufferTimeout = null;
77
+ }
78
+ // Clear history cache if it exceeds the max size
79
+ if (historyCache.size > MAX_HISTORY_CACHE_SIZE) {
80
+ logger.debug({ cacheSize: historyCache.size }, 'Clearing history cache');
81
+ historyCache.clear();
59
82
  }
60
83
  const newData = makeBufferData();
61
84
  const chatUpdates = Object.values(data.chatUpdates);
62
- // gather the remaining conditional events so we re-queue them
63
85
  let conditionalChatUpdatesLeft = 0;
64
86
  for (const update of chatUpdates) {
65
87
  if (update.conditional) {
@@ -87,14 +109,14 @@ const makeEventBuffer = (logger) => {
87
109
  };
88
110
  },
89
111
  emit(event, evData) {
90
- if (buffersInProgress && BUFFERABLE_EVENT_SET.has(event)) {
112
+ if (isBuffering && BUFFERABLE_EVENT_SET.has(event)) {
91
113
  append(data, historyCache, event, evData, logger);
92
114
  return true;
93
115
  }
94
116
  return ev.emit('event', { [event]: evData });
95
117
  },
96
118
  isBuffering() {
97
- return buffersInProgress > 0;
119
+ return isBuffering;
98
120
  },
99
121
  buffer,
100
122
  flush,
@@ -103,16 +125,31 @@ const makeEventBuffer = (logger) => {
103
125
  buffer();
104
126
  try {
105
127
  const result = await work(...args);
128
+ // If this is the only buffer, flush after a small delay
129
+ if (bufferCount === 1) {
130
+ setTimeout(() => {
131
+ if (isBuffering && bufferCount === 1) {
132
+ flush();
133
+ }
134
+ }, 100); // Small delay to allow nested buffers
135
+ }
106
136
  return result;
107
137
  }
138
+ catch (error) {
139
+ throw error;
140
+ }
108
141
  finally {
109
- flush();
142
+ bufferCount = Math.max(0, bufferCount - 1);
143
+ if (bufferCount === 0) {
144
+ // Auto-flush when no other buffers are active
145
+ setTimeout(flush, 100);
146
+ }
110
147
  }
111
148
  };
112
149
  },
113
150
  on: (...args) => ev.on(...args),
114
151
  off: (...args) => ev.off(...args),
115
- removeAllListeners: (...args) => ev.removeAllListeners(...args),
152
+ removeAllListeners: (...args) => ev.removeAllListeners(...args)
116
153
  };
117
154
  };
118
155
  exports.makeEventBuffer = makeEventBuffer;
@@ -138,8 +175,9 @@ const makeBufferData = () => {
138
175
  groupUpdates: {}
139
176
  };
140
177
  };
141
- function append(data, historyCache, event, eventData, logger) {
142
- var _a, _b, _c;
178
+ function append(data, historyCache, event,
179
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
180
+ eventData, logger) {
143
181
  switch (event) {
144
182
  case 'messaging-history.set':
145
183
  for (const chat of eventData.chats) {
@@ -176,13 +214,16 @@ function append(data, historyCache, event, eventData, logger) {
176
214
  }
177
215
  }
178
216
  data.historySets.empty = false;
217
+ data.historySets.syncType = eventData.syncType;
218
+ data.historySets.progress = eventData.progress;
219
+ data.historySets.peerDataRequestSessionId = eventData.peerDataRequestSessionId;
179
220
  data.historySets.isLatest = eventData.isLatest || data.historySets.isLatest;
180
221
  break;
181
222
  case 'chats.upsert':
182
223
  for (const chat of eventData) {
183
224
  let upsert = data.chatUpserts[chat.id];
184
225
  if (!upsert) {
185
- upsert = data.historySets[chat.id];
226
+ upsert = data.historySets.chats[chat.id];
186
227
  if (upsert) {
187
228
  logger.debug({ chatId: chat.id }, 'absorbed chat upsert in chat set');
188
229
  }
@@ -288,7 +329,7 @@ function append(data, historyCache, event, eventData, logger) {
288
329
  const { messages, type } = eventData;
289
330
  for (const message of messages) {
290
331
  const key = stringifyMessageKey(message.key);
291
- let existing = (_a = data.messageUpserts[key]) === null || _a === void 0 ? void 0 : _a.message;
332
+ let existing = data.messageUpserts[key]?.message;
292
333
  if (!existing) {
293
334
  existing = data.historySets.messages[key];
294
335
  if (existing) {
@@ -309,9 +350,7 @@ function append(data, historyCache, event, eventData, logger) {
309
350
  else {
310
351
  data.messageUpserts[key] = {
311
352
  message,
312
- type: type === 'notify' || ((_b = data.messageUpserts[key]) === null || _b === void 0 ? void 0 : _b.type) === 'notify'
313
- ? 'notify'
314
- : type
353
+ type: type === 'notify' || data.messageUpserts[key]?.type === 'notify' ? 'notify' : type
315
354
  };
316
355
  }
317
356
  }
@@ -320,7 +359,7 @@ function append(data, historyCache, event, eventData, logger) {
320
359
  const msgUpdates = eventData;
321
360
  for (const { key, update } of msgUpdates) {
322
361
  const keyStr = stringifyMessageKey(key);
323
- const existing = data.historySets.messages[keyStr] || ((_c = data.messageUpserts[keyStr]) === null || _c === void 0 ? void 0 : _c.message);
362
+ const existing = data.historySets.messages[keyStr] || data.messageUpserts[keyStr]?.message;
324
363
  if (existing) {
325
364
  Object.assign(existing, update);
326
365
  // if the message was received & read by us
@@ -367,8 +406,7 @@ function append(data, historyCache, event, eventData, logger) {
367
406
  (0, messages_1.updateMessageWithReaction)(existing.message, reaction);
368
407
  }
369
408
  else {
370
- data.messageReactions[keyStr] = data.messageReactions[keyStr]
371
- || { key, reactions: [] };
409
+ data.messageReactions[keyStr] = data.messageReactions[keyStr] || { key, reactions: [] };
372
410
  (0, messages_1.updateMessageWithReaction)(data.messageReactions[keyStr], reaction);
373
411
  }
374
412
  }
@@ -382,8 +420,7 @@ function append(data, historyCache, event, eventData, logger) {
382
420
  (0, messages_1.updateMessageWithReceipt)(existing.message, receipt);
383
421
  }
384
422
  else {
385
- data.messageReceipts[keyStr] = data.messageReceipts[keyStr]
386
- || { key, userReceipt: [] };
423
+ data.messageReceipts[keyStr] = data.messageReceipts[keyStr] || { key, userReceipt: [] };
387
424
  (0, messages_1.updateMessageWithReceipt)(data.messageReceipts[keyStr], receipt);
388
425
  }
389
426
  }
@@ -423,10 +460,10 @@ function append(data, historyCache, event, eventData, logger) {
423
460
  // if the message has already been marked read by us
424
461
  const chatId = message.key.remoteJid;
425
462
  const chat = data.chatUpdates[chatId] || data.chatUpserts[chatId];
426
- if ((0, process_message_1.isRealMessage)(message, '')
427
- && (0, process_message_1.shouldIncrementChatUnread)(message)
428
- && typeof (chat === null || chat === void 0 ? void 0 : chat.unreadCount) === 'number'
429
- && chat.unreadCount > 0) {
463
+ if ((0, process_message_1.isRealMessage)(message, '') &&
464
+ (0, process_message_1.shouldIncrementChatUnread)(message) &&
465
+ typeof chat?.unreadCount === 'number' &&
466
+ chat.unreadCount > 0) {
430
467
  logger.debug({ chatId: chat.id }, 'decrementing chat counter');
431
468
  chat.unreadCount -= 1;
432
469
  if (chat.unreadCount === 0) {
@@ -442,7 +479,10 @@ function consolidateEvents(data) {
442
479
  chats: Object.values(data.historySets.chats),
443
480
  messages: Object.values(data.historySets.messages),
444
481
  contacts: Object.values(data.historySets.contacts),
445
- isLatest: data.historySets.isLatest
482
+ syncType: data.historySets.syncType,
483
+ progress: data.historySets.progress,
484
+ isLatest: data.historySets.isLatest,
485
+ peerDataRequestSessionId: data.historySets.peerDataRequestSessionId
446
486
  };
447
487
  }
448
488
  const chatUpsertList = Object.values(data.chatUpserts);
@@ -496,12 +536,10 @@ function consolidateEvents(data) {
496
536
  return map;
497
537
  }
498
538
  function concatChats(a, b) {
499
- if (b.unreadCount === null) {
500
- // neutralize unread counter
501
- if (a.unreadCount < 0) {
502
- a.unreadCount = undefined;
503
- b.unreadCount = undefined;
504
- }
539
+ if (b.unreadCount === null && // neutralize unread counter
540
+ a.unreadCount < 0) {
541
+ a.unreadCount = undefined;
542
+ b.unreadCount = undefined;
505
543
  }
506
544
  if (typeof a.unreadCount === 'number' && typeof b.unreadCount === 'number') {
507
545
  b = { ...b };
@@ -1,24 +1,20 @@
1
- /// <reference types="node" />
2
- import { AxiosRequestConfig } from 'axios';
3
- import { Logger } from 'pino';
4
- import { proto } from '../../WAProto';
5
- import { BaileysEventEmitter, BaileysEventMap, WACallUpdateType, WAVersion } from '../Types';
6
- import { BinaryNode } from '../WABinary';
7
- export declare const Browsers: {
8
- ubuntu: (browser: any) => [string, string, string];
9
- macOS: (browser: any) => [string, string, string];
10
- baileys: (browser: any) => [string, string, string];
11
- windows: (browser: any) => [string, string, string];
12
- /** The appropriate browser based on your OS & release */
13
- appropriate: (browser: any) => [string, string, string];
1
+ import { type AxiosRequestConfig } from 'axios';
2
+ import { proto } from '../../WAProto/index.js';
3
+ import type { BaileysEventEmitter, BaileysEventMap, BrowsersMap, ConnectionState, WACallUpdateType, WAVersion } from '../Types';
4
+ import { type BinaryNode } from '../WABinary';
5
+ export declare const Browsers: BrowsersMap;
6
+ export declare const getPlatformId: (browser: string) => string;
7
+ export declare const BufferJSON: {
8
+ replacer: (k: any, value: any) => any;
9
+ reviver: (_: any, value: any) => any;
14
10
  };
15
- export declare const getPlatformId: (browser: string) => any;
16
11
  export declare const getKeyAuthor: (key: proto.IMessageKey | undefined | null, meId?: string) => string;
17
- export declare const writeRandomPadMax16: (msg: Uint8Array) => Buffer;
18
- export declare const unpadRandomMax16: (e: Uint8Array | Buffer) => Uint8Array;
19
- export declare const encodeWAMessage: (message: proto.IMessage) => Buffer;
12
+ export declare const writeRandomPadMax16: (msg: Uint8Array) => Buffer<ArrayBuffer>;
13
+ export declare const unpadRandomMax16: (e: Uint8Array | Buffer) => Uint8Array<ArrayBuffer>;
14
+ export declare const generateParticipantHashV2: (participants: string[]) => string;
15
+ export declare const encodeWAMessage: (message: proto.IMessage) => Buffer<ArrayBuffer>;
20
16
  export declare const generateRegistrationId: () => number;
21
- export declare const encodeBigEndian: (e: number, t?: number) => Uint8Array;
17
+ export declare const encodeBigEndian: (e: number, t?: number) => Uint8Array<ArrayBuffer>;
22
18
  export declare const toNumber: (t: Long | number | null | undefined) => number;
23
19
  /** unix timestamp of a date in seconds */
24
20
  export declare const unixTimestampSeconds: (date?: Date) => number;
@@ -37,34 +33,33 @@ export declare const delayCancellable: (ms: number) => {
37
33
  export declare function promiseTimeout<T>(ms: number | undefined, promise: (resolve: (v: T) => void, reject: (error: any) => void) => void): Promise<T>;
38
34
  export declare const generateMessageIDV2: (userId?: string) => string;
39
35
  export declare const generateMessageID: () => string;
40
- export declare function bindWaitForEvent<T extends keyof BaileysEventMap>(ev: BaileysEventEmitter, event: T): (check: (u: BaileysEventMap[T]) => boolean | undefined, timeoutMs?: number) => Promise<void>;
41
- export declare const bindWaitForConnectionUpdate: (ev: BaileysEventEmitter) => (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
42
- export declare const printQRIfNecessaryListener: (ev: BaileysEventEmitter, logger: Logger) => void;
36
+ export declare function bindWaitForEvent<T extends keyof BaileysEventMap>(ev: BaileysEventEmitter, event: T): (check: (u: BaileysEventMap[T]) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
37
+ export declare const bindWaitForConnectionUpdate: (ev: BaileysEventEmitter) => (check: (u: Partial<ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
43
38
  /**
44
39
  * utility that fetches latest baileys version from the master branch.
45
40
  * Use to ensure your WA connection is always on the latest version
46
41
  */
47
- export declare const fetchLatestBaileysVersion: (options?: AxiosRequestConfig<any>) => Promise<{
42
+ export declare const fetchLatestBaileysVersion: (options?: AxiosRequestConfig<{}>) => Promise<{
48
43
  version: WAVersion;
49
44
  isLatest: boolean;
50
45
  error?: undefined;
51
46
  } | {
52
47
  version: WAVersion;
53
48
  isLatest: boolean;
54
- error: any;
49
+ error: unknown;
55
50
  }>;
56
51
  /**
57
52
  * A utility that fetches the latest web version of whatsapp.
58
53
  * Use to ensure your WA connection is always on the latest version
59
54
  */
60
- export declare const fetchLatestWaWebVersion: (options: AxiosRequestConfig<any>) => Promise<{
55
+ export declare const fetchLatestWaWebVersion: (options: AxiosRequestConfig<{}>) => Promise<{
61
56
  version: WAVersion;
62
57
  isLatest: boolean;
63
58
  error?: undefined;
64
59
  } | {
65
60
  version: WAVersion;
66
61
  isLatest: boolean;
67
- error: any;
62
+ error: unknown;
68
63
  }>;
69
64
  /** unique message tag prefix for MD clients */
70
65
  export declare const generateMdTagPrefix: () => string;
@@ -87,6 +82,11 @@ export declare const getCodeFromWSError: (error: Error) => number;
87
82
  * Is the given platform WA business
88
83
  * @param platform AuthenticationCreds.platform
89
84
  */
90
- export declare const isWABusinessPlatform: (platform: string) => boolean;
91
- export declare function trimUndefined(obj: any): any;
85
+ export declare const isWABusinessPlatform: (platform: string) => platform is "smba" | "smbi";
86
+ export declare function trimUndefined(obj: {
87
+ [_: string]: any;
88
+ }): {
89
+ [_: string]: any;
90
+ };
92
91
  export declare function bytesToCrockford(buffer: Buffer): string;
92
+ export declare function encodeNewsletterMessage(message: proto.IMessage): Uint8Array;