Skip to content

Version 1.16.2 - #63

Open
Eonus21 wants to merge 430 commits into
Eonus21:masterfrom
wwebjs:main
Open

Version 1.16.2#63
Eonus21 wants to merge 430 commits into
Eonus21:masterfrom
wwebjs:main

Conversation

@Eonus21

@Eonus21 Eonus21 commented Mar 4, 2022

Copy link
Copy Markdown
Owner

No description provided.

alechkos and others added 30 commits November 26, 2023 23:00
* Fix window.Store.getMsgInfo is not a function

* Unneccery code removed
Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
* edit caption

* Update Client.js

* refactor: events combined into one line

---------

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
* Change Supported features

* Update "P" to "p"

* style: fixed typo

---------

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
…sage.js (#2556)

* Update Message.js

Fix Cannot read properties of undefined (reading 'mediaStage') when msg or msg.mediaData is undefined.

* node 13 compatible

---------

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
* Fix link preview

* Fix typo

* Fix preview options

* Add example for preview
* fix: allow to send docs without a caption

* fix: typo

* fix: async function proper handling
* add option cipherMsg

* add event  message_ciphertext

* example

* remove option cipherMsg

* removing unlinked code

* Update Client.js

---------

Co-authored-by: Shir Serlui <70711723+shirser121@users.noreply.github.com>
Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
* Reduce supply chain attacks vectors

For some smallers dependencies we should hardcode specific versions to make it harder to make a supply chain attack

* Update package.json
* Fix: Wrong import of Contact object

There was an error in the import:
`const {Contact} = require('./Contact');`
instead of
`const Contact = require('./Contact');`

* style: fix import order

---------

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
* feat: add Message.pin and Message.unpin methods

* feat: added usage example

* docs: clarifications
* added logic to mention groups + fixed user mentions

* usage example updated

* docs fixed

* window.injectToFunction clarifications

* usage example clarifications

* fix: typo

* docs: added missed docs
* fix: fix links retrieving from message

* docs: fix Message.links property type

* refactor: revert bracking changes
…xts" by removing semicolons. (#2697)

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
* fix(isOfficialClient): initial commit

* fix(isOfficial): eslint my dear

* chore: eslint my dear x2

* fix(isOfficial): make code more transparent

* fix(isOfficial): missing await

* fix(isOfficial): Obfuscate set to custom seed so maintainers can verify

* feat(isOfficial): original code

* chore: eslint
* Upgade node version

* Update package.json

* Node v18

* Update README.md

* Prevent unverified lib upgrade

---------

Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
* style: guide link fix and detailed description

Due to updates in the guide, the link broke. I also added a banner to make it look similar to the guide's readme. Additionally, changed link inclusion and revised text for better clarity, aligning it with the descriptive style used in the guide's descriptions.

* fix: change to current wweb version in the lib

* style: bring minor changes

* text background-color

* fix banner

---------

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
* fix: logo link

* fix: fix broken link in readme file

---------

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
* Update GroupChat.js

* Update index.d.ts

* style: clarify method doc

* refactor: add additional check

* fix: provide valid error name

---------

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
* Merge branch 'add-polls' into polls-ext

* added listener to poll votes

* added isUnvote property

* added option for custom message secret

* usage example updated

* added logic for catching removed votes

* usage example updated

* fixed logic for poll vote events

* temp usage example

* No more `isCurrentState`

* messageSecret converted to array

Co-authored-by: tuyuribr <45042245+tuyuribr@users.noreply.github.com>

* docs updated

* we already have messageSecret in vote.parentMessage

* PollVote.selectedOptions changed to be similar to pollOptions

* docs fixed

* window.injectToFunction clarifications

* minor clarifications

* fix: typo

* style: fix broken link in readme file

---------

Co-authored-by: tuyuribr <45042245+tuyuribr@users.noreply.github.com>
Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
purpshell and others added 30 commits February 10, 2026 23:24
Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
Co-authored-by: tuyuribr <45042245+tuyuribr@users.noreply.github.com>
* Store: remove all mentions of window.Store

* Apply suggestion from @BenyFilho

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>

---------

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
* Applying correction given on discord

* Update Client.js

* Update Client.js

* Update Client.js

---------

Co-authored-by: BenyFilho <168232825+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
…127101)

* 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>
* Fix correct module

* fix: joinGroupViaInvite not working
* fix Message get Mentions

* Update Message.js

check if m is a string

* Update Message.js

* Update Message.js

* Update Message.js

* Update Message.js

* Update Message.js

* Update Message.js

* Update Message.js

* Update Message.js

* Update Message.js

* Update Message.js
…handling (#127098)

* 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>
…22449)

* 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>
…#201660)

store.save() was receiving path.join(this.dataPath, this.sessionName)
instead of just this.sessionName. This caused remote stores (e.g. S3)
to use the full local filesystem path as the storage key, resulting in
zip files being saved under paths like:
  sessions/Users/user/project/.wwebjs_session/default/RemoteAuth-default.zip
instead of:
  sessions/RemoteAuth-default.zip

all other store calls (sessionExists, extract, delete) already pass
this.sessionName correctly. This brings store.save in line with them.

the local filesystem operations (creating and cleaning up the zip file)
continue to use path.join(this.dataPath, ...) which is correct.

regression introduced in e6fd112.

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
* fix: use WA's own LID resolution for block/unblock

block() was passing a Chat object to blockContact() which expects a
contact. unblock() was using synchronous Contact.get() which returns
undefined if the contact isn't cached.

with blocklist migration enabled, blocking a PN contact without a chat
fails because the internal S() function needs a LID or an existing chat
to resolve the accountLid. The old getChat() approach worked around this
by creating a chat via findOrCreateLatestChat, but that's a side effect
and passes the wrong type.

use WAWebBlockContactUtils.getContactToBlockOnlyUseIfNoAssociatedChat()
instead, which is WA's own utility for this exact case. It resolves the
contact's LID via getCurrentLidContact() without needing to create a
chat.

* fix: check alternate WID for blocked status in getContactModel

iscontactblocked on PN contacts returns false because the Blocklist
only contains LID entries. Use getAlternateUserWid() to resolve
the PN/LID mapping and check the Blocklist directly, matching WA
web's own $Contact$p_3 fallback logic.

---------

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
* 💥 fix(Channel): handle undefined channelMetadata to prevent crash

* Update Channel.js

* Update Channel.js

* Update Channel.js

Co-authored-by: @BenyFilho

* Update Channel.js

Co-authored-by: @BenyFilho

* Update Channel.js

Co-authored-by: @BenyFilho

* Update Channel.js

Co-authored-by: @BenyFilho

* Update Channel.js

Co-authored-by:

* fix: update description in Channel.js

co-authored-by: @BenyFilho

---------

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
* Updated WWebJS.getContacts to handle business or enterprise contacts properly

* Added missing return statement
…type 4) (#182677)

* fix: recover ciphertext messages via PLACEHOLDER_MESSAGE_RESEND

Add automatic recovery for ciphertext messages using WhatsApp's built-in
PLACEHOLDER_MESSAGE_RESEND (PDO type 4). Override the AB test gate and
send recovery requests after a 5s grace period.

Also adds message_ciphertext_failed event at 15s and fixes incorrect
JSDoc on onAddMessageCiphertextEvent.

* fix: skip message event when ciphertext resolves to revoked

when a ciphertext message is revoked before it decrypts, WhatsApp's
internal revoke handler calls model.set({ type: 'revoked', ... }) on
the existing model in place. This triggers change:type on the ciphertext
model, which fired the deferred listener and emitted a spurious message
event with type === 'revoked'.

add an early return in the once('change:type') callback to skip
onaddmessageevent when the resolved type is revoked.

fixes #201668

* fix: use handlePlaceholderMsgsSeen for ciphertext recovery

replace the manual sendPeerDataOperationRequest call with a direct call
to handlePlaceholderMsgsSeen. This adds subtype filtering (skips
bot_unavailable_fanout, hosted_unavailable_fanout,
view_once_unavailable_fanout), an age check (14 day limit via the
placeholder_message_resend_maximum_days_limit AB prop), and internal
deduplication so the same message doesn't get multiple PDO requests.

the true second argument is the 'is visible' flag the function expects.
since the gate override is already in place earlier in the evaluate
block, the function passes its own internal gate check and proceeds
normally.

suggested by @sofi-ans in review.

* fix: batch ciphertext PDO requests instead of sending per-message

handleplaceholdermsgsseen has built-in chunking (batches of 32 per PDO)
but calling it with [msg] per message from Msg.on('add') bypasses that.
collect ciphertext messages into a shared buffer and flush them in a
single call after the 5s grace period.

also guard the failTimer to skip if the message type already changed.

* fix: replace silent catch blocks with established patterns

address reviewer feedback - remove catch (_) { // comment } pattern:
- Gate override now uses injectToFunction (existing utility)
- PDO call uses direct require without silent error swallowing

* fix(types): add on() overload for message_ciphertext_failed event

* fix: skip unavailable fanout placeholders from ciphertext recovery

unavailable fanout placeholders (view_once, hosted, bot) are
unrecoverable - WhatsApp's handlePlaceholderMsgsSeen explicitly
skips them and won't resend via PDO. Without this check, the
15s failTimer fires message_ciphertext_failed as a false positive.
`Message.react` moved to `Client.sendReaction`
…es (#201713)

WhatsApp Web changed the signature of WAWebChatLoadMessages.loadEarlierMsgs
from positional (chat, msgCollection) to an options object
{chat, msgCollection, signal, threadId, trigger}.

Calling the old positional form crashes with "Cannot read properties of
undefined (reading 'waitForChatLoading')" because the destructure reads
e.chat on the first positional argument instead of treating the first
argument as the chat.

Updates both Chat.fetchMessages and Channel.fetchMessages to pass the
options object. No other behaviour change.
Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
* Fixing getContacts revolve all promisses

Fixing getContacts revolve all promisses

* Update Utils.js

* Fixing getContactModel
* Fix: Event Call

* Update Client.js
* chore: bump versions

* chore: add package-lock.json

* revert: eslint comment

---------

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
* fix(deps): upgrade eslint and plugins to 10.2.0

* chore: manual lint-fix

* chore: automatic lint-fix

* feat(repo): github actions - lint - use node v24

because it is linting (not runtime), so why not
to use the latest stable Node version

* fix: remove @stylistic/eslint-plugin (in favor of prettier)

* fix: eslint uses `ecmaVersion` 2025

* fix: eslint's "mocha" config is isolated (for test files only)

for example `describe` is not considered "global" outside the
test files. the same for all other "eslint/mocha" rules -
they are applied only to files in `/tests` folder.

* chore: update package-lock.json after eslint upgrade
* Fix Block and UnBlock Contact

* Update Contact.js
* update module store

* delete auth stores directory
…01697)

* feat: support big file downloads (read from WA cache + streaming)

* fix: simplify downloadMediaStream to use a single handle

instead of two handles (resultHandle + blobHandle) with disposal gaps,
get the blob handle directly from evaluateHandle and read metadata
via blobHandle.evaluate. This eliminates the intermediate resultHandle
entirely.

blobhandle is disposed in all exit paths: null metadata, evaluate
error, and generator finally.
* fix: prevent duplicate ready events on SPA re-injection

1. Add _injectInProgress concurrency guard
2. Replace polling loops with waitForFunction
3. Deduplicate Backbone listeners via tuple array with cleanup
4. Atomic hasSynced check after listener registration
5. isMainFrame guard and storeAvailable SPA skip in framenavigated

co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: add robustness fixes from fork PR #41

- try/finally around inject() to always reset _injectInProgress
- Atomic hasSynced check inside listener registration evaluate()
- Fix framenavigated: capture isLogout before async, skip re-inject
  only when not logout AND store available
- try/catch around obj.off() in listener cleanup
- Null guard in QR ref change handler
- Reset qrRetries on LOADING_SCREEN event
- Add exposeFunctionIfAbsent in requestPairingCode()

co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove QR listener on auth success

extract named onRefChange handler so it can be removed via
socket.on('change:hasSynced') once authentication succeeds,
matching PR #41's cleanup behavior.

co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor: remove exposeFunctionIfAbsent from requestPairingCode

* fix: run refreshQR in browser context via pupPage.evaluate

the onAuthAppStateChangedEvent callback is registered with
exposefunctionifabsent, so it runs in Node.js context, not the browser.
calling window.require() there throws ReferenceError: window is not defined,
which means the QR code was never refreshed on UNPAIRED_IDLE state.

* fix: remove unnecessary try/catch around Backbone .off()

backbone's .off() never throws - verified on a live WhatsApp Web
instance with non-existent listeners, fake events, and double-off.
the try/catch was defensive but unnecessary.

* fix: remove unnecessary try/catch blocks in framenavigated handler

- storeAvailable: evaluate() always succeeds after framenavigated
  because Puppeteer waits for the execution context automatically
  (verified via CDP event order and Puppeteer source)
- inject(): matches upstream behavior - let errors surface instead
  of silently swallowing them

* fix: use AbortController to cancel inject on page navigation

when WhatsApp Web does location.reload() during inject (e.g. after
viewer context auth), puppeteer's waitForFunction hangs for 30s on
a dead execution context. After the timeout, no recovery is possible.

fix:
- Replace _injectInProgress flag with AbortController pattern: new
  inject() calls automatically cancel any previous in-progress inject
- Pass signal to waitForFunction for immediate cancellation
- Move framenavigated handler registration before first inject() in
  initialize(), so navigation during startup triggers re-inject
- Abort inject on destroy() to prevent spurious errors

* chore: ignore *.d.ts in eslint

upstream added TypeScript declaration changes that ESLint cannot parse.

* chore: revert index.d.ts and .eslintignore changes

* fix: reset _framenavigatedRegistered flag on destroy

* fix: revert unintended setCurrentIndexHtml refactor from lint auto-fix

* fix: replace async listener with waitForResponse for index cache

the response listener used an async handler on EventEmitter. mitt
ignores returned Promises, so when res.text() rejected on CDP
disconnect the promise was orphaned - causing unhandledRejection.

replace with page.waitForResponse() which returns a proper Promise
chain. Use .catch((_) => _) following the existing convention in
this codebase (see waitForNavigation on line 386).

* Revert "fix: replace async listener with waitForResponse for index cache"

This reverts commit 8cfd915.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…1792)

Co-authored-by: Aliyss Snow <33941859+aliyss@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.