baileys-antiban 3.0.0 → 3.0.1

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/dist/health.js CHANGED
@@ -110,7 +110,7 @@ export class HealthMonitor {
110
110
  reasons.push(`${disconnects} disconnects in last hour (critical threshold)`);
111
111
  }
112
112
  else if (disconnects >= this.config.disconnectWarningThreshold) {
113
- score += 15;
113
+ score += 30;
114
114
  reasons.push(`${disconnects} disconnects in last hour`);
115
115
  }
116
116
  // Failed messages
@@ -127,11 +127,11 @@ export class HealthMonitor {
127
127
  const decayRate = this.lastEventWasSevere ? 2 : 5;
128
128
  score = Math.max(0, score - Math.floor(minutesSinceLastBad * decayRate));
129
129
  let risk;
130
- if (score >= 85)
130
+ if (score >= 80)
131
131
  risk = 'critical';
132
- else if (score >= 60)
132
+ else if (score >= 40)
133
133
  risk = 'high';
134
- else if (score >= 30)
134
+ else if (score >= 15)
135
135
  risk = 'medium';
136
136
  else
137
137
  risk = 'low';
@@ -134,7 +134,7 @@ export class PostReconnectThrottle {
134
134
  }
135
135
  // Calculate budget for current window
136
136
  const baselineRate = this.config.baselineRatePerMinute ? this.config.baselineRatePerMinute() : 8;
137
- const allowedInWindow = Math.floor(baselineRate * multiplier);
137
+ const allowedInWindow = Math.max(1, Math.floor(baselineRate * multiplier));
138
138
  // Check if we're over budget
139
139
  if (this.sendsInCurrentWindow >= allowedInWindow) {
140
140
  const windowRemaining = this.WINDOW_DURATION_MS - (now - this.currentWindowStart);
@@ -37,6 +37,10 @@ export class TimelockGuard {
37
37
  this.config.onTimelockDetected?.(this.getState());
38
38
  this.scheduleResume();
39
39
  }
40
+ else if (this.state.isActive && wasActive) {
41
+ // Already locked but expiry updated — reschedule timer with new expiry
42
+ this.scheduleResume();
43
+ }
40
44
  if (!this.state.isActive && wasActive) {
41
45
  this.clearResumeTimer();
42
46
  this.config.onTimelockLifted?.(this.getState());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baileys-antiban",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
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/index.js",
6
6
  "types": "dist/index.d.ts",