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