@queenanya/baileys 8.2.7 → 8.3.2

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 (105) hide show
  1. package/WAProto/index.d.ts +1590 -6
  2. package/WAProto/index.js +4635 -3
  3. package/engine-requirements.js +1 -1
  4. package/lib/Defaults/baileys-version.json +1 -1
  5. package/lib/Defaults/index.d.ts +1 -1
  6. package/lib/Defaults/index.js +4 -5
  7. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  8. package/lib/Signal/Group/ciphertext-message.js +15 -0
  9. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  10. package/lib/Signal/Group/group-session-builder.js +64 -0
  11. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  12. package/lib/Signal/Group/group_cipher.js +96 -0
  13. package/lib/Signal/Group/index.d.ts +11 -0
  14. package/lib/Signal/Group/index.js +57 -0
  15. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  16. package/lib/Signal/Group/keyhelper.js +55 -0
  17. package/lib/Signal/Group/queue-job.d.ts +1 -0
  18. package/lib/Signal/Group/queue-job.js +57 -0
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  20. package/lib/Signal/Group/sender-chain-key.js +34 -0
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  22. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  24. package/lib/Signal/Group/sender-key-message.js +69 -0
  25. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  26. package/lib/Signal/Group/sender-key-name.js +51 -0
  27. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  28. package/lib/Signal/Group/sender-key-record.js +53 -0
  29. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  30. package/lib/Signal/Group/sender-key-state.js +99 -0
  31. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  32. package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
  33. package/lib/Signal/libsignal.js +33 -20
  34. package/lib/Socket/Client/types.d.ts +1 -0
  35. package/lib/Socket/Client/websocket.d.ts +1 -0
  36. package/lib/Socket/Client/websocket.js +11 -1
  37. package/lib/Socket/business.d.ts +5 -8
  38. package/lib/Socket/chats.d.ts +4 -8
  39. package/lib/Socket/chats.js +7 -87
  40. package/lib/Socket/groups.d.ts +4 -6
  41. package/lib/Socket/groups.js +13 -9
  42. package/lib/Socket/index.d.ts +5 -8
  43. package/lib/Socket/messages-recv.d.ts +5 -8
  44. package/lib/Socket/messages-recv.js +20 -25
  45. package/lib/Socket/messages-send.d.ts +5 -8
  46. package/lib/Socket/messages-send.js +116 -81
  47. package/lib/Socket/newsletter.d.ts +4 -6
  48. package/lib/Socket/newsletter.js +2 -4
  49. package/lib/Socket/socket.js +63 -1
  50. package/lib/Socket/usync.js +15 -10
  51. package/lib/Types/Chat.d.ts +2 -8
  52. package/lib/Types/Contact.d.ts +4 -5
  53. package/lib/Types/GroupMetadata.d.ts +4 -3
  54. package/lib/Types/Label.d.ts +0 -11
  55. package/lib/Types/Message.d.ts +15 -2
  56. package/lib/Types/Socket.d.ts +0 -2
  57. package/lib/Utils/chat-utils.d.ts +8 -8
  58. package/lib/Utils/chat-utils.js +4 -30
  59. package/lib/Utils/crypto.d.ts +1 -1
  60. package/lib/Utils/crypto.js +1 -3
  61. package/lib/Utils/decode-wa-message.d.ts +2 -4
  62. package/lib/Utils/decode-wa-message.js +18 -161
  63. package/lib/Utils/generics.d.ts +18 -8
  64. package/lib/Utils/generics.js +93 -7
  65. package/lib/Utils/history.js +1 -1
  66. package/lib/Utils/index.d.ts +1 -0
  67. package/lib/Utils/index.js +1 -0
  68. package/lib/Utils/messages-media.d.ts +9 -16
  69. package/lib/Utils/messages-media.js +186 -98
  70. package/lib/Utils/messages.d.ts +1 -1
  71. package/lib/Utils/messages.js +27 -17
  72. package/lib/Utils/use-single-file-auth-state.d.ts +5 -0
  73. package/lib/Utils/use-single-file-auth-state.js +66 -0
  74. package/lib/Utils/validate-connection.js +7 -7
  75. package/lib/WABinary/constants.d.ts +4 -4
  76. package/lib/WABinary/constants.js +1271 -8
  77. package/lib/WABinary/encode.js +5 -7
  78. package/lib/WABinary/jid-utils.d.ts +3 -3
  79. package/lib/WABinary/jid-utils.js +18 -18
  80. package/lib/WAM/constants.d.ts +2 -3
  81. package/lib/WAM/encode.js +2 -2
  82. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
  83. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -2
  84. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +3 -3
  85. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
  86. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
  87. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +1 -1
  88. package/lib/WAUSync/USyncQuery.js +13 -17
  89. package/package.json +10 -5
  90. package/WASignalGroup/GroupProtocol.js +0 -1697
  91. package/WASignalGroup/ciphertext_message.js +0 -16
  92. package/WASignalGroup/group_cipher.js +0 -120
  93. package/WASignalGroup/group_session_builder.js +0 -46
  94. package/WASignalGroup/index.js +0 -5
  95. package/WASignalGroup/keyhelper.js +0 -21
  96. package/WASignalGroup/protobufs.js +0 -3
  97. package/WASignalGroup/queue_job.js +0 -69
  98. package/WASignalGroup/sender_chain_key.js +0 -50
  99. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  100. package/WASignalGroup/sender_key_message.js +0 -92
  101. package/WASignalGroup/sender_key_name.js +0 -70
  102. package/WASignalGroup/sender_key_record.js +0 -56
  103. package/WASignalGroup/sender_key_state.js +0 -129
  104. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  105. package/lib/Store/make-cache-manager-store.js +0 -83
@@ -1,7 +1,6 @@
1
1
  import { Boom } from '@hapi/boom';
2
2
  import { proto } from '../../WAProto';
3
- import { BotListInfo, ChatModification, ContactAction, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
4
- import { LabelActionBody } from '../Types/Label';
3
+ import { BotListInfo, ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
5
4
  import { BinaryNode } from '../WABinary';
6
5
  import { USyncQuery } from '../WAUSync';
7
6
  export declare const makeChatsSocket: (config: SocketConfig) => {
@@ -26,8 +25,8 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
26
25
  fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
27
26
  fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
28
27
  updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
29
- updateProfilePictureFull: (jid: string, content: WAMediaUpload) => Promise<void>;
30
- updateProfilePictureFull2: (jid: string, content: WAMediaUpload) => Promise<void>;
28
+ updateProfilePictureFull: any;
29
+ updateProfilePictureFull2: any;
31
30
  removeProfilePicture: (jid: string) => Promise<void>;
32
31
  updateProfileStatus: (status: string) => Promise<void>;
33
32
  updateProfileName: (name: string) => Promise<void>;
@@ -42,12 +41,9 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
42
41
  updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>;
43
42
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
44
43
  getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>;
45
- resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
44
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
46
45
  chatModify: (mod: ChatModification, jid: string) => Promise<void>;
47
46
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
48
- addOrEditContact: (jid: string, contact: ContactAction) => Promise<void>;
49
- removeContact: (jid: string) => Promise<void>;
50
- addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
51
47
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
52
48
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
53
49
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -10,6 +10,7 @@ const WAProto_1 = require("../../WAProto");
10
10
  const Defaults_1 = require("../Defaults");
11
11
  const Types_1 = require("../Types");
12
12
  const Utils_1 = require("../Utils");
13
+ const chat_set_1 = require("./chat-set");
13
14
  const make_mutex_1 = require("../Utils/make-mutex");
14
15
  const process_message_1 = __importDefault(require("../Utils/process-message"));
15
16
  const WABinary_1 = require("../WABinary");
@@ -206,59 +207,6 @@ const makeChatsSocket = (config) => {
206
207
  ]
207
208
  });
208
209
  };
209
- /** update the profile picture for yourself or a group as Full */
210
- const updateProfilePictureFull = async (jid, content) => {
211
- let targetJid;
212
- if (!jid) {
213
- throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
214
- }
215
- if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
216
- targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
217
- }
218
- const { img } = await (0, Utils_1.generateProfilePictureFull)(content);
219
- await query({
220
- tag: 'iq',
221
- attrs: {
222
- target: targetJid,
223
- to: WABinary_1.S_WHATSAPP_NET,
224
- type: 'set',
225
- xmlns: 'w:profile:picture'
226
- },
227
- content: [
228
- {
229
- tag: 'picture',
230
- attrs: { type: 'image' },
231
- content: img
232
- }
233
- ]
234
- });
235
- };
236
- const updateProfilePictureFull2 = async (jid, content) => {
237
- let targetJid;
238
- if (!jid) {
239
- throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
240
- }
241
- if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
242
- targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
243
- }
244
- const { preview } = await (0, Utils_1.generateProfilePictureFP)(content);
245
- await query({
246
- tag: 'iq',
247
- attrs: {
248
- target: targetJid,
249
- to: WABinary_1.S_WHATSAPP_NET,
250
- type: 'set',
251
- xmlns: 'w:profile:picture'
252
- },
253
- content: [
254
- {
255
- tag: 'picture',
256
- attrs: { type: 'image' },
257
- content: preview
258
- }
259
- ]
260
- });
261
- };
262
210
  /** remove the profile picture for yourself or a group */
263
211
  const removeProfilePicture = async (jid) => {
264
212
  let targetJid;
@@ -543,16 +491,18 @@ const makeChatsSocket = (config) => {
543
491
  await sendNode({
544
492
  tag: 'presence',
545
493
  attrs: {
546
- name: me.name,
494
+ name: me.name.replace(/@/g, ''),
547
495
  type
548
496
  }
549
497
  });
550
498
  }
551
499
  else {
500
+ const { server } = (0, WABinary_1.jidDecode)(toJid);
501
+ const isLid = server === 'lid';
552
502
  await sendNode({
553
503
  tag: 'chatstate',
554
504
  attrs: {
555
- from: me.id,
505
+ from: isLid ? me.lid : me.id,
556
506
  to: toJid,
557
507
  },
558
508
  content: [
@@ -725,32 +675,6 @@ const makeChatsSocket = (config) => {
725
675
  }
726
676
  }, jid);
727
677
  };
728
- /**
729
- * Add or Edit Contact
730
- */
731
- const addOrEditContact = (jid, contact) => {
732
- return chatModify({
733
- contact
734
- }, jid);
735
- };
736
- /**
737
- * Remove Contact
738
- */
739
- const removeContact = (jid) => {
740
- return chatModify({
741
- contact: null
742
- }, jid);
743
- };
744
- /**
745
- * Adds label
746
- */
747
- const addLabel = (jid, labels) => {
748
- return chatModify({
749
- addLabel: {
750
- ...labels
751
- }
752
- }, jid);
753
- };
754
678
  /**
755
679
  * Adds label for the chats
756
680
  */
@@ -901,7 +825,6 @@ const makeChatsSocket = (config) => {
901
825
  if (receivedPendingNotifications && // if we don't have the app state key
902
826
  // we keep buffering events until we finally have
903
827
  // the key and can sync the messages
904
- // todo scrutinize
905
828
  !((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId)) {
906
829
  ev.buffer();
907
830
  needToFlushWithAppStateSync = true;
@@ -922,8 +845,8 @@ const makeChatsSocket = (config) => {
922
845
  fetchDisappearingDuration,
923
846
  fetchStatus,
924
847
  updateProfilePicture,
925
- updateProfilePictureFull,
926
- updateProfilePictureFull2,
848
+ updateProfilePictureFull: chat_set_1.updateProfilePictureFull,
849
+ updateProfilePictureFull2: chat_set_1.updateProfilePictureFull2,
927
850
  removeProfilePicture,
928
851
  updateProfileStatus,
929
852
  updateProfileName,
@@ -941,9 +864,6 @@ const makeChatsSocket = (config) => {
941
864
  resyncAppState,
942
865
  chatModify,
943
866
  cleanDirtyBits,
944
- addOrEditContact,
945
- removeContact,
946
- addLabel,
947
867
  addChatLabel,
948
868
  removeChatLabel,
949
869
  addMessageLabel,
@@ -2,6 +2,7 @@ import { proto } from '../../WAProto';
2
2
  import { GroupMetadata, ParticipantAction, SocketConfig, WAMessageKey } from '../Types';
3
3
  import { BinaryNode } from '../WABinary';
4
4
  export declare const makeGroupsSocket: (config: SocketConfig) => {
5
+ groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
5
6
  groupMetadata: (jid: string) => Promise<GroupMetadata>;
6
7
  groupCreate: (subject: string, participants: string[]) => Promise<GroupMetadata>;
7
8
  groupLeave: (id: string) => Promise<void>;
@@ -64,8 +65,8 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
64
65
  fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
65
66
  fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
66
67
  updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
67
- updateProfilePictureFull: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
68
- updateProfilePictureFull2: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
68
+ updateProfilePictureFull: any;
69
+ updateProfilePictureFull2: any;
69
70
  removeProfilePicture: (jid: string) => Promise<void>;
70
71
  updateProfileStatus: (status: string) => Promise<void>;
71
72
  updateProfileName: (name: string) => Promise<void>;
@@ -80,12 +81,9 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
80
81
  updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
81
82
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
82
83
  getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
83
- resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
84
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
84
85
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
85
86
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
86
- addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
87
- removeContact: (jid: string) => Promise<void>;
88
- addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
89
87
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
90
88
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
91
89
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -67,6 +67,7 @@ const makeGroupsSocket = (config) => {
67
67
  });
68
68
  return {
69
69
  ...sock,
70
+ groupQuery,
70
71
  groupMetadata,
71
72
  groupCreate: async (subject, participants) => {
72
73
  const key = (0, Utils_1.generateMessageIDV2)();
@@ -278,12 +279,14 @@ const extractGroupMetadata = (result) => {
278
279
  let desc;
279
280
  let descId;
280
281
  let descOwner;
281
- let descOwnerPn;
282
+ let descOwnerLid;
282
283
  let descTime;
283
284
  if (descChild) {
284
285
  desc = (0, WABinary_1.getBinaryNodeChildString)(descChild, 'body');
285
- descOwner = descChild.attrs.participant;
286
- descOwnerPn = descChild.attrs.participant_pn ? (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant_pn) : undefined;
286
+ descOwner = (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant_pn || descChild.attrs.participant);
287
+ if (group.attrs.addressing_mode === 'lid') {
288
+ descOwnerLid = (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant);
289
+ }
287
290
  descId = descChild.attrs.id;
288
291
  descTime = descChild.attrs.t ? +descChild.attrs.t : undefined;
289
292
  }
@@ -295,17 +298,17 @@ const extractGroupMetadata = (result) => {
295
298
  id: groupId,
296
299
  addressingMode: group.attrs.addressing_mode,
297
300
  subject: group.attrs.subject,
298
- subjectOwner: group.attrs.s_o,
299
- subjectOwnerPn: group.attrs.s_o_pn ? (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o_pn) : undefined,
301
+ subjectOwner: (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o_pn || group.attrs.s_o),
302
+ ...(group.attrs.addressing_mode === 'lid' ? { subjectOwnerLid: (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o) } : {}),
300
303
  subjectTime: group.attrs.s_t ? +group.attrs.s_t : undefined,
301
304
  size: groupSize || (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
302
305
  creation: group.attrs.creation ? +group.attrs.creation : undefined,
303
- owner: group.attrs.creator ? (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) : undefined,
304
- onwerPn: group.attrs.creator_pn ? (0, WABinary_1.jidNormalizedUser)(group.attrs.creator_pn) : undefined,
306
+ owner: (0, WABinary_1.jidNormalizedUser)(group.attrs.creator_pn || group.attrs.creator),
307
+ ...(group.attrs.addressing_mode === 'lid' ? { ownerLid: (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) } : {}),
305
308
  desc,
306
309
  descId,
307
310
  descOwner,
308
- descOwnerPn,
311
+ descOwnerLid,
309
312
  descTime,
310
313
  linkedParent: ((_b = (0, WABinary_1.getBinaryNodeChild)(group, 'linked_parent')) === null || _b === void 0 ? void 0 : _b.attrs.jid) || undefined,
311
314
  restrict: !!(0, WABinary_1.getBinaryNodeChild)(group, 'locked'),
@@ -316,7 +319,8 @@ const extractGroupMetadata = (result) => {
316
319
  memberAddMode,
317
320
  participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {
318
321
  return {
319
- id: attrs.phone_number || attrs.jid,
322
+ id: attrs.jid,
323
+ jid: attrs.phone_number || attrs.jid,
320
324
  lid: attrs.lid || attrs.jid,
321
325
  admin: (attrs.type || null),
322
326
  };
@@ -29,7 +29,6 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
29
29
  relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
30
30
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
31
31
  sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
32
- getButtonArgs: (message: import("../Types").WAProto.IMessage) => import("..").BinaryNode["attrs"];
33
32
  readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
34
33
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
35
34
  waUploadToServer: import("../Types").WAMediaUploadFunction;
@@ -43,7 +42,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
43
42
  }>;
44
43
  sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
45
44
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
46
- sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
45
+ sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo>;
47
46
  subscribeNewsletterUpdates: (jid: string) => Promise<{
48
47
  duration: string;
49
48
  }>;
@@ -65,6 +64,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
65
64
  newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
66
65
  newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
67
66
  newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
67
+ groupQuery: (jid: string, type: "get" | "set", content: import("..").BinaryNode[]) => Promise<any>;
68
68
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
69
69
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
70
70
  groupLeave: (id: string) => Promise<void>;
@@ -113,8 +113,8 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
113
113
  fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
114
114
  fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
115
115
  updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
116
- updateProfilePictureFull: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
117
- updateProfilePictureFull2: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
116
+ updateProfilePictureFull: any;
117
+ updateProfilePictureFull2: any;
118
118
  removeProfilePicture: (jid: string) => Promise<void>;
119
119
  updateProfileStatus: (status: string) => Promise<void>;
120
120
  updateProfileName: (name: string) => Promise<void>;
@@ -129,12 +129,9 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
129
129
  updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
130
130
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
131
131
  getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
132
- resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
132
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
133
133
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
134
134
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
135
- addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
136
- removeContact: (jid: string) => Promise<void>;
137
- addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
138
135
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
139
136
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
140
137
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -19,7 +19,6 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
19
19
  relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
20
20
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
21
21
  sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
22
- getButtonArgs: (message: proto.IMessage) => BinaryNode["attrs"];
23
22
  readMessages: (keys: WAMessageKey[]) => Promise<void>;
24
23
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
25
24
  waUploadToServer: import("../Types").WAMediaUploadFunction;
@@ -33,7 +32,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
33
32
  }>;
34
33
  sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
35
34
  updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
36
- sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
35
+ sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo>;
37
36
  subscribeNewsletterUpdates: (jid: string) => Promise<{
38
37
  duration: string;
39
38
  }>;
@@ -55,6 +54,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
55
54
  newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
56
55
  newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
57
56
  newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
57
+ groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
58
58
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
59
59
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
60
60
  groupLeave: (id: string) => Promise<void>;
@@ -103,8 +103,8 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
103
103
  fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
104
104
  fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
105
105
  updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
106
- updateProfilePictureFull: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
107
- updateProfilePictureFull2: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
106
+ updateProfilePictureFull: any;
107
+ updateProfilePictureFull2: any;
108
108
  removeProfilePicture: (jid: string) => Promise<void>;
109
109
  updateProfileStatus: (status: string) => Promise<void>;
110
110
  updateProfileName: (name: string) => Promise<void>;
@@ -119,12 +119,9 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
119
119
  updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
120
120
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
121
121
  getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
122
- resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
122
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
123
123
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
124
124
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
125
- addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
126
- removeContact: (jid: string) => Promise<void>;
127
- addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
128
125
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
129
126
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
130
127
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -16,9 +16,9 @@ const WABinary_1 = require("../WABinary");
16
16
  const groups_1 = require("./groups");
17
17
  const messages_send_1 = require("./messages-send");
18
18
  const makeMessagesRecvSocket = (config) => {
19
- const { logger, retryRequestDelayMs, maxMsgRetryCount, ignoreMsgLoading, getMessage, shouldIgnoreJid } = config;
19
+ const { logger, retryRequestDelayMs, maxMsgRetryCount, getMessage, shouldIgnoreJid } = config;
20
20
  const sock = (0, messages_send_1.makeMessagesSocket)(config);
21
- const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, createParticipantNodes, getUSyncDevices, sendPeerDataOperationMessage, } = sock;
21
+ const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, groupMetadata, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, createParticipantNodes, getUSyncDevices, sendPeerDataOperationMessage, } = sock;
22
22
  /** this mutex ensures that each retryRequest will wait for the previous one to finish */
23
23
  const retryMutex = (0, make_mutex_1.makeMutex)();
24
24
  const msgRetryCache = config.msgRetryCounterCache || new node_cache_1.default({
@@ -35,11 +35,6 @@ const makeMessagesRecvSocket = (config) => {
35
35
  });
36
36
  let sendActiveReceipts = false;
37
37
  const sendMessageAck = async ({ tag, attrs, content }, errorCode) => {
38
- // If ws not connected - logs it and return
39
- if (!ws.isOpen) {
40
- logger.warn({ attrs: attrs }, 'Client not connected, cannot send ack');
41
- return;
42
- }
43
38
  const stanza = {
44
39
  tag: 'ack',
45
40
  attrs: {
@@ -67,7 +62,6 @@ const makeMessagesRecvSocket = (config) => {
67
62
  await sendNode(stanza);
68
63
  };
69
64
  const offerCall = async (toJid, isVideo = false) => {
70
- const ToJidm = `${toJid}`;
71
65
  const callId = (0, crypto_1.randomBytes)(16).toString('hex').toUpperCase().substring(0, 64);
72
66
  const offerContent = [];
73
67
  offerContent.push({ tag: 'audio', attrs: { enc: 'opus', rate: '16000' }, content: undefined });
@@ -89,9 +83,7 @@ const makeMessagesRecvSocket = (config) => {
89
83
  offerContent.push({ tag: 'capability', attrs: { ver: '1' }, content: new Uint8Array([1, 4, 255, 131, 207, 4]) });
90
84
  offerContent.push({ tag: 'encopt', attrs: { keygen: '2' }, content: undefined });
91
85
  const encKey = (0, crypto_1.randomBytes)(32);
92
- const usrr = toJid.split('@')[0];
93
- const srvr = toJid.split('@')[1];
94
- const devices = (await getUSyncDevices([toJid], true, false)).map(({ user, device }) => toJid);
86
+ const devices = (await getUSyncDevices([toJid], true, false)).map(({ user, device }) => (0, WABinary_1.jidEncode)(user, 's.whatsapp.net', device));
95
87
  await assertSessions(devices, true);
96
88
  const { nodes: destinations, shouldIncludeDeviceIdentity } = await createParticipantNodes(devices, {
97
89
  call: {
@@ -192,7 +184,7 @@ const makeMessagesRecvSocket = (config) => {
192
184
  ]
193
185
  };
194
186
  if (node.attrs.recipient) {
195
- receipt.attrs.recipient = (0, WABinary_1.getBotJid)(node.attrs.recipient);
187
+ receipt.attrs.recipient = node.attrs.recipient;
196
188
  }
197
189
  if (node.attrs.participant) {
198
190
  receipt.attrs.participant = node.attrs.participant;
@@ -423,9 +415,6 @@ const makeMessagesRecvSocket = (config) => {
423
415
  case 'encrypt':
424
416
  await handleEncryptNotification(node);
425
417
  break;
426
- case 'newsletter':
427
- // TO DO
428
- break;
429
418
  case 'devices':
430
419
  const devices = (0, WABinary_1.getBinaryNodeChildren)(child, 'device');
431
420
  if ((0, WABinary_1.areJidsSameUser)(child.attrs.jid, authState.creds.me.id)) {
@@ -721,11 +710,6 @@ const makeMessagesRecvSocket = (config) => {
721
710
  };
722
711
  const handleMessage = async (node) => {
723
712
  var _a, _b, _c;
724
- if (ignoreMsgLoading && node.attrs.offline) {
725
- logger.debug({ key: node.attrs.key }, 'ignored offline message');
726
- await sendMessageAck(node);
727
- return;
728
- }
729
713
  if (shouldIgnoreJid(node.attrs.from) && node.attrs.from !== '@s.whatsapp.net') {
730
714
  logger.debug({ key: node.attrs.key }, 'ignored message');
731
715
  await sendMessageAck(node);
@@ -753,7 +737,7 @@ const makeMessagesRecvSocket = (config) => {
753
737
  placeholderResendCache.del(node.attrs.id);
754
738
  }
755
739
  }
756
- const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger, getMessage);
740
+ const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger);
757
741
  if (response && ((_a = msg === null || msg === void 0 ? void 0 : msg.messageStubParameters) === null || _a === void 0 ? void 0 : _a[0]) === Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT) {
758
742
  msg.messageStubParameters = [Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT, response];
759
743
  }
@@ -763,7 +747,7 @@ const makeMessagesRecvSocket = (config) => {
763
747
  try {
764
748
  await Promise.all([
765
749
  processingMutex.mutex(async () => {
766
- var _a, _b, _c;
750
+ var _a, _b, _c, _d, _e, _f;
767
751
  await decrypt();
768
752
  // message failed to decrypt
769
753
  if (msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT) {
@@ -789,6 +773,20 @@ const makeMessagesRecvSocket = (config) => {
789
773
  else {
790
774
  // no type in the receipt => message delivered
791
775
  let type = undefined;
776
+ if ((_b = msg.key.participant) === null || _b === void 0 ? void 0 : _b.endsWith('@lid')) {
777
+ msg.key.participant = node.attrs.participant_pn || authState.creds.me.id;
778
+ }
779
+ if ((0, WABinary_1.isJidGroup)(msg.key.remoteJid) && ((_f = (_e = (_d = (_c = msg.message) === null || _c === void 0 ? void 0 : _c.extendedTextMessage) === null || _d === void 0 ? void 0 : _d.contextInfo) === null || _e === void 0 ? void 0 : _e.participant) === null || _f === void 0 ? void 0 : _f.endsWith('@lid'))) {
780
+ if (msg.message.extendedTextMessage.contextInfo) {
781
+ const metadata = await groupMetadata(msg.key.remoteJid);
782
+ const sender = msg.message.extendedTextMessage.contextInfo.participant;
783
+ const found = metadata.participants.find(p => p.id === sender);
784
+ msg.message.extendedTextMessage.contextInfo.participant = (found === null || found === void 0 ? void 0 : found.jid) || sender;
785
+ }
786
+ }
787
+ if (!(0, WABinary_1.isJidGroup)(msg.key.remoteJid) && (0, WABinary_1.isLidUser)(msg.key.remoteJid)) {
788
+ msg.key.remoteJid = node.attrs.sender_pn || node.attrs.peer_recipient_pn;
789
+ }
792
790
  let participant = msg.key.participant;
793
791
  if (category === 'peer') { // special peer message
794
792
  type = 'peer_msg';
@@ -811,9 +809,6 @@ const makeMessagesRecvSocket = (config) => {
811
809
  await sendReceipt(jid, undefined, [msg.key.id], 'hist_sync');
812
810
  }
813
811
  }
814
- if (((_b = node.attrs) === null || _b === void 0 ? void 0 : _b.addressing_mode) === 'lid' && ((_c = node.attrs) === null || _c === void 0 ? void 0 : _c.participant_pn)) {
815
- msg.key.participant = (0, WABinary_1.jidNormalizedUser)(node.attrs.participant_pn);
816
- }
817
812
  (0, Utils_1.cleanMessage)(msg, authState.creds.me.id);
818
813
  await sendMessageAck(node);
819
814
  await upsertMessage(msg, node.attrs.offline ? 'append' : 'notify');
@@ -9,7 +9,6 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
9
9
  relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
10
10
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
11
11
  sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
12
- getButtonArgs: (message: proto.IMessage) => BinaryNode["attrs"];
13
12
  readMessages: (keys: WAMessageKey[]) => Promise<void>;
14
13
  refreshMediaConn: (forceGet?: boolean) => Promise<MediaConnInfo>;
15
14
  waUploadToServer: import("../Types").WAMediaUploadFunction;
@@ -23,7 +22,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
23
22
  }>;
24
23
  sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
25
24
  updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
26
- sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
25
+ sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo>;
27
26
  subscribeNewsletterUpdates: (jid: string) => Promise<{
28
27
  duration: string;
29
28
  }>;
@@ -45,6 +44,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
45
44
  newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
46
45
  newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
47
46
  newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
47
+ groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
48
48
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
49
49
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
50
50
  groupLeave: (id: string) => Promise<void>;
@@ -93,8 +93,8 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
93
93
  fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
94
94
  fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
95
95
  updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
96
- updateProfilePictureFull: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
97
- updateProfilePictureFull2: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
96
+ updateProfilePictureFull: any;
97
+ updateProfilePictureFull2: any;
98
98
  removeProfilePicture: (jid: string) => Promise<void>;
99
99
  updateProfileStatus: (status: string) => Promise<void>;
100
100
  updateProfileName: (name: string) => Promise<void>;
@@ -109,12 +109,9 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
109
109
  updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
110
110
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
111
111
  getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
112
- resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
112
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
113
113
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
114
114
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
115
- addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
116
- removeContact: (jid: string) => Promise<void>;
117
- addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
118
115
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
119
116
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
120
117
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;