@wanzforme/bails 0.0.0-stage → 1.0.0

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 +355 -2
  2. package/WAProto/GenerateStatics.sh +3 -0
  3. package/WAProto/WAProto.proto +6847 -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 +1580 -0
  38. package/lib/Socket/mex.js +54 -0
  39. package/lib/Socket/newsletter.js +641 -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 +409 -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 +25 -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/meta-ai-msmsg.js +155 -0
  87. package/lib/Utils/noise-handler.js +201 -0
  88. package/lib/Utils/offline-node-processor.js +40 -0
  89. package/lib/Utils/pre-key-manager.js +106 -0
  90. package/lib/Utils/process-message.js +630 -0
  91. package/lib/Utils/reporting-utils.js +258 -0
  92. package/lib/Utils/signal.js +201 -0
  93. package/lib/Utils/stanza-ack.js +38 -0
  94. package/lib/Utils/sticker.js +133 -0
  95. package/lib/Utils/sync-action-utils.js +49 -0
  96. package/lib/Utils/tc-token-utils.js +163 -0
  97. package/lib/Utils/use-multi-file-auth-state.js +121 -0
  98. package/lib/Utils/use-sqlite-auth-state.js +162 -0
  99. package/lib/Utils/validate-connection.js +203 -0
  100. package/lib/WABinary/constants.js +1301 -0
  101. package/lib/WABinary/decode.js +262 -0
  102. package/lib/WABinary/encode.js +220 -0
  103. package/lib/WABinary/generic-utils.js +204 -0
  104. package/lib/WABinary/index.js +6 -0
  105. package/lib/WABinary/jid-utils.js +98 -0
  106. package/lib/WABinary/types.js +2 -0
  107. package/lib/WAM/BinaryInfo.js +10 -0
  108. package/lib/WAM/constants.js +22853 -0
  109. package/lib/WAM/encode.js +150 -0
  110. package/lib/WAM/index.js +4 -0
  111. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +53 -0
  112. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
  113. package/lib/WAUSync/Protocols/USyncContactProtocol.js +54 -0
  114. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  115. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  116. package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +58 -0
  117. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +30 -0
  118. package/lib/WAUSync/Protocols/USyncPictureProtocol.js +32 -0
  119. package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +28 -0
  120. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +39 -0
  121. package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
  122. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +27 -0
  123. package/lib/WAUSync/Protocols/index.js +12 -0
  124. package/lib/WAUSync/USyncQuery.js +151 -0
  125. package/lib/WAUSync/USyncUser.js +56 -0
  126. package/lib/WAUSync/index.js +3 -0
  127. package/lib/index.js +34 -0
  128. package/package.json +124 -5
package/README.md CHANGED
@@ -1,3 +1,356 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="https://e.top4top.io/p_38721hu6c1.jpg" width="250"/>
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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
+ > `"@wanzlonely/bails4u": "latest"` 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-messate)
33
+ - [Generic Send / Relay](#generic-send--relay)
34
+ - [Simple Senders](#simple-senders)
35
+ - [Rich Menu](#rich-menu)
36
+ - [Sending Message with Participant](#sending-message-with-participant)
37
+ - [Message Builder](#message-builder)
38
+ - [Import](#import)
39
+ - [Example](#examle)
40
+ - [Button](#button)
41
+ - [Quick Reply + URL + Copy](#quick-reply--url--copy)
42
+ - [ButtonV2](#buttonv2)
43
+ - [Carousel](#carousel)
44
+ - [Why Choose WhatsApp Baileys?](#why-choose-whatsapp-baileys)
45
+ - [Contributors](#contributors)
46
+ - [Contact Developer](#contact-developer)
47
+
48
+ ---
49
+
50
+ # Requirements
51
+
52
+ - Node.js **>= 20**
53
+ - Optional peer dependencies depending on the features you use:
54
+ - `sharp` or `jimp` for image processing
55
+ - `link-preview-js` for link previews
56
+ - `audio-decode` for audio waveform handling
57
+ - `fluent-ffmpeg` for frame preview video, MessageBuilder Toolkit.getMp4Preview
58
+
59
+ ---
60
+
61
+ # Installation
62
+
63
+ ```bash
64
+ npm install @wanzlonely/bails4u
65
+ ```
66
+
67
+ Add it to your `package.json`:
68
+
69
+ ```json
70
+ {
71
+ "dependencies": {
72
+ "@wanzlonely/bails4u": "latest"
73
+ }
74
+ }
75
+ ```
76
+
77
+ ---
78
+
79
+ # Import
80
+
81
+ ```javascript
82
+ const {
83
+ default: makeWASocket,
84
+ // Other Options
85
+ } = require('@wanzlonely/bails4u');
86
+ ```
87
+
88
+ ---
89
+
90
+ # Quick Start
91
+
92
+ ## With QR Code
93
+
94
+ ```javascript
95
+ const {
96
+ default: makeWASocket,
97
+ Browsers
98
+ // Other Options
99
+ } = require('@wanzlonely/bails4u');
100
+
101
+ const client = makeWASocket({
102
+ browser: Browsers.ubuntu('Chrome'),
103
+ printQRInTerminal: true
104
+ });
105
+ ```
106
+
107
+ ## With Pairing Code
108
+
109
+ ```javascript
110
+ const {
111
+ default: makeWASocket,
112
+ fetchLatestWAWebVersion,
113
+ Browsers
114
+ } = require('@wanzlonely/bails4u');
115
+
116
+ const client = makeWASocket({
117
+ browser: Browsers.ubuntu('Chrome'),
118
+ printQRInTerminal: false,
119
+ version: fetchLatestWAWebVersion(),
120
+ auth: state
121
+ });
122
+
123
+ const number = "628XXXXX";
124
+ const code = await client.requestPairingCode(number.trim()); // Use (number, "XXXXXXXX") for custom pairing
125
+
126
+ console.log("Ur pairing code : " + code);
127
+ ```
128
+
129
+ ---
130
+
131
+ # Sending Message
132
+
133
+ ## Generic Send / Relay
134
+
135
+ ```javascript
136
+ // relayMessage — sends a raw message object, bypassing the sendMessage pipeline
137
+ await client.relayMessage(m.chat, {
138
+ conversation: 'WnzLnly'
139
+ })
140
+
141
+ // sendMessage — the standard way to send a message
142
+ await client.sendMessage(m.chat, {
143
+ text: 'WnzLnly'
144
+ })
145
+ ```
146
+
147
+ ## Simple Senders
148
+
149
+ ```javascript
150
+ await client.sendText(m.chat, 'Hi!', { contextInfo: { mentionedJid: [jid] } })
151
+ await client.sendImage(m.chat, { url: './photo.jpg' }, 'image caption')
152
+ await client.sendVideo(m.chat, { url: './clip.mp4' }, 'video caption')
153
+ await client.sendAudio(m.chat, { url: './clip.mp3' })
154
+ await client.sendLocation(m.chat, 'Location name', -6.2, 106.8, 'https://maps.example', '1234567890')
155
+ await client.sendPoll(m.chat, 'Pick one', ['Option 1', 'Option 2', 'Option 3'], /* multiSelect */ true)
156
+ await client.sendQuiz(m.chat, 'Correct answer?', ['1', '2', '3'], /* correctIndex */ '2')
157
+ ```
158
+
159
+ ## Rich Menu
160
+
161
+ `sendRich` sends a rich response with an optional header image, action buttons, carousel cards, and an open-URL footer:
162
+
163
+ ```javascript
164
+ await client.sendRich(m.chat, {
165
+ header: {
166
+ disclaimer: true,
167
+ disclaimerText: "t.me/WanzzWangsaf",
168
+ title: "WnzLnly"
169
+ },
170
+ body: {
171
+ title: "Select Option",
172
+ buttons: ["Menu 1", "Menu 2"]
173
+ },
174
+ footer: {
175
+ text: "Telegram Channel",
176
+ url: "https://t.me/aboutvin7x"
177
+ }
178
+ });
179
+ ```
180
+
181
+ # Sending Message with Participant
182
+
183
+ `relayMessage`:
184
+
185
+ ```javascript
186
+ await client.relayMessage(m.chat, {
187
+ extendedTextMessage: {
188
+ text: "WnzLnly"
189
+ }
190
+ }, {
191
+ ptcp: true
192
+ });
193
+ ```
194
+
195
+ `sendMessage`:
196
+
197
+ ```javascript
198
+ await client.sendMessage(m.chat, {
199
+ text: "WnzLnly"
200
+ }, {
201
+ ptcp: true
202
+ });
203
+ ```
204
+
205
+ ---
206
+
207
+ # Message Builder
208
+
209
+ MessageBuilder v4.7 is included directly in `"npm:@wanzlonely/bails4u"`.
210
+
211
+ ## Import
212
+
213
+ ```javascript
214
+ const {
215
+ VERSION,
216
+ Button,
217
+ ButtonV2,
218
+ Carousel,
219
+ AIRich,
220
+ Toolkit,
221
+ bind,
222
+ MB
223
+ } = require('@wanzlonely/bails4u');
224
+ ```
225
+
226
+ > [!NOTE]
227
+ > MessageBuilder is integrated. You don't need to install `baileys-mbuilder` separately.
228
+
229
+ ---
230
+
231
+ ## Example
232
+
233
+ ```javascript
234
+ const { MB } = require('@wanzlonely/bails4u')
235
+
236
+ const rich = new MB.AIRich(sock)
237
+ .setTitle('WnzLnly')
238
+ .setFooter('Dibuat dengan AIRich')
239
+ .addText('Halo! Ini respons rich.')
240
+ .addCode('javascript', `console.log('Halo Wanz')`)
241
+ .addTable([
242
+ ['Fitur', 'Status'],
243
+ ['Button', 'Tersedia'],
244
+ ['Carousel', 'Tersedia'],
245
+ ['AIRich', 'Eksperimental']
246
+ ])
247
+ .addSuggest(['List Menu', 'Help', 'About Wanz'])
248
+
249
+ await rich.send(jid)
250
+ ```
251
+
252
+ ---
253
+
254
+ ## Button
255
+
256
+ Builder `Button` is used for native-flow interactive messages.
257
+
258
+ ### Quick Reply + URL + Copy
259
+
260
+ ```js
261
+ const { MB } = require('@wanzlonely/bails4u')
262
+
263
+ const msg = new MB.Button(client)
264
+ .setTitle('Select Menu')
265
+ .setBody('Pilih salah satu di bawah.')
266
+ .setFooter('t.me/WanzzWangsaf')
267
+ .addReply('Ping', 'ping')
268
+ .addUrl('Buka Website', 'https://example.com')
269
+ .addCopy('Salin Kode', 'WnzLnly')
270
+
271
+ await msg.send(m.chat)
272
+ ```
273
+
274
+ ---
275
+
276
+ ## ButtonV2
277
+
278
+ `ButtonV2` provides a simpler classic button builder.
279
+
280
+ ```javasript
281
+ const { MB } = require('@wanzlonely/bails4u')
282
+
283
+ const message = new MB.ButtonV2(client)
284
+ .setTitle('WnzLnly')
285
+ .setSubtitle('WhatsApp Bot')
286
+ .setBody('Pilih satu tindakan.')
287
+ .setFooter('Wanz Baileys')
288
+ .setThumbnail('https://example.com/xxx.jpg')
289
+ .addButton('Menu', 'menu')
290
+ .addButton('Ping', 'ping')
291
+
292
+ await message.send(m.chat)
293
+ ```
294
+
295
+ ---
296
+
297
+ ## Carousel
298
+
299
+ Carousel cards can be created from `Button.toCard()` and then submitted to `Carousel`.
300
+
301
+ ```js
302
+ const { MB } = require('@wanzlonely/bails4u')
303
+
304
+ const card1 = await new MB.Button(client)
305
+ .setImage('https://example.com/card1.jpg')
306
+ .setBody('Kartu pertama')
307
+ .addReply('Pilih', 'card_1')
308
+ .toCard()
309
+
310
+ const card2 = await new MB.Button(client)
311
+ .setImage('https://example.com/card2.jpg')
312
+ .setBody('Kartu kedua')
313
+ .addUrl('Buka', 'https://example.com')
314
+ .toCard()
315
+
316
+ const carousel = new MB.Carousel(client)
317
+ .setBody('Pilih salah satu kartu di bawah.')
318
+ .setFooter('Wanz Carousel')
319
+ .addCard([card1, card2])
320
+
321
+ await carousel.send(jid)
322
+ ```
323
+
324
+ > [!IMPORTANT]
325
+ > Each carousel card must have an image or video media attachment in its header.
326
+
327
+ ---
328
+
329
+ # Why Choose WhatsApp Baileys?
330
+
331
+ 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.
332
+
333
+ ---
334
+
335
+ # Contributors
336
+
337
+ <table>
338
+ <tr>
339
+ <td align="center">
340
+ <a href="https://github.com/wanzchil">
341
+ <img src="https://github.com/wanzchil.png" width="80px;" style="border-radius:50%;" alt="Main contributor"/>
342
+ <br /><sub><b>Wanz Lonely</b></sub>
343
+ </a>
344
+ </td>
345
+ </tr>
346
+ </table>
347
+
348
+ ---
349
+
350
+ ## Contact Developer
351
+
352
+ For questions, support, or collaboration, feel free to contact the developer:
353
+
354
+ - **Telegram**: [Telegram Contact](https://t.me/WanzzWangsaf)
355
+ - **Channel WhatsApp**: [Channel WhatsApp](https://whatsapp.com/channel/0029Vb0A6XC3WHTORDf0Pn3V)
356
+ - **Channel Telegram**: [Channel Telegram](https://t.me/wanznotdev)
@@ -0,0 +1,3 @@
1
+ yarn pbjs -t static-module --no-beautify -w es6 --no-bundle --no-delimited --no-verify --no-comments -o ./index.js ./WAProto.proto;
2
+ yarn pbjs -t static-module --no-beautify -w es6 --no-bundle --no-delimited --no-verify ./WAProto.proto | yarn pbts --no-comments -o ./index.d.ts -;
3
+ node ./fix-imports.js