@rizzkezik/bails 6.1.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 (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +535 -0
  3. package/WAProto/GenerateStatics.sh +3 -0
  4. package/WAProto/WAProto.proto +6902 -0
  5. package/WAProto/fix-imports.js +85 -0
  6. package/WAProto/index.d.ts +79257 -0
  7. package/WAProto/index.js +242946 -0
  8. package/engine-requirements.js +10 -0
  9. package/lib/Defaults/index.js +130 -0
  10. package/lib/Signal/Group/ciphertext-message.js +12 -0
  11. package/lib/Signal/Group/group-session-builder.js +30 -0
  12. package/lib/Signal/Group/group_cipher.js +82 -0
  13. package/lib/Signal/Group/index.js +12 -0
  14. package/lib/Signal/Group/keyhelper.js +18 -0
  15. package/lib/Signal/Group/sender-chain-key.js +26 -0
  16. package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
  17. package/lib/Signal/Group/sender-key-message.js +66 -0
  18. package/lib/Signal/Group/sender-key-name.js +48 -0
  19. package/lib/Signal/Group/sender-key-record.js +41 -0
  20. package/lib/Signal/Group/sender-key-state.js +84 -0
  21. package/lib/Signal/Group/sender-message-key.js +26 -0
  22. package/lib/Signal/libsignal.js +431 -0
  23. package/lib/Signal/lid-mapping.js +277 -0
  24. package/lib/Socket/Client/index.js +3 -0
  25. package/lib/Socket/Client/types.js +11 -0
  26. package/lib/Socket/Client/websocket.js +54 -0
  27. package/lib/Socket/business.js +379 -0
  28. package/lib/Socket/chats.js +1193 -0
  29. package/lib/Socket/communities.js +431 -0
  30. package/lib/Socket/groups.js +374 -0
  31. package/lib/Socket/index.js +12 -0
  32. package/lib/Socket/luxu.js +387 -0
  33. package/lib/Socket/messages-recv.js +1916 -0
  34. package/lib/Socket/messages-send.js +1435 -0
  35. package/lib/Socket/mex.js +42 -0
  36. package/lib/Socket/newsletter.js +270 -0
  37. package/lib/Socket/socket.js +967 -0
  38. package/lib/Store/index.js +10 -0
  39. package/lib/Store/keyed-db.js +108 -0
  40. package/lib/Store/make-cache-manager-store.js +85 -0
  41. package/lib/Store/make-in-memory-store.js +198 -0
  42. package/lib/Store/make-ordered-dictionary.js +75 -0
  43. package/lib/Store/object-repository.js +32 -0
  44. package/lib/Types/Auth.js +2 -0
  45. package/lib/Types/Bussines.js +2 -0
  46. package/lib/Types/Call.js +2 -0
  47. package/lib/Types/Chat.js +8 -0
  48. package/lib/Types/Contact.js +2 -0
  49. package/lib/Types/Events.js +2 -0
  50. package/lib/Types/GroupMetadata.js +2 -0
  51. package/lib/Types/Label.js +25 -0
  52. package/lib/Types/LabelAssociation.js +7 -0
  53. package/lib/Types/Message.js +11 -0
  54. package/lib/Types/Mex.js +37 -0
  55. package/lib/Types/Product.js +2 -0
  56. package/lib/Types/Signal.js +2 -0
  57. package/lib/Types/Socket.js +3 -0
  58. package/lib/Types/State.js +56 -0
  59. package/lib/Types/USync.js +2 -0
  60. package/lib/Types/index.js +26 -0
  61. package/lib/Utils/auth-utils.js +302 -0
  62. package/lib/Utils/browser-utils.js +48 -0
  63. package/lib/Utils/business.js +231 -0
  64. package/lib/Utils/chat-utils.js +872 -0
  65. package/lib/Utils/companion-reg-client-utils.js +35 -0
  66. package/lib/Utils/crypto.js +118 -0
  67. package/lib/Utils/decode-wa-message.js +350 -0
  68. package/lib/Utils/event-buffer.js +622 -0
  69. package/lib/Utils/generics.js +403 -0
  70. package/lib/Utils/history.js +134 -0
  71. package/lib/Utils/identity-change-handler.js +50 -0
  72. package/lib/Utils/index.js +23 -0
  73. package/lib/Utils/link-preview.js +85 -0
  74. package/lib/Utils/logger.js +3 -0
  75. package/lib/Utils/lt-hash.js +8 -0
  76. package/lib/Utils/make-mutex.js +33 -0
  77. package/lib/Utils/message-composer.js +273 -0
  78. package/lib/Utils/message-retry-manager.js +265 -0
  79. package/lib/Utils/messages-media.js +788 -0
  80. package/lib/Utils/messages.js +1253 -0
  81. package/lib/Utils/noise-handler.js +201 -0
  82. package/lib/Utils/offline-node-processor.js +40 -0
  83. package/lib/Utils/pre-key-manager.js +106 -0
  84. package/lib/Utils/process-message.js +630 -0
  85. package/lib/Utils/reporting-utils.js +258 -0
  86. package/lib/Utils/signal.js +201 -0
  87. package/lib/Utils/stanza-ack.js +38 -0
  88. package/lib/Utils/sync-action-utils.js +49 -0
  89. package/lib/Utils/tc-token-utils.js +163 -0
  90. package/lib/Utils/use-multi-file-auth-state.js +121 -0
  91. package/lib/Utils/validate-connection.js +203 -0
  92. package/lib/WABinary/constants.js +1301 -0
  93. package/lib/WABinary/decode.js +262 -0
  94. package/lib/WABinary/encode.js +220 -0
  95. package/lib/WABinary/generic-utils.js +204 -0
  96. package/lib/WABinary/index.js +6 -0
  97. package/lib/WABinary/jid-utils.js +98 -0
  98. package/lib/WABinary/types.js +2 -0
  99. package/lib/WAM/BinaryInfo.js +10 -0
  100. package/lib/WAM/constants.js +22853 -0
  101. package/lib/WAM/encode.js +150 -0
  102. package/lib/WAM/index.js +4 -0
  103. package/lib/WAUSync/Protocols/USyncContactProtocol.js +52 -0
  104. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
  105. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  106. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
  107. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
  108. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
  109. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  110. package/lib/WAUSync/Protocols/index.js +6 -0
  111. package/lib/WAUSync/USyncQuery.js +98 -0
  112. package/lib/WAUSync/USyncUser.js +31 -0
  113. package/lib/WAUSync/index.js +4 -0
  114. package/lib/index.js +31 -0
  115. package/package.json +143 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 RansK2
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,535 @@
1
+ # <div align='center'>Baileys - Typescript/Javascript WhatsApp Web API</div>
2
+
3
+ <p align="center">
4
+ <img src="https://img2.pixhost.to/images/8783/741643401_papaqueen.jpg" alt="Thumbnail" />
5
+ </p>
6
+
7
+ <div align='center'>
8
+
9
+ ![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/whiskeysockets/baileys/total)
10
+ ![NPM Downloads](https://img.shields.io/npm/dw/%40whiskeysockets%2Fbaileys?label=npm&color=%23CB3837)
11
+ ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/whiskeysockets/baileys)
12
+ ![GitHub License](https://img.shields.io/github/license/whiskeysockets/baileys)
13
+ ![Discord](https://img.shields.io/discord/725839806084546610?label=discord&color=%235865F2)
14
+ ![GitHub Repo stars](https://img.shields.io/github/stars/whiskeysockets/baileys)
15
+ ![GitHub forks](https://img.shields.io/github/forks/whiskeysockets/baileys)
16
+
17
+ </div>
18
+
19
+ 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.
20
+
21
+ 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.
22
+
23
+ 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.
24
+
25
+ ---
26
+
27
+ ### Main Features and Advantages
28
+
29
+ - Supports automatic and custom pairing processes
30
+ - Fixes previous pairing issues that often caused failures or disconnections
31
+ - Supports interactive messages, action buttons, and dynamic menus
32
+ - Efficient automatic session management for reliable operation
33
+ - Compatible with the latest multi-device features from WhatsApp
34
+ - Lightweight, stable, and easy to integrate into various systems
35
+ - Suitable for developing bots, automation, and complete communication solutions
36
+ - Comprehensive documentation and example codes to facilitate development
37
+
38
+ ---
39
+
40
+ ## Getting Started
41
+
42
+ Begin by installing the library via your preferred package manager, then follow the provided configuration guide. You can also utilize the ready-made example codes to understand how the features work. Use session storage and interactive messaging features to build complete, stable solutions tailored to your business or project needs.
43
+
44
+ ---
45
+
46
+ ## Add Function ( Simple code )
47
+
48
+ # RansK2 Baileys
49
+
50
+ Simple WhatsApp Web API Library Based On Baileys.
51
+
52
+ ---
53
+
54
+ # Installation
55
+
56
+ ### Install Package
57
+
58
+ Install package using npm.
59
+
60
+ ```bash
61
+ npm install @ranstech/bails
62
+ ```
63
+
64
+ ---
65
+
66
+ # Import
67
+
68
+ ### CommonJS
69
+
70
+ Import package using require.
71
+
72
+ ```javascript
73
+ const {
74
+ default: makeWASocket
75
+ } = require("@ranstech/bails");
76
+ ```
77
+
78
+ ---
79
+
80
+ ### ES Module
81
+
82
+ Import package using ES Module.
83
+
84
+ ```javascript
85
+ import makeWASocket from "@ranstech/bails";
86
+ ```
87
+
88
+ ---
89
+
90
+ # Connection Documentation
91
+
92
+ ### Connect With QR Code
93
+
94
+ Connect WhatsApp using QR authentication.
95
+
96
+ ```javascript
97
+ const {
98
+ default: makeWASocket,
99
+ Browsers
100
+ } = require("@ranstech/bails");
101
+
102
+ const client = makeWASocket({
103
+ browser: Browsers.ubuntu("Chrome"),
104
+ printQRInTerminal: true
105
+ });
106
+ ```
107
+
108
+ ---
109
+
110
+ ### Connect With Pairing Code
111
+
112
+ Connect WhatsApp using phone number.
113
+
114
+ ```javascript
115
+ const {
116
+ default: makeWASocket,
117
+ Browsers,
118
+ fetchLatestWAWebVersion
119
+ } = require("@ranstech/bails");
120
+
121
+ const client = makeWASocket({
122
+ browser: Browsers.ubuntu("Chrome"),
123
+ printQRInTerminal: false,
124
+ version: fetchLatestWAWebVersion(),
125
+ aiLabel: false
126
+ });
127
+
128
+ const code = await client.requestPairingCode("628xxxxxxxxxx");
129
+
130
+ console.log(code);
131
+ ```
132
+
133
+ ---
134
+
135
+ # Store Documentation
136
+
137
+ ### In Memory Store
138
+
139
+ Store contacts, chats and messages in memory.
140
+
141
+ ```javascript
142
+ const {
143
+ default: makeWASocket,
144
+ makeInMemoryStore
145
+ } = require("@ranstech/bails");
146
+
147
+ const pino = require("pino");
148
+
149
+ const store = makeInMemoryStore({
150
+ logger: pino().child({
151
+ level: "silent",
152
+ stream: "store"
153
+ })
154
+ });
155
+
156
+ store.bind(client.ev);
157
+ ```
158
+
159
+ ---
160
+
161
+ # Group Documentation
162
+
163
+ ### Member Label
164
+
165
+ Send member label inside group.
166
+
167
+ ```javascript
168
+ await client.sendMessage(jid, {
169
+ groupLabel: {
170
+ labelText: "Premium Member"
171
+ }
172
+ });
173
+ ```
174
+
175
+ ---
176
+
177
+ ### Message Members
178
+
179
+ Send message to all group members.
180
+
181
+ ```javascript
182
+ await client.sendMessageMembers(
183
+ jid,
184
+ {
185
+ extendedTextMessage: {
186
+ text: "Hello Members"
187
+ }
188
+ },
189
+ {}
190
+ );
191
+ ```
192
+
193
+ ---
194
+
195
+ # Utility Documentation
196
+
197
+ ### Check Channel Information
198
+
199
+ Get newsletter information from URL.
200
+
201
+ ```javascript
202
+ client.newsletterFromUrl(url);
203
+ ```
204
+
205
+ Result:
206
+
207
+ ```json
208
+ {
209
+ "name": "Channel Name",
210
+ "id": "123456789",
211
+ "state": "ACTIVE",
212
+ "subscribers": "1000",
213
+ "verification": "UNVERIFIED",
214
+ "creation_time": 1728547155,
215
+ "description": "Channel Description"
216
+ }
217
+ ```
218
+
219
+ ---
220
+
221
+ ### Check WhatsApp Number
222
+
223
+ Check whether number exists on WhatsApp.
224
+
225
+ ```javascript
226
+ client.checkWhatsApp(jid);
227
+ ```
228
+
229
+ ---
230
+
231
+ # SendMessage Documentation
232
+
233
+ ### Send Text
234
+
235
+ Send text message.
236
+
237
+ ```javascript
238
+ await client.sendText(
239
+ jid,
240
+ "Hello World"
241
+ );
242
+ ```
243
+
244
+ ---
245
+
246
+ ### Send Image
247
+
248
+ Send image message.
249
+
250
+ ```javascript
251
+ await client.sendImage(
252
+ jid,
253
+ {
254
+ url: "./image.jpg"
255
+ },
256
+ "Caption Here"
257
+ );
258
+ ```
259
+
260
+ ---
261
+
262
+ ### Send Video
263
+
264
+ Send video message.
265
+
266
+ ```javascript
267
+ await client.sendVideo(
268
+ jid,
269
+ {
270
+ url: "./video.mp4"
271
+ },
272
+ "Caption Here"
273
+ );
274
+ ```
275
+
276
+ ---
277
+
278
+ ### Send Audio
279
+
280
+ Send audio message.
281
+
282
+ ```javascript
283
+ await client.sendAudio(
284
+ jid,
285
+ {
286
+ url: "./audio.mp3"
287
+ }
288
+ );
289
+ ```
290
+
291
+ ---
292
+
293
+ ### Send Location
294
+
295
+ Send location message.
296
+
297
+ ```javascript
298
+ await client.sendLocation(
299
+ jid,
300
+ "RansK2",
301
+ -6.2,
302
+ 106.8,
303
+ "https://example.com",
304
+ "123456789"
305
+ );
306
+ ```
307
+
308
+ ---
309
+
310
+ ### Send Poll
311
+
312
+ Create poll message.
313
+
314
+ ```javascript
315
+ await client.sendPoll(
316
+ jid,
317
+ "Choose One",
318
+ [
319
+ "Option 1",
320
+ "Option 2",
321
+ "Option 3"
322
+ ],
323
+ true
324
+ );
325
+ ```
326
+
327
+ ---
328
+
329
+ ### Send Quiz
330
+
331
+ Create quiz poll message.
332
+
333
+ ```javascript
334
+ await client.sendQuiz(
335
+ jid,
336
+ "Question Here",
337
+ [
338
+ "A",
339
+ "B",
340
+ "C"
341
+ ],
342
+ "B"
343
+ );
344
+ ```
345
+
346
+ ---
347
+
348
+ ### Status Mention
349
+
350
+ Mention users through status.
351
+
352
+ ```javascript
353
+ await client.statusMention(
354
+ jid,
355
+ {
356
+ extendedTextMessage: {
357
+ text: "Hello World"
358
+ }
359
+ }
360
+ );
361
+ ```
362
+
363
+ ---
364
+
365
+ ### Interactive Message
366
+
367
+ Send interactive message.
368
+
369
+ ```javascript
370
+ await client.sendMessage(
371
+ jid,
372
+ {
373
+ image: {
374
+ url: "./image.jpg"
375
+ },
376
+ text: "Body Message",
377
+ title: "Hello World",
378
+ footer: "RansK2",
379
+ interactiveButtons: [
380
+ {
381
+ name: "single_select",
382
+ buttonParamsJson: JSON.stringify({
383
+ title: "Menu"
384
+ })
385
+ }
386
+ ]
387
+ }
388
+ );
389
+ ```
390
+
391
+ ---
392
+
393
+ ### Product Message
394
+
395
+ Send product catalog message.
396
+
397
+ ```javascript
398
+ await client.sendMessage(
399
+ jid,
400
+ {
401
+ productMessage: {
402
+ title: "RansK2 Product",
403
+ description: "Product Description",
404
+ thumbnail: {
405
+ url: "./thumbnail.jpg"
406
+ },
407
+ productId: "PRODUCT_ID",
408
+ retailerId: "RETAILER_ID",
409
+ url: "https://example.com",
410
+ body: "Product Body",
411
+ footer: "Footer Product",
412
+ priceAmount1000: 50000,
413
+ currencyCode: "IDR"
414
+ }
415
+ }
416
+ );
417
+ ```
418
+
419
+ ---
420
+
421
+ ### Order Message
422
+
423
+ Send order message.
424
+
425
+ ```javascript
426
+ await client.sendMessage(
427
+ jid,
428
+ {
429
+ thumbnail: thumbnailBuffer,
430
+ message: "Order Example",
431
+ orderTitle: "RansK2 Store",
432
+ totalAmount1000: 50000,
433
+ totalCurrencyCode: "IDR"
434
+ }
435
+ );
436
+ ```
437
+
438
+ ---
439
+
440
+ ### Poll Result Snapshot
441
+
442
+ Display poll result snapshot.
443
+
444
+ ```javascript
445
+ await client.sendMessage(
446
+ jid,
447
+ {
448
+ pollResultMessage: {
449
+ name: "Example Poll",
450
+ options: [
451
+ {
452
+ optionName: "Option 1"
453
+ },
454
+ {
455
+ optionName: "Option 2"
456
+ }
457
+ ]
458
+ }
459
+ }
460
+ );
461
+ ```
462
+
463
+ ---
464
+
465
+ ## Why Choose WhatsApp Baileys?
466
+
467
+ 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.
468
+
469
+ ---
470
+
471
+ ### Technical Notes
472
+
473
+ - Supports custom pairing codes that are stable and secure
474
+ - Fixes previous issues related to pairing and authentication
475
+ - Features interactive messages and action buttons for dynamic menu creation
476
+ - Automatic and efficient session management for long-term stability
477
+ - Compatible with the latest multi-device features from WhatsApp
478
+ - Easy to integrate and customize based on your needs
479
+ - Perfect for developing bots, customer service automation, and other communication applications
480
+ - Has 1 newsletter follow, only the developer's WhatsApp channel: [WhatsApp Channel](https://whatsapp.com/channel/0029Vb3IiqTL7UVP9A9n0w1x)
481
+
482
+ ---
483
+
484
+ For complete documentation, installation guides, and implementation examples, please visit the official repository and community forums. We continually update and improve this library to meet the needs of developers and users of modern WhatsApp automation solutions.
485
+
486
+ **Thank you for choosing WhatsApp Baileys as your WhatsApp automation solution!**
487
+
488
+
489
+ ---
490
+
491
+
492
+ ### Contact Developer
493
+
494
+ For questions, support, or collaboration, feel free to contact the developer:
495
+
496
+ - **Telegram**: [Telegram Contact](https://t.me/ranstech)
497
+ - **Channel WhatsApp**: [Channel WhatsApp](https://whatsapp.com/channel/0029Vb3IiqTL7UVP9A9n0w1x)
498
+
499
+ ### 🙌 Contributors outside the Baileys code
500
+
501
+ Thanks to the following awesome contributors who help improve this project 💖
502
+
503
+ <table>
504
+ <tr>
505
+ <td align="center">
506
+ <a href="https://github.com/alannzxd">
507
+ <img src="https://github.com/alannzxd.png" width="80px;" style="border-radius:50%;" alt="Developer"/>
508
+ <br />
509
+ <sub><b>RansK2</b></sub>
510
+ </a>
511
+ </td>
512
+ <td align="center">
513
+ <a href="https://github.com/tenka-san">
514
+ <img src="https://github.com/tenka-san.png" width="80px;" style="border-radius:50%;" alt="Developer"/>
515
+ <br />
516
+ <sub><b>D | Yuukey-7eppeli</b></sub>
517
+ </a>
518
+ </td>
519
+ <td align="center">
520
+ <a href="https://github.com/kiuur">
521
+ <img src="https://github.com/kiuur.png" width="80px;" style="border-radius:50%;" alt="Contributor"/>
522
+ <br />
523
+ <sub><b>KyuuRzy</b></sub>
524
+ </a>
525
+ </td>
526
+ <td align="center">
527
+ <a href="https://github.com/RexxHayanasi">
528
+ <img src="https://github.com/RexxHayanasi.png" width="80px;" style="border-radius:50%;" alt="Contributor"/>
529
+ <br />
530
+ <sub><b>RexxHayanasi</b></sub>
531
+ </a>
532
+ </td>
533
+ </tr>
534
+ </table>
535
+
@@ -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