@wppconnect/wa-js 4.3.0 → 4.3.1
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 +2 -2
- package/README.md +84 -0
- package/dist/group/functions/join.d.ts +20 -4
- package/dist/whatsapp/functions/joinGroupViaInvite.d.ts +6 -1
- package/dist/whatsapp/functions/sendJoinGroupViaInvite.d.ts +12 -1
- package/dist/wppconnect-wa.js +1 -1
- package/dist/wppconnect-wa.js.LICENSE.txt +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
## 4.3.
|
|
1
|
+
## <small>4.3.1 (2026-06-19)</small>
|
|
2
2
|
|
|
3
|
-
*
|
|
3
|
+
* fix(group): pass membershipApprovalMode to joinGroupViaInvite (#3468) ([3383b0374789dd25564068669bd2caadc25c0f5a](https://github.com/wppconnect-team/wa-js/commit/3383b0374789dd25564068669bd2caadc25c0f5a)), closes [#3468](https://github.com/wppconnect-team/wa-js/issues/3468) [#2221](https://github.com/wppconnect-team/wa-js/issues/2221)
|
package/README.md
CHANGED
|
@@ -483,6 +483,90 @@ This is useful for:
|
|
|
483
483
|
- Identifying when function signatures changed
|
|
484
484
|
- Finding new or removed modules
|
|
485
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
|
+
|
|
486
570
|
## How to use this project
|
|
487
571
|
|
|
488
572
|
Basically, you need to inject the `wppconnect-wa.js` file into the browser after WhatsApp page load.
|
|
@@ -13,16 +13,32 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
/**
|
|
17
|
+
* Result returned by {@link join}.
|
|
18
|
+
*
|
|
19
|
+
* `pendingApproval` is `true` when the group has `membershipApprovalMode`
|
|
20
|
+
* enabled and the join request was submitted successfully but still requires
|
|
21
|
+
* an admin to approve it before the bot becomes a member.
|
|
22
|
+
*/
|
|
23
|
+
export interface JoinGroupResult {
|
|
24
|
+
id: string;
|
|
25
|
+
pendingApproval: boolean;
|
|
26
|
+
}
|
|
16
27
|
/**
|
|
17
28
|
* Join in a group from an invite code.
|
|
18
29
|
*
|
|
30
|
+
* When the group requires admin approval (`membershipApprovalMode: true`),
|
|
31
|
+
* the method returns `{ id, pendingApproval: true }` instead of throwing
|
|
32
|
+
* `UnexpectedJoinGroupViaInviteResponse` (issues #2221 / #2746).
|
|
33
|
+
*
|
|
19
34
|
* @example
|
|
20
35
|
* ```javascript
|
|
21
|
-
* await WPP.group.join('abcde....');
|
|
36
|
+
* const result = await WPP.group.join('abcde....');
|
|
37
|
+
* if (result.pendingApproval) {
|
|
38
|
+
* console.log('Request sent — waiting for admin approval');
|
|
39
|
+
* }
|
|
22
40
|
* ```
|
|
23
41
|
*
|
|
24
42
|
* @category Group
|
|
25
43
|
*/
|
|
26
|
-
export declare function join(inviteCode: string): Promise<
|
|
27
|
-
id: string;
|
|
28
|
-
}>;
|
|
44
|
+
export declare function join(inviteCode: string): Promise<JoinGroupResult>;
|
|
@@ -16,7 +16,12 @@
|
|
|
16
16
|
import { Wid } from '..';
|
|
17
17
|
/**
|
|
18
18
|
* @whatsapp 153438 >= 2.2301.5
|
|
19
|
+
*
|
|
20
|
+
* When `membershipApprovalMode` is `false` (default) the server must respond
|
|
21
|
+
* with a `<group>` node; when `true` it must respond with
|
|
22
|
+
* `<membership_approval_request>`. If the wrong node is returned the function
|
|
23
|
+
* throws `UnexpectedJoinGroupViaInviteResponse` (see WAWebBackendErrors).
|
|
19
24
|
*/
|
|
20
|
-
export declare function joinGroupViaInvite(
|
|
25
|
+
export declare function joinGroupViaInvite(code: string, membershipApprovalMode: boolean): Promise<{
|
|
21
26
|
gid: Wid;
|
|
22
27
|
}>;
|
|
@@ -14,7 +14,18 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { Wid } from '..';
|
|
17
|
+
/**
|
|
18
|
+
* Result shape returned by {@link sendJoinGroupViaInvite}.
|
|
19
|
+
*
|
|
20
|
+
* `membershipApprovalMode` mirrors the flag queried via
|
|
21
|
+
* `getGroupInfoFromInviteCode` and signals whether the bot's join request is
|
|
22
|
+
* pending admin approval (`true`) or the bot joined immediately (`false`).
|
|
23
|
+
*/
|
|
24
|
+
export interface SendJoinGroupViaInviteResult {
|
|
25
|
+
gid: Wid;
|
|
26
|
+
membershipApprovalMode: boolean;
|
|
27
|
+
}
|
|
17
28
|
/** @whatsapp 69586
|
|
18
29
|
* @whatsapp 769586 >= 2.2222.8
|
|
19
30
|
*/
|
|
20
|
-
export declare function sendJoinGroupViaInvite(code: string): Promise<
|
|
31
|
+
export declare function sendJoinGroupViaInvite(code: string): Promise<SendJoinGroupViaInviteResult>;
|