@wppconnect/wa-js 4.2.0 → 4.3.1-alpha.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,3 @@
1
- ## 4.2.0 (2026-05-15)
1
+ ## <small>4.3.1-alpha.0 (2026-06-04)</small>
2
2
 
3
- * fix: remove outdated pre-lid release patches (#3425) ([aadc862253d4c4989d6a9e404c349889d55fa0d1](https://github.com/wppconnect-team/wa-js/commit/aadc862253d4c4989d6a9e404c349889d55fa0d1)), closes [#3425](https://github.com/wppconnect-team/wa-js/issues/3425)
3
+ * fix: unknown on chat list ([a8bd92d2b381d56ca5b96c392f71aa81d7ff0c70](https://github.com/wppconnect-team/wa-js/commit/a8bd92d2b381d56ca5b96c392f71aa81d7ff0c70))
package/CLAUDE.md ADDED
@@ -0,0 +1,124 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ WA-JS (`@wppconnect/wa-js`) is a browser injection library that extracts and wraps WhatsApp Web's internal functions, exposing them as a stable public API (`window.WPP`). It is bundled as a UMD library and injected into the WhatsApp Web page at runtime.
8
+
9
+ ## Commands
10
+
11
+ ```bash
12
+ # Build
13
+ npm run build:prd # Production build (minified) → dist/wppconnect-wa.js
14
+ npm run build:dev # Development build (inline source maps)
15
+ npm run build:watch # Watch mode
16
+
17
+ # Lint
18
+ npm run lint # ESLint + Prettier check
19
+
20
+ # Docs
21
+ npm run docs:build # Generate TypeDoc API docs
22
+
23
+ # Local development
24
+ npm run build:dev && WA_VERSION=latest npm run launch:local
25
+ npm run build:dev && WA_VERSION=<version> npm run launch:local
26
+ # Available versions listed in node_modules/@wppconnect/wa-version/html/
27
+
28
+ # WA source — download bundles (alpha included)
29
+ npm run wa-source:populate # latest 20 versions (default)
30
+ npm run wa-source:populate -- --all # all versions
31
+ npm run wa-source:populate -- --version <version> # single version
32
+ npm run wa-source:populate -- --force # re-download existing
33
+
34
+ # WA source — format before debugging internals (see Debugging section)
35
+ npm run wa-source:format <version>
36
+ ```
37
+
38
+ Available versions (alpha included) are listed in `node_modules/@wppconnect/wa-version/html/`.
39
+
40
+ ## Architecture
41
+
42
+ ### Loader System
43
+
44
+ The most critical piece. `src/loader/` detects which WhatsApp module system is active and exposes WhatsApp's internal modules to the rest of WA-JS:
45
+
46
+ - **Meta loader** (WA >= 2.3000.0): Uses `global.require()` with `ErrorGuard.skipGuardGlobal()`
47
+ - **Webpack loader** (legacy): Intercepts webpack chunk callbacks at startup
48
+
49
+ All `src/whatsapp/` imports resolve through this loader system at runtime.
50
+
51
+ ### Module Layout
52
+
53
+ `src/index.ts` is the entry point and re-exports all feature modules. Each feature module (e.g. `src/chat/`, `src/group/`) follows this internal pattern:
54
+
55
+ ```
56
+ <feature>/
57
+ ├── index.ts # Re-exports functions and registers patches/events
58
+ ├── types.ts # TypeScript types for the feature
59
+ ├── patch.ts # Monkey-patches WhatsApp internals (if needed)
60
+ ├── functions/ # One file per exported function
61
+ └── events/ # Event registration and re-emission
62
+ ```
63
+
64
+ ### `src/whatsapp/`
65
+
66
+ Low-level bindings to WhatsApp Web's internals, organized by type:
67
+ - `models/` — WhatsApp data model classes (Chat, Message, Contact, etc.)
68
+ - `collections/` — Backbone-style collections of models
69
+ - `stores/` — Singleton global collection instances
70
+ - `functions/` — Raw WhatsApp functions extracted from the bundle
71
+ - `enums/` — WhatsApp enumerations
72
+ - `multidevice/` — Multi-device protocol
73
+ - `websocket/` — WebSocket layer
74
+
75
+ These are **not part of the public API**. Feature modules in `src/<feature>/` wrap them.
76
+
77
+ ### Build Output
78
+
79
+ Webpack bundles everything into a single UMD file (`dist/wppconnect-wa.js`) exposing the global `WPP`. The `src/tools/` directory contains development utilities (not included in the bundle).
80
+
81
+ ## Debugging WhatsApp Internals
82
+
83
+ When a WA-JS function breaks after a WhatsApp Web update, the root cause is almost always one of:
84
+
85
+ - A function was **moved to a different internal module**
86
+ - A function was **renamed**
87
+ - Arguments changed from **positional to named params** (or vice versa)
88
+
89
+ ### Workflow
90
+
91
+ **Before inspecting any WhatsApp source**, the bundles must be downloaded and formatted:
92
+
93
+ 1. Download bundles for the target version (if not already done). The default run fetches the latest 20 versions; for an older one pass `--version`:
94
+ ```bash
95
+ npm run wa-source:populate # latest 20 (usually sufficient)
96
+ npm run wa-source:populate -- --version <version> # specific older version
97
+ ```
98
+ 2. Format so identifiers and structure are readable:
99
+ ```bash
100
+ npm run wa-source:format <version>
101
+ ```
102
+
103
+ > **Fresh debug session:** If you haven't worked on this WA version before, confirm with the user that they have run both commands above for that version before proceeding. Do not attempt to read `wa-source/<version>/` without the formatted source in place.
104
+
105
+ Once formatted, search the WA source for the function or module in question, compare old vs. new signatures, and update the corresponding binding in `src/whatsapp/`.
106
+
107
+ ## Version Compatibility
108
+
109
+ Fixes must support both the new WhatsApp Web version and older versions still listed in `node_modules/@wppconnect/wa-version/html/`.
110
+
111
+ If a workaround is only needed for older versions, mark it with a TODO so it gets cleaned up once those versions are no longer available:
112
+
113
+ ```ts
114
+ // TODO: remove when <version> is no longer available in wa-version/html
115
+ ```
116
+
117
+ ## Code Conventions
118
+
119
+ - Node version: 24 (see `.nvmrc`)
120
+ - TypeScript strict mode enabled; decorators enabled
121
+ - ESLint enforces import ordering (`simple-import-sort`) and file headers
122
+ - Prettier: single quotes, trailing commas (ES5)
123
+ - Commit messages follow Conventional Commits (enforced by commitlint)
124
+ - Pre-commit: lint-staged runs ESLint on staged files
package/README.md CHANGED
@@ -320,6 +320,37 @@ For the most up-to-date list of available functions, launch the project locally
320
320
 
321
321
  `Object.keys(WPP.privacy).sort()`
322
322
 
323
+ ### Labels vs Lists
324
+
325
+ WhatsApp has two separate chat-organization features that share the same internal infrastructure but serve different purposes:
326
+
327
+ | | `WPP.labels` | `WPP.lists` |
328
+ |---|---|---|
329
+ | **Account** | Business only | Personal + Business |
330
+ | **Purpose** | Tag chats for CRM workflows (e.g. "New lead", "Pending") | Group chats into named tabs (e.g. "Family", "Work") |
331
+ | **Visible as** | Colored label chips on chats | Tabs at the top of the chat list |
332
+ | **API guard** | `assertIsBusiness()` — throws on personal accounts | No business check |
333
+
334
+ Use `WPP.labels` for business label management. Use `WPP.lists` to create and manage chat grouping lists on any account type.
335
+
336
+ #### Lists Functions
337
+
338
+ `WPP.lists.create` - Create a new list
339
+
340
+ `WPP.lists.list` - Get all custom lists
341
+
342
+ `WPP.lists.addChats` - Add chats to a list
343
+
344
+ `WPP.lists.removeChats` - Remove chats from a list
345
+
346
+ `WPP.lists.rename` - Rename a list
347
+
348
+ `WPP.lists.remove` - Delete a list
349
+
350
+ For the most up-to-date list of available functions, launch the project locally and run this in your browser console:
351
+
352
+ `Object.keys(WPP.lists).sort()`
353
+
323
354
  ### Events
324
355
 
325
356
  #### Connection Events
@@ -452,6 +483,90 @@ This is useful for:
452
483
  - Identifying when function signatures changed
453
484
  - Finding new or removed modules
454
485
 
486
+ ## Building with a custom global variable name
487
+
488
+ If you are developing an extension or automation tool that may run on the same WhatsApp Web page alongside other WA-JS-based projects, you can compile your own build of this library under a different global variable name to avoid conflicts.
489
+
490
+ ### When to do this
491
+
492
+ By default, WA-JS exposes itself as `window.WPP`. If two tools built on WA-JS are injected into the same page using the default name, they will overwrite each other. Building under a custom name (e.g. `window.MYWPP`) ensures each tool owns its own isolated global.
493
+
494
+ ### Steps
495
+
496
+ **1. Clone the repository and install dependencies**
497
+
498
+ ```bash
499
+ git clone https://github.com/wppconnect-team/wa-js.git
500
+ cd wa-js
501
+ npm install
502
+ ```
503
+
504
+ **2. Change the global variable name in `webpack.config.js`**
505
+
506
+ Find the `output.library` block and replace `'WPP'` with your chosen name:
507
+
508
+ ```js
509
+ // webpack.config.js
510
+ output: {
511
+ filename: 'wppconnect-wa.js',
512
+ path: path.resolve(__dirname, 'dist'),
513
+ library: {
514
+ name: 'MYWPP', // <-- your custom global variable name
515
+ type: 'global',
516
+ },
517
+ },
518
+ ```
519
+
520
+ **3. Update the pre-injection config key in `src/config/index.ts`**
521
+
522
+ Replace every occurrence of `WPPConfig` with `<YOURNAME>Config` (e.g. `MYWPPConfig`). There are three occurrences in that file:
523
+
524
+ ```ts
525
+ // Before
526
+ interface Window { WPPConfig: Config; }
527
+ const setted = window.WPPConfig || {};
528
+ window.WPPConfig = config;
529
+
530
+ // After (using MYWPP as example)
531
+ interface Window { MYWPPConfig: Config; }
532
+ const setted = window.MYWPPConfig || {};
533
+ window.MYWPPConfig = config;
534
+ ```
535
+
536
+ **4. Build the production bundle**
537
+
538
+ ```bash
539
+ npm run build:prd
540
+ ```
541
+
542
+ The compiled file will be available at:
543
+
544
+ ```
545
+ dist/wppconnect-wa.js
546
+ ```
547
+
548
+ ### Result
549
+
550
+ When your custom build is injected into WhatsApp Web:
551
+
552
+ - The library is available as **`window.MYWPP`** (your chosen name).
553
+ - **`window.WPP` is not set** — there is no conflict with other WA-JS builds on the same page.
554
+ - Pre-injection configuration is read from **`window.MYWPPConfig`** instead of `window.WPPConfig`.
555
+
556
+ **Pre-injection usage example:**
557
+
558
+ ```javascript
559
+ // Set this before injecting your custom build
560
+ window.MYWPPConfig = {
561
+ deviceName: 'My Extension',
562
+ };
563
+
564
+ // After injection, use your custom global
565
+ window.MYWPP.loader.onReady(function () {
566
+ console.log('My extension is ready');
567
+ });
568
+ ```
569
+
455
570
  ## How to use this project
456
571
 
457
572
  Basically, you need to inject the `wppconnect-wa.js` file into the browser after WhatsApp page load.
package/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ export { isFullReady, isInjected, isReady } from './loader';
21
21
  export { loader };
22
22
  export { config, Config } from './config';
23
23
  export * as blocklist from './blocklist';
24
+ export * as lists from './lists';
24
25
  export * as call from './call';
25
26
  export * as cart from './cart';
26
27
  export * as catalog from './catalog';
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * Copyright 2026 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Wid } from '../../whatsapp';
17
+ /**
18
+ * Add chats to an existing list
19
+ *
20
+ * @example
21
+ * ```javascript
22
+ * await WPP.lists.addChats('42', ['number@c.us', 'number2@c.us']);
23
+ * ```
24
+ *
25
+ * @category Lists
26
+ */
27
+ export declare function addChats(listId: string, chatIds: (string | Wid)[]): Promise<void>;
@@ -0,0 +1,29 @@
1
+ /*!
2
+ * Copyright 2026 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Wid } from '../../whatsapp';
17
+ /**
18
+ * Create a new list and optionally add chats to it.
19
+ * Works for both personal and business accounts.
20
+ *
21
+ * @example
22
+ * ```javascript
23
+ * const id = await WPP.lists.create('Family', ['number@c.us', 'number2@c.us']);
24
+ * console.log(id); // '42'
25
+ * ```
26
+ *
27
+ * @category Lists
28
+ */
29
+ export declare function create(name: string, chatIds?: (string | Wid)[], colorIndex?: number): Promise<string>;
@@ -0,0 +1,21 @@
1
+ /*!
2
+ * Copyright 2026 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { addChats } from './addChats';
17
+ export { create } from './create';
18
+ export { list, ListInfo } from './list';
19
+ export { remove } from './remove';
20
+ export { removeChats } from './removeChats';
21
+ export { rename } from './rename';
@@ -0,0 +1,34 @@
1
+ /*!
2
+ * Copyright 2026 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export interface ListInfo {
17
+ id: string;
18
+ name: string;
19
+ colorIndex: number;
20
+ }
21
+ /**
22
+ * Return all custom lists (personal account lists)
23
+ *
24
+ * @example
25
+ * ```javascript
26
+ * const lists = WPP.lists.list();
27
+ * for (const l of lists) {
28
+ * console.log(l.id, l.name);
29
+ * }
30
+ * ```
31
+ *
32
+ * @category Lists
33
+ */
34
+ export declare function list(): ListInfo[];
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * Copyright 2026 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Delete a list by ID
18
+ *
19
+ * @example
20
+ * ```javascript
21
+ * await WPP.lists.remove('42');
22
+ * ```
23
+ *
24
+ * @category Lists
25
+ */
26
+ export declare function remove(listId: string): Promise<void>;
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * Copyright 2026 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Wid } from '../../whatsapp';
17
+ /**
18
+ * Remove chats from a list
19
+ *
20
+ * @example
21
+ * ```javascript
22
+ * await WPP.lists.removeChats('42', ['number@c.us']);
23
+ * ```
24
+ *
25
+ * @category Lists
26
+ */
27
+ export declare function removeChats(listId: string, chatIds: (string | Wid)[]): Promise<void>;
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * Copyright 2026 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Rename a list
18
+ *
19
+ * @example
20
+ * ```javascript
21
+ * await WPP.lists.rename('42', 'New Name');
22
+ * ```
23
+ *
24
+ * @category Lists
25
+ */
26
+ export declare function rename(listId: string, newName: string): Promise<void>;
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Copyright 2026 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './functions';
@@ -15,7 +15,9 @@
15
15
  */
16
16
  import { ReplyButtonModel } from '../models';
17
17
  import { BaseCollection } from './BaseCollection';
18
- /** @whatsapp 47688 */
18
+ /** @whatsapp 47688
19
+ * @whatsapp WAWebButtonCollection >= 2.3000.1039447205
20
+ */
19
21
  export declare class ButtonCollection extends BaseCollection<ReplyButtonModel> {
20
22
  static model: ReplyButtonModel;
21
23
  static comparator(): any;
@@ -18,3 +18,17 @@ import { Wid } from '..';
18
18
  * @whatsapp WAWebContactPresenceBridge
19
19
  */
20
20
  export declare function subscribePresence(id: Wid, tcToken?: any): Promise<any>;
21
+ /**
22
+ * Subscribe user presence (individual contact).
23
+ * Replaces subscribePresence in WAWebContactPresenceBridge >= ~2.3000.1039447205
24
+ *
25
+ * @whatsapp WAWebContactPresenceBridge >= 2.3000.1039447205
26
+ */
27
+ export declare function subscribeUserPresence(id: Wid): Promise<any>;
28
+ /**
29
+ * Subscribe group presence.
30
+ * Added in WAWebContactPresenceBridge >= ~2.3000.1039447205
31
+ *
32
+ * @whatsapp WAWebContactPresenceBridge >= 2.3000.1039447205
33
+ */
34
+ export declare function subscribeGroupPresence(id: Wid): void;
@@ -34,13 +34,15 @@ interface Session {
34
34
  }
35
35
  interface Derived {
36
36
  }
37
- /** @whatsapp 36473
37
+ /** @whatsapp WAWebCallModel >= 2.3000.0
38
+ * @whatsapp 36473
38
39
  * @whatsapp 40122 >= 2.2204.13
39
40
  * @whatsapp 736473 >= 2.2222.8
40
41
  */
41
42
  export declare interface CallModel extends ModelProxy<Props, Session, Derived> {
42
43
  }
43
- /** @whatsapp 36473
44
+ /** @whatsapp WAWebCallModel >= 2.3000.0
45
+ * @whatsapp 36473
44
46
  * @whatsapp 40122 >= 2.2204.13
45
47
  * @whatsapp 736473 >= 2.2222.8
46
48
  */
@@ -39,6 +39,8 @@ interface Props extends PropsChatBase {
39
39
  unreadMentionsOfMe?: any;
40
40
  msgUnsyncedButtonReplyMsgs?: any;
41
41
  endOfHistoryTransferType?: any;
42
+ /** Contact LID for PnLess protocol (Phone Number-less) */
43
+ accountLid?: Wid;
42
44
  }
43
45
  interface Session extends SessionChatBase {
44
46
  stale?: any;
@@ -20,6 +20,8 @@ interface Props {
20
20
  colorIndex?: number;
21
21
  color?: number;
22
22
  count?: any;
23
+ type?: number;
24
+ predefinedId?: number;
23
25
  }
24
26
  interface Session {
25
27
  stale?: any;