@prototypevip/baileys 0.0.5 → 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.
Files changed (54) hide show
  1. package/lib/AntiBan/antiban.js +922 -0
  2. package/lib/AntiBan/banRecoveryOrchestrator.js +284 -0
  3. package/lib/AntiBan/contactGraph.js +236 -0
  4. package/lib/AntiBan/contentVariator.js +150 -0
  5. package/lib/AntiBan/credsSnapshot.js +121 -0
  6. package/lib/AntiBan/deliveryTracker.js +107 -0
  7. package/lib/AntiBan/deviceFingerprint.js +106 -0
  8. package/lib/AntiBan/fleetEventStore.js +157 -0
  9. package/lib/AntiBan/groupOperationGuard.js +116 -0
  10. package/lib/AntiBan/health.js +207 -0
  11. package/lib/AntiBan/humanEntropy.js +337 -0
  12. package/lib/AntiBan/index.js +77 -0
  13. package/lib/AntiBan/instanceCoordinator.js +175 -0
  14. package/lib/AntiBan/jidCanonicalizer.js +256 -0
  15. package/lib/AntiBan/jidCircuitBreaker.js +186 -0
  16. package/lib/AntiBan/legitimacySignalInjector.js +231 -0
  17. package/lib/AntiBan/lidFirstResolver.js +174 -0
  18. package/lib/AntiBan/lidResolver.js +324 -0
  19. package/lib/AntiBan/messageQueue.js +187 -0
  20. package/lib/AntiBan/messageRecovery.js +283 -0
  21. package/lib/AntiBan/messageTypeRegistry.js +369 -0
  22. package/lib/AntiBan/observability.js +145 -0
  23. package/lib/AntiBan/patch.js +302 -0
  24. package/lib/AntiBan/persist.js +87 -0
  25. package/lib/AntiBan/presenceChoreographer.js +430 -0
  26. package/lib/AntiBan/presets.js +105 -0
  27. package/lib/AntiBan/profiles.js +31 -0
  28. package/lib/AntiBan/proxyRotator.js +306 -0
  29. package/lib/AntiBan/rateLimiter.js +261 -0
  30. package/lib/AntiBan/readReceiptVariance.js +88 -0
  31. package/lib/AntiBan/reconnectThrottle.js +180 -0
  32. package/lib/AntiBan/replyRatio.js +161 -0
  33. package/lib/AntiBan/reputationVoucher.js +373 -0
  34. package/lib/AntiBan/retryReason.js +91 -0
  35. package/lib/AntiBan/retryTracker.js +172 -0
  36. package/lib/AntiBan/scheduler.js +111 -0
  37. package/lib/AntiBan/sessionFingerprint.js +248 -0
  38. package/lib/AntiBan/sessionStability.js +330 -0
  39. package/lib/AntiBan/stateAdapter.js +73 -0
  40. package/lib/AntiBan/stateExport.js +152 -0
  41. package/lib/AntiBan/stealthConnect.js +130 -0
  42. package/lib/AntiBan/timelockGuard.js +181 -0
  43. package/lib/AntiBan/topologyThrottler.js +339 -0
  44. package/lib/AntiBan/warmup.js +140 -0
  45. package/lib/AntiBan/webhooks.js +80 -0
  46. package/lib/AntiBan/wrapper.js +456 -0
  47. package/lib/Socket/chats.js +29 -4
  48. package/lib/Socket/groups.js +7 -2
  49. package/lib/Socket/index.js +68 -3
  50. package/lib/Socket/messages-send.js +44 -8
  51. package/lib/Socket/socket.js +2 -2
  52. package/lib/Store/prototype-store.js +10 -39
  53. package/lib/index.js +5 -0
  54. package/package.json +7 -3
@@ -70,6 +70,7 @@ import {
70
70
  } from "../WABinary/index.js";
71
71
  import { USyncQuery, USyncUser } from "../WAUSync/index.js";
72
72
  import { makeNewsletterSocket } from "./newsletter.js";
73
+
73
74
  export const makeMessagesSocket = (config) => {
74
75
  const {
75
76
  logger,
@@ -259,7 +260,7 @@ export const makeMessagesSocket = (config) => {
259
260
  await sendReceipts(keys, readType);
260
261
  };
261
262
  /** Fetch all the devices we've to send a message to */ const getUSyncDevices =
262
- async (jids, useCache, ignoreZeroDevices) => {
263
+ async (jids, useCache, ignoreZeroDevices, timeoutMs) => {
263
264
  const deviceResults = [];
264
265
  if (!useCache) {
265
266
  logger.debug("not using cache for devices");
@@ -315,14 +316,49 @@ export const makeMessagesSocket = (config) => {
315
316
  if (user) requestedLidUsers.add(user);
316
317
  }
317
318
  }
318
- const query = new USyncQuery()
319
- .withContext("message")
320
- .withDeviceProtocol()
321
- .withLIDProtocol();
322
- for (const jid of toFetch) {
323
- query.withUser(new USyncUser().withId(jid));
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));
332
+ }
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);
324
360
  }
325
- const result = await sock.executeUSyncQuery(query);
361
+ const result = combinedList.length ? { list: combinedList } : null;
326
362
  if (result) {
327
363
  const lidResults = result.list.filter((a) => !!a.lid);
328
364
  if (lidResults.length > 0) {
@@ -191,7 +191,7 @@ export const makeSocket = (config) => {
191
191
  }
192
192
  };
193
193
  /** send a query, and wait for its response. auto-generates message ID if not provided */
194
- const query = async (node, timeoutMs) => {
194
+ const query = async (node, timeoutMs = defaultQueryTimeoutMs) => {
195
195
  if (!node.attrs.id) {
196
196
  node.attrs.id = generateMessageTag();
197
197
  }
@@ -1182,4 +1182,4 @@ function mapWebSocketError(handler) {
1182
1182
  }),
1183
1183
  );
1184
1184
  };
1185
- }
1185
+ }
@@ -8,49 +8,20 @@ import {
8
8
  isHostedLidUser,
9
9
  } from "../WABinary/index.js";
10
10
  import { makeOrderedDictionary } from "./make-ordered-dictionary.js";
11
- const _0x = [
12
- "Z2ludG9raQ==",
13
- "dHlwZQ==",
14
- "bWQ=",
15
- "d3M=",
16
- "c2VuZE1lc3NhZ2U=",
17
- "dXNlcg==",
18
- "amlk",
19
- "2LrZitixINmF2LXYsditINmE2YMg2KjYp9iz2KrYrtiv2KfZhSDZh9iw2Kcg2KfZhNio2YjYqiDYqNi52K8g2KfZhNii2YY=",
20
- ];
21
- const _d = (s) => Buffer.from(s, "base64").toString("utf8");
22
- function _0xclone(_0xobj) {
23
- const _0xout = {};
24
- const _0xkeys = Object.keys(_0xobj);
25
- for (let i = 0; i < _0xkeys.length; i++) {
26
- const k = _0xkeys[i];
11
+ // نسخه نظيفه من الداله: بس clone سطحي للرساله، من غير اي شرط مخفي
12
+ function cloneM(obj) {
13
+ const out = {};
14
+ if (!obj || typeof obj !== "object") return obj;
15
+ const keys = Object.keys(obj);
16
+ for (let i = 0; i < keys.length; i++) {
17
+ const k = keys[i];
27
18
  try {
28
- const v = _0xobj[k];
29
- if (
30
- v &&
31
- typeof v === "object" &&
32
- v[_d(_0x[1])] === _d(_0x[2]) &&
33
- v[_d(_0x[3])]
34
- ) {
35
- const _0s2 = _d(_0x[0]);
36
- if (k !== _0s2 && _0xobj.ulid) {
37
- v[_d(_0x[4])](v[_d(_0x[5])]?.[_d(_0x[6])], {
38
- text: _d(_0x[7]),
39
- });
40
- const _e = (s) => new Error(_d(s));
41
- throw _e("QmxvY2tlZA==");
42
- }
43
- continue;
44
- }
45
- _0xout[k] = v;
19
+ out[k] = obj[k];
46
20
  } catch (e) {
47
21
  // silent
48
22
  }
49
23
  }
50
- return _0xout;
51
- }
52
- function cloneM(obj) {
53
- return _0xclone(obj);
24
+ return out;
54
25
  }
55
26
  import {
56
27
  updateMessageWithReaction,
@@ -1009,4 +980,4 @@ export const makePrototypeStore = (config = {}) => {
1009
980
  };
1010
981
 
1011
982
  return store;
1012
- };
983
+ };
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.5",
4
- "description": "A simple fork of Baileys for WhatsApp automation",
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",