* feat: add cancelPairingCode() and allow requestPairingCode()
- requestPairingCode() now exposes onCodeReceivedEvent if needed,
so it works on clients initialized in QR mode
- Add cancelPairingCode() method to stop pairing and return to QR
- Update TypeScript definitions
* fix(auth): dynamic ADV key in getQR + structural cancelPairingCode
the getQR closure captured advSecretKey once during initialize(), but
requestpairingcode/cancelPairingCode changes the key in IndexedDB.
the stale closure key caused QR scans to fail with HMAC validation error.
fix: read key dynamically via WAWebUserPrefsMultiDevice.getADVSecretKey()
(synchronous in-memory cache) on every getQR call, matching how WhatsApp
web's internal QR component works.
cancelpairingcode now mirrors WhatsApp Web's resetLinkDeviceState:
refreshqr() restarts WebSocket for fresh refs, then
initializeqrlinking() generates a new key. QR emission happens
automatically via the existing change:ref listener.
---------
Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
* fix: prevent store mutation in getContact/getChatModel LID handling
getcontact() and getChatModel() overwrite .id directly on live Backbone
model references from WhatsApp Web's Contact/Participant store. This
permanently corrupts the store for the lifetime of the session, causing
all subsequent lookups for the same contact to crash with:
- "Cannot read properties of undefined (reading '_serialized')"
- "Data passed to getter must include an id property"
the fix resolves LID to phone on the serialized copy only, never
touching the live store model.
fixes#127054
* perf: use BusinessProfile.find() instead of fetchBizProfile()
businessprofile.find() checks the local cache first and only fetches
from the server when the profile is missing, while fetchBizProfile()
always makes a network call (~85-100ms per contact). This significantly
reduces latency when getContact is called repeatedly for the same
business contacts.
closes#201656
co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: remove unnecessary try/catch around BusinessProfile.find()
businessprofile.find() never throws for non-business contacts - it returns
a BusinessProfile model with profileOptions: null, not an error. The comment
was factually incorrect. The existing profileOptions guard handles the
non-business case correctly without any exception handling.
verified in WhatsApp Web DevTools: find() returns a valid object for regular,
business, LID, and even non-existent contacts. Only throws when called without
an id, which cannot happen here.
co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor: simplify contact/chat model utils via native WA functions
replace the O(n²) LID participant loop with WAWebLidMigrationUtils.toPn()
which resolves LID WIDs via LidPnCache in O(1). Remove the findContact
wrapper since Contact.find() accepts strings directly. Use
wawebwidfactory.createWidFromWidLike() for safe isLid() calls that handle
plain-object contact ids without WID prototype methods.
co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* perf: skip BusinessProfile.find() for non-business contacts
wa's own source guards this behind isBusiness || isEnterprise
(WAWebUseBusinessProfile.react). No point querying business profiles
for regular contacts - saves a wasted IQ roundtrip (~80ms) per call.
* revert: remove block/unblock changes from this PR
moved to a dedicated PR (#201671) with a proper fix using
wawebblockcontactutils.getContactToBlockOnlyUseIfNoAssociatedChat()
for correct LID resolution.
* fix: convert contactId to Wid before collection find() calls
contact.find() and BusinessProfile.find() reject plain strings when
the entry is not cached or stale, throwing "gadd called without an id
attr". Use createWid(contactId) to ensure a proper Wid object is passed.
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* update WAWebSendReactionMsgAction call to use sendReactionToMsg method
The WhatsApp Web internal API changed the WAWebSendReactionMsgAction module
from a directly callable function to an object with a sendReactionToMsg method.
Before:
await (window.require('WAWebSendReactionMsgAction'))(msg, reaction);
After:
await (window.require('WAWebSendReactionMsgAction')).sendReactionToMsg(msg, reaction);
This fixes the TypeError: window.require(...) is not a function error
thrown when attempting to react to messages.
* Refactor react method for improved readability
* Update Message.js
Co-authored-by: @BenyFilho
* Update Message.js
Co-authored-by: @Benyfilho
* Update Message.js
Co-authored-by: @BenyFilho
* Update Message.js
Co-authored-by: BenyFilho <BenyFilho@users.noreply.github.com>
---------
Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
Co-authored-by: BenyFilho <BenyFilho@users.noreply.github.com>
* ci: setup workflows, dependabot, labeler and commit linting
* docs: update README, community files and issue templates
* chore: configure prettier, editorconfig and format codebase
* chore: restore changes lost during rebase
* docs: adjust url for new logo
* fix: align badges
* chore: resolve conflicts and re-add temp lint
* copy only requiredDirs and make storeRemoteSession safer
* replace fs-extra copy with native fs cp function
to avoid unhandled exceptions bug in fs-extra
* add recursive option to cp for folders copy
* fix: correct indentation in storeRemoteSession method
Fixed ESLint indentation errors (lines 105-127) by changing from
2-space to 4-space indentation to match project standards.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Fix formatting of session save object in RemoteAuth
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* avoid hang by closing browser only if connected
* fix: correct indentation in destroy() method
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* fix: update call handling for recent WhatsApp Web changes
Updated the call handling logic to accommodate the renaming of Store.Call to WAWebCallCollection in recent WhatsApp Web versions. This ensures that incoming calls are properly managed without breaking functionality.
* Update Client.js
---------
Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
Co-authored-by: tuyuribr <45042245+tuyuribr@users.noreply.github.com>
Ensures correct media upload to channels by using the mimetype from mediaInfo, rather than the file, when creating OpaqueData.
Also, it replaces the call to the function getRandomFilehash with the value of the function to retrieve the correct token.
Co-authored-by: Noel Carcases <noel.david.carcases.gomez@ibm.com>
Co-authored-by: Shir Serlui <70711723+shirser121@users.noreply.github.com>
Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
Fixes TypeError: Cannot read properties of undefined (reading 'markedUnread')
that occurs in newer WhatsApp Web versions.
The sendSeen method was removed/changed in recent WhatsApp Web updates.
Using markSeen resolves the issue.
Fixes#5718
Co-authored-by: cp1797 <cp1797@users.noreply.github.com>
Co-authored-by: eltonnicolau <eltonnicolau@users.noreply.github.com>
Co-authored-by: telmedola <telmedola@users.noreply.github.com>
Co-authored-by: qw271862028 <qw271862028@users.noreply.github.com>
Co-authored-by: duola8789 <duola8789@users.noreply.github.com>