@queenanya/baileys 7.4.14 → 7.5.11

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 (88) hide show
  1. package/README.md +26 -26
  2. package/WAProto/index.js +66875 -96112
  3. package/lib/Defaults/baileys-version.json +1 -1
  4. package/lib/Defaults/index.d.ts +1 -231
  5. package/lib/Defaults/index.js +11 -23
  6. package/lib/Socket/Client/index.d.ts +2 -3
  7. package/lib/Socket/Client/index.js +2 -3
  8. package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
  9. package/lib/Socket/Client/{web-socket-client.js → websocket.js} +2 -2
  10. package/lib/Socket/business.d.ts +29 -22
  11. package/lib/Socket/chats.d.ts +14 -3
  12. package/lib/Socket/chats.js +76 -48
  13. package/lib/Socket/groups.d.ts +21 -4
  14. package/lib/Socket/groups.js +12 -1
  15. package/lib/Socket/index.d.ts +37 -32
  16. package/lib/Socket/index.js +2 -2
  17. package/lib/Socket/messages-recv.d.ts +28 -22
  18. package/lib/Socket/messages-recv.js +291 -180
  19. package/lib/Socket/messages-send.d.ts +23 -13
  20. package/lib/Socket/messages-send.js +110 -76
  21. package/lib/Socket/newsletter.d.ts +17 -7
  22. package/lib/Socket/newsletter.js +67 -54
  23. package/lib/Socket/socket.d.ts +3 -1
  24. package/lib/Socket/socket.js +15 -17
  25. package/lib/Store/make-cache-manager-store.d.ts +2 -1
  26. package/lib/Store/make-in-memory-store.js +13 -11
  27. package/lib/Store/make-ordered-dictionary.js +2 -2
  28. package/lib/Types/Auth.d.ts +1 -6
  29. package/lib/Types/Call.d.ts +1 -1
  30. package/lib/Types/Chat.d.ts +12 -7
  31. package/lib/Types/Contact.d.ts +1 -1
  32. package/lib/Types/Events.d.ts +44 -2
  33. package/lib/Types/GroupMetadata.d.ts +3 -1
  34. package/lib/Types/Label.d.ts +11 -0
  35. package/lib/Types/Message.d.ts +37 -30
  36. package/lib/Types/Newsletter.d.ts +0 -13
  37. package/lib/Types/Newsletter.js +1 -15
  38. package/lib/Types/Socket.d.ts +10 -3
  39. package/lib/Types/index.d.ts +8 -0
  40. package/lib/Utils/auth-utils.js +1 -7
  41. package/lib/Utils/chat-utils.d.ts +5 -4
  42. package/lib/Utils/chat-utils.js +41 -20
  43. package/lib/Utils/crypto.d.ts +2 -1
  44. package/lib/Utils/crypto.js +4 -2
  45. package/lib/Utils/decode-wa-message.d.ts +1 -0
  46. package/lib/Utils/decode-wa-message.js +34 -14
  47. package/lib/Utils/event-buffer.js +14 -8
  48. package/lib/Utils/generics.d.ts +37 -13
  49. package/lib/Utils/generics.js +102 -18
  50. package/lib/Utils/history.d.ts +6 -2
  51. package/lib/Utils/history.js +3 -0
  52. package/lib/Utils/index.d.ts +1 -0
  53. package/lib/Utils/index.js +1 -0
  54. package/lib/Utils/link-preview.js +24 -1
  55. package/lib/Utils/logger.d.ts +1 -3
  56. package/lib/Utils/make-mutex.js +1 -0
  57. package/lib/Utils/messages-media.d.ts +3 -2
  58. package/lib/Utils/messages-media.js +17 -32
  59. package/lib/Utils/messages.d.ts +1 -0
  60. package/lib/Utils/messages.js +67 -72
  61. package/lib/Utils/noise-handler.d.ts +3 -3
  62. package/lib/Utils/noise-handler.js +7 -12
  63. package/lib/Utils/process-message.d.ts +3 -2
  64. package/lib/Utils/process-message.js +55 -21
  65. package/lib/Utils/signal.js +23 -16
  66. package/lib/Utils/use-multi-file-auth-state.js +17 -3
  67. package/lib/Utils/validate-connection.d.ts +0 -1
  68. package/lib/Utils/validate-connection.js +10 -44
  69. package/lib/WABinary/constants.js +5 -5
  70. package/lib/WABinary/decode.d.ts +3 -2
  71. package/lib/WABinary/decode.js +6 -4
  72. package/lib/WABinary/encode.d.ts +1 -2
  73. package/lib/WABinary/encode.js +8 -6
  74. package/lib/WABinary/generic-utils.d.ts +1 -0
  75. package/lib/WABinary/jid-utils.d.ts +3 -3
  76. package/lib/WABinary/jid-utils.js +5 -5
  77. package/lib/WAM/BinaryInfo.d.ts +3 -2
  78. package/lib/WAM/constants.d.ts +3 -2
  79. package/lib/WAM/encode.d.ts +1 -0
  80. package/lib/WAM/encode.js +2 -2
  81. package/package.json +37 -35
  82. package/lib/Defaults/phonenumber-mcc.json +0 -223
  83. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  84. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  85. package/lib/Socket/registration.d.ts +0 -267
  86. package/lib/Socket/registration.js +0 -166
  87. /package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +0 -0
  88. /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.makeChatsSocket = void 0;
7
7
  const boom_1 = require("@hapi/boom");
8
+ const node_cache_1 = __importDefault(require("node-cache"));
8
9
  const WAProto_1 = require("../../WAProto");
9
10
  const Defaults_1 = require("../Defaults");
10
11
  const Types_1 = require("../Types");
@@ -23,6 +24,13 @@ const makeChatsSocket = (config) => {
23
24
  let pendingAppStateSync = false;
24
25
  /** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
25
26
  const processingMutex = (0, make_mutex_1.makeMutex)();
27
+ const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
28
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
29
+ useClones: false
30
+ });
31
+ if (!config.placeholderResendCache) {
32
+ config.placeholderResendCache = placeholderResendCache;
33
+ }
26
34
  /** helper function to fetch the given app state sync key */
27
35
  const getAppStateSyncKey = async (keyId) => {
28
36
  const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId]);
@@ -66,6 +74,9 @@ const makeChatsSocket = (config) => {
66
74
  }]
67
75
  });
68
76
  };
77
+ const updateCallPrivacy = async (value) => {
78
+ await privacyQuery('calladd', value);
79
+ };
69
80
  const updateLastSeenPrivacy = async (value) => {
70
81
  await privacyQuery('last', value);
71
82
  };
@@ -170,6 +181,19 @@ const makeChatsSocket = (config) => {
170
181
  };
171
182
  }
172
183
  };
184
+ /** Fetching The Disappearing Duration of a specific chats by their jids*/
185
+ const fetchDisappearingDuration = async (...jids) => {
186
+ const list = jids.map((jid) => ({ tag: 'user', attrs: { jid } }));
187
+ const results = await interactiveQuery(list, { tag: 'disappearing_mode', attrs: {} });
188
+ return results.map(item => {
189
+ const result = (0, WABinary_1.getBinaryNodeChild)(item, 'disappearing_mode');
190
+ return {
191
+ user: item.attrs.jid,
192
+ duration: parseInt(result === null || result === void 0 ? void 0 : result.attrs.duration),
193
+ setAt: new Date(+((result === null || result === void 0 ? void 0 : result.attrs.t) || 0) * 1000)
194
+ };
195
+ });
196
+ };
173
197
  /** update the profile picture for yourself or a group */
174
198
  const updateProfilePicture = async (jid, content) => {
175
199
  let targetJid;
@@ -349,9 +373,9 @@ const makeChatsSocket = (config) => {
349
373
  const email = (0, WABinary_1.getBinaryNodeChild)(profiles, 'email');
350
374
  const category = (0, WABinary_1.getBinaryNodeChild)((0, WABinary_1.getBinaryNodeChild)(profiles, 'categories'), 'category');
351
375
  const businessHours = (0, WABinary_1.getBinaryNodeChild)(profiles, 'business_hours');
352
- const businessHoursConfig = businessHours ?
353
- (0, WABinary_1.getBinaryNodeChildren)(businessHours, 'business_hours_config') :
354
- undefined;
376
+ const businessHoursConfig = businessHours
377
+ ? (0, WABinary_1.getBinaryNodeChildren)(businessHours, 'business_hours_config')
378
+ : undefined;
355
379
  const websiteStr = (_a = website === null || website === void 0 ? void 0 : website.content) === null || _a === void 0 ? void 0 : _a.toString();
356
380
  return {
357
381
  wid: (_b = profiles.attrs) === null || _b === void 0 ? void 0 : _b.jid,
@@ -460,16 +484,12 @@ const makeChatsSocket = (config) => {
460
484
  states[name] = newState;
461
485
  Object.assign(globalMutationMap, mutationMap);
462
486
  logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`);
463
- await authState.keys.set({ 'app-state-sync-version': {
464
- [name]: newState
465
- } });
487
+ await authState.keys.set({ 'app-state-sync-version': { [name]: newState } });
466
488
  }
467
489
  // only process if there are syncd patches
468
490
  if (patches.length) {
469
491
  const { state: newState, mutationMap } = await (0, Utils_1.decodePatches)(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch);
470
- await authState.keys.set({ 'app-state-sync-version': {
471
- [name]: newState
472
- } });
492
+ await authState.keys.set({ 'app-state-sync-version': { [name]: newState } });
473
493
  logger.info(`synced ${name} to v${newState.version}`);
474
494
  initialVersionMap[name] = newState.version;
475
495
  Object.assign(globalMutationMap, mutationMap);
@@ -484,13 +504,11 @@ const makeChatsSocket = (config) => {
484
504
  catch (error) {
485
505
  // if retry attempts overshoot
486
506
  // or key not found
487
- const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS ||
488
- ((_a = error.output) === null || _a === void 0 ? void 0 : _a.statusCode) === 404 ||
489
- error.name === 'TypeError';
507
+ const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS
508
+ || ((_a = error.output) === null || _a === void 0 ? void 0 : _a.statusCode) === 404
509
+ || error.name === 'TypeError';
490
510
  logger.info({ name, error: error.stack }, `failed to sync state from version${isIrrecoverableError ? '' : ', removing and trying from scratch'}`);
491
- await authState.keys.set({ 'app-state-sync-version': {
492
- [name]: null
493
- } });
511
+ await authState.keys.set({ 'app-state-sync-version': { [name]: null } });
494
512
  // increment number of retries
495
513
  attemptsMap[name] = (attemptsMap[name] || 0) + 1;
496
514
  if (isIrrecoverableError) {
@@ -572,15 +590,15 @@ const makeChatsSocket = (config) => {
572
590
  id: generateMessageTag(),
573
591
  type: 'subscribe'
574
592
  },
575
- content: tcToken ?
576
- [
593
+ content: tcToken
594
+ ? [
577
595
  {
578
596
  tag: 'tctoken',
579
597
  attrs: {},
580
598
  content: tcToken
581
599
  }
582
- ] :
583
- undefined
600
+ ]
601
+ : undefined
584
602
  }));
585
603
  const handlePresenceUpdate = ({ tag, attrs, content }) => {
586
604
  var _a;
@@ -611,9 +629,7 @@ const makeChatsSocket = (config) => {
611
629
  logger.error({ tag, attrs, content }, 'recv invalid presence node');
612
630
  }
613
631
  if (presence) {
614
- ev.emit('presence.update', { id: jid, presences: {
615
- [participant]: presence
616
- } });
632
+ ev.emit('presence.update', { id: jid, presences: { [participant]: presence } });
617
633
  }
618
634
  };
619
635
  const appPatch = async (patchCreate) => {
@@ -664,9 +680,7 @@ const makeChatsSocket = (config) => {
664
680
  ]
665
681
  };
666
682
  await query(node);
667
- await authState.keys.set({ 'app-state-sync-version': {
668
- [name]: state
669
- } });
683
+ await authState.keys.set({ 'app-state-sync-version': { [name]: state } });
670
684
  });
671
685
  });
672
686
  if (config.emitOwnEvents) {
@@ -679,7 +693,7 @@ const makeChatsSocket = (config) => {
679
693
  };
680
694
  /** sending non-abt props may fix QR scan fail if server expects */
681
695
  const fetchProps = async () => {
682
- var _a, _b;
696
+ var _a, _b, _c;
683
697
  const resultNode = await query({
684
698
  tag: 'iq',
685
699
  attrs: {
@@ -688,20 +702,19 @@ const makeChatsSocket = (config) => {
688
702
  type: 'get',
689
703
  },
690
704
  content: [
691
- {
692
- tag: 'props',
693
- attrs: {
705
+ { tag: 'props', attrs: {
694
706
  protocol: '2',
695
707
  hash: ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.lastPropHash) || ''
696
- }
697
- }
708
+ } }
698
709
  ]
699
710
  });
700
711
  const propsNode = (0, WABinary_1.getBinaryNodeChild)(resultNode, 'props');
701
712
  let props = {};
702
713
  if (propsNode) {
703
- authState.creds.lastPropHash = (_b = propsNode === null || propsNode === void 0 ? void 0 : propsNode.attrs) === null || _b === void 0 ? void 0 : _b.hash;
704
- ev.emit('creds.update', authState.creds);
714
+ if ((_b = propsNode.attrs) === null || _b === void 0 ? void 0 : _b.hash) { // on some clients, the hash is returning as undefined
715
+ authState.creds.lastPropHash = (_c = propsNode === null || propsNode === void 0 ? void 0 : propsNode.attrs) === null || _c === void 0 ? void 0 : _c.hash;
716
+ ev.emit('creds.update', authState.creds);
717
+ }
705
718
  props = (0, WABinary_1.reduceBinaryNodeToDictionary)(propsNode, 'prop');
706
719
  }
707
720
  logger.debug('fetched props');
@@ -711,7 +724,7 @@ const makeChatsSocket = (config) => {
711
724
  * modify a chat -- mark unread, read etc.
712
725
  * lastMessages must be sorted in reverse chronologically
713
726
  * requires the last messages till the last message received; required for archive & unread
714
- */
727
+ */
715
728
  const chatModify = (mod, jid) => {
716
729
  const patch = (0, Utils_1.chatModificationToAppPatch)(mod, jid);
717
730
  return appPatch(patch);
@@ -727,6 +740,16 @@ const makeChatsSocket = (config) => {
727
740
  }
728
741
  }, jid);
729
742
  };
743
+ /**
744
+ * Adds label
745
+ */
746
+ const addLabel = (jid, labels) => {
747
+ return chatModify({
748
+ addLabel: {
749
+ ...labels
750
+ }
751
+ }, jid);
752
+ };
730
753
  /**
731
754
  * Adds label for the chats
732
755
  */
@@ -795,24 +818,25 @@ const makeChatsSocket = (config) => {
795
818
  }
796
819
  }
797
820
  const historyMsg = (0, Utils_1.getHistoryMsg)(msg.message);
798
- const shouldProcessHistoryMsg = historyMsg ?
799
- (shouldSyncHistoryMessage(historyMsg) &&
800
- Defaults_1.PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType)) :
801
- false;
821
+ const shouldProcessHistoryMsg = historyMsg
822
+ ? (shouldSyncHistoryMessage(historyMsg)
823
+ && Defaults_1.PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType))
824
+ : false;
802
825
  if (historyMsg && !authState.creds.myAppStateKeyId) {
803
826
  logger.warn('skipping app state sync, as myAppStateKeyId is not set');
804
827
  pendingAppStateSync = true;
805
828
  }
806
829
  await Promise.all([
807
830
  (async () => {
808
- if (historyMsg &&
809
- authState.creds.myAppStateKeyId) {
831
+ if (historyMsg
832
+ && authState.creds.myAppStateKeyId) {
810
833
  pendingAppStateSync = false;
811
834
  await doAppStateSync();
812
835
  }
813
836
  })(),
814
837
  (0, process_message_1.default)(msg, {
815
838
  shouldProcessHistoryMsg,
839
+ placeholderResendCache,
816
840
  ev,
817
841
  creds: authState.creds,
818
842
  keyStore: authState.keys,
@@ -821,8 +845,8 @@ const makeChatsSocket = (config) => {
821
845
  getMessage: config.getMessage,
822
846
  })
823
847
  ]);
824
- if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.appStateSyncKeyShare) &&
825
- pendingAppStateSync) {
848
+ if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.appStateSyncKeyShare)
849
+ && pendingAppStateSync) {
826
850
  await doAppStateSync();
827
851
  pendingAppStateSync = false;
828
852
  }
@@ -873,14 +897,13 @@ const makeChatsSocket = (config) => {
873
897
  sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
874
898
  .catch(error => onUnexpectedError(error, 'presence update requests'));
875
899
  }
876
- if (receivedPendingNotifications) {
877
- // if we don't have the app state key
900
+ if (receivedPendingNotifications && // if we don't have the app state key
878
901
  // we keep buffering events until we finally have
879
902
  // the key and can sync the messages
880
- if (!((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId) && !config.mobile) {
881
- ev.buffer();
882
- needToFlushWithAppStateSync = true;
883
- }
903
+ // todo scrutinize
904
+ !((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId)) {
905
+ ev.buffer();
906
+ needToFlushWithAppStateSync = true;
884
907
  }
885
908
  });
886
909
  return {
@@ -894,12 +917,16 @@ const makeChatsSocket = (config) => {
894
917
  profilePictureUrl,
895
918
  onWhatsApp,
896
919
  fetchBlocklist,
920
+ fetchDisappearingDuration,
897
921
  fetchStatus,
898
922
  updateProfilePicture,
923
+ updateProfilePictureFull,
924
+ updateProfilePictureFull2,
899
925
  removeProfilePicture,
900
926
  updateProfileStatus,
901
927
  updateProfileName,
902
928
  updateBlockStatus,
929
+ updateCallPrivacy,
903
930
  updateLastSeenPrivacy,
904
931
  updateOnlinePrivacy,
905
932
  updateProfilePicturePrivacy,
@@ -911,6 +938,7 @@ const makeChatsSocket = (config) => {
911
938
  resyncAppState,
912
939
  chatModify,
913
940
  cleanDirtyBits,
941
+ addLabel,
914
942
  addChatLabel,
915
943
  removeChatLabel,
916
944
  addMessageLabel,
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { proto } from '../../WAProto';
3
- import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
4
+ import { GroupMetadata, ParticipantAction, SocketConfig, WAMessageKey } from '../Types';
4
5
  import { BinaryNode } from '../WABinary';
5
6
  export declare const makeGroupsSocket: (config: SocketConfig) => {
6
7
  groupMetadata: (jid: string) => Promise<GroupMetadata>;
@@ -23,12 +24,19 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
23
24
  groupInviteCode: (jid: string) => Promise<string | undefined>;
24
25
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
25
26
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
27
+ /**
28
+ * revoke a v4 invite for someone
29
+ * @param groupJid group jid
30
+ * @param invitedJid jid of person you invited
31
+ * @returns true if successful
32
+ */
33
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
26
34
  /**
27
35
  * accept a GroupInviteMessage
28
36
  * @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
29
37
  * @param inviteMessage the message to accept
30
38
  */
31
- groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
39
+ groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
32
40
  groupGetInviteInfo: (code: string) => Promise<GroupMetadata>;
33
41
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
34
42
  groupSettingUpdate: (jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') => Promise<void>;
@@ -53,26 +61,35 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
53
61
  jid: string;
54
62
  }[]>;
55
63
  fetchBlocklist: () => Promise<string[]>;
64
+ fetchDisappearingDuration: (...jids: string[]) => Promise<{
65
+ user: string;
66
+ duration: number;
67
+ setAt: Date;
68
+ }[]>;
56
69
  fetchStatus: (jid: string) => Promise<{
57
70
  status: string | undefined;
58
71
  setAt: Date;
59
72
  } | undefined>;
60
73
  updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
74
+ updateProfilePictureFull: (jid: any, content: any) => Promise<void>;
75
+ updateProfilePictureFull2: (jid: any, content: any) => Promise<void>;
61
76
  removeProfilePicture: (jid: string) => Promise<void>;
62
77
  updateProfileStatus: (status: string) => Promise<void>;
63
78
  updateProfileName: (name: string) => Promise<void>;
64
79
  updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
80
+ updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
65
81
  updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
66
82
  updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
67
83
  updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
68
84
  updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
69
85
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
70
- updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
86
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
71
87
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
72
88
  getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
73
89
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
74
90
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
75
91
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
92
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
76
93
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
77
94
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
78
95
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -82,7 +99,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
82
99
  fromMe?: boolean | undefined;
83
100
  }[], star: boolean) => Promise<void>;
84
101
  type: "md";
85
- ws: any;
102
+ ws: import("./Client").WebSocketClient;
86
103
  ev: import("../Types").BaileysEventEmitter & {
87
104
  process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
88
105
  buffer(): void;
@@ -187,12 +187,23 @@ const makeGroupsSocket = (config) => {
187
187
  const result = (0, WABinary_1.getBinaryNodeChild)(results, 'group');
188
188
  return result === null || result === void 0 ? void 0 : result.attrs.jid;
189
189
  },
190
+ /**
191
+ * revoke a v4 invite for someone
192
+ * @param groupJid group jid
193
+ * @param invitedJid jid of person you invited
194
+ * @returns true if successful
195
+ */
196
+ groupRevokeInviteV4: async (groupJid, invitedJid) => {
197
+ const result = await groupQuery(groupJid, 'set', [{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }]);
198
+ return !!result;
199
+ },
190
200
  /**
191
201
  * accept a GroupInviteMessage
192
202
  * @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
193
203
  * @param inviteMessage the message to accept
194
204
  */
195
205
  groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
206
+ var _a;
196
207
  key = typeof key === 'string' ? { remoteJid: key } : key;
197
208
  const results = await groupQuery(inviteMessage.groupJid, 'set', [{
198
209
  tag: 'accept',
@@ -224,7 +235,7 @@ const makeGroupsSocket = (config) => {
224
235
  await upsertMessage({
225
236
  key: {
226
237
  remoteJid: inviteMessage.groupJid,
227
- id: (0, Utils_1.generateMessageID)(),
238
+ id: (0, Utils_1.generateMessageIDV3)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
228
239
  fromMe: false,
229
240
  participant: key.remoteJid,
230
241
  },
@@ -1,9 +1,9 @@
1
+ /// <reference types="long" />
2
+ /// <reference types="node" />
1
3
  /// <reference types="node" />
2
4
  import { UserFacingSocketConfig } from '../Types';
3
5
  declare const makeWASocket: (config: UserFacingSocketConfig) => {
4
- register: (code: string) => Promise<import("./registration").ExistsResponse>;
5
- requestRegistrationCode: (registrationOptions?: import("./registration").RegistrationOptions | undefined) => Promise<import("./registration").ExistsResponse>;
6
- logger: import("pino").Logger<import("pino").LoggerOptions>;
6
+ logger: import("pino").Logger<never, boolean>;
7
7
  getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
8
8
  getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
9
9
  products: import("../Types").Product[];
@@ -17,34 +17,30 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
17
17
  deleted: number;
18
18
  }>;
19
19
  productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
20
- sendMessageAck: ({ tag, attrs, content }: import("../index").BinaryNode) => Promise<void>;
21
- sendRetryRequest: (node: import("../index").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
22
- offerCall: (toJid: string, isVideo?: boolean) => Promise<{
23
- id: string;
24
- to: string;
25
- }>;
20
+ sendMessageAck: ({ tag, attrs, content }: import("..").BinaryNode) => Promise<void>;
21
+ sendRetryRequest: (node: import("..").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
26
22
  rejectCall: (callId: string, callFrom: string) => Promise<void>;
27
- getPrivacyTokens: (jids: string[]) => Promise<import("../index").BinaryNode>;
23
+ fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>;
24
+ requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
25
+ getPrivacyTokens: (jids: string[]) => Promise<import("..").BinaryNode>;
28
26
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
29
- relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
27
+ relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
30
28
  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
- getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
33
- [key: string]: string;
34
- };
35
- readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
29
+ sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
30
+ readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
36
31
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
37
- getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../index").JidWithDevice[]>;
32
+ waUploadToServer: import("../Types").WAMediaUploadFunction;
33
+ fetchPrivacySettings: (force?: boolean) => Promise<{
34
+ [_: string]: string;
35
+ }>;
36
+ sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
38
37
  createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
39
38
  [key: string]: string;
40
39
  } | undefined) => Promise<{
41
- nodes: import("../index").BinaryNode[];
40
+ nodes: import("..").BinaryNode[];
42
41
  shouldIncludeDeviceIdentity: boolean;
43
42
  }>;
44
- waUploadToServer: import("../Types").WAMediaUploadFunction;
45
- fetchPrivacySettings: (force?: boolean) => Promise<{
46
- [_: string]: string;
47
- }>;
43
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("..").JidWithDevice[]>;
48
44
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
49
45
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
50
46
  subscribeNewsletterUpdates: (jid: string) => Promise<{
@@ -59,14 +55,13 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
59
55
  newsletterFollow: (jid: string) => Promise<void>;
60
56
  newsletterUnmute: (jid: string) => Promise<void>;
61
57
  newsletterMute: (jid: string) => Promise<void>;
62
- newsletterAction: (jid: string, type: "mute" | "follow" | "unfollow" | "unmute") => Promise<void>;
63
- newsletterCreate: (name: string, description: string, reaction_codes: string) => Promise<import("../Types").NewsletterMetadata>;
58
+ newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
64
59
  newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
65
60
  newsletterAdminCount: (jid: string) => Promise<number>;
66
61
  newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
67
62
  newsletterDemote: (jid: string, user: string) => Promise<void>;
68
63
  newsletterDelete: (jid: string) => Promise<void>;
69
- newsletterReactMessage: (jid: string, serverId: string, code?: string | undefined) => Promise<void>;
64
+ newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
70
65
  newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
71
66
  newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
72
67
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
@@ -83,13 +78,14 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
83
78
  groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
84
79
  status: string;
85
80
  jid: string;
86
- content: import("../index").BinaryNode;
81
+ content: import("..").BinaryNode;
87
82
  }[]>;
88
83
  groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
89
84
  groupInviteCode: (jid: string) => Promise<string | undefined>;
90
85
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
91
86
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
92
- groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
87
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
88
+ groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
93
89
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
94
90
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
95
91
  groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
@@ -111,26 +107,35 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
111
107
  jid: string;
112
108
  }[]>;
113
109
  fetchBlocklist: () => Promise<string[]>;
110
+ fetchDisappearingDuration: (...jids: string[]) => Promise<{
111
+ user: string;
112
+ duration: number;
113
+ setAt: Date;
114
+ }[]>;
114
115
  fetchStatus: (jid: string) => Promise<{
115
116
  status: string | undefined;
116
117
  setAt: Date;
117
118
  } | undefined>;
118
119
  updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
120
+ updateProfilePictureFull: (jid: any, content: any) => Promise<void>;
121
+ updateProfilePictureFull2: (jid: any, content: any) => Promise<void>;
119
122
  removeProfilePicture: (jid: string) => Promise<void>;
120
123
  updateProfileStatus: (status: string) => Promise<void>;
121
124
  updateProfileName: (name: string) => Promise<void>;
122
125
  updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
126
+ updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
123
127
  updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
124
128
  updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
125
129
  updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
126
130
  updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
127
131
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
128
- updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
132
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
129
133
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
130
134
  getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
131
135
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
132
136
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
133
137
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
138
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
134
139
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
135
140
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
136
141
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -140,7 +145,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
140
145
  fromMe?: boolean | undefined;
141
146
  }[], star: boolean) => Promise<void>;
142
147
  type: "md";
143
- ws: any;
148
+ ws: import("./Client").WebSocketClient;
144
149
  ev: import("../Types").BaileysEventEmitter & {
145
150
  process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
146
151
  buffer(): void;
@@ -155,11 +160,11 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
155
160
  signalRepository: import("../Types").SignalRepository;
156
161
  user: import("../Types").Contact | undefined;
157
162
  generateMessageTag: () => string;
158
- query: (node: import("../index").BinaryNode, timeoutMs?: number | undefined) => Promise<import("../index").BinaryNode>;
163
+ query: (node: import("..").BinaryNode, timeoutMs?: number | undefined) => Promise<import("..").BinaryNode>;
159
164
  waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
160
165
  waitForSocketOpen: () => Promise<void>;
161
166
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
162
- sendNode: (frame: import("../index").BinaryNode) => Promise<void>;
167
+ sendNode: (frame: import("..").BinaryNode) => Promise<void>;
163
168
  logout: (msg?: string | undefined) => Promise<void>;
164
169
  end: (error: Error | undefined) => void;
165
170
  onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
@@ -167,6 +172,6 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
167
172
  uploadPreKeysToServerIfRequired: () => Promise<void>;
168
173
  requestPairingCode: (phoneNumber: string) => Promise<string>;
169
174
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
170
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("../index").BinaryNode>;
175
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("..").BinaryNode>;
171
176
  };
172
177
  export default makeWASocket;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const Defaults_1 = require("../Defaults");
4
- const registration_1 = require("./registration");
4
+ const business_1 = require("./business");
5
5
  // export the last socket layer
6
- const makeWASocket = (config) => ((0, registration_1.makeRegistrationSocket)({
6
+ const makeWASocket = (config) => ((0, business_1.makeBusinessSocket)({
7
7
  ...Defaults_1.DEFAULT_CONNECTION_CONFIG,
8
8
  ...config
9
9
  }));