@badzz88/baileys 8.4.9 → 8.5.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 (153) hide show
  1. package/WAProto/WAProto.proto +6 -347
  2. package/WAProto/fix-imports.js +85 -86
  3. package/WAProto/index.d.ts +25 -4913
  4. package/WAProto/index.js +93 -14069
  5. package/{src → lib}/Defaults/index.js +2 -13
  6. package/{src → lib}/Signal/Group/group_cipher.js +5 -5
  7. package/{src → lib}/Signal/Group/keyhelper.js +4 -4
  8. package/{src → lib}/Signal/Group/sender-chain-key.js +2 -2
  9. package/{src → lib}/Signal/Group/sender-key-distribution-message.js +1 -1
  10. package/{src → lib}/Signal/Group/sender-key-message.js +3 -3
  11. package/{src → lib}/Signal/Group/sender-key-record.js +1 -1
  12. package/{src → lib}/Signal/Group/sender-message-key.js +2 -2
  13. package/{src → lib}/Signal/libsignal.js +26 -6
  14. package/{src → lib}/Socket/chats.js +58 -616
  15. package/{src → lib}/Socket/communities.js +28 -59
  16. package/{src → lib}/Socket/graphql.js +103 -362
  17. package/{src → lib}/Socket/groups.js +29 -77
  18. package/{src → lib}/Socket/index.js +5 -3
  19. package/{src → lib}/Socket/interactive-handler.js +60 -117
  20. package/{src → lib}/Socket/interop.js +19 -36
  21. package/lib/Socket/luxu.js +387 -0
  22. package/{src → lib}/Socket/managed-account.js +27 -58
  23. package/{src → lib}/Socket/messages-recv.js +143 -715
  24. package/{src → lib}/Socket/messages-send.js +102 -412
  25. package/lib/Socket/mex.js +60 -0
  26. package/{src → lib}/Socket/newsletter.js +23 -266
  27. package/{src → lib}/Socket/privacy.js +38 -41
  28. package/{src → lib}/Socket/registration.js +106 -113
  29. package/{src → lib}/Socket/socket.js +101 -88
  30. package/{src → lib}/Socket/text-router.js +17 -1
  31. package/lib/Socket/username.js +243 -0
  32. package/lib/Store/keyed-db.js +108 -0
  33. package/{src → lib}/Store/make-in-memory-store.js +104 -6
  34. package/lib/Types/Mex.js +112 -0
  35. package/{src → lib}/Types/Newsletter.js +41 -72
  36. package/{src → lib}/Types/index.js +1 -0
  37. package/{src → lib}/Utils/chat-utils.js +9 -73
  38. package/lib/Utils/command-loader.d.ts +31 -0
  39. package/lib/Utils/command-loader.js +100 -0
  40. package/lib/Utils/companion-reg-client-utils.js +42 -0
  41. package/lib/Utils/crypto.js +155 -0
  42. package/lib/Utils/curve25519-js.js +275 -0
  43. package/{src → lib}/Utils/decode-wa-message.js +36 -284
  44. package/{src → lib}/Utils/event-buffer.js +27 -6
  45. package/{src → lib}/Utils/generics.js +37 -114
  46. package/{src → lib}/Utils/index.js +5 -1
  47. package/lib/Utils/lt-hash.js +39 -0
  48. package/{src → lib}/Utils/message-retry-manager.js +39 -0
  49. package/{src → lib}/Utils/messages-media.js +58 -105
  50. package/{src → lib}/Utils/messages.js +529 -115
  51. package/lib/Utils/meta-ai-msmsg.js +262 -0
  52. package/lib/Utils/native-bridge.js +82 -0
  53. package/{src → lib}/Utils/noise-handler.js +15 -13
  54. package/{src → lib}/Utils/process-message.js +55 -54
  55. package/{src → lib}/Utils/reporting-utils.js +2 -2
  56. package/lib/Utils/session-pool.d.ts +16 -0
  57. package/lib/Utils/session-pool.js +94 -0
  58. package/{src → lib}/Utils/signal.js +51 -19
  59. package/{src → lib}/Utils/stanza-ack.js +2 -36
  60. package/lib/Utils/sticker.d.ts +17 -0
  61. package/lib/Utils/sticker.js +145 -0
  62. package/{src → lib}/Utils/tc-token-utils.js +1 -1
  63. package/{src → lib}/Utils/validate-connection.js +11 -40
  64. package/lib/Utils/view-once-cache.d.ts +9 -0
  65. package/lib/Utils/view-once-cache.js +79 -0
  66. package/{src → lib}/WABinary/decode.js +4 -38
  67. package/lib/WABinary/encode.js +228 -0
  68. package/{src → lib}/WABinary/generic-utils.js +93 -1
  69. package/{src → lib}/WABinary/jid-utils.js +3 -16
  70. package/{src → lib}/WAM/encode.js +1 -1
  71. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
  72. package/{src → lib}/WAUSync/Protocols/USyncContactProtocol.js +1 -7
  73. package/{src → lib}/WAUSync/Protocols/USyncDeviceProtocol.js +5 -13
  74. package/{src → lib}/WAUSync/Protocols/USyncDisappearingModeProtocol.js +4 -1
  75. package/{src → lib}/WAUSync/Protocols/USyncFeatureProtocol.js +2 -17
  76. package/{src → lib}/WAUSync/Protocols/USyncStatusProtocol.js +2 -7
  77. package/{src → lib}/WAUSync/Protocols/USyncUsernameProtocol.js +1 -2
  78. package/{src → lib}/WAUSync/Protocols/index.js +0 -1
  79. package/{src → lib}/WAUSync/USyncQuery.js +6 -77
  80. package/{src → lib}/WAUSync/USyncUser.js +8 -16
  81. package/{src → lib}/WAUSync/index.js +0 -1
  82. package/{src → lib}/antiban.js +266 -355
  83. package/{src → lib}/index.js +2 -2
  84. package/package.json +18 -15
  85. package/WAProto/fix-import.js +0 -38
  86. package/src/Socket/mex.js +0 -47
  87. package/src/Socket/username.js +0 -234
  88. package/src/Utils/crypto.js +0 -125
  89. package/src/Utils/lt-hash.js +0 -10
  90. package/src/Utils/message-inspect.js +0 -400
  91. package/src/Utils/meta-ai-msmsg.js +0 -133
  92. package/src/WABinary/encode.js +0 -58
  93. package/src/WAUSync/Protocols/USyncBusinessProtocol.js +0 -100
  94. package/src/WAUSync/USyncBackoff.js +0 -31
  95. /package/{src → lib}/Defaults/phonenumber-mcc.json +0 -0
  96. /package/{src → lib}/Signal/Group/ciphertext-message.js +0 -0
  97. /package/{src → lib}/Signal/Group/group-session-builder.js +0 -0
  98. /package/{src → lib}/Signal/Group/index.js +0 -0
  99. /package/{src → lib}/Signal/Group/sender-key-name.js +0 -0
  100. /package/{src → lib}/Signal/Group/sender-key-state.js +0 -0
  101. /package/{src → lib}/Signal/lid-mapping.js +0 -0
  102. /package/{src → lib}/Socket/Client/index.js +0 -0
  103. /package/{src → lib}/Socket/Client/types.js +0 -0
  104. /package/{src → lib}/Socket/Client/websocket.js +0 -0
  105. /package/{src → lib}/Socket/aigroups.js +0 -0
  106. /package/{src → lib}/Socket/business.js +0 -0
  107. /package/{src → lib}/Store/index.js +0 -0
  108. /package/{src → lib}/Store/make-cache-manager-store.js +0 -0
  109. /package/{src → lib}/Store/make-ordered-dictionary.js +0 -0
  110. /package/{src → lib}/Store/object-repository.js +0 -0
  111. /package/{src → lib}/Types/Auth.js +0 -0
  112. /package/{src → lib}/Types/Bussines.js +0 -0
  113. /package/{src → lib}/Types/Call.js +0 -0
  114. /package/{src → lib}/Types/Chat.js +0 -0
  115. /package/{src → lib}/Types/Contact.js +0 -0
  116. /package/{src → lib}/Types/Events.js +0 -0
  117. /package/{src → lib}/Types/GroupMetadata.js +0 -0
  118. /package/{src → lib}/Types/Label.js +0 -0
  119. /package/{src → lib}/Types/LabelAssociation.js +0 -0
  120. /package/{src → lib}/Types/Message.js +0 -0
  121. /package/{src → lib}/Types/Product.js +0 -0
  122. /package/{src → lib}/Types/Signal.js +0 -0
  123. /package/{src → lib}/Types/Socket.js +0 -0
  124. /package/{src → lib}/Types/State.js +0 -0
  125. /package/{src → lib}/Types/USync.js +0 -0
  126. /package/{src → lib}/Utils/auth-utils.js +0 -0
  127. /package/{src → lib}/Utils/browser-utils.js +0 -0
  128. /package/{src → lib}/Utils/business.js +0 -0
  129. /package/{src → lib}/Utils/consumer-application.js +0 -0
  130. /package/{src → lib}/Utils/group-history.js +0 -0
  131. /package/{src → lib}/Utils/history.js +0 -0
  132. /package/{src → lib}/Utils/identity-change-handler.js +0 -0
  133. /package/{src → lib}/Utils/jid-display-normalization.js +0 -0
  134. /package/{src → lib}/Utils/link-preview.js +0 -0
  135. /package/{src → lib}/Utils/logger.js +0 -0
  136. /package/{src → lib}/Utils/make-mutex.js +0 -0
  137. /package/{src → lib}/Utils/message-composer.js +0 -0
  138. /package/{src → lib}/Utils/offline-node-processor.js +0 -0
  139. /package/{src → lib}/Utils/pre-key-manager.js +0 -0
  140. /package/{src → lib}/Utils/sync-action-utils.js +0 -0
  141. /package/{src → lib}/Utils/use-multi-file-auth-state.js +0 -0
  142. /package/{src → lib}/Utils/voip-rekey.js +0 -0
  143. /package/{src → lib}/WABinary/constants.js +0 -0
  144. /package/{src → lib}/WABinary/index.js +0 -0
  145. /package/{src → lib}/WABinary/types.js +0 -0
  146. /package/{src → lib}/WAM/BinaryInfo.js +0 -0
  147. /package/{src → lib}/WAM/constants.js +0 -0
  148. /package/{src → lib}/WAM/index.js +0 -0
  149. /package/{src → lib}/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -0
  150. /package/{src → lib}/WAUSync/Protocols/USyncLIDProtocol.js +0 -0
  151. /package/{src → lib}/WAUSync/Protocols/USyncPictureProtocol.js +0 -0
  152. /package/{src → lib}/WAUSync/Protocols/USyncSidelistProtocol.js +0 -0
  153. /package/{src → lib}/WAUSync/Protocols/USyncTextStatusProtocol.js +0 -0
@@ -0,0 +1,60 @@
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', { value: true })
3
+ exports.executeWMexQuery = void 0
4
+ exports.wMexQuery = void 0
5
+ const { Boom } = require('@hapi/boom')
6
+ const WeaBineri = require('../WABinary')
7
+
8
+ const wMexQuery = (variables, queryId, query, generateMessageTag) => {
9
+ return query({
10
+ tag: 'iq',
11
+ attrs: {
12
+ id: generateMessageTag(),
13
+ type: 'get',
14
+ to: WeaBineri.S_WHATSAPP_NET,
15
+ xmlns: 'w:mex'
16
+ },
17
+ content: [
18
+ {
19
+ tag: 'query',
20
+ attrs: { query_id: queryId },
21
+ content: Buffer.from(JSON.stringify({ variables }), 'utf-8')
22
+ }
23
+ ]
24
+ })
25
+ }
26
+ exports.wMexQuery = wMexQuery
27
+
28
+ const executeWMexQuery = async (variables, queryId, dataPath, query, generateMessageTag) => {
29
+ const result = await wMexQuery(variables, queryId, query, generateMessageTag)
30
+ const child = WeaBineri.getBinaryNodeChild(result, 'result')
31
+ if (child?.content) {
32
+ const str = child.content.toString('utf-8').replace(/^\x00+/, '').trim()
33
+ let data
34
+ try {
35
+ data = JSON.parse(str)
36
+ } catch {
37
+ data = str
38
+ }
39
+ if (typeof data === 'string') {
40
+ return data
41
+ }
42
+ if (data.errors && data.errors.length > 0) {
43
+ const errorMessages = data.errors.map(err => err.message || 'Unknown error').join(', ')
44
+ const firstError = data.errors[0]
45
+ const errorCode = firstError.extensions?.error_code || 400
46
+ throw new Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError })
47
+ }
48
+
49
+ const response = dataPath? data?.data?.[dataPath] : data?.data
50
+ if (typeof response!== 'undefined') {
51
+ return response
52
+ }
53
+ }
54
+
55
+ const action = (dataPath || '').startsWith('xwa2_')
56
+ ? dataPath.substring(5).replace(/_/g, '')
57
+ : dataPath?.replace(/_/g, '')
58
+ throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result })
59
+ }
60
+ exports.executeWMexQuery = executeWMexQuery
@@ -7,117 +7,9 @@ const WABinary_1 = require('../WABinary')
7
7
  const groups_1 = require('./groups')
8
8
  const aigroups_1 = require('./aigroups')
9
9
  const mex_1 = require('./mex')
10
-
11
- /** Map a raw role string from the wire to the NewsletterRole enum. */
12
- const mapNewsletterRole = raw => {
13
- if (!raw) return Types_1.NewsletterRole.GUEST
14
- const upper = String(raw).toUpperCase()
15
- switch (upper) {
16
- case 'OWNER':
17
- return Types_1.NewsletterRole.OWNER
18
- case 'ADMIN':
19
- return Types_1.NewsletterRole.ADMIN
20
- case 'SUBSCRIBER':
21
- return Types_1.NewsletterRole.SUBSCRIBER
22
- default:
23
- return Types_1.NewsletterRole.GUEST
24
- }
25
- }
26
-
27
- /** Map a raw state string from the wire to the NewsletterState enum. */
28
- const mapNewsletterState = raw => {
29
- if (!raw) return Types_1.NewsletterState.UNKNOWN
30
- const upper = String(raw).toUpperCase()
31
- switch (upper) {
32
- case 'ACTIVE':
33
- return Types_1.NewsletterState.ACTIVE
34
- case 'SUSPENDED':
35
- return Types_1.NewsletterState.SUSPENDED
36
- case 'GEO_SUSPENDED':
37
- return Types_1.NewsletterState.GEO_SUSPENDED
38
- default:
39
- return Types_1.NewsletterState.UNKNOWN
40
- }
41
- }
42
-
43
- /** Map a raw reaction setting/codes value from the wire to the NewsletterReactionSetting enum. */
44
- const mapReactionSetting = raw => {
45
- if (!raw) return Types_1.NewsletterReactionSetting.NONE
46
- const upper = String(raw).toUpperCase()
47
- switch (upper) {
48
- case 'ALLOWLIST':
49
- return Types_1.NewsletterReactionSetting.ALLOWLIST
50
- case 'BLOCKLIST':
51
- return Types_1.NewsletterReactionSetting.BLOCKLIST
52
- default:
53
- return Types_1.NewsletterReactionSetting.NONE
54
- }
55
- }
56
-
57
- /**
58
- * Enrich a raw newsletter metadata object with normalised protocol fields.
59
- * Handles both flat objects (direct API result) and objects that nest additional
60
- * data under thread_metadata / viewer_metadata.
61
- */
62
- const mergeDsaCountries = (a, b) => {
63
- if (!a && !b) return null
64
- const merged = [...(Array.isArray(a) ? a : a ? [a] : []), ...(Array.isArray(b) ? b : b ? [b] : [])]
65
- return merged.length ? [...new Set(merged)] : null
66
- }
67
-
68
- const enrichNewsletterMetadata = raw => {
69
- if (!raw || typeof raw !== 'object') return raw
70
- const thread = raw.thread_metadata || {}
71
- const viewer = raw.viewer_metadata || {}
72
- const dsaCountries = mergeDsaCountries(
73
- thread.dsa_eligibility_countries ?? raw.dsa_eligibility_countries ?? null,
74
- thread.dsa_eligible_countries ?? raw.dsa_eligible_countries ?? null
75
- )
76
- return {
77
- ...raw,
78
- role: mapNewsletterRole(viewer.role ?? raw.role),
79
- newsletterState: mapNewsletterState(raw.state ?? thread.state),
80
- reactionSetting: mapReactionSetting(
81
- thread.reaction_codes ?? thread.reaction_setting ?? raw.reaction_codes ?? raw.reaction_setting
82
- ),
83
- dsaEligibilityCountries: dsaCountries,
84
- dsaDecision: thread.dsa_decision ?? raw.dsa_decision ?? null,
85
- pinnedMessage:
86
- thread.pinned_message_server_id ??
87
- thread.pinned_message_id ??
88
- raw.pinned_message_server_id ??
89
- raw.pinned_message_id ??
90
- null,
91
- hasQuestionsFeature: !!(thread.has_questions_feature ?? raw.has_questions_feature ?? false),
92
- hasMusicFeature: !!(
93
- thread.has_music_feature ??
94
- thread.music_enabled ??
95
- raw.has_music_feature ??
96
- raw.music_enabled ??
97
- false
98
- ),
99
- viewsCount:
100
- thread.views_count != null
101
- ? parseInt(thread.views_count, 10)
102
- : raw.views_count != null
103
- ? parseInt(raw.views_count, 10)
104
- : null,
105
- subscriberCount:
106
- thread.subscriber_count != null
107
- ? parseInt(thread.subscriber_count, 10)
108
- : raw.subscriber_count != null
109
- ? parseInt(raw.subscriber_count, 10)
110
- : null
111
- }
112
- }
113
-
114
10
  const parseNewsletterCreateResponse = response => {
115
11
  const { id, thread_metadata: thread, viewer_metadata: viewer } = response
116
- const dsaCountries = mergeDsaCountries(
117
- thread.dsa_eligibility_countries ?? null,
118
- thread.dsa_eligible_countries ?? null
119
- )
120
- const base = {
12
+ return {
121
13
  id: id,
122
14
  owner: undefined,
123
15
  name: thread.name.text,
@@ -130,37 +22,28 @@ const parseNewsletterCreateResponse = response => {
130
22
  id: thread.picture.id,
131
23
  directPath: thread.picture.direct_path
132
24
  },
133
- mute_state: viewer.mute,
134
- role: mapNewsletterRole(viewer.role),
135
- newsletterState: mapNewsletterState(thread.state),
136
- reactionSetting: mapReactionSetting(thread.reaction_codes ?? thread.reaction_setting),
137
- dsaEligibilityCountries: dsaCountries,
138
- dsaDecision: thread.dsa_decision ?? null,
139
- pinnedMessage: thread.pinned_message_server_id ?? thread.pinned_message_id ?? null,
140
- hasQuestionsFeature: !!(thread.has_questions_feature ?? false),
141
- hasMusicFeature: !!(thread.has_music_feature ?? thread.music_enabled ?? false)
25
+ mute_state: viewer.mute
142
26
  }
143
- return base
144
27
  }
145
28
  const parseNewsletterMetadata = result => {
146
29
  if (typeof result !== 'object' || result === null) {
147
30
  return null
148
31
  }
149
32
  if ('id' in result && typeof result.id === 'string') {
150
- return enrichNewsletterMetadata(result)
33
+ return result
151
34
  }
152
35
  if ('result' in result && typeof result.result === 'object' && result.result !== null && 'id' in result.result) {
153
- return enrichNewsletterMetadata(result.result)
36
+ return result.result
154
37
  }
155
38
  return null
156
39
  }
157
40
  const makeNewsletterSocket = config => {
158
41
  const sock = (0, aigroups_1.makeAIGroupsSocket)(config)
159
- const { query, generateMessageTag, sendNode } = sock
42
+ const encoder = new TextDecoder();
43
+ const { query, generateMessageTag } = sock
160
44
  const executeWMexQuery = (variables, queryId, dataPath) => {
161
45
  return (0, mex_1.executeWMexQuery)(variables, queryId, dataPath, query, generateMessageTag)
162
46
  }
163
-
164
47
  const newsletterWMexQuery = async (jid, queryId, content) => (query({
165
48
  tag: 'iq',
166
49
  attrs: {
@@ -226,7 +109,7 @@ const makeNewsletterSocket = config => {
226
109
  return executeWMexQuery(
227
110
  { newsletter_id: jid },
228
111
  Types_1.QueryIds.SUBSCRIBERS,
229
- Types_1.XWAPaths.xwa2_newsletter_followers
112
+ Types_1.XWAPaths.xwa2_newsletter_subscribers
230
113
  )
231
114
  },
232
115
  newsletterMetadata: async (type, key) => {
@@ -247,13 +130,13 @@ const makeNewsletterSocket = config => {
247
130
  return parseNewsletterMetadata(result)
248
131
  },
249
132
  newsletterFollow: jid => {
250
- return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.FOLLOW, Types_1.XWAPaths.xwa2_newsletter_join_v2)
133
+ return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.FOLLOW, Types_1.XWAPaths.xwa2_newsletter_follow)
251
134
  },
252
135
  newsletterUnfollow: jid => {
253
136
  return executeWMexQuery(
254
137
  { newsletter_id: jid },
255
138
  Types_1.QueryIds.UNFOLLOW,
256
- Types_1.XWAPaths.xwa2_newsletter_leave_v2
139
+ Types_1.XWAPaths.xwa2_newsletter_unfollow
257
140
  )
258
141
  },
259
142
  newsletterMute: jid => {
@@ -324,48 +207,6 @@ const makeNewsletterSocket = config => {
324
207
  })
325
208
  return result
326
209
  },
327
- /**
328
- * Find the numeric server_id for a newsletter message by its WhatsApp message ID.
329
- * Fetches the last `limit` messages and scans attrs for a matching message_id.
330
- */
331
- newsletterGetServerId: async (jid, messageId, limit = 50) => {
332
- console.log('[newsletterGetServerId] called jid:', jid, 'messageId:', messageId)
333
- let result
334
- try {
335
- result = await query(
336
- {
337
- tag: 'iq',
338
- attrs: {
339
- id: generateMessageTag(),
340
- type: 'get',
341
- xmlns: 'newsletter',
342
- to: jid
343
- },
344
- content: [{ tag: 'message_updates', attrs: { count: String(limit) } }]
345
- },
346
- 5000
347
- )
348
- } catch (e) {
349
- console.log('[newsletterGetServerId] query error/timeout:', e?.message)
350
- return null
351
- }
352
- console.log('[newsletterGetServerId] result tag:', result?.tag, 'attrs:', JSON.stringify(result?.attrs))
353
- if (!result) return null
354
- const updatesNode = (0, WABinary_1.getBinaryNodeChild)(result, 'message_updates')
355
- const messages = (0, WABinary_1.getBinaryNodeChildren)(updatesNode ?? result, 'message')
356
- console.log(
357
- '[newsletterGetServerId] messages count:',
358
- messages.length,
359
- 'first attrs:',
360
- JSON.stringify(messages[0]?.attrs)
361
- )
362
- for (const msg of messages) {
363
- if (msg.attrs.message_id === messageId || msg.attrs.id === messageId) {
364
- return msg.attrs.server_id ? +msg.attrs.server_id : null
365
- }
366
- }
367
- return null
368
- },
369
210
  subscribeNewsletterUpdates: async jid => {
370
211
  const result = await query({
371
212
  tag: 'iq',
@@ -400,7 +241,7 @@ const makeNewsletterSocket = config => {
400
241
  await executeWMexQuery(
401
242
  { newsletter_id: jid, user_id: userJid },
402
243
  Types_1.QueryIds.DEMOTE,
403
- Types_1.XWAPaths.xwa2_newsletter_admin_demote
244
+ Types_1.XWAPaths.xwa2_newsletter_demote
404
245
  )
405
246
  },
406
247
  newsletterDelete: async jid => {
@@ -487,24 +328,6 @@ const makeNewsletterSocket = config => {
487
328
  })
488
329
  return result
489
330
  },
490
- /**
491
- * Revoke (delete) a message posted to a newsletter.
492
- * @param {string} jid - Newsletter JID
493
- * @param {number|string} serverId - server_id of the message to revoke
494
- */
495
- newsletterRevokeMessage: async (jid, serverId) => {
496
- await sendNode({
497
- tag: 'message',
498
- attrs: {
499
- to: jid,
500
- type: 'text',
501
- edit: '7',
502
- server_id: String(serverId),
503
- id: generateMessageTag()
504
- },
505
- content: []
506
- })
507
- },
508
331
  /**
509
332
  * Pin a newsletter message
510
333
  */
@@ -646,11 +469,7 @@ const makeNewsletterSocket = config => {
646
469
  const { limit = 20, interests = null, sortField = 'SUBSCRIBER_COUNT', sortOrder = 'DESC' } = options
647
470
  const variables = { limit, sort_field: sortField, sort_order: sortOrder }
648
471
  if (interests?.length) variables.interests = interests
649
- return executeWMexQuery(
650
- variables,
651
- Types_1.QueryIds.DIRECTORY_LIST,
652
- Types_1.XWAPaths.xwa2_newsletters_directory_list
653
- )
472
+ return executeWMexQuery(variables, Types_1.QueryIds.DIRECTORY_LIST, Types_1.XWAPaths.xwa2_newsletters_directory_list)
654
473
  },
655
474
  /**
656
475
  * Search the newsletter directory.
@@ -795,11 +614,7 @@ const makeNewsletterSocket = config => {
795
614
  * @param {string} jid - Newsletter JID
796
615
  */
797
616
  newsletterEnableWamo: async jid => {
798
- return executeWMexQuery(
799
- { newsletter_id: jid },
800
- Types_1.QueryIds.WAMO_ENABLE_SUB,
801
- 'xwa2_newsletter_wamo_enable_sub'
802
- )
617
+ return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_ENABLE_SUB, 'xwa2_newsletter_wamo_enable_sub')
803
618
  },
804
619
  /**
805
620
  * Disable Wamo (paid subscription) for a newsletter.
@@ -831,72 +646,44 @@ const makeNewsletterSocket = config => {
831
646
  * @param {string} jid - Newsletter JID
832
647
  */
833
648
  wamoAfsAgeCollection: async jid =>
834
- executeWMexQuery(
835
- { newsletter_id: jid },
836
- Types_1.QueryIds.WAMO_AFS_AGE_COLLECTION,
837
- Types_1.XWAPaths.xwa2_wamo_afs_age_collection
838
- ),
649
+ executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_AFS_AGE_COLLECTION, Types_1.XWAPaths.xwa2_wamo_afs_age_collection),
839
650
  /**
840
651
  * Fetch Wamo asset collection (images/assets for Wamo UI).
841
652
  * @param {string} jid - Newsletter JID
842
653
  */
843
654
  wamoAssetCollection: async jid =>
844
- executeWMexQuery(
845
- { newsletter_id: jid },
846
- Types_1.QueryIds.WAMO_ASSET_COLLECTION,
847
- Types_1.XWAPaths.xwa2_wamo_asset_collection
848
- ),
655
+ executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_ASSET_COLLECTION, Types_1.XWAPaths.xwa2_wamo_asset_collection),
849
656
  /**
850
657
  * Fetch a Wamo ad-hoc notice by ID.
851
658
  * @param {string} noticeId - Notice ID to fetch
852
659
  */
853
660
  wamoFetchAdhocNotice: async noticeId =>
854
- executeWMexQuery(
855
- { notice_id: noticeId },
856
- Types_1.QueryIds.WAMO_FETCH_ADHOC_NOTICE,
857
- Types_1.XWAPaths.xwa2_wamo_fetch_adhoc_notice_by_id
858
- ),
661
+ executeWMexQuery({ notice_id: noticeId }, Types_1.QueryIds.WAMO_FETCH_ADHOC_NOTICE, Types_1.XWAPaths.xwa2_wamo_fetch_adhoc_notice_by_id),
859
662
  /**
860
663
  * Fetch the Wamo identity token for a newsletter.
861
664
  * @param {string} jid - Newsletter JID
862
665
  */
863
666
  wamoFetchIdentityToken: async jid =>
864
- executeWMexQuery(
865
- { newsletter_id: jid },
866
- Types_1.QueryIds.WAMO_FETCH_IDENTITY_TOKEN,
867
- Types_1.XWAPaths.xwa2_wamo_fetch_identity_token
868
- ),
667
+ executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_FETCH_IDENTITY_TOKEN, Types_1.XWAPaths.xwa2_wamo_fetch_identity_token),
869
668
  /**
870
669
  * Get Wamo subscription compliance info.
871
670
  * @param {string} jid - Newsletter JID
872
671
  */
873
672
  wamoSubComplianceInfo: async jid =>
874
- executeWMexQuery(
875
- { newsletter_id: jid },
876
- Types_1.QueryIds.WAMO_SUB_COMPLIANCE_INFO,
877
- Types_1.XWAPaths.xwa2_wamo_sub_get_compliance_info
878
- ),
673
+ executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_SUB_COMPLIANCE_INFO, Types_1.XWAPaths.xwa2_wamo_sub_get_compliance_info),
879
674
  /**
880
675
  * Get the Wamo user ID version for a newsletter.
881
676
  * @param {string} jid - Newsletter JID
882
677
  */
883
678
  wamoUserIdVersion: async jid =>
884
- executeWMexQuery(
885
- { newsletter_id: jid },
886
- Types_1.QueryIds.WAMO_USER_ID_VERSION,
887
- Types_1.XWAPaths.xwa2_wamo_user_id_version
888
- ),
679
+ executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_USER_ID_VERSION, Types_1.XWAPaths.xwa2_wamo_user_id_version),
889
680
  /**
890
681
  * Set the Wamo user ID version for a newsletter.
891
682
  * @param {string} jid - Newsletter JID
892
683
  * @param {number} version - Version to set
893
684
  */
894
685
  wamoSetUserIdVersion: async (jid, version) =>
895
- executeWMexQuery(
896
- { newsletter_id: jid, version },
897
- Types_1.QueryIds.WAMO_SET_USER_ID_VERSION,
898
- Types_1.XWAPaths.xwa2_wamo_set_user_id_version
899
- ),
686
+ executeWMexQuery({ newsletter_id: jid, version }, Types_1.QueryIds.WAMO_SET_USER_ID_VERSION, Types_1.XWAPaths.xwa2_wamo_set_user_id_version),
900
687
  /**
901
688
  * Leave a newsletter (unsubscribe).
902
689
  * @param {string} jid - Newsletter JID
@@ -919,11 +706,7 @@ const makeNewsletterSocket = config => {
919
706
  * @param {string} jid - Newsletter JID
920
707
  */
921
708
  newsletterEnforcements: async jid =>
922
- executeWMexQuery(
923
- { newsletter_id: jid },
924
- Types_1.QueryIds.ENFORCEMENTS,
925
- Types_1.XWAPaths.xwa2_newsletter_enforcements
926
- ),
709
+ executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.ENFORCEMENTS, Types_1.XWAPaths.xwa2_newsletter_enforcements),
927
710
  /**
928
711
  * Fetch user reports for a newsletter (admin action).
929
712
  * @param {string} jid - Newsletter JID
@@ -950,11 +733,7 @@ const makeNewsletterSocket = config => {
950
733
  * @param {string} url - URL to preview
951
734
  */
952
735
  newsletterLinkPreviewCheck: async url =>
953
- executeWMexQuery(
954
- { url },
955
- Types_1.QueryIds.LINK_PREVIEW_CHECK,
956
- Types_1.XWAPaths.xwa2_newsletter_link_preview_check
957
- ),
736
+ executeWMexQuery({ url }, Types_1.QueryIds.LINK_PREVIEW_CHECK, Types_1.XWAPaths.xwa2_newsletter_link_preview_check),
958
737
  /**
959
738
  * Update newsletter verification status (admin/platform action).
960
739
  * @param {string} jid - Newsletter JID
@@ -972,9 +751,9 @@ const makeNewsletterSocket = config => {
972
751
  * @param {string} serverId - Server message ID
973
752
  * @param {boolean} isPaidPartnership
974
753
  */
975
- newsletterLabelPaidPartnership: async (jid, serverId, messageType = 'MESSAGE') =>
754
+ newsletterLabelPaidPartnership: async (jid, serverId, isPaidPartnership) =>
976
755
  executeWMexQuery(
977
- { newsletter_id: jid, server_id: String(serverId), message_type: messageType },
756
+ { newsletter_id: jid, server_id: serverId, is_paid_partnership: isPaidPartnership },
978
757
  Types_1.QueryIds.LABEL_PAID_PARTNERSHIP,
979
758
  Types_1.XWAPaths.xwa2_newsletter_label_paid_partnership
980
759
  ),
@@ -1005,28 +784,6 @@ const makeNewsletterSocket = config => {
1005
784
  Types_1.QueryIds.RANKING_FEATURES,
1006
785
  Types_1.XWAPaths.xwa2_newsletter_ranking_features
1007
786
  ),
1008
- /**
1009
- * Fetch account reachout timelock (rate-limit state for outreach actions).
1010
- */
1011
- fetchReachoutTimelock: async () =>
1012
- executeWMexQuery({}, Types_1.QueryIds.REACHOUT_TIMELOCK, Types_1.XWAPaths.xwa2_fetch_account_reachout_timelock),
1013
- /**
1014
- * Fetch message capping info (daily/weekly send limit status).
1015
- */
1016
- fetchMessageCappingInfo: async () =>
1017
- executeWMexQuery({}, Types_1.QueryIds.MESSAGE_CAPPING_INFO, Types_1.XWAPaths.xwa2_message_capping_info),
1018
- /**
1019
- * Update the response state for a question in a newsletter message.
1020
- * @param {string} jid - Newsletter JID
1021
- * @param {string} serverId - Server message ID of the question
1022
- * @param {string} state - New response state (e.g. 'OPEN', 'CLOSED')
1023
- */
1024
- newsletterQuestionResponseStateUpdate: async (jid, serverId, state) =>
1025
- executeWMexQuery(
1026
- { newsletter_id: jid, server_id: serverId, state },
1027
- Types_1.QueryIds.QUESTION_RESPONSE_STATE_UPDATE,
1028
- Types_1.XWAPaths.xwa2_newsletter_question_response_state_update
1029
- ),
1030
787
  /**
1031
788
  * Send view receipts for newsletter messages (marks them as seen).
1032
789
  * serverMessageIds: array of numeric server-side message IDs.
@@ -10,34 +10,34 @@ const { executeWMexQuery } = require('./mex')
10
10
  */
11
11
  const PRIVACY_MEX_IDS = {
12
12
  // Privacy settings
13
- GET_SETTINGS: '32774292262215379', // GetPrivacySettingsQuery
14
- SET_SETTING: '26887749497493182', // SetPrivacySettingMutation
15
- UPDATE_CONTACT_LIST: '26375158178762799', // UpdatePrivacyContactListMutation
16
- GET_CONTACT_LIST: '25700444246275822', // GetPrivacyContactListQuery
13
+ GET_SETTINGS: '32774292262215380', // GetPrivacySettingsQuery
14
+ SET_SETTING: '26887749497493184', // SetPrivacySettingMutation
15
+ UPDATE_CONTACT_LIST: '26375158178762800', // UpdatePrivacyContactListMutation
16
+ GET_CONTACT_LIST: '25700444246275824', // GetPrivacyContactListQuery
17
17
  // Status / profile
18
18
  UPDATE_TEXT_STATUS: '25863197129975892', // UpdateTextStatus
19
- GET_TEXT_STATUS_LIST: '25741205615468935', // GetTextStatusList
19
+ GET_TEXT_STATUS_LIST: '25741205615468936', // GetTextStatusList
20
20
  UPDATE_USER_STATUS: '7452341274886724', // UpdateUserStatus
21
- FETCH_USER_PICTURE: '24983561624604407', // FetchUserPictureInfo
21
+ FETCH_USER_PICTURE: '24983561624604410', // FetchUserPictureInfo
22
22
  PROFILE_PICTURE_MUTATION: '24714239711610700', // ProfilePictureMutation
23
23
  // Account / auth
24
- ACCOUNT_LOGIN: '27298465499757127', // AccountLoginMutation
25
- ACCOUNT_LOGOUT: '26863447609979194', // AccountLogoutMutation
26
- MULTI_ACCOUNT_REVOKE: '25846242091639661', // MultiAccountRevokeAccount
27
- ADD_MULTI_ACCOUNT_LINK: '25502812266025193', // AddMultiAccountLink
28
- ADD_TRUSTED_DEVICE: '24522952587403287', // AddTrustedDeviceMutation
29
- GET_TRUSTED_DEVICES: '27391232653862770', // GetTrustedDevicesQuery
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
30
  UNTRUST_TRUSTED_DEVICE: '26574930682133620', // UntrustTrustedDeviceMutation
31
- DELETE_TRUSTED_DEVICE: '33867503889559538', // DeleteTrustedDeviceMutation
31
+ DELETE_TRUSTED_DEVICE: '33867503889559536', // DeleteTrustedDeviceMutation
32
32
  // Misc
33
- MOBILE_CONFIG_FETCH: '25676911271914597', // MobileConfigFetchQuery
34
- NOTIFY_PUSH_NAME: '25900490552974543', // NotifyPushName
35
- CONTACT_INTEGRITY: '25924358997169495', // ContactIntegrityQuery
36
- BIZ_INTEGRITY: '25975613018777537', // BizIntegrityQuery
33
+ MOBILE_CONFIG_FETCH: '25676911271914596', // MobileConfigFetchQuery
34
+ NOTIFY_PUSH_NAME: '25900490552974544', // NotifyPushName
35
+ CONTACT_INTEGRITY: '25924358997169496', // ContactIntegrityQuery
36
+ BIZ_INTEGRITY: '25975613018777536', // BizIntegrityQuery
37
37
  LINKED_PROFILES_SET: '25013968611531010', // LinkedProfilesSet
38
- LINKED_PROFILES_REMOVE: '24537675509265525', // LinkedProfilesRemove
39
- LINKED_PROFILES_UPDATE: '24876967165297614', // LinkedProfilesUpdate
40
- MIGRATE_BLOCKLIST_LID: '25028600226770432', // MigrateBlocklistLid
38
+ LINKED_PROFILES_REMOVE: '24537675509265524', // LinkedProfilesRemove
39
+ LINKED_PROFILES_UPDATE: '24876967165297616', // LinkedProfilesUpdate
40
+ MIGRATE_BLOCKLIST_LID: '25028600226770430', // MigrateBlocklistLid
41
41
  QR_CODE_SCAN: '26287165600869744' // QRCodeScan
42
42
  }
43
43
 
@@ -67,18 +67,9 @@ const makePrivacySocket = sock => {
67
67
  * Confirmed from C24403Akb.java — variables: { feature, setting }
68
68
  * dataPath: xwa2_privacy_feature_update
69
69
  *
70
- * Values are lowercase and case-sensitive on the wire (confirmed 2026-07-19 against
71
- * WASmaxInPrivacyEnums / WAWebPrivacySettings) — NOT the uppercase values this doc used to list.
72
- *
73
- * Known features: "last" (last seen), "online", "profile" (photo), "status", "readreceipts",
74
- * "groupadd" (who can add you to groups), "groupcreation", "calladd",
75
- * "defense" (anti-scraping), "messages", "linked_profiles", "cover_photo",
76
- * "dependentaccountmessages", "pix", "stickers"
77
- * (the last 6 are business-account-only)
78
- * Known settings: "all", "contacts", "contact_blacklist", "none" — most features.
79
- * "online" only accepts "all" | "match_last_seen".
80
- * "calladd" only accepts "all" | "contacts" | "known".
81
- * "defense" only accepts "off" | "on_standard".
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"
82
73
  *
83
74
  * @param {string} feature - Privacy feature name
84
75
  * @param {string} setting - New value
@@ -150,7 +141,8 @@ const makePrivacySocket = sock => {
150
141
  *
151
142
  * @param {string} status - New status string
152
143
  */
153
- const updateUserStatus = status => mexQuery({ status }, PRIVACY_MEX_IDS.UPDATE_USER_STATUS, 'xwa2_update_user_status')
144
+ const updateUserStatus = status =>
145
+ mexQuery({ status }, PRIVACY_MEX_IDS.UPDATE_USER_STATUS, 'xwa2_update_user_status')
154
146
 
155
147
  /**
156
148
  * Fetch picture info for a user via MEX.
@@ -229,11 +221,7 @@ const makePrivacySocket = sock => {
229
221
  * @param {string} deviceName - Human-readable device name
230
222
  */
231
223
  const addTrustedDevice = (deviceId, deviceName) =>
232
- mexQuery(
233
- { device_id: deviceId, device_name: deviceName },
234
- PRIVACY_MEX_IDS.ADD_TRUSTED_DEVICE,
235
- 'xwa2_add_trusted_device'
236
- )
224
+ mexQuery({ device_id: deviceId, device_name: deviceName }, PRIVACY_MEX_IDS.ADD_TRUSTED_DEVICE, 'xwa2_add_trusted_device')
237
225
 
238
226
  /**
239
227
  * Fetch list of trusted devices for the account via MEX.
@@ -251,7 +239,11 @@ const makePrivacySocket = sock => {
251
239
  * @param {string} [reason='USER_INITIATED']
252
240
  */
253
241
  const untrustTrustedDevice = (deviceId, reason = 'USER_INITIATED') =>
254
- 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
+ )
255
247
 
256
248
  /**
257
249
  * Delete a trusted device entirely via MEX.
@@ -334,7 +326,11 @@ const makePrivacySocket = sock => {
334
326
  * @param {string[]} jids - Business JIDs to check
335
327
  */
336
328
  const bizIntegrityQuery = jids =>
337
- 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
+ )
338
334
 
339
335
  /**
340
336
  * Set linked social profiles (FB/IG) via MEX.
@@ -411,7 +407,8 @@ const makePrivacySocket = sock => {
411
407
  *
412
408
  * @param {string} qrData - Raw QR code data string
413
409
  */
414
- const qrCodeScan = qrData => mexQuery({ qr_data: qrData }, PRIVACY_MEX_IDS.QR_CODE_SCAN, 'xwa2_qr_code_scan')
410
+ const qrCodeScan = qrData =>
411
+ mexQuery({ qr_data: qrData }, PRIVACY_MEX_IDS.QR_CODE_SCAN, 'xwa2_qr_code_scan')
415
412
 
416
413
  return {
417
414
  ...sock,