@badzz88/baileys 8.5.4 → 8.5.5

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 (107) hide show
  1. package/README.md +1 -1
  2. package/WAProto/WAProto.proto +75 -1256
  3. package/WAProto/index.d.ts +19729 -36122
  4. package/WAProto/index.js +132193 -178538
  5. package/engine-requirements.js +15 -7
  6. package/lib/Defaults/index.js +14 -22
  7. package/lib/Signal/Group/group_cipher.js +5 -5
  8. package/lib/Signal/Group/keyhelper.js +4 -4
  9. package/lib/Signal/Group/sender-chain-key.js +2 -2
  10. package/lib/Signal/Group/sender-key-distribution-message.js +1 -1
  11. package/lib/Signal/Group/sender-key-message.js +3 -3
  12. package/lib/Signal/Group/sender-key-record.js +1 -1
  13. package/lib/Signal/Group/sender-message-key.js +5 -5
  14. package/lib/Signal/libsignal.js +28 -39
  15. package/lib/Signal/lid-mapping.js +8 -28
  16. package/lib/Socket/aigroups.js +5 -5
  17. package/lib/Socket/business.js +11 -3
  18. package/lib/Socket/chats.js +319 -668
  19. package/lib/Socket/communities.js +89 -85
  20. package/lib/Socket/graphql.js +228 -435
  21. package/lib/Socket/groups.js +211 -132
  22. package/lib/Socket/index.js +7 -9
  23. package/lib/Socket/interactive-handler.js +60 -117
  24. package/lib/Socket/interop.js +175 -56
  25. package/lib/Socket/luxu.js +387 -0
  26. package/lib/Socket/managed-account.js +48 -79
  27. package/lib/Socket/messages-recv.js +340 -898
  28. package/lib/Socket/messages-send.js +160 -462
  29. package/lib/Socket/mex.js +53 -40
  30. package/lib/Socket/newsletter.js +295 -291
  31. package/lib/Socket/privacy.js +265 -77
  32. package/lib/Socket/registration.js +157 -164
  33. package/lib/Socket/socket.js +199 -181
  34. package/lib/Socket/text-router.js +83 -0
  35. package/lib/Socket/username.js +227 -144
  36. package/lib/Store/keyed-db.js +108 -0
  37. package/lib/Store/make-cache-manager-store.js +2 -2
  38. package/lib/Store/make-in-memory-store.js +141 -25
  39. package/lib/Types/Auth.js +3 -3
  40. package/lib/Types/Label.js +1 -1
  41. package/lib/Types/LabelAssociation.js +1 -1
  42. package/lib/Types/Mex.js +112 -0
  43. package/lib/Types/Newsletter.js +65 -96
  44. package/lib/Types/State.js +4 -4
  45. package/lib/Types/index.js +1 -1
  46. package/lib/Utils/auth-utils.js +57 -52
  47. package/lib/Utils/browser-utils.js +1 -1
  48. package/lib/Utils/business.js +6 -2
  49. package/lib/Utils/chat-utils.js +38 -102
  50. package/lib/Utils/command-loader.d.ts +31 -0
  51. package/lib/Utils/command-loader.js +100 -0
  52. package/lib/Utils/companion-reg-client-utils.js +42 -0
  53. package/lib/Utils/crypto.js +84 -54
  54. package/lib/Utils/curve25519-js.js +275 -0
  55. package/lib/Utils/decode-wa-message.js +83 -316
  56. package/lib/Utils/event-buffer.js +61 -37
  57. package/lib/Utils/generics.js +103 -157
  58. package/lib/Utils/group-history.js +12 -3
  59. package/lib/Utils/history.js +15 -15
  60. package/lib/Utils/index.js +5 -1
  61. package/lib/Utils/link-preview.js +8 -3
  62. package/lib/Utils/lt-hash.js +35 -2
  63. package/lib/Utils/make-mutex.js +1 -1
  64. package/lib/Utils/message-retry-manager.js +92 -27
  65. package/lib/Utils/messages-media.js +130 -159
  66. package/lib/Utils/messages.js +566 -144
  67. package/lib/Utils/meta-ai-msmsg.js +202 -62
  68. package/lib/Utils/native-bridge.js +82 -0
  69. package/lib/Utils/noise-handler.js +21 -19
  70. package/lib/Utils/offline-node-processor.js +8 -3
  71. package/lib/Utils/pre-key-manager.js +23 -13
  72. package/lib/Utils/process-message.js +106 -197
  73. package/lib/Utils/reporting-utils.js +2 -2
  74. package/lib/Utils/session-pool.d.ts +16 -0
  75. package/lib/Utils/session-pool.js +94 -0
  76. package/lib/Utils/signal.js +63 -28
  77. package/lib/Utils/stanza-ack.js +12 -39
  78. package/lib/Utils/sticker.d.ts +17 -0
  79. package/lib/Utils/sticker.js +145 -0
  80. package/lib/Utils/sync-action-utils.js +7 -4
  81. package/lib/Utils/tc-token-utils.js +25 -20
  82. package/lib/Utils/use-multi-file-auth-state.js +14 -30
  83. package/lib/Utils/validate-connection.js +19 -59
  84. package/lib/Utils/view-once-cache.d.ts +9 -0
  85. package/lib/Utils/view-once-cache.js +79 -0
  86. package/lib/WABinary/decode.js +16 -50
  87. package/lib/WABinary/encode.js +224 -54
  88. package/lib/WABinary/generic-utils.js +97 -7
  89. package/lib/WABinary/jid-utils.js +14 -27
  90. package/lib/WAM/encode.js +7 -7
  91. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +1 -58
  92. package/lib/WAUSync/Protocols/USyncContactProtocol.js +1 -7
  93. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -13
  94. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +4 -1
  95. package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +7 -20
  96. package/lib/WAUSync/Protocols/USyncPictureProtocol.js +1 -1
  97. package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +2 -2
  98. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -7
  99. package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +1 -1
  100. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +1 -2
  101. package/lib/WAUSync/Protocols/index.js +0 -1
  102. package/lib/WAUSync/USyncQuery.js +6 -77
  103. package/lib/WAUSync/USyncUser.js +8 -16
  104. package/lib/WAUSync/index.js +0 -1
  105. package/lib/antiban.js +854 -608
  106. package/lib/index.js +1 -1
  107. package/package.json +20 -16
@@ -4,38 +4,41 @@ exports.makePrivacySocket = void 0
4
4
 
5
5
  const { executeWMexQuery } = require('./mex')
6
6
 
7
-
7
+ /**
8
+ * MEX query IDs for privacy, status/profile, account/auth, and misc operations.
9
+ * Source: assets/whatsapp-android-mex_client_persist_ids.json
10
+ */
8
11
  const PRIVACY_MEX_IDS = {
9
-
10
- GET_SETTINGS: '32774292262215379',
11
- SET_SETTING: '26887749497493182',
12
- UPDATE_CONTACT_LIST: '26375158178762799',
13
- GET_CONTACT_LIST: '25700444246275822',
14
-
15
- UPDATE_TEXT_STATUS: '25863197129975892',
16
- GET_TEXT_STATUS_LIST: '25741205615468935',
17
- UPDATE_USER_STATUS: '7452341274886724',
18
- FETCH_USER_PICTURE: '24983561624604407',
19
- PROFILE_PICTURE_MUTATION: '24714239711610700',
20
-
21
- ACCOUNT_LOGIN: '27298465499757127',
22
- ACCOUNT_LOGOUT: '26863447609979194',
23
- MULTI_ACCOUNT_REVOKE: '25846242091639661',
24
- ADD_MULTI_ACCOUNT_LINK: '25502812266025193',
25
- ADD_TRUSTED_DEVICE: '24522952587403287',
26
- GET_TRUSTED_DEVICES: '27391232653862770',
27
- UNTRUST_TRUSTED_DEVICE: '26574930682133620',
28
- DELETE_TRUSTED_DEVICE: '33867503889559538',
29
-
30
- MOBILE_CONFIG_FETCH: '25676911271914597',
31
- NOTIFY_PUSH_NAME: '25900490552974543',
32
- CONTACT_INTEGRITY: '25924358997169495',
33
- BIZ_INTEGRITY: '25975613018777537',
34
- LINKED_PROFILES_SET: '25013968611531010',
35
- LINKED_PROFILES_REMOVE: '24537675509265525',
36
- LINKED_PROFILES_UPDATE: '24876967165297614',
37
- MIGRATE_BLOCKLIST_LID: '25028600226770432',
38
- QR_CODE_SCAN: '26287165600869744'
12
+ // Privacy settings
13
+ GET_SETTINGS: '32774292262215380', // GetPrivacySettingsQuery
14
+ SET_SETTING: '26887749497493184', // SetPrivacySettingMutation
15
+ UPDATE_CONTACT_LIST: '26375158178762800', // UpdatePrivacyContactListMutation
16
+ GET_CONTACT_LIST: '25700444246275824', // GetPrivacyContactListQuery
17
+ // Status / profile
18
+ UPDATE_TEXT_STATUS: '25863197129975892', // UpdateTextStatus
19
+ GET_TEXT_STATUS_LIST: '25741205615468936', // GetTextStatusList
20
+ UPDATE_USER_STATUS: '7452341274886724', // UpdateUserStatus
21
+ FETCH_USER_PICTURE: '24983561624604410', // FetchUserPictureInfo
22
+ PROFILE_PICTURE_MUTATION: '24714239711610700', // ProfilePictureMutation
23
+ // Account / auth
24
+ ACCOUNT_LOGIN: '27298465499757130', // AccountLoginMutation
25
+ ACCOUNT_LOGOUT: '26863447609979190', // AccountLogoutMutation
26
+ MULTI_ACCOUNT_REVOKE: '25846242091639660', // MultiAccountRevokeAccount
27
+ ADD_MULTI_ACCOUNT_LINK: '25502812266025190', // AddMultiAccountLink
28
+ ADD_TRUSTED_DEVICE: '24522952587403290', // AddTrustedDeviceMutation
29
+ GET_TRUSTED_DEVICES: '25123358920671964', // GetTrustedDevicesQuery
30
+ UNTRUST_TRUSTED_DEVICE: '26574930682133620', // UntrustTrustedDeviceMutation
31
+ DELETE_TRUSTED_DEVICE: '33867503889559536', // DeleteTrustedDeviceMutation
32
+ // Misc
33
+ MOBILE_CONFIG_FETCH: '25676911271914596', // MobileConfigFetchQuery
34
+ NOTIFY_PUSH_NAME: '25900490552974544', // NotifyPushName
35
+ CONTACT_INTEGRITY: '25924358997169496', // ContactIntegrityQuery
36
+ BIZ_INTEGRITY: '25975613018777536', // BizIntegrityQuery
37
+ LINKED_PROFILES_SET: '25013968611531010', // LinkedProfilesSet
38
+ LINKED_PROFILES_REMOVE: '24537675509265524', // LinkedProfilesRemove
39
+ LINKED_PROFILES_UPDATE: '24876967165297616', // LinkedProfilesUpdate
40
+ MIGRATE_BLOCKLIST_LID: '25028600226770430', // MigrateBlocklistLid
41
+ QR_CODE_SCAN: '26287165600869744' // QRCodeScan
39
42
  }
40
43
 
41
44
  const makePrivacySocket = sock => {
@@ -44,19 +47,45 @@ const makePrivacySocket = sock => {
44
47
  const mexQuery = (variables, queryId, dataPath) =>
45
48
  executeWMexQuery(variables, queryId, dataPath, query, generateMessageTag)
46
49
 
47
-
50
+ // ── Privacy Settings ────────────────────────────────────────────────────
48
51
 
49
-
52
+ /**
53
+ * Fetch all privacy settings via MEX.
54
+ * Confirmed from C24395AkT.java — variables: { users: [{ jid, privacy_features: [...] }] }
55
+ * dataPath: xwa2_fetch_wa_users (array of users, each with privacy_settings[])
56
+ *
57
+ * @param {string} jid - Own JID
58
+ * @param {string[]} [features] - Privacy features to fetch (default: all known)
59
+ */
50
60
  const getPrivacySettings = (jid, features = null) => {
51
61
  const users = [{ jid, ...(features ? { privacy_features: features } : {}) }]
52
62
  return mexQuery({ users }, PRIVACY_MEX_IDS.GET_SETTINGS, 'xwa2_fetch_wa_users')
53
63
  }
54
64
 
55
-
65
+ /**
66
+ * Set a privacy setting via MEX.
67
+ * Confirmed from C24403Akb.java — variables: { feature, setting }
68
+ * dataPath: xwa2_privacy_feature_update
69
+ *
70
+ * Known features: "LAST_SEEN", "ONLINE", "PROFILE_PHOTO", "STATUS", "READ_RECEIPTS",
71
+ * "GROUPS", "CALLS", "SCREENSHOT", "LIVE_LOCATION"
72
+ * Known settings: "ALL", "CONTACTS", "CONTACT_BLACKLIST", "NONE"
73
+ *
74
+ * @param {string} feature - Privacy feature name
75
+ * @param {string} setting - New value
76
+ */
56
77
  const setPrivacySetting = (feature, setting) =>
57
78
  mexQuery({ feature, setting }, PRIVACY_MEX_IDS.SET_SETTING, 'xwa2_privacy_feature_update')
58
79
 
59
-
80
+ /**
81
+ * Update the contact list for a privacy setting (e.g. "GROUPS" with CONTACT_BLACKLIST).
82
+ * Confirmed from InteropPrivacySettingWithContactListUpdate pattern.
83
+ * dataPath: xwa2_privacy_contact_list_update
84
+ *
85
+ * @param {string} feature - Privacy feature
86
+ * @param {string} setting - "CONTACT_BLACKLIST" | "CONTACTS"
87
+ * @param {string[]} jids - List of JIDs to include in the list
88
+ */
60
89
  const updatePrivacyContactList = (feature, setting, jids) =>
61
90
  mexQuery(
62
91
  { feature, setting, contacts: jids.map(jid => ({ jid })) },
@@ -64,33 +93,73 @@ const makePrivacySocket = sock => {
64
93
  'xwa2_privacy_contact_list_update'
65
94
  )
66
95
 
67
-
96
+ /**
97
+ * Fetch the contact list for a privacy setting.
98
+ * dataPath: xwa2_privacy_contact_list
99
+ *
100
+ * @param {string} feature - Privacy feature
101
+ * @param {string} setting - "CONTACT_BLACKLIST" | "CONTACTS"
102
+ */
68
103
  const getPrivacyContactList = (feature, setting) =>
69
104
  mexQuery({ feature, setting }, PRIVACY_MEX_IDS.GET_CONTACT_LIST, 'xwa2_privacy_contact_list')
70
105
 
71
-
72
-
73
-
106
+ // ── Status / Profile ───────────────────────────────────────────────────
107
+
108
+ /**
109
+ * Update own text status (About/Evolved About) via MEX.
110
+ * Confirmed from C227219wi.java:
111
+ * text_status_input: { text, emoji: { content } }
112
+ * dataPath: xwa2_text_status_update
113
+ *
114
+ * @param {string} text - Status text
115
+ * @param {string} [emoji] - Optional emoji to attach
116
+ */
74
117
  const updateTextStatus = (text, emoji = null) => {
75
118
  const input = { text }
76
119
  if (emoji) input.emoji = { content: emoji }
77
120
  return mexQuery({ text_status_input: input }, PRIVACY_MEX_IDS.UPDATE_TEXT_STATUS, 'xwa2_text_status_update')
78
121
  }
79
122
 
80
-
123
+ /**
124
+ * Fetch text statuses (About) for a list of JIDs via MEX.
125
+ * Confirmed from C227219wi.java:
126
+ * input: [{ jid, last_update_time: null }]
127
+ * dataPath: xwa2_text_status_list
128
+ *
129
+ * @param {string[]} jids - JIDs to fetch statuses for
130
+ * @param {number|null} [lastUpdateTime] - Only return statuses newer than this timestamp
131
+ */
81
132
  const getTextStatusList = (jids, lastUpdateTime = null) => {
82
133
  const input = jids.map(jid => ({ jid, last_update_time: lastUpdateTime }))
83
134
  return mexQuery({ input }, PRIVACY_MEX_IDS.GET_TEXT_STATUS_LIST, 'xwa2_text_status_list')
84
135
  }
85
136
 
86
-
87
- const updateUserStatus = status => mexQuery({ status }, PRIVACY_MEX_IDS.UPDATE_USER_STATUS, 'xwa2_update_user_status')
88
-
89
-
137
+ /**
138
+ * Update own user status string via MEX.
139
+ * Confirmed from UpdateUserStatus mutation — variables: { status }
140
+ * dataPath: xwa2_update_user_status
141
+ *
142
+ * @param {string} status - New status string
143
+ */
144
+ const updateUserStatus = status =>
145
+ mexQuery({ status }, PRIVACY_MEX_IDS.UPDATE_USER_STATUS, 'xwa2_update_user_status')
146
+
147
+ /**
148
+ * Fetch picture info for a user via MEX.
149
+ * dataPath: xwa2_fetch_user_picture_info
150
+ *
151
+ * @param {string} jid - JID to fetch picture info for
152
+ */
90
153
  const fetchUserPictureInfo = jid =>
91
154
  mexQuery({ jid }, PRIVACY_MEX_IDS.FETCH_USER_PICTURE, 'xwa2_fetch_user_picture_info')
92
155
 
93
-
156
+ /**
157
+ * Set own profile picture via MEX.
158
+ * dataPath: xwa2_profile_picture_mutation
159
+ *
160
+ * @param {string} imageBase64 - Base64-encoded image data
161
+ * @param {'image'|'preview'} [type='image'] - Picture type
162
+ */
94
163
  const setProfilePictureMex = (imageBase64, type = 'image') =>
95
164
  mexQuery(
96
165
  { input: { image: imageBase64, type } },
@@ -98,13 +167,28 @@ const makePrivacySocket = sock => {
98
167
  'xwa2_profile_picture_mutation'
99
168
  )
100
169
 
101
-
170
+ // ── Account / Auth ─────────────────────────────────────────────────────
102
171
 
103
-
172
+ /**
173
+ * Mark account as logged-in via MEX (companion device registration flow).
174
+ * Confirmed from LogoutManager.java:
175
+ * input: { phone_number }
176
+ * dataPath: xwa2_account_login
177
+ *
178
+ * @param {string} phoneNumber - Phone number (raw, e.g. "491234567890")
179
+ */
104
180
  const accountLogin = phoneNumber =>
105
181
  mexQuery({ input: { phone_number: phoneNumber } }, PRIVACY_MEX_IDS.ACCOUNT_LOGIN, 'xwa2_account_login')
106
182
 
107
-
183
+ /**
184
+ * Mark account as logged-out via MEX.
185
+ * Confirmed from LogoutManager.java:
186
+ * input: { phone_number, enabled_biometric }
187
+ * dataPath: xwa2_account_logout
188
+ *
189
+ * @param {string} phoneNumber - Phone number
190
+ * @param {boolean} [enabledBiometric=false]
191
+ */
108
192
  const accountLogout = (phoneNumber, enabledBiometric = false) =>
109
193
  mexQuery(
110
194
  { input: { phone_number: phoneNumber, enabled_biometric: enabledBiometric } },
@@ -112,7 +196,14 @@ const makePrivacySocket = sock => {
112
196
  'xwa2_account_logout'
113
197
  )
114
198
 
115
-
199
+ /**
200
+ * Add a multi-account link (secondary account) via MEX.
201
+ * Confirmed from AddMultiAccountLink mutation:
202
+ * input: { phone_number }
203
+ * dataPath: xwa2_add_multi_account_link
204
+ *
205
+ * @param {string} phoneNumber - Phone number of account to link
206
+ */
116
207
  const addMultiAccountLink = phoneNumber =>
117
208
  mexQuery(
118
209
  { input: { phone_number: phoneNumber } },
@@ -120,32 +211,70 @@ const makePrivacySocket = sock => {
120
211
  'xwa2_add_multi_account_link'
121
212
  )
122
213
 
123
-
214
+ /**
215
+ * Add a trusted device (biometric/passkey) via MEX.
216
+ * Confirmed from RegTrustedDeviceGraphQLHelper.java:
217
+ * device_id, device_name
218
+ * dataPath: xwa2_add_trusted_device
219
+ *
220
+ * @param {string} deviceId - Device ID suffix
221
+ * @param {string} deviceName - Human-readable device name
222
+ */
124
223
  const addTrustedDevice = (deviceId, deviceName) =>
125
- mexQuery(
126
- { device_id: deviceId, device_name: deviceName },
127
- PRIVACY_MEX_IDS.ADD_TRUSTED_DEVICE,
128
- 'xwa2_add_trusted_device'
129
- )
224
+ mexQuery({ device_id: deviceId, device_name: deviceName }, PRIVACY_MEX_IDS.ADD_TRUSTED_DEVICE, 'xwa2_add_trusted_device')
130
225
 
131
-
226
+ /**
227
+ * Fetch list of trusted devices for the account via MEX.
228
+ * dataPath: xwa2_get_trusted_devices
229
+ */
132
230
  const getTrustedDevices = () => mexQuery({}, PRIVACY_MEX_IDS.GET_TRUSTED_DEVICES, 'xwa2_get_trusted_devices')
133
231
 
134
-
232
+ /**
233
+ * Untrust (remove) a trusted device via MEX.
234
+ * Confirmed from RegTrustedDeviceGraphQLHelper.java:
235
+ * device_id, reason (default: "REREG")
236
+ * dataPath: xwa2_untrust_trusted_device
237
+ *
238
+ * @param {string} deviceId - Device ID to remove
239
+ * @param {string} [reason='USER_INITIATED']
240
+ */
135
241
  const untrustTrustedDevice = (deviceId, reason = 'USER_INITIATED') =>
136
- mexQuery({ device_id: deviceId, reason }, PRIVACY_MEX_IDS.UNTRUST_TRUSTED_DEVICE, 'xwa2_untrust_trusted_device')
242
+ mexQuery(
243
+ { device_id: deviceId, reason },
244
+ PRIVACY_MEX_IDS.UNTRUST_TRUSTED_DEVICE,
245
+ 'xwa2_untrust_trusted_device'
246
+ )
137
247
 
138
-
248
+ /**
249
+ * Delete a trusted device entirely via MEX.
250
+ * dataPath: xwa2_delete_trusted_device
251
+ *
252
+ * @param {string} deviceId - Device ID to delete
253
+ */
139
254
  const deleteTrustedDevice = deviceId =>
140
255
  mexQuery({ device_id: deviceId }, PRIVACY_MEX_IDS.DELETE_TRUSTED_DEVICE, 'xwa2_delete_trusted_device')
141
256
 
142
-
257
+ /**
258
+ * Revoke multi-account link for a secondary account via MEX.
259
+ * dataPath: xwa2_multi_account_revoke
260
+ *
261
+ * @param {string} accountJid - JID of the account to revoke
262
+ */
143
263
  const revokeMultiAccount = accountJid =>
144
264
  mexQuery({ account_jid: accountJid }, PRIVACY_MEX_IDS.MULTI_ACCOUNT_REVOKE, 'xwa2_multi_account_revoke')
145
265
 
146
-
147
-
148
-
266
+ // ── Misc ───────────────────────────────────────────────────────────────
267
+
268
+ /**
269
+ * Fetch mobile config via MEX.
270
+ * Confirmed from C28889Clt.java:
271
+ * api_version, ep_refresh_id, flags
272
+ * dataPath: xwa2_mobile_config_fetch
273
+ *
274
+ * @param {number} [apiVersion=0]
275
+ * @param {number} [epRefreshId=0]
276
+ * @param {string} [flags='']
277
+ */
149
278
  const fetchMobileConfig = (apiVersion = 0, epRefreshId = 0, flags = '') =>
150
279
  mexQuery(
151
280
  { api_version: apiVersion, ep_refresh_id: epRefreshId, flags },
@@ -153,7 +282,15 @@ const makePrivacySocket = sock => {
153
282
  'xwa2_mobile_config_fetch'
154
283
  )
155
284
 
156
-
285
+ /**
286
+ * Notify group members of your push name via MEX.
287
+ * Confirmed from C128275fj.java:
288
+ * input: { group_jid, participants: [{ jid, push_name }] }
289
+ * dataPath: xwa2_notify_push_name
290
+ *
291
+ * @param {string} groupJid - Group JID
292
+ * @param {{ jid: string, pushName: string }[]} participants
293
+ */
157
294
  const notifyPushName = (groupJid, participants) =>
158
295
  mexQuery(
159
296
  {
@@ -166,7 +303,14 @@ const makePrivacySocket = sock => {
166
303
  'xwa2_notify_push_name'
167
304
  )
168
305
 
169
-
306
+ /**
307
+ * Run a contact integrity check via MEX.
308
+ * Confirmed from RunnableC24106Aep.java — uses xwa2_fetch_wa_users path.
309
+ * use_case: "START_CHAT_CONTEXT"
310
+ *
311
+ * @param {string[]} jids - JIDs to check
312
+ * @param {string} [useCase='START_CHAT_CONTEXT']
313
+ */
170
314
  const contactIntegrityQuery = (jids, useCase = 'START_CHAT_CONTEXT') =>
171
315
  mexQuery(
172
316
  { users: jids.map(jid => ({ jid })), use_case: useCase },
@@ -174,11 +318,28 @@ const makePrivacySocket = sock => {
174
318
  'xwa2_fetch_wa_users'
175
319
  )
176
320
 
177
-
321
+ /**
322
+ * Run a business integrity check via MEX.
323
+ * Confirmed from BizIntegrityQuery — variables: { users: [{ jid }] }
324
+ * dataPath: xwa2_fetch_wa_users
325
+ *
326
+ * @param {string[]} jids - Business JIDs to check
327
+ */
178
328
  const bizIntegrityQuery = jids =>
179
- mexQuery({ users: jids.map(jid => ({ jid })) }, PRIVACY_MEX_IDS.BIZ_INTEGRITY, 'xwa2_fetch_wa_users')
329
+ mexQuery(
330
+ { users: jids.map(jid => ({ jid })) },
331
+ PRIVACY_MEX_IDS.BIZ_INTEGRITY,
332
+ 'xwa2_fetch_wa_users'
333
+ )
180
334
 
181
-
335
+ /**
336
+ * Set linked social profiles (FB/IG) via MEX.
337
+ * Confirmed from C24386Ak3.java:
338
+ * profiles: [{ type: "FB"|"IG", username|vid, encrypted_metadata?, user_info? }]
339
+ * dataPath: xwa2_linked_profiles_set
340
+ *
341
+ * @param {{ type: 'FB'|'IG', username?: string, vid?: string }[]} profiles
342
+ */
182
343
  const linkedProfilesSet = profiles => {
183
344
  const mapped = profiles.map(p => {
184
345
  const entry = { type: p.type }
@@ -189,7 +350,12 @@ const makePrivacySocket = sock => {
189
350
  return mexQuery({ profiles: mapped }, PRIVACY_MEX_IDS.LINKED_PROFILES_SET, 'xwa2_linked_profiles_set')
190
351
  }
191
352
 
192
-
353
+ /**
354
+ * Remove linked social profiles via MEX.
355
+ * dataPath: xwa2_linked_profiles_remove
356
+ *
357
+ * @param {('FB'|'IG')[]} types - Profile types to remove
358
+ */
193
359
  const linkedProfilesRemove = types =>
194
360
  mexQuery(
195
361
  { profiles: types.map(type => ({ type })) },
@@ -197,7 +363,14 @@ const makePrivacySocket = sock => {
197
363
  'xwa2_linked_profiles_remove'
198
364
  )
199
365
 
200
-
366
+ /**
367
+ * Update linked social profile visibility/settings via MEX.
368
+ * Confirmed from LinkedProfilesUpdate mutation:
369
+ * profiles: [{ type, show_on_profile }]
370
+ * dataPath: xwa2_linked_profiles_update
371
+ *
372
+ * @param {{ type: 'FB'|'IG', showOnProfile: boolean }[]} profiles
373
+ */
201
374
  const linkedProfilesUpdate = profiles =>
202
375
  mexQuery(
203
376
  { profiles: profiles.map(({ type, showOnProfile }) => ({ type, show_on_profile: showOnProfile })) },
@@ -205,7 +378,16 @@ const makePrivacySocket = sock => {
205
378
  'xwa2_linked_profiles_update'
206
379
  )
207
380
 
208
-
381
+ /**
382
+ * Migrate blocklist to LID addressing via MEX.
383
+ * Confirmed from C8Eu.java:
384
+ * input: { blocklist: [{ jid }], dhash, dirty_ack }
385
+ * dataPath: xwa2_migrate_blocklist_lid
386
+ *
387
+ * @param {string[]} jids - Blocked JIDs to migrate
388
+ * @param {string} [dhash=''] - Current blocklist hash
389
+ * @param {boolean} [dirtyAck=true]
390
+ */
209
391
  const migrateBlocklistLid = (jids, dhash = '', dirtyAck = true) =>
210
392
  mexQuery(
211
393
  {
@@ -219,23 +401,29 @@ const makePrivacySocket = sock => {
219
401
  'xwa2_migrate_blocklist_lid'
220
402
  )
221
403
 
222
-
223
- const qrCodeScan = qrData => mexQuery({ qr_data: qrData }, PRIVACY_MEX_IDS.QR_CODE_SCAN, 'xwa2_qr_code_scan')
404
+ /**
405
+ * Scan a QR code via MEX (used for linking companion devices).
406
+ * dataPath: xwa2_qr_code_scan
407
+ *
408
+ * @param {string} qrData - Raw QR code data string
409
+ */
410
+ const qrCodeScan = qrData =>
411
+ mexQuery({ qr_data: qrData }, PRIVACY_MEX_IDS.QR_CODE_SCAN, 'xwa2_qr_code_scan')
224
412
 
225
413
  return {
226
414
  ...sock,
227
-
415
+ // Privacy
228
416
  getPrivacySettings,
229
417
  setPrivacySetting,
230
418
  updatePrivacyContactList,
231
419
  getPrivacyContactList,
232
-
420
+ // Status / profile
233
421
  updateTextStatus,
234
422
  getTextStatusList,
235
423
  updateUserStatus,
236
424
  fetchUserPictureInfo,
237
425
  setProfilePictureMex,
238
-
426
+ // Account / auth
239
427
  accountLogin,
240
428
  accountLogout,
241
429
  addMultiAccountLink,
@@ -244,7 +432,7 @@ const makePrivacySocket = sock => {
244
432
  untrustTrustedDevice,
245
433
  deleteTrustedDevice,
246
434
  revokeMultiAccount,
247
-
435
+ // Misc
248
436
  fetchMobileConfig,
249
437
  notifyPushName,
250
438
  contactIntegrityQuery,