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:

OptionDefaultMeaning
perChatPerMinute12Message cap per chat per minute (sliding window)
globalPerMinute60Global message cap per minute across all chats
minDelayMs700Base delay before each send β€” scaled by the warmup factor
jitterMs900Gaussian jitter added on top (sigma = jitterMs / 2)
warmupDays7Account warmup length (days)
warmupStartDate.now()Warmup start timestamp β€” persist this value across restarts, or the warmup restarts too
typingSimulationtrueSends a "composing" presence before text/caption messages
groupAddMax / groupAddWindowMs3 / 600000At most 3 member-add operations per group per 10 minutes
groupCreateMax / groupCreateWindowMs2 / 600000At most 2 group creations per 10 minutes

Exactly what wrap() does to your socket

No magic β€” three methods are wrapped, everything else is untouched:

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

CodeCategoryActionWhat it means
401 loggedOutlogged_outstopSession logged out β€” pair again. Never auto-reconnect.
515 restartRequiredrestart_requiredrestartThe server asked for a restart β€” reconnect once (normal right after pairing).
440 connectionReplacedreplacedstopAnother connection replaced this session β€” check linked devices.
500 badSessionbad_sessionstopCorrupt session β€” delete the auth state and pair again.
411 multideviceMismatchmismatchstopMulti-device mismatch β€” pair again.
403 forbiddenforbiddenstopPossibly restricted/blocked. Stop and inspect the account.
429rate_limitedbackoffToo fast β€” back off and lower your send rate.
408 timedOut / connectionLost, 428 connectionClosed, anything elsetransientreconnectTemporary network/server trouble β€” safe to reconnect with a delay.

Exported components

ExportPurpose
wrapAntiBan(sock, options?)Shortcut to wrap a socket
AunuAntiBanThe main class (.wrap(sock), .warmupFactor(), .effectiveLimit(base))
classifyDisconnect(error)β†’ { category, action, detail }
RateLimiterStandalone limiter (acquire(key) / tryAcquire(key))
gaussianJitter(mean?, sigma?)Gaussian random delay generator
AntiBan reduces risk β€” it does not eliminate it. Spam is still spam: only message people who expect to hear from you, and respect WhatsApp's platform limits.