Hysen Labs
Library / SDK
oxidezap/baileyrs avatar
oxidezap

baileyrs

A Rust-powered WhatsApp Web library for JavaScript, with a Baileys-compatible API

25 stars13 forksTypeScriptMIT
DEEP OPEN-SOURCE ANALYSIS

baileyrs wraps a Rust WhatsApp library for JavaScript

baileyrs is a Rust powered WhatsApp Web library for JavaScript with a Baileys compatible API and WASM based crypto.

How it works

baileyrs is a Rust powered WhatsApp Web library for JavaScript that presents a Baileys compatible API. The README explains that it is a thin JavaScript wrapper over whatsapp-rust compiled to WebAssembly. The heavy work runs in Rust and WASM through the whatsapp-rust-bridge package: the Signal protocol, the Noise handshake, media encryption, binary node serialization, and the protobuf codec all execute outside the JavaScript runtime. The public surface is intentionally shaped to mirror Baileys, the well known WhatsApp library, so existing integrations can move over with minimal changes. The README points to an ATTRIBUTION.md for details on that compatibility. The practical effect is that a team already using Baileys can adopt baileyrs to get Rust level performance for the cryptographic and serialization hot paths while keeping the method names and shapes they know. Because the core is WASM, the library fits into ordinary Node or browser JavaScript builds without a native addon step, which keeps deployment simple compared with a library that needs compiled native bindings. The bridge package is the seam between the two worlds: the JavaScript side exposes the familiar API, and the Rust side does the compute, so the developer rarely has to think about which layer is running a given operation as long as the types line up.

Where it differs from Baileys

The README includes a comparison table that shows the concrete differences. The Signal protocol moves from JavaScript libsignal to Rust and WASM. Media encrypt and decrypt moves from Node crypto to Rust AES-256-CBC with HMAC. Media upload and download moves from JavaScript fetch with temp files to Rust with CDN failover, auth refresh, and resumable upload. Key management moves from a JavaScript auth state to a Rust PersistenceManager. Auto reconnect changes from a manual startSock loop to retries handled in Rust with fibonacci backoff, while terminal drops remain the caller's responsibility. Each of these is a place where the Rust implementation takes over a part that was previously JavaScript or Node specific. The benefit the project implies is steadier performance and fewer Node only dependencies, especially for media and reconnection handling. The table is a clear way to judge the migration: if your code only touches the high level Baileys style API, the swap is small, while anything that reached into Node crypto or the reconnect loop may need review. The resumable upload and CDN failover in particular are practical wins for media heavy bots, because a dropped connection no longer throws away the bytes already sent, and the auth refresh inside Rust keeps the session alive without the caller writing that logic by hand.

Proving compatibility

Rather than assume it matches Baileys, baileyrs checks. The README lists a declaration audit against upstream's type definitions, a wire fidelity audit of the send path, about 50 behavioral compatibility suites, and a differential fuzz suite that generates its own inputs from the proto schema and compares the two libraries directly. Differences the fuzzers find are recorded with a reason and a review date, and known open ones are listed in a divergence file. This testing story is the part that makes the compatibility claim credible, because it shows the authors measured behavior against the original rather than estimating it. Installation requires Node.js, and the package is published on npm as @oxidezap/baileyrs with download counts and a DeepWiki guide covering sending messages, media, groups, privacy, newsletters, custom stores, socket configuration, error handling, and memory monitoring. The project is written in TypeScript and is released under the MIT license. For a team, the fuzz and audit work is the reason to trust a drop in replacement for an established library. The divergence file is the honest part: instead of claiming perfect parity, the authors publish the gaps they know about, with a review date, so an adopter can check whether a known difference touches the calls their code actually makes before switching.

Editorial conclusion

The library is released under the MIT license, written in TypeScript, and published on npm as @oxidezap/baileyrs.

DEEP OPEN-SOURCE ANALYSIS

Official sources

Community notes

Community notes