@wppconnect-team/wppconnect 2.3.5 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +87 -69
  3. package/README.pt-BR.md +119 -0
  4. package/dist/api/helpers/decrypt.js +8 -19
  5. package/dist/api/helpers/download-file.d.ts +4 -0
  6. package/dist/api/helpers/download-file.js +12 -0
  7. package/dist/api/helpers/file-to-base64.d.ts +6 -0
  8. package/dist/api/helpers/file-to-base64.js +27 -10
  9. package/dist/api/layers/catalog.layer.d.ts +3 -3
  10. package/dist/api/layers/catalog.layer.js +2 -2
  11. package/dist/api/layers/group.layer.js +3 -5
  12. package/dist/api/layers/host.layer.d.ts +10 -3
  13. package/dist/api/layers/host.layer.js +56 -25
  14. package/dist/api/layers/labels.layer.d.ts +34 -12
  15. package/dist/api/layers/labels.layer.js +36 -18
  16. package/dist/api/layers/profile.layer.d.ts +1 -1
  17. package/dist/api/layers/profile.layer.js +1 -3
  18. package/dist/api/layers/sender.layer.d.ts +4 -6
  19. package/dist/api/layers/sender.layer.js +6 -7
  20. package/dist/api/layers/status.layer.d.ts +13 -4
  21. package/dist/api/layers/status.layer.js +10 -9
  22. package/dist/api/model/index.d.ts +1 -0
  23. package/dist/api/model/index.js +1 -0
  24. package/dist/api/model/label.d.ts +16 -0
  25. package/dist/api/whatsapp.d.ts +24 -0
  26. package/dist/api/whatsapp.js +101 -52
  27. package/dist/config/create-config.d.ts +13 -1
  28. package/dist/config/create-config.js +2 -2
  29. package/dist/config/puppeteer.config.d.ts +12 -0
  30. package/dist/config/puppeteer.config.js +17 -7
  31. package/dist/controllers/auth.js +3 -1
  32. package/dist/controllers/browser.d.ts +27 -0
  33. package/dist/controllers/browser.js +128 -7
  34. package/dist/controllers/initializer.js +78 -44
  35. package/dist/lib/wapi/wapi.js +1 -1
  36. package/documentation/readme-reference.md +118 -0
  37. package/package.json +19 -19
  38. package/scripts/docs-redirects.mjs +70 -0
  39. package/scripts/typedoc-canonical.mjs +49 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,75 @@
1
+ ## 2.4.0 (2026-11-13)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **browser:** poll readiness in hidden pages ([712e504](https://github.com/wppconnect-team/wppconnect/commit/712e504))
6
+ - **browser:** respect ownership during automatic cleanup ([c774248](https://github.com/wppconnect-team/wppconnect/commit/c774248))
7
+ - bump wa-js version to 4.8.0 (#2964) ([7e0dace](https://github.com/wppconnect-team/wppconnect/commit/7e0dace)), closes [#2964](https://github.com/wppconnect-team/wppconnect/issues/2964)
8
+ - **labels:** await promises, fix method signatures and export label models (#2951) ([94937ce](https://github.com/wppconnect-team/wppconnect/commit/94937ce)), closes [#2951](https://github.com/wppconnect-team/wppconnect/issues/2951)
9
+ - normalize forwarding input and run the complete test suite ([b28c1d6](https://github.com/wppconnect-team/wppconnect/commit/b28c1d6))
10
+ - **wapi:** remove unbounded new messages buffer ([9532a1a](https://github.com/wppconnect-team/wppconnect/commit/9532a1a))
11
+ - **wapi:** serialize existing message models without extra copies ([7992ab3](https://github.com/wppconnect-team/wppconnect/commit/7992ab3))
12
+
13
+ ### Documentation
14
+
15
+ - adopt official WPPConnect branding and API favicon (#2946) ([4d8dda6](https://github.com/wppconnect-team/wppconnect/commit/4d8dda6)), closes [#2946](https://github.com/wppconnect-team/wppconnect/issues/2946)
16
+ - publish canonical SDK URLs and preserve renamed references (#2959) ([7ab758a](https://github.com/wppconnect-team/wppconnect/commit/7ab758a)), closes [#2959](https://github.com/wppconnect-team/wppconnect/issues/2959)
17
+ - refresh API reference visual design (#2950) ([fd0f11b](https://github.com/wppconnect-team/wppconnect/commit/fd0f11b)), closes [#2950](https://github.com/wppconnect-team/wppconnect/issues/2950)
18
+ - standardize bilingual READMEs and support guidance ([672e8cc](https://github.com/wppconnect-team/wppconnect/commit/672e8cc))
19
+ - update official WPPConnect logo and API favicon (#2949) ([17f73ca](https://github.com/wppconnect-team/wppconnect/commit/17f73ca)), closes [#2949](https://github.com/wppconnect-team/wppconnect/issues/2949)
20
+
21
+ ### Build System
22
+
23
+ - **deps-dev:** bump fast-uri from 3.1.7 to 3.1.9 ([94f5b44](https://github.com/wppconnect-team/wppconnect/commit/94f5b44))
24
+ - **deps-dev:** update babel monorepo to ^7.29.13 (#2955) ([77c3fb2](https://github.com/wppconnect-team/wppconnect/commit/77c3fb2)), closes [#2955](https://github.com/wppconnect-team/wppconnect/issues/2955)
25
+ - **deps-dev:** update dependency concurrently to ^10.0.7 (#2957) ([a43806e](https://github.com/wppconnect-team/wppconnect/commit/a43806e)), closes [#2957](https://github.com/wppconnect-team/wppconnect/issues/2957)
26
+ - **deps-dev:** update dependency eslint to v10.14.0 (#2953) ([bfe7d57](https://github.com/wppconnect-team/wppconnect/commit/bfe7d57)), closes [#2953](https://github.com/wppconnect-team/wppconnect/issues/2953)
27
+ - **deps-dev:** update dependency globals to ^17.14.0 (#2954) ([1c34452](https://github.com/wppconnect-team/wppconnect/commit/1c34452)), closes [#2954](https://github.com/wppconnect-team/wppconnect/issues/2954)
28
+ - **deps-dev:** update dependency release-it to ^21.1.2 (#2952) ([df15904](https://github.com/wppconnect-team/wppconnect/commit/df15904)), closes [#2952](https://github.com/wppconnect-team/wppconnect/issues/2952)
29
+ - **deps-dev:** update dependency typescript-eslint to ^8.72.1 (#2943) ([b912ee1](https://github.com/wppconnect-team/wppconnect/commit/b912ee1)), closes [#2943](https://github.com/wppconnect-team/wppconnect/issues/2943)
30
+ - **deps-dev:** update dependency typescript-eslint to ^8.72.2 (#2960) ([775e5ee](https://github.com/wppconnect-team/wppconnect/commit/775e5ee)), closes [#2960](https://github.com/wppconnect-team/wppconnect/issues/2960)
31
+ - **deps-dev:** update dependency webpack to ^5.112.2 (#2942) ([8bf6381](https://github.com/wppconnect-team/wppconnect/commit/8bf6381)), closes [#2942](https://github.com/wppconnect-team/wppconnect/issues/2942)
32
+ - **deps:** bump follow-redirects from 1.16.1 to 1.16.2 (#2947) ([7bff268](https://github.com/wppconnect-team/wppconnect/commit/7bff268)), closes [#2947](https://github.com/wppconnect-team/wppconnect/issues/2947)
33
+ - **deps:** bump undici and release-it (#2948) ([7db9899](https://github.com/wppconnect-team/wppconnect/commit/7db9899)), closes [#2948](https://github.com/wppconnect-team/wppconnect/issues/2948)
34
+ - **deps:** bump zod, puppeteer and puppeteer-core (#2939) ([349fcdc](https://github.com/wppconnect-team/wppconnect/commit/349fcdc)), closes [#2939](https://github.com/wppconnect-team/wppconnect/issues/2939)
35
+ - **deps:** update dependency axios to ^1.21.0 (#2944) ([d8576d2](https://github.com/wppconnect-team/wppconnect/commit/d8576d2)), closes [#2944](https://github.com/wppconnect-team/wppconnect/issues/2944)
36
+ - **deps:** update dependency node to v24.22.2 (#2945) ([8d2ad2b](https://github.com/wppconnect-team/wppconnect/commit/8d2ad2b)), closes [#2945](https://github.com/wppconnect-team/wppconnect/issues/2945)
37
+ - **deps:** update dependency serialize-javascript to v7.1.4 (#2940) ([1b44483](https://github.com/wppconnect-team/wppconnect/commit/1b44483)), closes [#2940](https://github.com/wppconnect-team/wppconnect/issues/2940)
38
+
39
+ ## <small>2.3.6 (2026-10-23)</small>
40
+
41
+ ### Bug Fixes
42
+
43
+ - **auth:** keep unpaired QR sessions out of chat readiness ([8f46042](https://github.com/wppconnect-team/wppconnect/commit/8f46042))
44
+ - **auth:** mark restored sessions as logged before waiting for chat ([366e3c0](https://github.com/wppconnect-team/wppconnect/commit/366e3c0))
45
+ - **auth:** only report disconnectedMobile after a real unpair ([111633b](https://github.com/wppconnect-team/wppconnect/commit/111633b))
46
+ - **browser:** apply default launch args and opt-in protection bypasses ([c2e0c06](https://github.com/wppconnect-team/wppconnect/commit/c2e0c06))
47
+ - **browser:** auto-close when only blank or closed tabs remain ([c165218](https://github.com/wppconnect-team/wppconnect/commit/c165218))
48
+ - **browser:** release the browser process tree on close and failed create ([b1407bf](https://github.com/wppconnect-team/wppconnect/commit/b1407bf))
49
+ - **deps:** require wa-js 4.7.2 for unread actions ([6b2a41b](https://github.com/wppconnect-team/wppconnect/commit/6b2a41b))
50
+ - **host:** guard exposeFunction against reused pages ([a778f5a](https://github.com/wppconnect-team/wppconnect/commit/a778f5a))
51
+ - **media:** bound resource use in file and download helpers ([5f5d9de](https://github.com/wppconnect-team/wppconnect/commit/5f5d9de))
52
+
53
+ ### Performance Improvements
54
+
55
+ - **decrypt:** decode media buffers directly instead of per-byte loops ([b03a29d](https://github.com/wppconnect-team/wppconnect/commit/b03a29d))
56
+ - **group:** fetch group member contacts in a single page call ([a41709e](https://github.com/wppconnect-team/wppconnect/commit/a41709e))
57
+ - **polling:** remove idle polling from live sessions ([de07dab](https://github.com/wppconnect-team/wppconnect/commit/de07dab))
58
+
59
+ ### Build System
60
+
61
+ - **deps-dev:** bump markdown-it from 14.3.2 to 14.3.3 ([7698abf](https://github.com/wppconnect-team/wppconnect/commit/7698abf))
62
+ - **deps-dev:** update commitlint monorepo to ^21.2.4 (#2932) ([b03defc](https://github.com/wppconnect-team/wppconnect/commit/b03defc)), closes [#2932](https://github.com/wppconnect-team/wppconnect/issues/2932)
63
+ - **deps-dev:** update dependency eslint to v10.13.0 (#2928) ([fd42ca9](https://github.com/wppconnect-team/wppconnect/commit/fd42ca9)), closes [#2928](https://github.com/wppconnect-team/wppconnect/issues/2928)
64
+ - **deps-dev:** update dependency eslint-plugin-prettier to ^5.5.7 (#2927) ([cdb3572](https://github.com/wppconnect-team/wppconnect/commit/cdb3572)), closes [#2927](https://github.com/wppconnect-team/wppconnect/issues/2927)
65
+ - **deps-dev:** update dependency typescript-eslint to ^8.72.0 (#2935) ([bb16ae6](https://github.com/wppconnect-team/wppconnect/commit/bb16ae6)), closes [#2935](https://github.com/wppconnect-team/wppconnect/issues/2935)
66
+ - **deps:** bump follow-redirects from 1.16.0 to 1.16.1 ([385ed97](https://github.com/wppconnect-team/wppconnect/commit/385ed97))
67
+ - **deps:** bump ip-address from 10.7.2 to 10.7.4 ([8a54f25](https://github.com/wppconnect-team/wppconnect/commit/8a54f25))
68
+
69
+ ### Chores
70
+
71
+ - **ci:** associate schedule with joaosouz4dev ([488d952](https://github.com/wppconnect-team/wppconnect/commit/488d952))
72
+
1
73
  ## <small>2.3.5 (2026-10-15)</small>
2
74
 
3
75
  ### Bug Fixes
package/README.md CHANGED
@@ -1,101 +1,119 @@
1
- # WPPConnect 📞
1
+ **English** | [Português (Brasil)](./README.pt-BR.md)
2
2
 
3
- ![WPPConnect Banner](./img/wppconnect-banner.jpeg)
3
+ <p align="center">
4
+ <a href="https://wppconnect.io/">
5
+ <picture>
6
+ <source media="(prefers-color-scheme: dark)" srcset="https://wppconnect-team.github.io/brand/v2/wppconnect-dark.png" />
7
+ <img src="https://wppconnect-team.github.io/brand/v2/wppconnect-light.png" alt="WPPConnect" width="220" height="121" />
8
+ </picture>
9
+ </a>
10
+ </p>
4
11
 
5
- [![npm version](https://img.shields.io/npm/v/@wppconnect-team/wppconnect.svg?color=green)](https://www.npmjs.com/package/@wppconnect-team/wppconnect)
6
- [![Downloads](https://img.shields.io/npm/dm/@wppconnect-team/wppconnect.svg)](https://www.npmjs.com/package/@wppconnect-team/wppconnect)
7
- [![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/wppconnect-team/wppconnect.svg)](https://isitmaintained.com/project/wppconnect-team/wppconnect 'Average time to resolve an issue')
8
- [![Percentage of issues still open](https://isitmaintained.com/badge/open/wppconnect-team/wppconnect.svg)](https://isitmaintained.com/project/wppconnect-team/wppconnect 'Percentage of issues still open')
9
- [![Build Status](https://img.shields.io/github/actions/workflow/status/wppconnect-team/wppconnect/build.yml?branch=master)](https://github.com/wppconnect-team/wppconnect/actions)
10
- [![Lint Status](https://img.shields.io/github/actions/workflow/status/wppconnect-team/wppconnect/lint.yml?branch=master&label=lint)](https://github.com/wppconnect-team/wppconnect/actions)
11
- [![release-it](https://img.shields.io/badge/%F0%9F%93%A6%F0%9F%9A%80-release--it-e10079.svg)](https://github.com/release-it/release-it)
12
+ # WPPConnect
12
13
 
13
- > WPPConnect is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination... 😀🤔💭
14
+ Control WhatsApp Web from Node.js applications.
14
15
 
15
- <p align="center">
16
- <a target="_blank" href="https://wppconnect.io/docs/tutorial/basics/installation">Getting Started</a> •
17
- <a target="_blank" href="https://wppconnect.io/docs/tutorial/basics/basic-functions">Basic Function</a> •
18
- <a target="_blank" href="https://wppconnect.io/wppconnect">Documentation</a>
19
- </p>
16
+ A project in the WPPConnect ecosystem, maintained by WPPConnect Team.
20
17
 
21
- ## Our online channels
18
+ [Getting started](#getting-started) | [Documentation](#documentation) | [Contributing](#contributing) | [Support WPPConnect](#support-the-project)
22
19
 
23
- [![Discord](https://img.shields.io/discord/844351092758413353?color=blueviolet&label=Discord&logo=discord&style=flat)](https://discord.gg/JU5JGGKGNG)
24
- [![Telegram Group](https://img.shields.io/badge/Telegram-Group-32AFED?logo=telegram)](https://t.me/wppconnect)
25
- [![WhatsApp Group](https://img.shields.io/badge/WhatsApp-Group-25D366?logo=whatsapp)](https://chat.whatsapp.com/LJaQu6ZyNvnBPNAVRbX00K)
26
- [![YouTube](https://img.shields.io/youtube/channel/subscribers/UCD7J9LG08PmGQrF5IS7Yv9A?label=YouTube)](https://www.youtube.com/c/wppconnect)
20
+ [![License: LGPL-3.0-or-later](https://img.shields.io/badge/license-LGPL--3.0--or--later-blue)](./LICENSE.md) [![npm version](https://img.shields.io/npm/v/@wppconnect-team/wppconnect)](https://www.npmjs.com/package/@wppconnect-team/wppconnect) [![CI](https://github.com/wppconnect-team/wppconnect/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/wppconnect-team/wppconnect/actions/workflows/build.yml) [![Open Collective](https://img.shields.io/badge/Open%20Collective-WPPConnect-blue)](https://opencollective.com/wppconnect)
27
21
 
28
- ## Functions
22
+ ## Overview
29
23
 
30
- | | |
31
- | ---------------------------------------------------------- | --- |
32
- | Automatic QR Refresh | ✔ |
33
- | Send **text, image, video, audio and docs** | ✔ |
34
- | Get **contacts, chats, groups, group members, Block List** | ✔ |
35
- | Send contacts | ✔ |
36
- | Send stickers | ✔ |
37
- | Send stickers GIF | ✔ |
38
- | Multiple Sessions | ✔ |
39
- | Forward Messages | ✔ |
40
- | Receive message | ✔ |
41
- | insert user section | ✔ |
42
- | Send _location_ | ✔ |
43
- | **and much more** | ✔ |
24
+ For developers building bots and integrations who want to manage the browser and session lifecycle in their own application. WPPConnect combines Puppeteer with the browser automation layer used by the ecosystem.
44
25
 
45
- See more at <a target="_blank" href="https://wppconnect.io/wppconnect/classes/Whatsapp.html">WhatsApp methods</a>
26
+ ## Features
46
27
 
47
- ## Installation
28
+ - Send and receive text, images, video, audio, documents, contacts, locations and stickers.
29
+ - Manage multiple sessions, QR pairing, chats, contacts and groups.
30
+ - Handle incoming messages and session events through the JavaScript/TypeScript API.
48
31
 
49
- The first thing that you had to do is install the `npm package` :
32
+ ## Getting started
50
33
 
51
- ```bash
52
- npm i --save @wppconnect-team/wppconnect
53
- ```
34
+ Use Node.js and npm, plus Chrome/Chromium and its operating-system dependencies. CI builds with Node.js 24.22.2; the package does not declare a minimum Node version.
54
35
 
55
- See more at <a target="_blank" href="https://wppconnect.io/docs/tutorial/basics/installation">Getting Started</a>
36
+ ```sh
37
+ npm install @wppconnect-team/wppconnect
38
+ ```
56
39
 
57
- ## Development
40
+ Save this as `index.cjs`, run `node index.cjs`, and scan the QR code with WhatsApp Linked devices. Send `ping` from an authorized test contact to receive `pong`.
58
41
 
59
- Building WPPConnect is really simple, to build the entire project just run
42
+ ```javascript
43
+ const wppconnect = require("@wppconnect-team/wppconnect");
60
44
 
61
- ```bash
62
- > npm run build
45
+ wppconnect.create({ session: "readme-demo" })
46
+ .then((client) => {
47
+ client.onMessage(async (message) => {
48
+ if (!message.isGroupMsg && message.body === "ping") {
49
+ await client.sendText(message.from, "pong");
50
+ }
51
+ });
52
+ })
53
+ .catch(console.error);
63
54
  ```
64
55
 
65
- # Update checking
56
+ ## Configuration
57
+
58
+ Pass session and browser options to `create(...)`; see [client creation](docs/getting-started/creating-client.md). Store session credentials privately. WhatsApp Web changes can require package updates; review release notes and deprecations when upgrading.
59
+
60
+ ## Documentation
61
+
62
+ - [Installation guide](https://wppconnect.io/docs/tutorial/basics/installation)
63
+ - [API reference](https://wppconnect.io/wppconnect/)
64
+ - [Runnable examples](./examples/)
65
+ - [Retained technical details and acknowledgments](documentation/readme-reference.md)
66
+
67
+ ## WPPConnect ecosystem
68
+
69
+ | Project | Purpose | When to use it |
70
+ | --- | --- | --- |
71
+ | [WPPConnect/WA-JS](https://github.com/wppconnect-team/wa-js) | Expose WhatsApp Web functions through the browser-side `WPP` API. | Run browser-side code in WhatsApp Web. |
72
+ | [WPPConnect Server](https://github.com/wppconnect-team/wppconnect-server) | Run a REST API for WhatsApp sessions, messages and webhooks. | Expose session and messaging operations over HTTP. |
73
+ | [WPPConnect Manager](https://github.com/wppconnect-team/wppconnect-manager) | Manage WPPConnect Server sessions and conversations in a self-hosted web workspace. | Operate compatible Server sessions and chats through a UI. |
66
74
 
67
- Whatsapp is in constant change. In order to tackle this issue, we suggest always keeping your Wppconnect package up-to-date.
75
+ ## Support the project
68
76
 
69
- The method/function names won't change, only their core algorithm. This way you won't have to makes changes in your code at every update.
70
- They will remain the same forever but might experience deprecation.
77
+ WPPConnect is maintained by an open-source community. Your support helps fund maintenance, infrastructure, documentation, and the people working on the ecosystem.
71
78
 
72
- ## Maintainers
79
+ If WPPConnect helps your project or business, consider making a one-time contribution or becoming a recurring supporter.
73
80
 
74
- Maintainers are needed, I cannot keep with all the updates by myself. If you are
75
- interested please open a Pull Request.
81
+ **[Support WPPConnect on Open Collective](https://opencollective.com/wppconnect)**
82
+
83
+ Contributions are voluntary. See the official page for current financial information. You can also help with code, tests, documentation, translations and well-described issue reports.
84
+
85
+ Additional official beneficiaries in [.github/FUNDING.yml](.github/FUNDING.yml): [joaosouz4dev](https://github.com/sponsors/joaosouz4dev), [manfe](https://github.com/sponsors/manfe).
76
86
 
77
87
  ## Contributing
78
88
 
79
- Pull requests are welcome. For major changes, please open an issue first to
80
- discuss what you would like to change.
89
+ Contributions of code, tests, examples, documentation and translations are welcome. For larger changes, discuss the approach in an issue first. Include the project/runtime versions, a minimal reproduction and sanitized logs when reporting a problem. Update both `README.md` and `README.pt-BR.md` in the same change when installation, configuration, features, examples, licensing or funding changes.
81
90
 
82
- ## Star History
91
+ Read [CONTRIBUTING.md](CONTRIBUTING.md).
83
92
 
84
- [![Star History Chart](https://star-history.dera.page/svg?repos=wppconnect-team/wppconnect,wppconnect-team/wa-js&type=Date)](https://star-history.dera.page/#wppconnect-team/wppconnect&wppconnect-team/wa-js&Date)
93
+ After installing the development dependencies, use the repository checks relevant to your change:
85
94
 
86
- ## License
95
+ ```sh
96
+ npm run build
97
+ npm run lint
98
+ npm test
99
+ ```
100
+
101
+ Account-dependent examples and tests require separate validation with an authorized test account. Never attach credentials or session files to an issue.
87
102
 
88
- This file is part of WPPConnect.
103
+ ## Community and support
104
+
105
+ Use [repository issues](https://github.com/wppconnect-team/wppconnect/issues) for reproducible bugs and feature proposals. For usage questions, join the community through the official channels:
106
+
107
+ - [Discord](https://discord.gg/JU5JGGKGNG)
108
+ - [Telegram](https://t.me/wppconnect)
109
+ - [YouTube](https://www.youtube.com/c/wppconnect)
110
+
111
+ This project is independent and is not affiliated with or endorsed by WhatsApp or Meta. Follow applicable terms and obtain authorization for account and messaging operations.
112
+
113
+ ## License
89
114
 
90
- WPPConnect is free software: you can redistribute it and/or modify
91
- it under the terms of the GNU Lesser General Public License as published by
92
- the Free Software Foundation, either version 3 of the License, or
93
- (at your option) any later version.
115
+ [GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later)](./LICENSE.md).
94
116
 
95
- WPPConnect is distributed in the hope that it will be useful,
96
- but WITHOUT ANY WARRANTY; without even the implied warranty of
97
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98
- GNU Lesser General Public License for more details.
117
+ WPPConnect Team and contributors.
99
118
 
100
- You should have received a copy of the GNU Lesser General Public License
101
- along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
119
+ The original legal document and existing copyright notices are preserved. Third-party components retain their own terms.
@@ -0,0 +1,119 @@
1
+ [English](./README.md) | **Português (Brasil)**
2
+
3
+ <p align="center">
4
+ <a href="https://wppconnect.io/">
5
+ <picture>
6
+ <source media="(prefers-color-scheme: dark)" srcset="https://wppconnect-team.github.io/brand/v2/wppconnect-dark.png" />
7
+ <img src="https://wppconnect-team.github.io/brand/v2/wppconnect-light.png" alt="WPPConnect" width="220" height="121" />
8
+ </picture>
9
+ </a>
10
+ </p>
11
+
12
+ # WPPConnect
13
+
14
+ Controle o WhatsApp Web em aplicações Node.js.
15
+
16
+ Um projeto do ecossistema WPPConnect, mantido pela WPPConnect Team.
17
+
18
+ [Primeiros passos](#primeiros-passos) | [Documentação](#documentação) | [Como contribuir](#como-contribuir) | [Apoie a WPPConnect](#apoie-o-projeto)
19
+
20
+ [![License: LGPL-3.0-or-later](https://img.shields.io/badge/license-LGPL--3.0--or--later-blue)](./LICENSE.md) [![npm version](https://img.shields.io/npm/v/@wppconnect-team/wppconnect)](https://www.npmjs.com/package/@wppconnect-team/wppconnect) [![CI](https://github.com/wppconnect-team/wppconnect/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/wppconnect-team/wppconnect/actions/workflows/build.yml) [![Open Collective](https://img.shields.io/badge/Open%20Collective-WPPConnect-blue)](https://opencollective.com/wppconnect)
21
+
22
+ ## Visão geral
23
+
24
+ Para desenvolvedores de bots e integrações que querem gerenciar o navegador e o ciclo de vida das sessões na própria aplicação. A WPPConnect combina Puppeteer com a camada de automação no navegador usada pelo ecossistema.
25
+
26
+ ## Funcionalidades
27
+
28
+ - Envie e receba texto, imagens, vídeo, áudio, documentos, contatos, localizações e stickers.
29
+ - Gerencie múltiplas sessões, pareamento por QR, conversas, contatos e grupos.
30
+ - Trate mensagens recebidas e eventos de sessão pela API JavaScript/TypeScript.
31
+
32
+ ## Primeiros passos
33
+
34
+ Use Node.js e npm, além de Chrome/Chromium e suas dependências do sistema operacional. O CI compila com Node.js 24.22.2; o pacote não declara uma versão mínima do Node.
35
+
36
+ ```sh
37
+ npm install @wppconnect-team/wppconnect
38
+ ```
39
+
40
+ Salve como `index.cjs`, execute `node index.cjs` e leia o QR code em Aparelhos conectados do WhatsApp. Envie `ping` de um contato de teste autorizado para receber `pong`.
41
+
42
+ ```javascript
43
+ const wppconnect = require("@wppconnect-team/wppconnect");
44
+
45
+ wppconnect.create({ session: "readme-demo" })
46
+ .then((client) => {
47
+ client.onMessage(async (message) => {
48
+ if (!message.isGroupMsg && message.body === "ping") {
49
+ await client.sendText(message.from, "pong");
50
+ }
51
+ });
52
+ })
53
+ .catch(console.error);
54
+ ```
55
+
56
+ ## Configuração
57
+
58
+ Passe as opções de sessão e navegador para `create(...)`; consulte a [criação do cliente](docs/getting-started/creating-client.md). Guarde as credenciais de sessão em local privado. Mudanças no WhatsApp Web podem exigir atualizações do pacote; confira as notas de versão e depreciações ao atualizar.
59
+
60
+ ## Documentação
61
+
62
+ - [Guia de instalação](https://wppconnect.io/docs/tutorial/basics/installation)
63
+ - [Referência da API](https://wppconnect.io/wppconnect/)
64
+ - [Exemplos executáveis](./examples/)
65
+ - [Detalhes técnicos e agradecimentos preservados](documentation/readme-reference.md)
66
+
67
+ ## Ecossistema WPPConnect
68
+
69
+ | Projeto | Finalidade | Quando usar |
70
+ | --- | --- | --- |
71
+ | [WPPConnect/WA-JS](https://github.com/wppconnect-team/wa-js) | Exponha funções do WhatsApp Web pela API `WPP` no navegador. | Executar código no navegador dentro do WhatsApp Web. |
72
+ | [WPPConnect Server](https://github.com/wppconnect-team/wppconnect-server) | Execute uma API REST para sessões, mensagens e webhooks do WhatsApp. | Expor operações de sessão e mensagens por HTTP. |
73
+ | [WPPConnect Manager](https://github.com/wppconnect-team/wppconnect-manager) | Gerencie sessões e conversas do WPPConnect Server em uma aplicação web auto-hospedada. | Operar sessões e conversas de um Server compatível pela interface. |
74
+
75
+ ## Apoie o projeto
76
+
77
+ A WPPConnect é mantida por uma comunidade de código aberto. Seu apoio ajuda a financiar a manutenção, a infraestrutura, a documentação e o trabalho das pessoas que desenvolvem o ecossistema.
78
+
79
+ Se a WPPConnect ajuda seu projeto ou sua empresa, considere fazer uma contribuição pontual ou apoiar de forma recorrente.
80
+
81
+ **[Apoie a WPPConnect no Open Collective](https://opencollective.com/wppconnect)**
82
+
83
+ As contribuições são voluntárias. Consulte a página oficial para acompanhar as informações financeiras atuais. Você também pode ajudar com código, testes, documentação, traduções e relatos de problemas bem descritos.
84
+
85
+ Beneficiários oficiais adicionais em [.github/FUNDING.yml](.github/FUNDING.yml): [joaosouz4dev](https://github.com/sponsors/joaosouz4dev), [manfe](https://github.com/sponsors/manfe).
86
+
87
+ ## Como contribuir
88
+
89
+ Contribuições de código, testes, exemplos, documentação e traduções são bem-vindas. Para mudanças maiores, discuta a proposta em uma issue primeiro. Ao relatar um problema, informe as versões do projeto/runtime, uma reprodução mínima e logs sem dados sensíveis. Atualize `README.md` e `README.pt-BR.md` na mesma alteração quando mudar instalação, configuração, funcionalidades, exemplos, licença ou arrecadação.
90
+
91
+ Leia [CONTRIBUTING.md](CONTRIBUTING.md).
92
+
93
+ Após instalar as dependências de desenvolvimento, use as verificações pertinentes à sua alteração:
94
+
95
+ ```sh
96
+ npm run build
97
+ npm run lint
98
+ npm test
99
+ ```
100
+
101
+ Exemplos e testes que dependem de conta exigem validação separada com uma conta de teste autorizada. Nunca anexe credenciais ou arquivos de sessão a uma issue.
102
+
103
+ ## Comunidade e suporte
104
+
105
+ Use as [issues do repositório](https://github.com/wppconnect-team/wppconnect/issues) para bugs reproduzíveis e propostas de funcionalidades. Para dúvidas de uso, participe pelos canais oficiais:
106
+
107
+ - [Discord](https://discord.gg/JU5JGGKGNG)
108
+ - [Telegram](https://t.me/wppconnect)
109
+ - [YouTube](https://www.youtube.com/c/wppconnect)
110
+
111
+ Este projeto é independente e não é afiliado nem endossado pelo WhatsApp ou pela Meta. Siga os termos aplicáveis e obtenha autorização para operações de conta e mensagens.
112
+
113
+ ## Licença
114
+
115
+ [GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later)](./LICENSE.md).
116
+
117
+ WPPConnect Team and contributors.
118
+
119
+ O documento jurídico original e os avisos de autoria existentes são preservados. Componentes de terceiros mantêm seus próprios termos.
@@ -55,7 +55,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
55
55
  exports.newMagix = exports.magix = exports.mediaTypes = exports.timeout = exports.makeOptions = void 0;
56
56
  const crypto = __importStar(require("crypto"));
57
57
  const futoin_hkdf_1 = __importDefault(require("futoin-hkdf"));
58
- const atob_1 = __importDefault(require("atob"));
59
58
  const stream_1 = require("stream");
60
59
  const makeOptions = (useragentOverride, responseType = 'arraybuffer') => ({
61
60
  responseType: responseType,
@@ -86,9 +85,14 @@ const processUA = (userAgent) => {
86
85
  return ua;
87
86
  };
88
87
  const magix = (fileData, mediaKeyBase64, mediaType, expectedSize) => {
89
- const encodedHex = fileData.toString('hex');
90
- const encodedBytes = hexToBytes(encodedHex);
91
- const mediaKeyBytes = base64ToBytes(mediaKeyBase64);
88
+ // fileData is already raw bytes. Converting it to hex and back per byte
89
+ // (substr + parseInt per byte, multi-MB intermediate strings) is pure
90
+ // overhead on every decrypt.
91
+ const encodedBytes = Buffer.isBuffer(fileData)
92
+ ? fileData
93
+ : Buffer.from(fileData);
94
+ // atob + charCodeAt per byte === base64 decode
95
+ const mediaKeyBytes = Buffer.from(mediaKeyBase64, 'base64');
92
96
  const info = `WhatsApp ${exports.mediaTypes[mediaType.toUpperCase()]} Keys`;
93
97
  const hash = 'sha256';
94
98
  const salt = new Uint8Array(32);
@@ -124,21 +128,6 @@ const fixPadding = (data, expectedSize) => {
124
128
  //@ts-ignore
125
129
  return Buffer.from(data, 'utf-8');
126
130
  };
127
- const hexToBytes = (hexStr) => {
128
- const intArray = [];
129
- for (let i = 0; i < hexStr.length; i += 2) {
130
- intArray.push(parseInt(hexStr.substr(i, 2), 16));
131
- }
132
- return new Uint8Array(intArray);
133
- };
134
- const base64ToBytes = (base64Str) => {
135
- const binaryStr = (0, atob_1.default)(base64Str);
136
- const byteArray = new Uint8Array(binaryStr.length);
137
- for (let i = 0; i < binaryStr.length; i++) {
138
- byteArray[i] = binaryStr.charCodeAt(i);
139
- }
140
- return byteArray;
141
- };
142
131
  const newMagix = (mediaKeyBase64, mediaType, expectedSize) => {
143
132
  const mediaKeyBytes = newBase64ToBytes(mediaKeyBase64);
144
133
  const info = `WhatsApp ${exports.mediaTypes[mediaType.toUpperCase()]} Keys`;
@@ -1 +1,5 @@
1
+ /** Upper bound so one remote file cannot exhaust a small host (100 MB). */
2
+ export declare const MAX_DOWNLOAD_BYTES: number;
3
+ /** Remote fetches must not wedge a send forever. */
4
+ export declare const DOWNLOAD_TIMEOUT_MS = 30000;
1
5
  export declare function downloadFileToBase64(_path: string, _mines?: (string | RegExp)[]): Promise<string | false>;
@@ -19,8 +19,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  return (mod && mod.__esModule) ? mod : { "default": mod };
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.DOWNLOAD_TIMEOUT_MS = exports.MAX_DOWNLOAD_BYTES = void 0;
22
23
  exports.downloadFileToBase64 = downloadFileToBase64;
23
24
  const axios_1 = __importDefault(require("axios"));
25
+ /** Upper bound so one remote file cannot exhaust a small host (100 MB). */
26
+ exports.MAX_DOWNLOAD_BYTES = 100 * 1024 * 1024;
27
+ /** Remote fetches must not wedge a send forever. */
28
+ exports.DOWNLOAD_TIMEOUT_MS = 30000;
24
29
  async function downloadFileToBase64(_path, _mines = []) {
25
30
  if (!Array.isArray(_mines)) {
26
31
  console.error(`set mines string array, not "${typeof _mines}" `);
@@ -33,7 +38,14 @@ async function downloadFileToBase64(_path, _mines = []) {
33
38
  try {
34
39
  const response = await axios_1.default.get(_path, {
35
40
  responseType: 'arraybuffer',
41
+ timeout: exports.DOWNLOAD_TIMEOUT_MS,
42
+ maxContentLength: exports.MAX_DOWNLOAD_BYTES,
36
43
  });
44
+ // Refuse to materialize a huge body (headers arrive before the bytes)
45
+ const contentLength = Number(response.headers['content-length']);
46
+ if (Number.isFinite(contentLength) && contentLength > exports.MAX_DOWNLOAD_BYTES) {
47
+ return false;
48
+ }
37
49
  const mimeType = String(response.headers['content-type'] ?? '');
38
50
  if (_mines.length) {
39
51
  const isValidMime = _mines.some((m) => {
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Upper bound for a single file read. A base64 data URI is ~1.37x the file
3
+ * size in one contiguous string, so an unbounded read can exhaust a small
4
+ * host on a single send.
5
+ */
6
+ export declare const MAX_FILE_BYTES: number;
1
7
  /**
2
8
  * Converts given file into base64 string
3
9
  * @param path file path
@@ -49,30 +49,47 @@ var __importStar = (this && this.__importStar) || (function () {
49
49
  };
50
50
  })();
51
51
  Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.MAX_FILE_BYTES = void 0;
52
53
  exports.fileToBase64 = fileToBase64;
53
54
  exports.Mine = Mine;
54
55
  const mimeTypes = __importStar(require("mime-types"));
55
56
  const fs = __importStar(require("fs"));
57
+ /**
58
+ * Upper bound for a single file read. A base64 data URI is ~1.37x the file
59
+ * size in one contiguous string, so an unbounded read can exhaust a small
60
+ * host on a single send.
61
+ */
62
+ exports.MAX_FILE_BYTES = 100 * 1024 * 1024;
56
63
  /**
57
64
  * Converts given file into base64 string
58
65
  * @param path file path
59
66
  * @param mime Optional, will retrieve file mime automatically if not defined (Example: 'image/png')
60
67
  */
61
68
  async function fileToBase64(path, mime) {
62
- if (fs.existsSync(path)) {
63
- const base64 = fs.readFileSync(path, { encoding: 'base64' });
64
- if (mime === undefined) {
65
- mime = mimeTypes.lookup(path);
69
+ let size;
70
+ try {
71
+ const stat = await fs.promises.stat(path);
72
+ if (!stat.isFile()) {
73
+ return false;
66
74
  }
67
- if (!mime) {
68
- mime = 'application/octet-stream';
69
- }
70
- const data = `data:${mime};base64,${base64}`;
71
- return data;
75
+ size = stat.size;
72
76
  }
73
- else {
77
+ catch {
74
78
  return false;
75
79
  }
80
+ if (size > exports.MAX_FILE_BYTES) {
81
+ console.error(`fileToBase64: "${path}" is ${size} bytes, exceeding the ${exports.MAX_FILE_BYTES} byte limit.`);
82
+ return false;
83
+ }
84
+ const base64 = (await fs.promises.readFile(path)).toString('base64');
85
+ if (mime === undefined) {
86
+ mime = mimeTypes.lookup(path);
87
+ }
88
+ if (!mime) {
89
+ mime = 'application/octet-stream';
90
+ }
91
+ const data = `data:${mime};base64,${base64}`;
92
+ return data;
76
93
  }
77
94
  async function Mine(path) {
78
95
  if (fs.existsSync(path)) {
@@ -69,17 +69,17 @@ export declare class CatalogLayer extends CommunityLayer {
69
69
  * @param options Object with options
70
70
  * @example
71
71
  * ```javascript
72
- * client.editProduct('56989897878' {
72
+ * client.editProduct('56989897878', {
73
73
  * name: 'Product name',
74
74
  * description: 'product description',
75
- * price: '89.90',
75
+ * price: 89.90,
76
76
  * isHidden: true,
77
77
  * url: 'https://wppconnect.io',
78
78
  * retailerId: 'AKA001',
79
79
  * });
80
80
  * ```
81
81
  */
82
- editProduct(productId: string, options: string): Promise<import("@wppconnect/wa-js/dist/whatsapp").ProductModel>;
82
+ editProduct(productId: string, options: any): Promise<import("@wppconnect/wa-js/dist/whatsapp").ProductModel>;
83
83
  /**
84
84
  * Delete product(s) on catalog
85
85
  * @param productsId Products ID
@@ -82,10 +82,10 @@ class CatalogLayer extends community_layer_1.CommunityLayer {
82
82
  * @param options Object with options
83
83
  * @example
84
84
  * ```javascript
85
- * client.editProduct('56989897878' {
85
+ * client.editProduct('56989897878', {
86
86
  * name: 'Product name',
87
87
  * description: 'product description',
88
- * price: '89.90',
88
+ * price: 89.90,
89
89
  * isHidden: true,
90
90
  * url: 'https://wppconnect.io',
91
91
  * retailerId: 'AKA001',
@@ -49,10 +49,8 @@ class GroupLayer extends retriever_layer_1.RetrieverLayer {
49
49
  */
50
50
  async getGroupMembers(groupId) {
51
51
  const membersIds = await this.getGroupMembersIds(groupId);
52
- const actions = membersIds.map((memberId) => {
53
- return this.getContact(memberId._serialized);
54
- });
55
- return Promise.all(actions);
52
+ const membersIdValues = membersIds.map((memberId) => memberId._serialized);
53
+ return (0, helpers_1.evaluateAndReturn)(this.page, (membersIdValues) => membersIdValues.map((memberId) => WAPI.getContact(memberId)), membersIdValues);
56
54
  }
57
55
  /**
58
56
  * Generates group-invite link
@@ -123,7 +121,7 @@ class GroupLayer extends retriever_layer_1.RetrieverLayer {
123
121
  * @param participantId Participant id'000000000000@c.us'
124
122
  */
125
123
  async promoteParticipant(groupId, participantId) {
126
- await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId, participantId }) => WPP.group.promoteParticipants(groupId, participantId), { groupId, participantId });
124
+ return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId, participantId }) => WPP.group.promoteParticipants(groupId, participantId), { groupId, participantId });
127
125
  }
128
126
  /**
129
127
  * Demotes admin privileges of participant