@heavstaltech/baileys 1.0.2 → 3.2.4

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 (133) hide show
  1. package/README.md +226 -53
  2. package/WAProto/index.js +14270 -302
  3. package/engine-requirements.js +10 -0
  4. package/lib/Defaults/baileys-version.json +1 -1
  5. package/lib/Defaults/index.js +118 -79
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  8. package/lib/Signal/Group/ciphertext-message.js +15 -0
  9. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  10. package/lib/Signal/Group/group-session-builder.js +64 -0
  11. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  12. package/lib/Signal/Group/group_cipher.js +96 -0
  13. package/lib/Signal/Group/index.d.ts +11 -0
  14. package/lib/Signal/Group/index.js +57 -0
  15. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  16. package/lib/Signal/Group/keyhelper.js +55 -0
  17. package/lib/Signal/Group/queue-job.d.ts +1 -0
  18. package/lib/Signal/Group/queue-job.js +57 -0
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  20. package/lib/Signal/Group/sender-chain-key.js +34 -0
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  22. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  24. package/lib/Signal/Group/sender-key-message.js +69 -0
  25. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  26. package/lib/Signal/Group/sender-key-name.js +51 -0
  27. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  28. package/lib/Signal/Group/sender-key-record.js +53 -0
  29. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  30. package/lib/Signal/Group/sender-key-state.js +99 -0
  31. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  32. package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
  33. package/lib/Signal/libsignal.js +51 -29
  34. package/lib/Socket/business.d.ts +43 -42
  35. package/lib/Socket/chats.d.ts +222 -36
  36. package/lib/Socket/chats.js +186 -153
  37. package/lib/Socket/dugong.d.ts +254 -0
  38. package/lib/Socket/dugong.js +484 -0
  39. package/lib/Socket/groups.d.ts +7 -7
  40. package/lib/Socket/groups.js +37 -35
  41. package/lib/Socket/index.d.ts +52 -51
  42. package/lib/Socket/index.js +1 -0
  43. package/lib/Socket/messages-recv.d.ts +37 -34
  44. package/lib/Socket/messages-recv.js +175 -37
  45. package/lib/Socket/messages-send.d.ts +12 -18
  46. package/lib/Socket/messages-send.js +396 -574
  47. package/lib/Socket/newsletter.d.ts +28 -26
  48. package/lib/Socket/newsletter.js +140 -25
  49. package/lib/Socket/registration.d.ts +52 -49
  50. package/lib/Socket/registration.js +7 -7
  51. package/lib/Socket/socket.d.ts +0 -1
  52. package/lib/Socket/socket.js +47 -198
  53. package/lib/Socket/usync.d.ts +10 -11
  54. package/lib/Store/make-cache-manager-store.d.ts +1 -2
  55. package/lib/Store/make-in-memory-store.d.ts +2 -2
  56. package/lib/Store/make-in-memory-store.js +1 -5
  57. package/lib/Store/make-ordered-dictionary.js +2 -2
  58. package/lib/Types/Auth.d.ts +1 -0
  59. package/lib/Types/Call.d.ts +1 -1
  60. package/lib/Types/Chat.d.ts +7 -12
  61. package/lib/Types/Events.d.ts +2 -17
  62. package/lib/Types/GroupMetadata.d.ts +2 -3
  63. package/lib/Types/Label.d.ts +0 -11
  64. package/lib/Types/Label.js +1 -1
  65. package/lib/Types/LabelAssociation.js +1 -1
  66. package/lib/Types/Message.d.ts +10 -170
  67. package/lib/Types/Newsletter.d.ts +97 -86
  68. package/lib/Types/Newsletter.js +38 -32
  69. package/lib/Types/Socket.d.ts +2 -7
  70. package/lib/Types/index.d.ts +0 -9
  71. package/lib/Types/index.js +1 -1
  72. package/lib/Utils/auth-utils.js +14 -35
  73. package/lib/Utils/business.d.ts +1 -1
  74. package/lib/Utils/business.js +2 -2
  75. package/lib/Utils/chat-utils.d.ts +12 -11
  76. package/lib/Utils/chat-utils.js +36 -52
  77. package/lib/Utils/crypto.d.ts +16 -15
  78. package/lib/Utils/crypto.js +26 -74
  79. package/lib/Utils/decode-wa-message.d.ts +0 -17
  80. package/lib/Utils/decode-wa-message.js +17 -53
  81. package/lib/Utils/event-buffer.js +7 -10
  82. package/lib/Utils/generics.d.ts +17 -13
  83. package/lib/Utils/generics.js +79 -58
  84. package/lib/Utils/history.d.ts +2 -6
  85. package/lib/Utils/history.js +6 -4
  86. package/lib/Utils/logger.d.ts +3 -1
  87. package/lib/Utils/lt-hash.js +12 -12
  88. package/lib/Utils/make-mutex.d.ts +2 -2
  89. package/lib/Utils/messages-media.d.ts +28 -25
  90. package/lib/Utils/messages-media.js +201 -103
  91. package/lib/Utils/messages.js +36 -473
  92. package/lib/Utils/noise-handler.d.ts +5 -4
  93. package/lib/Utils/noise-handler.js +14 -19
  94. package/lib/Utils/process-message.d.ts +5 -5
  95. package/lib/Utils/process-message.js +23 -75
  96. package/lib/Utils/signal.d.ts +1 -2
  97. package/lib/Utils/signal.js +26 -32
  98. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
  99. package/lib/Utils/use-multi-file-auth-state.js +66 -242
  100. package/lib/Utils/validate-connection.d.ts +1 -1
  101. package/lib/Utils/validate-connection.js +88 -64
  102. package/lib/WABinary/constants.d.ts +27 -24
  103. package/lib/WABinary/decode.d.ts +2 -1
  104. package/lib/WABinary/decode.js +11 -23
  105. package/lib/WABinary/encode.d.ts +2 -1
  106. package/lib/WABinary/encode.js +147 -134
  107. package/lib/WABinary/generic-utils.d.ts +5 -2
  108. package/lib/WABinary/generic-utils.js +125 -37
  109. package/lib/WABinary/jid-utils.d.ts +1 -1
  110. package/lib/WAM/BinaryInfo.d.ts +11 -2
  111. package/lib/WAM/encode.d.ts +2 -1
  112. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
  113. package/lib/WAUSync/USyncUser.d.ts +2 -0
  114. package/lib/index.d.ts +12 -0
  115. package/lib/index.js +12 -0
  116. package/package.json +102 -98
  117. package/WAProto/index.d.ts +0 -50383
  118. package/WASignalGroup/GroupProtocol.js +0 -1697
  119. package/WASignalGroup/ciphertext_message.js +0 -16
  120. package/WASignalGroup/group_cipher.js +0 -120
  121. package/WASignalGroup/group_session_builder.js +0 -46
  122. package/WASignalGroup/index.js +0 -5
  123. package/WASignalGroup/keyhelper.js +0 -21
  124. package/WASignalGroup/protobufs.js +0 -3
  125. package/WASignalGroup/queue_job.js +0 -69
  126. package/WASignalGroup/sender_chain_key.js +0 -50
  127. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  128. package/WASignalGroup/sender_key_message.js +0 -92
  129. package/WASignalGroup/sender_key_name.js +0 -70
  130. package/WASignalGroup/sender_key_record.js +0 -56
  131. package/WASignalGroup/sender_key_state.js +0 -129
  132. package/lib/Utils/use-single-file-auth-state.d.ts +0 -12
  133. package/lib/Utils/use-single-file-auth-state.js +0 -75
package/README.md CHANGED
@@ -10,10 +10,10 @@
10
10
  <a href="https://www.npmjs.com/package/@heavstaltech/baileys">
11
11
  <img src="https://img.shields.io/badge/NPM-@heavstaltech/baileys-cb3837?style=for-the-badge&logo=npm&logoColor=white" alt="NPM" />
12
12
  </a>
13
- <a href="https://github.com/Promise818/HT-baileys">
13
+ <a href="https://github.com/HeavstalTech/HT-baileys">
14
14
  <img src="https://img.shields.io/badge/Version-1.0.1-2ea44f?style=for-the-badge&logo=github&logoColor=white" alt="Version" />
15
15
  </a>
16
- <a href="https://github.com/Promise818/HT-baileys/blob/master/LICENSE">
16
+ <a href="https://github.com/HeavstalTech/HT-baileys/blob/master/LICENSE">
17
17
  <img src="https://img.shields.io/badge/License-MIT-fab005?style=for-the-badge" alt="License" />
18
18
  </a>
19
19
  </div>
@@ -24,18 +24,25 @@
24
24
 
25
25
  **HT-baileys** is an advanced fork of the WhatsApp Web API library, engineered and maintained by **Heavstal Tech**.
26
26
 
27
- This library builds upon the stability of the original Baileys architecture while integrating extended features required for modern, production-grade automation. It provides a robust solution for enterprise bots, featuring optimized connection headers, custom pairing code logic, and native support for WhatsApp Channels (Newsletters).
27
+ This library builds upon the stability of the original Baileys architecture while integrating extended features required for modern, production-grade automation. It provides a robust solution for enterprise bots, featuring optimized connection headers, custom pairing code logic, and native support for WhatsApp Channels (Newsletters), Interactive Messages, and more.
28
+
29
+ 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.
30
+
31
+ 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.
32
+
33
+ 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.
28
34
 
29
35
  ## Features Overview
30
36
 
31
37
  | Feature | Description |
32
38
  | :--- | :--- |
33
- | 💬 **Send Messages to Channels** | Full support for sending text and media messages to WhatsApp Channels (Newsletters). |
34
- | 🔘 **Button & Interactive Messages** | Native support for buttons, lists, and interactive messages on both Messenger and Business API. |
35
- | 🤖 **AI Message Icon** | Customize message appearances with an optional AI icon (`ai: true`), adding a modern touch to automated responses. |
36
- | 🖼️ **Full-Size Profile Pictures** | Allows uploading profile pictures in their original resolution without aggressive cropping. |
37
- | 🔑 **Custom Pairing Codes** | **Heavstal Exclusive:** Define custom alphanumeric pairing codes (e.g., `HEAVSTAL`) for branded authentication flows. |
38
- | 🛠️ **Libsignal Fixes** | Enhanced stability with refined logs, providing cleaner output and fewer connection drops. |
39
+ | 💬 **Newsletters & Channels** | Full support for sending text, media, and managing WhatsApp Channels. |
40
+ | 🔘 **Interactive Messages** | Native support for buttons, lists, carousel, and product messages. |
41
+ | 🤖 **AI Message Icon** | Customize message appearances with an optional AI icon (`ai: true`). |
42
+ | 🔑 **Custom Pairing Codes** | **Heavstal Exclusive:** Define custom alphanumeric pairing codes (e.g., `HEAVSTAL`). |
43
+ | 📊 **Polls & Events** | Create polls with vote tracking and schedule WhatsApp events. |
44
+ | 🖼️ **Albums & High-Res Media** | Send album messages and upload full-size profile pictures. |
45
+ | 🛠️ **Stability Fixes** | Enhanced Libsignal logs and connection management. |
39
46
 
40
47
  ---
41
48
 
@@ -53,7 +60,7 @@ npm install @heavstaltech/baileys@latest
53
60
 
54
61
  ---
55
62
 
56
- ## Usage
63
+ ## Getting Started
57
64
 
58
65
  ### Basic Connection
59
66
 
@@ -99,7 +106,7 @@ connectToWhatsApp()
99
106
 
100
107
  ---
101
108
 
102
- ## Feature Implementation
109
+ ## Core Feature Implementation
103
110
 
104
111
  ### 1. Custom Pairing Code
105
112
  HT-baileys supports the definition of custom alphanumeric pairing codes, allowing for branded connection flows.
@@ -119,67 +126,233 @@ if (!sock.authState.creds.registered) {
119
126
  }
120
127
  ```
121
128
 
122
- ### 2. Newsletter Management
123
- Provides a full suite of tools for managing WhatsApp Channels (Newsletters).
129
+ ### 2. Utilities
130
+ Useful helper functions included in the library.
124
131
 
125
- **Create a Channel**
126
- ```ts
127
- const channel = await sock.newsletterCreate("Heavstal Updates", "Official Channel Description")
128
- console.log("Channel Created:", channel.id)
132
+ **Check Banned Number**
133
+ ```javascript
134
+ await sock.checkWhatsApp(jid)
135
+ ```
136
+
137
+ ### 3. Newsletter Management
138
+ Tools for managing and interacting with WhatsApp Channels.
139
+
140
+ **Get Channel ID by URL**
141
+ ```javascript
142
+ await sock.newsletterId(url)
129
143
  ```
130
144
 
131
- **Update Channel Metadata**
145
+ **Create & Update Channel**
132
146
  ```ts
147
+ const channel = await sock.newsletterCreate("Heavstal Updates", "Official Channel Description")
148
+
149
+ // Update Metadata
133
150
  await sock.newsletterUpdateName(channel.id, "Heavstal Tech")
134
151
  await sock.newsletterUpdateDescription(channel.id, "Official Updates")
135
152
  ```
136
153
 
137
- ### 3. Interactive Messages (Buttons & Lists)
138
- Native support for interactive message types, including single-select lists and call-to-action buttons.
154
+ ---
139
155
 
140
- ```ts
141
- const interactiveMessage = {
142
- body: { text: "Select an option below" },
143
- footer: { text: "Heavstal Tech" },
144
- header: { title: "Main Menu", hasMediaAttachment: false },
145
- nativeFlowMessage: {
156
+ ## Advanced Messaging Documentation
157
+
158
+ ### Group Status V2
159
+ Send a status update specific to a group context.
160
+
161
+ ```javascript
162
+ await sock.sendMessage(jid, {
163
+ groupStatusMessage: {
164
+ text: "Hello World"
165
+ }
166
+ });
167
+ ```
168
+
169
+ ### Album Message
170
+ Send multiple images combined into a single album bubble.
171
+
172
+ ```javascript
173
+ await sock.sendMessage(jid, {
174
+ albumMessage: [
175
+ { image: { url: "https://example.com/1.jpg" }, caption: "First Photo" },
176
+ { image: { url: "https://example.com/2.jpg" }, caption: "Second Photo" }
177
+ ]
178
+ }, { quoted: m });
179
+ ```
180
+
181
+ ### Event Message
182
+ Create and send a WhatsApp Event invitation.
183
+
184
+ ```javascript
185
+ await sock.sendMessage(jid, {
186
+ eventMessage: {
187
+ isCanceled: false,
188
+ name: "Heavstal Launch",
189
+ description: "Official Launch Party",
190
+ location: {
191
+ degreesLatitude: 0,
192
+ degreesLongitude: 0,
193
+ name: "Virtual"
194
+ },
195
+ joinLink: "https://call.whatsapp.com/video/example",
196
+ startTime: "1763019000",
197
+ endTime: "1763026200",
198
+ extraGuestsAllowed: false
199
+ }
200
+ }, { quoted: m });
201
+ ```
202
+
203
+ ### Poll Message
204
+ Send a poll and display results.
205
+
206
+ ```javascript
207
+ await sock.sendMessage(jid, {
208
+ pollResultMessage: {
209
+ name: "Which framework do you prefer?",
210
+ pollVotes: [
211
+ { optionName: "React", optionVoteCount: "10" },
212
+ { optionName: "Vue", optionVoteCount: "5" }
213
+ ]
214
+ }
215
+ }, { quoted: m });
216
+ ```
217
+
218
+ ### Product Message
219
+ Send a catalog product message with a "Buy Now" button.
220
+
221
+ ```javascript
222
+ await sock.sendMessage(jid, {
223
+ productMessage: {
224
+ title: "Premium Service",
225
+ description: "Lifetime access to premium features",
226
+ thumbnail: { url: "https://example.com/image.jpg" },
227
+ productId: "PROD001",
228
+ retailerId: "RETAIL001",
229
+ url: "https://example.com/product",
230
+ body: "Product Details",
231
+ footer: "Special Offer",
232
+ priceAmount1000: 50000,
233
+ currencyCode: "USD",
146
234
  buttons: [
147
235
  {
148
- name: "single_select",
236
+ name: "cta_url",
149
237
  buttonParamsJson: JSON.stringify({
150
- title: "Tap to open",
151
- sections: [{
152
- title: "Services",
153
- rows: [
154
- { header: "STATUS", title: "System Status", id: "status_check" }
155
- ]
156
- }]
238
+ display_text: "Buy Now",
239
+ url: "https://example.com/buy"
157
240
  })
158
241
  }
159
242
  ]
160
243
  }
161
- }
162
-
163
- await sock.sendMessage(jid, {
164
- viewOnceMessage: {
165
- message: { interactiveMessage }
166
- }
167
- })
244
+ }, { quoted: m });
168
245
  ```
169
246
 
170
- ### 4. Album Messages
171
- Allows sending multiple media assets (Images/Videos) grouped as a single album.
247
+ ### Request Payment Message
248
+ Send a payment request with a custom background and sticker.
249
+
250
+ ```javascript
251
+ // Assuming 'm' is the message object you are quoting
252
+ let quotedType = m.quoted?.mtype || '';
253
+ let quotedContent = JSON.stringify({ [quotedType]: m.quoted }, null, 2);
254
+
255
+ await sock.sendMessage(jid, {
256
+ requestPaymentMessage: {
257
+ currency: "IDR",
258
+ amount: 10000000,
259
+ from: m.sender,
260
+ sticker: JSON.parse(quotedContent),
261
+ background: {
262
+ id: "100",
263
+ fileLength: "0",
264
+ width: 1000,
265
+ height: 1000,
266
+ mimetype: "image/webp",
267
+ placeholderArgb: 0xFF00FFFF,
268
+ textArgb: 0xFFFFFFFF,
269
+ subtextArgb: 0xFFAA00FF
270
+ }
271
+ }
272
+ }, { quoted: m });
273
+ ```
172
274
 
173
- ```ts
174
- const mediaContent = [
175
- { image: { url: "https://example.com/image1.jpg" } },
176
- { image: { url: "https://example.com/image2.jpg" } }
177
- ]
275
+ ### Interactive Messages (Native Flow)
276
+ Complex interactive messages including buttons, copy-to-clipboard, and lists.
277
+
278
+ **Native Flow with Buttons & Lists:**
279
+ ```javascript
280
+ await sock.sendMessage(jid, {
281
+ interactiveMessage: {
282
+ header: "Heavstal Tech",
283
+ title: "Interactive Menu",
284
+ footer: "Powered by HT-baileys",
285
+ image: { url: "https://example.com/image.jpg" },
286
+ nativeFlowMessage: {
287
+ messageParamsJson: JSON.stringify({
288
+ limited_time_offer: {
289
+ text: "Special Offer",
290
+ url: "https://heavstal-tech.vercel.app",
291
+ copy_code: "DISCOUNT20",
292
+ expiration_time: Date.now() + 86400000
293
+ },
294
+ }),
295
+ buttons: [
296
+ {
297
+ name: "single_select",
298
+ buttonParamsJson: JSON.stringify({
299
+ title: "Open Menu",
300
+ sections: [
301
+ {
302
+ title: "Main Options",
303
+ highlight_label: "Popular",
304
+ rows: [
305
+ {
306
+ title: "Check Status",
307
+ description: "View system status",
308
+ id: "status_row"
309
+ }
310
+ ]
311
+ }
312
+ ]
313
+ })
314
+ },
315
+ {
316
+ name: "cta_copy",
317
+ buttonParamsJson: JSON.stringify({
318
+ display_text: "Copy ID",
319
+ id: "123456789",
320
+ copy_code: "HT-1234"
321
+ })
322
+ }
323
+ ]
324
+ }
325
+ }
326
+ }, { quoted: m });
327
+ ```
178
328
 
179
- await sock.sendMessage(jid, {
180
- album: mediaContent,
181
- caption: "Media Album"
182
- })
329
+ **Interactive Message with Document:**
330
+ *Note: Documents must be passed as buffers.*
331
+
332
+ ```javascript
333
+ import fs from 'fs';
334
+
335
+ await sock.sendMessage(jid, {
336
+ interactiveMessage: {
337
+ header: "Documentation",
338
+ title: "Read Guidelines",
339
+ footer: "Heavstal Tech",
340
+ document: fs.readFileSync("./manual.pdf"),
341
+ mimetype: "application/pdf",
342
+ fileName: "manual.pdf",
343
+ jpegThumbnail: fs.readFileSync("./thumb.jpg"),
344
+ buttons: [
345
+ {
346
+ name: "cta_url",
347
+ buttonParamsJson: JSON.stringify({
348
+ display_text: "Visit Website",
349
+ url: "https://heavstal-tech.vercel.app",
350
+ merchant_url: "https://heavstal-tech.vercel.app"
351
+ })
352
+ }
353
+ ]
354
+ }
355
+ }, { quoted: m });
183
356
  ```
184
357
 
185
358
  ---
@@ -199,5 +372,5 @@ This software is provided "as is", without warranty of any kind. Users are respo
199
372
  ---
200
373
 
201
374
  <div align="center">
202
- <sub>© 2025 Heavstal Tech. All rights reserved.</sub>
375
+ <sub>© 2025 - 2026 Heavstal Tech. All rights reserved.</sub>
203
376
  </div>