@dnuzi/baileys 0.0.1

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 (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +374 -0
  3. package/WAProto/index.js +104216 -0
  4. package/engine-requirements.js +19 -0
  5. package/lib/@dnuzi +1 -0
  6. package/lib/Defaults/index.js +143 -0
  7. package/lib/Signal/Group/ciphertext-message.js +11 -0
  8. package/lib/Signal/Group/group-session-builder.js +29 -0
  9. package/lib/Signal/Group/group_cipher.js +81 -0
  10. package/lib/Signal/Group/index.js +11 -0
  11. package/lib/Signal/Group/keyhelper.js +17 -0
  12. package/lib/Signal/Group/sender-chain-key.js +25 -0
  13. package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
  14. package/lib/Signal/Group/sender-key-message.js +65 -0
  15. package/lib/Signal/Group/sender-key-name.js +47 -0
  16. package/lib/Signal/Group/sender-key-record.js +40 -0
  17. package/lib/Signal/Group/sender-key-state.js +83 -0
  18. package/lib/Signal/Group/sender-message-key.js +25 -0
  19. package/lib/Signal/libsignal.js +402 -0
  20. package/lib/Signal/lid-mapping.js +270 -0
  21. package/lib/Socket/Client/index.js +2 -0
  22. package/lib/Socket/Client/types.js +10 -0
  23. package/lib/Socket/Client/websocket.js +53 -0
  24. package/lib/Socket/business.js +378 -0
  25. package/lib/Socket/chats.js +1048 -0
  26. package/lib/Socket/communities.js +430 -0
  27. package/lib/Socket/groups.js +328 -0
  28. package/lib/Socket/index.js +11 -0
  29. package/lib/Socket/messages-recv.js +1463 -0
  30. package/lib/Socket/messages-send.js +1241 -0
  31. package/lib/Socket/mex.js +41 -0
  32. package/lib/Socket/newsletter.js +227 -0
  33. package/lib/Socket/socket.js +951 -0
  34. package/lib/Store/index.js +3 -0
  35. package/lib/Store/make-in-memory-store.js +421 -0
  36. package/lib/Store/make-ordered-dictionary.js +78 -0
  37. package/lib/Store/object-repository.js +23 -0
  38. package/lib/Types/Auth.js +1 -0
  39. package/lib/Types/Bussines.js +1 -0
  40. package/lib/Types/Call.js +1 -0
  41. package/lib/Types/Chat.js +7 -0
  42. package/lib/Types/Contact.js +1 -0
  43. package/lib/Types/Events.js +1 -0
  44. package/lib/Types/GroupMetadata.js +1 -0
  45. package/lib/Types/Label.js +24 -0
  46. package/lib/Types/LabelAssociation.js +6 -0
  47. package/lib/Types/Message.js +17 -0
  48. package/lib/Types/Newsletter.js +33 -0
  49. package/lib/Types/Product.js +1 -0
  50. package/lib/Types/Signal.js +1 -0
  51. package/lib/Types/Socket.js +2 -0
  52. package/lib/Types/State.js +12 -0
  53. package/lib/Types/USync.js +1 -0
  54. package/lib/Types/index.js +25 -0
  55. package/lib/Utils/auth-utils.js +289 -0
  56. package/lib/Utils/browser-utils.js +28 -0
  57. package/lib/Utils/business.js +230 -0
  58. package/lib/Utils/chat-utils.js +811 -0
  59. package/lib/Utils/companion-reg-client-utils.js +32 -0
  60. package/lib/Utils/crypto.js +117 -0
  61. package/lib/Utils/decode-wa-message.js +282 -0
  62. package/lib/Utils/event-buffer.js +573 -0
  63. package/lib/Utils/generics.js +385 -0
  64. package/lib/Utils/history.js +130 -0
  65. package/lib/Utils/identity-change-handler.js +48 -0
  66. package/lib/Utils/index.js +22 -0
  67. package/lib/Utils/link-preview.js +84 -0
  68. package/lib/Utils/logger.js +2 -0
  69. package/lib/Utils/lt-hash.js +7 -0
  70. package/lib/Utils/make-mutex.js +32 -0
  71. package/lib/Utils/message-retry-manager.js +224 -0
  72. package/lib/Utils/messages-media.js +830 -0
  73. package/lib/Utils/messages.js +1887 -0
  74. package/lib/Utils/noise-handler.js +200 -0
  75. package/lib/Utils/offline-node-processor.js +39 -0
  76. package/lib/Utils/pre-key-manager.js +105 -0
  77. package/lib/Utils/process-message.js +527 -0
  78. package/lib/Utils/reporting-utils.js +257 -0
  79. package/lib/Utils/signal.js +158 -0
  80. package/lib/Utils/stanza-ack.js +37 -0
  81. package/lib/Utils/sync-action-utils.js +47 -0
  82. package/lib/Utils/tc-token-utils.js +17 -0
  83. package/lib/Utils/use-multi-file-auth-state.js +120 -0
  84. package/lib/Utils/use-single-file-auth-state.js +96 -0
  85. package/lib/Utils/validate-connection.js +206 -0
  86. package/lib/WABinary/constants.js +1300 -0
  87. package/lib/WABinary/decode.js +261 -0
  88. package/lib/WABinary/encode.js +219 -0
  89. package/lib/WABinary/generic-utils.js +227 -0
  90. package/lib/WABinary/index.js +5 -0
  91. package/lib/WABinary/jid-utils.js +95 -0
  92. package/lib/WABinary/types.js +1 -0
  93. package/lib/WAM/BinaryInfo.js +9 -0
  94. package/lib/WAM/constants.js +22852 -0
  95. package/lib/WAM/encode.js +149 -0
  96. package/lib/WAM/index.js +3 -0
  97. package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -0
  98. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
  99. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
  100. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
  101. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
  102. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
  103. package/lib/WAUSync/Protocols/index.js +4 -0
  104. package/lib/WAUSync/USyncQuery.js +93 -0
  105. package/lib/WAUSync/USyncUser.js +22 -0
  106. package/lib/WAUSync/index.js +3 -0
  107. package/lib/index.js +51 -0
  108. package/package.json +77 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DanuZz ?
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,374 @@
1
+ # 🌟 @dnuzi/baileys
2
+
3
+ [![npm version](https://badge.fury.io/js/@dnuzi%2Fbaileys.svg)](https://badge.fury.io/js/@dnuzi/baileys)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js Version](https://img.shields.io/node/v/@dnuzi/baileys.svg)](https://nodejs.org/)
6
+ [![Downloads](https://img.shields.io/npm/dm/@dnuzi/baileys.svg)](https://npmjs.com/package/@dnuzi/baileys)
7
+
8
+ <p align="center">
9
+ <img src="https://github.com/dnuzi/mova-npm-media/blob/main/baileyz.gif" alt="@dnuzi/baileys Thumbnail" width="500" />
10
+ </p>
11
+
12
+ **@dnuzi/baileys** is a powerful, lightweight, and actively maintained fork of Baileys — a WebSocket-based Node.js library for seamless WhatsApp automation. It delivers high performance without browser dependencies and includes many enhancements for modern WhatsApp features.
13
+
14
+ Ideal for bots, customer service tools, interactive automations, e-commerce, and more.
15
+
16
+ ### ⚙️ Key Enhancements
17
+
18
+ - **Advanced Pairing**: Custom alphanumeric pairing codes with improved reliability.
19
+ - **Rich Interactive Messages**: Buttons, lists, native flows, carousels, limited-time offers, polls, events, and more.
20
+ - **Media & Albums**: Full album (carousel) support, HD profile pics, thumbnails, buffer-only documents.
21
+ - **Newsletter/Channel Tools**: Create, update, react, and manage WhatsApp Channels.
22
+ - **Extra Message Types**: Group status, AI labels, view-once variants, external ad replies, payment messages, sticker packs, and raw proto support.
23
+ - **Utilities**: `findUserId`, custom pairing, better session management, and more.
24
+ - **Multi-Device Ready** with stable reconnection.
25
+
26
+ > **Developer**: [@DanuZz](https://danuzz.movanest.xyz)
27
+ > **Repository**: [npmjs.com/package/@dnuzi/baileys](https://npmjs.com/package/@dnuzi/baileys)
28
+
29
+ ---
30
+
31
+ ## 🚀 Installation
32
+
33
+ ```bash
34
+ npm install @dnuzi/baileys
35
+ # or
36
+ yarn add @dnuzi/baileys
37
+ # or
38
+ pnpm add @dnuzi/baileys
39
+ ```
40
+
41
+ **Requirements**: Node.js ≥ 20.x
42
+ Recommended: `pino`, `@hapi/boom`, `delay` (built-in).
43
+
44
+ ---
45
+
46
+ ## 🔧 Quick Start
47
+
48
+ ```javascript
49
+ import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from '@dnuzi/baileys';
50
+ import { Boom } from '@hapi/boom';
51
+ import pino from 'pino';
52
+
53
+ const logger = pino({ level: 'silent' });
54
+
55
+ const connectToWhatsApp = async () => {
56
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys');
57
+
58
+ const sock = makeWASocket({
59
+ logger,
60
+ auth: state,
61
+ printQRInTerminal: false,
62
+ syncFullHistory: false,
63
+ });
64
+
65
+ sock.ev.on('creds.update', saveCreds);
66
+
67
+ sock.ev.on('connection.update', (update) => {
68
+ const { connection, lastDisconnect } = update;
69
+
70
+ if (connection === 'close') {
71
+ const shouldReconnect = new Boom(lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut;
72
+ console.log('Connection closed due to', lastDisconnect?.error, '— reconnecting:', shouldReconnect);
73
+ if (shouldReconnect) connectToWhatsApp();
74
+ } else if (connection === 'open') {
75
+ console.log('✅ Connected to WhatsApp');
76
+ }
77
+ });
78
+
79
+ // Generate pairing code on first connection
80
+ sock.ev.on('connection.update', async (update) => {
81
+ if (update.connection === 'connecting' && !sock.authState.creds.registered) {
82
+ await delay(1500);
83
+ const code = await sock.requestPairingCode('94XXXXXXXXXX'); // Your number with country code, no '+'
84
+ console.log('🔗 Pairing Code:', code);
85
+ }
86
+ });
87
+
88
+ // Example message handler
89
+ sock.ev.on('messages.upsert', async ({ messages }) => {
90
+ for (const m of messages) {
91
+ if (!m.message) continue;
92
+ const jid = m.key.remoteJid;
93
+ await sock.sendMessage(jid, { text: '👋 Hello from @dnuzi/baileys!' });
94
+ }
95
+ });
96
+
97
+ return sock;
98
+ };
99
+
100
+ connectToWhatsApp();
101
+ ```
102
+
103
+ ---
104
+
105
+ ## 📖 All Examples (Click to Expand)
106
+
107
+ ### 📬 Basic Text, Mention, Reaction, Location & Poll
108
+
109
+ <details>
110
+ <summary>Click to view basic messaging examples</summary>
111
+
112
+ ```javascript
113
+ // Text message
114
+ await sock.sendMessage(jid, { text: '👋 Hello from @dnuzi/baileys' }, { quoted: m });
115
+
116
+ // Mention
117
+ await sock.sendMessage(jid, {
118
+ text: 'Hello @628123456789',
119
+ mentions: ['628123456789@s.whatsapp.net']
120
+ });
121
+
122
+ // Mention All
123
+ await sock.sendMessage(jid, {
124
+ text: 'Hello everyone!',
125
+ mentionAll: true
126
+ });
127
+
128
+ // Reaction
129
+ await sock.sendMessage(jid, {
130
+ react: { key: m.key, text: '❤️' }
131
+ });
132
+
133
+ // Location
134
+ await sock.sendMessage(jid, {
135
+ location: {
136
+ degreesLatitude: 37.422,
137
+ degreesLongitude: -122.084,
138
+ name: 'Googleplex'
139
+ }
140
+ });
141
+
142
+ // Poll
143
+ await sock.sendMessage(jid, {
144
+ poll: {
145
+ name: 'Favorite Color?',
146
+ values: ['Red', 'Blue', 'Green'],
147
+ selectableCount: 1
148
+ }
149
+ });
150
+ ```
151
+ </details>
152
+
153
+ ### 🖼️ Media Messages (Image, Video, Audio, Sticker, Album)
154
+
155
+ <details>
156
+ <summary>Click to view media sending examples</summary>
157
+
158
+ ```javascript
159
+ // Image
160
+ await sock.sendMessage(jid, {
161
+ image: { url: './image.jpg' },
162
+ caption: 'Beautiful image'
163
+ });
164
+
165
+ // Video
166
+ await sock.sendMessage(jid, {
167
+ video: { url: './video.mp4' },
168
+ caption: 'Cool video',
169
+ gifPlayback: false
170
+ });
171
+
172
+ // Sticker
173
+ await sock.sendMessage(jid, {
174
+ sticker: { url: './sticker.webp' }
175
+ });
176
+
177
+ // Audio / Voice Note
178
+ await sock.sendMessage(jid, {
179
+ audio: { url: './audio.mp3' },
180
+ ptt: true // true = voice note
181
+ });
182
+
183
+ // Album (Carousel)
184
+ await sock.sendMessage(jid, {
185
+ album: [
186
+ { image: { url: './pic1.jpg' }, caption: 'Photo 1' },
187
+ { video: { url: './clip.mp4' }, caption: 'Video 1' }
188
+ ]
189
+ });
190
+ ```
191
+ </details>
192
+
193
+ ### 👉🏻 Interactive Messages (Buttons, List, Native Flow, Carousel)
194
+
195
+ <details>
196
+ <summary>Click to view interactive message examples</summary>
197
+
198
+ ```javascript
199
+ // Simple Buttons
200
+ await sock.sendMessage(jid, {
201
+ text: 'Choose one:',
202
+ footer: '@dnuzi/baileys',
203
+ buttons: [
204
+ { text: 'Click Me', id: 'btn1' },
205
+ { text: 'Visit Site', id: 'btn2' }
206
+ ]
207
+ });
208
+
209
+ // List (works best in private chats)
210
+ await sock.sendMessage(jid, {
211
+ text: 'Select option',
212
+ footer: '@dnuzi/baileys',
213
+ buttonText: 'Select',
214
+ sections: [{
215
+ title: 'Menu',
216
+ rows: [{ title: 'Option A', rowId: 'opt1' }]
217
+ }]
218
+ });
219
+
220
+ // Advanced Interactive with Native Flow + Carousel
221
+ await sock.sendMessage(jid, {
222
+ text: 'Explore options',
223
+ footer: '@dnuzi/baileys',
224
+ cards: [ /* array of card objects with image, caption, nativeFlow */ ]
225
+ });
226
+ ```
227
+ </details>
228
+
229
+ ### 💳 Payment & Product Messages
230
+
231
+ <details>
232
+ <summary>Click to view payment & product examples</summary>
233
+
234
+ ```javascript
235
+ // Request Payment
236
+ await sock.sendMessage(jid, {
237
+ requestPaymentFrom: 'recipient@s.whatsapp.net',
238
+ amount: 49900,
239
+ currency: 'USD'
240
+ });
241
+
242
+ // Product Message
243
+ await sock.sendMessage(jid, {
244
+ image: { url: './prod.jpg' },
245
+ product: { title: 'Baileyz Enterprise' },
246
+ businessOwnerJid: '0@s.whatsapp.net'
247
+ });
248
+ ```
249
+ </details>
250
+
251
+ ### 📣 Newsletter / Channel Management
252
+
253
+ <details>
254
+ <summary>Click to view newsletter examples</summary>
255
+
256
+ ```javascript
257
+ // Create newsletter
258
+ await sock.newsletterCreate('My Channel');
259
+
260
+ // Update description
261
+ await sock.newsletterUpdateDescription('1234XXXX@newsletter', 'Daily updates!');
262
+
263
+ // React to channel message
264
+ await sock.newsletterReactMessage('1234XXXX@newsletter', '192', '💜');
265
+
266
+ // Get subscribed newsletters
267
+ const newsletters = await sock.newsletterSubscribed();
268
+ ```
269
+ </details>
270
+
271
+ ### 👥 Group Management
272
+
273
+ <details>
274
+ <summary>Click to view group examples</summary>
275
+
276
+ ```javascript
277
+ // Create group
278
+ const group = await sock.groupCreate('My Group', ['94XXXXXXXXXX@s.whatsapp.net']);
279
+
280
+ // Add member
281
+ await sock.groupParticipantsUpdate(group.id, ['number@s.whatsapp.net'], 'add');
282
+
283
+ // Update subject / description / picture
284
+ await sock.groupUpdateSubject(group.id, 'New Name');
285
+ await sock.groupUpdateDescription(group.id, 'Group description');
286
+ await sock.updateProfilePicture(group.id, { url: './photo.jpg' });
287
+ ```
288
+ </details>
289
+
290
+ ### 🔧 Utility & Special Features
291
+
292
+ <details>
293
+ <summary>Click to view utility examples</summary>
294
+
295
+ ```javascript
296
+ // Custom Pairing Code
297
+ const code = await sock.requestPairingCode('94XXXXXXXXXX', 'THANKUU1');
298
+ console.log('Pairing Code:', code);
299
+
300
+ // Find User ID (PN <-> LID)
301
+ const ids = await sock.findUserId('94XXXXXXXXXX@s.whatsapp.net');
302
+ console.log(ids);
303
+
304
+ // AI Label
305
+ await sock.sendMessage(jid, {
306
+ text: 'AI generated message',
307
+ ai: true
308
+ });
309
+
310
+ // Group Status Message
311
+ await sock.sendMessage(jid, {
312
+ groupStatus: true,
313
+ image: { url: './status.jpg' },
314
+ caption: 'Group update!'
315
+ });
316
+
317
+ // External Ad Reply
318
+ await sock.sendMessage(jid, {
319
+ text: 'Check this out',
320
+ externalAdReply: {
321
+ title: 'Special Offer',
322
+ thumbnail: fs.readFileSync('./thumb.jpg')
323
+ }
324
+ });
325
+ ```
326
+ </details>
327
+
328
+ ### 📊 More Advanced Message Types (View Once, Ephemeral, Raw, etc.)
329
+
330
+ <details>
331
+ <summary>Click to view advanced wrappers</summary>
332
+
333
+ ```javascript
334
+ // View Once
335
+ await sock.sendMessage(jid, {
336
+ image: { url: './secret.jpg' },
337
+ viewOnce: true
338
+ });
339
+
340
+ // Ephemeral
341
+ await sock.sendMessage(jid, {
342
+ text: 'This will disappear',
343
+ ephemeral: true
344
+ });
345
+
346
+ // Raw (manual proto)
347
+ await sock.sendMessage(jid, {
348
+ extendedTextMessage: { text: 'Custom message' },
349
+ raw: true
350
+ });
351
+ ```
352
+ </details>
353
+
354
+ ---
355
+
356
+ ## 🚀 Why @dnuzi/baileys?
357
+
358
+ - **High Stability** — Fixed pairing and reconnection issues.
359
+ - **Feature-Rich** — Many extensions not available in the base library.
360
+ - **Developer Friendly** — Clean API, TypeScript support, and modular design.
361
+ - **Production Proven** — Powers real-world bots and services.
362
+
363
+ **Built with ❤️** for the WhatsApp automation community.
364
+
365
+ ---
366
+
367
+ ## 📄 License
368
+ MIT © [@DanuZz](https://danuzz.movanest.xyz)
369
+
370
+ ## 📞 Support & Contact
371
+ - **Website**: [MovaNest](https://www.movanest.xyz)
372
+ - **Developer**: [@DanuZz](https://danuzz.movanest.xyz)
373
+
374
+ Let's automate the future together! 🚀