@genuxofficial/baileys 2.0.0 → 3.0.0

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 (76) hide show
  1. package/LICENSE +1 -1
  2. package/WAProto/WAProto.proto +4633 -0
  3. package/engine-requirements.js +1 -1
  4. package/lib/Defaults/index.d.ts +5 -3
  5. package/lib/Defaults/index.js +7 -7
  6. package/lib/Signal/libsignal.js +9 -18
  7. package/lib/Socket/Client/types.d.ts +2 -0
  8. package/lib/Socket/Client/websocket.js +1 -1
  9. package/lib/Socket/business.d.ts +40 -38
  10. package/lib/Socket/chats.d.ts +17 -20
  11. package/lib/Socket/chats.js +1 -85
  12. package/lib/Socket/groups.d.ts +25 -28
  13. package/lib/Socket/groups.js +9 -10
  14. package/lib/Socket/index.d.ts +46 -44
  15. package/lib/Socket/messages-recv.d.ts +37 -36
  16. package/lib/Socket/messages-recv.js +14 -26
  17. package/lib/Socket/messages-send.d.ts +35 -33
  18. package/lib/Socket/messages-send.js +10 -8
  19. package/lib/Socket/newsletter.d.ts +28 -31
  20. package/lib/Socket/newsletter.js +21 -17
  21. package/lib/Socket/socket.d.ts +7 -5
  22. package/lib/Socket/socket.js +1 -1
  23. package/lib/Socket/usync.d.ts +11 -9
  24. package/lib/Socket/usync.js +15 -10
  25. package/lib/Store/make-in-memory-store.d.ts +1 -1
  26. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  27. package/lib/Types/Auth.d.ts +2 -0
  28. package/lib/Types/Chat.d.ts +2 -8
  29. package/lib/Types/Contact.d.ts +0 -5
  30. package/lib/Types/GroupMetadata.d.ts +4 -5
  31. package/lib/Types/Label.d.ts +0 -11
  32. package/lib/Types/Label.js +1 -1
  33. package/lib/Types/LabelAssociation.js +1 -1
  34. package/lib/Types/Message.d.ts +27 -2
  35. package/lib/Types/Newsletter.js +2 -2
  36. package/lib/Types/Socket.d.ts +2 -0
  37. package/lib/Types/index.js +1 -1
  38. package/lib/Utils/auth-utils.js +3 -3
  39. package/lib/Utils/business.js +17 -5
  40. package/lib/Utils/chat-utils.d.ts +10 -8
  41. package/lib/Utils/chat-utils.js +0 -27
  42. package/lib/Utils/crypto.d.ts +16 -14
  43. package/lib/Utils/crypto.js +22 -34
  44. package/lib/Utils/decode-wa-message.d.ts +1 -1
  45. package/lib/Utils/decode-wa-message.js +16 -31
  46. package/lib/Utils/generics.d.ts +8 -33
  47. package/lib/Utils/generics.js +12 -98
  48. package/lib/Utils/link-preview.js +1 -34
  49. package/lib/Utils/make-mutex.d.ts +2 -2
  50. package/lib/Utils/messages-media.d.ts +19 -29
  51. package/lib/Utils/messages-media.js +87 -151
  52. package/lib/Utils/messages.d.ts +8 -5
  53. package/lib/Utils/messages.js +20 -28
  54. package/lib/Utils/noise-handler.d.ts +6 -4
  55. package/lib/Utils/process-message.js +2 -2
  56. package/lib/Utils/validate-connection.d.ts +2 -2
  57. package/lib/WABinary/decode.d.ts +4 -2
  58. package/lib/WABinary/decode.js +7 -17
  59. package/lib/WABinary/encode.d.ts +3 -1
  60. package/lib/WABinary/encode.js +7 -17
  61. package/lib/WABinary/generic-utils.d.ts +6 -6
  62. package/lib/WABinary/generic-utils.js +36 -21
  63. package/lib/WABinary/jid-utils.d.ts +6 -2
  64. package/lib/WABinary/jid-utils.js +5 -1
  65. package/lib/WAM/BinaryInfo.d.ts +12 -2
  66. package/lib/WAM/encode.d.ts +3 -1
  67. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
  68. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +23 -14
  69. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
  70. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
  71. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
  72. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +1 -1
  73. package/lib/WAUSync/USyncQuery.js +13 -17
  74. package/package.json +59 -53
  75. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  76. package/lib/Store/make-cache-manager-store.js +0 -83
@@ -16,30 +16,25 @@ 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, ignoreMsgLoading, shouldIgnoreJid } = config;
20
20
  const sock = (0, messages_send_1.makeMessagesSocket)(config);
21
21
  const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, 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({
25
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY, // 1 hour
25
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
26
26
  useClones: false
27
27
  });
28
28
  const callOfferCache = config.callOfferCache || new node_cache_1.default({
29
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.CALL_OFFER, // 5 mins
29
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.CALL_OFFER,
30
30
  useClones: false
31
31
  });
32
32
  const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
33
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY, // 1 hour
33
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
34
34
  useClones: false
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,6 +184,7 @@ const makeMessagesRecvSocket = (config) => {
192
184
  ]
193
185
  };
194
186
  if (node.attrs.recipient) {
187
+ //Fixes problem with retry that is never done when it is @bot
195
188
  receipt.attrs.recipient = (0, WABinary_1.getBotJid)(node.attrs.recipient);
196
189
  }
197
190
  if (node.attrs.participant) {
@@ -346,22 +339,22 @@ const makeMessagesRecvSocket = (config) => {
346
339
  const handleNewsletterNotification = (id, node) => {
347
340
  const messages = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
348
341
  const message = (0, WABinary_1.getBinaryNodeChild)(messages, 'message');
349
- const serverId = message.attrs.server_id;
342
+ const server_id = message.attrs.server_id;
350
343
  const reactionsList = (0, WABinary_1.getBinaryNodeChild)(message, 'reactions');
351
344
  const viewsList = (0, WABinary_1.getBinaryNodeChildren)(message, 'views_count');
352
345
  if (reactionsList) {
353
346
  const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionsList, 'reaction');
354
347
  if (reactions.length === 0) {
355
- ev.emit('newsletter.reaction', { id, 'server_id': serverId, reaction: { removed: true } });
348
+ ev.emit('newsletter.reaction', { id, server_id, reaction: { removed: true } });
356
349
  }
357
350
  reactions.forEach(item => {
358
351
  var _a, _b;
359
- 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) } });
352
+ ev.emit('newsletter.reaction', { id, server_id, 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) } });
360
353
  });
361
354
  }
362
355
  if (viewsList.length) {
363
356
  viewsList.forEach(item => {
364
- ev.emit('newsletter.view', { id, 'server_id': serverId, count: +item.attrs.count });
357
+ ev.emit('newsletter.view', { id, server_id, count: +item.attrs.count });
365
358
  });
366
359
  }
367
360
  };
@@ -423,9 +416,6 @@ const makeMessagesRecvSocket = (config) => {
423
416
  case 'encrypt':
424
417
  await handleEncryptNotification(node);
425
418
  break;
426
- case 'newsletter':
427
- // TO DO
428
- break;
429
419
  case 'devices':
430
420
  const devices = (0, WABinary_1.getBinaryNodeChildren)(child, 'device');
431
421
  if ((0, WABinary_1.areJidsSameUser)(child.attrs.jid, authState.creds.me.id)) {
@@ -611,7 +601,8 @@ const makeMessagesRecvSocket = (config) => {
611
601
  const isLid = attrs.from.includes('lid');
612
602
  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);
613
603
  const remoteJid = !isNodeFromMe || (0, WABinary_1.isJidGroup)(attrs.from) ? attrs.from : attrs.recipient;
614
- const fromMe = !attrs.recipient || ((attrs.type === 'retry' || attrs.type === 'sender') && isNodeFromMe);
604
+ const fromMe = !attrs.recipient || ((attrs.type === 'retry' || attrs.type === 'sender')
605
+ && isNodeFromMe);
615
606
  const key = {
616
607
  remoteJid,
617
608
  id: '',
@@ -763,7 +754,7 @@ const makeMessagesRecvSocket = (config) => {
763
754
  try {
764
755
  await Promise.all([
765
756
  processingMutex.mutex(async () => {
766
- var _a, _b, _c;
757
+ var _a;
767
758
  await decrypt();
768
759
  // message failed to decrypt
769
760
  if (msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT) {
@@ -811,9 +802,6 @@ const makeMessagesRecvSocket = (config) => {
811
802
  await sendReceipt(jid, undefined, [msg.key.id], 'hist_sync');
812
803
  }
813
804
  }
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
805
  (0, Utils_1.cleanMessage)(msg, authState.creds.me.id);
818
806
  await sendMessageAck(node);
819
807
  await upsertMessage(msg, node.attrs.offline ? 'append' : 'notify');
@@ -906,7 +894,7 @@ const makeMessagesRecvSocket = (config) => {
906
894
  await sendMessageAck(node);
907
895
  };
908
896
  const handleBadAck = async ({ attrs }) => {
909
- const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id, 'server_id': attrs === null || attrs === void 0 ? void 0 : attrs.server_id };
897
+ const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id, server_id: attrs === null || attrs === void 0 ? void 0 : attrs.server_id };
910
898
  // current hypothesis is that if pash is sent in the ack
911
899
  // it means -- the message hasn't reached all devices yet
912
900
  // we'll retry sending the message here
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import { Boom } from '@hapi/boom';
2
4
  import { proto } from '../../WAProto';
3
5
  import { AnyMessageContent, MediaConnInfo, MessageReceiptType, MessageRelayOptions, MiscMessageGenerationOptions, SocketConfig, WAMessageKey } from '../Types';
@@ -9,7 +11,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
9
11
  relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
10
12
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
11
13
  sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
12
- getButtonArgs: (message: proto.IMessage) => BinaryNode["attrs"];
14
+ getButtonArgs: (message: proto.IMessage) => BinaryNode['attrs'];
13
15
  readMessages: (keys: WAMessageKey[]) => Promise<void>;
14
16
  refreshMediaConn: (forceGet?: boolean) => Promise<MediaConnInfo>;
15
17
  waUploadToServer: import("../Types").WAMediaUploadFunction;
@@ -17,7 +19,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
17
19
  [_: string]: string;
18
20
  }>;
19
21
  getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<JidWithDevice[]>;
20
- createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: BinaryNode["attrs"]) => Promise<{
22
+ createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: BinaryNode['attrs']) => Promise<{
21
23
  nodes: BinaryNode[];
22
24
  shouldIncludeDeviceIdentity: boolean;
23
25
  }>;
@@ -28,7 +30,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
28
30
  duration: string;
29
31
  }>;
30
32
  newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
31
- newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
33
+ newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
32
34
  newsletterUpdateName: (jid: string, name: string) => Promise<void>;
33
35
  newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
34
36
  newsletterRemovePicture: (jid: string) => Promise<void>;
@@ -36,24 +38,29 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
36
38
  newsletterFollow: (jid: string) => Promise<void>;
37
39
  newsletterUnmute: (jid: string) => Promise<void>;
38
40
  newsletterMute: (jid: string) => Promise<void>;
39
- newsletterCreate: (name: string, description?: string, picture?: import("../Types").WAMediaUpload) => Promise<import("../Types").NewsletterMetadata>;
40
- newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
41
+ newsletterCreate: (name: string, description?: string | undefined, picture?: import("../Types").WAMediaUpload | undefined) => Promise<import("../Types").NewsletterMetadata>;
42
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
41
43
  newsletterAdminCount: (jid: string) => Promise<number>;
42
44
  newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
43
45
  newsletterDemote: (jid: string, user: string) => Promise<void>;
44
46
  newsletterDelete: (jid: string) => Promise<void>;
45
- newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
46
- newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
47
- newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
47
+ newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
48
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
49
+ newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
48
50
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
49
51
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
50
52
  groupLeave: (id: string) => Promise<void>;
51
53
  groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
54
+ /**
55
+ * generic send receipt function
56
+ * used for receipts of phone call, read, delivery etc.
57
+ * */
52
58
  groupRequestParticipantsList: (jid: string) => Promise<{
53
59
  [key: string]: string;
54
60
  }[]>;
55
- groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
61
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
56
62
  status: string;
63
+ /** Correctly bulk send receipts to multiple chats, participants */
57
64
  jid: string;
58
65
  }[]>;
59
66
  groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
@@ -61,7 +68,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
61
68
  jid: string;
62
69
  content: BinaryNode;
63
70
  }[]>;
64
- groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
71
+ groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
65
72
  groupInviteCode: (jid: string) => Promise<string | undefined>;
66
73
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
67
74
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
@@ -69,21 +76,21 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
69
76
  groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
70
77
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
71
78
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
72
- groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
73
- groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
79
+ groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
80
+ groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
74
81
  groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
75
82
  groupFetchAllParticipating: () => Promise<{
76
83
  [_: string]: import("../Types").GroupMetadata;
77
84
  }>;
78
85
  getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
79
86
  processingMutex: {
80
- mutex<T>(code: () => Promise<T> | T): Promise<T>;
87
+ mutex<T>(code: () => T | Promise<T>): Promise<T>;
81
88
  };
82
89
  upsertMessage: (msg: proto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
83
90
  appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
84
- sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
85
- presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
86
- profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
91
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
92
+ presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
93
+ profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
87
94
  onWhatsApp: (...jids: string[]) => Promise<{
88
95
  jid: string;
89
96
  exists: unknown;
@@ -93,8 +100,6 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
93
100
  fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
94
101
  fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
95
102
  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>;
98
103
  removeProfilePicture: (jid: string) => Promise<void>;
99
104
  updateProfileStatus: (status: string) => Promise<void>;
100
105
  updateProfileName: (name: string) => Promise<void>;
@@ -108,29 +113,26 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
108
113
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
109
114
  updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
110
115
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
111
- getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
116
+ getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
112
117
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
113
118
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
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>;
119
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
118
120
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
119
121
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
120
122
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
121
123
  removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
122
124
  star: (jid: string, messages: {
123
125
  id: string;
124
- fromMe?: boolean;
126
+ fromMe?: boolean | undefined;
125
127
  }[], star: boolean) => Promise<void>;
126
128
  executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
127
129
  type: "md";
128
- ws: import("./Client").WebSocketClient;
130
+ ws: import("./Client/websocket").WebSocketClient;
129
131
  ev: import("../Types").BaileysEventEmitter & {
130
- process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
132
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
131
133
  buffer(): void;
132
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
133
- flush(force?: boolean): boolean;
134
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
135
+ flush(force?: boolean | undefined): boolean;
134
136
  isBuffering(): boolean;
135
137
  };
136
138
  authState: {
@@ -140,17 +142,17 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
140
142
  signalRepository: import("../Types").SignalRepository;
141
143
  user: import("../Types").Contact | undefined;
142
144
  generateMessageTag: () => string;
143
- query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
144
- waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
145
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<any>;
146
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
145
147
  waitForSocketOpen: () => Promise<void>;
146
148
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
147
149
  sendNode: (frame: BinaryNode) => Promise<void>;
148
- logout: (msg?: string) => Promise<void>;
150
+ logout: (msg?: string | undefined) => Promise<void>;
149
151
  end: (error: Error | undefined) => void;
150
- onUnexpectedError: (err: Error | Boom, msg: string) => void;
152
+ onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
151
153
  uploadPreKeys: (count?: number) => Promise<void>;
152
154
  uploadPreKeysToServerIfRequired: () => Promise<void>;
153
155
  requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
154
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
156
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number | undefined) => Promise<void>;
155
157
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
156
158
  };
@@ -19,7 +19,7 @@ const makeMessagesSocket = (config) => {
19
19
  const sock = (0, newsletter_1.makeNewsletterSocket)(config);
20
20
  const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, sendNode, groupMetadata, groupToggleEphemeral, } = sock;
21
21
  const userDevicesCache = config.userDevicesCache || new node_cache_1.default({
22
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES, // 5 minutes
22
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES,
23
23
  useClones: false
24
24
  });
25
25
  let mediaConn;
@@ -139,7 +139,9 @@ const makeMessagesSocket = (config) => {
139
139
  if (!toFetch.length) {
140
140
  return deviceResults;
141
141
  }
142
- const query = new WAUSync_1.USyncQuery().withContext('message').withDeviceProtocol();
142
+ const query = new WAUSync_1.USyncQuery()
143
+ .withContext('message')
144
+ .withDeviceProtocol();
143
145
  for (const jid of toFetch) {
144
146
  query.withUser(new WAUSync_1.USyncUser().withId(jid));
145
147
  }
@@ -156,7 +158,6 @@ const makeMessagesSocket = (config) => {
156
158
  userDevicesCache.set(key, deviceMap[key]);
157
159
  }
158
160
  }
159
- logger.debug(deviceResults);
160
161
  return deviceResults;
161
162
  };
162
163
  const assertSessions = async (jids, force) => {
@@ -265,7 +266,7 @@ const makeMessagesSocket = (config) => {
265
266
  const { user, server } = (0, WABinary_1.jidDecode)(jid);
266
267
  const statusJid = 'status@broadcast';
267
268
  const isGroup = server === 'g.us';
268
- const isNewsletter = server === 'newsletter';
269
+ const isNewsletter = server == 'newsletter';
269
270
  const isStatus = jid === statusJid;
270
271
  const isLid = server === 'lid';
271
272
  msgId = msgId || (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id);
@@ -738,11 +739,11 @@ const makeMessagesSocket = (config) => {
738
739
  (disappearingMessagesInChat ? Defaults_1.WA_DEFAULT_EPHEMERAL : 0) :
739
740
  disappearingMessagesInChat;
740
741
  await groupToggleEphemeral(jid, value);
741
- }
742
- else {
743
742
  if (jid.endsWith('@bot')) {
744
743
  jid = (0, WABinary_1.getBotJid)(jid);
745
744
  }
745
+ }
746
+ else {
746
747
  let mediaHandle;
747
748
  const fullMsg = await (0, Utils_1.generateWAMessage)(jid, content, {
748
749
  logger,
@@ -759,8 +760,9 @@ const makeMessagesSocket = (config) => {
759
760
  : undefined
760
761
  }),
761
762
  getProfilePicUrl: sock.profilePictureUrl,
762
- upload: async (readStream, opts) => {
763
- const up = await waUploadToServer(readStream, { ...opts, newsletter: (0, WABinary_1.isJidNewsletter)(jid) });
763
+ //need update 👉
764
+ upload: async (encFilePath, opts) => {
765
+ const up = await waUploadToServer(encFilePath, { ...opts, newsletter: (0, WABinary_1.isJidNewsletter)(jid) });
764
766
  mediaHandle = up.handle;
765
767
  return up;
766
768
  },
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import { SocketConfig, WAMediaUpload, NewsletterMetadata, NewsletterReactionMode, NewsletterViewRole, NewsletterFetchedUpdate } from '../Types';
2
4
  import { BinaryNode } from '../WABinary';
3
5
  export declare const makeNewsletterSocket: (config: SocketConfig) => {
@@ -14,7 +16,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
14
16
  newsletterUnmute: (jid: string) => Promise<void>;
15
17
  newsletterMute: (jid: string) => Promise<void>;
16
18
  newsletterCreate: (name: string, description?: string, picture?: WAMediaUpload) => Promise<NewsletterMetadata>;
17
- newsletterMetadata: (type: "invite" | "jid", key: string, role?: NewsletterViewRole) => Promise<NewsletterMetadata>;
19
+ newsletterMetadata: (type: 'invite' | 'jid', key: string, role?: NewsletterViewRole) => Promise<NewsletterMetadata>;
18
20
  newsletterAdminCount: (jid: string) => Promise<number>;
19
21
  /**user is Lid, not Jid */
20
22
  newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
@@ -23,7 +25,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
23
25
  newsletterDelete: (jid: string) => Promise<void>;
24
26
  /**if code wasn't passed, the reaction will be removed (if is reacted) */
25
27
  newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
26
- newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<NewsletterFetchedUpdate[]>;
28
+ newsletterFetchMessages: (type: 'invite' | 'jid', key: string, count: number, after?: number) => Promise<NewsletterFetchedUpdate[]>;
27
29
  newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<NewsletterFetchedUpdate[]>;
28
30
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
29
31
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
@@ -32,7 +34,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
32
34
  groupRequestParticipantsList: (jid: string) => Promise<{
33
35
  [key: string]: string;
34
36
  }[]>;
35
- groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
37
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
36
38
  status: string;
37
39
  jid: string;
38
40
  }[]>;
@@ -41,43 +43,41 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
41
43
  jid: string;
42
44
  content: BinaryNode;
43
45
  }[]>;
44
- groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
46
+ groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
45
47
  groupInviteCode: (jid: string) => Promise<string | undefined>;
46
48
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
47
49
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
48
50
  groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
49
51
  groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
50
- groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
52
+ groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>; /**user is Lid, not Jid */
51
53
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
52
- groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
53
- groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
54
+ groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
55
+ groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
54
56
  groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
55
57
  groupFetchAllParticipating: () => Promise<{
56
58
  [_: string]: import("../Types").GroupMetadata;
57
59
  }>;
58
60
  getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
59
61
  processingMutex: {
60
- mutex<T>(code: () => Promise<T> | T): Promise<T>;
62
+ mutex<T>(code: () => T | Promise<T>): Promise<T>;
61
63
  };
62
64
  fetchPrivacySettings: (force?: boolean) => Promise<{
63
65
  [_: string]: string;
64
66
  }>;
65
67
  upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
66
68
  appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
67
- sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
68
- presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
69
- profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
69
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
70
+ presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
71
+ profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
70
72
  onWhatsApp: (...jids: string[]) => Promise<{
71
73
  jid: string;
72
74
  exists: unknown;
73
75
  lid: unknown;
74
76
  }[] | undefined>;
75
77
  fetchBlocklist: () => Promise<string[]>;
76
- fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
77
- fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
78
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
79
+ fetchStatus: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
78
80
  updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
79
- updateProfilePictureFull: (jid: string, content: WAMediaUpload) => Promise<void>;
80
- updateProfilePictureFull2: (jid: string, content: WAMediaUpload) => Promise<void>;
81
81
  removeProfilePicture: (jid: string) => Promise<void>;
82
82
  updateProfileStatus: (status: string) => Promise<void>;
83
83
  updateProfileName: (name: string) => Promise<void>;
@@ -91,29 +91,26 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
91
91
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
92
92
  updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
93
93
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
94
- getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
94
+ getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
95
95
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
96
96
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
97
- cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
98
- addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
99
- removeContact: (jid: string) => Promise<void>;
100
- addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
97
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
101
98
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
102
99
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
103
100
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
104
101
  removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
105
102
  star: (jid: string, messages: {
106
103
  id: string;
107
- fromMe?: boolean;
104
+ fromMe?: boolean | undefined;
108
105
  }[], star: boolean) => Promise<void>;
109
- executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
106
+ executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>;
110
107
  type: "md";
111
- ws: import("./Client").WebSocketClient;
108
+ ws: import("./Client/websocket").WebSocketClient;
112
109
  ev: import("../Types").BaileysEventEmitter & {
113
- process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
110
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
114
111
  buffer(): void;
115
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
116
- flush(force?: boolean): boolean;
112
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
113
+ flush(force?: boolean | undefined): boolean;
117
114
  isBuffering(): boolean;
118
115
  };
119
116
  authState: {
@@ -123,18 +120,18 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
123
120
  signalRepository: import("../Types").SignalRepository;
124
121
  user: import("../Types").Contact | undefined;
125
122
  generateMessageTag: () => string;
126
- query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
127
- waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
123
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<any>;
124
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
128
125
  waitForSocketOpen: () => Promise<void>;
129
126
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
130
127
  sendNode: (frame: BinaryNode) => Promise<void>;
131
- logout: (msg?: string) => Promise<void>;
128
+ logout: (msg?: string | undefined) => Promise<void>;
132
129
  end: (error: Error | undefined) => void;
133
- onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
130
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
134
131
  uploadPreKeys: (count?: number) => Promise<void>;
135
132
  uploadPreKeysToServerIfRequired: () => Promise<void>;
136
133
  requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
137
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
134
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number | undefined) => Promise<void>;
138
135
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
139
136
  };
140
137
  export declare const extractNewsletterMetadata: (node: BinaryNode, isCreate?: boolean) => NewsletterMetadata;
@@ -20,6 +20,7 @@ var QueryIds;
20
20
  QueryIds["DEMOTE"] = "6551828931592903";
21
21
  })(QueryIds || (QueryIds = {}));
22
22
  const makeNewsletterSocket = (config) => {
23
+ const { getMessage } = config;
23
24
  const sock = (0, groups_1.makeGroupsSocket)(config);
24
25
  const { authState, signalRepository, query, generateMessageTag } = sock;
25
26
  const encoder = new TextEncoder();
@@ -45,12 +46,7 @@ const makeNewsletterSocket = (config) => {
45
46
  {
46
47
  tag: 'query',
47
48
  attrs: { query_id },
48
- content: encoder.encode(JSON.stringify({
49
- variables: {
50
- 'newsletter_id': jid,
51
- ...content
52
- }
53
- }))
49
+ content: encoder.encode(JSON.stringify({ variables: { newsletter_id: jid, ...content } }))
54
50
  }
55
51
  ]
56
52
  }));
@@ -65,21 +61,30 @@ const makeNewsletterSocket = (config) => {
65
61
  return await Promise.all((0, WABinary_1.getAllBinaryNodeChildren)(child).map(async (messageNode) => {
66
62
  var _a, _b;
67
63
  messageNode.attrs.from = child === null || child === void 0 ? void 0 : child.attrs.jid;
68
- const views = parseInt(((_b = (_a = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'views_count')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.count) || '0');
64
+ const views = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'views_count')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.count;
69
65
  const reactionNode = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'reactions');
70
66
  const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionNode, 'reaction')
71
67
  .map(({ attrs }) => ({ count: +attrs.count, code: attrs.code }));
72
- const data = {
73
- 'server_id': messageNode.attrs.server_id,
74
- views,
75
- reactions
76
- };
68
+ let data;
77
69
  if (type === 'messages') {
78
- const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger, config.getMessage);
70
+ const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger, getMessage);
79
71
  await decrypt();
80
- data.message = message;
72
+ data = {
73
+ server_id: messageNode.attrs.server_id,
74
+ views: views ? +views : undefined,
75
+ reactions,
76
+ message
77
+ };
78
+ return data;
79
+ }
80
+ else {
81
+ data = {
82
+ server_id: messageNode.attrs.server_id,
83
+ views: views ? +views : undefined,
84
+ reactions
85
+ };
86
+ return data;
81
87
  }
82
- return data;
83
88
  }));
84
89
  };
85
90
  return {
@@ -205,11 +210,10 @@ const makeNewsletterSocket = (config) => {
205
210
  });
206
211
  },
207
212
  newsletterFetchMessages: async (type, key, count, after) => {
208
- const afterStr = after === null || after === void 0 ? void 0 : after.toString();
209
213
  const result = await newsletterQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
210
214
  {
211
215
  tag: 'messages',
212
- attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: afterStr || '100' }
216
+ attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: (after === null || after === void 0 ? void 0 : after.toString()) || '100' }
213
217
  }
214
218
  ]);
215
219
  return await parseFetchedUpdates(result, 'messages');