lordceaser-baileys 1.0.20 → 1.0.21

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 (123) hide show
  1. package/lib/Defaults/baileys-version.json +1 -1
  2. package/lib/Defaults/index.d.ts +235 -3
  3. package/lib/Defaults/index.js +22 -6
  4. package/lib/Defaults/phonenumber-mcc.json +223 -0
  5. package/lib/Signal/libsignal.js +9 -18
  6. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +2 -0
  7. package/lib/Socket/Client/index.d.ts +3 -2
  8. package/lib/Socket/Client/index.js +3 -2
  9. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  10. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  11. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
  12. package/lib/Socket/Client/{websocket.js → web-socket-client.js} +2 -2
  13. package/lib/Socket/business.d.ts +40 -38
  14. package/lib/Socket/chats.d.ts +23 -25
  15. package/lib/Socket/chats.js +78 -79
  16. package/lib/Socket/groups.d.ts +29 -30
  17. package/lib/Socket/groups.js +3 -4
  18. package/lib/Socket/index.d.ts +48 -44
  19. package/lib/Socket/index.js +2 -2
  20. package/lib/Socket/messages-recv.d.ts +37 -37
  21. package/lib/Socket/messages-recv.js +44 -98
  22. package/lib/Socket/messages-send.d.ts +31 -33
  23. package/lib/Socket/messages-send.js +70 -82
  24. package/lib/Socket/registration.d.ts +242 -0
  25. package/lib/Socket/registration.js +166 -0
  26. package/lib/Socket/socket.d.ts +10 -9
  27. package/lib/Socket/socket.js +23 -28
  28. package/lib/Store/index.d.ts +3 -0
  29. package/lib/Store/index.js +10 -0
  30. package/lib/Store/make-cache-manager-store.d.ts +14 -0
  31. package/lib/Store/make-cache-manager-store.js +83 -0
  32. package/lib/Store/make-in-memory-store.d.ts +118 -0
  33. package/lib/Store/make-in-memory-store.js +422 -0
  34. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  35. package/lib/Store/make-ordered-dictionary.js +81 -0
  36. package/lib/Store/object-repository.d.ts +10 -0
  37. package/lib/Store/object-repository.js +27 -0
  38. package/lib/Types/Auth.d.ts +7 -0
  39. package/lib/Types/Chat.d.ts +7 -12
  40. package/lib/Types/Contact.d.ts +1 -1
  41. package/lib/Types/GroupMetadata.d.ts +0 -2
  42. package/lib/Types/Label.js +1 -1
  43. package/lib/Types/LabelAssociation.js +1 -1
  44. package/lib/Types/Message.d.ts +10 -9
  45. package/lib/Types/Message.js +3 -1
  46. package/lib/Types/Socket.d.ts +11 -16
  47. package/lib/Types/index.js +1 -1
  48. package/lib/Utils/auth-utils.d.ts +3 -3
  49. package/lib/Utils/auth-utils.js +13 -7
  50. package/lib/Utils/business.js +5 -13
  51. package/lib/Utils/chat-utils.d.ts +14 -13
  52. package/lib/Utils/chat-utils.js +31 -36
  53. package/lib/Utils/crypto.d.ts +15 -14
  54. package/lib/Utils/crypto.js +30 -70
  55. package/lib/Utils/decode-wa-message.d.ts +2 -18
  56. package/lib/Utils/decode-wa-message.js +19 -23
  57. package/lib/Utils/event-buffer.d.ts +2 -2
  58. package/lib/Utils/event-buffer.js +7 -7
  59. package/lib/Utils/generics.d.ts +14 -15
  60. package/lib/Utils/generics.js +29 -33
  61. package/lib/Utils/history.d.ts +2 -2
  62. package/lib/Utils/history.js +1 -1
  63. package/lib/Utils/link-preview.d.ts +2 -2
  64. package/lib/Utils/link-preview.js +1 -34
  65. package/lib/Utils/logger.d.ts +3 -10
  66. package/lib/Utils/lt-hash.d.ts +2 -2
  67. package/lib/Utils/lt-hash.js +6 -6
  68. package/lib/Utils/make-mutex.d.ts +2 -2
  69. package/lib/Utils/make-mutex.js +0 -1
  70. package/lib/Utils/messages-media.d.ts +24 -20
  71. package/lib/Utils/messages-media.js +76 -79
  72. package/lib/Utils/messages.d.ts +9 -7
  73. package/lib/Utils/messages.js +30 -29
  74. package/lib/Utils/noise-handler.d.ts +11 -9
  75. package/lib/Utils/noise-handler.js +22 -17
  76. package/lib/Utils/process-message.d.ts +5 -4
  77. package/lib/Utils/process-message.js +40 -68
  78. package/lib/Utils/signal.d.ts +1 -2
  79. package/lib/Utils/signal.js +19 -11
  80. package/lib/Utils/use-multi-file-auth-state.js +14 -46
  81. package/lib/Utils/validate-connection.d.ts +3 -2
  82. package/lib/Utils/validate-connection.js +46 -16
  83. package/lib/WABinary/constants.js +5 -5
  84. package/lib/WABinary/decode.d.ts +3 -2
  85. package/lib/WABinary/decode.js +9 -20
  86. package/lib/WABinary/encode.d.ts +2 -1
  87. package/lib/WABinary/encode.js +18 -38
  88. package/lib/WABinary/generic-utils.d.ts +2 -1
  89. package/lib/WABinary/generic-utils.js +3 -3
  90. package/lib/WABinary/jid-utils.d.ts +3 -7
  91. package/lib/WABinary/jid-utils.js +2 -9
  92. package/lib/WAM/BinaryInfo.d.ts +11 -2
  93. package/lib/WAM/constants.d.ts +2 -3
  94. package/lib/WAM/encode.d.ts +2 -1
  95. package/lib/WAM/encode.js +2 -2
  96. package/lib/index.d.ts +1 -1
  97. package/lib/index.js +1 -1
  98. package/package.json +2 -2
  99. package/lib/Socket/usync.d.ts +0 -36
  100. package/lib/Socket/usync.js +0 -70
  101. package/lib/Types/USync.d.ts +0 -25
  102. package/lib/Types/USync.js +0 -2
  103. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  104. package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -32
  105. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  106. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -57
  107. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  108. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -30
  109. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  110. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -42
  111. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
  112. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -53
  113. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
  114. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -24
  115. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  116. package/lib/WAUSync/Protocols/index.js +0 -20
  117. package/lib/WAUSync/USyncQuery.d.ts +0 -28
  118. package/lib/WAUSync/USyncQuery.js +0 -89
  119. package/lib/WAUSync/USyncUser.d.ts +0 -12
  120. package/lib/WAUSync/USyncUser.js +0 -26
  121. package/lib/WAUSync/index.d.ts +0 -3
  122. package/lib/WAUSync/index.js +0 -19
  123. /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
@@ -4,21 +4,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.makeMessagesSocket = void 0;
7
- const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
8
7
  const boom_1 = require("@hapi/boom");
9
- const WAProto_1 = require("../WAProto");
8
+ const node_cache_1 = __importDefault(require("node-cache"));
9
+ const WAProto_1 = require("../../WAProto");
10
10
  const Defaults_1 = require("../Defaults");
11
11
  const Utils_1 = require("../Utils");
12
12
  const link_preview_1 = require("../Utils/link-preview");
13
13
  const WABinary_1 = require("../WABinary");
14
- const WAUSync_1 = require("../WAUSync");
15
14
  const groups_1 = require("./groups");
16
15
  const makeMessagesSocket = (config) => {
17
16
  const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, cachedGroupMetadata, } = config;
18
17
  const sock = (0, groups_1.makeGroupsSocket)(config);
19
- const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, sendNode, groupMetadata, groupToggleEphemeral, } = sock;
18
+ const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, generateMessageTag, sendNode, groupMetadata, groupToggleEphemeral, } = sock;
20
19
  const userDevicesCache = config.userDevicesCache || new node_cache_1.default({
21
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES, // 5 minutes
20
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES,
22
21
  useClones: false
23
22
  });
24
23
  let mediaConn;
@@ -116,46 +115,66 @@ const makeMessagesSocket = (config) => {
116
115
  if (!useCache) {
117
116
  logger.debug('not using cache for devices');
118
117
  }
119
- const toFetch = [];
118
+ const users = [];
120
119
  jids = Array.from(new Set(jids));
121
120
  for (let jid of jids) {
122
121
  const user = (_a = (0, WABinary_1.jidDecode)(jid)) === null || _a === void 0 ? void 0 : _a.user;
123
122
  jid = (0, WABinary_1.jidNormalizedUser)(jid);
124
- if (useCache) {
125
- const devices = userDevicesCache.get(user);
126
- if (devices) {
127
- deviceResults.push(...devices);
128
- logger.trace({ user }, 'using cache for devices');
129
- }
130
- else {
131
- toFetch.push(jid);
132
- }
123
+ const devices = userDevicesCache.get(user);
124
+ if (devices && useCache) {
125
+ deviceResults.push(...devices);
126
+ logger.trace({ user }, 'using cache for devices');
133
127
  }
134
128
  else {
135
- toFetch.push(jid);
129
+ users.push({ tag: 'user', attrs: { jid } });
136
130
  }
137
131
  }
138
- if (!toFetch.length) {
132
+ if (!users.length) {
139
133
  return deviceResults;
140
134
  }
141
- const query = new WAUSync_1.USyncQuery()
142
- .withContext('message')
143
- .withDeviceProtocol();
144
- for (const jid of toFetch) {
145
- query.withUser(new WAUSync_1.USyncUser().withId(jid));
146
- }
147
- const result = await sock.executeUSyncQuery(query);
148
- if (result) {
149
- const extracted = (0, Utils_1.extractDeviceJids)(result === null || result === void 0 ? void 0 : result.list, authState.creds.me.id, ignoreZeroDevices);
150
- const deviceMap = {};
151
- for (const item of extracted) {
152
- deviceMap[item.user] = deviceMap[item.user] || [];
153
- deviceMap[item.user].push(item);
154
- deviceResults.push(item);
155
- }
156
- for (const key in deviceMap) {
157
- userDevicesCache.set(key, deviceMap[key]);
158
- }
135
+ const iq = {
136
+ tag: 'iq',
137
+ attrs: {
138
+ to: WABinary_1.S_WHATSAPP_NET,
139
+ type: 'get',
140
+ xmlns: 'usync',
141
+ },
142
+ content: [
143
+ {
144
+ tag: 'usync',
145
+ attrs: {
146
+ sid: generateMessageTag(),
147
+ mode: 'query',
148
+ last: 'true',
149
+ index: '0',
150
+ context: 'message',
151
+ },
152
+ content: [
153
+ {
154
+ tag: 'query',
155
+ attrs: {},
156
+ content: [
157
+ {
158
+ tag: 'devices',
159
+ attrs: { version: '2' }
160
+ }
161
+ ]
162
+ },
163
+ { tag: 'list', attrs: {}, content: users }
164
+ ]
165
+ },
166
+ ],
167
+ };
168
+ const result = await query(iq);
169
+ const extracted = (0, Utils_1.extractDeviceJids)(result, authState.creds.me.id, ignoreZeroDevices);
170
+ const deviceMap = {};
171
+ for (const item of extracted) {
172
+ deviceMap[item.user] = deviceMap[item.user] || [];
173
+ deviceMap[item.user].push(item);
174
+ deviceResults.push(item);
175
+ }
176
+ for (const key in deviceMap) {
177
+ userDevicesCache.set(key, deviceMap[key]);
159
178
  }
160
179
  return deviceResults;
161
180
  };
@@ -225,17 +244,10 @@ const makeMessagesSocket = (config) => {
225
244
  return msgId;
226
245
  };
227
246
  const createParticipantNodes = async (jids, message, extraAttrs) => {
228
- let patched = await patchMessageBeforeSending(message, jids);
229
- if (!Array.isArray(patched)) {
230
- patched = jids ? jids.map(jid => ({ recipientJid: jid, ...patched })) : [patched];
231
- }
247
+ const patched = await patchMessageBeforeSending(message, jids);
248
+ const bytes = (0, Utils_1.encodeWAMessage)(patched);
232
249
  let shouldIncludeDeviceIdentity = false;
233
- const nodes = await Promise.all(patched.map(async (patchedMessageWithJid) => {
234
- const { recipientJid: jid, ...patchedMessage } = patchedMessageWithJid;
235
- if (!jid) {
236
- return {};
237
- }
238
- const bytes = (0, Utils_1.encodeWAMessage)(patchedMessage);
250
+ const nodes = await Promise.all(jids.map(async (jid) => {
239
251
  const { type, ciphertext } = await signalRepository
240
252
  .encryptMessage({ jid, data: bytes });
241
253
  if (type === 'pkmsg') {
@@ -325,19 +337,10 @@ const makeMessagesSocket = (config) => {
325
337
  if (isStatus && statusJidList) {
326
338
  participantsList.push(...statusJidList);
327
339
  }
328
- if (!isStatus) {
329
- additionalAttributes = {
330
- ...additionalAttributes,
331
- addressing_mode: (groupData === null || groupData === void 0 ? void 0 : groupData.addressingMode) || 'pn'
332
- };
333
- }
334
340
  const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false);
335
341
  devices.push(...additionalDevices);
336
342
  }
337
- const patched = await patchMessageBeforeSending(message);
338
- if (Array.isArray(patched)) {
339
- throw new boom_1.Boom('Per-jid patching is not supported in groups');
340
- }
343
+ const patched = await patchMessageBeforeSending(message, devices.map(d => (0, WABinary_1.jidEncode)(d.user, isLid ? 'lid' : 's.whatsapp.net', d.device)));
341
344
  const bytes = (0, Utils_1.encodeWAMessage)(patched);
342
345
  const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage({
343
346
  group: destinationJid,
@@ -347,7 +350,7 @@ const makeMessagesSocket = (config) => {
347
350
  const senderKeyJids = [];
348
351
  // ensure a connection is established with every device
349
352
  for (const { user, device } of devices) {
350
- const jid = (0, WABinary_1.jidEncode)(user, (groupData === null || groupData === void 0 ? void 0 : groupData.addressingMode) === 'lid' ? 'lid' : 's.whatsapp.net', device);
353
+ const jid = (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : 's.whatsapp.net', device);
351
354
  if (!senderKeyMap[jid] || !!participant) {
352
355
  senderKeyJids.push(jid);
353
356
  // store that this person has had the sender keys sent to them
@@ -377,13 +380,14 @@ const makeMessagesSocket = (config) => {
377
380
  await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
378
381
  }
379
382
  else {
380
- const { user: meUser } = (0, WABinary_1.jidDecode)(meId);
383
+ const { user: meUser, device: meDevice } = (0, WABinary_1.jidDecode)(meId);
381
384
  if (!participant) {
382
385
  devices.push({ user });
383
- if (user !== meUser) {
384
- devices.push({ user: meUser });
385
- }
386
- if ((additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes['category']) !== 'peer') {
386
+ // do not send message to self if the device is 0 (mobile)
387
+ if (!((additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes['category']) === 'peer' && user === meUser)) {
388
+ if (meDevice !== undefined && meDevice !== 0) {
389
+ devices.push({ user: meUser });
390
+ }
387
391
  const additionalDevices = await getUSyncDevices([meId, jid], !!useUserDevicesCache, true);
388
392
  devices.push(...additionalDevices);
389
393
  }
@@ -430,7 +434,7 @@ const makeMessagesSocket = (config) => {
430
434
  tag: 'message',
431
435
  attrs: {
432
436
  id: msgId,
433
- type: getMessageType(message),
437
+ type: 'text',
434
438
  ...(additionalAttributes || {})
435
439
  },
436
440
  content: binaryNodeContent
@@ -470,12 +474,6 @@ const makeMessagesSocket = (config) => {
470
474
  });
471
475
  return msgId;
472
476
  };
473
- const getMessageType = (message) => {
474
- if (message.pollCreationMessage || message.pollCreationMessageV2 || message.pollCreationMessageV3) {
475
- return 'poll';
476
- }
477
- return 'text';
478
- };
479
477
  const getMediaType = (message) => {
480
478
  if (message.imageMessage) {
481
479
  return 'image';
@@ -569,11 +567,11 @@ const makeMessagesSocket = (config) => {
569
567
  const content = (0, Utils_1.assertMediaContent)(message.message);
570
568
  const mediaKey = content.mediaKey;
571
569
  const meId = authState.creds.me.id;
572
- const node = await (0, Utils_1.encryptMediaRetryRequest)(message.key, mediaKey, meId);
570
+ const node = (0, Utils_1.encryptMediaRetryRequest)(message.key, mediaKey, meId);
573
571
  let error = undefined;
574
572
  await Promise.all([
575
573
  sendNode(node),
576
- waitForMsgMediaUpdate(async (update) => {
574
+ waitForMsgMediaUpdate(update => {
577
575
  const result = update.find(c => c.key.id === message.key.id);
578
576
  if (result) {
579
577
  if (result.error) {
@@ -581,7 +579,7 @@ const makeMessagesSocket = (config) => {
581
579
  }
582
580
  else {
583
581
  try {
584
- const media = await (0, Utils_1.decryptMediaRetryData)(result.media, mediaKey, result.key.id);
582
+ const media = (0, Utils_1.decryptMediaRetryData)(result.media, mediaKey, result.key.id);
585
583
  if (media.result !== WAProto_1.proto.MediaRetryNotification.ResultType.SUCCESS) {
586
584
  const resultStr = WAProto_1.proto.MediaRetryNotification.ResultType[media.result];
587
585
  throw new boom_1.Boom(`Media re-upload failed by device (${resultStr})`, { data: media, statusCode: (0, Utils_1.getStatusCodeForMediaRetry)(media.result) || 404 });
@@ -645,9 +643,7 @@ const makeMessagesSocket = (config) => {
645
643
  const isDeleteMsg = 'delete' in content && !!content.delete;
646
644
  const isEditMsg = 'edit' in content && !!content.edit;
647
645
  const isPinMsg = 'pin' in content && !!content.pin;
648
- const isPollMessage = 'poll' in content && !!content.poll;
649
646
  const additionalAttributes = {};
650
- const additionalNodes = [];
651
647
  // required for delete
652
648
  if (isDeleteMsg) {
653
649
  // if the chat is a group, and I am not the author, then delete the message as an admin
@@ -664,18 +660,10 @@ const makeMessagesSocket = (config) => {
664
660
  else if (isPinMsg) {
665
661
  additionalAttributes.edit = '2';
666
662
  }
667
- else if (isPollMessage) {
668
- additionalNodes.push({
669
- tag: 'meta',
670
- attrs: {
671
- polltype: 'creation'
672
- },
673
- });
674
- }
675
663
  if ('cachedGroupMetadata' in options) {
676
664
  console.warn('cachedGroupMetadata in sendMessage are deprecated, now cachedGroupMetadata is part of the socket config.');
677
665
  }
678
- await relayMessage(jid, fullMsg.message, { messageId: fullMsg.key.id, useCachedGroupMetadata: options.useCachedGroupMetadata, additionalAttributes, statusJidList: options.statusJidList, additionalNodes });
666
+ await relayMessage(jid, fullMsg.message, { messageId: fullMsg.key.id, useCachedGroupMetadata: options.useCachedGroupMetadata, additionalAttributes, statusJidList: options.statusJidList });
679
667
  if (config.emitOwnEvents) {
680
668
  process.nextTick(() => {
681
669
  processingMutex.mutex(() => (upsertMessage(fullMsg, 'append')));
@@ -0,0 +1,242 @@
1
+ /// <reference types="long" />
2
+ /// <reference types="node" />
3
+ import { AxiosRequestConfig } from 'axios';
4
+ import { KeyPair, SignedKeyPair, SocketConfig } from '../Types';
5
+ export declare const makeRegistrationSocket: (config: SocketConfig) => {
6
+ register: (code: string) => Promise<ExistsResponse>;
7
+ requestRegistrationCode: (registrationOptions?: RegistrationOptions) => Promise<ExistsResponse>;
8
+ logger: import("pino").Logger<import("pino").LoggerOptions>;
9
+ getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
10
+ getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
11
+ products: import("../Types").Product[];
12
+ nextPageCursor: string | undefined;
13
+ }>;
14
+ getCollections: (jid?: string | undefined, limit?: number) => Promise<{
15
+ collections: import("../Types").CatalogCollection[];
16
+ }>;
17
+ productCreate: (create: import("../Types").ProductCreate) => Promise<import("../Types").Product>;
18
+ productDelete: (productIds: string[]) => Promise<{
19
+ deleted: number;
20
+ }>;
21
+ productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
22
+ sendMessageAck: ({ tag, attrs, content }: import("../WABinary").BinaryNode) => Promise<void>;
23
+ sendRetryRequest: (node: import("../WABinary").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
24
+ rejectCall: (callId: string, callFrom: string) => Promise<void>;
25
+ fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAProto.IMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>;
26
+ requestPlaceholderResend: (messageKey: import("../Types").WAProto.IMessageKey) => Promise<string | undefined>;
27
+ getPrivacyTokens: (jids: string[]) => Promise<import("../WABinary").BinaryNode>;
28
+ assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
29
+ relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
30
+ sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
31
+ sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
32
+ readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
33
+ refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
34
+ waUploadToServer: import("../Types").WAMediaUploadFunction;
35
+ fetchPrivacySettings: (force?: boolean) => Promise<{
36
+ [_: string]: string;
37
+ }>;
38
+ sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
39
+ createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
40
+ [key: string]: string;
41
+ } | undefined) => Promise<{
42
+ nodes: import("../WABinary").BinaryNode[];
43
+ shouldIncludeDeviceIdentity: boolean;
44
+ }>;
45
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
46
+ updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
47
+ sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
48
+ groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
49
+ groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
50
+ groupLeave: (id: string) => Promise<void>;
51
+ groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
52
+ groupRequestParticipantsList: (jid: string) => Promise<{
53
+ [key: string]: string;
54
+ }[]>;
55
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
56
+ status: string;
57
+ jid: string;
58
+ }[]>;
59
+ groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
60
+ status: string;
61
+ jid: string;
62
+ content: import("../WABinary").BinaryNode;
63
+ }[]>;
64
+ groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
65
+ groupInviteCode: (jid: string) => Promise<string | undefined>;
66
+ groupRevokeInvite: (jid: string) => Promise<string | undefined>;
67
+ groupAcceptInvite: (code: string) => Promise<string | undefined>;
68
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
69
+ groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
70
+ groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
71
+ groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
72
+ groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
73
+ groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
74
+ groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
75
+ groupFetchAllParticipating: () => Promise<{
76
+ [_: string]: import("../Types").GroupMetadata;
77
+ }>;
78
+ processingMutex: {
79
+ mutex<T>(code: () => T | Promise<T>): Promise<T>;
80
+ };
81
+ upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
82
+ appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
83
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
84
+ presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
85
+ profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
86
+ onWhatsApp: (...jids: string[]) => Promise<{
87
+ exists: boolean;
88
+ jid: string;
89
+ }[]>;
90
+ fetchBlocklist: () => Promise<string[]>;
91
+ fetchStatus: (jid: string) => Promise<{
92
+ status: string | undefined;
93
+ setAt: Date;
94
+ } | undefined>;
95
+ updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
96
+ removeProfilePicture: (jid: string) => Promise<void>;
97
+ updateProfileStatus: (status: string) => Promise<void>;
98
+ updateProfileName: (name: string) => Promise<void>;
99
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
100
+ updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
101
+ updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
102
+ updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
103
+ updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
104
+ updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
105
+ updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
106
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
107
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>;
108
+ getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
109
+ resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
110
+ chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
111
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
112
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
113
+ addChatLabel: (jid: string, labelId: string) => Promise<void>;
114
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>;
115
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
116
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
117
+ star: (jid: string, messages: {
118
+ id: string;
119
+ fromMe?: boolean | undefined;
120
+ }[], star: boolean) => Promise<void>;
121
+ type: "md";
122
+ ws: any;
123
+ ev: import("../Types").BaileysEventEmitter & {
124
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
125
+ buffer(): void;
126
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
127
+ flush(force?: boolean | undefined): boolean;
128
+ isBuffering(): boolean;
129
+ };
130
+ authState: {
131
+ creds: import("../Types").AuthenticationCreds;
132
+ keys: import("../Types").SignalKeyStoreWithTransaction;
133
+ };
134
+ signalRepository: import("../Types").SignalRepository;
135
+ user: import("../Types").Contact | undefined;
136
+ generateMessageTag: () => string;
137
+ query: (node: import("../WABinary").BinaryNode, timeoutMs?: number | undefined) => Promise<import("../WABinary").BinaryNode>;
138
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
139
+ waitForSocketOpen: () => Promise<void>;
140
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
141
+ sendNode: (frame: import("../WABinary").BinaryNode) => Promise<void>;
142
+ logout: (msg?: string | undefined) => Promise<void>;
143
+ end: (error: Error | undefined) => void;
144
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
145
+ uploadPreKeys: (count?: number) => Promise<void>;
146
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
147
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
148
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
149
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("../WABinary").BinaryNode>;
150
+ };
151
+ export interface RegistrationData {
152
+ registrationId: number;
153
+ signedPreKey: SignedKeyPair;
154
+ noiseKey: KeyPair;
155
+ signedIdentityKey: KeyPair;
156
+ identityId: Buffer;
157
+ phoneId: string;
158
+ deviceId: string;
159
+ backupToken: Buffer;
160
+ }
161
+ export interface RegistrationOptions {
162
+ /** your phone number */
163
+ phoneNumber?: string;
164
+ /** the country code of your phone number */
165
+ phoneNumberCountryCode: string;
166
+ /** your phone number without country code */
167
+ phoneNumberNationalNumber: string;
168
+ /** the country code of your mobile network
169
+ * @see {@link https://de.wikipedia.org/wiki/Mobile_Country_Code}
170
+ */
171
+ phoneNumberMobileCountryCode: string;
172
+ /** the network code of your mobile network
173
+ * @see {@link https://de.wikipedia.org/wiki/Mobile_Network_Code}
174
+ */
175
+ phoneNumberMobileNetworkCode: string;
176
+ /**
177
+ * How to send the one time code
178
+ */
179
+ method?: 'sms' | 'voice' | 'captcha';
180
+ /**
181
+ * The captcha code if it was requested
182
+ */
183
+ captcha?: string;
184
+ }
185
+ export type RegistrationParams = RegistrationData & RegistrationOptions;
186
+ export declare function registrationParams(params: RegistrationParams): {
187
+ cc: string;
188
+ in: string;
189
+ Rc: string;
190
+ lg: string;
191
+ lc: string;
192
+ mistyped: string;
193
+ authkey: string;
194
+ e_regid: string;
195
+ e_keytype: string;
196
+ e_ident: string;
197
+ e_skey_id: string;
198
+ e_skey_val: string;
199
+ e_skey_sig: string;
200
+ fdid: string;
201
+ network_ratio_type: string;
202
+ expid: string;
203
+ simnum: string;
204
+ hasinrc: string;
205
+ pid: string;
206
+ id: string;
207
+ backup_token: string;
208
+ token: string;
209
+ fraud_checkpoint_code: string | undefined;
210
+ };
211
+ /**
212
+ * Requests a registration code for the given phone number.
213
+ */
214
+ export declare function mobileRegisterCode(params: RegistrationParams, fetchOptions?: AxiosRequestConfig): Promise<ExistsResponse>;
215
+ export declare function mobileRegisterExists(params: RegistrationParams, fetchOptions?: AxiosRequestConfig): Promise<ExistsResponse>;
216
+ /**
217
+ * Registers the phone number on whatsapp with the received OTP code.
218
+ */
219
+ export declare function mobileRegister(params: RegistrationParams & {
220
+ code: string;
221
+ }, fetchOptions?: AxiosRequestConfig): Promise<ExistsResponse>;
222
+ /**
223
+ * Encrypts the given string as AEAD aes-256-gcm with the public whatsapp key and a random keypair.
224
+ */
225
+ export declare function mobileRegisterEncrypt(data: string): string;
226
+ export declare function mobileRegisterFetch(path: string, opts?: AxiosRequestConfig): Promise<ExistsResponse>;
227
+ export interface ExistsResponse {
228
+ status: 'fail' | 'sent';
229
+ voice_length?: number;
230
+ voice_wait?: number;
231
+ sms_length?: number;
232
+ sms_wait?: number;
233
+ reason?: 'incorrect' | 'missing_param' | 'code_checkpoint';
234
+ login?: string;
235
+ flash_type?: number;
236
+ ab_hash?: string;
237
+ ab_key?: string;
238
+ exp_cfg?: string;
239
+ lid?: string;
240
+ image_blob?: string;
241
+ audio_blob?: string;
242
+ }