Skip to content
polymorfaPublic
forked from tulir/whatsmeow

About

A GO WhatsApp library focused on industrial scale and efficiency.

Topics

Resources

Contributing

Stars

79 stars

Watchers

7 watching

Forks

 
 

Latest commit

 

History

2,083 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HyperMeow

Go Reference Go

HyperMeow is Polymorfa's production-focused fork of tulir/whatsmeow. It keeps the upstream Go package names and protocol foundation while adding the business-app surface, LID-first identity model, bounded state, PostgreSQL efficiency, and reliability controls needed for large multi-session deployments.

The upstream project remains the smaller choice for applications that only need its core WhatsApp messaging scope. HyperMeow deliberately accepts a broader API and maintenance surface in exchange for the capabilities below.

Why HyperMeow instead of upstream WhatsMeow?

This comparison was last verified against upstream main at c88388f on 2026-11-12. Each upstream sync must update this section when the difference changes.

Area HyperMeow advantage over upstream main
Business app Adds linked-account and eligibility reads, business-profile and cover-photo mutation, product and collection mutation, catalog creation, cart and visibility controls, appeal and merchant-compliance operations, and validated business message builders.
Native Flows Adds typed address, list, order, and Flow message builders with payload limits, exact JSON-number preservation, UTF-8 validation, and response metadata handling.
Identity Treats LIDs as the stable Signal identity, persists PN and username aliases, resolves aliases in batches, exposes phone-number consent messages, and generates LID identity verification codes.
App state Adds atomic label replacement, label and quick-reply events, full-sync event controls, and independent history-sync receipt, storage, and media-deletion policies.
Channels Adds newsletter deletion through generated MEX bindings.
Reliability Hardens malformed binary-node handling, serializes device save/delete operations, surfaces participant-hash mismatches, bounds attacker-influenced caches, and redacts sensitive business payloads from node logs.
PostgreSQL Batches Signal and metadata work, avoids empty PN-to-LID transactions, adds indexed alias lookups, and keeps PostgreSQL authoritative after bounded cache eviction.
Validation Ships a reproducible Barback/PostgreSQL harness covering DM, group, history, media, mixed-message, security-code, phone-consent, resource, and saturation workloads.

Measured system advantages

The repository retains the raw reports and methodology behind these numbers in benchmark/barback/testdata/results. They compare frozen revisions under the same local Barback, PostgreSQL, TLS, Noise, CPU, and memory constraints. They are engineering comparisons, not WhatsApp WAN or account-rate-limit claims.

Measurement Upstream WhatsMeow HyperMeow Result
Disconnected constructor heap, 2,000 clients 78,929 B/client 4,240 B/client 94.6% less Go heap
Group-128 send p95 33.998 ms 7.024 ms 79.3% lower
Group-128 client CPU 5.502 s 2.301 s 58.2% lower
Group-128 SQL calls 165,053 3,456 97.9% fewer
Highest healthy encrypted ping-pong rate 900 pairs/s 1,700 pairs/s 1.89x the rate

The complete three-repeat system matrix documents allocation, RSS, CPU, latency, PostgreSQL, network, and I/O results across five workloads. It also records the trade-offs: history-heavy peak RSS was slightly higher in one comparison, and active-session capacity depends on contacts, groups, media, handlers, and application queues rather than constructor memory alone.

Install

HyperMeow requires Go 1.26 or newer; the module selects Go 1.27.2 as its preferred toolchain.

Install the newest reviewed commit from the authoritative main branch:

go get github.com/polymorfa/hypermeow@main

The main query resolves to a commit pseudo-version. Pin the resulting pseudo-version in go.mod for reproducible builds. Every published semantic version is retracted: do not install HyperMeow with @latest, a version tag, or any feature branch.

To experiment with changes that have not reached main, use the integration branch explicitly:

go get github.com/polymorfa/hypermeow@dev

dev is unstable and may be rebased. Do not use it in production or publish a library that depends on it.

The root package remains named whatsmeow, so use an explicit import alias:

import whatsmeow "github.com/polymorfa/hypermeow"

Migrating from WhatsMeow

Replace go.mau.fi/whatsmeow imports with github.com/polymorfa/hypermeow and remove any old module replacement:

go mod edit -dropreplace=go.mau.fi/whatsmeow
go get github.com/polymorfa/hypermeow@main
go mod tidy

Receiving statuses

Personal and group <status> publications use encrypted message processing; channel statuses keep their plaintext processing path. The original transport tag is preserved for acknowledgments. MessageInfo.StatusKind() distinguishes personal, group and channel publications from ordinary messages, status mentions and replies. Group-status-v2 content is unwrapped while RawMessage retains the original protobuf.

Pairwise status sessions are stored separately from chat sessions. Explicit meta session_scope="status" is honored by default. Applications that consume served AB props can install Client.GetStatusSessionMode before connecting to supply status_infra_1_1_session_split (0 disabled, 1 receiver enabled, 2 sender enabled, 3 forced). This receive change does not enable status publishing.

Custom RemoteSignal receivers must use RemoteReceive.StatusSession to select the pairwise session and carry StatusKind into their application event. Sender keys remain scoped to the group and sender, and private keys and plaintext stay in the remote store. Upgrading this library alone does not upgrade a remote receiver's protocol or storage. Legacy encrypted group publications also need RemoteReceiveResult.StatusKind returned after decrypt and on duplicate delivery, so the client can select the status receipt class without seeing plaintext.

Newsletter observations

NewsletterMessage.ViewCounts preserves the reported view definitions, including an untyped legacy count and a separate views count. It does not select an account's view-definition gate. ViewsCountPresent and ForwardsCountPresent distinguish a reported zero from an absent or malformed counter. The existing scalar count fields remain available.

A nil ReactionCounts means no valid reaction observation; an allocated empty map preserves an explicitly empty list. These observations do not reproduce the client's local database reconciliation. Original message IDs and timestamps may be absent in a live observation; its server position is a separate reference.

NewsletterMilestone accepts quoted and numeric decimal integer positions without converting through floating point. An absent, null or zero position means the milestone has no message (for example a follower-count milestone) and decodes as position 0. It rejects negative, empty, fractional and overflowing positions. Its JSON output keeps quoted positions.

Core compatibility

HyperMeow retains upstream's core support for:

  • private, group, media, and status messages;
  • group management and invite links;
  • typing, delivery, and read receipts;
  • app-state synchronization;
  • retry receipts and message decryption recovery.

New exported functionality is additive unless called out in the changelog.

Remote Signal stores

NewRemoteSignalClient uses a customer-held Signal store through RemoteSignal. The store supplies public prekeys and builds encrypted message stanzas; private keys and message plaintext stay outside HyperMeow. Applications implementing the interface must implement both durable upload operations:

  • PreparePreKeyUpload(ctx, count) returns a RemotePreKeyUploadBatch with an opaque 32-character lowercase hexadecimal BatchID and 1–812 public PreKeys. count selects a fresh batch size. An outstanding batch returns all surviving keys in its original order, even when its size differs from count. Persist that batch across service restarts; do not truncate it or generate a top-up.
  • AcknowledgePreKeyUpload(ctx, batchID, ids) commits the complete upload after the WhatsApp upload IQ succeeds. IDs can cross the 24-bit wrap boundary. The acknowledgement covers every surviving key; consumed original members can remain in the list and must not be recreated. Replaying the last exact ACK after a lost response succeeds without changing a newer batch.

The adapter captures independent public-key and ID snapshots. It checks the literal last uploaded ID and acknowledges the entire captured list. A failed IQ does not acknowledge the batch. After an attempted ACK fails, the adapter retains it and resolves that exact ACK before preparing another batch. Unsupported remote operations fail; there is no fresh-generation fallback. Upload serialization and the adapter mutex keep upload state separate from retry-receipt generation.

GeneratePreKeys and MarkPreKeysUploaded remain separate operations for fresh retry-receipt keys. GenOnePreKey generates one fresh key and marks it published; it never borrows from a prepared upload batch. Remote implementations must reject legacy marking of prepared-batch members. Returned one-time prekeys must have unique nonzero 24-bit IDs, a nonzero 32-byte public key, and no private key or signed-prekey signature.

This interface change requires matching remote-store implementations. It does not establish that a service is deployed or a feature is available to customers. Production consumers continue to pin reviewed main pseudo-versions.

SendMessage and SendFBMessage return the destination used for sending in SendResponse.Chat. GetQRChannel refreshes its active QR code when pairing secrets rotate. Full-sync fetch errors emit events.AppStateSyncError after releasing the sync lock, so a handler can retry the fetch.

The types/richresponse package decodes rich bot responses. Known primitives retain their type names during JSON round trips; unknown primitives, view models, and text-entity metadata retain their raw JSON. Malformed known values return a decode error.

Custom store.ChatSettingsStore implementations must add PutWASARootSecretID and GetWASARootSecretID for bot root-secret state. sqlstore adds this field through schema version 19; its existing migrations remain unchanged. Schema version 20 adds the device is_hosted flag for hosted (coexistence) pairing.

Connection options

Connections use one WebSocket endpoint by default. To try both WhatsApp chat endpoints concurrently, configure the client before connecting:

import (
    whatsmeow "github.com/polymorfa/hypermeow"
    "github.com/polymorfa/hypermeow/socket"
)

// client is an existing *whatsmeow.Client.
client.SocketConfig = &whatsmeow.SocketConfig{
    RaceURLs: append([]string(nil), socket.RaceURLs...),
}

SocketConfig.RaceURLs activates racing when it contains at least two URLs. The first successful upgrade wins. Pending upgrades are canceled, and opened losers close asynchronously with status 1000 and reason loser socket. The winner proceeds without waiting for those close handshakes. If every endpoint fails, the returned error joins the failures in configured URL order. Initial background reconnect classification uses the first matching HTTP status in configured URL order, ahead of network errors from other endpoints. When no HTTP status is present, network and dial failures remain retryable. The existing single-endpoint retry rules remain unchanged.

With zero or one race URL, the client uses SocketConfig.URL, or the default endpoint if URL is empty. With racing enabled, the list supplies the endpoints and URL is ignored. SocketConfig.Origin and Client.WebSocketHeaders apply to all racers. Repeated header values and empty entries that suppress defaults are preserved. Browsers control request headers on JS/WASM builds, as they do for single-endpoint connections.

Client.DisablePostConnectPassiveIQ defaults to false. Set it to true only when your login payload already declares passive: false; the client then skips the post-connect passive/active IQ. This option does not change the login payload. Configure both options before connecting rather than while a connection is active.

Discord

Join the WhatsApp Web ecosystem Discord and visit #hypermeow for project discussion.

Get support

If you'd like business to enterprise-level support from Rajeh, you can book a video chat. Book a 1 hour time slot by contacting him on Discord or pre-ordering here. The earlier you pre-order the better, as his time slots usually fill up very quickly.

If you are a business, we encourage you to contribute back to the development costs of the project. You can do so by booking meetings or sponsoring below. All support is welcome from businesses of all sizes.

Sponsor

If you'd like to financially support this project, you can do so here.

Disclaimer

Caution

This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates. The official WhatsApp website can be found at whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.

The maintainers do not condone using this project in practices that violate the Terms of Service of WhatsApp, and call upon users to use it fairly.

License

Upstream-derived files retain their original Tulir Asokan and contributor copyright notices and remain licensed under MPL-2.0.

Polymorfa-added files: Copyright (c) 2026 Rajeh Taher, licensed under the MIT License.

See LICENSING.md for the file-level boundary.

Connection lifecycle observers

AddConnectionEventHandler(func(context.Context, any)) observes Connected, Disconnected, QR, LoggedOut, StreamReplaced and CATRefreshError. The context is the original connection's ConnectContext argument, captured before asynchronous delivery. A delayed event can arrive after that context is cancelled. Compare it with the connection authority your application owns before updating state; do not label an old event using the newest connection. RemoveConnectionEventHandler(id) removes a registration; an already captured callback can still arrive. Callbacks run without the observer registry lock and can remove themselves.

Generic AddEventHandler consumers still receive these events. Other event types retain their existing API. Connection observers do not authorize a send, undo bytes already sent or prove that a cancelled socket has finished closing. Disconnect and wait for owned work to settle before accepting replacement connection authority. FrameSocket.SetOnDisconnect replaces the callback under the socket lock; assign the legacy field only before connecting. These additions are unreleased until their reviewed main commit is adopted.

Custom decrypted-event buffers should implement store.EventBufferPublicationStore to retain the group-publication flag while atomically deleting plaintext. The SQL store implements this with migration 21. Old processed rows and custom stores without this extension have unknown legacy classification; no status is inferred from a group chat alone.

Recovering an interrupted identity reset

The local adapter deletes both chat and status session rows before removing their shared identity. A failed session deletion therefore leaves the old identity in place. Use Device.DeleteIdentityAndSessions when removing both; custom callers must preserve that order and serialize other writers to the same backend.

Failed rows stay unavailable on the current Device until deletion succeeds. Guarded session access retries deletion of its known pending key before using any stored row. Device.ReconcileSessionResets(ctx) can also retry all tracked failures after storage recovers. A reset that cannot retain all possible failures is refused before it starts; it does not permanently disable the Device or discard unknown failures. Admission retries at most two existing failures, while explicit reconciliation can retry the full bounded set. Both reset history and tracked failures retain at most 1,024 address entries. Pruning history invalidates older prefetched caches, which must be loaded again.

These guards are per Device and are not cross-process fencing. A fresh adapter retains the original identity for surviving rows after a failed library-managed reset; this relies on backend deletion completion and ordering. Custom-store, transaction, process-crash and previous-release state acceptance still need their own evidence. Restarting is not a substitute for repairing a failed backend.

Pending recovery runs before buffered decryption opens its transaction. A previously failed deletion is not reconciled by a write that can still roll back. SQLStore marks its transaction callbacks and also detects transactions opened directly on its underlying database. Custom transactional SessionStores must expose SessionTransactionState or mark their contexts with WithSessionTransaction; callbacks must forward that context. Saved buffered plaintext bypasses new preparation and decryption. These are source contracts, not database/crash or previous-release acceptance evidence.

SQL identity cache and transactions: use SQLStore.DoDecryptionTxn for identity reads or writes inside a database transaction. It owns the commit/rollback boundary, serializes identity-cache access for that device until completion, clears the transaction's cache entries afterward and invalidates earlier identity-fetch tokens. Nested calls with its callback context share that boundary. An externally opened transaction cannot supply its eventual outcome, so identity operations and nested DoDecryptionTxn calls in that context return ErrUnmanagedIdentityTransaction before accessing the cache or running the callback. Phone-number to LID migration also owns its transaction boundary and refuses to run inside an outer transaction. Escaped callback contexts are also rejected. This does not coordinate other SQLStore instances or processes that write the same device rows; those require separate store ownership and admission.

The SQL rollback/replay regression uses a local SQLite database and authored opaque session bytes, not real account traffic or decrypted Signal sessions. Run it with CGO enabled: CGO_ENABLED=1 go test ./store/sqlstore -run TestSQLIdentityRollbackReplay. The SQLite driver is a test-only import; the library still does not register a driver for applications. Cache serialization and guest-session throughput need acceptance on the composed native candidate before merge.

Call-link guests

The guest package registers a one-time guest identity for a WhatsApp call link and logs it in without pairing a phone. The identity lives only in memory and only for one call:

import "github.com/polymorfa/hypermeow/guest"

device := guest.NewDevice(nil) // fresh keys, in-memory stores
reg, err := guest.Register(ctx, device, guest.Request{
    InviteCode: "https://call.whatsapp.com/voice/TOKEN",
    Name:       "Ada",
})
if err != nil {
    return err
}
client, err := guest.NewClient(device, reg, nil)
if err != nil {
    return err
}
err = client.Connect()

NewClient applies the guest identity before creating the client, sets the guest login payload, turns off the post-connect passive IQ and uses the registered browser's User-Agent. Request.BaseURL points registration at another host, such as a simulator. A guest can only join the call link it registered for. Messaging, groups and app state don't apply.

Guest registration never follows HTTP redirects, including with a supplied HTTP client. Point BaseURL directly at the intended registration service. The in-memory guest store retains at most 1024 unconsumed prekeys, including at most 64 retry keys. Upload attempts are at least one second apart; new upload batches are generated at most once per minute. A failed upload can retry its pending keys after the shorter interval. These local resource limits return an error when reached and never evict an unconsumed key.

Signal identities, sessions and sender keys share a limit of 1024 entries and 16 MiB of stored key/value data, in addition to the prekey limit. Each address is limited to 512 bytes. Writes beyond those limits return an error without evicting trusted identities. Replacing existing state or deleting identities and sessions releases the corresponding capacity. These are local policies for one-call guests, not WhatsApp server limits.

Registration error strings omit provider response text. Typed guest.Error fields and unwrapped causes remain available for explicit diagnostics and may contain reflected request data; avoid logging them without redaction.

About

A GO WhatsApp library focused on industrial scale and efficiency.

Topics

Resources

Contributing

Stars

79 stars

Watchers

7 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages