@elfhkry/baileys 8.0.11

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 (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +290 -0
  3. package/WAProto/WAProto.proto +5311 -0
  4. package/WAProto/index.js +94091 -0
  5. package/lib/Defaults/index.js +123 -0
  6. package/lib/KeyDB/BinarySearch.js +20 -0
  7. package/lib/KeyDB/KeyedDB.js +167 -0
  8. package/lib/KeyDB/index.js +4 -0
  9. package/lib/Signal/Group/ciphertext-message.js +13 -0
  10. package/lib/Signal/Group/group-session-builder.js +32 -0
  11. package/lib/Signal/Group/group_cipher.js +84 -0
  12. package/lib/Signal/Group/index.js +13 -0
  13. package/lib/Signal/Group/keyhelper.js +20 -0
  14. package/lib/Signal/Group/sender-chain-key.js +28 -0
  15. package/lib/Signal/Group/sender-key-distribution-message.js +65 -0
  16. package/lib/Signal/Group/sender-key-message.js +68 -0
  17. package/lib/Signal/Group/sender-key-name.js +52 -0
  18. package/lib/Signal/Group/sender-key-record.js +43 -0
  19. package/lib/Signal/Group/sender-key-state.js +86 -0
  20. package/lib/Signal/Group/sender-message-key.js +28 -0
  21. package/lib/Signal/libsignal.js +324 -0
  22. package/lib/Signal/lid-mapping.js +155 -0
  23. package/lib/Socket/Client/index.js +4 -0
  24. package/lib/Socket/Client/types.js +13 -0
  25. package/lib/Socket/Client/websocket.js +52 -0
  26. package/lib/Socket/Client/websocket.js.bak +53 -0
  27. package/lib/Socket/business.js +377 -0
  28. package/lib/Socket/chats.js +922 -0
  29. package/lib/Socket/communities.js +413 -0
  30. package/lib/Socket/dugong.js +768 -0
  31. package/lib/Socket/groups.js +312 -0
  32. package/lib/Socket/index.js +16 -0
  33. package/lib/Socket/messages-recv.js +1163 -0
  34. package/lib/Socket/messages-send.js +1179 -0
  35. package/lib/Socket/mex.js +45 -0
  36. package/lib/Socket/newsletter.js +247 -0
  37. package/lib/Socket/socket.js +888 -0
  38. package/lib/Store/index.js +6 -0
  39. package/lib/Store/make-cache-manager-store.js +75 -0
  40. package/lib/Store/make-in-memory-store.js +290 -0
  41. package/lib/Store/make-ordered-dictionary.js +79 -0
  42. package/lib/Store/object-repository.js +25 -0
  43. package/lib/Types/Auth.js +3 -0
  44. package/lib/Types/Bussines.js +3 -0
  45. package/lib/Types/Call.js +3 -0
  46. package/lib/Types/Chat.js +9 -0
  47. package/lib/Types/Contact.js +3 -0
  48. package/lib/Types/Events.js +3 -0
  49. package/lib/Types/GroupMetadata.js +3 -0
  50. package/lib/Types/Label.js +25 -0
  51. package/lib/Types/LabelAssociation.js +7 -0
  52. package/lib/Types/Message.js +12 -0
  53. package/lib/Types/Newsletter.js +33 -0
  54. package/lib/Types/Newsletter.js.bak +33 -0
  55. package/lib/Types/Product.js +3 -0
  56. package/lib/Types/Signal.js +3 -0
  57. package/lib/Types/Socket.js +4 -0
  58. package/lib/Types/State.js +11 -0
  59. package/lib/Types/USync.js +3 -0
  60. package/lib/Types/index.js +28 -0
  61. package/lib/Utils/auth-utils.js +219 -0
  62. package/lib/Utils/baileys-event-stream.js +44 -0
  63. package/lib/Utils/browser-utils.js +25 -0
  64. package/lib/Utils/business.js +233 -0
  65. package/lib/Utils/chat-utils.js +752 -0
  66. package/lib/Utils/crypto.js +130 -0
  67. package/lib/Utils/decode-wa-message.js +267 -0
  68. package/lib/Utils/event-buffer.js +528 -0
  69. package/lib/Utils/generics.js +355 -0
  70. package/lib/Utils/history.js +87 -0
  71. package/lib/Utils/index.js +21 -0
  72. package/lib/Utils/link-preview.js +81 -0
  73. package/lib/Utils/logger.js +5 -0
  74. package/lib/Utils/lt-hash.js +45 -0
  75. package/lib/Utils/make-mutex.js +36 -0
  76. package/lib/Utils/message-retry-manager.js +113 -0
  77. package/lib/Utils/messages-media.js +644 -0
  78. package/lib/Utils/messages.js +909 -0
  79. package/lib/Utils/noise-handler.js +144 -0
  80. package/lib/Utils/pre-key-manager.js +85 -0
  81. package/lib/Utils/process-message.js +341 -0
  82. package/lib/Utils/signal.js +161 -0
  83. package/lib/Utils/use-multi-file-auth-state.js +111 -0
  84. package/lib/Utils/validate-connection.js +200 -0
  85. package/lib/WABinary/constants.js +1303 -0
  86. package/lib/WABinary/decode.js +240 -0
  87. package/lib/WABinary/encode.js +218 -0
  88. package/lib/WABinary/generic-utils.js +189 -0
  89. package/lib/WABinary/index.js +7 -0
  90. package/lib/WABinary/jid-utils.js +93 -0
  91. package/lib/WABinary/types.js +3 -0
  92. package/lib/WAM/BinaryInfo.js +11 -0
  93. package/lib/WAM/constants.js +22853 -0
  94. package/lib/WAM/encode.js +154 -0
  95. package/lib/WAM/index.js +5 -0
  96. package/lib/WAUSync/Protocols/USyncContactProtocol.js +30 -0
  97. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
  98. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +29 -0
  99. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +39 -0
  100. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  101. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +30 -0
  102. package/lib/WAUSync/Protocols/index.js +6 -0
  103. package/lib/WAUSync/USyncQuery.js +90 -0
  104. package/lib/WAUSync/USyncUser.js +24 -0
  105. package/lib/WAUSync/index.js +5 -0
  106. package/lib/index.js +21 -0
  107. package/package.json +103 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 TsmXeuka
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,290 @@
1
+ <div align="center">
2
+
3
+ <img src="https://camo.githubusercontent.com/c1f3b7dcf8145e1a0d91e90aae2b7080e761e88b7d770e0e8429c369d7311425/68747470733a2f2f66696c65732e636174626f782e6d6f652f6335733967302e6a7067" alt="WhatsApp Baileys" width="100%" />
4
+
5
+ <br/>
6
+ <br/>
7
+
8
+ # @elfhkry/baileys
9
+
10
+ <p>
11
+ <img src="https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white" />
12
+ <img src="https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge&logo=whatsapp&logoColor=white" />
13
+ <img src="https://img.shields.io/badge/WebSocket-010101?style=for-the-badge&logo=socketdotio&logoColor=white" />
14
+ <img src="https://img.shields.io/badge/Open%20Source-FF4500?style=for-the-badge&logo=github&logoColor=white" />
15
+ <img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge" />
16
+ </p>
17
+
18
+ **Open-source WhatsApp automation library 2014 no browser required.**
19
+ Built on WebSocket for speed, stability, and full multi-device support.
20
+
21
+ <br/>
22
+
23
+ [Installation](#getting-started) [Documentation](#sendmessage-documentation) [Features](#main-features) [Telegram](https://t.me/Fhkry666)
24
+
25
+ </div>
26
+
27
+ ---
28
+
29
+ ## What is @elfhkry/baileys?
30
+
31
+ **@elfhkry/baileys** is a powerful, open-source library for developers who need reliable WhatsApp automation without the overhead of a browser. Powered by **WebSocket technology**, it supports message management, group administration, interactive messages, and action buttons all in a lightweight and modular package.
32
+
33
+ Actively maintained with continuous improvements to **pairing stability**, **session management**, and **WhatsApp multi-device compatibility**.
34
+
35
+ Perfect for:
36
+ - Business bots & chat automation
37
+ - Customer service systems
38
+ - Broadcast & notification tools
39
+ - E-commerce integrations
40
+
41
+ ---
42
+
43
+ ## Main Features
44
+
45
+ | Feature | Description |
46
+ |---|---|
47
+ | **Custom Pairing** | Stable pairing with your own codes no disconnection issues |
48
+ | **Interactive Messages** | Buttons, menus, native flows, and more |
49
+ | **Session Management** | Automatic, efficient, and long-term stable |
50
+ | **Multi-Device Support** | Fully compatible with WhatsApp's latest multi-device API |
51
+ | **Lightweight & Modular** | Easy to integrate into any Node.js project |
52
+ | **Rich Documentation** | Comprehensive guides and example code included |
53
+ | **Secure Auth** | Improved authentication flow with fixed prior vulnerabilities |
54
+
55
+ ---
56
+
57
+ ## Getting Started
58
+
59
+ Install via npm or yarn:
60
+
61
+ ```bash
62
+ npm install @elfhkry/baileys
63
+ # or
64
+ yarn add @elfhkry/baileys
65
+ ```
66
+
67
+ Then import and initialize:
68
+
69
+ ```javascript
70
+ const { makeWASocket, useMultiFileAuthState } = require("@elfhkry/baileys");
71
+
72
+ const { state, saveCreds } = await useMultiFileAuthState("auth_info");
73
+ const sock = makeWASocket({ auth: state });
74
+
75
+ sock.ev.on("creds.update", saveCreds);
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Additional Functions
81
+
82
+ ### Get Channel ID
83
+ ```javascript
84
+ await sock.newsletterId(url);
85
+ ```
86
+
87
+ ### Check Banned Number
88
+ ```javascript
89
+ await sock.checkWhatsApp(target);
90
+ ```
91
+
92
+ ---
93
+
94
+ ## SendMessage Documentation
95
+
96
+ <details>
97
+ <summary><b>Group Status Message (V2)</b></summary>
98
+ <br/>
99
+
100
+ ```javascript
101
+ await sock.sendMessage(target, {
102
+ groupStatusMessage: {
103
+ text: "Hello World"
104
+ }
105
+ });
106
+ ```
107
+ </details>
108
+
109
+ <details>
110
+ <summary><b>Album Message (Multiple Images)</b></summary>
111
+ <br/>
112
+
113
+ ```javascript
114
+ await sock.sendMessage(target, {
115
+ albumMessage: [
116
+ { image: cihuy, caption: "First photo" },
117
+ { image: { url: "IMAGE_URL" }, caption: "Second photo" }
118
+ ]
119
+ }, { quoted: m });
120
+ ```
121
+ </details>
122
+
123
+ <details>
124
+ <summary><b>Event Message</b></summary>
125
+ <br/>
126
+
127
+ ```javascript
128
+ await sock.sendMessage(target, {
129
+ eventMessage: {
130
+ isCanceled: false,
131
+ name: "Event Name",
132
+ description: "Event description here",
133
+ location: {
134
+ degreesLatitude: 0,
135
+ degreesLongitude: 0,
136
+ name: "Location Name"
137
+ },
138
+ joinLink: "https://call.whatsapp.com/video/example",
139
+ startTime: "1763019000",
140
+ endTime: "1763026200",
141
+ extraGuestsAllowed: false
142
+ }
143
+ }, { quoted: m });
144
+ ```
145
+ </details>
146
+
147
+ <details>
148
+ <summary><b>Poll Result Message</b></summary>
149
+ <br/>
150
+
151
+ ```javascript
152
+ await sock.sendMessage(target, {
153
+ pollResultMessage: {
154
+ name: "Poll Title",
155
+ pollVotes: [
156
+ { optionName: "Option A", optionVoteCount: "112233" },
157
+ { optionName: "Option B", optionVoteCount: "1" }
158
+ ]
159
+ }
160
+ }, { quoted: m });
161
+ ```
162
+ </details>
163
+
164
+ <details>
165
+ <summary><b>Simple Interactive Message</b></summary>
166
+ <br/>
167
+
168
+ ```javascript
169
+ await sock.sendMessage(target, {
170
+ interactiveMessage: {
171
+ header: "Hello World",
172
+ title: "Hello World",
173
+ footer: "telegram: @Fhkry666",
174
+ buttons: [
175
+ {
176
+ name: "cta_copy",
177
+ buttonParamsJson: JSON.stringify({
178
+ display_text: "Copy Code",
179
+ id: "123456789",
180
+ copy_code: "ABC123XYZ"
181
+ })
182
+ }
183
+ ]
184
+ }
185
+ }, { quoted: m });
186
+ ```
187
+ </details>
188
+
189
+ <details>
190
+ <summary><b>Interactive Message with Native Flow</b></summary>
191
+ <br/>
192
+
193
+ ```javascript
194
+ await sock.sendMessage(target, {
195
+ interactiveMessage: {
196
+ header: "Hello World",
197
+ title: "Hello World",
198
+ footer: "telegram: @Fhkry666",
199
+ image: { url: "https://example.com/image.jpg" },
200
+ nativeFlowMessage: {
201
+ messageParamsJson: JSON.stringify({
202
+ limited_time_offer: {
203
+ text: "Limited offer text",
204
+ url: "https://t.me/Fhkry666",
205
+ copy_code: "PROMO2024",
206
+ expiration_time: Date.now() * 999
207
+ },
208
+ bottom_sheet: {
209
+ in_thread_buttons_limit: 2,
210
+ divider_indices: [1, 2, 3, 4, 5, 999],
211
+ list_title: "List Title",
212
+ button_title: "Button Title"
213
+ },
214
+ tap_target_configuration: {
215
+ title: "Title",
216
+ description: "Description text",
217
+ canonical_url: "https://t.me/Fhkry666",
218
+ domain: "shop.example.com",
219
+ button_index: 0
220
+ }
221
+ }),
222
+ buttons: [
223
+ {
224
+ name: "single_select",
225
+ buttonParamsJson: JSON.stringify({ has_multiple_buttons: true })
226
+ },
227
+ {
228
+ name: "call_permission_request",
229
+ buttonParamsJson: JSON.stringify({ has_multiple_buttons: true })
230
+ },
231
+ {
232
+ name: "single_select",
233
+ buttonParamsJson: JSON.stringify({
234
+ title: "Select an Option",
235
+ sections: [
236
+ {
237
+ title: "Section Title",
238
+ highlight_label: "Label",
239
+ rows: [
240
+ {
241
+ title: "Row Title",
242
+ description: "Row description",
243
+ id: "row_1"
244
+ }
245
+ ]
246
+ }
247
+ ],
248
+ has_multiple_buttons: true
249
+ })
250
+ },
251
+ {
252
+ name: "cta_copy",
253
+ buttonParamsJson: JSON.stringify({
254
+ display_text: "Copy Code",
255
+ id: "123456789",
256
+ copy_code: "ABC123XYZ"
257
+ })
258
+ }
259
+ ]
260
+ }
261
+ }
262
+ }, { quoted: m });
263
+ ```
264
+ </details>
265
+
266
+ <details>
267
+ <summary><b>Interactive Message with Thumbnail</b></summary>
268
+ <br/>
269
+
270
+ ```javascript
271
+ await sock.sendMessage(target, {
272
+ interactiveMessage: {
273
+ header: "Hello World",
274
+ title: "Hello World",
275
+ footer: "telegram: @Fhkry666",
276
+ image: { url: "https://example.com/image.jpg" },
277
+ buttons: [
278
+ {
279
+ name: "cta_copy",
280
+ buttonParamsJson: JSON.stringify({
281
+ display_text: "Copy Code",
282
+ id: "123456789",
283
+ copy_code: "ABC123XYZ"
284
+ })
285
+ }
286
+ ]
287
+ }
288
+ }, { quoted: m });
289
+ ```
290
+ </details>