angularsockets 1.0.1 → 1.0.3

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 (131) hide show
  1. package/README.md +1880 -36
  2. package/WAProto/index.d.ts +50383 -0
  3. package/WAProto/index.js +37203 -11791
  4. package/WASignalGroup/GroupProtocol.js +1697 -0
  5. package/WASignalGroup/ciphertext_message.js +16 -0
  6. package/WASignalGroup/group_cipher.js +120 -0
  7. package/WASignalGroup/group_session_builder.js +46 -0
  8. package/WASignalGroup/index.js +5 -0
  9. package/WASignalGroup/keyhelper.js +21 -0
  10. package/WASignalGroup/protobufs.js +3 -0
  11. package/WASignalGroup/queue_job.js +69 -0
  12. package/WASignalGroup/sender_chain_key.js +50 -0
  13. package/WASignalGroup/sender_key_distribution_message.js +78 -0
  14. package/WASignalGroup/sender_key_message.js +92 -0
  15. package/WASignalGroup/sender_key_name.js +70 -0
  16. package/WASignalGroup/sender_key_record.js +56 -0
  17. package/WASignalGroup/sender_key_state.js +129 -0
  18. package/{lib/Signal/Group/sender-message-key.js → WASignalGroup/sender_message_key.js} +16 -6
  19. package/lib/Defaults/baileys-version.json +1 -1
  20. package/lib/Defaults/index.js +79 -101
  21. package/lib/Signal/libsignal.js +29 -51
  22. package/lib/Socket/Client/web-socket-client.js +0 -2
  23. package/lib/Socket/business.d.ts +42 -43
  24. package/lib/Socket/chats.d.ts +9 -8
  25. package/lib/Socket/chats.js +107 -21
  26. package/lib/Socket/groups.d.ts +7 -7
  27. package/lib/Socket/groups.js +24 -25
  28. package/lib/Socket/index.d.ts +51 -52
  29. package/lib/Socket/messages-recv.d.ts +34 -37
  30. package/lib/Socket/messages-recv.js +37 -175
  31. package/lib/Socket/messages-send.d.ts +16 -10
  32. package/lib/Socket/messages-send.js +540 -346
  33. package/lib/Socket/newsletter.d.ts +26 -28
  34. package/lib/Socket/newsletter.js +4 -4
  35. package/lib/Socket/registration.d.ts +49 -52
  36. package/lib/Socket/registration.js +7 -7
  37. package/lib/Socket/socket.d.ts +1 -0
  38. package/lib/Socket/socket.js +36 -23
  39. package/lib/Socket/usync.d.ts +11 -10
  40. package/lib/Store/make-cache-manager-store.d.ts +2 -1
  41. package/lib/Store/make-in-memory-store.d.ts +2 -2
  42. package/lib/Store/make-in-memory-store.js +5 -1
  43. package/lib/Store/make-ordered-dictionary.js +2 -2
  44. package/lib/Types/Auth.d.ts +0 -1
  45. package/lib/Types/Call.d.ts +1 -1
  46. package/lib/Types/Chat.d.ts +12 -7
  47. package/lib/Types/Events.d.ts +17 -2
  48. package/lib/Types/GroupMetadata.d.ts +3 -2
  49. package/lib/Types/Label.d.ts +11 -0
  50. package/lib/Types/Label.js +1 -1
  51. package/lib/Types/LabelAssociation.js +1 -1
  52. package/lib/Types/Message.d.ts +170 -10
  53. package/lib/Types/Newsletter.js +3 -3
  54. package/lib/Types/Socket.d.ts +7 -2
  55. package/lib/Types/index.d.ts +9 -0
  56. package/lib/Types/index.js +1 -1
  57. package/lib/Utils/auth-utils.js +35 -14
  58. package/lib/Utils/business.d.ts +1 -1
  59. package/lib/Utils/business.js +2 -2
  60. package/lib/Utils/chat-utils.d.ts +11 -12
  61. package/lib/Utils/chat-utils.js +52 -36
  62. package/lib/Utils/crypto.d.ts +15 -16
  63. package/lib/Utils/crypto.js +74 -26
  64. package/lib/Utils/decode-wa-message.d.ts +17 -0
  65. package/lib/Utils/decode-wa-message.js +53 -17
  66. package/lib/Utils/event-buffer.js +10 -7
  67. package/lib/Utils/generics.d.ts +13 -17
  68. package/lib/Utils/generics.js +26 -15
  69. package/lib/Utils/history.d.ts +6 -2
  70. package/lib/Utils/history.js +4 -6
  71. package/lib/Utils/logger.d.ts +1 -3
  72. package/lib/Utils/lt-hash.js +12 -12
  73. package/lib/Utils/make-mutex.d.ts +2 -2
  74. package/lib/Utils/messages-media.d.ts +25 -28
  75. package/lib/Utils/messages-media.js +47 -57
  76. package/lib/Utils/messages.js +461 -44
  77. package/lib/Utils/noise-handler.d.ts +4 -5
  78. package/lib/Utils/noise-handler.js +19 -14
  79. package/lib/Utils/process-message.d.ts +5 -5
  80. package/lib/Utils/process-message.js +75 -23
  81. package/lib/Utils/signal.d.ts +2 -1
  82. package/lib/Utils/signal.js +43 -35
  83. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -1
  84. package/lib/Utils/use-multi-file-auth-state.js +251 -36
  85. package/lib/Utils/use-single-file-auth-state.d.ts +12 -0
  86. package/lib/Utils/use-single-file-auth-state.js +75 -0
  87. package/lib/Utils/validate-connection.d.ts +1 -1
  88. package/lib/Utils/validate-connection.js +1 -1
  89. package/lib/WABinary/decode.d.ts +1 -2
  90. package/lib/WABinary/decode.js +23 -11
  91. package/lib/WABinary/encode.d.ts +1 -2
  92. package/lib/WABinary/encode.js +46 -22
  93. package/lib/WABinary/generic-utils.d.ts +2 -4
  94. package/lib/WABinary/generic-utils.js +2 -10
  95. package/lib/WABinary/jid-utils.d.ts +1 -1
  96. package/lib/WAM/BinaryInfo.d.ts +2 -11
  97. package/lib/WAM/encode.d.ts +1 -2
  98. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
  99. package/lib/WAUSync/USyncUser.d.ts +0 -2
  100. package/lib/index.js +0 -6
  101. package/package.json +96 -104
  102. package/engine-requirements.js +0 -10
  103. package/lib/Defaults/phonenumber-mcc.json +0 -223
  104. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  105. package/lib/Signal/Group/ciphertext-message.js +0 -15
  106. package/lib/Signal/Group/group-session-builder.d.ts +0 -14
  107. package/lib/Signal/Group/group-session-builder.js +0 -64
  108. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  109. package/lib/Signal/Group/group_cipher.js +0 -96
  110. package/lib/Signal/Group/index.d.ts +0 -11
  111. package/lib/Signal/Group/index.js +0 -57
  112. package/lib/Signal/Group/keyhelper.d.ts +0 -10
  113. package/lib/Signal/Group/keyhelper.js +0 -55
  114. package/lib/Signal/Group/queue-job.d.ts +0 -1
  115. package/lib/Signal/Group/queue-job.js +0 -57
  116. package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
  117. package/lib/Signal/Group/sender-chain-key.js +0 -34
  118. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
  119. package/lib/Signal/Group/sender-key-distribution-message.js +0 -66
  120. package/lib/Signal/Group/sender-key-message.d.ts +0 -18
  121. package/lib/Signal/Group/sender-key-message.js +0 -69
  122. package/lib/Signal/Group/sender-key-name.d.ts +0 -17
  123. package/lib/Signal/Group/sender-key-name.js +0 -51
  124. package/lib/Signal/Group/sender-key-record.d.ts +0 -30
  125. package/lib/Signal/Group/sender-key-record.js +0 -53
  126. package/lib/Signal/Group/sender-key-state.d.ts +0 -38
  127. package/lib/Signal/Group/sender-key-state.js +0 -99
  128. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  129. package/lib/Socket/dugong.d.ts +0 -175
  130. package/lib/Socket/dugong.js +0 -342
  131. package/lib/index.d.ts +0 -12
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.makeMessagesRecvSocket = void 0;
7
7
  const boom_1 = require("@hapi/boom");
8
8
  const crypto_1 = require("crypto");
9
- const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
9
+ const node_cache_1 = __importDefault(require("node-cache"));
10
10
  const WAProto_1 = require("../../WAProto");
11
11
  const Defaults_1 = require("../Defaults");
12
12
  const Types_1 = require("../Types");
@@ -16,34 +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 {
20
- logger,
21
- retryRequestDelayMs,
22
- maxMsgRetryCount,
23
- getMessage,
24
- shouldIgnoreJid
25
- } = config;
19
+ const { logger, retryRequestDelayMs, maxMsgRetryCount, getMessage, shouldIgnoreJid } = config;
26
20
  const sock = (0, messages_send_1.makeMessagesSocket)(config);
27
- const {
28
- ev,
29
- authState,
30
- ws,
31
- processingMutex,
32
- signalRepository,
33
- query,
34
- upsertMessage,
35
- resyncAppState,
36
- groupMetadata,
37
- onUnexpectedError,
38
- assertSessions,
39
- sendNode,
40
- relayMessage,
41
- sendReceipt,
42
- uploadPreKeys,
43
- createParticipantNodes,
44
- getUSyncDevices,
45
- sendPeerDataOperationMessage
46
- } = sock;
21
+ const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, getUSyncDevices, sendPeerDataOperationMessage, createParticipantNodes } = sock;
47
22
  /** this mutex ensures that each retryRequest will wait for the previous one to finish */
48
23
  const retryMutex = (0, make_mutex_1.makeMutex)();
49
24
  const msgRetryCache = config.msgRetryCounterCache || new node_cache_1.default({
@@ -67,7 +42,7 @@ const makeMessagesRecvSocket = (config) => {
67
42
  to: attrs.from,
68
43
  class: tag
69
44
  }
70
- }
45
+ };
71
46
  if (!!errorCode) {
72
47
  stanza.attrs.error = errorCode.toString();
73
48
  }
@@ -83,69 +58,32 @@ const makeMessagesRecvSocket = (config) => {
83
58
  if (tag === 'message' && (0, WABinary_1.getBinaryNodeChild)({ tag, attrs, content }, 'unavailable')) {
84
59
  stanza.attrs.from = authState.creds.me.id;
85
60
  }
86
- logger.debug({
87
- recv: {
88
- tag,
89
- attrs
90
- },
91
- sent: stanza.attrs }, 'sent ack');
61
+ logger.debug({ recv: { tag, attrs }, sent: stanza.attrs }, 'sent ack');
92
62
  await sendNode(stanza);
93
63
  };
94
64
  const offerCall = async (toJid, isVideo = false) => {
95
65
  const callId = (0, crypto_1.randomBytes)(16).toString('hex').toUpperCase().substring(0, 64);
96
66
  const offerContent = [];
97
- offerContent.push({
98
- tag: 'audio',
99
- attrs: {
100
- enc: 'opus',
101
- rate: '16000'
102
- }, content: undefined
103
- });
104
- offerContent.push({
105
- tag: 'audio',
106
- attrs: {
107
- enc: 'opus',
108
- rate: '8000'
109
- }, content: undefined
110
- });
67
+ offerContent.push({ tag: 'audio', attrs: { enc: 'opus', rate: '16000' }, content: undefined });
68
+ offerContent.push({ tag: 'audio', attrs: { enc: 'opus', rate: '8000' }, content: undefined });
111
69
  if (isVideo) {
112
70
  offerContent.push({
113
71
  tag: 'video',
114
- attrs: {
115
- orientation: '0',
116
- 'screen_width': '1920',
117
- 'screen_height': '1080',
118
- 'device_orientation': '0',
119
- enc: 'vp8',
120
- dec: 'vp8',
121
- }
72
+ attrs: { enc: 'vp8', dec: 'vp8', orientation: '0', 'screen_width': '1920', 'screen_height': '1080', 'device_orientation': '0' },
73
+ content: undefined
122
74
  });
123
75
  }
124
- offerContent.push({
125
- tag: 'net',
126
- attrs: {
127
- medium: '3'
128
- }, content: undefined
129
- });
130
- offerContent.push({
131
- tag: 'capability',
132
- attrs: {
133
- ver: '1'
134
- }, content: new Uint8Array([1, 4, 255, 131, 207, 4]) });
135
- offerContent.push({
136
- tag: 'encopt',
137
- attrs: {
138
- keygen: '2'
139
- }, content: undefined
140
- })
76
+ offerContent.push({ tag: 'net', attrs: { medium: '3' }, content: undefined });
77
+ offerContent.push({ tag: 'capability', attrs: { ver: '1' }, content: new Uint8Array([1, 4, 255, 131, 207, 4]) });
78
+ offerContent.push({ tag: 'encopt', attrs: { keygen: '2' }, content: undefined });
141
79
  const encKey = (0, crypto_1.randomBytes)(32);
142
80
  const devices = (await getUSyncDevices([toJid], true, false)).map(({ user, device }) => (0, WABinary_1.jidEncode)(user, 's.whatsapp.net', device));
143
81
  await assertSessions(devices, true);
144
82
  const { nodes: destinations, shouldIncludeDeviceIdentity } = await createParticipantNodes(devices, {
145
83
  call: {
146
- callKey: encKey
84
+ callKey: new Uint8Array(encKey)
147
85
  }
148
- });
86
+ }, { count: '0' });
149
87
  offerContent.push({ tag: 'destination', attrs: {}, content: destinations });
150
88
  if (shouldIncludeDeviceIdentity) {
151
89
  offerContent.push({
@@ -157,6 +95,7 @@ const makeMessagesRecvSocket = (config) => {
157
95
  const stanza = ({
158
96
  tag: 'call',
159
97
  attrs: {
98
+ id: await config.generateMessageIDV2() ?? (0, Utils_1.generateMessageIDV2)(),
160
99
  to: toJid,
161
100
  },
162
101
  content: [{
@@ -170,9 +109,8 @@ const makeMessagesRecvSocket = (config) => {
170
109
  });
171
110
  await query(stanza);
172
111
  return {
173
- callId,
174
- toJid,
175
- isVideo,
112
+ id: callId,
113
+ to: toJid
176
114
  };
177
115
  };
178
116
  const rejectCall = async (callId, callFrom) => {
@@ -386,57 +324,10 @@ const makeMessagesRecvSocket = (config) => {
386
324
  msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD;
387
325
  msg.messageStubParameters = [participantJid, isDenied ? 'revoked' : 'rejected'];
388
326
  break;
389
- break;
390
- default:
391
- // console.log("BAILEYS-DEBUG:", JSON.stringify({ ...child, content: Buffer.isBuffer(child.content) ? child.content.toString() : child.content, participant }, null, 2))
392
- }
393
- };
394
- const handleNewsletterNotification = (id, node) => {
395
- const messages = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
396
- const message = (0, WABinary_1.getBinaryNodeChild)(messages, 'message');
397
- const serverId = message.attrs.server_id;
398
- const reactionsList = (0, WABinary_1.getBinaryNodeChild)(message, 'reactions');
399
- const viewsList = (0, WABinary_1.getBinaryNodeChildren)(message, 'views_count');
400
- if (reactionsList) {
401
- const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionsList, 'reaction');
402
- if (reactions.length === 0) {
403
- ev.emit('newsletter.reaction', { id, 'server_id': serverId, reaction: { removed: true } });
404
- }
405
- reactions.forEach(item => {
406
- var _a, _b;
407
- ev.emit('newsletter.reaction', { id, 'server_id': serverId, reaction: { code: (_a = item.attrs) === null || _a === void 0 ? void 0 : _a.code, count: +((_b = item.attrs) === null || _b === void 0 ? void 0 : _b.count) } });
408
- });
409
- }
410
- if (viewsList.length) {
411
- viewsList.forEach(item => {
412
- ev.emit('newsletter.view', { id, 'server_id': serverId, count: +item.attrs.count });
413
- });
414
- }
415
- };
416
- const handleMexNewsletterNotification = (id, node) => {
417
- var _a;
418
- const operation = node === null || node === void 0 ? void 0 : node.attrs.op_name;
419
- const content = JSON.parse((_a = node === null || node === void 0 ? void 0 : node.content) === null || _a === void 0 ? void 0 : _a.toString());
420
- let contentPath;
421
- if (operation === Types_1.MexOperations.PROMOTE || operation === Types_1.MexOperations.DEMOTE) {
422
- let action;
423
- if (operation === Types_1.MexOperations.PROMOTE) {
424
- action = 'promote';
425
- contentPath = content.data[Types_1.XWAPaths.PROMOTE];
426
- }
427
- if (operation === Types_1.MexOperations.DEMOTE) {
428
- action = 'demote';
429
- contentPath = content.data[Types_1.XWAPaths.DEMOTE];
430
- }
431
- ev.emit('newsletter-participants.update', { id, author: contentPath.actor.pn, user: contentPath.user.pn, new_role: contentPath.user_new_role, action });
432
- }
433
- if (operation === Types_1.MexOperations.UPDATE) {
434
- contentPath = content.data[Types_1.XWAPaths.METADATA_UPDATE];
435
- ev.emit('newsletter-settings.update', { id, update: contentPath.thread_metadata.settings });
436
327
  }
437
328
  };
438
329
  const processNotification = async (node) => {
439
- var _a, _b;
330
+ var _a, _b, _c;
440
331
  const result = {};
441
332
  const [child] = (0, WABinary_1.getAllBinaryNodeChildren)(node);
442
333
  const nodeType = node.attrs.type;
@@ -455,12 +346,6 @@ const makeMessagesRecvSocket = (config) => {
455
346
  logger.debug({ jid }, 'got privacy token update');
456
347
  }
457
348
  break;
458
- case 'newsletter':
459
- handleNewsletterNotification(node.attrs.from, child);
460
- break;
461
- case 'mex':
462
- handleMexNewsletterNotification(node.attrs.from, child);
463
- break;
464
349
  case 'w:gp2':
465
350
  handleGroupNotification(node.attrs.participant, child, result);
466
351
  break;
@@ -489,7 +374,7 @@ const makeMessagesRecvSocket = (config) => {
489
374
  const setPicture = (0, WABinary_1.getBinaryNodeChild)(node, 'set');
490
375
  const delPicture = (0, WABinary_1.getBinaryNodeChild)(node, 'delete');
491
376
  ev.emit('contacts.update', [{
492
- id: from || ((_b = (_a = (setPicture || delPicture)) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.hash) || '',
377
+ id: (0, WABinary_1.jidNormalizedUser)((_a = node === null || node === void 0 ? void 0 : node.attrs) === null || _a === void 0 ? void 0 : _a.from) || ((_c = (_b = (setPicture || delPicture)) === null || _b === void 0 ? void 0 : _b.attrs) === null || _c === void 0 ? void 0 : _c.hash) || '',
493
378
  imgUrl: setPicture ? 'changed' : 'removed'
494
379
  }]);
495
380
  if ((0, WABinary_1.isJidGroup)(from)) {
@@ -617,7 +502,6 @@ const makeMessagesRecvSocket = (config) => {
617
502
  };
618
503
  const sendMessagesAgain = async (key, ids, retryNode) => {
619
504
  var _a;
620
- // todo: implement a cache to store the last 256 sent messages (copy whatsmeow)
621
505
  const msgs = await Promise.all(ids.map(id => getMessage({ ...key, id })));
622
506
  const remoteJid = key.remoteJid;
623
507
  const participant = key.participant || remoteJid;
@@ -656,7 +540,7 @@ const makeMessagesRecvSocket = (config) => {
656
540
  const isLid = attrs.from.includes('lid');
657
541
  const isNodeFromMe = (0, WABinary_1.areJidsSameUser)(attrs.participant || attrs.from, isLid ? (_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.lid : (_b = authState.creds.me) === null || _b === void 0 ? void 0 : _b.id);
658
542
  const remoteJid = !isNodeFromMe || (0, WABinary_1.isJidGroup)(attrs.from) ? attrs.from : attrs.recipient;
659
- const fromMe = !attrs.recipient || ((attrs.type === 'retry' || attrs.type === 'sender') && isNodeFromMe);
543
+ const fromMe = !attrs.recipient || (attrs.type === 'retry' && isNodeFromMe);
660
544
  const key = {
661
545
  remoteJid,
662
546
  id: '',
@@ -681,7 +565,7 @@ const makeMessagesRecvSocket = (config) => {
681
565
  (
682
566
  // basically, we only want to know when a message from us has been delivered to/read by the other person
683
567
  // or another device of ours has read some messages
684
- status >= WAProto_1.proto.WebMessageInfo.Status.SERVER_ACK ||
568
+ status >= WAProto_1.proto.WebMessageInfo.Status.DELIVERY_ACK ||
685
569
  !isNodeFromMe)) {
686
570
  if ((0, WABinary_1.isJidGroup)(remoteJid) || (0, WABinary_1.isJidStatusBroadcast)(remoteJid)) {
687
571
  if (attrs.participant) {
@@ -803,7 +687,7 @@ const makeMessagesRecvSocket = (config) => {
803
687
  try {
804
688
  await Promise.all([
805
689
  processingMutex.mutex(async () => {
806
- var _a, _b, _c, _d, _e, _f;
690
+ var _a;
807
691
  await decrypt();
808
692
  // message failed to decrypt
809
693
  if (msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT) {
@@ -829,20 +713,6 @@ const makeMessagesRecvSocket = (config) => {
829
713
  else {
830
714
  // no type in the receipt => message delivered
831
715
  let type = undefined;
832
- if ((_b = msg.key.participant) === null || _b === void 0 ? void 0 : _b.endsWith('@lid')) {
833
- msg.key.participant = node.attrs.participant_pn || authState.creds.me.id;
834
- }
835
- 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'))) {
836
- if (msg.message.extendedTextMessage.contextInfo) {
837
- const metadata = await groupMetadata(msg.key.remoteJid);
838
- const sender = msg.message.extendedTextMessage.contextInfo.participant;
839
- const found = metadata.participants.find(p => p.id === sender);
840
- msg.message.extendedTextMessage.contextInfo.participant = (found === null || found === void 0 ? void 0 : found.jid) || sender;
841
- }
842
- }
843
- if (!(0, WABinary_1.isJidGroup)(msg.key.remoteJid) && (0, WABinary_1.isLidUser)(msg.key.remoteJid)) {
844
- msg.key.remoteJid = node.attrs.sender_pn || node.attrs.peer_recipient_pn;
845
- }
846
716
  let participant = msg.key.participant;
847
717
  if (category === 'peer') { // special peer message
848
718
  type = 'peer_msg';
@@ -957,28 +827,20 @@ const makeMessagesRecvSocket = (config) => {
957
827
  await sendMessageAck(node);
958
828
  };
959
829
  const handleBadAck = async ({ attrs }) => {
960
- const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id, 'server_id': attrs === null || attrs === void 0 ? void 0 : attrs.server_id };
961
- // current hypothesis is that if pash is sent in the ack
962
- // it means -- the message hasn't reached all devices yet
963
- // we'll retry sending the message here
964
- if (attrs.phash) {
965
- logger.info({ attrs }, 'received phash in ack, resending message...');
966
- const cacheKey = `${key.remoteJid}:${key.id}`;
967
- if ((msgRetryCache.get(cacheKey) || 0) >= maxMsgRetryCount) {
968
- logger.warn({ attrs }, 'reached max retry count, not sending message again');
969
- msgRetryCache.del(cacheKey);
970
- return;
971
- }
972
- const retryCount = msgRetryCache.get(cacheKey) || 0;
973
- const msg = await getMessage(key);
974
- if (msg) {
975
- await relayMessage(key.remoteJid, msg, { messageId: key.id, useUserDevicesCache: false });
976
- msgRetryCache.set(cacheKey, retryCount + 1);
977
- }
978
- else {
979
- logger.warn({ attrs }, 'could not send message again, as it was not found');
980
- }
981
- }
830
+ const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id };
831
+ // WARNING: REFRAIN FROM ENABLING THIS FOR NOW. IT WILL CAUSE A LOOP
832
+ // // current hypothesis is that if pash is sent in the ack
833
+ // // it means -- the message hasn't reached all devices yet
834
+ // // we'll retry sending the message here
835
+ // if(attrs.phash) {
836
+ // logger.info({ attrs }, 'received phash in ack, resending message...')
837
+ // const msg = await getMessage(key)
838
+ // if(msg) {
839
+ // await relayMessage(key.remoteJid!, msg, { messageId: key.id!, useUserDevicesCache: false })
840
+ // } else {
841
+ // logger.warn({ attrs }, 'could not send message again, as it was not found')
842
+ // }
843
+ // }
982
844
  // error in acknowledgement,
983
845
  // device could not display the message
984
846
  if (attrs.error) {
@@ -1101,8 +963,8 @@ const makeMessagesRecvSocket = (config) => {
1101
963
  ...sock,
1102
964
  sendMessageAck,
1103
965
  sendRetryRequest,
1104
- rejectCall,
1105
966
  offerCall,
967
+ rejectCall,
1106
968
  fetchMessageHistory,
1107
969
  requestPlaceholderResend,
1108
970
  };
@@ -1,8 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import { Boom } from '@hapi/boom';
3
3
  import { proto } from '../../WAProto';
4
- import { AnyMessageContent, MediaConnInfo, MessageReceiptType, MessageRelayOptions, MiscMessageGenerationOptions, SocketConfig, WAMessageKey } from '../Types';
4
+ import { AnyMessageContent, Media, MediaConnInfo, MessageReceiptType, MessageRelayOptions, MiscMessageGenerationOptions, QueryIds, SocketConfig, WAMessageKey } from '../Types';
5
5
  import { BinaryNode, JidWithDevice } from '../WABinary';
6
+ import { USyncQuery } from '../WAUSync';
6
7
  export declare const makeMessagesSocket: (config: SocketConfig) => {
7
8
  getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
8
9
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
@@ -13,17 +14,22 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
13
14
  readMessages: (keys: WAMessageKey[]) => Promise<void>;
14
15
  refreshMediaConn: (forceGet?: boolean) => Promise<MediaConnInfo>;
15
16
  getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<JidWithDevice[]>;
17
+ sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
16
18
  createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: BinaryNode['attrs']) => Promise<{
17
19
  nodes: BinaryNode[];
18
20
  shouldIncludeDeviceIdentity: boolean;
19
21
  }>;
22
+ profilePictureUrl: (jid: string, type?: 'preview' | 'image', timeoutMs?: number) => Promise<string | null | undefined>;
20
23
  waUploadToServer: import("../Types").WAMediaUploadFunction;
21
24
  fetchPrivacySettings: (force?: boolean) => Promise<{
22
25
  [_: string]: string;
23
26
  }>;
24
- sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
25
27
  updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
28
+ sendStatusMentions: (content: AnyMessageContent, jids?: string[]) => Promise<proto.WebMessageInfo>;
29
+ sendAlbumMessage: (jid: string, medias: Media[], options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo>;
26
30
  sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
31
+ newsletterQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<BinaryNode>;
32
+ newsletterWMexQuery: (jid: string | undefined, queryId: QueryIds, content?: object | undefined) => Promise<BinaryNode>;
27
33
  subscribeNewsletterUpdates: (jid: string) => Promise<{
28
34
  duration: string;
29
35
  }>;
@@ -37,7 +43,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
37
43
  newsletterUnmute: (jid: string) => Promise<void>;
38
44
  newsletterMute: (jid: string) => Promise<void>;
39
45
  newsletterAction: (jid: string, type: "mute" | "follow" | "unfollow" | "unmute") => Promise<void>;
40
- newsletterCreate: (name: string, description: string, reaction_codes: string) => Promise<import("../Types").NewsletterMetadata>;
46
+ newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
41
47
  newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
42
48
  newsletterAdminCount: (jid: string) => Promise<number>;
43
49
  newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
@@ -46,6 +52,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
46
52
  newsletterReactMessage: (jid: string, serverId: string, code?: string | undefined) => Promise<void>;
47
53
  newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
48
54
  newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
55
+ groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<BinaryNode>;
49
56
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
50
57
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
51
58
  groupLeave: (id: string) => Promise<void>;
@@ -75,24 +82,22 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
75
82
  groupFetchAllParticipating: () => Promise<{
76
83
  [_: string]: import("../Types").GroupMetadata;
77
84
  }>;
85
+ interactiveQuery: (userNodes: BinaryNode[], queryNode: BinaryNode) => Promise<BinaryNode[]>;
78
86
  processingMutex: {
79
87
  mutex<T>(code: () => T | Promise<T>): Promise<T>;
80
88
  };
81
89
  upsertMessage: (msg: proto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
82
90
  appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
91
+ fetchUserLid: (jid: string) => Promise<string | undefined>;
83
92
  sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
84
93
  presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
85
- profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
86
94
  onWhatsApp: (...jids: string[]) => Promise<{
87
95
  jid: string;
88
96
  exists: unknown;
89
- lid: unknown;
90
97
  }[] | undefined>;
91
98
  fetchBlocklist: () => Promise<string[]>;
92
- fetchStatus: (jid: string) => Promise<{
93
- status: string | undefined;
94
- setAt: Date;
95
- } | undefined>;
99
+ fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
100
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
96
101
  updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
97
102
  removeProfilePicture: (jid: string) => Promise<void>;
98
103
  updateProfileStatus: (status: string) => Promise<void>;
@@ -117,6 +122,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
117
122
  id: string;
118
123
  fromMe?: boolean | undefined;
119
124
  }[], star: boolean) => Promise<void>;
125
+ executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
120
126
  type: "md";
121
127
  ws: any;
122
128
  ev: import("../Types").BaileysEventEmitter & {
@@ -143,7 +149,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
143
149
  onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
144
150
  uploadPreKeys: (count?: number) => Promise<void>;
145
151
  uploadPreKeysToServerIfRequired: () => Promise<void>;
146
- requestPairingCode: (phoneNumber: string) => Promise<string>;
152
+ requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
147
153
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
148
154
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
149
155
  };