@zaiinlin/bails 0.0.0-stage → 1.0.2

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 (128) hide show
  1. package/README.md +1 -3
  2. package/WAProto/GenerateStatics.sh +3 -0
  3. package/WAProto/WAProto.proto +7772 -0
  4. package/WAProto/fix-imports.js +85 -0
  5. package/WAProto/index.d.ts +79257 -0
  6. package/WAProto/index.js +242946 -0
  7. package/engine-requirements.js +10 -0
  8. package/lib/Defaults/index.js +131 -0
  9. package/lib/Signal/Group/ciphertext-message.js +12 -0
  10. package/lib/Signal/Group/group-session-builder.js +30 -0
  11. package/lib/Signal/Group/group_cipher.js +82 -0
  12. package/lib/Signal/Group/index.js +12 -0
  13. package/lib/Signal/Group/keyhelper.js +18 -0
  14. package/lib/Signal/Group/sender-chain-key.js +26 -0
  15. package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
  16. package/lib/Signal/Group/sender-key-message.js +66 -0
  17. package/lib/Signal/Group/sender-key-name.js +48 -0
  18. package/lib/Signal/Group/sender-key-record.js +41 -0
  19. package/lib/Signal/Group/sender-key-state.js +84 -0
  20. package/lib/Signal/Group/sender-message-key.js +26 -0
  21. package/lib/Signal/libsignal.js +431 -0
  22. package/lib/Signal/lid-mapping.js +277 -0
  23. package/lib/Socket/Client/index.js +3 -0
  24. package/lib/Socket/Client/types.js +11 -0
  25. package/lib/Socket/Client/websocket.js +54 -0
  26. package/lib/Socket/MessageBuilder.js +3729 -0
  27. package/lib/Socket/business.js +379 -0
  28. package/lib/Socket/chats.js +1198 -0
  29. package/lib/Socket/communities.js +431 -0
  30. package/lib/Socket/graphql.js +716 -0
  31. package/lib/Socket/groups.js +374 -0
  32. package/lib/Socket/index.js +29 -0
  33. package/lib/Socket/interop.js +463 -0
  34. package/lib/Socket/luxu.js +387 -0
  35. package/lib/Socket/message-builder.js +556 -0
  36. package/lib/Socket/messages-recv.js +1916 -0
  37. package/lib/Socket/messages-send.js +1516 -0
  38. package/lib/Socket/mex.js +54 -0
  39. package/lib/Socket/newsletter.js +699 -0
  40. package/lib/Socket/privacy.js +318 -0
  41. package/lib/Socket/socket.js +1115 -0
  42. package/lib/Socket/username.js +236 -0
  43. package/lib/Store/index.js +10 -0
  44. package/lib/Store/keyed-db.js +108 -0
  45. package/lib/Store/make-cache-manager-store.js +85 -0
  46. package/lib/Store/make-in-memory-store.js +244 -0
  47. package/lib/Store/make-ordered-dictionary.js +75 -0
  48. package/lib/Store/object-repository.js +32 -0
  49. package/lib/Types/Auth.js +2 -0
  50. package/lib/Types/Bussines.js +2 -0
  51. package/lib/Types/Call.js +2 -0
  52. package/lib/Types/Chat.js +8 -0
  53. package/lib/Types/Contact.js +2 -0
  54. package/lib/Types/Events.js +2 -0
  55. package/lib/Types/GroupMetadata.js +2 -0
  56. package/lib/Types/Label.js +25 -0
  57. package/lib/Types/LabelAssociation.js +7 -0
  58. package/lib/Types/Message.js +11 -0
  59. package/lib/Types/Mex.js +111 -0
  60. package/lib/Types/Product.js +2 -0
  61. package/lib/Types/Signal.js +2 -0
  62. package/lib/Types/Socket.js +3 -0
  63. package/lib/Types/State.js +56 -0
  64. package/lib/Types/USync.js +2 -0
  65. package/lib/Types/index.js +26 -0
  66. package/lib/Utils/auth-utils.js +302 -0
  67. package/lib/Utils/browser-utils.js +48 -0
  68. package/lib/Utils/business.js +231 -0
  69. package/lib/Utils/chat-utils.js +872 -0
  70. package/lib/Utils/companion-reg-client-utils.js +35 -0
  71. package/lib/Utils/crypto.js +118 -0
  72. package/lib/Utils/decode-wa-message.js +350 -0
  73. package/lib/Utils/event-buffer.js +622 -0
  74. package/lib/Utils/generics.js +403 -0
  75. package/lib/Utils/history.js +134 -0
  76. package/lib/Utils/identity-change-handler.js +50 -0
  77. package/lib/Utils/index.js +24 -0
  78. package/lib/Utils/link-preview.js +85 -0
  79. package/lib/Utils/logger.js +3 -0
  80. package/lib/Utils/lt-hash.js +8 -0
  81. package/lib/Utils/make-mutex.js +33 -0
  82. package/lib/Utils/message-composer.js +273 -0
  83. package/lib/Utils/message-retry-manager.js +265 -0
  84. package/lib/Utils/messages-media.js +870 -0
  85. package/lib/Utils/messages.js +1394 -0
  86. package/lib/Utils/noise-handler.js +201 -0
  87. package/lib/Utils/offline-node-processor.js +40 -0
  88. package/lib/Utils/pre-key-manager.js +106 -0
  89. package/lib/Utils/process-message.js +630 -0
  90. package/lib/Utils/reporting-utils.js +258 -0
  91. package/lib/Utils/signal.js +201 -0
  92. package/lib/Utils/stanza-ack.js +38 -0
  93. package/lib/Utils/sticker.js +133 -0
  94. package/lib/Utils/sync-action-utils.js +49 -0
  95. package/lib/Utils/tc-token-utils.js +163 -0
  96. package/lib/Utils/use-multi-file-auth-state.js +121 -0
  97. package/lib/Utils/use-sqlite-auth-state.js +162 -0
  98. package/lib/Utils/validate-connection.js +203 -0
  99. package/lib/WABinary/constants.js +1301 -0
  100. package/lib/WABinary/decode.js +262 -0
  101. package/lib/WABinary/encode.js +220 -0
  102. package/lib/WABinary/generic-utils.js +204 -0
  103. package/lib/WABinary/index.js +6 -0
  104. package/lib/WABinary/jid-utils.js +98 -0
  105. package/lib/WABinary/types.js +2 -0
  106. package/lib/WAM/BinaryInfo.js +10 -0
  107. package/lib/WAM/constants.js +22853 -0
  108. package/lib/WAM/encode.js +150 -0
  109. package/lib/WAM/index.js +4 -0
  110. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +53 -0
  111. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
  112. package/lib/WAUSync/Protocols/USyncContactProtocol.js +54 -0
  113. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  114. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  115. package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +58 -0
  116. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +30 -0
  117. package/lib/WAUSync/Protocols/USyncPictureProtocol.js +32 -0
  118. package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +28 -0
  119. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +39 -0
  120. package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
  121. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +27 -0
  122. package/lib/WAUSync/Protocols/index.js +12 -0
  123. package/lib/WAUSync/USyncQuery.js +151 -0
  124. package/lib/WAUSync/USyncUser.js +56 -0
  125. package/lib/WAUSync/index.js +3 -0
  126. package/lib/index.js +92 -0
  127. package/package.json +143 -4
  128. package/readme.md +456 -0
package/readme.md ADDED
@@ -0,0 +1,456 @@
1
+ <p align="center">
2
+ <img src="https://e.top4top.io/p_38721hu6c1.jpg" width="250"/>
3
+ </p>
4
+
5
+ <h1 align="center">WhatsApp Baileys</h1>
6
+
7
+ <p align="center">
8
+ Open-source library for building fast, stable WhatsApp automation and integrations over WebSocket — no browser required.
9
+ </p>
10
+
11
+ <p align="center">
12
+ <img src="https://img.shields.io/badge/Node.js-%3E%3D20-339933?logo=node.js&logoColor=white" alt="Node.js" />
13
+ <img src="https://img.shields.io/badge/license-MIT-blue" />
14
+ <img src="https://img.shields.io/badge/multi--device-supported-success" />
15
+ </p>
16
+
17
+ > [!NOTE]
18
+ > `"@zaiinlin/bails": "^1.0.2"` is an unofficial WhatsApp Web API library. Not affiliated, not authorized, not maintained, not sponsored, and not endorsed by WhatsApp or Meta.
19
+ >
20
+ > Use Baileys responsibly, and comply with the WhatsApp Terms of Service and applicable laws.
21
+
22
+ ---
23
+
24
+ # Table of Contents
25
+
26
+ - [Requirements](#requirements)
27
+ - [Installation](#installation)
28
+ - [Import](#import)
29
+ - [Quick Start](#quick-start)
30
+ - [With QR Code](#with-qr-code)
31
+ - [With Pairing Code](#with-pairing-code)
32
+ - [Sending Message](#sending-message)
33
+ - [Generic Send / Relay](#generic-send--relay)
34
+ - [Simple Senders](#simple-senders)
35
+ - [Ban Checker](#ban-checker)
36
+ - [Send Message with Participant](#sending-message-with-participant)
37
+ - [Rich Menu](#rich-menu)
38
+ - [Message Builder](#message-builder)
39
+ - [Import](#import-1)
40
+ - [Example](#example)
41
+ - [Button](#button)
42
+ - [Quick Reply + URL + Copy](#quick-reply--url--copy)
43
+ - [ButtonV2](#buttonv2)
44
+ - [Carousel](#carousel)
45
+ - [Why Choose WhatsApp Baileys?](#why-choose-whatsapp-baileys)
46
+ - [Contributors](#contributors)
47
+ - [Contact & Support](#contact--support)
48
+
49
+ ---
50
+
51
+ # Requirements
52
+
53
+ - Node.js **>= 20**
54
+ - Optional peer dependencies depending on the features you use:
55
+ - `sharp` or `jimp` for image processing
56
+ - `link-preview-js` for link previews
57
+ - `audio-decode` for audio waveform handling
58
+ - `fluent-ffmpeg` for frame preview video, MessageBuilder Toolkit.getMp4Preview
59
+
60
+ ---
61
+
62
+ # Installation
63
+
64
+ ```bash
65
+ npm install @zaiinlin/bails
66
+ ```
67
+
68
+ Add it to your `package.json`:
69
+
70
+ ```json
71
+ {
72
+ "dependencies": {
73
+ "@zaiinlin/bails": "^1.0.2"
74
+ }
75
+ }
76
+ ```
77
+
78
+ ---
79
+
80
+ # Import
81
+
82
+ ```javascript
83
+ const {
84
+ default: makeWASocket,
85
+ // Other Options
86
+ } = require('@zaiinlin/bails');
87
+ ```
88
+
89
+ ---
90
+
91
+ # Quick Start
92
+
93
+ ## With QR Code
94
+
95
+ ```javascript
96
+ const {
97
+ default: makeWASocket,
98
+ Browsers
99
+ // Other Options
100
+ } = require('@zaiinlin/bails');
101
+
102
+ const client = makeWASocket({
103
+ browser: Browsers.ubuntu('Chrome'),
104
+ printQRInTerminal: true
105
+ });
106
+ ```
107
+
108
+ ## With Pairing Code
109
+
110
+ ```javascript
111
+ const {
112
+ default: makeWASocket,
113
+ fetchLatestWAWebVersion,
114
+ Browsers
115
+ } = require('@zaiinlin/bails');
116
+
117
+ const client = makeWASocket({
118
+ browser: Browsers.ubuntu('Chrome'),
119
+ printQRInTerminal: false,
120
+ version: fetchLatestWAWebVersion(),
121
+ auth: state
122
+ });
123
+
124
+ const number = "628XXXXX";
125
+ const code = await client.requestPairingCode(number.trim()); // Use (number, "XXXXXXXX") for custom pairing
126
+
127
+ console.log("Ur pairing code : " + code);
128
+ ```
129
+
130
+ ---
131
+
132
+ # Sending Message
133
+
134
+ ## Generic Send / Relay
135
+
136
+ ```javascript
137
+ // relayMessage — sends a raw message object
138
+ (async () => {
139
+ await client.relayMessage(m.chat, {
140
+ conversation: 'zaienv'
141
+ });
142
+ })();
143
+
144
+ // sendMessage — the standard way to send a message
145
+ (async () => {
146
+ await client.sendMessage(m.chat, {
147
+ text: 'zaienv'
148
+ });
149
+ })();
150
+ ```
151
+
152
+ ## Simple Senders
153
+
154
+ ### Send Text
155
+
156
+ ```javascript
157
+ (async () => {
158
+ await client.sendText(m.chat, 'Hi!', {
159
+ contextInfo: {
160
+ mentionedJid: [jid]
161
+ }
162
+ });
163
+ })();
164
+ ```
165
+
166
+ ### Send Image
167
+
168
+ ```javascript
169
+ (async () => {
170
+ await client.sendImage(m.chat, { url: './photo.jpg' }, 'image caption');
171
+ })();
172
+ ```
173
+
174
+ ### Send Video
175
+
176
+ ```javascript
177
+ (async () => {
178
+ await client.sendVideo(m.chat, { url: './clip.mp4' }, 'video caption');
179
+ })();
180
+ ```
181
+
182
+ ### Send Audio
183
+
184
+ ```javascript
185
+ (async () => {
186
+ await client.sendAudio(m.chat, { url: './clip.mp3' });
187
+ })();
188
+ ```
189
+
190
+ ### Send Location
191
+
192
+ ```javascript
193
+ (async () => {
194
+ await client.sendLocation(m.chat, 'Location name', -6.2, 106.8, 'https://maps.example', '1234567890');
195
+ })();
196
+ ```
197
+
198
+ ### Send Poll
199
+
200
+ ```javascript
201
+ (async () => {
202
+ await client.sendPoll(m.chat, 'Pick one', ['Option 1', 'Option 2', 'Option 3'], true);
203
+ })();
204
+ ```
205
+
206
+ ### Send Quiz
207
+
208
+ ```javascript
209
+ (async () => {
210
+ await client.sendQuiz(m.chat, 'Correct answer?', ['1', '2', '3'], '2');
211
+ })();
212
+ ```
213
+
214
+ ## Ban Checker
215
+
216
+ `checkBan` allows you to check the WhatsApp ban status of a phone number using an external API.
217
+
218
+ ### Example
219
+
220
+ ```javascript
221
+ (async () => {
222
+ try {
223
+ const number = '6281234567890';
224
+ const result = await checkBan(number);
225
+
226
+ await client.sendMessage(m.chat, {
227
+ text: JSON.stringify(result, null, 2)
228
+ });
229
+ } catch (error) {
230
+ console.error('Ban Checker Error:', error.message);
231
+ }
232
+ })();
233
+ ```
234
+
235
+ ### Usage
236
+
237
+ - Replace `6281234567890` with the phone number you want to check.
238
+ - `checkBan` must already be defined in your bot's environment.
239
+
240
+ > [!NOTE]
241
+ > Ban Checker relies on an external API. Its availability and accuracy depend on the API provider. Results are not an official confirmation of a WhatsApp account's ban status.
242
+
243
+ # Send Message with Participant
244
+
245
+ `relayMessage`:
246
+
247
+ ```javascript
248
+ (async () => {
249
+ await client.relayMessage(m.chat, {
250
+ extendedTextMessage: {
251
+ text: 'zaienv'
252
+ }
253
+ }, {
254
+ ptcp: true
255
+ });
256
+ })();
257
+ ```
258
+
259
+ `sendMessage`:
260
+
261
+ ```javascript
262
+ (async () => {
263
+ await client.sendMessage(m.chat, {
264
+ text: 'zaienv'
265
+ }, {
266
+ ptcp: true
267
+ });
268
+ })();
269
+ ```
270
+
271
+ ## Rich Menu
272
+
273
+ `sendRich` sends a rich response with an optional header image, action buttons, carousel cards, and an open-URL footer:
274
+
275
+ ```javascript
276
+ await client.sendRich(m.chat, {
277
+ header: {
278
+ disclaimer: true,
279
+ disclaimerText: "t.me/zdven",
280
+ title: "zaienv"
281
+ },
282
+ body: {
283
+ title: "Select Option",
284
+ buttons: ["Menu 1", "Menu 2"]
285
+ },
286
+ footer: {
287
+ text: "Telegram Channel",
288
+ url: "https://t.me/zdxnv"
289
+ }
290
+ });
291
+ ```
292
+
293
+ ---
294
+
295
+ # Message Builder
296
+
297
+ MessageBuilder v4.7 is included directly in `"github:zaiinlin/baileys"`.
298
+
299
+ ## Import
300
+
301
+ ```javascript
302
+ const {
303
+ VERSION,
304
+ Button,
305
+ ButtonV2,
306
+ Carousel,
307
+ AIRich,
308
+ Toolkit,
309
+ bind,
310
+ MB
311
+ } = require('@zaiinlin/bails');
312
+ ```
313
+
314
+ > [!NOTE]
315
+ > MessageBuilder is integrated. You don't need to install `baileys-mbuilder` separately.
316
+
317
+ ---
318
+
319
+ ## Example
320
+
321
+ ```javascript
322
+ const { MB } = require('@zaiinlin/bails')
323
+
324
+ const rich = new MB.AIRich(sock)
325
+ .setTitle('zaienv')
326
+ .setFooter('Dibuat dengan AIRich')
327
+ .addText('Halo! Ini respons rich.')
328
+ .addCode('javascript', `console.log('Halo zai')`)
329
+ .addTable([
330
+ ['Fitur', 'Status'],
331
+ ['Button', 'Tersedia'],
332
+ ['Carousel', 'Tersedia'],
333
+ ['AIRich', 'Eksperimental']
334
+ ])
335
+ .addSuggest(['List Menu', 'Help', 'About zai'])
336
+
337
+ await rich.send(jid)
338
+ ```
339
+
340
+ ---
341
+
342
+ ## Button
343
+
344
+ Builder `Button` is used for native-flow interactive messages.
345
+
346
+ ### Quick Reply + URL + Copy
347
+
348
+ ```js
349
+ const { MB } = require('@zaiinlin/bails')
350
+
351
+ const msg = new MB.Button(client)
352
+ .setTitle('Select Menu')
353
+ .setBody('Pilih salah satu di bawah.')
354
+ .setFooter('t.me/zdven')
355
+ .addReply('Ping', 'ping')
356
+ .addUrl('Buka Website', 'https://example.com')
357
+ .addCopy('Salin Kode', 'zaienv')
358
+
359
+ await msg.send(m.chat)
360
+ ```
361
+
362
+ ---
363
+
364
+ ## ButtonV2
365
+
366
+ `ButtonV2` provides a simpler classic button builder.
367
+
368
+ ```javascript
369
+ const { MB } = require('@zaiinlin/bails')
370
+
371
+ const message = new MB.ButtonV2(client)
372
+ .setTitle('zaienv')
373
+ .setSubtitle('WhatsApp Bot')
374
+ .setBody('Pilih satu tindakan.')
375
+ .setFooter('zaiBaileys')
376
+ .setThumbnail('https://example.com/xxx.jpg')
377
+ .addButton('Menu', 'menu')
378
+ .addButton('Ping', 'ping')
379
+
380
+ await message.send(m.chat)
381
+ ```
382
+
383
+ ---
384
+
385
+ ## Carousel
386
+
387
+ Carousel cards can be created from `Button.toCard()` and then submitted to `Carousel`.
388
+
389
+ ```javascript
390
+ const { MB } = require('@zaiinlin/bails')
391
+
392
+ const card1 = await new MB.Button(client)
393
+ .setImage('https://example.com/card1.jpg')
394
+ .setBody('Kartu pertama')
395
+ .addReply('Pilih', 'card_1')
396
+ .toCard()
397
+
398
+ const card2 = await new MB.Button(client)
399
+ .setImage('https://example.com/card2.jpg')
400
+ .setBody('Kartu kedua')
401
+ .addUrl('Buka', 'https://example.com')
402
+ .toCard()
403
+
404
+ const carousel = new MB.Carousel(client)
405
+ .setBody('Pilih salah satu kartu di bawah.')
406
+ .setFooter('zaiCarousel')
407
+ .addCard([card1, card2])
408
+
409
+ await carousel.send(jid)
410
+ ```
411
+
412
+ > [!IMPORTANT]
413
+ > Each carousel card must have an image or video media attachment in its header.
414
+
415
+ ---
416
+
417
+ # Why Choose WhatsApp Baileys?
418
+
419
+ 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.
420
+
421
+ ---
422
+
423
+ # Contributors
424
+
425
+ <table>
426
+ <tr>
427
+ <td align="center">
428
+ <a href="https://github.com/zaienv">
429
+ <img src="https://cdn.takahasii.my.id/file/414f32e8-80ca-4711-beb7-4d1f68b0e5e3?mode=attachment&exp=0&sig=ae07c53dec74437ac82708f1b88245e1a38aa02891bc4abd5ce58217248b025e" width="80px;" style="border-radius:50%;" alt="Main contributor"/>
430
+ <br /><sub><b>Z A I D E V</b></sub>
431
+ </a>
432
+ </td>
433
+ </tr>
434
+ </table>
435
+
436
+ ---
437
+
438
+ ## Contact & Support
439
+
440
+ Have questions, suggestions, or need help with this project? Feel free to reach out through the channels below.
441
+
442
+ <p align="center">
443
+ <a href="https://t.me/zdven">
444
+ <img src="https://img.shields.io/badge/Telegram-Contact%20Developer-26A5E4?style=flat-square&logo=telegram&logoColor=white" alt="Telegram"/>
445
+ </a>
446
+ <a href="https://whatsapp.com/channel/0029VbDXMbwElagkugFqkU3U">
447
+ <img src="https://img.shields.io/badge/WhatsApp-Official%20Channel-25D366?style=flat-square&logo=whatsapp&logoColor=white" alt="WhatsApp Channel"/>
448
+ </a>
449
+ <a href="https://t.me/zdxnv">
450
+ <img src="https://img.shields.io/badge/Telegram-Updates-2CA5E0?style=flat-square&logo=telegram&logoColor=white" alt="Telegram Channel"/>
451
+ </a>
452
+ </p>
453
+
454
+ <p align="center">
455
+ <sub>Developed and maintained by <a href="https://github.com/zaienv">zai</a>.</sub>
456
+ </p>