@sixcore/baileys 1.0.0 → 1.0.1

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.

Potentially problematic release.


This version of @sixcore/baileys might be problematic. Click here for more details.

Files changed (228) hide show
  1. package/WAProto/index.js +14270 -302
  2. package/jessica.js +91 -0
  3. package/lib/Defaults/baileys-version.json +1 -1
  4. package/lib/Defaults/index.js +117 -79
  5. package/lib/Defaults/phonenumber-mcc.json +223 -0
  6. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  7. package/lib/Signal/Group/ciphertext-message.js +15 -0
  8. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  9. package/lib/Signal/Group/group-session-builder.js +64 -0
  10. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  11. package/lib/Signal/Group/group_cipher.js +96 -0
  12. package/lib/Signal/Group/index.d.ts +11 -0
  13. package/lib/Signal/Group/index.js +57 -0
  14. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  15. package/lib/Signal/Group/keyhelper.js +55 -0
  16. package/lib/Signal/Group/queue-job.d.ts +1 -0
  17. package/lib/Signal/Group/queue-job.js +57 -0
  18. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  19. package/lib/Signal/Group/sender-chain-key.js +34 -0
  20. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  21. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  22. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  23. package/lib/Signal/Group/sender-key-message.js +69 -0
  24. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  25. package/lib/Signal/Group/sender-key-name.js +51 -0
  26. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  27. package/lib/Signal/Group/sender-key-record.js +53 -0
  28. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  29. package/lib/Signal/Group/sender-key-state.js +99 -0
  30. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  31. package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
  32. package/lib/Signal/libsignal.js +51 -29
  33. package/lib/Socket/business.d.ts +43 -42
  34. package/lib/Socket/chats.d.ts +222 -36
  35. package/lib/Socket/chats.js +173 -153
  36. package/lib/Socket/dugong.d.ts +254 -0
  37. package/lib/Socket/dugong.js +484 -0
  38. package/lib/Socket/groups.d.ts +7 -7
  39. package/lib/Socket/groups.js +37 -35
  40. package/lib/Socket/index.d.ts +52 -51
  41. package/lib/Socket/index.js +1 -0
  42. package/lib/Socket/messages-recv.d.ts +37 -34
  43. package/lib/Socket/messages-recv.js +175 -37
  44. package/lib/Socket/messages-send.d.ts +12 -18
  45. package/lib/Socket/messages-send.js +396 -574
  46. package/lib/Socket/newsletter.d.ts +28 -26
  47. package/lib/Socket/newsletter.js +123 -25
  48. package/lib/Socket/registration.d.ts +52 -49
  49. package/lib/Socket/registration.js +7 -7
  50. package/lib/Socket/socket.d.ts +0 -1
  51. package/lib/Socket/socket.js +49 -27
  52. package/lib/Socket/usync.d.ts +10 -11
  53. package/lib/Store/make-cache-manager-store.d.ts +1 -2
  54. package/lib/Store/make-in-memory-store.d.ts +2 -2
  55. package/lib/Store/make-in-memory-store.js +1 -5
  56. package/lib/Store/make-ordered-dictionary.js +2 -2
  57. package/lib/Types/Auth.d.ts +1 -0
  58. package/lib/Types/Call.d.ts +1 -1
  59. package/lib/Types/Chat.d.ts +7 -12
  60. package/lib/Types/Events.d.ts +2 -17
  61. package/lib/Types/GroupMetadata.d.ts +2 -3
  62. package/lib/Types/Label.d.ts +0 -11
  63. package/lib/Types/Label.js +1 -1
  64. package/lib/Types/LabelAssociation.js +1 -1
  65. package/lib/Types/Message.d.ts +10 -170
  66. package/lib/Types/Newsletter.d.ts +97 -86
  67. package/lib/Types/Newsletter.js +38 -32
  68. package/lib/Types/Socket.d.ts +2 -7
  69. package/lib/Types/index.d.ts +0 -9
  70. package/lib/Types/index.js +1 -1
  71. package/lib/Utils/auth-utils.js +14 -35
  72. package/lib/Utils/business.d.ts +1 -1
  73. package/lib/Utils/business.js +2 -2
  74. package/lib/Utils/chat-utils.d.ts +12 -11
  75. package/lib/Utils/chat-utils.js +36 -52
  76. package/lib/Utils/crypto.d.ts +16 -15
  77. package/lib/Utils/crypto.js +26 -74
  78. package/lib/Utils/decode-wa-message.d.ts +0 -17
  79. package/lib/Utils/decode-wa-message.js +17 -53
  80. package/lib/Utils/event-buffer.js +7 -10
  81. package/lib/Utils/generics.d.ts +17 -13
  82. package/lib/Utils/generics.js +79 -58
  83. package/lib/Utils/history.d.ts +2 -6
  84. package/lib/Utils/history.js +6 -4
  85. package/lib/Utils/logger.d.ts +3 -1
  86. package/lib/Utils/lt-hash.js +12 -12
  87. package/lib/Utils/make-mutex.d.ts +2 -2
  88. package/lib/Utils/messages-media.d.ts +28 -25
  89. package/lib/Utils/messages-media.js +733 -557
  90. package/lib/Utils/messages.js +68 -473
  91. package/lib/Utils/noise-handler.d.ts +5 -4
  92. package/lib/Utils/noise-handler.js +14 -19
  93. package/lib/Utils/process-message.d.ts +5 -5
  94. package/lib/Utils/process-message.js +23 -75
  95. package/lib/Utils/signal.d.ts +1 -2
  96. package/lib/Utils/signal.js +26 -32
  97. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
  98. package/lib/Utils/use-multi-file-auth-state.js +66 -242
  99. package/lib/Utils/validate-connection.d.ts +1 -1
  100. package/lib/Utils/validate-connection.js +88 -64
  101. package/lib/WABinary/constants.d.ts +27 -24
  102. package/lib/WABinary/decode.d.ts +2 -1
  103. package/lib/WABinary/decode.js +11 -23
  104. package/lib/WABinary/encode.d.ts +2 -1
  105. package/lib/WABinary/encode.js +147 -134
  106. package/lib/WABinary/generic-utils.d.ts +5 -2
  107. package/lib/WABinary/generic-utils.js +125 -37
  108. package/lib/WABinary/jid-utils.d.ts +1 -1
  109. package/lib/WAM/BinaryInfo.d.ts +11 -2
  110. package/lib/WAM/encode.d.ts +2 -1
  111. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
  112. package/lib/WAUSync/USyncUser.d.ts +2 -0
  113. package/lib/index.d.ts +12 -0
  114. package/lib/index.js +64 -1
  115. package/package.json +113 -51
  116. package/WAProto/GenerateStatics.sh +0 -4
  117. package/WAProto/WAProto.proto +0 -4357
  118. package/WAProto/index.d.ts +0 -50383
  119. package/WASignalGroup/GroupProtocol.js +0 -1697
  120. package/WASignalGroup/ciphertext_message.js +0 -16
  121. package/WASignalGroup/generate-proto.sh +0 -1
  122. package/WASignalGroup/group.proto +0 -42
  123. package/WASignalGroup/group_cipher.js +0 -120
  124. package/WASignalGroup/group_session_builder.js +0 -46
  125. package/WASignalGroup/index.js +0 -5
  126. package/WASignalGroup/keyhelper.js +0 -21
  127. package/WASignalGroup/protobufs.js +0 -3
  128. package/WASignalGroup/queue_job.js +0 -69
  129. package/WASignalGroup/sender_chain_key.js +0 -50
  130. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  131. package/WASignalGroup/sender_key_message.js +0 -92
  132. package/WASignalGroup/sender_key_name.js +0 -70
  133. package/WASignalGroup/sender_key_record.js +0 -56
  134. package/WASignalGroup/sender_key_state.js +0 -129
  135. package/lib/Utils/use-single-file-auth-state.d.ts +0 -12
  136. package/lib/Utils/use-single-file-auth-state.js +0 -75
  137. package/src/Defaults/baileys-version.json +0 -3
  138. package/src/Defaults/index.ts +0 -133
  139. package/src/Signal/Group/ciphertext-message.ts +0 -9
  140. package/src/Signal/Group/group-session-builder.ts +0 -56
  141. package/src/Signal/Group/group_cipher.ts +0 -117
  142. package/src/Signal/Group/index.ts +0 -11
  143. package/src/Signal/Group/keyhelper.ts +0 -28
  144. package/src/Signal/Group/sender-chain-key.ts +0 -34
  145. package/src/Signal/Group/sender-key-distribution-message.ts +0 -95
  146. package/src/Signal/Group/sender-key-message.ts +0 -96
  147. package/src/Signal/Group/sender-key-name.ts +0 -66
  148. package/src/Signal/Group/sender-key-record.ts +0 -69
  149. package/src/Signal/Group/sender-key-state.ts +0 -134
  150. package/src/Signal/Group/sender-message-key.ts +0 -36
  151. package/src/Signal/libsignal.ts +0 -447
  152. package/src/Signal/lid-mapping.ts +0 -209
  153. package/src/Socket/Client/index.ts +0 -2
  154. package/src/Socket/Client/types.ts +0 -22
  155. package/src/Socket/Client/websocket.ts +0 -56
  156. package/src/Socket/business.ts +0 -421
  157. package/src/Socket/chats.ts +0 -1223
  158. package/src/Socket/communities.ts +0 -477
  159. package/src/Socket/groups.ts +0 -361
  160. package/src/Socket/index.ts +0 -22
  161. package/src/Socket/messages-recv.ts +0 -1563
  162. package/src/Socket/messages-send.ts +0 -1210
  163. package/src/Socket/mex.ts +0 -58
  164. package/src/Socket/newsletter.ts +0 -229
  165. package/src/Socket/socket.ts +0 -1072
  166. package/src/Types/Auth.ts +0 -115
  167. package/src/Types/Bussines.ts +0 -20
  168. package/src/Types/Call.ts +0 -14
  169. package/src/Types/Chat.ts +0 -138
  170. package/src/Types/Contact.ts +0 -24
  171. package/src/Types/Events.ts +0 -132
  172. package/src/Types/GroupMetadata.ts +0 -70
  173. package/src/Types/Label.ts +0 -48
  174. package/src/Types/LabelAssociation.ts +0 -35
  175. package/src/Types/Message.ts +0 -424
  176. package/src/Types/Newsletter.ts +0 -98
  177. package/src/Types/Product.ts +0 -85
  178. package/src/Types/Signal.ts +0 -76
  179. package/src/Types/Socket.ts +0 -150
  180. package/src/Types/State.ts +0 -43
  181. package/src/Types/USync.ts +0 -27
  182. package/src/Types/globals.d.ts +0 -8
  183. package/src/Types/index.ts +0 -67
  184. package/src/Utils/auth-utils.ts +0 -331
  185. package/src/Utils/browser-utils.ts +0 -31
  186. package/src/Utils/business.ts +0 -286
  187. package/src/Utils/chat-utils.ts +0 -933
  188. package/src/Utils/crypto.ts +0 -184
  189. package/src/Utils/decode-wa-message.ts +0 -355
  190. package/src/Utils/event-buffer.ts +0 -662
  191. package/src/Utils/generics.ts +0 -470
  192. package/src/Utils/history.ts +0 -114
  193. package/src/Utils/index.ts +0 -18
  194. package/src/Utils/link-preview.ts +0 -111
  195. package/src/Utils/logger.ts +0 -13
  196. package/src/Utils/lt-hash.ts +0 -65
  197. package/src/Utils/make-mutex.ts +0 -45
  198. package/src/Utils/message-retry-manager.ts +0 -229
  199. package/src/Utils/messages-media.ts +0 -820
  200. package/src/Utils/messages.ts +0 -1137
  201. package/src/Utils/noise-handler.ts +0 -192
  202. package/src/Utils/pre-key-manager.ts +0 -126
  203. package/src/Utils/process-message.ts +0 -622
  204. package/src/Utils/signal.ts +0 -214
  205. package/src/Utils/use-multi-file-auth-state.ts +0 -136
  206. package/src/Utils/validate-connection.ts +0 -253
  207. package/src/WABinary/constants.ts +0 -1305
  208. package/src/WABinary/decode.ts +0 -281
  209. package/src/WABinary/encode.ts +0 -253
  210. package/src/WABinary/generic-utils.ts +0 -127
  211. package/src/WABinary/index.ts +0 -5
  212. package/src/WABinary/jid-utils.ts +0 -128
  213. package/src/WABinary/types.ts +0 -17
  214. package/src/WAM/BinaryInfo.ts +0 -12
  215. package/src/WAM/constants.ts +0 -22889
  216. package/src/WAM/encode.ts +0 -169
  217. package/src/WAM/index.ts +0 -3
  218. package/src/WAUSync/Protocols/USyncContactProtocol.ts +0 -32
  219. package/src/WAUSync/Protocols/USyncDeviceProtocol.ts +0 -78
  220. package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.ts +0 -35
  221. package/src/WAUSync/Protocols/USyncStatusProtocol.ts +0 -44
  222. package/src/WAUSync/Protocols/UsyncBotProfileProtocol.ts +0 -76
  223. package/src/WAUSync/Protocols/UsyncLIDProtocol.ts +0 -33
  224. package/src/WAUSync/Protocols/index.ts +0 -4
  225. package/src/WAUSync/USyncQuery.ts +0 -133
  226. package/src/WAUSync/USyncUser.ts +0 -32
  227. package/src/WAUSync/index.ts +0 -3
  228. package/src/index.ts +0 -13
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { Boom } from '@hapi/boom';
4
3
  import { SocketConfig } from '../Types';
5
4
  import { BinaryNode } from '../WABinary';
@@ -20,21 +20,16 @@ const Client_1 = require("./Client");
20
20
  const makeSocket = (config) => {
21
21
  var _a, _b;
22
22
  const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository, } = config;
23
- let url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl;
24
- config.mobile = config.mobile || url.protocol === 'tcp:';
25
- if (config.mobile && url.protocol !== 'tcp:') {
26
- url = new url_1.URL(`tcp://${Defaults_1.MOBILE_ENDPOINT}:${Defaults_1.MOBILE_PORT}`);
27
- }
28
- if (!config.mobile && url.protocol === 'wss' && ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.routingInfo)) {
29
- url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'));
30
- }
23
+ const url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl;
31
24
  if (config.mobile || url.protocol === 'tcp:') {
32
- throw new boom_1.Boom('Mobile API is not supported anymore', { statusCode: Types_1.DisconnectReason.loggedOut });
25
+ throw new boom_1.Boom('Mobile API is not supported anymore', {
26
+ statusCode: Types_1.DisconnectReason.loggedOut
27
+ });
33
28
  }
34
29
  if (url.protocol === 'wss' && ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.routingInfo)) {
35
30
  url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'));
36
31
  }
37
- const ws = config.socket ? config.socket : config.mobile ? new Client_1.MobileSocketClient(url, config) : new Client_1.WebSocketClient(url, config);
32
+ const ws = new Client_1.WebSocketClient(url, config);
38
33
  ws.connect();
39
34
  const ev = (0, Utils_1.makeEventBuffer)(logger);
40
35
  /** ephemeral key pair used to encrypt/decrypt communication. Unique for each connection */
@@ -42,8 +37,7 @@ const makeSocket = (config) => {
42
37
  /** WA noise protocol wrapper */
43
38
  const noise = (0, Utils_1.makeNoiseHandler)({
44
39
  keyPair: ephemeralKeyPair,
45
- NOISE_HEADER: config.mobile ? Defaults_1.MOBILE_NOISE_HEADER : Defaults_1.NOISE_WA_HEADER,
46
- mobile: config.mobile,
40
+ NOISE_HEADER: Defaults_1.NOISE_WA_HEADER,
47
41
  logger,
48
42
  routingInfo: (_b = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _b === void 0 ? void 0 : _b.routingInfo
49
43
  });
@@ -86,6 +80,25 @@ const makeSocket = (config) => {
86
80
  /** log & process any unexpected errors */
87
81
  const onUnexpectedError = (err, msg) => {
88
82
  logger.error({ err }, `unexpected error in '${msg}'`);
83
+ const message = (err && ((err.stack || err.message) || String(err))).toLowerCase();
84
+ // auto recover from cryptographic desyncs by re-uploading prekeys
85
+ if (message.includes('bad mac') || (message.includes('mac') && message.includes('invalid'))) {
86
+ try {
87
+ uploadPreKeysToServerIfRequired(true)
88
+ .catch(e => logger.warn({ e }, 'failed to re-upload prekeys after bad mac'));
89
+ }
90
+ catch (_e) {
91
+ // ignore
92
+ }
93
+ }
94
+ // gently back off when encountering rate limits (429)
95
+ if (message.includes('429') || message.includes('rate limit')) {
96
+ const wait = Math.min(30000, (config.backoffDelayMs || 5000));
97
+ logger.info({ wait }, 'backing off due to rate limit');
98
+ setTimeout(() => {
99
+ // intentionally empty; wait to delay further sends
100
+ }, wait);
101
+ }
89
102
  };
90
103
  /** await the next incoming message */
91
104
  const awaitNextMessage = async (sendMsg) => {
@@ -122,7 +135,7 @@ const makeSocket = (config) => {
122
135
  let onRecv;
123
136
  let onErr;
124
137
  try {
125
- return await (0, Utils_1.promiseTimeout)(timeoutMs, (resolve, reject) => {
138
+ const result = await (0, Utils_1.promiseTimeout)(timeoutMs, (resolve, reject) => {
126
139
  onRecv = resolve;
127
140
  onErr = err => {
128
141
  reject(err || new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed }));
@@ -131,6 +144,7 @@ const makeSocket = (config) => {
131
144
  ws.on('close', onErr); // if the socket closes, you'll never receive the message
132
145
  ws.off('error', onErr);
133
146
  });
147
+ return result;
134
148
  }
135
149
  finally {
136
150
  ws.off(`TAG:${msgId}`, onRecv);
@@ -144,9 +158,10 @@ const makeSocket = (config) => {
144
158
  node.attrs.id = generateMessageTag();
145
159
  }
146
160
  const msgId = node.attrs.id;
147
- const wait = waitForMessage(msgId, timeoutMs);
148
- await sendNode(node);
149
- const result = await wait;
161
+ const [result] = await Promise.all([
162
+ waitForMessage(msgId, timeoutMs),
163
+ sendNode(node)
164
+ ]);
150
165
  if ('tag' in result) {
151
166
  (0, WABinary_1.assertNodeErrorFree)(result);
152
167
  }
@@ -165,10 +180,7 @@ const makeSocket = (config) => {
165
180
  logger.trace({ handshake }, 'handshake recv from WA');
166
181
  const keyEnc = await noise.processHandshake(handshake, creds.noiseKey);
167
182
  let node;
168
- if (config.mobile) {
169
- node = (0, Utils_1.generateMobileNode)(config);
170
- }
171
- else if (!creds.me) {
183
+ if (!creds.me) {
172
184
  node = (0, Utils_1.generateRegistrationNode)(creds, config);
173
185
  logger.info({ node }, 'not logged in, attempting registration...');
174
186
  }
@@ -183,7 +195,7 @@ const makeSocket = (config) => {
183
195
  payload: payloadEnc,
184
196
  },
185
197
  }).finish());
186
- await noise.finishInit();
198
+ noise.finishInit();
187
199
  startKeepAliveRequest();
188
200
  };
189
201
  const getAvailablePreKeysOnServer = async () => {
@@ -371,17 +383,24 @@ const makeSocket = (config) => {
371
383
  }
372
384
  end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
373
385
  };
374
- const requestPairingCode = async (phoneNumber, pairKey = "ABCD1234") => {
386
+
387
+ /** This method was created by snowi, and implemented by KyuuRzy */
388
+ /** hey bro, if you delete this text */
389
+ /** you are the most cursed human being who likes to claim other people's property 😹🙌🏻 */
390
+ const requestPairingCode = async (phoneNumber, pairKey) => {
375
391
  if (pairKey) {
376
- authState.creds.pairingCode = pairKey.toUpperCase()
392
+ authState.creds.pairingCode = pairKey.toUpperCase();
377
393
  } else {
378
394
  authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
379
395
  }
396
+
380
397
  authState.creds.me = {
381
398
  id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
382
399
  name: '~'
383
400
  };
401
+
384
402
  ev.emit('creds.update', authState.creds);
403
+
385
404
  await sendNode({
386
405
  tag: 'iq',
387
406
  attrs: {
@@ -396,7 +415,6 @@ const makeSocket = (config) => {
396
415
  attrs: {
397
416
  jid: authState.creds.me.id,
398
417
  stage: 'companion_hello',
399
- // eslint-disable-next-line camelcase
400
418
  should_show_push_notification: 'true'
401
419
  },
402
420
  content: [
@@ -423,14 +441,15 @@ const makeSocket = (config) => {
423
441
  {
424
442
  tag: 'link_code_pairing_nonce',
425
443
  attrs: {},
426
- content: '0'
444
+ content: "0"
427
445
  }
428
446
  ]
429
447
  }
430
448
  ]
431
449
  });
450
+
432
451
  return authState.creds.pairingCode;
433
- };
452
+ }
434
453
  async function generatePairingKey() {
435
454
  const salt = (0, crypto_1.randomBytes)(32);
436
455
  const randomIv = (0, crypto_1.randomBytes)(16);
@@ -609,7 +628,10 @@ const makeSocket = (config) => {
609
628
  type: 'md',
610
629
  ws,
611
630
  ev,
612
- authState: { creds, keys },
631
+ authState: {
632
+ creds,
633
+ keys
634
+ },
613
635
  signalRepository,
614
636
  get user() {
615
637
  return authState.creds.me;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Boom } from '@hapi/boom';
3
2
  import { SocketConfig } from '../Types';
4
3
  import { BinaryNode } from '../WABinary';
@@ -6,12 +5,12 @@ import { USyncQuery } from '../WAUSync';
6
5
  export declare const makeUSyncSocket: (config: SocketConfig) => {
7
6
  executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
8
7
  type: "md";
9
- ws: any;
8
+ ws: import("./Client").WebSocketClient;
10
9
  ev: import("../Types").BaileysEventEmitter & {
11
- process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
10
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
12
11
  buffer(): void;
13
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
14
- flush(force?: boolean | undefined): boolean;
12
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
13
+ flush(force?: boolean): boolean;
15
14
  isBuffering(): boolean;
16
15
  };
17
16
  authState: {
@@ -21,17 +20,17 @@ export declare const makeUSyncSocket: (config: SocketConfig) => {
21
20
  signalRepository: import("../Types").SignalRepository;
22
21
  user: import("../Types").Contact | undefined;
23
22
  generateMessageTag: () => string;
24
- query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
25
- waitForMessage: <T_1>(msgId: string, timeoutMs?: number | undefined) => Promise<T_1>;
23
+ query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
24
+ waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
26
25
  waitForSocketOpen: () => Promise<void>;
27
26
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
28
27
  sendNode: (frame: BinaryNode) => Promise<void>;
29
- logout: (msg?: string | undefined) => Promise<void>;
28
+ logout: (msg?: string) => Promise<void>;
30
29
  end: (error: Error | undefined) => void;
31
- onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
30
+ onUnexpectedError: (err: Error | Boom, msg: string) => void;
32
31
  uploadPreKeys: (count?: number) => Promise<void>;
33
32
  uploadPreKeysToServerIfRequired: () => Promise<void>;
34
- requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
35
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
33
+ requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
34
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
36
35
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
37
36
  };
@@ -1,6 +1,5 @@
1
- import { Store } from 'cache-manager';
2
1
  import { AuthenticationCreds } from '../Types';
3
- declare const makeCacheManagerAuthState: (store: Store, sessionKey: string) => Promise<{
2
+ declare const makeCacheManagerAuthState: (store: Storage, sessionKey: string) => Promise<{
4
3
  clearState: () => Promise<void>;
5
4
  saveCreds: () => Promise<void>;
6
5
  state: {
@@ -1,11 +1,11 @@
1
1
  import type KeyedDB from '@adiwajshing/keyed-db';
2
2
  import type { Comparable } from '@adiwajshing/keyed-db/lib/Types';
3
+ import type { Logger } from 'pino';
3
4
  import { proto } from '../../WAProto';
4
5
  import type makeMDSocket from '../Socket';
5
6
  import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types';
6
7
  import { Label } from '../Types/Label';
7
8
  import { LabelAssociation } from '../Types/LabelAssociation';
8
- import { ILogger } from '../Utils/logger';
9
9
  import { ObjectRepository } from './object-repository';
10
10
  type WASocket = ReturnType<typeof makeMDSocket>;
11
11
  export declare const waChatKey: (pin: boolean) => {
@@ -17,7 +17,7 @@ export declare const waLabelAssociationKey: Comparable<LabelAssociation, string>
17
17
  export type BaileysInMemoryStoreConfig = {
18
18
  chatKey?: Comparable<Chat, string>;
19
19
  labelAssociationKey?: Comparable<LabelAssociation, string>;
20
- logger?: ILogger;
20
+ logger?: Logger;
21
21
  socket?: WASocket;
22
22
  };
23
23
  declare const _default: (config: BaileysInMemoryStoreConfig) => {
@@ -74,11 +74,7 @@ exports.default = (config) => {
74
74
  ev.on('connection.update', update => {
75
75
  Object.assign(state, update);
76
76
  });
77
- ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest, syncType }) => {
78
- if (syncType === WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND) {
79
- return; // FOR NOW,
80
- //TODO: HANDLE
81
- }
77
+ ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest }) => {
82
78
  if (isLatest) {
83
79
  chats.clear();
84
80
  for (const id in messages) {
@@ -56,9 +56,9 @@ function makeOrderedDictionary(idGetter) {
56
56
  },
57
57
  clear: () => {
58
58
  array.splice(0, array.length);
59
- for (const key of Object.keys(dict)) {
59
+ Object.keys(dict).forEach(key => {
60
60
  delete dict[key];
61
- }
61
+ });
62
62
  },
63
63
  filter: (contain) => {
64
64
  let i = 0;
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import type { proto } from '../../WAProto';
2
3
  import { RegistrationOptions } from '../Socket/registration';
3
4
  import type { Contact } from './Contact';
@@ -1,4 +1,4 @@
1
- export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate';
1
+ export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept';
2
2
  export type WACallEvent = {
3
3
  chatId: string;
4
4
  from: string;
@@ -1,16 +1,13 @@
1
1
  import type { proto } from '../../WAProto';
2
2
  import type { AccountSettings } from './Auth';
3
3
  import type { BufferedEventData } from './Events';
4
- import type { LabelActionBody } from './Label';
5
4
  import type { ChatLabelAssociationActionBody } from './LabelAssociation';
6
5
  import type { MessageLabelAssociationActionBody } from './LabelAssociation';
7
- import type { MinimalMessage, WAMessageKey } from './Message';
6
+ import type { MinimalMessage } from './Message';
8
7
  /** privacy settings in WhatsApp Web */
9
8
  export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
10
9
  export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
11
- export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
12
10
  export type WAReadReceiptsValue = 'all' | 'none';
13
- export type WAPrivacyCallValue = 'all' | 'known';
14
11
  /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
15
12
  export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
16
13
  export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
@@ -62,12 +59,12 @@ export type ChatModification = {
62
59
  /** mute for duration, or provide timestamp of mute to remove*/
63
60
  mute: number | null;
64
61
  } | {
65
- clear: boolean;
66
- } | {
67
- deleteForMe: {
68
- deleteMedia: boolean;
69
- key: WAMessageKey;
70
- timestamp: number;
62
+ clear: 'all' | {
63
+ messages: {
64
+ id: string;
65
+ fromMe?: boolean;
66
+ timestamp: number;
67
+ }[];
71
68
  };
72
69
  } | {
73
70
  star: {
@@ -83,8 +80,6 @@ export type ChatModification = {
83
80
  } | {
84
81
  delete: true;
85
82
  lastMessages: LastMessageList;
86
- } | {
87
- addLabel: LabelActionBody;
88
83
  } | {
89
84
  addChatLabel: ChatLabelAssociationActionBody;
90
85
  } | {
@@ -4,7 +4,7 @@ import { AuthenticationCreds } from './Auth';
4
4
  import { WACallEvent } from './Call';
5
5
  import { Chat, ChatUpdate, PresenceData } from './Chat';
6
6
  import { Contact } from './Contact';
7
- import { GroupMetadata, ParticipantAction, RequestJoinAction, RequestJoinMethod } from './GroupMetadata';
7
+ import { GroupMetadata, ParticipantAction } from './GroupMetadata';
8
8
  import { Label } from './Label';
9
9
  import { LabelAssociation } from './LabelAssociation';
10
10
  import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
@@ -19,10 +19,7 @@ export type BaileysEventMap = {
19
19
  chats: Chat[];
20
20
  contacts: Contact[];
21
21
  messages: WAMessage[];
22
- isLatest?: boolean;
23
- progress?: number | null;
24
- syncType?: proto.HistorySync.HistorySyncType;
25
- peerDataRequestSessionId?: string | null;
22
+ isLatest: boolean;
26
23
  };
27
24
  /** upsert chats */
28
25
  'chats.upsert': Chat[];
@@ -61,12 +58,10 @@ export type BaileysEventMap = {
61
58
  /**
62
59
  * add/update the given messages. If they were received while the connection was online,
63
60
  * the update will have type: "notify"
64
- * if requestId is provided, then the messages was received from the phone due to it being unavailable
65
61
  * */
66
62
  'messages.upsert': {
67
63
  messages: WAMessage[];
68
64
  type: MessageUpsertType;
69
- requestId?: string;
70
65
  };
71
66
  /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
72
67
  'messages.reaction': {
@@ -83,13 +78,6 @@ export type BaileysEventMap = {
83
78
  participants: string[];
84
79
  action: ParticipantAction;
85
80
  };
86
- 'group.join-request': {
87
- id: string;
88
- author: string;
89
- participant: string;
90
- action: RequestJoinAction;
91
- method: RequestJoinMethod;
92
- };
93
81
  'blocklist.set': {
94
82
  blocklist: string[];
95
83
  };
@@ -118,9 +106,6 @@ export type BufferedEventData = {
118
106
  };
119
107
  empty: boolean;
120
108
  isLatest: boolean;
121
- progress?: number | null;
122
- syncType?: proto.HistorySync.HistorySyncType;
123
- peerDataRequestSessionId?: string;
124
109
  };
125
110
  chatUpserts: {
126
111
  [jid: string]: Chat;
@@ -4,13 +4,12 @@ export type GroupParticipant = (Contact & {
4
4
  isSuperAdmin?: boolean;
5
5
  admin?: 'admin' | 'superadmin' | null;
6
6
  });
7
- export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify';
8
- export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
9
- export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
7
+ export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
10
8
  export interface GroupMetadata {
11
9
  id: string;
12
10
  owner: string | undefined;
13
11
  subject: string;
12
+ addressingMode: "pn" | "lid";
14
13
  /** group subject owner */
15
14
  subjectOwner?: string;
16
15
  /** group subject modification date */
@@ -10,17 +10,6 @@ export interface Label {
10
10
  /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
11
11
  predefinedId?: string;
12
12
  }
13
- export interface LabelActionBody {
14
- id: string;
15
- /** Label name */
16
- name?: string;
17
- /** Label color ID */
18
- color?: number;
19
- /** Is label has been deleted */
20
- deleted?: boolean;
21
- /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
22
- predefinedId?: number;
23
- }
24
13
  /** WhatsApp has 20 predefined colors */
25
14
  export declare enum LabelColor {
26
15
  Color1 = 0,
@@ -24,4 +24,4 @@ var LabelColor;
24
24
  LabelColor[LabelColor["Color18"] = 17] = "Color18";
25
25
  LabelColor[LabelColor["Color19"] = 18] = "Color19";
26
26
  LabelColor[LabelColor["Color20"] = 19] = "Color20";
27
- })(LabelColor || (exports.LabelColor = LabelColor = {}));
27
+ })(LabelColor = exports.LabelColor || (exports.LabelColor = {}));
@@ -6,4 +6,4 @@ var LabelAssociationType;
6
6
  (function (LabelAssociationType) {
7
7
  LabelAssociationType["Chat"] = "label_jid";
8
8
  LabelAssociationType["Message"] = "label_message";
9
- })(LabelAssociationType || (exports.LabelAssociationType = LabelAssociationType = {}));
9
+ })(LabelAssociationType = exports.LabelAssociationType || (exports.LabelAssociationType = {}));