angularsockets 1.4.4 → 1.4.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 +90 -224
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +16 -5
- package/lib/Defaults/index.js +23 -12
- package/lib/Socket/chats.d.ts +0 -12
- package/lib/Socket/chats.js +1 -38
- package/lib/Socket/messages-send.d.ts +0 -1
- package/lib/Socket/messages-send.js +255 -101
- package/lib/Socket/newsletter.js +88 -123
- package/lib/Socket/setup.js +481 -0
- package/lib/Socket/setup.ts +623 -0
- package/lib/Socket/socket.d.ts +270 -43
- package/lib/Socket/socket.js +1 -1
- package/lib/Types/Message.d.ts +0 -2
- package/lib/Types/Newsletter.d.ts +73 -97
- package/lib/Types/Newsletter.js +18 -38
- package/lib/Utils/generics.js +18 -5
- package/lib/Utils/index.d.ts +0 -2
- package/lib/Utils/index.js +0 -3
- package/lib/Utils/messages-media.d.ts +1 -5
- package/lib/Utils/messages-media.js +170 -77
- package/lib/Utils/messages.d.ts +5 -0
- package/lib/Utils/messages.js +78 -7
- package/lib/Utils/process-message.js +19 -0
- package/lib/Utils/validate-connection.js +77 -21
- package/lib/WABinary/jid-utils.d.ts +1 -0
- package/lib/WABinary/jid-utils.js +3 -1
- package/lib/index.js +10 -28
- package/package.json +28 -38
- package/LICENSE +0 -21
- package/README.MD +0 -170
- package/engine-requirements.js +0 -10
- package/lib/Socket/RHandler.d.ts +0 -416
- package/lib/Socket/RHandler.js +0 -530
- package/lib/Utils/audioToBuffer.js +0 -29
- package/lib/Utils/streamToBuffer.js +0 -15
- package/lib/index.js.bak +0 -56
package/README.md
CHANGED
|
@@ -1,250 +1,116 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
Angularsockets
|
|
3
|
+
</h1>
|
|
1
4
|
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<img src="https://files.catbox.moe/dmz2fn.jpg" width="300" alt="Elaina Bail Banner" />
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://dabby.vercel.app/menu.jpg" width="400" style="border-radius:8px;">
|
|
7
|
+
</p>
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
<strong>Enterprise-Grade WhatsApp Business API</strong>
|
|
11
|
+
</p>
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<img src="https://img.shields.io/npm/v/angularsockets?color=blueviolet&label=version&logo=npm" alt="npm version" />
|
|
13
|
-
</a>
|
|
14
|
-
<a href="https://www.npmjs.com/package/angularsockets">
|
|
15
|
-
<img src="https://img.shields.io/npm/dt/angularsockets?color=blueviolet&label=downloads&logo=npm" alt="npm downloads" />
|
|
16
|
-
</a>
|
|
17
|
-
<a href="https://whatsapp.com/channel/0029VapYyKEGufIpsd3Rja2C">
|
|
18
|
-
<img src="https://img.shields.io/badge/Join-WhatsApp%20Channel-25D366?logo=whatsapp&logoColor=white" alt="WhatsApp Channel" />
|
|
19
|
-
</a>
|
|
20
|
-
</p>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
<p align="center">
|
|
24
|
-
<a href="https://elaina-bail.vercel.app">
|
|
25
|
-
<img src="https://img.shields.io/badge/Documentation-Baileys-blue?style=for-the-badge&logo=readthedocs&logoColor=white" alt="View Documentation">
|
|
26
|
-
</a>
|
|
13
|
+
<p align="center">
|
|
14
|
+
<sub>High-performance modified Baileys library for scalable WhatsApp integrations</sub>
|
|
27
15
|
</p>
|
|
28
16
|
|
|
29
17
|
---
|
|
30
18
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
> **angularsockets** is a refined version of the Baileys library with cleaner API usage, exclusive features like album messaging, newsletter controls, and full-size profile uploads — tailored for modern WhatsApp automation needs.
|
|
34
|
-
|
|
35
|
-
### Current Version: **1.4.0**
|
|
36
|
-
|
|
37
|
-
> **Update Information**
|
|
38
|
-
|
|
39
|
-
All update information is now redirected to the WhatsApp channel:
|
|
40
|
-
|
|
41
|
-
<a href="https://whatsapp.com/channel/0029VapYyKEGufIpsd3Rja2C">
|
|
42
|
-
<img src="https://img.shields.io/badge/Join-WhatsApp%20Channel-25D366?logo=whatsapp&logoColor=white" alt="WhatsApp Channel" />
|
|
43
|
-
</a>
|
|
19
|
+
# 🎀 Angularsockets
|
|
44
20
|
|
|
21
|
+
> **Angularsockets** a mod og *Baileys WhatsApp Web API* by **Mr Frank**
|
|
45
22
|
---
|
|
46
23
|
|
|
47
|
-
##
|
|
48
|
-
|
|
49
|
-
### Via package.json Fork Baileys (NPM)
|
|
50
|
-
|
|
51
|
-
**@whiskeysockets/baileys**
|
|
52
|
-
|
|
53
|
-
```json
|
|
54
|
-
"dependencies": {
|
|
55
|
-
"@whiskeysockets/baileys": "npm:angularsockets"
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
**@adiwajsing/baileys**
|
|
60
|
-
|
|
61
|
-
```json
|
|
62
|
-
"dependencies": {
|
|
63
|
-
"@adiwajshing/baileys": "npm:angularsockets"
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Or via terminal
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
npm install baileys@npm:angularsockets
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Importing (for those who don't fork another repository)
|
|
74
|
-
|
|
75
|
-
**ESM**
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
import makeWASocket from 'angularsockets'
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
**CJS**
|
|
24
|
+
## ✨ Mafeatures
|
|
25
|
+
✅ Stabil & lasts long
|
|
82
26
|
|
|
83
|
-
|
|
84
|
-
const { default: makeWASocket } = require('angularsockets')
|
|
85
|
-
```
|
|
27
|
+
✅ Support multi-device (MD)
|
|
86
28
|
|
|
87
|
-
|
|
29
|
+
✅ Support buttons
|
|
88
30
|
|
|
89
|
-
|
|
31
|
+
✅ SSupport Custom Pairing Code
|
|
90
32
|
|
|
91
|
-
|
|
92
|
-
|----------|-------------|
|
|
93
|
-
| 📢 Channels | Seamlessly send messages to WhatsApp Channels |
|
|
94
|
-
| 🖱️ Buttons | Create interactive messages with button options and quick replies |
|
|
95
|
-
| 🖼️ Albums | Send grouped images or videos as an album (carousel-like format) |
|
|
96
|
-
| 👤 LID Grouping | Handle group operations using the latest @lid addressing style |
|
|
97
|
-
| 🤖 AI Message Style | Add a stylized "AI" icon to messages |
|
|
98
|
-
| 📷 HD Profile Pics | Upload full-size profile pictures without cropping |
|
|
99
|
-
| 🔐 Pairing Code | Generate custom alphanumeric pairing codes |
|
|
100
|
-
| 🛠️ Dev Experience | Reduced noise from logs with optimized libsignal printouts |
|
|
33
|
+
✅ Support Group
|
|
101
34
|
|
|
102
35
|
---
|
|
103
36
|
|
|
104
|
-
##
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
```javascript
|
|
110
|
-
// Create a newsletter
|
|
111
|
-
await sock.newsletterCreate("Elaina Updates");
|
|
112
|
-
|
|
113
|
-
// Change description
|
|
114
|
-
await sock.newsletterUpdateDescription("elaina@newsletter", "Fresh updates weekly");
|
|
115
|
-
|
|
116
|
-
// Send a reaction to a channel message
|
|
117
|
-
await sock.newsletterReactMessage("elaina@newsletter", "175", "🔥");
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
</details>
|
|
121
|
-
|
|
122
|
-
<details>
|
|
123
|
-
<summary><strong>📌 Interactive Messaging</strong></summary>
|
|
124
|
-
|
|
125
|
-
```javascript
|
|
126
|
-
const buttons = [
|
|
127
|
-
{ buttonId: 'btn1', buttonText: { displayText: 'Click Me' }, type: 1 },
|
|
128
|
-
{ buttonId: 'btn2', buttonText: { displayText: 'Visit Site' }, type: 1 }
|
|
129
|
-
];
|
|
130
|
-
|
|
131
|
-
const msg = {
|
|
132
|
-
text: "Choose one:",
|
|
133
|
-
footer: "From Elaina with love 💜",
|
|
134
|
-
buttons,
|
|
135
|
-
headerType: 1
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
await sock.sendMessage(id, msg, { quoted: null });
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
</details>
|
|
142
|
-
|
|
143
|
-
<details>
|
|
144
|
-
<summary><strong>🖼️ Send Album</strong></summary>
|
|
145
|
-
|
|
146
|
-
```javascript
|
|
147
|
-
const media = [
|
|
148
|
-
{ image: { url: "https://example.com/pic1.jpg" } },
|
|
149
|
-
{ video: { url: "https://example.com/clip.mp4" } }
|
|
150
|
-
];
|
|
151
|
-
|
|
152
|
-
await sock.sendMessage(id, { album: media, caption: "Memories 💫" }, { quoted: null });
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
</details>
|
|
156
|
-
|
|
157
|
-
<details>
|
|
158
|
-
<summary><strong>🔐 Pairing with Custom Code</strong></summary>
|
|
159
|
-
|
|
160
|
-
```javascript
|
|
161
|
-
const code = await sock.requestPairingCode("62xxxxxxxxxx", "ELAINA01");
|
|
162
|
-
console.log("Your Pairing Code:", code);
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
</details>
|
|
37
|
+
## 📦 Installation
|
|
38
|
+
Install npm
|
|
39
|
+
```bash
|
|
40
|
+
npm i angularsockets
|
|
166
41
|
|
|
167
|
-
<details>
|
|
168
|
-
<summary><strong>📊 Poll Creation</strong></summary>
|
|
169
42
|
|
|
170
|
-
|
|
171
|
-
const pollMessage = {
|
|
172
|
-
name: "Favorite Color?",
|
|
173
|
-
values: ["Red", "Blue", "Green"],
|
|
174
|
-
selectableCount: 1
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
await sock.sendMessage(id, { poll: pollMessage });
|
|
178
|
-
```
|
|
43
|
+
## Handling Events
|
|
179
44
|
|
|
180
|
-
|
|
45
|
+
- Baileys uses the EventEmitter syntax for events.
|
|
46
|
+
They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
|
|
181
47
|
|
|
182
|
-
|
|
183
|
-
|
|
48
|
+
> [!IMPORTANT]
|
|
49
|
+
> **The events are [these](https://baileys.whiskeysockets.io/types/BaileysEventMap.html)**, it's important you see all events
|
|
184
50
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
await sock.sendMessage(id, { location: locationMessage });
|
|
51
|
+
You can listen to these events like this:
|
|
52
|
+
```ts
|
|
53
|
+
const sock = makeWASocket()
|
|
54
|
+
sock.ev.on('messages.upsert', ({ messages }) => {
|
|
55
|
+
console.log('got messages', messages)
|
|
56
|
+
})
|
|
194
57
|
```
|
|
58
|
+
This is a fix mention @lid for bots working in groups
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
|
|
62
|
+
sock.ev.on('messages.upsert', async chatUpdate => {
|
|
63
|
+
try {
|
|
64
|
+
mek = chatUpdate.messages[0]
|
|
65
|
+
if (!mek.message) return
|
|
66
|
+
mek.message = (Object.keys(mek.message)[0] === 'ephemeralMessage') ? mek.message.ephemeralMessage.message : mek.message
|
|
67
|
+
const m = mek
|
|
68
|
+
const isGroup = m.key.remoteJid.endsWith('@g.us');
|
|
69
|
+
const mentionedJid = mek.message?.extendedTextMessage?.contextInfo?.mentionedJid || [];
|
|
70
|
+
if (isGroup && Array.isArray(mentionedJid) && mentionedJid.some(j => j.endsWith('@lid'))) {
|
|
71
|
+
const groupMetadata = await sock.groupMetadata(mek.key.remoteJid);
|
|
72
|
+
const resolvedMentions = mentionedJid.map(jid => {
|
|
73
|
+
if (jid.endsWith('@lid')) {
|
|
74
|
+
const match = groupMetadata.participants.find(p => p.id === jid);
|
|
75
|
+
return match?.jid || jid;
|
|
76
|
+
}
|
|
77
|
+
return jid;
|
|
78
|
+
});
|
|
79
|
+
mek.message.extendedTextMessage.contextInfo.mentionedJid = resolvedMentions;
|
|
80
|
+
const lidMap = {};
|
|
81
|
+
mentionedJid.forEach(originalLid => {
|
|
82
|
+
if (originalLid.endsWith('@lid')) {
|
|
83
|
+
const match = groupMetadata.participants.find(p => p.id === originalLid);
|
|
84
|
+
if (match && match.jid) {
|
|
85
|
+
const jidNumber = match.jid.split('@')[0];
|
|
86
|
+
const lidNumber = originalLid.split('@')[0];
|
|
87
|
+
lidMap[lidNumber] = jidNumber;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const replaceLidInText = (text) => {
|
|
92
|
+
if (!text) return text;
|
|
93
|
+
Object.entries(lidMap).forEach(([lidNum, jidNum]) => {
|
|
94
|
+
const regex = new RegExp(`@${lidNum}\\b`, 'g');
|
|
95
|
+
text = text.replace(regex, `@${jidNum}`);
|
|
96
|
+
});
|
|
97
|
+
return text;
|
|
98
|
+
};
|
|
99
|
+
if (mek.message.conversation) {
|
|
100
|
+
mek.message.conversation = replaceLidInText(mek.message.conversation);
|
|
101
|
+
}
|
|
102
|
+
if (mek.message.extendedTextMessage?.text) {
|
|
103
|
+
mek.message.extendedTextMessage.text = replaceLidInText(mek.message.extendedTextMessage.text);
|
|
104
|
+
}
|
|
105
|
+
let msg = {
|
|
106
|
+
messages: [proto.WebMessageInfo.fromObject(mek)],
|
|
107
|
+
type: "append",
|
|
108
|
+
};
|
|
109
|
+
return conn.ev.emit("messages.upsert", msg);
|
|
110
|
+
}
|
|
111
|
+
} catch (err) {
|
|
195
112
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
<details>
|
|
199
|
-
<summary><strong>👥 Group Management</strong></summary>
|
|
113
|
+
}
|
|
114
|
+
});
|
|
200
115
|
|
|
201
|
-
```javascript
|
|
202
|
-
// Create group
|
|
203
|
-
const group = await sock.groupCreate("My New Group", [number1, number2]);
|
|
204
|
-
|
|
205
|
-
// Add participants
|
|
206
|
-
await sock.groupAdd(group.id, [number3, number4]);
|
|
207
|
-
|
|
208
|
-
// Change group description
|
|
209
|
-
await sock.groupUpdateDescription(group.id, "This is our awesome group!");
|
|
210
116
|
```
|
|
211
|
-
|
|
212
|
-
</details>
|
|
213
|
-
|
|
214
|
-
---
|
|
215
|
-
|
|
216
|
-
**Note:** Replace `id` with the actual recipient ID and `sock` with your WhatsApp socket connection variable.
|
|
217
|
-
|
|
218
|
-
---
|
|
219
|
-
|
|
220
|
-
## 🐞 Found a Bug?
|
|
221
|
-
|
|
222
|
-
Please contact the maintainer directly via WhatsApp:
|
|
223
|
-
|
|
224
|
-
<p align="center">
|
|
225
|
-
<a href="https://wa.me/263719647303" target="_blank">
|
|
226
|
-
<img alt="WhatsApp" src="https://img.shields.io/badge/Chat%20on%20WhatsApp-25D366?style=for-the-badge&logo=whatsapp&logoColor=white">
|
|
227
|
-
</a>
|
|
228
|
-
</p>
|
|
229
|
-
|
|
230
|
-
---
|
|
231
|
-
|
|
232
|
-
## 🙏 Credits
|
|
233
|
-
|
|
234
|
-
**Creator:** MR FRANK OFC
|
|
235
|
-
|
|
236
|
-
- 🌐 Website: [mrfrankofc.gleeze.com](https://mrfrankofc.gleeze.com)
|
|
237
|
-
- 💻 GitHub: [@mrfr8nk](https://github.com/mrfr8nk)
|
|
238
|
-
|
|
239
|
-
**Special Thanks:**
|
|
240
|
-
- RexyHayanais
|
|
241
|
-
- Nystar
|
|
242
|
-
|
|
243
|
-
> [!CAUTION]
|
|
244
|
-
> Built on top of the WhiskeySockets/Baileys project. All original core logic credits go to their team. angularsockets extends it with thoughtful UX and DX improvements.
|
|
245
|
-
|
|
246
|
-
---
|
|
247
|
-
|
|
248
|
-
<div align="center">
|
|
249
|
-
<p>Made with 💜 by MR FRANK OFC</p>
|
|
250
|
-
</div>
|
package/lib/Defaults/index.d.ts
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { proto } from '../../WAProto';
|
|
2
|
-
import type { MediaType, SocketConfig } from '../Types';
|
|
2
|
+
import type { MediaType, SocketConfig, WAVersion } from '../Types';
|
|
3
|
+
|
|
3
4
|
export declare const UNAUTHORIZED_CODES: number[];
|
|
4
5
|
export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
6
|
+
export declare const CALL_VIDEO_PREFIX = "https://call.whatsapp.com/video/";
|
|
7
|
+
export declare const CALL_AUDIO_PREFIX = "https://call.whatsapp.com/voice/";
|
|
5
8
|
export declare const DEF_CALLBACK_PREFIX = "CB:";
|
|
6
9
|
export declare const DEF_TAG_PREFIX = "TAG:";
|
|
7
10
|
export declare const PHONE_CONNECTION_CB = "CB:Pong";
|
|
11
|
+
|
|
12
|
+
export declare const WA_ADV_ACCOUNT_SIG_PREFIX: Buffer;
|
|
13
|
+
export declare const WA_ADV_DEVICE_SIG_PREFIX: Buffer;
|
|
14
|
+
export declare const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX: Buffer;
|
|
15
|
+
export declare const WA_ADV_HOSTED_DEVICE_SIG_PREFIX: Buffer;
|
|
16
|
+
|
|
8
17
|
export declare const WA_DEFAULT_EPHEMERAL: number;
|
|
9
18
|
export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
10
19
|
export declare const DICT_VERSION = 3;
|
|
11
|
-
export declare const KEY_BUNDLE_TYPE: Buffer
|
|
12
|
-
export declare const NOISE_WA_HEADER: Buffer
|
|
13
|
-
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
20
|
+
export declare const KEY_BUNDLE_TYPE: Buffer;
|
|
21
|
+
export declare const NOISE_WA_HEADER: Buffer;
|
|
14
22
|
export declare const URL_REGEX: RegExp;
|
|
15
23
|
export declare const WA_CERT_DETAILS: {
|
|
16
24
|
SERIAL: number;
|
|
@@ -39,10 +47,13 @@ export declare const MEDIA_HKDF_KEY_MAPPING: {
|
|
|
39
47
|
'product-catalog-image': string;
|
|
40
48
|
'payment-bg-image': string;
|
|
41
49
|
ptv: string;
|
|
50
|
+
'biz-cover-photo': string;
|
|
42
51
|
};
|
|
43
52
|
export declare const MEDIA_KEYS: MediaType[];
|
|
44
53
|
export declare const MIN_PREKEY_COUNT = 5;
|
|
45
|
-
export declare const INITIAL_PREKEY_COUNT =
|
|
54
|
+
export declare const INITIAL_PREKEY_COUNT = 812;
|
|
55
|
+
export declare const UPLOAD_TIMEOUT = 30000;
|
|
56
|
+
export declare const MIN_UPLOAD_INTERVAL = 5000;
|
|
46
57
|
export declare const DEFAULT_CACHE_TTLS: {
|
|
47
58
|
SIGNAL_STORE: number;
|
|
48
59
|
MSG_RETRY: number;
|
package/lib/Defaults/index.js
CHANGED
|
@@ -3,23 +3,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DEFAULT_CACHE_TTLS = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.WA_DEFAULT_EPHEMERAL = exports.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.DEFAULT_ORIGIN = exports.UNAUTHORIZED_CODES = void 0;
|
|
6
|
+
exports.DEFAULT_CACHE_TTLS = exports.MIN_UPLOAD_INTERVAL = exports.UPLOAD_TIMEOUT = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.WA_DEFAULT_EPHEMERAL = exports.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.CALL_AUDIO_PREFIX = exports.CALL_VIDEO_PREFIX = exports.DEFAULT_ORIGIN = exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = exports.WA_ADV_DEVICE_SIG_PREFIX = exports.WA_ADV_ACCOUNT_SIG_PREFIX = exports.UNAUTHORIZED_CODES = void 0;
|
|
7
7
|
const WAProto_1 = require("../../WAProto");
|
|
8
8
|
const libsignal_1 = require("../Signal/libsignal");
|
|
9
9
|
const Utils_1 = require("../Utils");
|
|
10
10
|
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
11
|
-
const
|
|
11
|
+
const version = [2, 3000, 1027934701];
|
|
12
12
|
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
13
13
|
exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
14
|
+
exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
|
|
15
|
+
exports.CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
|
|
14
16
|
exports.DEF_CALLBACK_PREFIX = 'CB:';
|
|
15
17
|
exports.DEF_TAG_PREFIX = 'TAG:';
|
|
16
18
|
exports.PHONE_CONNECTION_CB = 'CB:Pong';
|
|
19
|
+
exports.WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
|
|
20
|
+
exports.WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
|
|
21
|
+
exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
|
|
22
|
+
exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
|
|
17
23
|
exports.WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
18
24
|
exports.NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
|
|
19
25
|
exports.DICT_VERSION = 3;
|
|
20
26
|
exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
21
|
-
exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]);
|
|
22
|
-
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
27
|
+
exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]);
|
|
23
28
|
exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
|
|
24
29
|
exports.WA_CERT_DETAILS = {
|
|
25
30
|
SERIAL: 0,
|
|
@@ -32,7 +37,7 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
|
32
37
|
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND,
|
|
33
38
|
];
|
|
34
39
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
35
|
-
version:
|
|
40
|
+
version: version,
|
|
36
41
|
browser: Utils_1.Browsers.ubuntu('Chrome'),
|
|
37
42
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
38
43
|
connectTimeoutMs: 20000,
|
|
@@ -47,13 +52,15 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
|
47
52
|
fireInitQueries: true,
|
|
48
53
|
auth: undefined,
|
|
49
54
|
markOnlineOnConnect: true,
|
|
50
|
-
syncFullHistory:
|
|
55
|
+
syncFullHistory: true,
|
|
51
56
|
patchMessageBeforeSending: msg => msg,
|
|
52
57
|
shouldSyncHistoryMessage: () => true,
|
|
53
58
|
shouldIgnoreJid: () => false,
|
|
54
59
|
linkPreviewImageThumbnailWidth: 192,
|
|
55
60
|
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
56
61
|
generateHighQualityLinkPreview: false,
|
|
62
|
+
enableAutoSessionRecreation: true,
|
|
63
|
+
enableRecentMessageCache: true,
|
|
57
64
|
options: {},
|
|
58
65
|
appStateMacVerification: {
|
|
59
66
|
patch: false,
|
|
@@ -74,6 +81,7 @@ exports.MEDIA_PATH_MAP = {
|
|
|
74
81
|
'product-catalog-image': '/product/image',
|
|
75
82
|
'md-app-state': '',
|
|
76
83
|
'md-msg-hist': '/mms/md-app-state',
|
|
84
|
+
'biz-cover-photo': '/pps/biz-cover-photo'
|
|
77
85
|
};
|
|
78
86
|
exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
79
87
|
'audio': 'Audio',
|
|
@@ -93,14 +101,17 @@ exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
|
93
101
|
'md-app-state': 'App State',
|
|
94
102
|
'product-catalog-image': '',
|
|
95
103
|
'payment-bg-image': 'Payment Background',
|
|
96
|
-
'ptv': 'Video'
|
|
104
|
+
'ptv': 'Video',
|
|
105
|
+
'biz-cover-photo': 'Image'
|
|
97
106
|
};
|
|
98
107
|
exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
|
|
99
108
|
exports.MIN_PREKEY_COUNT = 5;
|
|
100
|
-
exports.INITIAL_PREKEY_COUNT =
|
|
109
|
+
exports.INITIAL_PREKEY_COUNT = 812;
|
|
110
|
+
exports.UPLOAD_TIMEOUT = 30000;
|
|
111
|
+
exports.MIN_UPLOAD_INTERVAL = 5000;
|
|
101
112
|
exports.DEFAULT_CACHE_TTLS = {
|
|
102
|
-
SIGNAL_STORE: 5 * 60,
|
|
103
|
-
MSG_RETRY: 60 * 60,
|
|
104
|
-
CALL_OFFER: 5 * 60,
|
|
105
|
-
USER_DEVICES: 5 * 60,
|
|
113
|
+
SIGNAL_STORE: 5 * 60,
|
|
114
|
+
MSG_RETRY: 60 * 60,
|
|
115
|
+
CALL_OFFER: 5 * 60,
|
|
116
|
+
USER_DEVICES: 5 * 60,
|
|
106
117
|
};
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -49,18 +49,6 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
49
49
|
id: string;
|
|
50
50
|
fromMe?: boolean;
|
|
51
51
|
}[], star: boolean) => Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Custom: checkStatusWA (for legacy Baileys)
|
|
54
|
-
* - Mengecek apakah nomor WA aktif / dibanned
|
|
55
|
-
* - Mengambil bio/status jika masih aktif
|
|
56
|
-
*/
|
|
57
|
-
checkStatusWA: (numberOrJid: string) => Promise<{
|
|
58
|
-
jid: string
|
|
59
|
-
IsBanned: boolean
|
|
60
|
-
Statusbio: string | null
|
|
61
|
-
setAt: Date | null
|
|
62
|
-
error?: string
|
|
63
|
-
}>,
|
|
64
52
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
65
53
|
type: "md";
|
|
66
54
|
ws: import("./Client").WebSocketClient;
|
package/lib/Socket/chats.js
CHANGED
|
@@ -168,42 +168,6 @@ const makeChatsSocket = (config) => {
|
|
|
168
168
|
return result.list;
|
|
169
169
|
}
|
|
170
170
|
};
|
|
171
|
-
const checkStatusWA = async (numberOrJid) => {
|
|
172
|
-
try {
|
|
173
|
-
const jid = numberOrJid.includes('@s.whatsapp.net')
|
|
174
|
-
? numberOrJid
|
|
175
|
-
: numberOrJid.replace(/[^0-9]/g, '') + '@s.whatsapp.net'
|
|
176
|
-
|
|
177
|
-
const exists = await onWhatsApp(jid)
|
|
178
|
-
if (!exists || !exists[0]?.exists) {
|
|
179
|
-
return {
|
|
180
|
-
jid,
|
|
181
|
-
IsBanned: true,
|
|
182
|
-
Statusbio: null,
|
|
183
|
-
setAt: null
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const fetched = await fetchStatus(jid).catch(() => [])
|
|
188
|
-
const status = fetched?.[0]?.status?.status || null
|
|
189
|
-
const setAt = fetched?.[0]?.status?.setAt || null
|
|
190
|
-
|
|
191
|
-
return {
|
|
192
|
-
jid,
|
|
193
|
-
IsBanned: false,
|
|
194
|
-
Statusbio: status,
|
|
195
|
-
setAt
|
|
196
|
-
}
|
|
197
|
-
} catch (e) {
|
|
198
|
-
return {
|
|
199
|
-
jid: numberOrJid,
|
|
200
|
-
IsBanned: true,
|
|
201
|
-
Statusbio: null,
|
|
202
|
-
setAt: null,
|
|
203
|
-
error: e.message
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
171
|
const fetchDisappearingDuration = async (...jids) => {
|
|
208
172
|
const usyncQuery = new WAUSync_1.USyncQuery()
|
|
209
173
|
.withDisappearingModeProtocol();
|
|
@@ -901,8 +865,7 @@ const checkStatusWA = async (numberOrJid) => {
|
|
|
901
865
|
removeChatLabel,
|
|
902
866
|
addMessageLabel,
|
|
903
867
|
removeMessageLabel,
|
|
904
|
-
star
|
|
905
|
-
checkStatusWA
|
|
868
|
+
star
|
|
906
869
|
};
|
|
907
870
|
};
|
|
908
871
|
exports.makeChatsSocket = makeChatsSocket;
|
|
@@ -23,7 +23,6 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
23
23
|
sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
24
24
|
updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
|
|
25
25
|
sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo>;
|
|
26
|
-
rex: any;
|
|
27
26
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
28
27
|
duration: string;
|
|
29
28
|
}>;
|