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