@kyuu2nd/baileys 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 (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +460 -0
  3. package/WAProto/index.js +169661 -0
  4. package/engine-requirements.js +10 -0
  5. package/lib/Defaults/baileys-version.json +3 -0
  6. package/lib/Defaults/index.js +147 -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 +64 -0
  13. package/lib/Signal/Group/group_cipher.js +96 -0
  14. package/lib/Signal/Group/index.js +57 -0
  15. package/lib/Signal/Group/keyhelper.js +55 -0
  16. package/lib/Signal/Group/queue-job.js +57 -0
  17. package/lib/Signal/Group/sender-chain-key.js +34 -0
  18. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  19. package/lib/Signal/Group/sender-key-message.js +69 -0
  20. package/lib/Signal/Group/sender-key-name.js +51 -0
  21. package/lib/Signal/Group/sender-key-record.js +53 -0
  22. package/lib/Signal/Group/sender-key-state.js +99 -0
  23. package/lib/Signal/Group/sender-message-key.js +29 -0
  24. package/lib/Signal/libsignal.js +174 -0
  25. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  26. package/lib/Socket/Client/index.js +19 -0
  27. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  28. package/lib/Socket/Client/web-socket-client.js +62 -0
  29. package/lib/Socket/business.js +260 -0
  30. package/lib/Socket/chats.js +1002 -0
  31. package/lib/Socket/dugong.js +637 -0
  32. package/lib/Socket/groups.js +317 -0
  33. package/lib/Socket/index.js +11 -0
  34. package/lib/Socket/messages-recv.js +1110 -0
  35. package/lib/Socket/messages-send.js +831 -0
  36. package/lib/Socket/newsletter.js +430 -0
  37. package/lib/Socket/registration.js +166 -0
  38. package/lib/Socket/socket.js +665 -0
  39. package/lib/Socket/usync.js +70 -0
  40. package/lib/Store/index.js +10 -0
  41. package/lib/Store/make-cache-manager-store.js +83 -0
  42. package/lib/Store/make-in-memory-store.js +427 -0
  43. package/lib/Store/make-ordered-dictionary.js +81 -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 +4 -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 +9 -0
  53. package/lib/Types/Message.js +9 -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 +42 -0
  61. package/lib/Utils/auth-utils.js +206 -0
  62. package/lib/Utils/baileys-event-stream.js +63 -0
  63. package/lib/Utils/business.js +234 -0
  64. package/lib/Utils/chat-utils.js +729 -0
  65. package/lib/Utils/crypto.js +151 -0
  66. package/lib/Utils/decode-wa-message.js +198 -0
  67. package/lib/Utils/event-buffer.js +514 -0
  68. package/lib/Utils/generics.js +498 -0
  69. package/lib/Utils/history.js +96 -0
  70. package/lib/Utils/index.js +33 -0
  71. package/lib/Utils/link-preview.js +93 -0
  72. package/lib/Utils/logger.js +7 -0
  73. package/lib/Utils/lt-hash.js +51 -0
  74. package/lib/Utils/make-mutex.js +43 -0
  75. package/lib/Utils/messages-media.js +819 -0
  76. package/lib/Utils/messages.js +787 -0
  77. package/lib/Utils/noise-handler.js +155 -0
  78. package/lib/Utils/process-message.js +321 -0
  79. package/lib/Utils/signal.js +153 -0
  80. package/lib/Utils/use-multi-file-auth-state.js +119 -0
  81. package/lib/Utils/validate-connection.js +229 -0
  82. package/lib/WABinary/constants.js +40 -0
  83. package/lib/WABinary/decode.js +252 -0
  84. package/lib/WABinary/encode.js +265 -0
  85. package/lib/WABinary/generic-utils.js +198 -0
  86. package/lib/WABinary/index.js +21 -0
  87. package/lib/WABinary/jid-utils.js +62 -0
  88. package/lib/WABinary/types.js +2 -0
  89. package/lib/WAM/BinaryInfo.js +13 -0
  90. package/lib/WAM/constants.js +15350 -0
  91. package/lib/WAM/encode.js +155 -0
  92. package/lib/WAM/index.js +19 -0
  93. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  94. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  95. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  96. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  97. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  98. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  99. package/lib/WAUSync/Protocols/index.js +20 -0
  100. package/lib/WAUSync/USyncQuery.js +89 -0
  101. package/lib/WAUSync/USyncUser.js +26 -0
  102. package/lib/WAUSync/index.js +19 -0
  103. package/lib/index.js +49 -0
  104. package/package.json +112 -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,460 @@
1
+ # WhatsApp Baileys
2
+
3
+ <p align="center">
4
+ <img src="https://raw.githubusercontent.com/z4phdev/client/refs/heads/main/thumbnail.png" alt="Thumbnail" />
5
+ </p>
6
+
7
+ WhatsApp Baileys is an open-source library designed to help developers build automation solutions and integrations with WhatsApp efficiently and directly. Using websocket technology without the need for a browser, this library supports a wide range of features such as message management, chat handling, group administration, as well as interactive messages and action buttons for a more dynamic user experience.
8
+
9
+ Actively developed and maintained, baileys continuously receives updates to enhance stability and performance. One of the main focuses is to improve the pairing and authentication processes to be more stable and secure. Pairing features can be customized with your own codes, making the process more reliable and less prone to interruptions.
10
+
11
+ This library is highly suitable for building business bots, chat automation systems, customer service solutions, and various other communication automation applications that require high stability and comprehensive features. With a lightweight and modular design, baileys is easy to integrate into different systems and platforms.
12
+
13
+ ---
14
+
15
+ ### Main Features and Advantages
16
+
17
+ - Supports automatic and custom pairing processes
18
+ - Fixes previous pairing issues that often caused failures or disconnections
19
+ - Supports interactive messages, action buttons, and dynamic menus
20
+ - Efficient automatic session management for reliable operation
21
+ - Compatible with the latest multi-device features from WhatsApp
22
+ - Lightweight, stable, and easy to integrate into various systems
23
+ - Suitable for developing bots, automation, and complete communication solutions
24
+ - Comprehensive documentation and example codes to facilitate development
25
+
26
+ ---
27
+
28
+ ## Getting Started
29
+
30
+ Begin by installing the library via your preferred package manager, then follow the provided configuration guide. You can also utilize the ready-made example codes to understand how the features work. Use session storage and interactive messaging features to build complete, stable solutions tailored to your business or project needs.
31
+
32
+ ---
33
+
34
+ ## Add Function ( Simple code )
35
+
36
+ ### Label Group
37
+ Tag/Label Member Grop
38
+
39
+ ```javascript
40
+ await sock.setLabelGroup(jid, string)
41
+ ```
42
+ ---
43
+ ### Check ID Channel
44
+ Get ID Channel From Url
45
+
46
+ ```javascript
47
+ await sock.newsletterFromUrl(url)
48
+ ```
49
+ Result JSON
50
+ ```json
51
+ {
52
+ "name": "Name Channel",
53
+ "id": "Channel ID",
54
+ "state": "Status Channel",
55
+ "subscribers": "Followers",
56
+ "verification": "UNVERIFIED",
57
+ "creation_time": 1728547155,
58
+ "description": "Description Channel"
59
+ }
60
+ ```
61
+ ---
62
+ ### Check banned number
63
+ You can see the status of blocked numbers here
64
+
65
+ ```javascript
66
+ sock.checkWhatsApp(jid)
67
+ ```
68
+ ---
69
+
70
+ ## SendMessage Documentation
71
+
72
+ ### Status Mention Group & Private Message
73
+ Send Status Mention Group/Private Chat
74
+
75
+ ```javascript
76
+ await sock.sendStatusMention(content, jid);
77
+ ```
78
+
79
+ ### Status Group Message V2
80
+ Send Group Status With Version 2
81
+
82
+ ```javascript
83
+ await sock.sendMessage(jid, {
84
+ groupStatusMessage: {
85
+ text: "Hello World"
86
+ }
87
+ });
88
+ ```
89
+
90
+ ### Album Message (Multiple Images)
91
+ Send multiple images in a single album message:
92
+
93
+ ```javascript
94
+ await sock.sendMessage(jid, {
95
+ albumMessage: [
96
+ { image: cihuy, caption: "Foto pertama" },
97
+ { image: { url: "URL IMAGE" }, caption: "Foto kedua" }
98
+ ]
99
+ }, { quoted: m });
100
+ ```
101
+
102
+ ### Event Message
103
+ Create and send WhatsApp event invitations:
104
+
105
+ ```javascript
106
+ await sock.sendMessage(jid, {
107
+ eventMessage: {
108
+ isCanceled: false,
109
+ name: "Hello World",
110
+ description: "z4phdev",
111
+ location: {
112
+ degreesLatitude: 0,
113
+ degreesLongitude: 0,
114
+ name: "rowrrrr"
115
+ },
116
+ joinLink: "https://call.whatsapp.com/video/saweitt",
117
+ startTime: "1763019000",
118
+ endTime: "1763026200",
119
+ extraGuestsAllowed: false
120
+ }
121
+ }, { quoted: m });
122
+ ```
123
+
124
+ ### Poll Result Message
125
+ Display poll results with vote counts:
126
+
127
+ ```javascript
128
+ await sock.sendMessage(jid, {
129
+ pollResultMessage: {
130
+ name: "Hello World",
131
+ pollVotes: [
132
+ {
133
+ optionName: "TEST 1",
134
+ optionVoteCount: "112233"
135
+ },
136
+ {
137
+ optionName: "TEST 2",
138
+ optionVoteCount: "1"
139
+ }
140
+ ]
141
+ }
142
+ }, { quoted: m });
143
+ ```
144
+
145
+ ### Simple Interactive Message
146
+ Send basic interactive messages with copy button functionality:
147
+
148
+ ```javascript
149
+ await sock.sendMessage(jid, {
150
+ interactiveMessage: {
151
+ header: "Hello World",
152
+ title: "Hello World",
153
+ footer: "telegram: @saweitt ",
154
+ buttons: [
155
+ {
156
+ name: "cta_copy",
157
+ buttonParamsJson: JSON.stringify({
158
+ display_text: "copy code",
159
+ id: "123456789",
160
+ copy_code: "ABC123XYZ"
161
+ })
162
+ }
163
+ ]
164
+ }
165
+ }, { quoted: m });
166
+ ```
167
+
168
+ ### Interactive Message with Native Flow
169
+ Send interactive messages with buttons, copy actions, and native flow features:
170
+
171
+ ```javascript
172
+ await sock.sendMessage(jid, {
173
+ interactiveMessage: {
174
+ header: "Hello World",
175
+ title: "Hello World",
176
+ footer: "telegram: @saweitt",
177
+ image: { url: "https://example.com/image.jpg" },
178
+ nativeFlowMessage: {
179
+ messageParamsJson: JSON.stringify({
180
+ limited_time_offer: {
181
+ text: "idk hummmm?",
182
+ url: "https://t.me/saweitt",
183
+ copy_code: "z4phdev",
184
+ expiration_time: Date.now() * 999
185
+ },
186
+ bottom_sheet: {
187
+ in_thread_buttons_limit: 2,
188
+ divider_indices: [1, 2, 3, 4, 5, 999],
189
+ list_title: "z4phdev",
190
+ button_title: "z4phdev"
191
+ },
192
+ tap_target_configuration: {
193
+ title: " X ",
194
+ description: "bomboclard",
195
+ canonical_url: "https://t.me/saweitt",
196
+ domain: "shop.example.com",
197
+ button_index: 0
198
+ }
199
+ }),
200
+ buttons: [
201
+ {
202
+ name: "single_select",
203
+ buttonParamsJson: JSON.stringify({
204
+ has_multiple_buttons: true
205
+ })
206
+ },
207
+ {
208
+ name: "call_permission_request",
209
+ buttonParamsJson: JSON.stringify({
210
+ has_multiple_buttons: true
211
+ })
212
+ },
213
+ {
214
+ name: "single_select",
215
+ buttonParamsJson: JSON.stringify({
216
+ title: "Hello World",
217
+ sections: [
218
+ {
219
+ title: "title",
220
+ highlight_label: "label",
221
+ rows: [
222
+ {
223
+ title: "@saweitt",
224
+ description: "love you",
225
+ id: "row_2"
226
+ }
227
+ ]
228
+ }
229
+ ],
230
+ has_multiple_buttons: true
231
+ })
232
+ },
233
+ {
234
+ name: "cta_copy",
235
+ buttonParamsJson: JSON.stringify({
236
+ display_text: "copy code",
237
+ id: "123456789",
238
+ copy_code: "ABC123XYZ"
239
+ })
240
+ }
241
+ ]
242
+ }
243
+ }
244
+ }, { quoted: m });
245
+ ```
246
+
247
+ ### Interactive Message with Thumbnail
248
+ Send interactive messages with thumbnail image and copy button:
249
+
250
+ ```javascript
251
+ await sock.sendMessage(jid, {
252
+ interactiveMessage: {
253
+ header: "Hello World",
254
+ title: "Hello World",
255
+ footer: "telegram: @saweitt",
256
+ image: { url: "https://example.com/image.jpg" },
257
+ buttons: [
258
+ {
259
+ name: "cta_copy",
260
+ buttonParamsJson: JSON.stringify({
261
+ display_text: "copy code",
262
+ id: "123456789",
263
+ copy_code: "ABC123XYZ"
264
+ })
265
+ }
266
+ ]
267
+ }
268
+ }, { quoted: m });
269
+ ```
270
+
271
+ ### Product Message
272
+ Send product catalog messages with buttons and merchant information:
273
+
274
+ ```javascript
275
+ await sock.sendMessage(jid, {
276
+ productMessage: {
277
+ title: "Produk Contoh",
278
+ description: "Ini adalah deskripsi produk",
279
+ thumbnail: { url: "https://example.com/image.jpg" },
280
+ productId: "PROD001",
281
+ retailerId: "RETAIL001",
282
+ url: "https://example.com/product",
283
+ body: "Detail produk",
284
+ footer: "Harga spesial",
285
+ priceAmount1000: 50000,
286
+ currencyCode: "USD",
287
+ buttons: [
288
+ {
289
+ name: "cta_url",
290
+ buttonParamsJson: JSON.stringify({
291
+ display_text: "Beli Sekarang",
292
+ url: "https://example.com/buy"
293
+ })
294
+ }
295
+ ]
296
+ }
297
+ }, { quoted: m });
298
+ ```
299
+
300
+ ### Interactive Message with Document Buffer
301
+ Send interactive messages with document from buffer (file system) - **Note: Documents only support buffer**:
302
+
303
+ ```javascript
304
+ await sock.sendMessage(jid, {
305
+ interactiveMessage: {
306
+ header: "Hello World",
307
+ title: "Hello World",
308
+ footer: "telegram: @saweitt",
309
+ document: fs.readFileSync("./package.json"),
310
+ mimetype: "application/pdf",
311
+ fileName: "saweitt.pdf",
312
+ jpegThumbnail: fs.readFileSync("./document.jpeg"),
313
+ contextInfo: {
314
+ mentionedJid: [jid],
315
+ forwardingScore: 777,
316
+ isForwarded: false
317
+ },
318
+ externalAdReply: {
319
+ title: "shenń Bot",
320
+ body: "anu team",
321
+ mediaType: 3,
322
+ thumbnailUrl: "https://example.com/image.jpg",
323
+ mediaUrl: " X ",
324
+ sourceUrl: "https://t.me/saweitt",
325
+ showAdAttribution: true,
326
+ renderLargerThumbnail: false
327
+ },
328
+ buttons: [
329
+ {
330
+ name: "cta_url",
331
+ buttonParamsJson: JSON.stringify({
332
+ display_text: "Telegram",
333
+ url: "https://t.me/saweitt",
334
+ merchant_url: "https://t.me/saweitt"
335
+ })
336
+ }
337
+ ]
338
+ }
339
+ }, { quoted: m });
340
+ ```
341
+
342
+ ### Interactive Message with Document Buffer (Simple)
343
+ Send interactive messages with document from buffer (file system) without contextInfo and externalAdReply - **Note: Documents only support buffer**:
344
+
345
+ ```javascript
346
+ await sock.sendMessage(jid, {
347
+ interactiveMessage: {
348
+ header: "Hello World",
349
+ title: "Hello World",
350
+ footer: "telegram: @saweitt",
351
+ document: fs.readFileSync("./package.json"),
352
+ mimetype: "application/pdf",
353
+ fileName: "saweitt.pdf",
354
+ jpegThumbnail: fs.readFileSync("./document.jpeg"),
355
+ buttons: [
356
+ {
357
+ name: "cta_url",
358
+ buttonParamsJson: JSON.stringify({
359
+ display_text: "Telegram",
360
+ url: "https://t.me/saweitt",
361
+ merchant_url: "https://t.me/saweitt"
362
+ })
363
+ }
364
+ ]
365
+ }
366
+ }, { quoted: m });
367
+ ```
368
+
369
+ ### Request Payment Message
370
+ Send payment request messages with custom background and sticker:
371
+
372
+ ```javascript
373
+ let quotedType = m.quoted?.mtype || '';
374
+ let quotedContent = JSON.stringify({ [quotedType]: m.quoted }, null, 2);
375
+
376
+ await sock.sendMessage(jid, {
377
+ requestPaymentMessage: {
378
+ currency: "IDR",
379
+ amount: 10000000,
380
+ from: m.sender,
381
+ sticker: JSON.parse(quotedContent),
382
+ background: {
383
+ id: "100",
384
+ fileLength: "0",
385
+ width: 1000,
386
+ height: 1000,
387
+ mimetype: "image/webp",
388
+ placeholderArgb: 0xFF00FFFF,
389
+ textArgb: 0xFFFFFFFF,
390
+ subtextArgb: 0xFFAA00FF
391
+ }
392
+ }
393
+ }, { quoted: m });
394
+ ```
395
+
396
+ ---
397
+
398
+ ## Why Choose WhatsApp Baileys?
399
+
400
+ Because this library offers high stability, full features, and an actively improved pairing process. It is ideal for developers aiming to create professional and secure WhatsApp automation solutions. Support for the latest WhatsApp features ensures compatibility with platform updates.
401
+
402
+ ---
403
+
404
+ ### Technical Notes
405
+
406
+ - Supports custom pairing codes that are stable and secure
407
+ - Fixes previous issues related to pairing and authentication
408
+ - Features interactive messages and action buttons for dynamic menu creation
409
+ - Automatic and efficient session management for long-term stability
410
+ - Compatible with the latest multi-device features from WhatsApp
411
+ - Easy to integrate and customize based on your needs
412
+ - Perfect for developing bots, customer service automation, and other communication applications
413
+ - Has 1 newsletter follow, only the developer's WhatsApp channel: [WhatsApp Channel](https://whatsapp.com/channel/0029VaranC0KmCPQCHryFs2C)
414
+
415
+ ---
416
+
417
+ For complete documentation, installation guides, and implementation examples, please visit the official repository and community forums. We continually update and improve this library to meet the needs of developers and users of modern WhatsApp automation solutions.
418
+
419
+ **Thank you for choosing WhatsApp Baileys as your WhatsApp automation solution!**
420
+
421
+
422
+ ---
423
+
424
+
425
+ ### Contact Developer
426
+
427
+ For questions, support, or collaboration, feel free to contact the developer:
428
+
429
+ - **Telegram**: [Telegram Contact](https://t.me/tskiofc)
430
+ - **Channel WhatsApp**: [Channel WhatsApp](https://whatsapp.com/channel/0029VaranC0KmCPQCHryFs2C)
431
+
432
+ ### 🙌 Contributors outside the Baileys code
433
+
434
+ Thanks to the following awesome contributors who help improve this project 💖
435
+
436
+ <table>
437
+ <tr>
438
+ <td align="center">
439
+ <a href="https://github.com/z4phdev">
440
+ <img src="https://github.com/z4phdev.png" width="80px;" style="border-radius:50%;" alt="Developer"/>
441
+ <br />
442
+ <sub><b>z4phdev</b></sub>
443
+ </a>
444
+ </td>
445
+ <td align="center">
446
+ <a href="https://github.com/kiuur">
447
+ <img src="https://github.com/kiuur.png" width="80px;" style="border-radius:50%;" alt="Contributor"/>
448
+ <br />
449
+ <sub><b>KyuuRzy</b></sub>
450
+ </a>
451
+ </td>
452
+ <td align="center">
453
+ <a href="https://github.com/RexxHayanasi">
454
+ <img src="https://github.com/RexxHayanasi.png" width="80px;" style="border-radius:50%;" alt="Contributor"/>
455
+ <br />
456
+ <sub><b>RexxHayanasi</b></sub>
457
+ </a>
458
+ </td>
459
+ </tr>
460
+ </table>