Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(deps): upgrade browser and request libraries
Yudhi Armyndharis5810f967b045
diff --git a/.github/dependabot.yml b/.github/dependabot.ymlindex ff61f004d..29921240f 100644--- a/.github/dependabot.yml+++ b/.github/dependabot.yml@@ -42,13 +42,11 @@ updates:# same three grounds.- dependency-name: "better-sqlite3"versions: [">=14.0.0"]- # puppeteer is pinned EXACTLY at whatsapp-web.js's own pin (both 24.38.0 today). The root pin- # exists to hold the whole tree on the Chromium/CDP line the engine and its specs are written- # against, and any bump the two manifests do not agree on desyncs the mirror: a 25.x proposal- # already fails lint and the unit suite on wwebjs-protocol-timeout.spec.ts. Lift when- # whatsapp-web.js moves its pin, and move the root pin in the same commit.+ # The root pin and $puppeteer override keep whatsapp-web.js on the tested 25.x line.+ # Browser teardown uses the connected getter. Recheck lifecycle, protocol errors and+ # engine smoke tests before adopting the next major.- dependency-name: "puppeteer"- versions: [">24.38.0"]+ versions: [">=26.0.0"]# audio-decode v3 collides with Baileys: every 7.0.0-rc line so far (through rc14) declares# `peerOptional audio-decode@"^2.1.3"`, so the bump fails `npm ci` with ERESOLVE before any# CI job runs. The pairing is load-bearing, not incidental — Baileys uses audio-decode todiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 745e64dde..f2974ca5e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Changed+- Upgrade Puppeteer to 25.16.0 with Zod 4, preserving whatsapp-web.js browser teardown.+- Update fast-uri to 3.1.9 and ip-address to 10.7.4.- Update dashboard validation tooling to Zod 4.6.7.- Support Guzzle 8 in the PHP SDK while retaining Guzzle 7 compatibility, from PHP SDK 0.7.0 (#1870).- Reject empty PHP SDK `defaultHeaders` lists before sending requests, from PHP SDK 0.7.0; use `''` for an empty header value (#1870).@@ -54,6 +56,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed+- Update multer to 2.5.0 and undici to 8.12.3 to prevent request teardown and response decoding failures.- Keep deleted sessions free of late message, status and bulk writes, and of the `message:failed` event of a bulk item whose session was deleted before it was sent.- Retain sending limits while hooks or preparation are pending, including across UTC midnight.- Preserve whatsapp-web.js readiness when an earlier QR render completes.@@ -186,6 +189,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Upgrade notes (behavior changes)+- Source installs using Puppeteer's downloaded browser move from Chrome 146 to 156; back up `SESSION_DATA_PATH` (default `data/sessions/`) before starting and restore it before downgrading Chrome. An explicit `PUPPETEER_EXECUTABLE_PATH` keeps selecting that browser.- ⚠️ **Breaking (config).** A production boot refuses a `METRICS_TOKEN` that is the `.env.example` placeholder or a known weak value such as `test` or `change-me`, since the scrape endpoint is public; set a long random token, or leave it unset to keep the endpoint disabled.- The HTTP port now opens after at most 60 s of plugin restore. Until a plugin still restoring is up, the hooks it owns (a send moderation veto, for one) do not run, an enable, disable, update, uninstall or reinstall of it answers `409`, an ingress route with a response contract answers `503` with `Retry-After`, and other ingress deliveries are held and dispatched once it is up (with the queue off, by the reconciler after `INGRESS_RECONCILE_GRACE_MS`); do not rely on a plugin veto for requests in the first minute after a boot with slow plugins.- An explicit `null` for a secret field of a plugin config removes the stored secret, where 0.25.0 kept it; a client that sends `null` for "not provided" must leave the key out.diff --git a/Dockerfile b/Dockerfileindex 103a06f9e..8c571adf2 100644--- a/Dockerfile+++ b/Dockerfile@@ -191,7 +191,7 @@ COPY package*.json ./# scripts/postinstall.js rides along so a bare local `npm ci` keeps working, but the# --ignore-scripts install below skips the hook here: the explicit fatal run right# after is the sole (and stricter) applier for the image.-COPY scripts/postinstall.js scripts/patch-wwebjs-201832.js scripts/wwebjs-201832.patch scripts/patch-wwebjs-newsletter-preview.js scripts/patch-wwebjs-status.js scripts/patch-wwebjs-ready-sync.js scripts/patch-wwebjs-participant-arity.js scripts/patch-wwebjs-block.js scripts/patch-wwebjs-group-description.js scripts/patch-wwebjs-media-id.js scripts/patch-wwebjs-send-error.js scripts/patch-baileys-appstate.js scripts/patch-baileys-newsletter-create.js scripts/patch-baileys-pairing.js ./scripts/+COPY scripts/postinstall.js scripts/patch-wwebjs-201832.js scripts/wwebjs-201832.patch scripts/patch-wwebjs-newsletter-preview.js scripts/patch-wwebjs-status.js scripts/patch-wwebjs-ready-sync.js scripts/patch-wwebjs-participant-arity.js scripts/patch-wwebjs-block.js scripts/patch-wwebjs-group-description.js scripts/patch-wwebjs-media-id.js scripts/patch-wwebjs-send-error.js scripts/patch-wwebjs-puppeteer.js scripts/patch-baileys-appstate.js scripts/patch-baileys-newsletter-create.js scripts/patch-baileys-pairing.js ./scripts/# Install production dependencies only, then apply the backports. The status patcher runs after# the two patchers it depends on: its transforms were written against the tree they leave behind.@@ -222,6 +222,7 @@ RUN npm ci --omit=dev --ignore-scripts \&& node scripts/patch-baileys-appstate.js \&& node scripts/patch-baileys-newsletter-create.js \&& node scripts/patch-baileys-pairing.js \+ && node scripts/patch-wwebjs-puppeteer.js \&& npm cache clean --force# Replace the npm the base image bundles. npm is not on the request path — the entrypoint runsdiff --git a/dashboard/package-lock.json b/dashboard/package-lock.jsonindex ca2ab2b1c..2e2c1dd96 100644--- a/dashboard/package-lock.json+++ b/dashboard/package-lock.json@@ -3910,9 +3910,9 @@}},"node_modules/undici": {- "version": "8.11.2",- "resolved": "https://registry.npmjs.org/undici/-/undici-8.11.2.tgz",- "integrity": "sha512-u4UB2/IrKdU6lFxumHmmo1a3fCQO5tzQllRorfoRS63txhrB7xTpSn1PftwC4qEHkOaqP95fCWW4lJzwErwzhQ==",+ "version": "8.12.3",+ "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz",+ "integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==","dev": true,"license": "MIT","engines": {diff --git a/docs/12-troubleshooting-faq.md b/docs/12-troubleshooting-faq.mdindex d2074fbe7..782f2b71e 100644--- a/docs/12-troubleshooting-faq.md+++ b/docs/12-troubleshooting-faq.md@@ -774,12 +774,12 @@ rm -rf node_modules/whatsapp-web.js && npm ciblock/unblock refusing every id, a status media send that never arrives, a group description thatcannot be set, an app-state resync that never settles-**Cause:** OpenWA applies twelve exact source transforms to its engine libraries at install time+**Cause:** OpenWA applies thirteen exact source transforms to its engine libraries at install time(docs/29 §29.3). The Docker image runs them without `--best-effort`, so a source shape a patcher-cannot recognise fails the image build. A source install runs them through `scripts/postinstall.js`-with `--best-effort`, where a patcher that cannot apply prints one line into a long `npm install`-transcript and the install still succeeds. The usual causes are `npm install --ignore-scripts` and-an upstream release whose shape a patcher no longer recognises. Each engine now checks its own+cannot recognise fails the image build. Source installs run the Puppeteer compatibility transform+without best-effort too, because browser teardown depends on it. The other transforms use+`--best-effort`, where a refusal prints one line into the install transcript and installation continues.+The usual causes are `npm install --ignore-scripts` and an upstream release whose shape a patcher no longer recognises. Each engine now checks its ownpatches as it starts and names the ones that did not land, so the report arrives on the machine thatis actually affected rather than in an install log nobody kept.diff --git a/docs/29-engine-capability-matrix.md b/docs/29-engine-capability-matrix.mdindex d44d00722..44cc9e98c 100644--- a/docs/29-engine-capability-matrix.md+++ b/docs/29-engine-capability-matrix.md@@ -5,7 +5,7 @@ Three-way comparison of every capability: the **Baileys library** (`@whiskeysockits adapter layer and REST API — including which "supported" cells only work because OpenWA patchesthe installed library. Coverage is total: all 113 `IWhatsAppEngine` methods (29.4), **all 152Baileys + 81 whatsapp-web.js library methods** (29.5), all 34 + 31 library events (29.5.4), and all-12 install-time patches (29.3). If it exists upstream or in OpenWA, it has a row here.+13 install-time patches (29.3). If it exists upstream or in OpenWA, it has a row here.## 29.1 How to read this matrix@@ -50,7 +50,7 @@ flowchart LRIF --> BA["BaileysAdapter"]SVC --> STORE["OpenWA-side stores"]end- WA --> WLIB["whatsapp-web.js 1.34.7<br/>+ 9 OpenWA patches"]+ WA --> WLIB["whatsapp-web.js 1.34.7<br/>+ 10 OpenWA patches"]BA --> BLIB["@whiskeysockets/baileys 7.0.0-rc14<br/>+ 3 OpenWA patches"]WLIB --> WEB["WhatsApp Web<br/>headless Chromium"]BLIB --> WAS["WhatsApp servers<br/>browser-free socket"]@@ -128,20 +128,19 @@ wrong interface method. Those three remain reader-verified.## 29.3 Install-time patches OpenWA applies to the libraries-OpenWA ships twelve exact, self-disabling source transforms over the installed engines. Each runs at-`npm install` (`scripts/postinstall.js`, `--best-effort`) and again in the Docker production stage-(**without** best-effort — dependency drift fails the image build). A recognized repaired source shape makes the-patcher no-op; an unrecognized source shape fails loudly rather than shipping a silently partial-patch. Retire the rc14 pairing backport once an upstream release includes both fixes.+OpenWA ships thirteen exact, self-disabling source transforms over the installed engines. Each runs at+`npm install` (`scripts/postinstall.js`) and again in the Docker production stage. A recognized repaired+source shape makes the patcher a no-op. Every image transform fails on an unknown shape. The Puppeteer+compatibility transform also fails a source install; the other transforms run with `--best-effort` there.+Retire the rc14 pairing backport once an upstream release includes both fixes.-"Fails loudly" holds for the image build, not for `npm install`, where `--best-effort` turns a-refusal into one line of a long transcript. So each patcher also exports an `isApplied()` predicate,-its own stand-down branch read back against the installed file, and each engine reports the patches+A best-effort refusal appears as one line of a long install transcript. So each patcher also exports an+`isApplied()` predicate, its own stand-down branch read back against the installed file, and each engine reports the patchesit is missing as it starts (`src/engine/adapters/engine-patch-status.ts`; 🔧¹ keeps the separatecheck described below). The report is diagnostic, not preventive: startup continues, so a sessionreaching READY is not evidence that every patch landed. See docs/12 for the operator procedure.-### 29.3.1 The twelve patches+### 29.3.1 The thirteen patches| # | Patcher | Library target | What it repairs | Stand-down predicate || ---- | ---------------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |@@ -157,10 +156,11 @@ reaching READY is not evidence that every patch landed. See docs/12 for the oper| 🔧⁹ | `scripts/patch-wwebjs-group-description.js` | whatsapp-web.js `GroupChat.js` | `GroupChat.setDescription()` calls the page's `WAWebGroupModifyInfoJob.setGroupDescription(chatWid, description, newId, descId)` positionally, but that job now takes a single options object `{desc, groupWid, newDescId, prevDescId}`. The first positional argument lands where the object is read, every field comes back undefined, and `widToGroupJid(undefined)` throws inside the page — reaching the caller as a bare `500` while the library still types the method `Promise<boolean>`. `setGroupSubject` in the same module is still positional, which is why subjects kept working and made the Wid look innocent. The patch sends the options object, takes `newDescId` from `WARandomHex.randomHex(8)` as the product does, and maps an empty description to `desc: null` so it selects the job's delete branch rather than sending an empty body element. The open upstream fix #201895 changes the same call, but keeps `WAWebMsgKey.newId()` and passes an empty description through verbatim, so this patcher will not stand down when it lands and the `desc: null` mapping has to be carried over rather than dropped with it. | exact-shape match; unknown shape fails the build. || 🔧¹⁰ | `scripts/patch-wwebjs-media-id.js` | whatsapp-web.js `Injected/Utils.js` | Every media send built by `processMediaData` failed on the WhatsApp Web builds rolled out on 2026-09-17 with `Data passed to getter must include an id property`, while text still sent. `window.WWebJS.sendMessage` builds the outgoing message with `id: newMsgKey` and then spreads the media model returned by `processMediaData` into it, and on those builds that model carries an enumerable private `__x_id` that clobbers the id when the `Msg` model initialises. The patch deletes `message.__x_id` right after the object is built, which is upstream's own fix (whatsapp-web.js PR #201923, unmerged, no release after 1.34.7). It stands down once the installed tree carries that line. | exact-shape match; unknown shape fails the build. || 🔧¹¹ | `scripts/patch-wwebjs-send-error.js` | whatsapp-web.js `Client.js` | A send the page refused reached OpenWA as the minified `t: t`, with nothing but Node frames: puppeteer rebuilds a page-side exception from its class name and description only, and WhatsApp Web's own error classes are minified to one letter and keep their detail in their own properties. The patch wraps the `window.WWebJS.sendMessage` call inside `Client.sendMessage`'s evaluate. A plain `Error`, which is what whatsapp-web.js's own send failures and WhatsApp Web's `No LID for user` already are, is rethrown as the same object, so its text and OpenWA's matching on it are unchanged. Anything else is rethrown as an `Error` reading `page threw {...}`, a capped JSON summary of the WhatsApp Web build actually running, the constructor name, `name`, `message`, `stack` and the value's own properties. Diagnostic only: a successful send returns what it returned before, and the dead-page classifier never reads a captured error as a transport death. | exact-shape match; unknown shape fails the build. |+| 🔧¹³ | `scripts/patch-wwebjs-puppeteer.js` | whatsapp-web.js `Client.js` | Use Puppeteer 25 browser connection getters so destroy closes Chromium and logout removes authentication only after closure. | Both exact replacements must match; an unknown or partial shape aborts installation. Stands down when upstream carries both changes. |### 29.3.2 Which matrix rows depend on which patch-This is the patch visibility the matrix cells refer to. Every patch is engine-specific (9 on wwjs,+This is the patch visibility the matrix cells refer to. Every patch is engine-specific (10 on wwjs,3 on Baileys), and **no row carries a row-level patch mark on both engines**. The two column-widepatches are a separate matter: 🔧¹ underwrites every wwjs cell and 🔧⁵ every baileys cell, so inthat sense every row does depend on a patch on each side. "Patch-dependent" below means a patch@@ -1060,7 +1060,7 @@ adapter sources — re-derive the same way when anything changes:cannot repopulate; and `rejectCall`, whose `Call.reject()` resolves while the caller's phonekeeps ringing (all in 29.6.2). Each answers 501 on wwjs. `.d.ts` presence is not capability, andonly a live call distinguishes the two.-- **12** install-time patches (9 whatsapp-web.js + 3 Baileys), all exact and self-disabling.+- **13** install-time patches (10 whatsapp-web.js + 3 Baileys), all exact and self-disabling.- **0 phantom-support rows** — every `not-available` cell throws at the adapter boundary.- Remaining adapter-gaps (fixable in this repo, ranked): **#1** `getChannelMessages` (Baileys —fetch is one line, `BinaryNode`→`ChannelMessage` parser is the work); **#2** `subscribeToChannel`diff --git a/package-lock.json b/package-lock.jsonindex 29f10d78a..c5b2982c9 100644--- a/package-lock.json+++ b/package-lock.json@@ -41,7 +41,7 @@"https-proxy-agent": "^9.1.0","ioredis": "^6.0.0","pg": "^8.23.1",- "puppeteer": "24.38.0",+ "puppeteer": "25.16.0","qrcode": "^1.5.4","reflect-metadata": "^0.2.2","rxjs": "^7.8.1",@@ -51,7 +51,7 @@"socks-proxy-agent": "^10.1.0","tar-stream": "3.2.0","typeorm": "^1.1.2",- "undici": "^8.11.2",+ "undici": "^8.12.3","whatsapp-web.js": "1.34.7","zod": "^4.6.7"},@@ -624,6 +624,7 @@"version": "7.29.7","resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz","integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==",+ "dev": true,"license": "MIT","dependencies": {"@babel/helper-validator-identifier": "^7.29.7",@@ -795,6 +796,7 @@"version": "7.29.7","resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz","integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",+ "dev": true,"license": "MIT","engines": {"node": ">=6.9.0"@@ -4279,12 +4281,12 @@"license": "BSD-3-Clause"},"node_modules/@puppeteer/browsers": {- "version": "3.2.1",- "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.2.1.tgz",- "integrity": "sha512-KDz+3qDRdBAlRlMjmKyj6dEs33YHTk/xRHEENSXq6TNnhgoU15ruSHtEBeVF6OZ9tBDY55Se4P0nFMNsipzU9A==",+ "version": "3.2.6",+ "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.2.6.tgz",+ "integrity": "sha512-MJP29gVoHznmqmwhH1tlZqzfeQ3aylTpSSa6WKZXtkwYUH02i9imBmWGTyZrbnAou5paX78SE4jMAUqnEPf8ug==","license": "Apache-2.0","dependencies": {- "modern-tar": "^0.8.0",+ "modern-tar": "^0.8.6","yargs": "^18.0.0"},"bin": {@@ -4307,9 +4309,9 @@}},"node_modules/@puppeteer/browsers/node_modules/ansi-regex": {- "version": "6.3.0",- "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.3.0.tgz",- "integrity": "sha512-WpDfL7NO6j7tH88IDBNVdUJxDh9nmCteAVW9dsep846XdwF4naCBK+/tGLX3KJgcpgMRXCFlTM2hKGoK9FsdrQ==",+ "version": "6.4.0",+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz",+ "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==","license": "MIT","engines": {"node": ">=12"@@ -4368,9 +4370,9 @@"license": "MIT"},"node_modules/@puppeteer/browsers/node_modules/string-width": {- "version": "8.2.2",- "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.2.2.tgz",- "integrity": "sha512-GaPUh5gfdrYzqeVNZvUfT23vYYxXzKYidUcnMtJg/3rxRV63EFZy3k6xfKlmfeJD0176lnUV/Usr3XcwSvFzpg==",+ "version": "8.3.0",+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz",+ "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==","license": "MIT","dependencies": {"get-east-asian-width": "^1.5.0",@@ -4433,9 +4435,9 @@}},"node_modules/@puppeteer/browsers/node_modules/yargs": {- "version": "18.1.0",- "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.1.0.tgz",- "integrity": "sha512-2rAgRKu54VsHkqI0/tYkmluGXHD4KW7yZoycuqDQ15QOTnc2VVfy0nN/1eMhnQLO00A+dwtK20xuCnc1YGeUyg==",+ "version": "18.2.0",+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz",+ "integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==","license": "MIT","dependencies": {"cliui": "^9.0.1",@@ -7023,6 +7025,7 @@"version": "3.1.0","resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz","integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",+ "dev": true,"license": "MIT","engines": {"node": ">=6"@@ -7119,27 +7122,21 @@}},"node_modules/chromium-bidi": {- "version": "14.0.0",- "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-14.0.0.tgz",- "integrity": "sha512-9gYlLtS6tStdRWzrtXaTMnqcM4dudNegMXJxkR0I/CXObHalYeYcAMPrL19eroNZHtJ8DQmu1E+ZNOYu/IXMXw==",+ "version": "157.0.8090-0",+ "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-157.0.8090-0.tgz",+ "integrity": "sha512-KJw7IQgqXwxpJgJlEIPg5mr2ZoqA+jkTRtc5EABI7sUJ3bu3cpI7NuEBoj4Gn1AsF78CaT9So5WQWspK3/wYag==","license": "Apache-2.0","dependencies": {"mitt": "^3.0.1",- "zod": "^3.24.1"+ "zod": "^4.6.5"+ },+ "engines": {+ "node": ">=20.19.0 <22.0.0 || >=22.12.0"},"peerDependencies": {"devtools-protocol": "*"}},- "node_modules/chromium-bidi/node_modules/zod": {- "version": "3.25.76",- "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",- "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",- "license": "MIT",- "funding": {- "url": "https://github.com/sponsors/colinhacks"- }- },"node_modules/ci-info": {"version": "4.4.0","resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.4.0.tgz",@@ -7852,9 +7849,9 @@}},"node_modules/devtools-protocol": {- "version": "0.0.1581282",- "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1581282.tgz",- "integrity": "sha512-nv7iKtNZQshSW2hKzYNr46nM/Cfh5SEvE2oV0/SEGgc9XupIY5ggf84Cz8eJIkBce7S3bmTAauFD6aysMpnqsQ==",+ "version": "0.0.1704951",+ "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1704951.tgz",+ "integrity": "sha512-GQhQOs9u/Mvm1zMtJIH872JS4AskuZdUSsPNPk4ChahtWAUqgz6atEtIsMt+nO7MqF1Ic4HxII/k8Cu36JivNg==","license": "BSD-3-Clause"},"node_modules/dezalgo": {@@ -8191,19 +8188,11 @@"node": ">=10.13.0"}},- "node_modules/env-paths": {- "version": "2.2.1",- "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",- "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==",- "license": "MIT",- "engines": {- "node": ">=6"- }- },"node_modules/error-ex": {"version": "1.3.4","resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.4.tgz","integrity": "sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==",+ "dev": true,"license": "MIT","dependencies": {"is-arrayish": "^0.2.1"@@ -8760,9 +8749,9 @@"license": "MIT"},"node_modules/fast-uri": {- "version": "3.1.8",- "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.8.tgz",- "integrity": "sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg==",+ "version": "3.1.9",+ "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz",+ "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==","funding": [{"type": "github",@@ -9484,6 +9473,7 @@"version": "3.3.1","resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz","integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==",+ "dev": true,"license": "MIT","dependencies": {"parent-module": "^1.0.0",@@ -9554,9 +9544,9 @@}},"node_modules/ip-address": {- "version": "10.7.2",- "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.2.tgz",- "integrity": "sha512-7H/2gFSIitxc0hG3nOI1glS8QLo/EHBFFLk8vEUjXY/xu0AdL8jZ9U1IzO2PUm0d2D/ofQcAifb0g6OBkt8U7w==",+ "version": "10.7.4",+ "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.4.tgz",+ "integrity": "sha512-DWBMKyeM25D70nrIiTkgQth59/G+naKOTep6huF9j+GmeK3DMD60Zvxg5d5qQnz+38AHgou6ean2LECX+lrKDg==","license": "MIT","engines": {"node": ">= 12"@@ -9575,6 +9565,7 @@"version": "0.2.1","resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz","integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==",+ "dev": true,"license": "MIT"},"node_modules/is-extglob": {@@ -10338,6 +10329,7 @@"version": "4.0.0","resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz","integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",+ "dev": true,"license": "MIT"},"node_modules/js-yaml": {@@ -10379,6 +10371,7 @@"version": "2.3.1","resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz","integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==",+ "dev": true,"license": "MIT"},"node_modules/json-schema-traverse": {@@ -10536,10 +10529,23 @@"protobufjs": "^7.5.5"}},+ "node_modules/lilconfig": {+ "version": "3.1.4",+ "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.4.tgz",+ "integrity": "sha512-zJZyBmQhArDRefuWTypZxwDpFDIYmrj8ypSBvwGD5P13Y95s6DjzKgu4DVdGbeQa5PDEsAOCAPNk4X+QOR006w==",+ "license": "MIT",+ "engines": {+ "node": ">=14"+ },+ "funding": {+ "url": "https://github.com/sponsors/antonk52"+ }+ },"node_modules/lines-and-columns": {"version": "1.2.4","resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz","integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",+ "dev": true,"license": "MIT"},"node_modules/load-esm": {@@ -10857,9 +10863,9 @@"license": "MIT"},"node_modules/modern-tar": {- "version": "0.8.4",- "resolved": "https://registry.npmjs.org/modern-tar/-/modern-tar-0.8.4.tgz",- "integrity": "sha512-gN54ddmyzEg10orwZ2u4OOv+bjpMWdIl5jIkodK97bMq8QBSL5c0D7YX0lT1Ooz+99S7+PvFbnxzdjgHo1r41g==",+ "version": "0.8.6",+ "resolved": "https://registry.npmjs.org/modern-tar/-/modern-tar-0.8.6.tgz",+ "integrity": "sha512-LYSks0tNVqbtez/9OB0YFP6qLRSqkdAxJWOQpVaR67lNTbj2zNLyYpowkRMia5lXLCZKzxwoxkxH2MbbBR2aEg==","license": "MIT","engines": {"node": ">=18.0.0"@@ -10916,9 +10922,9 @@}},"node_modules/multer": {- "version": "2.4.0",- "resolved": "https://registry.npmjs.org/multer/-/multer-2.4.0.tgz",- "integrity": "sha512-7dqa0ZcFfzbefdTuIkzOSMvZWC0J7FLqBOjJUZvDCXShIURWKxAyTT1wHhnE5q19c7jOJf43IYYKjBmZVZmvhg==",+ "version": "2.5.0",+ "resolved": "https://registry.npmjs.org/multer/-/multer-2.5.0.tgz",+ "integrity": "sha512-BsqOzYGVq49JcW2IzoSAxeKYRevb+dGGPPWleOR8Lrlk4igwxu1/9pwSXlByhCb7MVZDrNJFC0IBP5/O5nLYRw==","license": "MIT","dependencies": {"append-field": "^1.0.0",@@ -11437,6 +11443,7 @@"version": "1.0.1","resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz","integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",+ "dev": true,"license": "MIT","dependencies": {"callsites": "^3.0.0"@@ -11449,6 +11456,7 @@"version": "5.2.0","resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz","integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==",+ "dev": true,"license": "MIT","dependencies": {"@babel/code-frame": "^7.0.0",@@ -11630,6 +11638,7 @@"version": "1.1.1","resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz","integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",+ "dev": true,"license": "ISC"},"node_modules/picomatch": {@@ -12006,66 +12015,60 @@}},"node_modules/puppeteer": {- "version": "24.38.0",- "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-24.38.0.tgz",- "integrity": "sha512-abnJOBVoL9PQTLKSbYGm9mjNFyIPaTVj77J/6cS370dIQtcZMpx8wyZoAuBzR71Aoon6yvI71NEVFUsl3JU82g==",+ "version": "25.16.0",+ "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-25.16.0.tgz",+ "integrity": "sha512-LOr3reYnxAYYfQkpopz1fQnL0LdvqhpR5U2Fu+QnwzTX2gpVTHsn91UETo5NNC1md2/oC54Zu1ChBXgZDNSP1A==","hasInstallScript": true,"license": "Apache-2.0","dependencies": {- "@puppeteer/browsers": "2.13.0",- "chromium-bidi": "14.0.0",- "cosmiconfig": "^9.0.0",- "devtools-protocol": "0.0.1581282",- "puppeteer-core": "24.38.0",- "typed-query-selector": "^2.12.1"+ "@puppeteer/browsers": "3.2.6",+ "chromium-bidi": "157.0.8090-0",+ "devtools-protocol": "0.0.1704951",+ "lilconfig": "^3.1.3",+ "puppeteer-core": "25.16.0",+ "typed-query-selector": "^2.12.3"},"bin": {- "puppeteer": "lib/cjs/puppeteer/node/cli.js"+ "puppeteer": "lib/puppeteer/node/cli.js"},"engines": {- "node": ">=18"+ "node": ">=22.12.0"}},"node_modules/puppeteer-core": {- "version": "24.38.0",- "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-24.38.0.tgz",- "integrity": "sha512-zB3S/tksIhgi2gZRndUe07AudBz5SXOB7hqG0kEa9/YXWrGwlVlYm3tZtwKgfRftBzbmLQl5iwHkQQl04n/mWw==",+ "version": "25.16.0",+ "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-25.16.0.tgz",+ "integrity": "sha512-VA5Pf54N8shfopNkZZXCdiiwfnnY8ZJYAMqFQRhlH5mGUhfwf53Ar770GPtdpTDLUqvQeYpIBtC9/G2Jij2IJw==","license": "Apache-2.0","dependencies": {- "@puppeteer/browsers": "2.13.0",- "chromium-bidi": "14.0.0",- "debug": "^4.4.3",- "devtools-protocol": "0.0.1581282",- "typed-query-selector": "^2.12.1",- "webdriver-bidi-protocol": "0.4.1",- "ws": "^8.19.0"+ "@puppeteer/browsers": "3.2.6",+ "chromium-bidi": "157.0.8090-0",+ "devtools-protocol": "0.0.1704951",+ "typed-query-selector": "^2.12.3",+ "webdriver-bidi-protocol": "1.0.1",+ "ws": "^8.22.0"},"engines": {- "node": ">=18"+ "node": ">=22.12.0"}},- "node_modules/puppeteer/node_modules/cosmiconfig": {- "version": "9.0.2",- "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-9.0.2.tgz",- "integrity": "sha512-gtTZxTDau1wL7Y7zifc2dd8jHSK/k6BTx/2Xp/BpdlAdnlYWFVt7qhJqgwi7637yRwRQ3qL4ZidbB4I8tA5VOg==",+ "node_modules/puppeteer-core/node_modules/ws": {+ "version": "8.22.0",+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz",+ "integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==","license": "MIT",- "dependencies": {- "env-paths": "^2.2.1",- "import-fresh": "^3.3.0",- "js-yaml": "^4.1.0",- "parse-json": "^5.2.0"- },"engines": {- "node": ">=14"- },- "funding": {- "url": "https://github.com/sponsors/d-fischer"+ "node": ">=10.0.0"},"peerDependencies": {- "typescript": ">=4.9.5"+ "bufferutil": "^4.0.1",+ "utf-8-validate": ">=5.0.2"},"peerDependenciesMeta": {- "typescript": {+ "bufferutil": {+ "optional": true+ },+ "utf-8-validate": {"optional": true}}@@ -12421,6 +12424,7 @@"version": "4.0.0","resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz","integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",+ "dev": true,"license": "MIT","engines": {"node": ">=4"@@ -13950,9 +13954,9 @@}},"node_modules/typed-query-selector": {- "version": "2.12.2",- "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.2.tgz",- "integrity": "sha512-EOPFbyIub4ngnEdqi2yOcNeDLaX/0jcE1JoAXQDDMIthap7FoN795lc/SHfIq2d416VufXpM8z/lD+WRm2gfOQ==",+ "version": "2.12.3",+ "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.3.tgz",+ "integrity": "sha512-/dtuMZyutHLlrxWhhC1uib00ELUr2dZ8C9B8YzZYsJmeE3V56OxRblrSM2UaF142pcMtak7ehZ6+poWGeehNIg==","license": "MIT"},"node_modules/typeorm": {@@ -14295,9 +14299,9 @@}},"node_modules/undici": {- "version": "8.11.2",- "resolved": "https://registry.npmjs.org/undici/-/undici-8.11.2.tgz",- "integrity": "sha512-u4UB2/IrKdU6lFxumHmmo1a3fCQO5tzQllRorfoRS63txhrB7xTpSn1PftwC4qEHkOaqP95fCWW4lJzwErwzhQ==",+ "version": "8.12.3",+ "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz",+ "integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==","license": "MIT","engines": {"node": ">=22.19.0"@@ -14521,9 +14525,9 @@}},"node_modules/webdriver-bidi-protocol": {- "version": "0.4.1",- "resolved": "https://registry.npmjs.org/webdriver-bidi-protocol/-/webdriver-bidi-protocol-0.4.1.tgz",- "integrity": "sha512-ARrjNjtWRRs2w4Tk7nqrf2gBI0QXWuOmMCx2hU+1jUt6d00MjMxURrhxhGbrsoiZKJrhTSTzbIrc554iKI10qw==",+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/webdriver-bidi-protocol/-/webdriver-bidi-protocol-1.0.1.tgz",+ "integrity": "sha512-WXWs/aXF2a6Al1Z2/V/7Gp2oPZOAAmHjJOTmv4KCXRJ122IMj3tSSMc6a4q3K4QOmhQbse/Ahr+oTVJOU2dUiw==","license": "Apache-2.0"},"node_modules/webidl-conversions": {diff --git a/package.json b/package.jsonindex e5073a53d..a3b944135 100644--- a/package.json+++ b/package.json@@ -41,7 +41,7 @@"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"","lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix","test": "jest",- "test:scripts": "node --test scripts/proxy-addr.spec.js scripts/music-metadata.spec.js scripts/postinstall.spec.js scripts/patch-wwebjs-newsletter-preview.spec.js scripts/patch-wwebjs-status.spec.js scripts/patch-wwebjs-ready-sync.spec.js scripts/patch-wwebjs-participant-arity.spec.js scripts/patch-wwebjs-block.spec.js scripts/patch-wwebjs-group-description.spec.js scripts/patch-wwebjs-media-id.spec.js scripts/patch-wwebjs-send-error.spec.js scripts/patch-baileys-appstate.spec.js scripts/patch-baileys-newsletter-create.spec.js scripts/patch-baileys-pairing.spec.js scripts/baileys-pairing.integration.spec.mjs scripts/dockerfile-patchers.spec.js scripts/check-dockerignore.spec.mjs scripts/smoke-test-docker-proxy.spec.js scripts/check-upstream-surface.spec.mjs scripts/check-sdk-docs.spec.mjs scripts/check-audit.spec.mjs scripts/check-contract-shapes.spec.mjs scripts/check-sdk-coverage.spec.mjs scripts/cli-entrypoint-guard.spec.mjs",+ "test:scripts": "node --test scripts/proxy-addr.spec.js scripts/music-metadata.spec.js scripts/postinstall.spec.js scripts/patch-wwebjs-newsletter-preview.spec.js scripts/patch-wwebjs-status.spec.js scripts/patch-wwebjs-ready-sync.spec.js scripts/patch-wwebjs-participant-arity.spec.js scripts/patch-wwebjs-block.spec.js scripts/patch-wwebjs-group-description.spec.js scripts/patch-wwebjs-media-id.spec.js scripts/patch-wwebjs-send-error.spec.js scripts/patch-wwebjs-puppeteer.spec.js scripts/patch-baileys-appstate.spec.js scripts/patch-baileys-newsletter-create.spec.js scripts/patch-baileys-pairing.spec.js scripts/baileys-pairing.integration.spec.mjs scripts/dockerfile-patchers.spec.js scripts/check-dockerignore.spec.mjs scripts/smoke-test-docker-proxy.spec.js scripts/check-upstream-surface.spec.mjs scripts/check-sdk-docs.spec.mjs scripts/check-audit.spec.mjs scripts/check-contract-shapes.spec.mjs scripts/check-sdk-coverage.spec.mjs scripts/cli-entrypoint-guard.spec.mjs","test:docs": "jest src/common/changelog-sections.spec.ts src/common/ci-privilege-gate.spec.ts src/common/docs-ci-jobs.spec.ts src/common/docs-coverage-policy.spec.ts src/common/docs-metrics-list.spec.ts src/common/docs-next-version.spec.ts src/common/docs-sdk-rate-limit.spec.ts src/common/openapi/docs-06-contract.spec.ts src/common/test-lane-partition.spec.ts src/config/docs-env-example.spec.ts src/config/openapi-contract.spec.ts src/config/openapi-export-pins.spec.ts src/config/wa-web-version-example-pin.spec.ts src/engine/docs-29-counts.spec.ts src/engine/docs-27-backfill-engine.spec.ts src/engine/engine-inventory-parity.spec.ts src/engine/engine-parity.spec.ts src/engine/inventory-mapping-direction.spec.ts src/engine/adapters/baileys-voice-waveform.spec.ts src/engine/adapters/wwebjs-newsletter-preview.spec.ts src/modules/audit/audit-coverage.spec.ts src/modules/auth/global-route-fence-coverage.spec.ts src/modules/auth/query-session-scope-coverage.spec.ts src/modules/docker/compose-network.spec.ts src/modules/queue/bull-board-mount-coverage.spec.ts src/common/release-gate-parity.spec.ts src/database/migrations/__tests__/migration-drift.spec.ts src/common/docs-governance.spec.ts --testPathIgnorePatterns=/node_modules/","test:watch": "jest --watch","test:cov": "jest --coverage",@@ -99,7 +99,7 @@"https-proxy-agent": "^9.1.0","ioredis": "^6.0.0","pg": "^8.23.1",- "puppeteer": "24.38.0",+ "puppeteer": "25.16.0","qrcode": "^1.5.4","reflect-metadata": "^0.2.2","rxjs": "^7.8.1",@@ -109,7 +109,7 @@"socks-proxy-agent": "^10.1.0","tar-stream": "3.2.0","typeorm": "^1.1.2",- "undici": "^8.11.2",+ "undici": "^8.12.3","whatsapp-web.js": "1.34.7","zod": "^4.6.7"},@@ -504,7 +504,6 @@]},"overrides": {- "@puppeteer/browsers": "3.2.1","shell-quote": "^1.11.0","minimatch@3": {"brace-expansion": "^1.1.21"@@ -521,11 +520,12 @@"ip-address": "^10.7.1","js-yaml": "^5.4.1","fast-uri": "^3.1.8",- "multer": "2.4.0",+ "multer": "2.5.0","better-sqlite3": "$better-sqlite3","socket.io": "$socket.io","typeorm": {"ioredis": "$ioredis"- }+ },+ "puppeteer": "$puppeteer"}}diff --git a/scripts/patch-wwebjs-puppeteer.js b/scripts/patch-wwebjs-puppeteer.jsnew file mode 100644index 000000000..a8e6221c3--- /dev/null+++ b/scripts/patch-wwebjs-puppeteer.js@@ -0,0 +1,51 @@+/** Puppeteer 25 removed isConnected(), which whatsapp-web.js 1.34.7 still calls during teardown. */+'use strict';++const fs = require('fs');+const path = require('path');++const DEFAULT_WWJS = path.join(__dirname, '..', 'node_modules', 'whatsapp-web.js');+const REPLACEMENTS = [+ ['const isConnected = browser?.isConnected?.();', 'const isConnected = browser?.connected;'],+ ['while (this.pupBrowser.isConnected() && maxDelay < 10)', 'while (this.pupBrowser.connected && maxDelay < 10)'],+];++function occurrences(source, needle) {+ return source.split(needle).length - 1;+}++function isPatched(source) {+ return REPLACEMENTS.every(([before, after]) => occurrences(source, before) === 0 && occurrences(source, after) === 1);+}++function applyPatch(wwjsDir = DEFAULT_WWJS) {+ const file = path.join(wwjsDir, 'src', 'Client.js');+ let source = fs.readFileSync(file, 'utf8');+ if (isPatched(source)) return { skipped: true };+ if (!REPLACEMENTS.every(([before, after]) => occurrences(source, before) === 1 && occurrences(source, after) === 0)) {+ throw new Error('unsupported Client.js shape; recheck Puppeteer browser teardown compatibility');+ }+ for (const [before, after] of REPLACEMENTS) source = source.replace(before, after);+ fs.writeFileSync(file, source);+ return { skipped: false };+}++function isApplied(wwjsDir = DEFAULT_WWJS) {+ try {+ return isPatched(fs.readFileSync(path.join(wwjsDir, 'src', 'Client.js'), 'utf8'));+ } catch {+ return true;+ }+}++if (require.main === module) {+ try {+ const { skipped } = applyPatch();+ console.log(`patch-wwebjs-puppeteer: ${skipped ? 'already applied' : 'browser teardown updated'}`);+ } catch (error) {+ console.error(`patch-wwebjs-puppeteer: ${error.message}`);+ process.exitCode = 1;+ }+}++module.exports = { applyPatch, isApplied, REPLACEMENTS };diff --git a/scripts/patch-wwebjs-puppeteer.spec.js b/scripts/patch-wwebjs-puppeteer.spec.jsnew file mode 100644index 000000000..df30c10b9--- /dev/null+++ b/scripts/patch-wwebjs-puppeteer.spec.js@@ -0,0 +1,82 @@+'use strict';++const test = require('node:test');+const assert = require('node:assert/strict');+const { Client } = require('whatsapp-web.js');+const fs = require('node:fs');+const os = require('node:os');+const path = require('node:path');+const { applyPatch, isApplied, REPLACEMENTS } = require('./patch-wwebjs-puppeteer.js');++function fixture(t, source) {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'openwa-puppeteer-'));+ t.after(() => fs.rmSync(root, { recursive: true, force: true }));+ fs.mkdirSync(path.join(root, 'src'));+ const file = path.join(root, 'src', 'Client.js');+ fs.writeFileSync(file, source);+ return { root, file };+}++test('updates both browser checks atomically and is idempotent', t => {+ const before = REPLACEMENTS.map(([old]) => old).join('\n');+ const after = REPLACEMENTS.map(([, fixed]) => fixed).join('\n');+ const { root, file } = fixture(t, before);+ assert.equal(isApplied(root), false);+ assert.deepEqual(applyPatch(root), { skipped: false });+ assert.equal(fs.readFileSync(file, 'utf8'), after);+ assert.equal(isApplied(root), true);+ assert.deepEqual(applyPatch(root), { skipped: true });+ assert.equal(fs.readFileSync(file, 'utf8'), after);+});++for (const source of [+ 'unknown source',+ REPLACEMENTS.map(([old]) => old)+ .join('\n')+ .repeat(2),+ REPLACEMENTS[0][0] + '\n' + REPLACEMENTS[1][1],+]) {+ test(`rejects unsupported or partial browser checks: ${source.split('\n')[0]}`, t => {+ const { root, file } = fixture(t, source);+ assert.throws(() => applyPatch(root), /unsupported Client.js shape/);+ assert.equal(fs.readFileSync(file, 'utf8'), source);+ assert.equal(isApplied(root), false);+ });+}++test('destroy closes a connected Puppeteer browser before destroying authentication', async () => {+ const calls = [];+ const client = {+ pupBrowser: { connected: true, close: async () => calls.push('close') },+ authStrategy: { destroy: async () => calls.push('destroy') },+ };+ await Client.prototype.destroy.call(client);+ assert.deepEqual(calls, ['close', 'destroy']);+});++test('destroy still releases authentication when the browser is already disconnected', async () => {+ const calls = [];+ const client = {+ pupBrowser: { connected: false, close: async () => calls.push('close') },+ authStrategy: { destroy: async () => calls.push('destroy') },+ };+ await Client.prototype.destroy.call(client);+ assert.deepEqual(calls, ['destroy']);+});++test('logout waits for browser closure before removing authentication', async () => {+ const calls = [];+ const client = {+ pupPage: { evaluate: async () => calls.push('page logout') },+ pupBrowser: {+ connected: true,+ async close() {+ calls.push('close');+ this.connected = false;+ },+ },+ authStrategy: { logout: async () => calls.push('auth logout') },+ };+ await Client.prototype.logout.call(client);+ assert.deepEqual(calls, ['page logout', 'close', 'auth logout']);+});diff --git a/scripts/postinstall.js b/scripts/postinstall.jsindex ca11e31f5..4ef0d0e06 100644--- a/scripts/postinstall.js+++ b/scripts/postinstall.js@@ -1,7 +1,7 @@/*** Post-install hook (npm `postinstall`).*- * Thirteen conditional steps, each skipped when its target is absent so the hook is a no-op where the+ * Fourteen conditional steps, each skipped when its target is absent so the hook is a no-op where the* piece is missing (the Docker builder stage copies package*.json long before any source):** 1. `npm ci` inside dashboard/ when dashboard/ exists — the dashboard carries its own lockfile and@@ -40,6 +40,8 @@** 13. `node scripts/patch-baileys-pairing.js --best-effort` when present, preserving pre-login* notification ACKs and refreshing pairing credentials. A partial patch remains fatal.+ * 14. `node scripts/patch-wwebjs-puppeteer.js` when present. Browser teardown must use the+ * connected getter required by Puppeteer 25; an unknown source shape aborts the install.** Structured like scripts/patch-wwebjs-201832.js: pure planning + injectable spawn, so the spec* (scripts/postinstall.spec.js, node:test) exercises every branch without a real npm run.@@ -193,6 +195,15 @@ function planSteps(root, env = process.env) {options: { stdio: 'inherit', cwd: root, env: cleanEnv },});}+ const puppeteerPatcher = path.join(root, 'scripts', 'patch-wwebjs-puppeteer.js');+ if (fs.existsSync(puppeteerPatcher)) {+ steps.push({+ name: 'whatsapp-web.js Puppeteer compatibility (scripts/patch-wwebjs-puppeteer.js)',+ command: process.execPath,+ args: [puppeteerPatcher],+ options: { stdio: 'inherit', cwd: root, env: cleanEnv },+ });+ }return steps;}diff --git a/scripts/postinstall.spec.js b/scripts/postinstall.spec.jsindex e9639006a..54942fc7b 100644--- a/scripts/postinstall.spec.js+++ b/scripts/postinstall.spec.js@@ -37,6 +37,7 @@ const EXPECTED_PATCHER_ORDER = ['patch-baileys-appstate.js','patch-baileys-newsletter-create.js','patch-baileys-pairing.js',+ 'patch-wwebjs-puppeteer.js',];/** Bare temp dir optionally holding a dashboard/ and/or the patch scripts. */@@ -185,7 +186,10 @@ test('planSteps: dashboard and all patchers run in stable order', () => {);for (const step of steps.slice(1)) {assert.equal(step.command, process.execPath);- assert.deepEqual(step.args.slice(1), ['--best-effort']);+ assert.deepEqual(+ step.args.slice(1),+ path.basename(step.args[0]) === 'patch-wwebjs-puppeteer.js' ? [] : ['--best-effort'],+ );}});diff --git a/scripts/smoke-test-engine-libs.sh b/scripts/smoke-test-engine-libs.shindex 4ec97d741..0579d8cf0 100755--- a/scripts/smoke-test-engine-libs.sh+++ b/scripts/smoke-test-engine-libs.sh@@ -51,7 +51,7 @@ else# The same launch options the engine uses by default (configuration.ts): the image's# PUPPETEER_EXECUTABLE_PATH and the default PUPPETEER_ARGS.docker run --rm "$@" "$IMAGE" node -e "- require('whatsapp-web.js');+ const { Client } = require('whatsapp-web.js');require('puppeteer').launch({executablePath: process.env.PUPPETEER_EXECUTABLE_PATH,@@ -60,7 +60,9 @@ else}).then(async browser => {console.log('PASS: browser launched: ' + (await browser.version()));- await browser.close();+ await Client.prototype.destroy.call({ pupBrowser: browser, authStrategy: { destroy: async () => {} } });+ if (browser.connected) throw new Error('whatsapp-web.js destroy left the browser connected');+ console.log('PASS: whatsapp-web.js destroy closed the browser');}).catch(error => { console.error('FAIL:', error); process.exit(1); });"diff --git a/src/engine/adapters/wwebjs-client-teardown.spec.ts b/src/engine/adapters/wwebjs-client-teardown.spec.tsindex 66c3b0607..c08f0489f 100644--- a/src/engine/adapters/wwebjs-client-teardown.spec.ts+++ b/src/engine/adapters/wwebjs-client-teardown.spec.ts@@ -410,7 +410,7 @@ describe('whatsapp-web.js operations that race a session teardown', () => {const destination = { fetchMessages: () => Promise.reject(new Error(message)) };const { adapter } = readyAdapter({pupPage: { isClosed: () => false },- pupBrowser: { isConnected: () => true },+ pupBrowser: { connected: true },getNumberId: () => Promise.resolve(found(CHAT)),getChatById: (id: string) => Promise.resolve(id === '[email protected]' ? source : destination),});@@ -436,7 +436,7 @@ describe('whatsapp-web.js operations that race a session teardown', () => {let closed = false;const { adapter } = readyAdapter({pupPage: { isClosed: () => closed },- pupBrowser: { isConnected: () => true },+ pupBrowser: { connected: true },getNumberId: () => Promise.resolve(found(CHAT)),getChatById: (id: string) => Promise.resolve(id === '[email protected]' ? source : destination),});@@ -556,7 +556,7 @@ const DEATH_CASES: DeathCase[] = [return {client: {pupPage: { isClosed: () => false },- pupBrowser: { isConnected: () => false },+ pupBrowser: { connected: false },getNumberId: () => Promise.resolve(found(CHAT)),getChatById: (id: string) => Promise.resolve(id === '[email protected]' ? source : destination),},diff --git a/src/engine/adapters/wwebjs-lifecycle.ts b/src/engine/adapters/wwebjs-lifecycle.tsindex c4f0756a8..41fde90a7 100644--- a/src/engine/adapters/wwebjs-lifecycle.ts+++ b/src/engine/adapters/wwebjs-lifecycle.ts@@ -909,10 +909,10 @@ export class WwebjsLifecycle {/** Whether puppeteer itself reports the page closed or the browser disconnected (not an error's text). */private isPageGone(): boolean {const { pupBrowser, pupPage } = (this.client ?? {}) as unknown as {- pupBrowser?: { isConnected?: () => boolean };+ pupBrowser?: { connected?: boolean };pupPage?: { isClosed?: () => boolean };};- return pupPage?.isClosed?.() === true || pupBrowser?.isConnected?.() === false;+ return pupPage?.isClosed?.() === true || pupBrowser?.connected === false;}markReadyFromClientInfo(): void {diff --git a/src/engine/adapters/wwebjs-protocol-timeout.spec.ts b/src/engine/adapters/wwebjs-protocol-timeout.spec.tsindex bdece6a25..90692f873 100644--- a/src/engine/adapters/wwebjs-protocol-timeout.spec.ts+++ b/src/engine/adapters/wwebjs-protocol-timeout.spec.ts@@ -1,5 +1,7 @@import { BadRequestException } from '@nestjs/common';-import { Callback } from 'puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js';+import { execFile } from 'node:child_process';+import { join } from 'node:path';+import { promisify } from 'node:util';import { Client } from 'whatsapp-web.js';import configuration, { MAX_TIMER_MS } from '../../config/configuration';import { validateEnv } from '../../config/env.validation';@@ -25,13 +27,20 @@ import { LabelNotFoundError } from '../../common/errors/label-not-found.error';* method name, with no `Protocol error (...)` prefix for the death pattern to match.*/const puppeteerProtocolTimeoutMessage = async (): Promise<string> => {- const callback = new Callback(1, 'Runtime.callFunctionOn', 1);- try {- await callback.promise;- } catch (error) {- return error instanceof Error ? error.message : String(error);- }- throw new Error('puppeteer-core did not reject on an expired protocolTimeout');+ // Load the ESM dependency in Node, outside Jest's CommonJS module loader.+ const { stdout } = await promisify(execFile)(+ process.execPath,+ [+ '--input-type=module',+ '-e',+ `import { Callback } from 'puppeteer-core/internal/common/CallbackRegistry.js';+ const callback = new Callback(1, 'Runtime.callFunctionOn', 1);+ try { await callback.promise; throw new Error('protocolTimeout did not expire'); }+ catch (error) { console.log(error.message); }`,+ ],+ { cwd: join(__dirname, '../../..'), encoding: 'utf8', timeout: 10_000 },+ );+ return stdout.trim();};/**diff --git a/src/modules/docker/compose-parity.spec.ts b/src/modules/docker/compose-parity.spec.tsindex 4586fe83f..55d6d52bd 100644--- a/src/modules/docker/compose-parity.spec.ts+++ b/src/modules/docker/compose-parity.spec.ts@@ -415,11 +415,8 @@ describe('DockerService managed specs ↔ docker-compose.yml parity', () => {...readFileSync(join(__dirname, '../../../Dockerfile'), 'utf8').matchAll(/^ENV (PUPPETEER_\w+)=/gm),].map(match => match[1]);expect(names.length).toBeGreaterThan(0);- // A file path, not require.resolve: jest maps `puppeteer` to a mock.- const config = readFileSync(- join(__dirname, '../../../node_modules/puppeteer/lib/cjs/puppeteer/getConfiguration.js'),- 'utf8',- );+ // Resolve the exported internal path without loading Puppeteer's ESM entry point.+ const config = readFileSync(require.resolve('puppeteer/internal/getConfiguration.js'), 'utf8');expect(names.filter(name => !config.includes(`'${name}'`))).toEqual([]);});