@fanzxnothuman/baileys 2.0.17

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 (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +479 -0
  3. package/WAProto/index.js +204542 -0
  4. package/engine-requirements.js +10 -0
  5. package/lib/Defaults/baileys-version.json +3 -0
  6. package/lib/Defaults/index.js +158 -0
  7. package/lib/Defaults/phonenumber-mcc.json +223 -0
  8. package/lib/Function/Download/tiktok.js +19 -0
  9. package/lib/Function/Tools/bypass.js +19 -0
  10. package/lib/Function/index.js +13 -0
  11. package/lib/Signal/Group/ciphertext-message.js +15 -0
  12. package/lib/Signal/Group/group-session-builder.js +99 -0
  13. package/lib/Signal/Group/group_cipher.js +131 -0
  14. package/lib/Signal/Group/index.js +141 -0
  15. package/lib/Signal/Group/keyhelper.js +78 -0
  16. package/lib/Signal/Group/queue-job.js +54 -0
  17. package/lib/Signal/Group/sender-chain-key.js +39 -0
  18. package/lib/Signal/Group/sender-key-distribution-message.js +76 -0
  19. package/lib/Signal/Group/sender-key-message.js +86 -0
  20. package/lib/Signal/Group/sender-key-name.js +53 -0
  21. package/lib/Signal/Group/sender-key-record.js +71 -0
  22. package/lib/Signal/Group/sender-key-state.js +123 -0
  23. package/lib/Signal/Group/sender-message-key.js +33 -0
  24. package/lib/Signal/libsignal.js +223 -0
  25. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  26. package/lib/Socket/Client/index.js +35 -0
  27. package/lib/Socket/Client/mobile-socket-client.js +96 -0
  28. package/lib/Socket/Client/web-socket-client.js +96 -0
  29. package/lib/Socket/business.js +289 -0
  30. package/lib/Socket/chats.js +1230 -0
  31. package/lib/Socket/dugong.js +689 -0
  32. package/lib/Socket/groups.js +401 -0
  33. package/lib/Socket/index.js +12 -0
  34. package/lib/Socket/messages-recv.js +1531 -0
  35. package/lib/Socket/messages-send.js +1011 -0
  36. package/lib/Socket/newsletter.js +526 -0
  37. package/lib/Socket/registration.js +212 -0
  38. package/lib/Socket/socket.js +842 -0
  39. package/lib/Socket/usync.js +67 -0
  40. package/lib/Store/index.js +16 -0
  41. package/lib/Store/make-cache-manager-store.js +90 -0
  42. package/lib/Store/make-in-memory-store.js +520 -0
  43. package/lib/Store/make-ordered-dictionary.js +78 -0
  44. package/lib/Store/object-repository.js +27 -0
  45. package/lib/Types/Auth.js +2 -0
  46. package/lib/Types/Call.js +2 -0
  47. package/lib/Types/Chat.js +10 -0
  48. package/lib/Types/Contact.js +2 -0
  49. package/lib/Types/Events.js +2 -0
  50. package/lib/Types/GroupMetadata.js +2 -0
  51. package/lib/Types/Label.js +27 -0
  52. package/lib/Types/LabelAssociation.js +12 -0
  53. package/lib/Types/Message.js +14 -0
  54. package/lib/Types/Newsletter.js +38 -0
  55. package/lib/Types/Product.js +2 -0
  56. package/lib/Types/Signal.js +2 -0
  57. package/lib/Types/Socket.js +2 -0
  58. package/lib/Types/State.js +2 -0
  59. package/lib/Types/USync.js +2 -0
  60. package/lib/Types/index.js +67 -0
  61. package/lib/Utils/auth-utils.js +223 -0
  62. package/lib/Utils/baileys-event-stream.js +67 -0
  63. package/lib/Utils/business.js +308 -0
  64. package/lib/Utils/chat-utils.js +1030 -0
  65. package/lib/Utils/crypto.js +210 -0
  66. package/lib/Utils/decode-wa-message.js +225 -0
  67. package/lib/Utils/event-buffer.js +559 -0
  68. package/lib/Utils/generics.js +599 -0
  69. package/lib/Utils/history.js +132 -0
  70. package/lib/Utils/index.js +49 -0
  71. package/lib/Utils/link-preview.js +112 -0
  72. package/lib/Utils/logger.js +11 -0
  73. package/lib/Utils/lt-hash.js +58 -0
  74. package/lib/Utils/make-mutex.js +41 -0
  75. package/lib/Utils/messages-media.js +978 -0
  76. package/lib/Utils/messages.js +1052 -0
  77. package/lib/Utils/noise-handler.js +185 -0
  78. package/lib/Utils/process-message.js +466 -0
  79. package/lib/Utils/signal.js +199 -0
  80. package/lib/Utils/use-multi-file-auth-state.js +129 -0
  81. package/lib/Utils/validate-connection.js +285 -0
  82. package/lib/WABinary/constants.js +1307 -0
  83. package/lib/WABinary/decode.js +287 -0
  84. package/lib/WABinary/encode.js +286 -0
  85. package/lib/WABinary/generic-utils.js +227 -0
  86. package/lib/WABinary/index.js +37 -0
  87. package/lib/WABinary/jid-utils.js +92 -0
  88. package/lib/WABinary/types.js +2 -0
  89. package/lib/WAM/BinaryInfo.js +13 -0
  90. package/lib/WAM/constants.js +15260 -0
  91. package/lib/WAM/encode.js +153 -0
  92. package/lib/WAM/index.js +35 -0
  93. package/lib/WAUSync/Protocols/USyncContactProtocol.js +37 -0
  94. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +78 -0
  95. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +35 -0
  96. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +53 -0
  97. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +76 -0
  98. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  99. package/lib/WAUSync/Protocols/index.js +36 -0
  100. package/lib/WAUSync/USyncQuery.js +105 -0
  101. package/lib/WAUSync/USyncUser.js +26 -0
  102. package/lib/WAUSync/index.js +35 -0
  103. package/lib/index.js +65 -0
  104. package/package.json +109 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 z4phdev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,479 @@
1
+ # WhatsApp Baileys
2
+
3
+ <p align="center">
4
+ <img src="https://files.catbox.moe/z33avx.png" alt="Thumbnail" />
5
+ </p>
6
+
7
+ WhatsApp Baileys is a robust open-source library engineered to empower developers in building sophisticated automation solutions and seamless WhatsApp integrations. Leveraging WebSocket technology — entirely browser-free — it delivers a comprehensive suite of capabilities including message management, chat handling, group administration, interactive messages, and dynamic action buttons for an elevated user experience.
8
+
9
+ Continuously developed and actively maintained, Baileys receives consistent updates to strengthen stability and overall performance. A primary area of focus is the refinement of pairing and authentication workflows, ensuring a more resilient and secure connection. Pairing procedures are fully customizable with user-defined codes, significantly reducing the likelihood of failures or unexpected disconnections.
10
+
11
+ This library is purpose-built for constructing enterprise-grade bots, chat automation pipelines, customer service platforms, and a wide spectrum of communication automation applications demanding both high reliability and feature completeness. Its lightweight, modular architecture ensures effortless integration across diverse systems and deployment environments.
12
+
13
+ ---
14
+
15
+ ### Key Features & Advantages
16
+
17
+ - Fully supports both automatic and custom pairing workflows
18
+ - Resolves longstanding pairing instability and disconnection issues
19
+ - Delivers interactive messages, action buttons, and dynamic menu rendering
20
+ - Intelligent session management with minimal overhead for sustained reliability
21
+ - Full compatibility with WhatsApp's latest multi-device architecture
22
+ - Lightweight, stable, and designed for seamless third-party integration
23
+ - Ideal for building bots, automation pipelines, and end-to-end communication solutions
24
+ - Thorough documentation and practical code examples to accelerate development
25
+
26
+ ---
27
+
28
+ ## Getting Started
29
+
30
+ Install the library through your preferred package manager and follow the configuration guide provided. The included example code offers a clear foundation for understanding each feature. Leverage session storage and interactive messaging capabilities to craft stable, production-ready solutions tailored to your specific requirements.
31
+
32
+ ---
33
+
34
+ ## Additional Functions
35
+
36
+ ### Label Group
37
+
38
+ Assign a tag or label to a group member.
39
+
40
+ ```javascript
41
+ await sock.setLabelGroup(jid, string);
42
+ ```
43
+
44
+ ---
45
+
46
+ ### Retrieve Channel ID
47
+
48
+ Fetch the channel identifier from a given URL.
49
+
50
+ ```javascript
51
+ await sock.newsletterFromUrl(url);
52
+ ```
53
+
54
+ Response JSON:
55
+
56
+ ```json
57
+ {
58
+ "name": "Channel Name",
59
+ "id": "Channel ID",
60
+ "state": "Channel Status",
61
+ "subscribers": "Subscriber Count",
62
+ "verification": "UNVERIFIED",
63
+ "creation_time": 1728547155,
64
+ "description": "Channel Description"
65
+ }
66
+ ```
67
+
68
+ ---
69
+
70
+ ### Check Banned Number
71
+
72
+ Verify whether a given number has been blocked or banned.
73
+
74
+ ```javascript
75
+ sock.checkWhatsApp(jid);
76
+ ```
77
+
78
+ ---
79
+
80
+ ## SendMessage Reference
81
+
82
+ ### Status Mention — Group & Private
83
+
84
+ Dispatch a status mention to a group or private conversation.
85
+
86
+ ```javascript
87
+ await sock.sendStatusMention(content, jid);
88
+ ```
89
+
90
+ ### Group Status Message (V2)
91
+
92
+ Send a group status using the Version 2 protocol.
93
+
94
+ ```javascript
95
+ await sock.sendMessage(jid, {
96
+ groupStatusMessage: {
97
+ text: "Your group status message here.",
98
+ },
99
+ });
100
+ ```
101
+
102
+ ### Album Message (Multiple Images)
103
+
104
+ Deliver multiple images as a single cohesive album.
105
+
106
+ ```javascript
107
+ await sock.sendMessage(jid, {
108
+ albumMessage: [
109
+ {
110
+ image: IMAGE,
111
+ caption: "First image caption",
112
+ },
113
+ {
114
+ image: { url: "YOUR_IMAGE_URL" },
115
+ caption: "Second image caption",
116
+ },
117
+ ],
118
+ }, { quoted: m });
119
+ ```
120
+
121
+ ### Event Message
122
+
123
+ Compose and dispatch a WhatsApp event invitation.
124
+
125
+ ```javascript
126
+ await sock.sendMessage(jid, {
127
+ eventMessage: {
128
+ isCanceled: false,
129
+ name: "Your Event Name",
130
+ description: "A brief description of your event.",
131
+ location: {
132
+ degreesLatitude: 0,
133
+ degreesLongitude: 0,
134
+ name: "Event Location",
135
+ },
136
+ joinLink: "https://call.whatsapp.com/video/your-link",
137
+ startTime: "1763019000",
138
+ endTime: "1763026200",
139
+ extraGuestsAllowed: false,
140
+ },
141
+ }, { quoted: m });
142
+ ```
143
+
144
+ ### Poll Result Message
145
+
146
+ Render poll results alongside their respective vote tallies.
147
+
148
+ ```javascript
149
+ await sock.sendMessage(jid, {
150
+ pollResultMessage: {
151
+ name: "Your Poll Title",
152
+ pollVotes: [
153
+ {
154
+ optionName: "Option A",
155
+ optionVoteCount: "2"
156
+ },
157
+ {
158
+ optionName: "Option B",
159
+ optionVoteCount: "1"
160
+ }
161
+ ]
162
+ }
163
+ }, { quoted: m });
164
+ ```
165
+
166
+ ### Simple Interactive Message
167
+
168
+ Send a straightforward interactive message featuring a copy-to-clipboard button.
169
+
170
+ ```javascript
171
+ await sock.sendMessage(jid, {
172
+ interactiveMessage: {
173
+ header: "Message Header",
174
+ title: "Message Title",
175
+ footer: "telegram: @fanzxnothuman",
176
+ buttons: [
177
+ {
178
+ name: "cta_copy",
179
+ buttonParamsJson: JSON.stringify({
180
+ display_text: "Copy Code",
181
+ id: "123456789",
182
+ copy_code: "YOUR_CODE_HERE"
183
+ })
184
+ }
185
+ ]
186
+ }
187
+ }, { quoted: m });
188
+ ```
189
+
190
+ ### Interactive Message with Native Flow
191
+
192
+ Send a feature-rich interactive message incorporating buttons, copy actions, and native flow elements.
193
+
194
+ ```javascript
195
+ await sock.sendMessage(jid, {
196
+ interactiveMessage: {
197
+ header: "Message Header",
198
+ title: "Message Title",
199
+ footer: "telegram: @fanzxnothuman",
200
+ image: { url: "https://example.com/image.jpg" },
201
+ nativeFlowMessage: {
202
+ messageParamsJson: JSON.stringify({
203
+ limited_time_offer: {
204
+ text: "Your promotional text here.",
205
+ url: "https://t.me/fanzxnothuman",
206
+ copy_code: "YOUR_CODE",
207
+ expiration_time: Date.now() * 999
208
+ },
209
+ bottom_sheet: {
210
+ in_thread_buttons_limit: 2,
211
+ divider_indices: [1, 2, 3, 4, 5, 999],
212
+ list_title: "List Title",
213
+ button_title: "Button Label"
214
+ },
215
+ tap_target_configuration: {
216
+ title: "Target Title",
217
+ description: "Target description.",
218
+ canonical_url: "https://t.me/fanzxnothuman",
219
+ domain: "example.com",
220
+ button_index: 0
221
+ }
222
+ }),
223
+ buttons: [
224
+ {
225
+ name: "single_select",
226
+ buttonParamsJson: JSON.stringify({
227
+ has_multiple_buttons: true
228
+ })
229
+ },
230
+ {
231
+ name: "call_permission_request",
232
+ buttonParamsJson: JSON.stringify({
233
+ has_multiple_buttons: true
234
+ })
235
+ },
236
+ {
237
+ name: "single_select",
238
+ buttonParamsJson: JSON.stringify({
239
+ title: "Select an Option",
240
+ sections: [
241
+ {
242
+ title: "Category",
243
+ highlight_label: "Label",
244
+ rows: [
245
+ {
246
+ title: "First Option",
247
+ description: "Option description.",
248
+ id: "row_1"
249
+ }
250
+ ]
251
+ }
252
+ ],
253
+ has_multiple_buttons: true
254
+ })
255
+ },
256
+ {
257
+ name: "cta_copy",
258
+ buttonParamsJson: JSON.stringify({
259
+ display_text: "Copy Code",
260
+ id: "123456789",
261
+ copy_code: "YOUR_CODE"
262
+ })
263
+ }
264
+ ]
265
+ }
266
+ }
267
+ }, { quoted: m });
268
+ ```
269
+
270
+ ### Interactive Message with Thumbnail
271
+
272
+ Send an interactive message accompanied by a thumbnail image and a copy button.
273
+
274
+ ```javascript
275
+ await sock.sendMessage(jid, {
276
+ interactiveMessage: {
277
+ header: "Message Header",
278
+ title: "Message Title",
279
+ footer: "telegram: @fanzxnothuman",
280
+ image: { url: "https://example.com/image.jpg" },
281
+ buttons: [
282
+ {
283
+ name: "cta_copy",
284
+ buttonParamsJson: JSON.stringify({
285
+ display_text: "Copy Code",
286
+ id: "123456789",
287
+ copy_code: "YOUR_CODE"
288
+ })
289
+ }
290
+ ]
291
+ }
292
+ }, { quoted: m });
293
+ ```
294
+
295
+ ### Product Message
296
+
297
+ Dispatch a product catalog message complete with merchant details and action buttons.
298
+
299
+ ```javascript
300
+ await sock.sendMessage(jid, {
301
+ productMessage: {
302
+ title: "Product Name",
303
+ description: "A concise description of the product.",
304
+ thumbnail: { url: "https://example.com/image.jpg" },
305
+ productId: "PROD001",
306
+ retailerId: "RETAIL001",
307
+ url: "https://example.com/product",
308
+ body: "Full product details.",
309
+ footer: "Special pricing available.",
310
+ priceAmount1000: 50000,
311
+ currencyCode: "IDR",
312
+ buttons: [
313
+ {
314
+ name: "cta_url",
315
+ buttonParamsJson: JSON.stringify({
316
+ display_text: "Purchase Now",
317
+ url: "https://example.com/buy"
318
+ })
319
+ }
320
+ ]
321
+ }
322
+ }, { quoted: m });
323
+ ```
324
+
325
+ ### Interactive Message with Document Buffer
326
+
327
+ Send an interactive message with a document loaded from the file system. **Note: Document attachments exclusively support buffer input.**
328
+
329
+ ```javascript
330
+ await sock.sendMessage(jid, {
331
+ interactiveMessage: {
332
+ header: "Message Header",
333
+ title: "Message Title",
334
+ footer: "telegram: @fanzxnothuman",
335
+ document: fs.readFileSync("./package.json"),
336
+ mimetype: "application/pdf",
337
+ fileName: "document.pdf",
338
+ jpegThumbnail: fs.readFileSync("./thumbnail.jpeg"),
339
+ contextInfo: {
340
+ mentionedJid: [jid],
341
+ forwardingScore: 777,
342
+ isForwarded: false
343
+ },
344
+ externalAdReply: {
345
+ title: "Your Bot Name",
346
+ body: "Your bot description.",
347
+ mediaType: 3,
348
+ thumbnailUrl: "https://example.com/image.jpg",
349
+ mediaUrl: "https://example.com",
350
+ sourceUrl: "https://t.me/fanzxnothuman",
351
+ showAdAttribution: true,
352
+ renderLargerThumbnail: false
353
+ },
354
+ buttons: [
355
+ {
356
+ name: "cta_url",
357
+ buttonParamsJson: JSON.stringify({
358
+ display_text: "Telegram",
359
+ url: "https://t.me/fanzxnothuman",
360
+ merchant_url: "https://t.me/fanzxnothuman"
361
+ })
362
+ }
363
+ ]
364
+ }
365
+ }, { quoted: m });
366
+ ```
367
+
368
+ ### Interactive Message with Document Buffer (Minimal)
369
+
370
+ A streamlined variant without `contextInfo` or `externalAdReply`. **Note: Document attachments exclusively support buffer input.**
371
+
372
+ ```javascript
373
+ await sock.sendMessage(jid, {
374
+ interactiveMessage: {
375
+ header: "Message Header",
376
+ title: "Message Title",
377
+ footer: "telegram: @fanzxnothuman",
378
+ document: fs.readFileSync("./package.json"),
379
+ mimetype: "application/pdf",
380
+ fileName: "document.pdf",
381
+ jpegThumbnail: fs.readFileSync("./thumbnail.jpeg"),
382
+ buttons: [
383
+ {
384
+ name: "cta_url",
385
+ buttonParamsJson: JSON.stringify({
386
+ display_text: "Telegram",
387
+ url: "https://t.me/fanzxnothuman",
388
+ merchant_url: "https://t.me/fanzxnothuman"
389
+ })
390
+ }
391
+ ]
392
+ }
393
+ }, { quoted: m });
394
+ ```
395
+
396
+ ### Request Payment Message
397
+
398
+ Initiate a payment request with a custom background configuration and sticker attachment.
399
+
400
+ ```javascript
401
+ let quotedType = m.quoted?.mtype || '';
402
+ let quotedContent = JSON.stringify({ [quotedType]: m.quoted }, null, 2);
403
+
404
+ await sock.sendMessage(jid, {
405
+ requestPaymentMessage: {
406
+ currency: 'IDR',
407
+ amount: 10000000,
408
+ from: m.sender,
409
+ sticker: JSON.parse(quotedContent),
410
+ background: {
411
+ id: '100',
412
+ fileLength: '0',
413
+ width: 1000,
414
+ height: 1000,
415
+ mimetype: 'image/webp',
416
+ placeholderArgb: 0xff00ffff,
417
+ textArgb: 0xffffffff,
418
+ subtextArgb: 0xffaa00ff
419
+ }
420
+ }
421
+ }, { quoted: m });
422
+ ```
423
+
424
+ ---
425
+
426
+ ## Why WhatsApp Baileys?
427
+
428
+ This library stands out for its exceptional stability, comprehensive feature set, and a continuously refined pairing mechanism. It is the preferred choice for developers building professional-grade, secure WhatsApp automation solutions. Ongoing support for the latest WhatsApp capabilities ensures long-term compatibility and future-proofing.
429
+
430
+ ---
431
+
432
+ ### Technical Notes
433
+
434
+ - Custom pairing codes with proven stability and security
435
+ - Resolves known authentication and pairing failure edge cases
436
+ - Interactive messages and action buttons for sophisticated dynamic menus
437
+ - Automated, low-overhead session management for sustained uptime
438
+ - Full multi-device support aligned with WhatsApp's latest specifications
439
+ - Modular design enabling straightforward customization and extensibility
440
+ - Well-suited for bots, customer service automation, and enterprise communication tooling
441
+ - Subscribe to the official WhatsApp Channel for updates: [WhatsApp Channel](https://whatsapp.com/channel/0029VbA69WNDDmFMgxLdoA0U)
442
+
443
+ ---
444
+
445
+ For complete documentation, installation instructions, and implementation references, visit the official repository and community forums. This library is under active development, with continuous improvements driven by real-world developer needs.
446
+
447
+ **Thank you for choosing WhatsApp Baileys as your WhatsApp automation foundation.**
448
+
449
+ ---
450
+
451
+ ### Contact
452
+
453
+ For inquiries, support, or collaboration opportunities:
454
+
455
+ - **Telegram**: [fanzxnothuman](https://t.me/fanzxnothuman)
456
+ - **WhatsApp Channel**: [WhatsApp Channel](https://whatsapp.com/channel/0029VbA69WNDDmFMgxLdoA0U)
457
+
458
+ ### 🙌 Contributors
459
+
460
+ Recognition to the following contributors who have helped shape this project:
461
+
462
+ <table>
463
+ <tr>
464
+ <td align="center">
465
+ <a href="https://github.com/fanzxnothuman">
466
+ <img src="https://github.com/fanzxnothuman.png" width="80px;" style="border-radius:50%;" alt="Uploader"/>
467
+ <br />
468
+ <sub><b>Fantzy</b></sub>
469
+ </a>
470
+ </td>
471
+ <td align="center">
472
+ <a href="https://github.com/kiuur">
473
+ <img src="https://github.com/kiuur.png" width="80px;" style="border-radius:50%;" alt="Developer"/>
474
+ <br />
475
+ <sub><b>KyuuRzy</b></sub>
476
+ </a>
477
+ </td>
478
+ </tr>
479
+ </table>