dct-dev-private-baileys 1.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 (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.MD +110 -0
  3. package/WAProto/GenerateStatics.sh +4 -0
  4. package/WAProto/WAProto.proto +5619 -0
  5. package/WAProto/index.js +169661 -0
  6. package/engine-requirements.js +10 -0
  7. package/lib/Api/Internet/growagarden.js +30 -0
  8. package/lib/Api/creator.json +12 -0
  9. package/lib/Api/downloader/tiktokdownload.js +132 -0
  10. package/lib/Api/index.js +38 -0
  11. package/lib/Api/nsfw/loli.js +79 -0
  12. package/lib/Api/stalker/githubstalk.js +46 -0
  13. package/lib/Api/stalker/stalkroblox.js +94 -0
  14. package/lib/Api/stalker/tiktokstalk.js +68 -0
  15. package/lib/Api/tools/ssweb.js +38 -0
  16. package/lib/Defaults/baileys-version.json +3 -0
  17. package/lib/Defaults/index.js +122 -0
  18. package/lib/Defaults/phonenumber_mcc.json +223 -0
  19. package/lib/Signal/Group/ciphertext-message.js +15 -0
  20. package/lib/Signal/Group/group-session-builder.js +64 -0
  21. package/lib/Signal/Group/group_cipher.js +96 -0
  22. package/lib/Signal/Group/index.js +57 -0
  23. package/lib/Signal/Group/keyhelper.js +55 -0
  24. package/lib/Signal/Group/queue-job.js +57 -0
  25. package/lib/Signal/Group/sender-chain-key.js +34 -0
  26. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  27. package/lib/Signal/Group/sender-key-message.js +69 -0
  28. package/lib/Signal/Group/sender-key-name.js +51 -0
  29. package/lib/Signal/Group/sender-key-record.js +53 -0
  30. package/lib/Signal/Group/sender-key-state.js +99 -0
  31. package/lib/Signal/Group/sender-message-key.js +29 -0
  32. package/lib/Signal/libsignal.js +174 -0
  33. package/lib/Socket/Client/index.js +18 -0
  34. package/lib/Socket/Client/types.js +13 -0
  35. package/lib/Socket/Client/websocket.js +111 -0
  36. package/lib/Socket/Thandler.js +501 -0
  37. package/lib/Socket/business.js +266 -0
  38. package/lib/Socket/chats.js +1138 -0
  39. package/lib/Socket/communities.js +441 -0
  40. package/lib/Socket/groups.js +332 -0
  41. package/lib/Socket/index.js +43 -0
  42. package/lib/Socket/messages-recv.js +1538 -0
  43. package/lib/Socket/messages-send.js +1207 -0
  44. package/lib/Socket/newsletter.js +379 -0
  45. package/lib/Socket/socket.js +849 -0
  46. package/lib/Socket/usync.js +70 -0
  47. package/lib/Store/index.js +8 -0
  48. package/lib/Store/make-in-memory-store.js +533 -0
  49. package/lib/Store/make-ordered-dictionary.js +81 -0
  50. package/lib/Store/object-repository.js +27 -0
  51. package/lib/Types/Auth.js +2 -0
  52. package/lib/Types/Call.js +2 -0
  53. package/lib/Types/Chat.js +4 -0
  54. package/lib/Types/Contact.js +2 -0
  55. package/lib/Types/Events.js +2 -0
  56. package/lib/Types/GroupMetadata.js +2 -0
  57. package/lib/Types/Label.js +27 -0
  58. package/lib/Types/LabelAssociation.js +9 -0
  59. package/lib/Types/Message.js +7 -0
  60. package/lib/Types/Newsletter.js +18 -0
  61. package/lib/Types/Product.js +2 -0
  62. package/lib/Types/Signal.js +2 -0
  63. package/lib/Types/Socket.js +2 -0
  64. package/lib/Types/State.js +2 -0
  65. package/lib/Types/USync.js +2 -0
  66. package/lib/Types/index.js +42 -0
  67. package/lib/Utils/async-iterable.js +40 -0
  68. package/lib/Utils/audioToBuffer.js +29 -0
  69. package/lib/Utils/auth-utils.js +200 -0
  70. package/lib/Utils/baileys-event-stream.js +67 -0
  71. package/lib/Utils/browser-utils.js +35 -0
  72. package/lib/Utils/business.js +234 -0
  73. package/lib/Utils/chat-utils.js +730 -0
  74. package/lib/Utils/crypto.js +193 -0
  75. package/lib/Utils/decode-wa-message.js +207 -0
  76. package/lib/Utils/event-buffer.js +565 -0
  77. package/lib/Utils/generics.js +432 -0
  78. package/lib/Utils/history.js +94 -0
  79. package/lib/Utils/index.js +36 -0
  80. package/lib/Utils/link-preview.js +126 -0
  81. package/lib/Utils/logger.js +7 -0
  82. package/lib/Utils/lt-hash.js +51 -0
  83. package/lib/Utils/make-mutex.js +43 -0
  84. package/lib/Utils/message-retry-manager.js +128 -0
  85. package/lib/Utils/messages-media.js +926 -0
  86. package/lib/Utils/messages.js +1105 -0
  87. package/lib/Utils/noise-handler.js +150 -0
  88. package/lib/Utils/process-message.js +404 -0
  89. package/lib/Utils/resolveJid.js +48 -0
  90. package/lib/Utils/signal.js +153 -0
  91. package/lib/Utils/streamToBuffer.js +15 -0
  92. package/lib/Utils/use-multi-file-auth-state.js +122 -0
  93. package/lib/Utils/validate-connection.js +229 -0
  94. package/lib/WABinary/constants.js +1303 -0
  95. package/lib/WABinary/decode.js +265 -0
  96. package/lib/WABinary/encode.js +250 -0
  97. package/lib/WABinary/generic-utils.js +110 -0
  98. package/lib/WABinary/index.js +21 -0
  99. package/lib/WABinary/jid-utils.js +85 -0
  100. package/lib/WABinary/types.js +2 -0
  101. package/lib/WAM/BinaryInfo.js +13 -0
  102. package/lib/WAM/constants.js +15350 -0
  103. package/lib/WAM/encode.js +155 -0
  104. package/lib/WAM/index.js +19 -0
  105. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  106. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  107. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  108. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  109. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  110. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  111. package/lib/WAUSync/Protocols/index.js +20 -0
  112. package/lib/WAUSync/USyncQuery.js +89 -0
  113. package/lib/WAUSync/USyncUser.js +26 -0
  114. package/lib/WAUSync/index.js +19 -0
  115. package/lib/index.js +91 -0
  116. package/package.json +127 -0
@@ -0,0 +1,1138 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.makeChatsSocket = void 0;
7
+ const boom_1 = require("@hapi/boom");
8
+ const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
9
+ const WAProto_1 = require("../../WAProto");
10
+ const Defaults_1 = require("../Defaults");
11
+ const Types_1 = require("../Types");
12
+ const Utils_1 = require("../Utils");
13
+ const make_mutex_1 = require("../Utils/make-mutex");
14
+ const process_message_1 = __importDefault(require("../Utils/process-message"));
15
+ const WABinary_1 = require("../WABinary");
16
+ const WAUSync_1 = require("../WAUSync");
17
+ const usync_1 = require("./usync");
18
+ const chalk = require('chalk');
19
+ const MAX_SYNC_ATTEMPTS = 2;
20
+ const SyncState = {
21
+ Connecting: 'connecting',
22
+ AwaitingInitialSync: 'awaiting_initial_sync',
23
+ Syncing: 'syncing',
24
+ Online: 'online'
25
+ };
26
+ const makeChatsSocket = (config) => {
27
+ const {
28
+ logger,
29
+ markOnlineOnConnect,
30
+ fireInitQueries,
31
+ appStateMacVerification,
32
+ shouldIgnoreJid,
33
+ shouldSyncHistoryMessage,
34
+ relayMessage, } = config;
35
+ const sock = (0, usync_1.makeUSyncSocket)(config);
36
+ const { ev, ws, authState, generateMessageTag, sendNode, query, signalRepository, onUnexpectedError, } = sock;
37
+ let privacySettings;
38
+ let syncState = SyncState.Connecting;
39
+ let needToFlushWithAppStateSync = false;
40
+ let pendingAppStateSync = false;
41
+ let awaitingSyncTimeout;
42
+ const processingMutex = (0, make_mutex_1.makeMutex)();
43
+ const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
44
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
45
+ useClones: false,
46
+ max: 5000
47
+ });
48
+ if (!config.placeholderResendCache) {
49
+ config.placeholderResendCache = placeholderResendCache;
50
+ }
51
+ const getAppStateSyncKey = async (keyId) => {
52
+ const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId]);
53
+ return key;
54
+ };
55
+ const fetchPrivacySettings = async (force = false) => {
56
+ if (!privacySettings || force) {
57
+ const { content } = await query({
58
+ tag: 'iq',
59
+ attrs: {
60
+ xmlns: 'privacy',
61
+ to: WABinary_1.S_WHATSAPP_NET,
62
+ type: 'get'
63
+ },
64
+ content: [
65
+ { tag: 'privacy', attrs: {} }
66
+ ]
67
+ });
68
+ privacySettings = (0, WABinary_1.reduceBinaryNodeToDictionary)(content === null || content === void 0 ? void 0 : content[0], 'category');
69
+ }
70
+ return privacySettings;
71
+ };
72
+ const privacyQuery = async (name, value) => {
73
+ await query({
74
+ tag: 'iq',
75
+ attrs: {
76
+ xmlns: 'privacy',
77
+ to: WABinary_1.S_WHATSAPP_NET,
78
+ type: 'set'
79
+ },
80
+ content: [{
81
+ tag: 'privacy',
82
+ attrs: {},
83
+ content: [
84
+ {
85
+ tag: 'category',
86
+ attrs: { name, value }
87
+ }
88
+ ]
89
+ }]
90
+ });
91
+ };
92
+ const updateMessagesPrivacy = async (value) => {
93
+ await privacyQuery('messages', value);
94
+ };
95
+ const updateCallPrivacy = async (value) => {
96
+ await privacyQuery('calladd', value);
97
+ };
98
+ const updateLastSeenPrivacy = async (value) => {
99
+ await privacyQuery('last', value);
100
+ };
101
+ const updateOnlinePrivacy = async (value) => {
102
+ await privacyQuery('online', value);
103
+ };
104
+ const updateProfilePicturePrivacy = async (value) => {
105
+ await privacyQuery('profile', value);
106
+ };
107
+ const updateStatusPrivacy = async (value) => {
108
+ await privacyQuery('status', value);
109
+ };
110
+ const updateReadReceiptsPrivacy = async (value) => {
111
+ await privacyQuery('readreceipts', value);
112
+ };
113
+ const updateGroupsAddPrivacy = async (value) => {
114
+ await privacyQuery('groupadd', value);
115
+ };
116
+ const updateDisableLinkPreviewsPrivacy = async (isPreviewsDisabled) => {
117
+ return chatModify({ disableLinkPreviews: { isPreviewsDisabled } }, '');
118
+ };
119
+ const updateDefaultDisappearingMode = async (duration) => {
120
+ await query({
121
+ tag: 'iq',
122
+ attrs: {
123
+ xmlns: 'disappearing_mode',
124
+ to: WABinary_1.S_WHATSAPP_NET,
125
+ type: 'set'
126
+ },
127
+ content: [{
128
+ tag: 'disappearing_mode',
129
+ attrs: {
130
+ duration: duration.toString()
131
+ }
132
+ }]
133
+ });
134
+ };
135
+ const getBotListV2 = async () => {
136
+ const resp = await query({
137
+ tag: 'iq',
138
+ attrs: {
139
+ xmlns: 'bot',
140
+ to: WABinary_1.S_WHATSAPP_NET,
141
+ type: 'get'
142
+ },
143
+ content: [{
144
+ tag: 'bot',
145
+ attrs: {
146
+ v: '2'
147
+ }
148
+ }]
149
+ });
150
+ const botNode = (0, WABinary_1.getBinaryNodeChild)(resp, 'bot');
151
+ const botList = [];
152
+ for (const section of (0, WABinary_1.getBinaryNodeChildren)(botNode, 'section')) {
153
+ if (section.attrs.type === 'all') {
154
+ for (const bot of (0, WABinary_1.getBinaryNodeChildren)(section, 'bot')) {
155
+ botList.push({
156
+ jid: bot.attrs.jid,
157
+ personaId: bot.attrs['persona_id']
158
+ });
159
+ }
160
+ }
161
+ }
162
+ return botList;
163
+ };
164
+ const onWhatsApp = async (...jids) => {
165
+ const usyncQuery = new WAUSync_1.USyncQuery()
166
+ .withContactProtocol()
167
+ .withLIDProtocol();
168
+ for (const jid of jids) {
169
+ const phone = `+${jid.replace('+', '').split('@')[0].split(':')[0]}`;
170
+ usyncQuery.withUser(new WAUSync_1.USyncUser().withPhone(phone));
171
+ }
172
+ const results = await sock.executeUSyncQuery(usyncQuery);
173
+ if (results) {
174
+ return results.list.filter((a) => !!a.contact).map(({ contact, id, lid }) => ({ jid: id, exists: contact, lid }));
175
+ }
176
+ };
177
+ const fetchStatus = async (...jids) => {
178
+ const usyncQuery = new WAUSync_1.USyncQuery()
179
+ .withStatusProtocol();
180
+ for (const jid of jids) {
181
+ usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid));
182
+ }
183
+ const result = await sock.executeUSyncQuery(usyncQuery);
184
+ if (result) {
185
+ return result.list;
186
+ }
187
+ };
188
+ const cekid = async (link) => {
189
+ try {
190
+ let url;
191
+ try {
192
+ url = new URL(link);
193
+ } catch {
194
+ return {
195
+ link,
196
+ jid: "-",
197
+ exists: false,
198
+ IsBanned: true,
199
+ metadata: "-",
200
+ error: "Invalid link format"
201
+ };
202
+ }
203
+
204
+ const isChannel =
205
+ url.hostname === "whatsapp.com" &&
206
+ url.pathname.startsWith("/channel/");
207
+
208
+ if (!isChannel) {
209
+ return {
210
+ link,
211
+ jid: "-",
212
+ exists: false,
213
+ IsBanned: true,
214
+ metadata: "-",
215
+ error: "Link bukan link channel WhatsApp"
216
+ };
217
+ }
218
+
219
+ const code = url.pathname.split("/channel/")[1]?.split("/")[0];
220
+
221
+ if (!code) {
222
+ return {
223
+ link,
224
+ jid: "-",
225
+ exists: false,
226
+ IsBanned: true,
227
+ metadata: "-",
228
+ error: "Invalid channel code"
229
+ };
230
+ }
231
+
232
+ let data = null;
233
+
234
+ try {
235
+ data = await conn.newsletterMetadata("invite", code);
236
+ } catch {
237
+ data = await conn.newsletterMetadata(code).catch(() => null);
238
+ }
239
+
240
+ if (!data?.id) {
241
+ return {
242
+ link,
243
+ jid: "-",
244
+ exists: false,
245
+ IsBanned: true,
246
+ metadata: "-",
247
+ error: "Gagal mengambil metadata channel"
248
+ };
249
+ }
250
+
251
+ return {
252
+ link,
253
+ jid: data.id,
254
+ exists: true,
255
+ IsBanned: false,
256
+ metadata: {
257
+ id: data.id || "-",
258
+ name: data.name || "-",
259
+ description: data.description || "-",
260
+ subscribers: data.subscribers || "-",
261
+ ownerJid: data.ownerJid || "-",
262
+ invite: data.invite || "-",
263
+ verification: data.verification || "-",
264
+ state: data.state || "-",
265
+ creation: data.creation || "-"
266
+ },
267
+ error: null
268
+ };
269
+
270
+ } catch (e) {
271
+ return {
272
+ link,
273
+ jid: "-",
274
+ exists: false,
275
+ IsBanned: true,
276
+ metadata: "-",
277
+ error: e.message
278
+ };
279
+ }
280
+ };
281
+ const checkStatusWA = async (numberOrJid) => {
282
+ try {
283
+ const jid = numberOrJid.includes('@s.whatsapp.net')
284
+ ? numberOrJid
285
+ : numberOrJid.replace(/[^0-9]/g, '') + '@s.whatsapp.net'
286
+
287
+ const exists = await onWhatsApp(jid)
288
+ if (!exists || !exists[0]?.exists) {
289
+ return {
290
+ jid,
291
+ IsBanned: true,
292
+ Statusbio: "-",
293
+ setAt: "-",
294
+ businessProfile: {
295
+ wid: "-",
296
+ address: "-",
297
+ description: "-",
298
+ website: "-",
299
+ email: "-",
300
+ category: "-",
301
+ business_hours: "-"
302
+ }
303
+ }
304
+ }
305
+
306
+ const fetched = await fetchStatus(jid).catch(() => [])
307
+ const status = fetched?.[0]?.status?.status || "-"
308
+ const setAt = fetched?.[0]?.status?.setAt || "-"
309
+
310
+ const business = await getBusinessProfile(jid).catch(() => null)
311
+
312
+ const businessProfile = business ? {
313
+ wid: business.wid || "-",
314
+ address: business.address || "-",
315
+ description: business.description || "-",
316
+ website: business.website?.[0] || "-",
317
+ email: business.email || "-",
318
+ category: business.category || "-",
319
+ business_hours: business.business_hours || "-"
320
+ } : {
321
+ wid: "-",
322
+ address: "-",
323
+ description: "-",
324
+ website: "-",
325
+ email: "-",
326
+ category: "-",
327
+ business_hours: "-"
328
+ }
329
+
330
+ return {
331
+ jid,
332
+ IsBanned: false,
333
+ Statusbio: status,
334
+ setAt,
335
+ businessProfile
336
+ }
337
+ } catch (e) {
338
+ return {
339
+ jid: numberOrJid,
340
+ IsBanned: true,
341
+ Statusbio: "-",
342
+ setAt: "-",
343
+ businessProfile: {
344
+ wid: "-",
345
+ address: "-",
346
+ description: "-",
347
+ website: "-",
348
+ email: "-",
349
+ category: "-",
350
+ business_hours: "-"
351
+ },
352
+ error: e.message
353
+ }
354
+ }
355
+ };
356
+ const getBusinessProfile = async (jid) => {
357
+ var _a, _b, _c, _d, _e, _f, _g;
358
+ const results = await query({
359
+ tag: 'iq',
360
+ attrs: {
361
+ to: 's.whatsapp.net',
362
+ xmlns: 'w:biz',
363
+ type: 'get'
364
+ },
365
+ content: [{
366
+ tag: 'business_profile',
367
+ attrs: { v: '244' },
368
+ content: [{
369
+ tag: 'profile',
370
+ attrs: { jid }
371
+ }]
372
+ }]
373
+ });
374
+ const profileNode = (0, WABinary_1.getBinaryNodeChild)(results, 'business_profile');
375
+ const profiles = (0, WABinary_1.getBinaryNodeChild)(profileNode, 'profile');
376
+ if (profiles) {
377
+ const address = (0, WABinary_1.getBinaryNodeChild)(profiles, 'address');
378
+ const description = (0, WABinary_1.getBinaryNodeChild)(profiles, 'description');
379
+ const website = (0, WABinary_1.getBinaryNodeChild)(profiles, 'website');
380
+ const email = (0, WABinary_1.getBinaryNodeChild)(profiles, 'email');
381
+ const category = (0, WABinary_1.getBinaryNodeChild)((0, WABinary_1.getBinaryNodeChild)(profiles, 'categories'), 'category');
382
+ const businessHours = (0, WABinary_1.getBinaryNodeChild)(profiles, 'business_hours');
383
+ const businessHoursConfig = businessHours ?
384
+ (0, WABinary_1.getBinaryNodeChildren)(businessHours, 'business_hours_config') :
385
+ undefined;
386
+ const websiteStr = (_a = website === null || website === void 0 ? void 0 : website.content) === null || _a === void 0 ? void 0 : _a.toString();
387
+ return {
388
+ wid: (_b = profiles.attrs) === null || _b === void 0 ? void 0 : _b.jid,
389
+ address: (_c = address === null || address === void 0 ? void 0 : address.content) === null || _c === void 0 ? void 0 : _c.toString(),
390
+ description: ((_d = description === null || description === void 0 ? void 0 : description.content) === null || _d === void 0 ? void 0 : _d.toString()) || '',
391
+ website: websiteStr ? [websiteStr] : [],
392
+ email: (_e = email === null || email === void 0 ? void 0 : email.content) === null || _e === void 0 ? void 0 : _e.toString(),
393
+ category: (_f = category === null || category === void 0 ? void 0 : category.content) === null || _f === void 0 ? void 0 : _f.toString(),
394
+ 'business_hours': {
395
+ timezone: (_g = businessHours === null || businessHours === void 0 ? void 0 : businessHours.attrs) === null || _g === void 0 ? void 0 : _g.timezone,
396
+ 'business_config': businessHoursConfig === null || businessHoursConfig === void 0 ? void 0 : businessHoursConfig.map(({ attrs }) => attrs)
397
+ }
398
+ };
399
+ }
400
+ };
401
+
402
+
403
+ const fetchDisappearingDuration = async (...jids) => {
404
+ const usyncQuery = new WAUSync_1.USyncQuery()
405
+ .withDisappearingModeProtocol();
406
+ for (const jid of jids) {
407
+ usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid));
408
+ }
409
+ const result = await sock.executeUSyncQuery(usyncQuery);
410
+ if (result) {
411
+ return result.list;
412
+ }
413
+ };
414
+ const updateProfilePicture = async (jid, content, dimensions) => {
415
+ let targetJid;
416
+ if (!jid) {
417
+ throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
418
+ }
419
+ if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
420
+ targetJid = (0, WABinary_1.jidNormalizedUser)(jid);
421
+ }
422
+ const { img } = await (0, Utils_1.generateProfilePicture)(content, dimensions);
423
+ await query({
424
+ tag: 'iq',
425
+ attrs: {
426
+ target: targetJid,
427
+ to: WABinary_1.S_WHATSAPP_NET,
428
+ type: 'set',
429
+ xmlns: 'w:profile:picture'
430
+ },
431
+ content: [
432
+ {
433
+ tag: 'picture',
434
+ attrs: { type: 'image' },
435
+ content: img
436
+ }
437
+ ]
438
+ });
439
+ };
440
+ const removeProfilePicture = async (jid) => {
441
+ let targetJid;
442
+ if (!jid) {
443
+ throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
444
+ }
445
+ if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
446
+ targetJid = (0, WABinary_1.jidNormalizedUser)(jid);
447
+ }
448
+ await query({
449
+ tag: 'iq',
450
+ attrs: {
451
+ target: targetJid,
452
+ to: WABinary_1.S_WHATSAPP_NET,
453
+ type: 'set',
454
+ xmlns: 'w:profile:picture'
455
+ }
456
+ });
457
+ };
458
+ const updateProfileStatus = async (status) => {
459
+ await query({
460
+ tag: 'iq',
461
+ attrs: {
462
+ to: WABinary_1.S_WHATSAPP_NET,
463
+ type: 'set',
464
+ xmlns: 'status'
465
+ },
466
+ content: [
467
+ {
468
+ tag: 'status',
469
+ attrs: {},
470
+ content: Buffer.from(status, 'utf-8')
471
+ }
472
+ ]
473
+ });
474
+ };
475
+ const updateProfileName = async (name) => {
476
+ await chatModify({ pushNameSetting: name }, '');
477
+ };
478
+ const fetchBlocklist = async () => {
479
+ const result = await query({
480
+ tag: 'iq',
481
+ attrs: {
482
+ xmlns: 'blocklist',
483
+ to: WABinary_1.S_WHATSAPP_NET,
484
+ type: 'get'
485
+ }
486
+ });
487
+ const listNode = (0, WABinary_1.getBinaryNodeChild)(result, 'list');
488
+ return (0, WABinary_1.getBinaryNodeChildren)(listNode, 'item')
489
+ .map(n => n.attrs.jid);
490
+ };
491
+ const updateBlockStatus = async (jid, action) => {
492
+ await query({
493
+ tag: 'iq',
494
+ attrs: {
495
+ xmlns: 'blocklist',
496
+ to: WABinary_1.S_WHATSAPP_NET,
497
+ type: 'set'
498
+ },
499
+ content: [
500
+ {
501
+ tag: 'item',
502
+ attrs: {
503
+ action,
504
+ jid
505
+ }
506
+ }
507
+ ]
508
+ });
509
+ };
510
+
511
+ const cleanDirtyBits = async (type, fromTimestamp) => {
512
+ logger.info({ fromTimestamp }, 'clean dirty bits ' + type);
513
+ await sendNode({
514
+ tag: 'iq',
515
+ attrs: {
516
+ to: WABinary_1.S_WHATSAPP_NET,
517
+ type: 'set',
518
+ xmlns: 'urn:xmpp:whatsapp:dirty',
519
+ id: generateMessageTag(),
520
+ },
521
+ content: [
522
+ {
523
+ tag: 'clean',
524
+ attrs: {
525
+ type,
526
+ ...(fromTimestamp ? { timestamp: fromTimestamp.toString() } : null),
527
+ }
528
+ }
529
+ ]
530
+ });
531
+ };
532
+ const newAppStateChunkHandler = (isInitialSync) => {
533
+ return {
534
+ onMutation(mutation) {
535
+ (0, Utils_1.processSyncAction)(mutation, ev, authState.creds.me, isInitialSync ? { accountSettings: authState.creds.accountSettings } : undefined, logger);
536
+ }
537
+ };
538
+ };
539
+ const resyncAppState = ev.createBufferedFunction(async (collections, isInitialSync) => {
540
+ const initialVersionMap = {};
541
+ const globalMutationMap = {};
542
+ await authState.keys.transaction(async () => {
543
+ var _a;
544
+ const collectionsToHandle = new Set(collections);
545
+ const attemptsMap = {};
546
+ while (collectionsToHandle.size) {
547
+ const states = {};
548
+ const nodes = [];
549
+ for (const name of collectionsToHandle) {
550
+ const result = await authState.keys.get('app-state-sync-version', [name]);
551
+ let state = result[name];
552
+ if (state) {
553
+ if (typeof initialVersionMap[name] === 'undefined') {
554
+ initialVersionMap[name] = state.version;
555
+ }
556
+ }
557
+ else {
558
+ state = (0, Utils_1.newLTHashState)();
559
+ }
560
+ states[name] = state;
561
+ logger.info(`resyncing ${name} from v${state.version}`);
562
+ nodes.push({
563
+ tag: 'collection',
564
+ attrs: {
565
+ name,
566
+ version: state.version.toString(),
567
+ 'return_snapshot': (!state.version).toString()
568
+ }
569
+ });
570
+ }
571
+ const result = await query({
572
+ tag: 'iq',
573
+ attrs: {
574
+ to: WABinary_1.S_WHATSAPP_NET,
575
+ xmlns: 'w:sync:app:state',
576
+ type: 'set'
577
+ },
578
+ content: [
579
+ {
580
+ tag: 'sync',
581
+ attrs: {},
582
+ content: nodes
583
+ }
584
+ ]
585
+ });
586
+ const decoded = await (0, Utils_1.extractSyncdPatches)(result, config === null || config === void 0 ? void 0 : config.options);
587
+ for (const key in decoded) {
588
+ const name = key;
589
+ const { patches, hasMorePatches, snapshot } = decoded[name];
590
+ try {
591
+ if (snapshot) {
592
+ const { state: newState, mutationMap } = await (0, Utils_1.decodeSyncdSnapshot)(name, snapshot, getAppStateSyncKey, initialVersionMap[name], appStateMacVerification.snapshot);
593
+ states[name] = newState;
594
+ Object.assign(globalMutationMap, mutationMap);
595
+ logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`);
596
+ await authState.keys.set({ 'app-state-sync-version': { [name]: newState } });
597
+ }
598
+ if (patches.length) {
599
+ const { state: newState, mutationMap } = await (0, Utils_1.decodePatches)(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch);
600
+ await authState.keys.set({ 'app-state-sync-version': { [name]: newState } });
601
+ logger.info(`synced ${name} to v${newState.version}`);
602
+ initialVersionMap[name] = newState.version;
603
+ Object.assign(globalMutationMap, mutationMap);
604
+ }
605
+ if (hasMorePatches) {
606
+ logger.info(`${name} has more patches...`);
607
+ }
608
+ else {
609
+ collectionsToHandle.delete(name);
610
+ }
611
+ }
612
+ catch (error) {
613
+ const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS
614
+ || ((_a = error.output) === null || _a === void 0 ? void 0 : _a.statusCode) === 404
615
+ || error.name === 'TypeError';
616
+ logger.info({ name, error: error.stack }, `failed to sync state from version${isIrrecoverableError ? '' : ', removing and trying from scratch'}`);
617
+ await authState.keys.set({ 'app-state-sync-version': { [name]: null } });
618
+ attemptsMap[name] = (attemptsMap[name] || 0) + 1;
619
+ if (isIrrecoverableError) {
620
+ collectionsToHandle.delete(name);
621
+ }
622
+ }
623
+ }
624
+ }
625
+ });
626
+ const { onMutation } = newAppStateChunkHandler(isInitialSync);
627
+ for (const key in globalMutationMap) {
628
+ onMutation(globalMutationMap[key]);
629
+ }
630
+ });
631
+ const profilePictureUrl = async (jid, type = 'preview', timeoutMs) => {
632
+ var _a;
633
+ jid = (0, WABinary_1.jidNormalizedUser)(jid);
634
+ try {
635
+ const result = await query({
636
+ tag: 'iq',
637
+ attrs: {
638
+ target: jid,
639
+ to: WABinary_1.S_WHATSAPP_NET,
640
+ type: 'get',
641
+ xmlns: 'w:profile:picture'
642
+ },
643
+ content: [
644
+ { tag: 'picture', attrs: { type, query: 'url' } }
645
+ ]
646
+ }, timeoutMs);
647
+ const child = (0, WABinary_1.getBinaryNodeChild)(result, 'picture');
648
+ return (_a = child === null || child === void 0 ? void 0 : child.attrs) === null || _a === void 0 ? void 0 : _a.url;
649
+ } catch (error) {
650
+ if (error.message?.includes('item-not-found') ||
651
+ error.output?.payload?.statusCode === 404 ||
652
+ error.statusCode === 404) {
653
+ logger.info(chalk.gray(`[INFO] Profile pic not found for ${jid}, using fallback`));
654
+ return {
655
+ eurl: undefined,
656
+ id: jid.split('@')[0],
657
+ status: null,
658
+ img: null
659
+ };
660
+ }
661
+ throw error;
662
+ }
663
+ };
664
+ const createCallLink = async (type, event, timeoutMs) => {
665
+ const result = await query({
666
+ tag: 'call',
667
+ attrs: {
668
+ id: generateMessageTag(),
669
+ to: '@call'
670
+ },
671
+ content: [
672
+ {
673
+ tag: 'link_create',
674
+ attrs: { media: type },
675
+ content: event ? [{ tag: 'event', attrs: { start_time: String(event.startTime) } }] : undefined
676
+ }
677
+ ]
678
+ }, timeoutMs);
679
+ const child = (0, WABinary_1.getBinaryNodeChild)(result, 'link_create');
680
+ return child?.attrs?.token;
681
+ };
682
+ const sendPresenceUpdate = async (type, toJid) => {
683
+ const me = authState.creds.me;
684
+ if (type === 'available' || type === 'unavailable') {
685
+ if (!me.name) {
686
+ logger.warn('no name present, ignoring presence update request...');
687
+ return;
688
+ }
689
+ ev.emit('connection.update', { isOnline: type === 'available' });
690
+ await sendNode({
691
+ tag: 'presence',
692
+ attrs: {
693
+ name: me.name.replace(/@/g, ''),
694
+ type
695
+ }
696
+ });
697
+ }
698
+ else {
699
+ const { server } = (0, WABinary_1.jidDecode)(toJid);
700
+ const isLid = server === 'lid';
701
+ await sendNode({
702
+ tag: 'chatstate',
703
+ attrs: {
704
+ from: isLid ? me.lid : me.id,
705
+ to: toJid,
706
+ },
707
+ content: [
708
+ {
709
+ tag: type === 'recording' ? 'composing' : type,
710
+ attrs: type === 'recording' ? { media: 'audio' } : {}
711
+ }
712
+ ]
713
+ });
714
+ }
715
+ };
716
+ const presenceSubscribe = (toJid, tcToken) => (sendNode({
717
+ tag: 'presence',
718
+ attrs: {
719
+ to: toJid,
720
+ id: generateMessageTag(),
721
+ type: 'subscribe'
722
+ },
723
+ content: tcToken
724
+ ? [
725
+ {
726
+ tag: 'tctoken',
727
+ attrs: {},
728
+ content: tcToken
729
+ }
730
+ ]
731
+ : undefined
732
+ }));
733
+ const handlePresenceUpdate = ({ tag, attrs, content }) => {
734
+ var _a;
735
+ let presence;
736
+ const jid = attrs.from;
737
+ const participant = attrs.participant || attrs.from;
738
+ if (shouldIgnoreJid(jid) && jid != '@s.whatsapp.net') {
739
+ return;
740
+ }
741
+ if (tag === 'presence') {
742
+ presence = {
743
+ lastKnownPresence: attrs.type === 'unavailable' ? 'unavailable' : 'available',
744
+ lastSeen: attrs.last && attrs.last !== 'deny' ? +attrs.last : undefined
745
+ };
746
+ }
747
+ else if (Array.isArray(content)) {
748
+ const [firstChild] = content;
749
+ let type = firstChild.tag;
750
+ if (type === 'paused') {
751
+ type = 'available';
752
+ }
753
+ if (((_a = firstChild.attrs) === null || _a === void 0 ? void 0 : _a.media) === 'audio') {
754
+ type = 'recording';
755
+ }
756
+ presence = { lastKnownPresence: type };
757
+ }
758
+ else {
759
+ logger.error({ tag, attrs, content }, 'recv invalid presence node');
760
+ }
761
+ if (presence) {
762
+ ev.emit('presence.update', { id: jid, presences: { [participant]: presence } });
763
+ }
764
+ };
765
+ const appPatch = async (patchCreate) => {
766
+ const name = patchCreate.type;
767
+ const myAppStateKeyId = authState.creds.myAppStateKeyId;
768
+ if (!myAppStateKeyId) {
769
+ throw new boom_1.Boom('App state key not present!', { statusCode: 400 });
770
+ }
771
+ let initial;
772
+ let encodeResult;
773
+ await processingMutex.mutex(async () => {
774
+ await authState.keys.transaction(async () => {
775
+ logger.debug({ patch: patchCreate }, 'applying app patch');
776
+ await resyncAppState([name], false);
777
+ const { [name]: currentSyncVersion } = await authState.keys.get('app-state-sync-version', [name]);
778
+ initial = currentSyncVersion || (0, Utils_1.newLTHashState)();
779
+ encodeResult = await (0, Utils_1.encodeSyncdPatch)(patchCreate, myAppStateKeyId, initial, getAppStateSyncKey);
780
+ const { patch, state } = encodeResult;
781
+ const node = {
782
+ tag: 'iq',
783
+ attrs: {
784
+ to: WABinary_1.S_WHATSAPP_NET,
785
+ type: 'set',
786
+ xmlns: 'w:sync:app:state'
787
+ },
788
+ content: [
789
+ {
790
+ tag: 'sync',
791
+ attrs: {},
792
+ content: [
793
+ {
794
+ tag: 'collection',
795
+ attrs: {
796
+ name,
797
+ version: (state.version - 1).toString(),
798
+ 'return_snapshot': 'false'
799
+ },
800
+ content: [
801
+ {
802
+ tag: 'patch',
803
+ attrs: {},
804
+ content: WAProto_1.proto.SyncdPatch.encode(patch).finish()
805
+ }
806
+ ]
807
+ }
808
+ ]
809
+ }
810
+ ]
811
+ };
812
+ await query(node);
813
+ await authState.keys.set({ 'app-state-sync-version': { [name]: state } });
814
+ });
815
+ });
816
+ if (config.emitOwnEvents) {
817
+ const { onMutation } = newAppStateChunkHandler(false);
818
+ const { mutationMap } = await (0, Utils_1.decodePatches)(name, [{ ...encodeResult.patch, version: { version: encodeResult.state.version }, }], initial, getAppStateSyncKey, config.options, undefined, logger);
819
+ for (const key in mutationMap) {
820
+ onMutation(mutationMap[key]);
821
+ }
822
+ }
823
+ };
824
+ const fetchProps = async () => {
825
+ var _a, _b, _c;
826
+ const resultNode = await query({
827
+ tag: 'iq',
828
+ attrs: {
829
+ to: WABinary_1.S_WHATSAPP_NET,
830
+ xmlns: 'w',
831
+ type: 'get',
832
+ },
833
+ content: [
834
+ { tag: 'props', attrs: {
835
+ protocol: '2',
836
+ hash: ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.lastPropHash) || ''
837
+ } }
838
+ ]
839
+ });
840
+ const propsNode = (0, WABinary_1.getBinaryNodeChild)(resultNode, 'props');
841
+ let props = {};
842
+ if (propsNode) {
843
+ if ((_b = propsNode.attrs) === null || _b === void 0 ? void 0 : _b.hash) {
844
+ authState.creds.lastPropHash = (_c = propsNode === null || propsNode === void 0 ? void 0 : propsNode.attrs) === null || _c === void 0 ? void 0 : _c.hash;
845
+ ev.emit('creds.update', authState.creds);
846
+ }
847
+ props = (0, WABinary_1.reduceBinaryNodeToDictionary)(propsNode, 'prop');
848
+ }
849
+ logger.debug('fetched props');
850
+ return props;
851
+ };
852
+ const chatModify = (mod, jid) => {
853
+ const patch = (0, Utils_1.chatModificationToAppPatch)(mod, jid);
854
+ return appPatch(patch);
855
+ };
856
+ const star = (jid, messages, star) => {
857
+ return chatModify({
858
+ star: {
859
+ messages,
860
+ star
861
+ }
862
+ }, jid);
863
+ };
864
+ const addOrEditContact = (jid, contact) => {
865
+ return chatModify({ contact }, jid);
866
+ };
867
+ const removeContact = (jid) => {
868
+ return chatModify({ contact: null }, jid);
869
+ };
870
+
871
+ const addLabelMember = async (jid, label, timestamp = Date.now()) => {
872
+ try {
873
+ return await relayMessage(
874
+ jid,
875
+ {
876
+ protocolMessage: {
877
+ type: 30,
878
+ memberLabel: {
879
+ label,
880
+ labelTimestamp: timestamp
881
+ }
882
+ }
883
+ },
884
+ {}
885
+ )
886
+ } catch (e) {
887
+ logger.error('Failed addLabelMember: ' + e)
888
+ throw e
889
+ }
890
+ }
891
+
892
+ const removeLabelMember = async (jid) => {
893
+ try {
894
+ return await relayMessage(
895
+ jid,
896
+ {
897
+ protocolMessage: {
898
+ type: 30,
899
+ memberLabel: {
900
+ label: ''
901
+ }
902
+ }
903
+ },
904
+ {}
905
+ )
906
+ } catch (e) {
907
+ logger.error('Failed removeLabelMember: ' + e)
908
+ throw e
909
+ }
910
+ }
911
+ const addLabel = (jid, labels) => {
912
+ return chatModify({ addLabel: { ...labels } }, jid);
913
+ };
914
+ const addChatLabel = (jid, labelId) => {
915
+ return chatModify({
916
+ addChatLabel: {
917
+ labelId
918
+ }
919
+ }, jid);
920
+ };
921
+ const removeChatLabel = (jid, labelId) => {
922
+ return chatModify({
923
+ removeChatLabel: {
924
+ labelId
925
+ }
926
+ }, jid);
927
+ };
928
+ const addMessageLabel = (jid, messageId, labelId) => {
929
+ return chatModify({
930
+ addMessageLabel: {
931
+ messageId,
932
+ labelId
933
+ }
934
+ }, jid);
935
+ };
936
+ const removeMessageLabel = (jid, messageId, labelId) => {
937
+ return chatModify({
938
+ removeMessageLabel: {
939
+ messageId,
940
+ labelId
941
+ }
942
+ }, jid);
943
+ };
944
+ const executeInitQueries = async () => {
945
+ await Promise.all([
946
+ fetchProps(),
947
+ fetchBlocklist(),
948
+ fetchPrivacySettings(),
949
+ ]);
950
+ };
951
+ const upsertMessage = ev.createBufferedFunction(async (msg, type) => {
952
+ var _a, _b, _c;
953
+ ev.emit('messages.upsert', { messages: [msg], type });
954
+ if (!!msg.pushName) {
955
+ let jid = msg.key.fromMe ? authState.creds.me.id : (msg.key.participant || msg.key.remoteJid);
956
+ jid = (0, WABinary_1.jidNormalizedUser)(jid);
957
+ if (!msg.key.fromMe) {
958
+ ev.emit('contacts.update', [{ id: jid, notify: msg.pushName, verifiedName: msg.verifiedBizName }]);
959
+ }
960
+ if (msg.key.fromMe && msg.pushName && ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.name) !== msg.pushName) {
961
+ ev.emit('creds.update', { me: { ...authState.creds.me, name: msg.pushName } });
962
+ }
963
+ }
964
+ const historyMsg = (0, Utils_1.getHistoryMsg)(msg.message);
965
+ const shouldProcessHistoryMsg = historyMsg
966
+ ? (shouldSyncHistoryMessage(historyMsg)
967
+ && Defaults_1.PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType))
968
+ : false;
969
+ if (historyMsg && syncState === SyncState.AwaitingInitialSync) {
970
+ if (awaitingSyncTimeout) {
971
+ clearTimeout(awaitingSyncTimeout);
972
+ awaitingSyncTimeout = undefined;
973
+ }
974
+ if (shouldProcessHistoryMsg) {
975
+ syncState = SyncState.Syncing;
976
+ logger.info('Transitioned to Syncing state');
977
+ } else {
978
+ syncState = SyncState.Online;
979
+ logger.info('History sync skipped, transitioning to Online state and flushing buffer');
980
+ ev.flush();
981
+ }
982
+ }
983
+ const doAppStateSync = async () => {
984
+ if (syncState === SyncState.Syncing) {
985
+ logger.info('Doing app state sync');
986
+ await resyncAppState(Types_1.ALL_WA_PATCH_NAMES, true);
987
+ syncState = SyncState.Online;
988
+ logger.info('App state sync complete, transitioning to Online state and flushing buffer');
989
+ ev.flush();
990
+ const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1;
991
+ ev.emit('creds.update', { accountSyncCounter });
992
+ }
993
+ };
994
+ if (historyMsg && !authState.creds.myAppStateKeyId) {
995
+ logger.warn('skipping app state sync, as myAppStateKeyId is not set');
996
+ pendingAppStateSync = true;
997
+ }
998
+ await Promise.all([
999
+ (async () => {
1000
+ if (historyMsg
1001
+ && authState.creds.myAppStateKeyId) {
1002
+ pendingAppStateSync = false;
1003
+ await doAppStateSync();
1004
+ }
1005
+ })(),
1006
+ (0, process_message_1.default)(msg, {
1007
+ signalRepository,
1008
+ shouldProcessHistoryMsg,
1009
+ placeholderResendCache,
1010
+ ev,
1011
+ creds: authState.creds,
1012
+ keyStore: authState.keys,
1013
+ logger,
1014
+ options: config.options,
1015
+ getMessage: config.getMessage,
1016
+ })
1017
+ ]);
1018
+ if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.appStateSyncKeyShare)
1019
+ && pendingAppStateSync) {
1020
+ await doAppStateSync();
1021
+ pendingAppStateSync = false;
1022
+ }
1023
+ });
1024
+ ws.on('CB:presence', handlePresenceUpdate);
1025
+ ws.on('CB:chatstate', handlePresenceUpdate);
1026
+ ws.on('CB:ib,,dirty', async (node) => {
1027
+ const { attrs } = (0, WABinary_1.getBinaryNodeChild)(node, 'dirty');
1028
+ const type = attrs.type;
1029
+ switch (type) {
1030
+ case 'account_sync':
1031
+ if (attrs.timestamp) {
1032
+ let { lastAccountSyncTimestamp } = authState.creds;
1033
+ if (lastAccountSyncTimestamp) {
1034
+ await cleanDirtyBits('account_sync', lastAccountSyncTimestamp);
1035
+ }
1036
+ lastAccountSyncTimestamp = +attrs.timestamp;
1037
+ ev.emit('creds.update', { lastAccountSyncTimestamp });
1038
+ }
1039
+ break;
1040
+ case 'groups':
1041
+ break;
1042
+ default:
1043
+ logger.info({ node }, 'received unknown sync');
1044
+ break;
1045
+ }
1046
+ });
1047
+ ev.on('connection.update', ({ connection, receivedPendingNotifications }) => {
1048
+ var _a;
1049
+ if (connection === 'open') {
1050
+ if (fireInitQueries) {
1051
+ executeInitQueries()
1052
+ .catch(error => onUnexpectedError(error, 'init queries'));
1053
+ }
1054
+ sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
1055
+ .catch(error => onUnexpectedError(error, 'presence update requests'));
1056
+ }
1057
+ if (receivedPendingNotifications &&
1058
+ !((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId)) {
1059
+ ev.buffer();
1060
+ needToFlushWithAppStateSync = true;
1061
+ }
1062
+ if (!receivedPendingNotifications || syncState !== SyncState.Connecting) {
1063
+ return;
1064
+ }
1065
+ syncState = SyncState.AwaitingInitialSync;
1066
+ logger.info('Connection is now AwaitingInitialSync, buffering events');
1067
+ ev.buffer();
1068
+ const willSyncHistory = shouldSyncHistoryMessage(
1069
+ WAProto_1.proto.Message.HistorySyncNotification.create({
1070
+ syncType: WAProto_1.proto.HistorySync.HistorySyncType.RECENT
1071
+ })
1072
+ );
1073
+ if (!willSyncHistory) {
1074
+ logger.info('History sync is disabled by config, not waiting for notification. Transitioning to Online.');
1075
+ syncState = SyncState.Online;
1076
+ setTimeout(() => ev.flush(), 0);
1077
+ return;
1078
+ }
1079
+ logger.info('History sync is enabled, awaiting notification with a 20s timeout.');
1080
+ if (awaitingSyncTimeout) {
1081
+ clearTimeout(awaitingSyncTimeout);
1082
+ }
1083
+ awaitingSyncTimeout = setTimeout(() => {
1084
+ if (syncState === SyncState.AwaitingInitialSync) {
1085
+ logger.warn('Timeout in AwaitingInitialSync, forcing state to Online and flushing buffer');
1086
+ syncState = SyncState.Online;
1087
+ ev.flush();
1088
+ }
1089
+ }, 20000);
1090
+ });
1091
+ return {
1092
+ ...sock,
1093
+ createCallLink,
1094
+ getBotListV2,
1095
+ processingMutex,
1096
+ fetchPrivacySettings,
1097
+ upsertMessage,
1098
+ appPatch,
1099
+ sendPresenceUpdate,
1100
+ presenceSubscribe,
1101
+ profilePictureUrl,
1102
+ onWhatsApp,
1103
+ checkStatusWA,
1104
+ fetchBlocklist,
1105
+ fetchDisappearingDuration,
1106
+ fetchStatus,
1107
+ updateProfilePicture,
1108
+ removeProfilePicture,
1109
+ updateProfileStatus,
1110
+ updateProfileName,
1111
+ updateBlockStatus,
1112
+ updateDisableLinkPreviewsPrivacy,
1113
+ updateCallPrivacy,
1114
+ updateMessagesPrivacy,
1115
+ updateLastSeenPrivacy,
1116
+ updateOnlinePrivacy,
1117
+ updateProfilePicturePrivacy,
1118
+ updateStatusPrivacy,
1119
+ updateReadReceiptsPrivacy,
1120
+ updateGroupsAddPrivacy,
1121
+ updateDefaultDisappearingMode,
1122
+ getBusinessProfile,
1123
+ resyncAppState,
1124
+ chatModify,
1125
+ cleanDirtyBits,
1126
+ addOrEditContact,
1127
+ removeContact,
1128
+ addLabel,
1129
+ addChatLabel,
1130
+ removeChatLabel,
1131
+ addMessageLabel,
1132
+ removeMessageLabel,
1133
+ star,
1134
+ addLabelMember,
1135
+ removeLabelMember
1136
+ };
1137
+ };
1138
+ exports.makeChatsSocket = makeChatsSocket;