@wppconnect/wa-js 3.22.1 → 3.23.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 CHANGED
@@ -1,9 +1,9 @@
1
- ## 3.22.1 (2026-02-28)
1
+ ## 3.23.1 (2026-03-04)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * getMessages (msgs.push is not a function) ([#3364](https://github.com/wppconnect-team/wa-js/issues/3364)) ([bdd2224](https://github.com/wppconnect-team/wa-js/commit/bdd222400e594e98b74cadc06a3a21eef3f2ecd8))
6
+ * event name to follow project pattern ([#3371](https://github.com/wppconnect-team/wa-js/issues/3371)) ([217158d](https://github.com/wppconnect-team/wa-js/commit/217158dc21dc1586168c254a564bd50f9b32cb43))
7
7
 
8
8
 
9
9
 
package/README.md CHANGED
@@ -58,6 +58,8 @@ There are convention names for some exported modules:
58
58
 
59
59
  `WPP.conn.getBuildConstants` - Current WhatsApp build constants
60
60
 
61
+ `WPP.conn.getStreamData` - Get current stream mode and info (connection state)
62
+
61
63
  For the most up-to-date list of available functions, launch the project locally and run this in your browser console:
62
64
 
63
65
  `Object.keys(WPP.conn).sort()`
@@ -131,6 +133,50 @@ For the most up-to-date list of available functions, launch the project locally
131
133
  `Object.keys(WPP.group).sort()`
132
134
 
133
135
  ### Events
136
+
137
+ #### Connection Events
138
+
139
+ `WPP.on('conn.stream_mode_changed', callback)` - Triggered when the connection mode changes
140
+
141
+ Stream modes:
142
+ - `QR` - QR code is displayed, waiting for scan
143
+ - `MAIN` - Main interface is loaded and ready
144
+ - `SYNCING` - Syncing messages and data
145
+ - `OFFLINE` - Connection is offline
146
+ - `CONFLICT` - Login conflict detected
147
+ - `PROXYBLOCK` - Blocked by proxy
148
+ - `TOS_BLOCK` - Blocked for Terms of Service violation
149
+ - `SMB_TOS_BLOCK` - SMB blocked for Terms of Service violation
150
+ - `DEPRECATED_VERSION` - WhatsApp version is deprecated
151
+
152
+ ```javascript
153
+ WPP.on('conn.stream_mode_changed', (mode) => {
154
+ console.log('Connection mode:', mode);
155
+ if (mode === 'MAIN') {
156
+ console.log('WhatsApp is ready!');
157
+ }
158
+ });
159
+ ```
160
+
161
+ `WPP.on('conn.stream_info_changed', callback)` - Triggered when the internal connection state changes
162
+
163
+ Stream info states:
164
+ - `OFFLINE` - Connection is offline
165
+ - `OPENING` - Opening connection
166
+ - `PAIRING` - Pairing with phone
167
+ - `SYNCING` - Syncing messages
168
+ - `RESUMING` - Resuming connection
169
+ - `CONNECTING` - Connecting to server
170
+ - `NORMAL` - Normal operation
171
+
172
+ ```javascript
173
+ WPP.on('conn.stream_info_changed', (info) => {
174
+ console.log('Connection state:', info);
175
+ });
176
+ ```
177
+
178
+ #### Chat Events
179
+
134
180
  `WPP.chat.on('chat.new_message')` - Event to dispatch on receive a new message
135
181
 
136
182
  To see all events, check: [https://wppconnect.io/wa-js/types/ev.EventTypes.html](https://wppconnect.io/wa-js/types/ev.EventTypes.html)
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { LogoutReason } from '../../whatsapp/enums';
16
+ import { LogoutReason, StreamInfo, StreamMode } from '../../whatsapp/enums';
17
17
  import { AuthCode } from '../types';
18
18
  export interface ConnEventTypes {
19
19
  'conn.auth_code_change': AuthCode | null;
@@ -91,4 +91,26 @@ export interface ConnEventTypes {
91
91
  'conn.online': boolean;
92
92
  'conn.qrcode_idle': undefined;
93
93
  'conn.require_auth': undefined;
94
+ /**
95
+ * Triggered when the stream mode changes
96
+ *
97
+ * @example
98
+ * ```javascript
99
+ * WPP.on('conn.stream_mode_changed', (mode) => {
100
+ * console.log('Stream mode changed to:', mode);
101
+ * });
102
+ * ```
103
+ */
104
+ 'conn.stream_mode_changed': StreamMode;
105
+ /**
106
+ * Triggered when the stream info changes
107
+ *
108
+ * @example
109
+ * ```javascript
110
+ * WPP.on('conn.stream_info_changed', (info) => {
111
+ * console.log('Stream info changed to:', info);
112
+ * });
113
+ * ```
114
+ */
115
+ 'conn.stream_info_changed': StreamInfo;
94
116
  }
@@ -24,3 +24,4 @@ import './registerNeedsUpdateEvent';
24
24
  import './registerOnlineEvent';
25
25
  import './registerQRCodeIdleEvent';
26
26
  import './registerRequireAuthEvent';
27
+ import './registerStreamEvent';
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright 2021 WPPConnect Team
2
+ * Copyright 2026 WPPConnect Team
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -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 {};
@@ -0,0 +1,31 @@
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 { StreamInfo, StreamMode } from '../../whatsapp/enums';
17
+ export interface StreamData {
18
+ mode: StreamMode;
19
+ info: StreamInfo | undefined;
20
+ }
21
+ /**
22
+ * Get current stream mode and info
23
+ *
24
+ * @example
25
+ * ```javascript
26
+ * const streamData = WPP.conn.getStreamData();
27
+ * console.log(streamData.mode); // 'MAIN', 'QR', 'SYNCING', etc.
28
+ * console.log(streamData.info); // 'NORMAL', 'OPENING', 'SYNCING', etc.
29
+ * ```
30
+ */
31
+ export declare function getStreamData(): StreamData;
@@ -26,6 +26,7 @@ export { getMyUserId } from './getMyUserId';
26
26
  export { getMyUserLid } from './getMyUserLid';
27
27
  export { getMyUserWid } from './getMyUserWid';
28
28
  export { getPlatform } from './getPlatform';
29
+ export { getStreamData, StreamData } from './getStreamData';
29
30
  export { getTheme, Theme } from './getTheme';
30
31
  export { isAuthenticated } from './isAuthenticated';
31
32
  export { isIdle } from './isIdle';
@@ -0,0 +1,28 @@
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
+ * StreamInfo represents the internal connection state
18
+ * @whatsapp 2.3000.x
19
+ */
20
+ export declare enum StreamInfo {
21
+ OFFLINE = "OFFLINE",
22
+ OPENING = "OPENING",
23
+ PAIRING = "PAIRING",
24
+ SYNCING = "SYNCING",
25
+ RESUMING = "RESUMING",
26
+ CONNECTING = "CONNECTING",
27
+ NORMAL = "NORMAL"
28
+ }
@@ -0,0 +1,30 @@
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
+ * StreamMode represents the connection state mode
18
+ * @whatsapp 2.3000.x
19
+ */
20
+ export declare enum StreamMode {
21
+ QR = "QR",
22
+ MAIN = "MAIN",
23
+ SYNCING = "SYNCING",
24
+ OFFLINE = "OFFLINE",
25
+ CONFLICT = "CONFLICT",
26
+ PROXYBLOCK = "PROXYBLOCK",
27
+ TOS_BLOCK = "TOS_BLOCK",
28
+ SMB_TOS_BLOCK = "SMB_TOS_BLOCK",
29
+ DEPRECATED_VERSION = "DEPRECATED_VERSION"
30
+ }
@@ -24,3 +24,5 @@ export * from './OUTWARD_TYPES';
24
24
  export * from './PIN_STATE';
25
25
  export * from './PinExpiryDurationOption';
26
26
  export * from './SendMsgResult';
27
+ export * from './StreamInfo';
28
+ export * from './StreamMode';
@@ -13,25 +13,26 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { StreamInfo, StreamMode } from '../enums';
16
17
  import { Model, ModelOptions, ModelPropertiesContructor, ModelProxy } from './Model';
17
18
  interface Props {
18
19
  }
19
20
  interface Session {
20
- info?: any;
21
- mode: string;
21
+ info?: StreamInfo;
22
+ mode: StreamMode;
22
23
  obscurity?: any;
23
24
  needsUpdate?: any;
24
- clientExpired?: any;
25
- hardExpired?: any;
25
+ isHardRefresh?: boolean;
26
26
  lastSyncStart?: any;
27
27
  needsManualDownload?: any;
28
28
  couldForce?: any;
29
29
  uiActive?: any;
30
+ isInConnectedCall?: boolean;
30
31
  available?: any;
31
32
  unavailableShiftTimer?: any;
33
+ unavailableAutoLockTimer?: any;
32
34
  unavailableLogoutTimer?: any;
33
35
  unobscureShiftTimer?: any;
34
- timeoutEvent?: any;
35
36
  resumeCount?: any;
36
37
  phoneAuthed?: any;
37
38
  }
@@ -48,16 +49,13 @@ export declare interface StreamModel extends ModelProxy<Props, Session, Derived>
48
49
  */
49
50
  export declare class StreamModel extends Model {
50
51
  constructor(proterties?: ModelPropertiesContructor<StreamModel>, options?: ModelOptions);
52
+ initialize(): void;
53
+ delete(): void;
51
54
  markAvailable(): void;
52
55
  markUnavailable(e?: any): void;
53
- onSelfUpdate(): void;
54
- onSocketUpdate(): void;
55
56
  unobscure(): void;
56
- onPhoneAuthedUpdate(): void;
57
- onAvailableUpdate(): void;
58
57
  sendAvailability(e?: any): void;
59
58
  updateCouldForce(): void;
60
- updateHardExpire(): void;
61
59
  logPageResume(): void;
62
60
  updateWamLog(): void;
63
61
  logModeChange(): void;