baileys-antiban 3.8.7 → 3.8.8

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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.8.8] - 2026-05-15
9
+
10
+ ### Added
11
+ - **`high-volume` preset** — for established, fully-warmed accounts running enterprise-scale operations. Limits: 40 msg/min, 1500/hr, 8000/day, 400–1800ms delays. Only use on accounts with 6+ months history and no prior bans. Set via `wrapSocket(sock, 'high-volume')` or env var `ANTIBAN_PRESET=high-volume`.
12
+ - **Env-var integration pattern in docs** — full example showing how to drive every antiban parameter from environment variables inside a bot framework (avoids redeploying to tune limits). Based on real-world usage patterns from Zyra (kaikybrofc/zyra).
13
+
8
14
  ## [3.8.7] - 2026-05-14
9
15
 
10
16
  ### Added
package/README.md CHANGED
@@ -1123,6 +1123,46 @@ Now every `npm install` / `openclaw plugins install @openclaw/whatsapp` automati
1123
1123
 
1124
1124
  ---
1125
1125
 
1126
+ ### Full env-var configuration (framework integration pattern)
1127
+
1128
+ When embedding `baileys-antiban` inside a framework or bot engine, drive every parameter from environment variables so you can tune without redeploying:
1129
+
1130
+ ```typescript
1131
+ import { wrapSocket } from 'baileys-antiban';
1132
+ import type { WrapOptions } from 'baileys-antiban';
1133
+
1134
+ function readBoolean(key: string, fallback: boolean): boolean {
1135
+ const v = process.env[key];
1136
+ return v === undefined ? fallback : v !== 'false' && v !== '0';
1137
+ }
1138
+ function readNumber(key: string, fallback: number): number {
1139
+ const v = process.env[key];
1140
+ return v === undefined ? fallback : parseInt(v, 10);
1141
+ }
1142
+
1143
+ const antibanOptions: WrapOptions = {
1144
+ preset: (process.env.WA_ANTIBAN_PRESET as any) || 'conservative',
1145
+ // rate limits
1146
+ maxPerMinute: readNumber('WA_ANTIBAN_MAX_PER_MINUTE', undefined as any),
1147
+ maxPerHour: readNumber('WA_ANTIBAN_MAX_PER_HOUR', undefined as any),
1148
+ maxPerDay: readNumber('WA_ANTIBAN_MAX_PER_DAY', undefined as any),
1149
+ minDelayMs: readNumber('WA_ANTIBAN_MIN_DELAY_MS', undefined as any),
1150
+ maxDelayMs: readNumber('WA_ANTIBAN_MAX_DELAY_MS', undefined as any),
1151
+ // warmup
1152
+ warmupDays: readNumber('WA_ANTIBAN_WARMUP_DAYS', undefined as any),
1153
+ // health
1154
+ logging: readBoolean('WA_ANTIBAN_LOGGING', true),
1155
+ // deaf session
1156
+ deafSession: readBoolean('WA_ANTIBAN_DEAF_SESSION_ENABLED', true)
1157
+ ? { timeoutMs: readNumber('WA_ANTIBAN_DEAF_TIMEOUT_MS', 300_000) }
1158
+ : undefined,
1159
+ };
1160
+
1161
+ const sock = wrapSocket(makeWASocket({ ... }), antibanOptions);
1162
+ ```
1163
+
1164
+ Undefined values fall back to the preset defaults — so you only override what you need. Set `WA_ANTIBAN_PRESET=high-volume` for established enterprise accounts, `WA_ANTIBAN_PRESET=conservative` for new numbers.
1165
+
1126
1166
  ### State not persisting across restarts
1127
1167
 
1128
1168
  Use the FileStateAdapter:
@@ -51,6 +51,24 @@ exports.PRESETS = {
51
51
  groupProfiles: false,
52
52
  logging: true,
53
53
  },
54
+ // For established, fully-warmed accounts running enterprise-scale operations.
55
+ // Only use on accounts with 6+ months history and no prior bans.
56
+ 'high-volume': {
57
+ maxPerMinute: 40,
58
+ maxPerHour: 1500,
59
+ maxPerDay: 8000,
60
+ minDelayMs: 400,
61
+ maxDelayMs: 1800,
62
+ newChatDelayMs: 1200,
63
+ warmupDays: 3,
64
+ day1Limit: 60,
65
+ growthFactor: 2.5,
66
+ inactivityThresholdHours: 24,
67
+ autoPauseAt: 'critical',
68
+ groupMultiplier: 0.95,
69
+ groupProfiles: false,
70
+ logging: true,
71
+ },
54
72
  };
55
73
  function resolveConfig(input) {
56
74
  if (input === undefined) {
@@ -58,14 +76,14 @@ function resolveConfig(input) {
58
76
  }
59
77
  if (typeof input === 'string') {
60
78
  if (!(input in exports.PRESETS)) {
61
- throw new Error(`Unknown preset "${input}". Valid: ${Object.keys(exports.PRESETS).join(', ')}`);
79
+ throw new Error(`Unknown preset "${input}". Valid: conservative, moderate, aggressive, high-volume`);
62
80
  }
63
81
  return { ...exports.PRESETS[input] };
64
82
  }
65
83
  // Object form — extract preset base, merge overrides
66
84
  const { preset = 'conservative', ...overrides } = input;
67
85
  if (!(preset in exports.PRESETS)) {
68
- throw new Error(`Unknown preset "${preset}". Valid: ${Object.keys(exports.PRESETS).join(', ')}`);
86
+ throw new Error(`Unknown preset "${preset}". Valid: conservative, moderate, aggressive, high-volume`);
69
87
  }
70
88
  return { ...exports.PRESETS[preset], ...overrides };
71
89
  }
package/dist/presets.d.ts CHANGED
@@ -16,7 +16,7 @@ export interface ResolvedConfig {
16
16
  persist?: string;
17
17
  logging: boolean;
18
18
  }
19
- export type PresetName = 'conservative' | 'moderate' | 'aggressive';
19
+ export type PresetName = 'conservative' | 'moderate' | 'aggressive' | 'high-volume';
20
20
  export type AntiBanInput = PresetName | Partial<ResolvedConfig & {
21
21
  preset?: PresetName;
22
22
  }> | undefined;
package/dist/presets.js CHANGED
@@ -47,6 +47,24 @@ export const PRESETS = {
47
47
  groupProfiles: false,
48
48
  logging: true,
49
49
  },
50
+ // For established, fully-warmed accounts running enterprise-scale operations.
51
+ // Only use on accounts with 6+ months history and no prior bans.
52
+ 'high-volume': {
53
+ maxPerMinute: 40,
54
+ maxPerHour: 1500,
55
+ maxPerDay: 8000,
56
+ minDelayMs: 400,
57
+ maxDelayMs: 1800,
58
+ newChatDelayMs: 1200,
59
+ warmupDays: 3,
60
+ day1Limit: 60,
61
+ growthFactor: 2.5,
62
+ inactivityThresholdHours: 24,
63
+ autoPauseAt: 'critical',
64
+ groupMultiplier: 0.95,
65
+ groupProfiles: false,
66
+ logging: true,
67
+ },
50
68
  };
51
69
  export function resolveConfig(input) {
52
70
  if (input === undefined) {
@@ -54,14 +72,14 @@ export function resolveConfig(input) {
54
72
  }
55
73
  if (typeof input === 'string') {
56
74
  if (!(input in PRESETS)) {
57
- throw new Error(`Unknown preset "${input}". Valid: ${Object.keys(PRESETS).join(', ')}`);
75
+ throw new Error(`Unknown preset "${input}". Valid: conservative, moderate, aggressive, high-volume`);
58
76
  }
59
77
  return { ...PRESETS[input] };
60
78
  }
61
79
  // Object form — extract preset base, merge overrides
62
80
  const { preset = 'conservative', ...overrides } = input;
63
81
  if (!(preset in PRESETS)) {
64
- throw new Error(`Unknown preset "${preset}". Valid: ${Object.keys(PRESETS).join(', ')}`);
82
+ throw new Error(`Unknown preset "${preset}". Valid: conservative, moderate, aggressive, high-volume`);
65
83
  }
66
84
  return { ...PRESETS[preset], ...overrides };
67
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baileys-antiban",
3
- "version": "3.8.7",
3
+ "version": "3.8.8",
4
4
  "description": "Anti-ban middleware for Baileys WhatsApp bots. Rate limiting, warmup, health monitor, LID resolver, disconnect classifier. Free Whapi.Cloud alternative.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -90,6 +90,7 @@
90
90
  },
91
91
  "devDependencies": {
92
92
  "@types/node": "^20.0.0",
93
+ "@whiskeysockets/baileys": "^7.0.0-rc11",
93
94
  "baileys": "github:WhiskeySockets/Baileys#dfad98f815feb771cc561f32707a00c6e085b1f1",
94
95
  "tsx": "^4.21.0",
95
96
  "typescript": "^5.0.0",