@wppconnect/wa-js 3.23.4 → 4.0.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 +2 -5
- package/README.md +2 -2
- package/changelog.config.cjs +43 -0
- package/dist/conn/events/eventTypes.d.ts +16 -0
- package/dist/conn/events/index.d.ts +1 -0
- package/dist/conn/events/registerBackendEventBusEvents.d.ts +16 -0
- package/dist/contact/functions/index.d.ts +6 -1
- package/dist/contact/functions/queryExists.d.ts +4 -34
- package/dist/contact/functions/queryUsernameExists.d.ts +61 -0
- package/dist/contact/functions/queryWidExists.d.ts +51 -0
- package/dist/eventEmitter/eventTypes.d.ts +3 -3
- package/dist/eventEmitter/index.d.ts +41 -41
- package/dist/index.d.ts +8 -8
- package/dist/loader/blacklist.d.ts +28 -0
- package/dist/{webpack → loader}/eventTypes.d.ts +4 -4
- package/dist/{webpack → loader}/index.d.ts +14 -9
- package/dist/whatsapp/exportModule.d.ts +2 -2
- package/dist/whatsapp/functions/index.d.ts +1 -0
- package/dist/whatsapp/functions/sendQueryExists.d.ts +2 -1
- package/dist/whatsapp/functions/sendQueryUsernameExists.d.ts +36 -0
- package/dist/whatsapp/misc/BackendEventBus.d.ts +55 -0
- package/dist/whatsapp/misc/index.d.ts +1 -0
- package/dist/wppconnect-wa.js +1 -1
- package/dist/wppconnect-wa.js.LICENSE.txt +1 -1
- package/eslint.config.mjs +14 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
##
|
|
1
|
+
## 4.0.0 (2026-04-29)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* disconnection after reading qrcode - flushing during sync ([#3409](https://github.com/wppconnect-team/wa-js/issues/3409)) ([428ee01](https://github.com/wppconnect-team/wa-js/commit/428ee012c12dedc663991e8734af67876a9593af))
|
|
3
|
+
* feat: add BackendEventBus and register backend event handling (#3416) ([75ca156033d428784e8bff868e1cead3ae18a8c5](https://github.com/wppconnect-team/wa-js/commit/75ca156033d428784e8bff868e1cead3ae18a8c5)), closes [#3416](https://github.com/wppconnect-team/wa-js/issues/3416)
|
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ After build, this project generates a file `dist/wppconnect-wa.js` to be used fo
|
|
|
35
35
|
|
|
36
36
|
Some parts of `WPP` variable:
|
|
37
37
|
|
|
38
|
-
- `WPP.
|
|
38
|
+
- `WPP.loader` - Scripts to export WhatsApp functions.
|
|
39
39
|
- `WPP.whatsapp` - Only exported WhatsApp functions.
|
|
40
40
|
- `WPP.chat` - Chat functions and events.
|
|
41
41
|
- ...
|
|
@@ -261,7 +261,7 @@ Basically, you need to inject the `wppconnect-wa.js` file into the browser after
|
|
|
261
261
|
(function () {
|
|
262
262
|
'use strict';
|
|
263
263
|
|
|
264
|
-
WPP.
|
|
264
|
+
WPP.loader.onReady(function () {
|
|
265
265
|
alert('Ready to use WPPConnect WA-JS');
|
|
266
266
|
});
|
|
267
267
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const TYPE_TITLES = {
|
|
2
|
+
feat: 'Features',
|
|
3
|
+
fix: 'Bug Fixes',
|
|
4
|
+
perf: 'Performance Improvements',
|
|
5
|
+
revert: 'Reverts',
|
|
6
|
+
docs: 'Documentation',
|
|
7
|
+
style: 'Styles',
|
|
8
|
+
refactor: 'Code Refactoring',
|
|
9
|
+
test: 'Tests',
|
|
10
|
+
build: 'Build System',
|
|
11
|
+
ci: 'Continuous Integration',
|
|
12
|
+
chore: 'Chores',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function toSection(type) {
|
|
16
|
+
if (!type) {
|
|
17
|
+
return 'Other Changes';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const normalized = String(type).toLowerCase();
|
|
21
|
+
if (TYPE_TITLES[normalized]) {
|
|
22
|
+
return TYPE_TITLES[normalized];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return normalized.charAt(0).toUpperCase() + normalized.slice(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
preset: 'angular',
|
|
30
|
+
writerOpts: {
|
|
31
|
+
transform: (commit) => {
|
|
32
|
+
const nextCommit = { ...commit };
|
|
33
|
+
nextCommit.type = toSection(nextCommit.type);
|
|
34
|
+
|
|
35
|
+
// Keep wildcard scopes from polluting section output.
|
|
36
|
+
if (nextCommit.scope === '*') {
|
|
37
|
+
nextCommit.scope = '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return nextCommit;
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -13,10 +13,26 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { BackendEventName } from '../../whatsapp';
|
|
16
17
|
import { LogoutReason, StreamInfo, StreamMode } from '../../whatsapp/enums';
|
|
17
18
|
import { AuthCode } from '../types';
|
|
18
19
|
export interface ConnEventTypes {
|
|
19
20
|
'conn.auth_code_change': AuthCode | null;
|
|
21
|
+
/**
|
|
22
|
+
* Triggered for every event emitted by WhatsApp Web's internal BackendEventBus.
|
|
23
|
+
* The first argument is the event name (one of the BackendEvent constant values).
|
|
24
|
+
* Some events carry additional arguments (e.g. set_socket_state passes the new state).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```javascript
|
|
28
|
+
* WPP.on('conn.backend_event', (eventName, ...args) => {
|
|
29
|
+
* if (eventName === 'storage_initialization_error') {
|
|
30
|
+
* // Browser IndexedDB failed — clear profile and restart to recover
|
|
31
|
+
* }
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
'conn.backend_event': (eventName: BackendEventName, ...args: any[]) => void;
|
|
20
36
|
/**
|
|
21
37
|
* Triggered afted a success QR code scan
|
|
22
38
|
*
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 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 {};
|
|
@@ -20,7 +20,12 @@ export { getPnLidEntry, InvalidWidForGetPnLidEntry, PnLidContactInfo, PnLidEntry
|
|
|
20
20
|
export { getProfilePictureUrl } from './getProfilePictureUrl';
|
|
21
21
|
export { getStatus } from './getStatus';
|
|
22
22
|
export { ContactListOptions, list } from './list';
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use queryWidExists instead
|
|
25
|
+
*/
|
|
26
|
+
export { queryExists, QueryExistsResult } from './queryExists';
|
|
27
|
+
export { queryUsernameExists, QueryUsernameExistsKeyRequired, QueryUsernameExistsResult, } from './queryUsernameExists';
|
|
28
|
+
export { queryWidExists, QueryWidExistsResult } from './queryWidExists';
|
|
24
29
|
export { remove } from './remove';
|
|
25
30
|
export { reportContact, ReportContactResult } from './reportContact';
|
|
26
31
|
export { save } from './save';
|
|
@@ -13,37 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
bizInfo?: {
|
|
21
|
-
verifiedName?: {
|
|
22
|
-
isApi: boolean;
|
|
23
|
-
level: string;
|
|
24
|
-
name: string;
|
|
25
|
-
privacyMode: any;
|
|
26
|
-
serial: string;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
disappearingMode?: {
|
|
30
|
-
duration: number;
|
|
31
|
-
settingTimestamp: number;
|
|
32
|
-
};
|
|
33
|
-
status?: string;
|
|
34
|
-
lid?: Wid;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Check if the number exists and what is correct ID
|
|
38
|
-
*
|
|
39
|
-
* This help to identify numbers with nine digit in Brazil
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```javascript
|
|
43
|
-
* const result = await WPP.contact.queryExists('[number]@c.us');
|
|
44
|
-
* console.log(result.wid); // Correct ID
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* @category Contact
|
|
48
|
-
*/
|
|
49
|
-
export declare function queryExists(contactId: string | Wid): Promise<QueryExistsResult | null>;
|
|
16
|
+
/** @deprecated Use QueryWidExistsResult instead */
|
|
17
|
+
export type { QueryWidExistsResult as QueryExistsResult } from './queryWidExists';
|
|
18
|
+
/** @deprecated Use queryWidExists instead */
|
|
19
|
+
export { queryWidExists as queryExists } from './queryWidExists';
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
export interface QueryUsernameExistsResult {
|
|
18
|
+
wid: Wid;
|
|
19
|
+
biz: boolean;
|
|
20
|
+
bizInfo?: {
|
|
21
|
+
verifiedName?: {
|
|
22
|
+
isApi: boolean;
|
|
23
|
+
level: string;
|
|
24
|
+
name: string;
|
|
25
|
+
privacyMode: any;
|
|
26
|
+
serial?: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
username?: string;
|
|
30
|
+
wasUpdated: boolean;
|
|
31
|
+
isUsernameSearch: true;
|
|
32
|
+
}
|
|
33
|
+
export interface QueryUsernameExistsKeyRequired {
|
|
34
|
+
keyRequired: true;
|
|
35
|
+
username?: string;
|
|
36
|
+
isUsernameSearch: true;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check if a WhatsApp username (@username) exists
|
|
40
|
+
*
|
|
41
|
+
* Some accounts protect their username with a PIN. When the account has PIN
|
|
42
|
+
* protection enabled, this function returns `{ keyRequired: true }` instead of
|
|
43
|
+
* contact info. Pass the numeric PIN as `key` to unlock the result.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```javascript
|
|
47
|
+
* // Basic lookup
|
|
48
|
+
* const result = await WPP.contact.queryUsernameExists('someusername');
|
|
49
|
+
* if (result && 'keyRequired' in result) {
|
|
50
|
+
* // Username is PIN-protected — prompt the user for the PIN
|
|
51
|
+
* } else if (result) {
|
|
52
|
+
* console.log(result.wid); // The contact's WID
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* // With PIN
|
|
56
|
+
* const result = await WPP.contact.queryUsernameExists('someusername', '1234');
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @category Contact
|
|
60
|
+
*/
|
|
61
|
+
export declare function queryUsernameExists(username: string, key?: string): Promise<QueryUsernameExistsResult | QueryUsernameExistsKeyRequired | null>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 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
|
+
export interface QueryWidExistsResult {
|
|
18
|
+
wid: Wid;
|
|
19
|
+
biz: boolean;
|
|
20
|
+
bizInfo?: {
|
|
21
|
+
verifiedName?: {
|
|
22
|
+
isApi: boolean;
|
|
23
|
+
level: string;
|
|
24
|
+
name: string;
|
|
25
|
+
privacyMode: any;
|
|
26
|
+
serial?: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
disappearingMode?: {
|
|
30
|
+
duration: number;
|
|
31
|
+
settingTimestamp: number;
|
|
32
|
+
};
|
|
33
|
+
status?: string;
|
|
34
|
+
lid?: Wid;
|
|
35
|
+
username?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if the wid (phone number or LID) exists on WhatsApp
|
|
39
|
+
*
|
|
40
|
+
* This helps to identify numbers with nine digit in Brazil.
|
|
41
|
+
* Results are cached via ContactStore (persistent) and a 5-min in-memory cache.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```javascript
|
|
45
|
+
* const result = await WPP.contact.queryWidExists('[number]@c.us');
|
|
46
|
+
* console.log(result.wid); // Correct ID
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @category Contact
|
|
50
|
+
*/
|
|
51
|
+
export declare function queryWidExists(contactId: string | Wid): Promise<QueryWidExistsResult | null>;
|
|
@@ -19,16 +19,16 @@ import { ChatEventTypes } from '../chat/events/eventTypes';
|
|
|
19
19
|
import { ConfigEventTypes } from '../config/eventTypes';
|
|
20
20
|
import { ConnEventTypes } from '../conn/events/eventTypes';
|
|
21
21
|
import { GroupEventTypes } from '../group/events/eventTypes';
|
|
22
|
+
import { LoaderEvents } from '../loader/eventTypes';
|
|
22
23
|
import { OrderEventTypes } from '../order/events/eventTypes';
|
|
23
24
|
import { StatusEventTypes } from '../status/events/eventTypes';
|
|
24
|
-
import { WebpackEvents } from '../webpack/eventTypes';
|
|
25
25
|
export { BlocklistEventTypes } from '../blocklist/events/eventTypes';
|
|
26
26
|
export { CallEventTypes } from '../call/events/eventTypes';
|
|
27
27
|
export { ChatEventTypes } from '../chat/events/eventTypes';
|
|
28
28
|
export { ConfigEventTypes } from '../config/eventTypes';
|
|
29
29
|
export { ConnEventTypes } from '../conn/events/eventTypes';
|
|
30
30
|
export { GroupEventTypes } from '../group/events/eventTypes';
|
|
31
|
+
export { LoaderEvents } from '../loader/eventTypes';
|
|
31
32
|
export { OrderEventTypes } from '../order/events/eventTypes';
|
|
32
33
|
export { StatusEventTypes } from '../status/events/eventTypes';
|
|
33
|
-
export
|
|
34
|
-
export type EventTypes = BlocklistEventTypes & CallEventTypes & ChatEventTypes & ConfigEventTypes & ConnEventTypes & GroupEventTypes & OrderEventTypes & StatusEventTypes & WebpackEvents;
|
|
34
|
+
export type EventTypes = BlocklistEventTypes & CallEventTypes & ChatEventTypes & ConfigEventTypes & ConnEventTypes & GroupEventTypes & OrderEventTypes & StatusEventTypes & LoaderEvents;
|