@prototypevip/baileys 0.0.6 → 0.0.7
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/lib/AntiBan/antiban.js +922 -0
- package/lib/AntiBan/banRecoveryOrchestrator.js +284 -0
- package/lib/AntiBan/contactGraph.js +236 -0
- package/lib/AntiBan/contentVariator.js +150 -0
- package/lib/AntiBan/credsSnapshot.js +121 -0
- package/lib/AntiBan/deliveryTracker.js +107 -0
- package/lib/AntiBan/deviceFingerprint.js +106 -0
- package/lib/AntiBan/fleetEventStore.js +157 -0
- package/lib/AntiBan/groupOperationGuard.js +116 -0
- package/lib/AntiBan/health.js +207 -0
- package/lib/AntiBan/humanEntropy.js +337 -0
- package/lib/AntiBan/index.js +77 -0
- package/lib/AntiBan/instanceCoordinator.js +175 -0
- package/lib/AntiBan/jidCanonicalizer.js +256 -0
- package/lib/AntiBan/jidCircuitBreaker.js +186 -0
- package/lib/AntiBan/legitimacySignalInjector.js +231 -0
- package/lib/AntiBan/lidFirstResolver.js +174 -0
- package/lib/AntiBan/lidResolver.js +324 -0
- package/lib/AntiBan/messageQueue.js +187 -0
- package/lib/AntiBan/messageRecovery.js +283 -0
- package/lib/AntiBan/messageTypeRegistry.js +369 -0
- package/lib/AntiBan/observability.js +145 -0
- package/lib/AntiBan/patch.js +302 -0
- package/lib/AntiBan/persist.js +87 -0
- package/lib/AntiBan/presenceChoreographer.js +430 -0
- package/lib/AntiBan/presets.js +105 -0
- package/lib/AntiBan/profiles.js +31 -0
- package/lib/AntiBan/proxyRotator.js +306 -0
- package/lib/AntiBan/rateLimiter.js +261 -0
- package/lib/AntiBan/readReceiptVariance.js +88 -0
- package/lib/AntiBan/reconnectThrottle.js +180 -0
- package/lib/AntiBan/replyRatio.js +161 -0
- package/lib/AntiBan/reputationVoucher.js +373 -0
- package/lib/AntiBan/retryReason.js +91 -0
- package/lib/AntiBan/retryTracker.js +172 -0
- package/lib/AntiBan/scheduler.js +111 -0
- package/lib/AntiBan/sessionFingerprint.js +248 -0
- package/lib/AntiBan/sessionStability.js +330 -0
- package/lib/AntiBan/stateAdapter.js +73 -0
- package/lib/AntiBan/stateExport.js +152 -0
- package/lib/AntiBan/stealthConnect.js +130 -0
- package/lib/AntiBan/timelockGuard.js +181 -0
- package/lib/AntiBan/topologyThrottler.js +339 -0
- package/lib/AntiBan/warmup.js +140 -0
- package/lib/AntiBan/webhooks.js +80 -0
- package/lib/AntiBan/wrapper.js +456 -0
- package/lib/Socket/groups.js +7 -2
- package/lib/Socket/index.js +68 -3
- package/lib/Socket/messages-send.js +42 -56
- package/lib/index.js +5 -0
- package/package.json +7 -3
|
@@ -70,11 +70,6 @@ import {
|
|
|
70
70
|
} from "../WABinary/index.js";
|
|
71
71
|
import { USyncQuery, USyncUser } from "../WAUSync/index.js";
|
|
72
72
|
import { makeNewsletterSocket } from "./newsletter.js";
|
|
73
|
-
// كاش سلبي: لو استعلام اجهزه شخص معين فشل/خلص وقته (حساب يوزرنيم/lid مش
|
|
74
|
-
// قابل للاكتشاف)، منعملش استعلام شبكه تاني ليه قبل ما المهله دي تخلص —
|
|
75
|
-
// كده ما بنستناش كل رساله في الجروب على نفس الحساب اللي مش هيرد اصلاً
|
|
76
|
-
const USYNC_DEVICES_NEGATIVE_CACHE = new Map();
|
|
77
|
-
const USYNC_DEVICES_NEGATIVE_TTL_MS = 5 * 60 * 1000; // 5 دقايق
|
|
78
73
|
|
|
79
74
|
export const makeMessagesSocket = (config) => {
|
|
80
75
|
const {
|
|
@@ -265,7 +260,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
265
260
|
await sendReceipts(keys, readType);
|
|
266
261
|
};
|
|
267
262
|
/** Fetch all the devices we've to send a message to */ const getUSyncDevices =
|
|
268
|
-
async (jids, useCache, ignoreZeroDevices) => {
|
|
263
|
+
async (jids, useCache, ignoreZeroDevices, timeoutMs) => {
|
|
269
264
|
const deviceResults = [];
|
|
270
265
|
if (!useCache) {
|
|
271
266
|
logger.debug("not using cache for devices");
|
|
@@ -290,15 +285,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
290
285
|
const usersToFetch = jidsWithUser.map((j) => j?.user).filter(Boolean);
|
|
291
286
|
mgetDevices = await userDevicesCache.mget(usersToFetch);
|
|
292
287
|
}
|
|
293
|
-
const now = Date.now();
|
|
294
288
|
for (const { jid, user } of jidsWithUser) {
|
|
295
|
-
// لو الشخص ده فشل استعلامه مؤخراً (حساب يوزرنيم/lid مش قابل
|
|
296
|
-
// للاكتشاف)، منعيدش نستنى عليه تاني قبل ما مهله الكاش السلبي تخلص —
|
|
297
|
-
// ده اللي كان بيسبب تأخير كام ثانيه على كل رساله في جروب فيه حساب زي ده
|
|
298
|
-
const negativeUntil = USYNC_DEVICES_NEGATIVE_CACHE.get(user);
|
|
299
|
-
if (negativeUntil && negativeUntil > now) {
|
|
300
|
-
continue; // من غير اجهزه اضافيه ليه، بدون استعلام شبكه تاني
|
|
301
|
-
}
|
|
302
289
|
if (useCache) {
|
|
303
290
|
const devices =
|
|
304
291
|
mgetDevices?.[user] ||
|
|
@@ -329,32 +316,49 @@ export const makeMessagesSocket = (config) => {
|
|
|
329
316
|
if (user) requestedLidUsers.add(user);
|
|
330
317
|
}
|
|
331
318
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
319
|
+
// بنقسم اللي محتاجين استعلام لمجموعات صغيرة (15 لكل مجموعة) بدل
|
|
320
|
+
// استعلام واحد للجروب كله، كل مجموعة بمهلتها الخاصة (4 ثواني). كده
|
|
321
|
+
// لو حساب واحد بس (يوزرنيم/lid مش قابل للاكتشاف) بطّأ، هو بس اللي
|
|
322
|
+
// بيتأثر — باقي الجروب بيتحل ويرد بسرعته الطبيعية زي أي جروب تاني،
|
|
323
|
+
// مفيش تراكم أو حجز 5 دقايق (كل رسالة بتاخد فرصتها من جديد).
|
|
324
|
+
// بارامتر اختياري: مهلة أطول لو النداء ده مش وقت رد حقيقي (تسخين
|
|
325
|
+
// كاش في الخلفية مثلاً) — من غير ما نغيّر سلوك أي نداء موجود قبل
|
|
326
|
+
// كده (الافتراضي لسه 4 ثواني زي ما هو).
|
|
327
|
+
const USYNC_DEVICES_TIMEOUT_MS = timeoutMs || 4000;
|
|
328
|
+
const CHUNK_SIZE = 15;
|
|
329
|
+
const chunks = [];
|
|
330
|
+
for (let i = 0; i < toFetch.length; i += CHUNK_SIZE) {
|
|
331
|
+
chunks.push(toFetch.slice(i, i + CHUNK_SIZE));
|
|
338
332
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
333
|
+
const runChunk = async (chunkJids) => {
|
|
334
|
+
const chunkQuery = new USyncQuery()
|
|
335
|
+
.withContext("message")
|
|
336
|
+
.withDeviceProtocol()
|
|
337
|
+
.withLIDProtocol();
|
|
338
|
+
for (const jid of chunkJids) {
|
|
339
|
+
chunkQuery.withUser(new USyncUser().withId(jid));
|
|
340
|
+
}
|
|
341
|
+
try {
|
|
342
|
+
return await Promise.race([
|
|
343
|
+
sock.executeUSyncQuery(chunkQuery),
|
|
344
|
+
new Promise((resolve) =>
|
|
345
|
+
setTimeout(() => resolve(null), USYNC_DEVICES_TIMEOUT_MS),
|
|
346
|
+
),
|
|
347
|
+
]);
|
|
348
|
+
} catch (e) {
|
|
349
|
+
logger.warn(
|
|
350
|
+
{ e: e, chunkSize: chunkJids.length },
|
|
351
|
+
"USync devices query failed/timed out for this chunk — continuing with the rest",
|
|
352
|
+
);
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
const chunkResults = await Promise.all(chunks.map(runChunk));
|
|
357
|
+
const combinedList = [];
|
|
358
|
+
for (const chunkResult of chunkResults) {
|
|
359
|
+
if (chunkResult?.list?.length) combinedList.push(...chunkResult.list);
|
|
357
360
|
}
|
|
361
|
+
const result = combinedList.length ? { list: combinedList } : null;
|
|
358
362
|
if (result) {
|
|
359
363
|
const lidResults = result.list.filter((a) => !!a.lid);
|
|
360
364
|
if (lidResults.length > 0) {
|
|
@@ -437,24 +441,6 @@ export const makeMessagesSocket = (config) => {
|
|
|
437
441
|
logger.warn({ error: error }, "failed to store user device lists");
|
|
438
442
|
}
|
|
439
443
|
}
|
|
440
|
-
// اي حد كان جوه toFetch بس مرجعش ليه اجهزه في النتيجه (حساب مش قابل
|
|
441
|
-
// للاكتشاف) — بنسجله في الكاش السلبي عشان مانستناهوش تاني قريب
|
|
442
|
-
const resolvedUsers = new Set(Object.keys(deviceMap));
|
|
443
|
-
for (const jid of toFetch) {
|
|
444
|
-
const u = jidDecode(jid)?.user;
|
|
445
|
-
if (u && !resolvedUsers.has(u)) {
|
|
446
|
-
USYNC_DEVICES_NEGATIVE_CACHE.set(u, Date.now() + USYNC_DEVICES_NEGATIVE_TTL_MS);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
} else {
|
|
450
|
-
// فشل الاستعلام كله (تايم اوت/خطأ) — نسجل كل اللي كنا بنجيبهم في
|
|
451
|
-
// الكاش السلبي عشان الرساله الجايه في نفس الجروب متستناش تاني
|
|
452
|
-
for (const jid of toFetch) {
|
|
453
|
-
const u = jidDecode(jid)?.user;
|
|
454
|
-
if (u) {
|
|
455
|
-
USYNC_DEVICES_NEGATIVE_CACHE.set(u, Date.now() + USYNC_DEVICES_NEGATIVE_TTL_MS);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
444
|
}
|
|
459
445
|
return deviceResults;
|
|
460
446
|
};
|
package/lib/index.js
CHANGED
|
@@ -8,5 +8,10 @@ export * from "./WABinary/index.js";
|
|
|
8
8
|
export * from "./WAM/index.js";
|
|
9
9
|
export * from "./WAUSync/index.js";
|
|
10
10
|
export * from "./Store/cache-factory.js";
|
|
11
|
+
|
|
12
|
+
// Anti-ban toolkit (optional, integrated from baileys-antiban)
|
|
13
|
+
export * from "./AntiBan/index.js";
|
|
14
|
+
export { wrapSocket, wrapSocketWithFingerprint } from "./Socket/index.js";
|
|
15
|
+
|
|
11
16
|
export { makeWASocket };
|
|
12
17
|
export default makeWASocket;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prototypevip/baileys",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.7",
|
|
4
|
+
"description": "Baileys fork with optional integrated anti-ban protection (rate limiting, warm-up, health monitoring, human-like messaging)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -34,7 +34,11 @@
|
|
|
34
34
|
"whatsapp-bot",
|
|
35
35
|
"whatsapp-chat",
|
|
36
36
|
"whatsapp-group",
|
|
37
|
-
"whatsapp-web"
|
|
37
|
+
"whatsapp-web",
|
|
38
|
+
"anti-ban",
|
|
39
|
+
"rate-limit",
|
|
40
|
+
"warmup",
|
|
41
|
+
"baileys-antiban"
|
|
38
42
|
],
|
|
39
43
|
"homepage": "https://github.com/GSK-F/baileys",
|
|
40
44
|
"author": "The Prototype",
|