@gqb333/based 2.7.71

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 (201) hide show
  1. package/LICENSE +58 -0
  2. package/README.MD +611 -0
  3. package/WAProto/GenerateStatics.sh +4 -0
  4. package/WAProto/WAProto.proto +5604 -0
  5. package/WAProto/index.d.ts +63156 -0
  6. package/WAProto/index.js +195638 -0
  7. package/WAProto/p.html +1 -0
  8. package/engine-requirements.js +10 -0
  9. package/lib/Defaults/baileys-version.json +3 -0
  10. package/lib/Defaults/index.d.ts +53 -0
  11. package/lib/Defaults/index.js +108 -0
  12. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  13. package/lib/Signal/Group/ciphertext-message.js +15 -0
  14. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  15. package/lib/Signal/Group/group-session-builder.js +64 -0
  16. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  17. package/lib/Signal/Group/group_cipher.js +96 -0
  18. package/lib/Signal/Group/index.d.ts +11 -0
  19. package/lib/Signal/Group/index.js +57 -0
  20. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  21. package/lib/Signal/Group/keyhelper.js +55 -0
  22. package/lib/Signal/Group/queue-job.d.ts +1 -0
  23. package/lib/Signal/Group/queue-job.js +57 -0
  24. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  25. package/lib/Signal/Group/sender-chain-key.js +34 -0
  26. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  27. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  28. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  29. package/lib/Signal/Group/sender-key-message.js +69 -0
  30. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  31. package/lib/Signal/Group/sender-key-name.js +51 -0
  32. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  33. package/lib/Signal/Group/sender-key-record.js +53 -0
  34. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  35. package/lib/Signal/Group/sender-key-state.js +99 -0
  36. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  37. package/lib/Signal/Group/sender-message-key.js +29 -0
  38. package/lib/Signal/libsignal.d.ts +3 -0
  39. package/lib/Signal/libsignal.js +174 -0
  40. package/lib/Socket/Client/index.d.ts +2 -0
  41. package/lib/Socket/Client/index.js +18 -0
  42. package/lib/Socket/Client/types.d.ts +16 -0
  43. package/lib/Socket/Client/types.js +13 -0
  44. package/lib/Socket/Client/websocket.d.ts +13 -0
  45. package/lib/Socket/Client/websocket.js +111 -0
  46. package/lib/Socket/business.d.ts +172 -0
  47. package/lib/Socket/business.js +260 -0
  48. package/lib/Socket/chats.d.ts +85 -0
  49. package/lib/Socket/chats.js +1094 -0
  50. package/lib/Socket/groups.d.ts +124 -0
  51. package/lib/Socket/groups.js +423 -0
  52. package/lib/Socket/index.d.ts +172 -0
  53. package/lib/Socket/index.js +32 -0
  54. package/lib/Socket/messages-interactive.js +259 -0
  55. package/lib/Socket/messages-recv.d.ts +161 -0
  56. package/lib/Socket/messages-recv.js +1474 -0
  57. package/lib/Socket/messages-send.d.ts +151 -0
  58. package/lib/Socket/messages-send.js +1085 -0
  59. package/lib/Socket/newsletter.d.ts +136 -0
  60. package/lib/Socket/newsletter.js +250 -0
  61. package/lib/Socket/socket.d.ts +43 -0
  62. package/lib/Socket/socket.js +1241 -0
  63. package/lib/Socket/usync.d.ts +36 -0
  64. package/lib/Socket/usync.js +123 -0
  65. package/lib/Store/index.d.ts +2 -0
  66. package/lib/Store/index.js +8 -0
  67. package/lib/Store/make-in-memory-store.d.ts +118 -0
  68. package/lib/Store/make-in-memory-store.js +452 -0
  69. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  70. package/lib/Store/make-ordered-dictionary.js +81 -0
  71. package/lib/Store/object-repository.d.ts +10 -0
  72. package/lib/Store/object-repository.js +27 -0
  73. package/lib/Types/Auth.d.ts +114 -0
  74. package/lib/Types/Auth.js +2 -0
  75. package/lib/Types/Call.d.ts +13 -0
  76. package/lib/Types/Call.js +2 -0
  77. package/lib/Types/Chat.d.ts +109 -0
  78. package/lib/Types/Chat.js +4 -0
  79. package/lib/Types/Contact.d.ts +29 -0
  80. package/lib/Types/Contact.js +2 -0
  81. package/lib/Types/Events.d.ts +199 -0
  82. package/lib/Types/Events.js +2 -0
  83. package/lib/Types/GroupMetadata.d.ts +64 -0
  84. package/lib/Types/GroupMetadata.js +2 -0
  85. package/lib/Types/Label.d.ts +35 -0
  86. package/lib/Types/Label.js +27 -0
  87. package/lib/Types/LabelAssociation.d.ts +29 -0
  88. package/lib/Types/LabelAssociation.js +9 -0
  89. package/lib/Types/Message.d.ts +740 -0
  90. package/lib/Types/Message.js +7 -0
  91. package/lib/Types/Newsletter.d.ts +22 -0
  92. package/lib/Types/Newsletter.js +18 -0
  93. package/lib/Types/Product.d.ts +78 -0
  94. package/lib/Types/Product.js +2 -0
  95. package/lib/Types/Signal.d.ts +63 -0
  96. package/lib/Types/Signal.js +2 -0
  97. package/lib/Types/Socket.d.ts +134 -0
  98. package/lib/Types/Socket.js +2 -0
  99. package/lib/Types/State.d.ts +27 -0
  100. package/lib/Types/State.js +2 -0
  101. package/lib/Types/USync.d.ts +25 -0
  102. package/lib/Types/USync.js +2 -0
  103. package/lib/Types/index.d.ts +65 -0
  104. package/lib/Types/index.js +43 -0
  105. package/lib/Utils/auth-utils.d.ts +18 -0
  106. package/lib/Utils/auth-utils.js +209 -0
  107. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  108. package/lib/Utils/baileys-event-stream.js +63 -0
  109. package/lib/Utils/business.d.ts +22 -0
  110. package/lib/Utils/business.js +234 -0
  111. package/lib/Utils/cache-manager.d.ts +16 -0
  112. package/lib/Utils/cache-manager.js +114 -0
  113. package/lib/Utils/chat-utils.d.ts +70 -0
  114. package/lib/Utils/chat-utils.js +734 -0
  115. package/lib/Utils/crypto.d.ts +40 -0
  116. package/lib/Utils/crypto.js +193 -0
  117. package/lib/Utils/decode-wa-message.d.ts +35 -0
  118. package/lib/Utils/decode-wa-message.js +207 -0
  119. package/lib/Utils/event-buffer.d.ts +35 -0
  120. package/lib/Utils/event-buffer.js +619 -0
  121. package/lib/Utils/generics.d.ts +89 -0
  122. package/lib/Utils/generics.js +440 -0
  123. package/lib/Utils/history.d.ts +19 -0
  124. package/lib/Utils/history.js +94 -0
  125. package/lib/Utils/index.d.ts +22 -0
  126. package/lib/Utils/index.js +38 -0
  127. package/lib/Utils/jid-validation.d.ts +2 -0
  128. package/lib/Utils/jid-validation.js +186 -0
  129. package/lib/Utils/link-preview.d.ts +21 -0
  130. package/lib/Utils/link-preview.js +152 -0
  131. package/lib/Utils/logger.d.ts +11 -0
  132. package/lib/Utils/logger.js +59 -0
  133. package/lib/Utils/lt-hash.d.ts +12 -0
  134. package/lib/Utils/lt-hash.js +51 -0
  135. package/lib/Utils/make-mutex.d.ts +7 -0
  136. package/lib/Utils/make-mutex.js +43 -0
  137. package/lib/Utils/messages-media.d.ts +120 -0
  138. package/lib/Utils/messages-media.js +848 -0
  139. package/lib/Utils/messages.d.ts +131 -0
  140. package/lib/Utils/messages.js +1793 -0
  141. package/lib/Utils/newsletter-utils.d.ts +2 -0
  142. package/lib/Utils/newsletter-utils.js +48 -0
  143. package/lib/Utils/noise-handler.d.ts +19 -0
  144. package/lib/Utils/noise-handler.js +150 -0
  145. package/lib/Utils/performance-config.d.ts +70 -0
  146. package/lib/Utils/performance-config.js +183 -0
  147. package/lib/Utils/process-message.d.ts +42 -0
  148. package/lib/Utils/process-message.js +498 -0
  149. package/lib/Utils/rate-limiter.js +90 -0
  150. package/lib/Utils/retry.js +66 -0
  151. package/lib/Utils/signal.d.ts +33 -0
  152. package/lib/Utils/signal.js +153 -0
  153. package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
  154. package/lib/Utils/use-multi-file-auth-state.js +129 -0
  155. package/lib/Utils/validate-connection.d.ts +10 -0
  156. package/lib/Utils/validate-connection.js +233 -0
  157. package/lib/WABinary/constants.d.ts +27 -0
  158. package/lib/WABinary/constants.js +1303 -0
  159. package/lib/WABinary/decode.d.ts +6 -0
  160. package/lib/WABinary/decode.js +279 -0
  161. package/lib/WABinary/encode.d.ts +2 -0
  162. package/lib/WABinary/encode.js +264 -0
  163. package/lib/WABinary/generic-utils.d.ts +14 -0
  164. package/lib/WABinary/generic-utils.js +114 -0
  165. package/lib/WABinary/index.d.ts +5 -0
  166. package/lib/WABinary/index.js +21 -0
  167. package/lib/WABinary/jid-utils.d.ts +38 -0
  168. package/lib/WABinary/jid-utils.js +485 -0
  169. package/lib/WABinary/types.d.ts +18 -0
  170. package/lib/WABinary/types.js +2 -0
  171. package/lib/WAM/BinaryInfo.d.ts +8 -0
  172. package/lib/WAM/BinaryInfo.js +13 -0
  173. package/lib/WAM/constants.d.ts +38 -0
  174. package/lib/WAM/constants.js +15350 -0
  175. package/lib/WAM/encode.d.ts +2 -0
  176. package/lib/WAM/encode.js +155 -0
  177. package/lib/WAM/index.d.ts +3 -0
  178. package/lib/WAM/index.js +19 -0
  179. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  180. package/lib/WAUSync/Protocols/USyncContactProtocol.js +102 -0
  181. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  182. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +110 -0
  183. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  184. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  185. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  186. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  187. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  188. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  189. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  190. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  191. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  192. package/lib/WAUSync/Protocols/index.js +20 -0
  193. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  194. package/lib/WAUSync/USyncQuery.js +147 -0
  195. package/lib/WAUSync/USyncUser.d.ts +12 -0
  196. package/lib/WAUSync/USyncUser.js +26 -0
  197. package/lib/WAUSync/index.d.ts +3 -0
  198. package/lib/WAUSync/index.js +19 -0
  199. package/lib/index.d.ts +17 -0
  200. package/lib/index.js +53 -0
  201. package/package.json +104 -0
package/LICENSE ADDED
@@ -0,0 +1,58 @@
1
+
2
+
3
+ Copyright (c) 2025 Gab (aka Gab333 / 333bot)
4
+ https://github.com/gab333 (puoi cambiare il link se vuoi)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ Attribution Required – The above copyright notice, this permission notice, and the following credit statement must be included in all copies, derivative works, or substantial portions of the Software, in source and/or binary form:
9
+
10
+ > "This software includes code originally created by Gab (aka Gab333 / 333bot), licensed under the MIT License."
11
+
12
+
13
+
14
+ The above copyright and permission notice shall be included in all copies or substantial portions of the Software.
15
+
16
+ Modifications must be clearly documented so as not to imply authorship by the original author without explicit permission.
17
+
18
+
19
+ ---
20
+
21
+ Disclaimer
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+
26
+
27
+ ---
28
+
29
+ Traduzione informativa in italiano (non vincolante)
30
+
31
+ Licenza MIT
32
+
33
+ Copyright (c) 2025 Gab (aka Gab333 / 333bot)
34
+ https://github.com/GabWT333
35
+
36
+ Con la presente si concede, a titolo gratuito, il permesso a chiunque ottenga una copia di questo software e dei file di documentazione associati (il "Software"), di utilizzare il Software senza restrizioni, inclusi, a titolo esemplificativo ma non esaustivo, i diritti di usare, copiare, modificare, unire, pubblicare, distribuire, concedere in sublicenza e/o vendere copie del Software, e di consentire alle persone a cui il Software è fornito di fare lo stesso, alle seguenti condizioni:
37
+
38
+ Attribuzione obbligatoria – La nota di copyright sopra riportata, questa nota di permesso e la seguente dicitura di credito devono essere incluse in tutte le copie, opere derivate o porzioni sostanziali del Software, sia in forma sorgente che binaria:
39
+
40
+ > "Questo software include codice creato originariamente da Gab (aka Gab333 / 333bot), concesso in licenza sotto MIT License."
41
+
42
+
43
+
44
+ La nota di copyright e di permesso di cui sopra deve essere inclusa in tutte le copie o porzioni sostanziali del Software.
45
+
46
+ Le modifiche devono essere chiaramente documentate, in modo da non implicare erroneamente l'autorialità dell'autore originale senza suo esplicito consenso.
47
+
48
+
49
+ ---
50
+
51
+ Esclusione di responsabilità
52
+
53
+ IL SOFTWARE VIENE FORNITO "COSÌ COM'È", SENZA GARANZIE DI ALCUN TIPO, ESPLICITE O IMPLICITE, INCLUSE MA NON LIMITATE ALLE GARANZIE DI COMMERCIABILITÀ, IDONEITÀ PER UNO SCOPO PARTICOLARE E NON VIOLAZIONE DI DIRITTI.
54
+ IN NESSUN CASO GLI AUTORI O I TITOLARI DEL COPYRIGHT POTRANNO ESSERE RITENUTI RESPONSABILI PER QUALSIASI RECLAMO, DANNO O ALTRE RESPONSABILITÀ, SIA IN UN'AZIONE CONTRATTUALE, ILLECITA O ALTRO, DERIVANTI DA, O IN CONNESSIONE CON, IL SOFTWARE O L'USO O ALTRE OPERAZIONI NEL SOFTWARE.
55
+
56
+
57
+ ---
58
+
package/README.MD ADDED
@@ -0,0 +1,611 @@
1
+ <div align="center">
2
+
3
+ <!-- BANNER -->
4
+ <img src="https://capsule-render.vercel.app/api?type=venom&color=0:020b18,50:00bfff,100:1e90ff&height=280&section=header&text=BASED&fontSize=130&fontColor=ffffff&animation=fadeIn&fontAlignY=55&stroke=00bfff&strokeWidth=2&desc=@GabWT333%20·%20WhatsApp%20Web%20API&descSize=18&descAlignY=78&descColor=7ec8e3" width="100%"/>
5
+
6
+ <!-- LOGO -->
7
+ <br>
8
+
9
+ <img src="https://qu.ax/FNs6D" width="100" height="100" style="border-radius:50%; border: 3px solid #00bfff; box-shadow: 0 0 20px #00bfff;"/>
10
+
11
+ <br><br>
12
+
13
+ <!-- ANIMATED TYPING -->
14
+ <img src="https://readme-typing-svg.herokuapp.com?font=JetBrains+Mono&weight=800&size=22&duration=3000&pause=1500&color=00BFFF&center=true&vCenter=true&repeat=true&width=600&height=45&lines=⚡+Fast+WhatsApp+Web+API;🔵+Full+LID+%2F+JID+Support;🛡️+Anti-Ban+Ready;🧠+Smart+TTL+Cache+System;📦+Built+on+Baileys+%2B+Improved" alt="Typing SVG"/>
15
+
16
+ <br><br>
17
+
18
+ <!-- BADGES ROW 1 -->
19
+ <a href="https://www.npmjs.com/package/@GabWT333/based">
20
+ <img src="https://img.shields.io/npm/v/@GabWT333/based?style=for-the-badge&logo=npm&logoColor=white&label=VERSION&color=00bfff&labelColor=020b18"/>
21
+ </a>
22
+ <a href="https://www.npmjs.com/package/@GabWT333/based">
23
+ <img src="https://img.shields.io/npm/dm/@GabWT333/based?style=for-the-badge&logo=npm&logoColor=white&label=DOWNLOADS%2FMO&color=1e90ff&labelColor=020b18"/>
24
+ </a>
25
+ <a href="https://www.npmjs.com/package/@GabWT333/based">
26
+ <img src="https://img.shields.io/npm/dt/@GabWT333/based?style=for-the-badge&logo=npm&logoColor=white&label=TOTAL+DL&color=00bfff&labelColor=020b18"/>
27
+ </a>
28
+ <a href="https://github.com/GabWT333/based/stargazers">
29
+ <img src="https://img.shields.io/github/stars/GabWT333/based?style=for-the-badge&logo=github&logoColor=white&label=STARS&color=00bfff&labelColor=020b18"/>
30
+ </a>
31
+ <a href="https://github.com/GabWT333/based/forks">
32
+ <img src="https://img.shields.io/github/forks/GabWT333/based?style=for-the-badge&logo=git&logoColor=white&label=FORKS&color=1e90ff&labelColor=020b18"/>
33
+ </a>
34
+
35
+ <br>
36
+
37
+ <!-- BADGES ROW 2 -->
38
+ <a href="https://github.com/GabWT333/based/blob/main/LICENSE">
39
+ <img src="https://img.shields.io/badge/LICENSE-MIT-1e90ff?style=for-the-badge&labelColor=020b18"/>
40
+ </a>
41
+ <a href="https://nodejs.org">
42
+ <img src="https://img.shields.io/badge/NODE-18%2B-00bfff?style=for-the-badge&logo=nodedotjs&logoColor=white&labelColor=020b18"/>
43
+ </a>
44
+ <a href="https://www.typescriptlang.org">
45
+ <img src="https://img.shields.io/badge/TYPESCRIPT-READY-1e90ff?style=for-the-badge&logo=typescript&logoColor=white&labelColor=020b18"/>
46
+ </a>
47
+ <a href="https://github.com/GabWT333/based/issues">
48
+ <img src="https://img.shields.io/github/issues/GabWT333/based?style=for-the-badge&logo=github&logoColor=white&label=ISSUES&color=00bfff&labelColor=020b18"/>
49
+ </a>
50
+
51
+ <br><br>
52
+
53
+ <!-- NAV PILLS -->
54
+ [![](https://img.shields.io/badge/·─·%20INSTALL-020b18?style=flat-square&color=020b18&labelColor=00bfff)](#-install)
55
+ [![](https://img.shields.io/badge/·─·%20QUICKSTART-020b18?style=flat-square&color=020b18&labelColor=1e90ff)](#-quickstart)
56
+ [![](https://img.shields.io/badge/·─·%20LID%2FJID-020b18?style=flat-square&color=020b18&labelColor=00bfff)](#-lidjid)
57
+ [![](https://img.shields.io/badge/·─·%20MESSAGES-020b18?style=flat-square&color=020b18&labelColor=1e90ff)](#-messages)
58
+ [![](https://img.shields.io/badge/·─·%20GROUPS-020b18?style=flat-square&color=020b18&labelColor=00bfff)](#-groups)
59
+ [![](https://img.shields.io/badge/·─·%20API%20REF-020b18?style=flat-square&color=020b18&labelColor=1e90ff)](#-api-reference)
60
+
61
+ </div>
62
+
63
+ <br>
64
+
65
+ ---
66
+
67
+ <div align="center">
68
+
69
+ ```
70
+ ╭──────────────────────────────────────────────────────────────────╮
71
+ │ │
72
+ │ > based is a WhatsApp Web API library maintained by │
73
+ │ GabWT333, forked from Baileys with serious improvements. │
74
+ │ │
75
+ │ > native LID/JID resolution · smart cache · anti-ban │
76
+ │ > full TypeScript · multi-device · 2025 features │
77
+ │ │
78
+ ╰──────────────────────────────────────────────────────────────────╯
79
+ ```
80
+
81
+ </div>
82
+
83
+ ---
84
+
85
+ ## ⚡ Install
86
+
87
+ ```bash
88
+ npm install @GabWT333/based
89
+ ```
90
+ ```bash
91
+ yarn add @GabWT333/based
92
+ ```
93
+ ```bash
94
+ pnpm add @GabWT333/based
95
+ ```
96
+
97
+ ---
98
+
99
+ ## 🚀 Quickstart
100
+
101
+ <details>
102
+ <summary><b>▶ Basic bot (click to expand)</b></summary>
103
+
104
+ ```typescript
105
+ import makeWASocket, {
106
+ useMultiFileAuthState,
107
+ DisconnectReason,
108
+ setPerformanceConfig
109
+ } from '@GabWT333/based';
110
+
111
+ setPerformanceConfig({
112
+ performance: { enableCache: true, syncFullHistory: false },
113
+ debug: { enableLidLogging: true, logLevel: 'info' }
114
+ });
115
+
116
+ async function start() {
117
+ const { state, saveCreds } = await useMultiFileAuthState('auth');
118
+
119
+ const sock = makeWASocket({
120
+ auth: state,
121
+ printQRInTerminal: true,
122
+ browser: ['GabWT333', 'Chrome', '4.0.0'],
123
+ markOnlineOnConnect: false,
124
+ syncFullHistory: false
125
+ });
126
+
127
+ sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
128
+ if (connection === 'open') console.log('✦ connected!');
129
+ if (connection === 'close') {
130
+ const shouldReconnect =
131
+ (lastDisconnect?.error as any)?.output?.statusCode !== DisconnectReason.loggedOut;
132
+ if (shouldReconnect) start();
133
+ }
134
+ });
135
+
136
+ sock.ev.on('creds.update', saveCreds);
137
+
138
+ sock.ev.on('messages.upsert', async ({ messages }) => {
139
+ const msg = messages[0];
140
+ if (!msg.message) return;
141
+ await sock.sendMessage(msg.key.remoteJid!, { text: 'pong 🏓' }, { quoted: msg });
142
+ });
143
+ }
144
+
145
+ start();
146
+ ```
147
+
148
+ </details>
149
+
150
+ <details>
151
+ <summary><b>🛡️ Anti-ban hardened setup (click to expand)</b></summary>
152
+
153
+ ```typescript
154
+ setPerformanceConfig({
155
+ performance: {
156
+ enableCache: true,
157
+ batchSize: 50,
158
+ maxRetries: 5,
159
+ retryDelay: 5000,
160
+ retryBackoffMultiplier: 1.5,
161
+ maxRetryDelay: 60000,
162
+ maxMsgRetryCount: 3
163
+ }
164
+ });
165
+
166
+ const sock = makeWASocket({
167
+ markOnlineOnConnect: false, // ← never appear online automatically
168
+ syncFullHistory: false, // ← don't pull chat history on connect
169
+ generateHighQualityLinkPreview: true
170
+ });
171
+ ```
172
+
173
+ </details>
174
+
175
+ ---
176
+
177
+ ## 🔵 LID/JID
178
+
179
+ > WhatsApp is migrating to a new identifier format called **LID**. Without proper handling, group messages return `undefined` senders. **based** solves this natively.
180
+
181
+ ```typescript
182
+ import { getSenderLid, validateJid, toJid, normalizeJid } from '@GabWT333/based';
183
+
184
+ sock.ev.on('messages.upsert', ({ messages }) => {
185
+ for (const msg of messages) {
186
+
187
+ const info = getSenderLid(msg);
188
+ // info.jid → '123@s.whatsapp.net'
189
+ // info.lid → '123@lid'
190
+ // info.isValid → true / false
191
+ // info.timestamp → Date.now()
192
+
193
+ const { isValid, error } = validateJid(info.jid);
194
+ if (!isValid) { console.warn('bad jid:', error); continue; }
195
+
196
+ const normalized = toJid(info.lid); // always get a safe JID
197
+ sock.sendMessage(normalized, { text: 'received ✓' });
198
+ }
199
+ });
200
+ ```
201
+
202
+ **Fields auto-injected into every event payload:**
203
+
204
+ | Field | Type | Description |
205
+ |---|---|---|
206
+ | `msg.key.remoteJid` | `string` | Standard JID (`@s.whatsapp.net`) |
207
+ | `msg.key.remoteLid` | `string?` | Raw LID when available |
208
+ | `msg.key.participantLid` | `string?` | Group sender LID |
209
+ | `msg.key.remoteJidNormalized` | `string` | Always-safe normalized JID |
210
+
211
+ ---
212
+
213
+ ## 🧠 Cache
214
+
215
+ ```typescript
216
+ setPerformanceConfig({
217
+ cache: {
218
+ lidCache: { ttl: 300_000, maxSize: 10000, cleanupInterval: 120_000 },
219
+ jidCache: { ttl: 300_000, maxSize: 10000, cleanupInterval: 120_000 },
220
+ lidToJidCache: { ttl: 300_000, maxSize: 5000, cleanupInterval: 180_000 },
221
+ groupMetadataCache: { ttl: 600_000, maxSize: 2000, cleanupInterval: 300_000 }
222
+ }
223
+ });
224
+
225
+ // monitor
226
+ const stats = getCacheStats();
227
+ console.log(`hit rate: ${stats.lidCache.hits / (stats.lidCache.hits + stats.lidCache.misses) * 100}%`);
228
+
229
+ // flush
230
+ clearCache();
231
+ ```
232
+
233
+ <div align="center">
234
+
235
+ ```
236
+ lidCache ──────────── 80–90% fewer API calls
237
+ jidCache ──────────── instant normalization
238
+ lidToJidCache ──────── zero-latency conversion
239
+ groupMetadataCache ─── group ops at warp speed
240
+ ```
241
+
242
+ </div>
243
+
244
+ ---
245
+
246
+ ## 💬 Messages
247
+
248
+ <details>
249
+ <summary><b>📝 Text & Mentions</b></summary>
250
+
251
+ ```typescript
252
+ await sock.sendMessage(jid, {
253
+ text: '*bold* _italic_ ~strike~ `mono`',
254
+ mentions: ['user@s.whatsapp.net']
255
+ });
256
+ ```
257
+
258
+ </details>
259
+
260
+ <details>
261
+ <summary><b>🖼️ Media (image / video / audio / doc / album)</b></summary>
262
+
263
+ ```typescript
264
+ // image
265
+ await sock.sendMessage(jid, { image: { url: './img.jpg' }, caption: 'caption' });
266
+
267
+ // video
268
+ await sock.sendMessage(jid, { video: { url: './clip.mp4' }, gifPlayback: false });
269
+
270
+ // voice note
271
+ await sock.sendMessage(jid, { audio: { url: './voice.mp3' }, mimetype: 'audio/mp4', ptt: true });
272
+
273
+ // document
274
+ await sock.sendMessage(jid, {
275
+ document: { url: './file.pdf' },
276
+ mimetype: 'application/pdf',
277
+ fileName: 'doc.pdf'
278
+ });
279
+
280
+ // album (multi-image)
281
+ await sock.sendMessage(jid, { album: buffers.map(b => ({ image: b })) });
282
+ ```
283
+
284
+ </details>
285
+
286
+ <details>
287
+ <summary><b>🔘 Buttons & Lists</b></summary>
288
+
289
+ ```typescript
290
+ // quick reply buttons
291
+ await sock.sendMessage(jid, {
292
+ text: 'choose:',
293
+ footer: 'GabWT333',
294
+ buttons: [
295
+ { buttonId: 'a', buttonText: { displayText: 'Option A' }, type: 1 },
296
+ { buttonId: 'b', buttonText: { displayText: 'Option B' }, type: 1 }
297
+ ]
298
+ });
299
+
300
+ // list menu
301
+ await sock.sendMessage(jid, {
302
+ text: 'menu', title: 'Pick one', buttonText: 'Open',
303
+ sections: [{
304
+ title: 'Options',
305
+ rows: [
306
+ { title: 'Item 1', rowId: 'i1', description: 'subtitle' },
307
+ { title: 'Item 2', rowId: 'i2', description: 'subtitle' }
308
+ ]
309
+ }]
310
+ });
311
+ ```
312
+
313
+ </details>
314
+
315
+ <details>
316
+ <summary><b>📊 Polls</b></summary>
317
+
318
+ ```typescript
319
+ await sock.sendMessage(jid, {
320
+ poll: {
321
+ name: 'Best runtime?',
322
+ values: ['Node', 'Deno', 'Bun'],
323
+ selectableCount: 1
324
+ }
325
+ });
326
+
327
+ // poll result snapshot
328
+ await sock.sendMessage(jid, {
329
+ pollResultSnapshot: {
330
+ name: 'Best runtime?',
331
+ pollVotes: [
332
+ { optionName: 'Node', optionVoteCount: 12 },
333
+ { optionName: 'Deno', optionVoteCount: 4 }
334
+ ],
335
+ pollType: 0
336
+ }
337
+ });
338
+ ```
339
+
340
+ </details>
341
+
342
+ <details>
343
+ <summary><b>🎠 Carousel</b></summary>
344
+
345
+ ```typescript
346
+ await sock.sendMessage(jid, {
347
+ text: 'swipe →',
348
+ cards: [
349
+ {
350
+ title: 'Card 1', body: 'description',
351
+ image: { url: './img1.jpg' },
352
+ buttons: [{ name: 'quick_reply', buttonParamsJson: '{"display_text":"Go"}' }]
353
+ },
354
+ { title: 'Card 2', body: 'description', video: { url: './clip.mp4' } }
355
+ ],
356
+ carouselCardType: 1 // 1 = horizontal scroll
357
+ });
358
+ ```
359
+
360
+ </details>
361
+
362
+ <details>
363
+ <summary><b>🎨 Stickers & Sticker Packs</b></summary>
364
+
365
+ ```typescript
366
+ // single sticker
367
+ await sock.sendMessage(jid, { sticker: { url: './s.webp' } });
368
+
369
+ // full sticker pack
370
+ await sock.sendMessage(jid, {
371
+ stickerPack: {
372
+ name: 'My Pack', publisher: 'GabWT333',
373
+ stickers: [
374
+ { sticker: { url: './s1.webp' }, emojis: ['🔥'] },
375
+ { sticker: { url: './s2.webp' }, emojis: ['💙'], isAnimated: true }
376
+ ]
377
+ }
378
+ });
379
+ ```
380
+
381
+ </details>
382
+
383
+ <details>
384
+ <summary><b>💸 Payments</b></summary>
385
+
386
+ ```typescript
387
+ // request
388
+ await sock.sendMessage(jid, {
389
+ requestPayment: { currency: 'EUR', amount1000: 5000, requestFrom: jid, note: 'invoice' }
390
+ });
391
+
392
+ // send payment
393
+ await sock.sendMessage(jid, {
394
+ sendPayment: {
395
+ requestMessageKey: { remoteJid: jid, fromMe: false, id: 'msgId' },
396
+ noteMessage: { text: 'paid ✓' }
397
+ }
398
+ });
399
+
400
+ // decline / cancel
401
+ await sock.sendMessage(jid, { declinePayment: { key: { remoteJid: jid, fromMe: false, id: 'msgId' } } });
402
+ await sock.sendMessage(jid, { cancelPayment: { key: { remoteJid: jid, fromMe: true, id: 'msgId' } } });
403
+ ```
404
+
405
+ </details>
406
+
407
+ <details>
408
+ <summary><b>📌 Pin · 🤖 AI Rich · 🔐 Encrypted · 📅 Scheduled Call · and more</b></summary>
409
+
410
+ ```typescript
411
+ // pin / unpin
412
+ await sock.sendMessage(jid, {
413
+ pin: { key: { remoteJid: jid, fromMe: false, id: 'msgId' }, type: 1, time: 86400 }
414
+ });
415
+
416
+ // AI rich response
417
+ await sock.sendMessage(jid, {
418
+ ai: true,
419
+ richResponse: {
420
+ messageType: 1,
421
+ submessages: [
422
+ { messageType: 2, messageText: 'Here is the answer' },
423
+ { messageType: 5, codeMetadata: { codeLanguage: 'js', codeBlocks: [{ codeContent: 'console.log("hi")' }] } }
424
+ ]
425
+ }
426
+ });
427
+
428
+ // scheduled call
429
+ await sock.sendMessage(jid, {
430
+ call: {
431
+ callKey: { fromMe: true, id: Date.now().toString(), remoteJid: jid },
432
+ type: 'OFFER',
433
+ time: Date.now() + 3_600_000,
434
+ title: 'Team sync'
435
+ }
436
+ });
437
+
438
+ // status sticker on broadcast
439
+ await sock.sendMessage('status@broadcast',
440
+ { sticker: { url: './s.webp' } },
441
+ { statusJidList: [jid] }
442
+ );
443
+ ```
444
+
445
+ </details>
446
+
447
+ ---
448
+
449
+ ## 👥 Groups
450
+
451
+ ```typescript
452
+ // ── create ──────────────────────────────────────────────────────────
453
+ const g = await sock.groupCreate('My Group 🔵', ['user@s.whatsapp.net']);
454
+
455
+ // ── participants ─────────────────────────────────────────────────────
456
+ await sock.groupParticipantsUpdate(jid, [user], 'add');
457
+ await sock.groupParticipantsUpdate(jid, [user], 'remove');
458
+ await sock.groupParticipantsUpdate(jid, [user], 'promote');
459
+ await sock.groupParticipantsUpdate(jid, [user], 'demote');
460
+
461
+ // ── settings ─────────────────────────────────────────────────────────
462
+ await sock.groupUpdateSubject(jid, 'New name');
463
+ await sock.groupUpdateDescription(jid, 'New description');
464
+ await sock.groupSettingUpdate(jid, 'announcement'); // admin-only
465
+ await sock.groupToggleEphemeral(jid, 86400); // 24h disappearing
466
+ await sock.groupJoinApprovalMode(jid, 'on'); // approval required
467
+ await sock.groupMemberAddMode(jid, 'admin_add'); // admin-only invites
468
+
469
+ // ── invite ───────────────────────────────────────────────────────────
470
+ const code = await sock.groupInviteCode(jid);
471
+ await sock.groupRevokeInvite(jid);
472
+ await sock.groupAcceptInvite(code);
473
+ await sock.groupLeave(jid);
474
+ ```
475
+
476
+ ---
477
+
478
+ ## 📡 Events
479
+
480
+ | Event | Trigger |
481
+ |---|---|
482
+ | `connection.update` | Connection state changed |
483
+ | `creds.update` | Auth credentials rotated — **always save** |
484
+ | `messages.upsert` | New or updated message |
485
+ | `messages.update` | Delivery / read receipt |
486
+ | `group-participants.update` | Member join / leave / promote |
487
+
488
+ ```typescript
489
+ // status tracking
490
+ sock.ev.on('messages.update', updates => {
491
+ for (const { key, update } of updates) {
492
+ const status = ['', 'sent', 'delivered', 'read'][update.status ?? 0];
493
+ console.log(`[${key.id}] → ${status}`);
494
+ }
495
+ });
496
+
497
+ // group events
498
+ sock.ev.on('group-participants.update', ({ id, action, participants }) => {
499
+ console.log(`[${id}] ${action}:`, participants);
500
+ });
501
+ ```
502
+
503
+ ---
504
+
505
+ ## 📖 API Reference
506
+
507
+ | Method | Returns | Description |
508
+ |---|---|---|
509
+ | `makeWASocket(cfg)` | `WASocket` | Create the socket |
510
+ | `useMultiFileAuthState(dir)` | `{ state, saveCreds }` | Persistent auth |
511
+ | `getSenderLid(msg)` | `SenderInfo` | Safe sender extraction |
512
+ | `validateJid(jid)` | `{ isValid, error }` | JID validation |
513
+ | `toJid(lid)` | `string` | LID → JID conversion |
514
+ | `normalizeJid(jid)` | `string` | Normalize any JID |
515
+ | `isValidJid(jid)` | `boolean` | Quick validity check |
516
+ | `getCacheStats()` | `CacheStats` | Hit/miss/size metrics |
517
+ | `clearCache()` | `void` | Flush all caches |
518
+ | `setPerformanceConfig(cfg)` | `void` | Tune perf settings |
519
+ | `getPerformanceConfig()` | `Config` | Read live config |
520
+
521
+ ---
522
+
523
+ ## 🔧 Troubleshooting
524
+
525
+ <details>
526
+ <summary><b>Connection keeps dropping</b></summary>
527
+
528
+ Use exponential backoff — set `maxRetries: 5` and `retryBackoffMultiplier: 1.5`. Never reconnect immediately on close.
529
+
530
+ </details>
531
+
532
+ <details>
533
+ <summary><b>Sender is undefined in group messages</b></summary>
534
+
535
+ Always use `getSenderLid(msg)` instead of reading `msg.key.participant` raw. The library patches this automatically in events but getSenderLid provides additional metadata.
536
+
537
+ </details>
538
+
539
+ <details>
540
+ <summary><b>Memory keeps growing</b></summary>
541
+
542
+ Reduce `maxSize` or `ttl` on cache entries. Call `clearCache()` periodically or on `connection.open`.
543
+
544
+ </details>
545
+
546
+ <details>
547
+ <summary><b>Account getting banned</b></summary>
548
+
549
+ Critical settings: `markOnlineOnConnect: false` + `syncFullHistory: false`. Lower `batchSize` to 30–50. Add natural delays between bulk sends.
550
+
551
+ </details>
552
+
553
+ ---
554
+
555
+ ## 🛡️ Security
556
+
557
+ | Layer | Tech |
558
+ |---|---|
559
+ | End-to-End Encryption | Signal Protocol |
560
+ | Key Management | Auto-generation & rotation |
561
+ | Authentication | QR code or pairing code |
562
+ | Storage | Encrypted local credentials |
563
+
564
+ ---
565
+
566
+ ## 🙏 Credits
567
+
568
+ | Project | Contribution |
569
+ |---|---|
570
+ | [Baileys](https://github.com/WhiskeySockets/Baileys) | Core WhatsApp Web engine |
571
+ | [Yupra](https://www.npmjs.com/package/@yupra/baileys) | LID/JID resolution research |
572
+ | [Signal Protocol](https://signal.org/) | E2E encryption layer |
573
+
574
+ ---
575
+
576
+ ## ⚠️ Disclaimer
577
+
578
+ > Not affiliated with WhatsApp Inc. or Meta Platforms.
579
+ > For educational and personal development use only.
580
+ > Use responsibly — abuse may result in account termination.
581
+
582
+ **MIT License © 2025 [GabWT333](https://github.com/GabWT333)**
583
+
584
+ ---
585
+
586
+ <div align="center">
587
+
588
+ <br>
589
+
590
+ <!-- FOOTER BANNER -->
591
+ <img src="https://capsule-render.vercel.app/api?type=shark&color=0:1e90ff,100:020b18&height=100&section=footer&reversal=false" width="100%"/>
592
+
593
+ <br>
594
+
595
+ <img src="https://qu.ax/FNs6D" width="64" height="64" style="border-radius:50%"/>
596
+
597
+ <br>
598
+
599
+ <img src="https://readme-typing-svg.herokuapp.com?font=JetBrains+Mono&size=14&duration=4000&pause=2000&color=00BFFF&center=true&vCenter=true&width=400&lines=built+with+%F0%9F%92%99+by+GabWT333;github.com%2FGabWT333%2Fbased" alt="footer typing"/>
600
+
601
+ <br>
602
+
603
+ [![GitHub](https://img.shields.io/badge/GitHub-GabWT333%2Fbased-00bfff?style=for-the-badge&logo=github&logoColor=white&labelColor=020b18)](https://github.com/GabWT333/based)
604
+ &nbsp;
605
+ [![NPM](https://img.shields.io/badge/NPM-@GabWT333%2Fbased-1e90ff?style=for-the-badge&logo=npm&logoColor=white&labelColor=020b18)](https://www.npmjs.com/package/@GabWT333/based)
606
+ &nbsp;
607
+ [![Donate](https://img.shields.io/badge/DONATE-PayPal-00bfff?style=for-the-badge&logo=paypal&logoColor=white&labelColor=020b18)](https://paypal.me/GabWT333)
608
+
609
+ <br><br>
610
+
611
+ </div>
@@ -0,0 +1,4 @@
1
+ yarn pbjs -t static-module -w commonjs -o ./WAProto/index.js ./WAProto/WAProto.proto;
2
+ yarn pbts -o ./WAProto/index.d.ts ./WAProto/index.js;
3
+
4
+ #protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=env=node,useOptionals=true,forceLong=long --ts_proto_out=. ./src/Binary/WAMessage.proto;