AunuAntiBan
New in v1.0.5. An account-protection layer inspired by baileys-antiban (kobie3717), cleanly reimplemented inside the package β no telemetry, no extra network calls.
Enable it in one line
import makeWASocket, { wrapAntiBan } from 'aunubaileys'
let sock = makeWASocket({ auth: state })
sock = wrapAntiBan(sock) // done β sendMessage is now protected
Or with custom options through the class:
import { AunuAntiBan } from 'aunubaileys'
const guard = new AunuAntiBan({
perChatPerMinute: 20,
globalPerMinute: 60,
warmupDays: 7
})
sock = guard.wrap(sock)
What it does
β±οΈ Two-layer rate limiting
Per-chat and global caps on sendMessage β bursts queue up instead of firing all at once.
π² Gaussian jitter
Inter-message delays are randomized with a Gaussian distribution (gaussianJitter) β timing feels human, not robotic.
π± 7-day warmup
New accounts start at a low limit and ramp up gradually (warmupFactor() / effectiveLimit(base)) over the warmup period.
π₯ Group guards
Caps on adding members and creating groups per time window β two of the riskiest ban triggers.
β¨οΈ Typing simulation
Optional "typingβ¦" presence before a message is sent.
π§ classifyDisconnect
Translates disconnect errors into a clear action: stop / restart / reconnect / backoff.
All options β with the real defaults
These defaults are read straight from the AunuAntiBan constructor in the package β not guidelines, the actual values used when you pass nothing:
| Option | Default | Meaning |
|---|---|---|
perChatPerMinute | 12 | Message cap per chat per minute (sliding window) |
globalPerMinute | 60 | Global message cap per minute across all chats |
minDelayMs | 700 | Base delay before each send β scaled by the warmup factor |
jitterMs | 900 | Gaussian jitter added on top (sigma = jitterMs / 2) |
warmupDays | 7 | Account warmup length (days) |
warmupStart | Date.now() | Warmup start timestamp β persist this value across restarts, or the warmup restarts too |
typingSimulation | true | Sends a "composing" presence before text/caption messages |
groupAddMax / groupAddWindowMs | 3 / 600000 | At most 3 member-add operations per group per 10 minutes |
groupCreateMax / groupCreateWindowMs | 2 / 600000 | At most 2 group creations per 10 minutes |
Exactly what wrap() does to your socket
No magic β three methods are wrapped, everything else is untouched:
sendMessageβ first waits for a slot in the global limiter, then the per-chat limiter (sliding-window; if the window is full it sleeps until the oldest hit expires). If typing simulation is on and the content has atextorcaption, it sends acomposingpresence update. Then it waitsminDelayMs Γ warmupFactor + gaussianJitter(0, jitterMs/2)milliseconds, and only then calls the originalsendMessage.groupParticipantsUpdateβ only the'add'action is guarded. Over the cap it throws a Boom error with status 429 ("β¦jeda dulu agar akun aman") instead of sending β catch it and back off; the add did not happen.groupCreateβ same pattern: over the cap, a 429 Boom is thrown and no group is created.
The instance is attached to the socket as sock.aunuAntiBan, so you can inspect or tune it later. The warmup factor runs from 0.3 β 1.0 linearly across warmupDays; effectiveLimit(base) is max(1, floor(base Γ factor)).
classifyDisconnect β the full table
| Code | Category | Action | What it means |
|---|---|---|---|
401 loggedOut | logged_out | stop | Session logged out β pair again. Never auto-reconnect. |
515 restartRequired | restart_required | restart | The server asked for a restart β reconnect once (normal right after pairing). |
440 connectionReplaced | replaced | stop | Another connection replaced this session β check linked devices. |
500 badSession | bad_session | stop | Corrupt session β delete the auth state and pair again. |
411 multideviceMismatch | mismatch | stop | Multi-device mismatch β pair again. |
403 forbidden | forbidden | stop | Possibly restricted/blocked. Stop and inspect the account. |
429 | rate_limited | backoff | Too fast β back off and lower your send rate. |
408 timedOut / connectionLost, 428 connectionClosed, anything else | transient | reconnect | Temporary network/server trouble β safe to reconnect with a delay. |
Exported components
| Export | Purpose |
|---|---|
wrapAntiBan(sock, options?) | Shortcut to wrap a socket |
AunuAntiBan | The main class (.wrap(sock), .warmupFactor(), .effectiveLimit(base)) |
classifyDisconnect(error) | β { category, action, detail } |
RateLimiter | Standalone limiter (acquire(key) / tryAcquire(key)) |
gaussianJitter(mean?, sigma?) | Gaussian random delay generator |