@than-xs/baileys 2.0.3

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 (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +422 -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/Signal/Group/ciphertext-message.js +15 -0
  9. package/lib/Signal/Group/group-session-builder.js +64 -0
  10. package/lib/Signal/Group/group_cipher.js +96 -0
  11. package/lib/Signal/Group/index.js +57 -0
  12. package/lib/Signal/Group/keyhelper.js +55 -0
  13. package/lib/Signal/Group/queue-job.js +57 -0
  14. package/lib/Signal/Group/sender-chain-key.js +34 -0
  15. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  16. package/lib/Signal/Group/sender-key-message.js +69 -0
  17. package/lib/Signal/Group/sender-key-name.js +51 -0
  18. package/lib/Signal/Group/sender-key-record.js +53 -0
  19. package/lib/Signal/Group/sender-key-state.js +99 -0
  20. package/lib/Signal/Group/sender-message-key.js +29 -0
  21. package/lib/Signal/libsignal.js +174 -0
  22. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  23. package/lib/Socket/Client/index.js +19 -0
  24. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  25. package/lib/Socket/Client/web-socket-client.js +62 -0
  26. package/lib/Socket/business.js +260 -0
  27. package/lib/Socket/chats.js +1002 -0
  28. package/lib/Socket/dugong.js +637 -0
  29. package/lib/Socket/groups.js +317 -0
  30. package/lib/Socket/index.js +11 -0
  31. package/lib/Socket/messages-recv.js +1110 -0
  32. package/lib/Socket/messages-send.js +831 -0
  33. package/lib/Socket/newsletter.js +459 -0
  34. package/lib/Socket/registration.js +166 -0
  35. package/lib/Socket/socket.js +662 -0
  36. package/lib/Socket/usync.js +70 -0
  37. package/lib/Store/index.js +10 -0
  38. package/lib/Store/make-cache-manager-store.js +83 -0
  39. package/lib/Store/make-in-memory-store.js +427 -0
  40. package/lib/Store/make-ordered-dictionary.js +81 -0
  41. package/lib/Store/object-repository.js +27 -0
  42. package/lib/Types/Auth.js +2 -0
  43. package/lib/Types/Call.js +2 -0
  44. package/lib/Types/Chat.js +4 -0
  45. package/lib/Types/Contact.js +2 -0
  46. package/lib/Types/Events.js +2 -0
  47. package/lib/Types/GroupMetadata.js +2 -0
  48. package/lib/Types/Label.js +27 -0
  49. package/lib/Types/LabelAssociation.js +9 -0
  50. package/lib/Types/Message.js +9 -0
  51. package/lib/Types/Newsletter.js +38 -0
  52. package/lib/Types/Product.js +2 -0
  53. package/lib/Types/Signal.js +2 -0
  54. package/lib/Types/Socket.js +2 -0
  55. package/lib/Types/State.js +2 -0
  56. package/lib/Types/USync.js +2 -0
  57. package/lib/Types/index.js +42 -0
  58. package/lib/Utils/auth-utils.js +206 -0
  59. package/lib/Utils/baileys-event-stream.js +63 -0
  60. package/lib/Utils/business.js +234 -0
  61. package/lib/Utils/chat-utils.js +729 -0
  62. package/lib/Utils/crypto.js +151 -0
  63. package/lib/Utils/decode-wa-message.js +198 -0
  64. package/lib/Utils/event-buffer.js +514 -0
  65. package/lib/Utils/generics.js +498 -0
  66. package/lib/Utils/history.js +96 -0
  67. package/lib/Utils/index.js +33 -0
  68. package/lib/Utils/link-preview.js +93 -0
  69. package/lib/Utils/logger.js +7 -0
  70. package/lib/Utils/lt-hash.js +51 -0
  71. package/lib/Utils/make-mutex.js +43 -0
  72. package/lib/Utils/messages-media.js +819 -0
  73. package/lib/Utils/messages.js +819 -0
  74. package/lib/Utils/noise-handler.js +155 -0
  75. package/lib/Utils/process-message.js +321 -0
  76. package/lib/Utils/signal.js +153 -0
  77. package/lib/Utils/use-multi-file-auth-state.js +119 -0
  78. package/lib/Utils/validate-connection.js +229 -0
  79. package/lib/WABinary/constants.js +40 -0
  80. package/lib/WABinary/decode.js +252 -0
  81. package/lib/WABinary/encode.js +265 -0
  82. package/lib/WABinary/generic-utils.js +198 -0
  83. package/lib/WABinary/index.js +21 -0
  84. package/lib/WABinary/jid-utils.js +62 -0
  85. package/lib/WABinary/types.js +2 -0
  86. package/lib/WAM/BinaryInfo.js +13 -0
  87. package/lib/WAM/constants.js +15350 -0
  88. package/lib/WAM/encode.js +155 -0
  89. package/lib/WAM/index.js +19 -0
  90. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  91. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  92. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  93. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  94. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  95. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  96. package/lib/WAUSync/Protocols/index.js +20 -0
  97. package/lib/WAUSync/USyncQuery.js +89 -0
  98. package/lib/WAUSync/USyncUser.js +26 -0
  99. package/lib/WAUSync/index.js +19 -0
  100. package/lib/index.js +84 -0
  101. package/package.json +110 -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,422 @@
1
+ # WhatsApp Baileys
2
+
3
+ <p align="center">
4
+ <img src="https://raw.githubusercontent.com/than-xs/than-xs/refs/heads/main/image.png" alt="image" />
5
+ </p>
6
+
7
+ **WhatsApp Baileys** is an open-source library built to help developers create automation systems and integrations with WhatsApp efficiently and directly through WebSocket — without requiring a browser instance.
8
+
9
+ Designed with stability and modularity in mind, this library supports message management, chat handling, group administration, interactive messages, event systems, polls, product catalogs, and more. It is suitable for building bots, business automation, customer service systems, and scalable communication platforms.
10
+
11
+ Baileys continues to receive improvements focused on authentication stability, pairing reliability, and compatibility with the latest WhatsApp multi-device architecture.
12
+
13
+ ---
14
+
15
+ ## ✨ Main Features & Advantages
16
+
17
+ - Automatic and custom pairing support
18
+ - Improved authentication & reconnection stability
19
+ - Interactive messages, native flow, and action buttons
20
+ - Album, event, poll, and product message support
21
+ - Efficient automatic session management
22
+ - Compatible with WhatsApp Multi-Device
23
+ - Lightweight, modular, and easy to integrate
24
+ - Suitable for bots, automation, and business systems
25
+ - Comprehensive examples for easier development
26
+
27
+ ---
28
+
29
+ ## 🚀 Getting Started
30
+
31
+ Install the library using your preferred package manager, configure your authentication/session storage, and start building automation workflows using the provided examples.
32
+
33
+ Leverage interactive messaging, newsletter tools, and session handling to build stable, production-ready solutions.
34
+
35
+ ---
36
+
37
+ # 📦 Additional Functions (Simple Examples)
38
+
39
+ ## Label Group
40
+ Tag or label group members.
41
+
42
+ ```javascript
43
+ await sock.setLabelGroup(jid, string)
44
+ ```
45
+ ---
46
+ ### Check Channel ID
47
+ Get channel ID from URL
48
+
49
+ ```javascript
50
+ await sock.newsletterFromUrl(url)
51
+ ```
52
+ Result (JSON)
53
+ ```json
54
+ {
55
+ "name": "Name Channel",
56
+ "id": "Channel ID",
57
+ "state": "Status Channel",
58
+ "subscribers": "Followers",
59
+ "verification": "UNVERIFIED",
60
+ "creation_time": 1728547155,
61
+ "description": "Description Channel"
62
+ }
63
+ ```
64
+ ---
65
+ ### Check Banned Number
66
+ Check the status of a WhatsApp number
67
+
68
+ ```javascript
69
+ sock.checkBan(jid)
70
+ ```
71
+ ---
72
+
73
+ ## 📤 SendMessage Documentation
74
+
75
+ ### Status Mention (Group & Private)
76
+
77
+ ```javascript
78
+ await sock.sendStatusMention(content, jid);
79
+ ```
80
+
81
+ ### Group Status Message V2
82
+
83
+ ```javascript
84
+ await sock.sendMessage(jid, {
85
+ groupStatusMessage: {
86
+ text: "Hello world"
87
+ }
88
+ });
89
+ ```
90
+
91
+ ### Album Message (Multiple Images)
92
+
93
+ ```javascript
94
+ await sock.sendMessage(jid, {
95
+ albumMessage: [
96
+ { image: buffer1, caption: "First image" },
97
+ { image: { url: "https://example.com/img.jpg" }, caption: "Second image" }
98
+ ]
99
+ });
100
+ ```
101
+
102
+ ### Event Message
103
+
104
+ ```javascript
105
+ await sock.sendMessage(jid, {
106
+ eventMessage: {
107
+ isCanceled: false,
108
+ name: "Event Title",
109
+ description: "Event description",
110
+ location: {
111
+ degreesLatitude: 0,
112
+ degreesLongitude: 0,
113
+ name: "Location Name"
114
+ },
115
+ joinLink: "https://call.whatsapp.com/video/example",
116
+ startTime: "1763019000",
117
+ endTime: "1763026200",
118
+ extraGuestsAllowed: false
119
+ }
120
+ });
121
+ ```
122
+
123
+ ### Poll Result Message
124
+
125
+ ```javascript
126
+ await sock.sendMessage(jid, {
127
+ pollResultMessage: {
128
+ name: "Poll Title",
129
+ pollVotes: [
130
+ { optionName: "Option 1", optionVoteCount: "10" },
131
+ { optionName: "Option 2", optionVoteCount: "5" }
132
+ ]
133
+ }
134
+ });
135
+ ```
136
+
137
+ ### Simple Interactive Message
138
+ Send basic interactive messages with copy button functionality :
139
+
140
+ ```javascript
141
+ await sock.sendMessage(jid, {
142
+ interactiveMessage: {
143
+ header: "Header",
144
+ title: "Title",
145
+ footer: "Footer",
146
+ buttons: [
147
+ {
148
+ name: "cta_copy",
149
+ buttonParamsJson: JSON.stringify({
150
+ display_text: "Copy Code",
151
+ id: "123",
152
+ copy_code: "ABC123"
153
+ })
154
+ }
155
+ ]
156
+ }
157
+ });
158
+ ```
159
+
160
+ ### Interactive Message with Native Flow
161
+ Send interactive messages with buttons, copy actions, and native flow features :
162
+
163
+ ```javascript
164
+ await sock.sendMessage(jid, {
165
+ interactiveMessage: {
166
+ header: "Hello world",
167
+ title: "Hello world",
168
+ footer: "telegram : @thanror",
169
+ image: { url: "https://example.com/image.jpg" },
170
+ nativeFlowMessage: {
171
+ messageParamsJson: JSON.stringify({
172
+ limited_time_offer: {
173
+ text: "yeah",
174
+ url: "https://t.me/thanror",
175
+ copy_code: "xs-meta",
176
+ expiration_time: Date.now() * 999
177
+ },
178
+ bottom_sheet: {
179
+ in_thread_buttons_limit: 2,
180
+ divider_indices: [1, 2, 3, 4, 5, 999],
181
+ list_title: "than.xs",
182
+ button_title: "than.xs"
183
+ },
184
+ tap_target_configuration: {
185
+ title: " X ",
186
+ description: "nande-nande",
187
+ canonical_url: "https://t.me/thanror",
188
+ domain: "shop.example.com",
189
+ button_index: 0
190
+ }
191
+ }),
192
+ buttons: [
193
+ {
194
+ name: "single_select",
195
+ buttonParamsJson: JSON.stringify({
196
+ has_multiple_buttons: true
197
+ })
198
+ },
199
+ {
200
+ name: "call_permission_request",
201
+ buttonParamsJson: JSON.stringify({
202
+ has_multiple_buttons: true
203
+ })
204
+ },
205
+ {
206
+ name: "single_select",
207
+ buttonParamsJson: JSON.stringify({
208
+ title: "Hello world",
209
+ sections: [
210
+ {
211
+ title: "title",
212
+ highlight_label: "label",
213
+ rows: [
214
+ {
215
+ title: "@thanror",
216
+ description: "love you",
217
+ id: "row_2"
218
+ }
219
+ ]
220
+ }
221
+ ],
222
+ has_multiple_buttons: true
223
+ })
224
+ },
225
+ {
226
+ name: "cta_copy",
227
+ buttonParamsJson: JSON.stringify({
228
+ display_text: "copy code",
229
+ id: "123456789",
230
+ copy_code: "ABC123XYZ"
231
+ })
232
+ }
233
+ ]
234
+ }
235
+ }
236
+ }, { quoted: m });
237
+ ```
238
+
239
+ ### Interactive Message with Thumbnail
240
+ Send interactive messages with thumbnail image and copy button :
241
+
242
+ ```javascript
243
+ await sock.sendMessage(jid, {
244
+ interactiveMessage: {
245
+ header: "Hello world",
246
+ title: "Hello world",
247
+ footer: "telegram : @thanror",
248
+ image: { url: "https://example.com/image.jpg" },
249
+ buttons: [
250
+ {
251
+ name: "cta_copy",
252
+ buttonParamsJson: JSON.stringify({
253
+ display_text: "copy code",
254
+ id: "123456789",
255
+ copy_code: "ABC123XYZ"
256
+ })
257
+ }
258
+ ]
259
+ }
260
+ }, { quoted: m });
261
+ ```
262
+
263
+ ### Product Message
264
+ Send product catalog messages with buttons and merchant information:
265
+
266
+ ```javascript
267
+ await sock.sendMessage(jid, {
268
+ productMessage: {
269
+ title: "Produk Contoh",
270
+ description: "Ini adalah deskripsi produk",
271
+ thumbnail: { url: "https://example.com/image.jpg" },
272
+ productId: "PROD001",
273
+ retailerId: "RETAIL001",
274
+ url: "https://example.com/product",
275
+ body: "Detail produk",
276
+ footer: "Harga spesial",
277
+ priceAmount1000: 50000,
278
+ currencyCode: "USD",
279
+ buttons: [
280
+ {
281
+ name: "cta_url",
282
+ buttonParamsJson: JSON.stringify({
283
+ display_text: "Beli Sekarang",
284
+ url: "https://example.com/buy"
285
+ })
286
+ }
287
+ ]
288
+ }
289
+ }, { quoted: m });
290
+ ```
291
+
292
+ ### Interactive Message with Document Buffer
293
+ Send interactive messages with document from buffer (file system) - **Note: Documents only support buffer**:
294
+
295
+ ```javascript
296
+ await sock.sendMessage(jid, {
297
+ interactiveMessage: {
298
+ header: "Hello world",
299
+ title: "Hello world",
300
+ footer: "telegram : @thanror",
301
+ document: fs.readFileSync("./package.json"),
302
+ mimetype: "application/pdf",
303
+ fileName: "document.pdf",
304
+ jpegThumbnail: fs.readFileSync("./document.jpeg"),
305
+ contextInfo: {
306
+ mentionedJid: [jid],
307
+ forwardingScore: 777,
308
+ isForwarded: false
309
+ },
310
+ externalAdReply: {
311
+ title: "than.xs",
312
+ body: "xs.company",
313
+ mediaType: 3,
314
+ thumbnailUrl: "https://example.com/image.jpg",
315
+ mediaUrl: " X ",
316
+ sourceUrl: "https://t.me/thanror",
317
+ showAdAttribution: true,
318
+ renderLargerThumbnail: false
319
+ },
320
+ buttons: [
321
+ {
322
+ name: "cta_url",
323
+ buttonParamsJson: JSON.stringify({
324
+ display_text: "Telegram",
325
+ url: "https://t.me/thanror",
326
+ merchant_url: "https://t.me/thanror"
327
+ })
328
+ }
329
+ ]
330
+ }
331
+ }, { quoted: m });
332
+ ```
333
+
334
+ ### Interactive Message with Document Buffer (Simple)
335
+ Send interactive messages with document from buffer (file system) without contextInfo and externalAdReply - **Note: Documents only support buffer**:
336
+
337
+ ```javascript
338
+ await sock.sendMessage(jid, {
339
+ interactiveMessage: {
340
+ header: "Hello world",
341
+ title: "Hello world",
342
+ footer: "telegram : @thanror",
343
+ document: fs.readFileSync("./package.json"),
344
+ mimetype: "application/pdf",
345
+ fileName: "document.pdf",
346
+ jpegThumbnail: fs.readFileSync("./document.jpeg"),
347
+ buttons: [
348
+ {
349
+ name: "cta_url",
350
+ buttonParamsJson: JSON.stringify({
351
+ display_text: "Telegram",
352
+ url: "https://t.me/thanror",
353
+ merchant_url: "https://t.me/thanror"
354
+ })
355
+ }
356
+ ]
357
+ }
358
+ }, { quoted: m });
359
+ ```
360
+
361
+ ### Request Payment Message
362
+ Send payment request messages with custom background and sticker:
363
+
364
+ ```javascript
365
+ let quotedType = m.quoted?.mtype || '';
366
+ let quotedContent = JSON.stringify({ [quotedType]: m.quoted }, null, 2);
367
+
368
+ await sock.sendMessage(jid, {
369
+ requestPaymentMessage: {
370
+ currency: "IDR",
371
+ amount: 10000000,
372
+ from: m.sender,
373
+ sticker: JSON.parse(quotedContent),
374
+ background: {
375
+ id: "100",
376
+ fileLength: "0",
377
+ width: 1000,
378
+ height: 1000,
379
+ mimetype: "image/webp",
380
+ placeholderArgb: 0xFF00FFFF,
381
+ textArgb: 0xFFFFFFFF,
382
+ subtextArgb: 0xFFAA00FF
383
+ }
384
+ }
385
+ }, { quoted: m });
386
+ ```
387
+
388
+ ---
389
+
390
+ ## Why Choose WhatsApp Baileys?
391
+
392
+ 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.
393
+
394
+ ---
395
+
396
+ ### Technical Notes
397
+
398
+ - Supports custom pairing codes that are stable and secure
399
+ - Fixes previous issues related to pairing and authentication
400
+ - Features interactive messages and action buttons for dynamic menu creation
401
+ - Automatic and efficient session management for long-term stability
402
+ - Compatible with the latest multi-device features from WhatsApp
403
+ - Easy to integrate and customize based on your needs
404
+ - Perfect for developing bots, customer service automation, and other communication applications
405
+ - Has 1 newsletter follow, only the developer's WhatsApp channel : [WhatsApp Channel](https://whatsapp.com/channel/0029VbAjdOlIt5rqKMzZiQ0s)
406
+
407
+ ---
408
+
409
+ 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.
410
+
411
+ **Thank you for choosing WhatsApp Baileys as your WhatsApp automation solution!**
412
+
413
+
414
+ ---
415
+
416
+
417
+ ### Contact Developer
418
+
419
+ For questions, support, or collaboration, feel free to contact the developer:
420
+
421
+ - **Telegram** : [Telegram Contact](https://t.me/thanror)
422
+ - **Channel WhatsApp** : [Channel WhatsApp](https://whatsapp.com/channel/0029VbAjdOlIt5rqKMzZiQ0s)