@zentrix/baileys 4.1.5
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.
- package/README.md +202 -0
- package/WAProto/index.js +169661 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +53 -0
- package/lib/Defaults/index.js +147 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/Group/sender-message-key.js +29 -0
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +336 -0
- package/lib/Signal/lid-mapping.js +293 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.js +19 -0
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/web-socket-client.d.ts +12 -0
- package/lib/Socket/Client/web-socket-client.js +62 -0
- package/lib/Socket/business.d.ts +171 -0
- package/lib/Socket/business.js +260 -0
- package/lib/Socket/chats.d.ts +267 -0
- package/lib/Socket/chats.js +970 -0
- package/lib/Socket/groups.d.ts +115 -0
- package/lib/Socket/groups.js +334 -0
- package/lib/Socket/index.d.ts +173 -0
- package/lib/Socket/index.js +11 -0
- package/lib/Socket/luxu.d.ts +268 -0
- package/lib/Socket/luxu.js +591 -0
- package/lib/Socket/messages-recv.d.ts +161 -0
- package/lib/Socket/messages-recv.js +1126 -0
- package/lib/Socket/messages-send.d.ts +149 -0
- package/lib/Socket/messages-send.js +913 -0
- package/lib/Socket/newsletter.d.ts +134 -0
- package/lib/Socket/newsletter.js +315 -0
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +43 -0
- package/lib/Socket/socket.js +688 -0
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +10 -0
- package/lib/Store/make-cache-manager-store.d.ts +13 -0
- package/lib/Store/make-cache-manager-store.js +83 -0
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/lib/Store/make-in-memory-store.js +427 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.d.ts +110 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.d.ts +102 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.d.ts +19 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.d.ts +157 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.d.ts +55 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.d.ts +35 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.d.ts +273 -0
- package/lib/Types/Message.js +9 -0
- package/lib/Types/Newsletter.d.ts +103 -0
- package/lib/Types/Newsletter.js +38 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.d.ts +111 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.d.ts +57 -0
- package/lib/Types/index.js +42 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/auth-utils.js +206 -0
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +63 -0
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/business.js +234 -0
- package/lib/Utils/chat-utils.d.ts +71 -0
- package/lib/Utils/chat-utils.js +729 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +151 -0
- package/lib/Utils/decode-wa-message.d.ts +19 -0
- package/lib/Utils/decode-wa-message.js +243 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/event-buffer.js +514 -0
- package/lib/Utils/generics.d.ts +92 -0
- package/lib/Utils/generics.js +423 -0
- package/lib/Utils/history.d.ts +15 -0
- package/lib/Utils/history.js +96 -0
- package/lib/Utils/identity-change-handler.js +68 -0
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/index.js +41 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +93 -0
- package/lib/Utils/logger.d.ts +4 -0
- package/lib/Utils/logger.js +7 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +51 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/make-mutex.js +43 -0
- package/lib/Utils/message-retry-manager.js +192 -0
- package/lib/Utils/messages-media.d.ts +116 -0
- package/lib/Utils/messages-media.js +819 -0
- package/lib/Utils/messages.d.ts +77 -0
- package/lib/Utils/messages.js +816 -0
- package/lib/Utils/noise-handler.d.ts +21 -0
- package/lib/Utils/noise-handler.js +155 -0
- package/lib/Utils/offline-node-processor.js +55 -0
- package/lib/Utils/pre-key-manager.js +95 -0
- package/lib/Utils/process-message.d.ts +41 -0
- package/lib/Utils/process-message.js +321 -0
- package/lib/Utils/signal.d.ts +32 -0
- package/lib/Utils/signal.js +153 -0
- package/lib/Utils/stanza-ack.js +47 -0
- package/lib/Utils/tc-token-utils.js +173 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.js +119 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +229 -0
- package/lib/WABinary/constants.d.ts +30 -0
- package/lib/WABinary/constants.js +40 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.js +252 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.js +265 -0
- package/lib/WABinary/generic-utils.d.ts +17 -0
- package/lib/WABinary/generic-utils.js +198 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +21 -0
- package/lib/WABinary/jid-utils.d.ts +31 -0
- package/lib/WABinary/jid-utils.js +138 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.d.ts +17 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/constants.js +15350 -0
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/encode.js +155 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.d.ts +28 -0
- package/lib/WAUSync/USyncQuery.js +89 -0
- package/lib/WAUSync/USyncUser.d.ts +12 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +35 -0
- package/package.json +108 -0
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
███████╗███████╗███╗ ██╗████████╗██████╗ ██╗██╗ ██╗
|
|
5
|
+
╚══███╔╝██╔════╝████╗ ██║╚══██╔══╝██╔══██╗██║╚██╗██╔╝
|
|
6
|
+
███╔╝ █████╗ ██╔██╗ ██║ ██║ ██████╔╝██║ ╚███╔╝
|
|
7
|
+
███╔╝ ██╔══╝ ██║╚██╗██║ ██║ ██╔══██╗██║ ██╔██╗
|
|
8
|
+
███████╗███████╗██║ ╚████║ ██║ ██║ ██║██║██╔╝ ██╗
|
|
9
|
+
╚══════╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═╝
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### ⚡ BAILEYS — Multi-Device WhatsApp API
|
|
13
|
+
|
|
14
|
+
[](https://github.com/ZENTRIX-TECH1/zentrix-baileys)
|
|
15
|
+
[](LICENSE)
|
|
16
|
+
[](https://nodejs.org)
|
|
17
|
+
[](https://github.com/ZENTRIX-TECH1/zentrix-baileys/stargazers)
|
|
18
|
+
|
|
19
|
+
> **A heavily patched & improved WhatsApp Multi-Device API**
|
|
20
|
+
> Built on top of Baileys — enhanced with critical bug fixes, stability improvements, and extended features.
|
|
21
|
+
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 📦 Installation
|
|
27
|
+
|
|
28
|
+
Pick your preferred install method:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
"@zentrix/baileys": "latest"
|
|
32
|
+
```
|
|
33
|
+
```json
|
|
34
|
+
"@zentrix/baileys": "^4.1.3"
|
|
35
|
+
```
|
|
36
|
+
```json
|
|
37
|
+
"baileys": "npm:@zentrix/baileys@latest"
|
|
38
|
+
```
|
|
39
|
+
```json
|
|
40
|
+
"whiskeysockets/baileys": "npm:@zentrix/baileys@latest"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then install:
|
|
44
|
+
```bash
|
|
45
|
+
npm install
|
|
46
|
+
# or
|
|
47
|
+
yarn install
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Import in your project:**
|
|
51
|
+
```js
|
|
52
|
+
// CommonJS
|
|
53
|
+
const { makeWASocket } = require('@zentrix/baileys')
|
|
54
|
+
|
|
55
|
+
// ESM
|
|
56
|
+
import { makeWASocket } from '@zentrix/baileys'
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 🔧 Drop-in Replacement
|
|
62
|
+
|
|
63
|
+
Already using `@whiskeysockets/baileys`? No code changes needed — just alias it:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"@whiskeysockets/baileys": "npm:@zentrix/baileys@latest"
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
All your existing imports will resolve to ZENTRIX Baileys automatically. ✅
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 🐛 Bugs Fixed
|
|
76
|
+
|
|
77
|
+
### 1. 🔁 Bad MAC Retry Loops
|
|
78
|
+
**Symptom:** Messages fail to decrypt, bot gets stuck in an infinite retry loop.
|
|
79
|
+
|
|
80
|
+
**Fix:** Replaced plain `Map` with a full `MessageRetryManager` class that:
|
|
81
|
+
- Detects MAC errors via `RetryReason` enum and forces **immediate session recreation**
|
|
82
|
+
- Tracks retry counts per message with LRU expiry (15-min TTL)
|
|
83
|
+
- Prevents session recreation hammering with a 1-hour cooldown
|
|
84
|
+
- Supports phone-based resend fallback with cancellable timeouts
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### 2. 🔄 Permanent Bad MAC After Contact Re-registers
|
|
89
|
+
**Symptom:** After a contact reinstalls WhatsApp, every message from them fails to decrypt permanently.
|
|
90
|
+
|
|
91
|
+
**Fix:** Added `handleIdentityChange()` which:
|
|
92
|
+
- Listens for identity change push notifications
|
|
93
|
+
- Debounces rapid identity changes per JID
|
|
94
|
+
- Forces Signal session teardown and rebuild via `assertSessions(force=true)`
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
### 3. ⚡ Pre-key Race Conditions
|
|
99
|
+
**Symptom:** Intermittent decryption failures under high message load.
|
|
100
|
+
|
|
101
|
+
**Fix:** Added `PreKeyManager` which:
|
|
102
|
+
- Creates a separate `PQueue` (concurrency: 1) per key type
|
|
103
|
+
- Serialises all reads/writes, eliminating race conditions
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### 4. 🧊 Event Loop Blocking on Reconnect
|
|
108
|
+
**Symptom:** Bot becomes unresponsive for seconds after reconnecting with a large backlog.
|
|
109
|
+
|
|
110
|
+
**Fix:** Added `makeOfflineNodeProcessor()` which:
|
|
111
|
+
- Yields to the event loop every 10 nodes
|
|
112
|
+
- Catches per-node errors without crashing the processing loop
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### 5. 📨 Incorrect ACK Stanza Construction
|
|
117
|
+
**Symptom:** Some ACKs were missing the `from` field, causing server-side routing issues.
|
|
118
|
+
|
|
119
|
+
**Fix:** Added `buildAckStanza()` — always includes correct fields matching WA Web behaviour.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### 6. 🪪 LID-Addressed Messages Failing to Decrypt
|
|
124
|
+
**Symptom:** Messages from LID-format JIDs silently fail to decrypt.
|
|
125
|
+
|
|
126
|
+
**Fix:** Added `LIDMappingStore` with:
|
|
127
|
+
- Bidirectional LID ↔ Phone Number mapping
|
|
128
|
+
- LRU in-memory cache (3-day TTL)
|
|
129
|
+
- In-flight request deduplication
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
### 7. ❌ Error 463 on 1-to-1 Message Sends
|
|
134
|
+
**Symptom:** Occasional `463` error — message never delivered.
|
|
135
|
+
|
|
136
|
+
**Fix:** Full tctoken system — reads, stores, and attaches privacy tokens to outgoing messages.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## ✨ New Exports
|
|
141
|
+
|
|
142
|
+
| Export | Description |
|
|
143
|
+
|--------|-------------|
|
|
144
|
+
| `isPnUser(jid)` | Checks `@s.whatsapp.net` |
|
|
145
|
+
| `isHostedPnUser(jid)` | Checks `@hosted` server |
|
|
146
|
+
| `isHostedLidUser(jid)` | Checks `@hosted.lid` server |
|
|
147
|
+
| `isJidMetaAI(jid)` | Checks `@bot` server (Meta AI) |
|
|
148
|
+
| `isJidBot(jid)` | Checks bot phone number pattern |
|
|
149
|
+
| `isJidNewsletter(jid)` | Fixed spelling (old alias kept) |
|
|
150
|
+
| `WAJIDDomains` | Enum: `WHATSAPP=0, LID=1, HOSTED=128, HOSTED_LID=129` |
|
|
151
|
+
| `META_AI_JID` | Constant: `'13135550002@c.us'` |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 📁 File Structure
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
zentrix-baileys/
|
|
159
|
+
├── lib/
|
|
160
|
+
│ ├── Utils/
|
|
161
|
+
│ │ ├── index.js ← Updated barrel
|
|
162
|
+
│ │ ├── message-retry-manager.js ← NEW
|
|
163
|
+
│ │ ├── identity-change-handler.js ← NEW
|
|
164
|
+
│ │ ├── pre-key-manager.js ← NEW
|
|
165
|
+
│ │ ├── offline-node-processor.js ← NEW
|
|
166
|
+
│ │ ├── stanza-ack.js ← NEW
|
|
167
|
+
│ │ └── tc-token-utils.js ← NEW
|
|
168
|
+
│ ├── Signal/
|
|
169
|
+
│ │ └── lid-mapping.js ← NEW
|
|
170
|
+
│ └── WABinary/
|
|
171
|
+
│ └── jid-utils.js ← Updated
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 🔗 New Dependencies
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
npm install lru-cache p-queue
|
|
180
|
+
# or
|
|
181
|
+
yarn add lru-cache p-queue
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
> `lru-cache` may already be present in your `package.json` — check before installing.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## 🔗 Links
|
|
189
|
+
|
|
190
|
+
- 📁 **Repository:** [github.com/ZENTRIX-TECH1/zentrix-baileys](https://github.com/ZENTRIX-TECH1/zentrix-baileys)
|
|
191
|
+
- 🐛 **Issues:** [github.com/ZENTRIX-TECH1/zentrix-baileys/issues](https://github.com/ZENTRIX-TECH1/zentrix-baileys/issues)
|
|
192
|
+
- 🌐 **Upstream:** [WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
<div align="center">
|
|
197
|
+
|
|
198
|
+
**Thanks for using ZENTRIX Baileys! 🙏**
|
|
199
|
+
|
|
200
|
+
*Built with 💙 by the Zentrix Team*
|
|
201
|
+
|
|
202
|
+
</div>
|