@wppconnect/wa-js 3.4.2 → 3.6.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,4 +1,4 @@
1
- ## 3.4.2 (2024-07-08)
1
+ # 3.6.0 (2024-07-16)
2
2
 
3
3
 
4
4
 
package/README.md CHANGED
@@ -19,6 +19,13 @@
19
19
  [![WhatsApp Group](https://img.shields.io/badge/WhatsApp-Group-25D366?logo=whatsapp)](https://chat.whatsapp.com/LJaQu6ZyNvnBPNAVRbX00K)
20
20
  [![YouTube](https://img.shields.io/youtube/channel/subscribers/UCD7J9LG08PmGQrF5IS7Yv9A?label=YouTube)](https://www.youtube.com/c/wppconnect)
21
21
 
22
+
23
+ ### Top Contributors (last 45 days) widget
24
+ ---
25
+ ![Top Contributors (Last 45 days) widget](https://embeddables.devactivity.com/orgs/wppconnect-team/508ecbcd-e55e-4e31-a647-6674f134b5bf.svg)
26
+ ---
27
+ <sup><sub>Check also our [Public Dashboard](https://app.devactivity.com/public/?organizationLogin=wppconnect-team) powered by [devActivity](https://devactivity.com/?ref=public_widget)</sub></sup>
28
+
22
29
  ## How does it work
23
30
 
24
31
  This project extract some functions of WhatsApp sources, that uses webpack.
@@ -40,6 +47,56 @@ There are a convection name for some exported modules:
40
47
  - `...Collection` - Class for collection of models (`ChatCollection`, `MsgCollection`)
41
48
  - `...Store` - Default and global instance of a collection (`ChatStore`, `MsgStore`)
42
49
 
50
+ ## Some Available functions
51
+ ### General Functions
52
+ `WPP.conn.connect` - Connect to WhatsApp Web
53
+
54
+ `WPP.conn.isAuthenticated` - Check if the connection is authenticated
55
+
56
+ `WPP.conn.logout` - Logout from WhatsApp Web
57
+
58
+ ### Chat Functions
59
+ `WPP.chat.sendTextMessage` - Send a text message
60
+
61
+ `WPP.chat.sendImageMessage` - Send an image message
62
+
63
+ `WPP.chat.sendVideoMessage` - Send a video message
64
+
65
+ `WPP.chat.sendFileMessage` - Send a file message
66
+
67
+ `WPP.chat.sendAudioMessage` - Send an audio message
68
+
69
+ `WPP.chat.getChat` - Get chat details
70
+
71
+ `WPP.chat.deleteMessage` - Delete a message
72
+
73
+ ### Contact Functions
74
+ `WPP.contact.getContact` - Get contact details
75
+
76
+ `WPP.contact.blockContact` - Block a contact
77
+
78
+ `WPP.contact.unblockContact` - Unblock a contact
79
+
80
+ `WPP.contact.getAllContacts` - Get all contacts
81
+
82
+ ### Group Functions
83
+ `WPP.group.createGroup` - Create a new group
84
+
85
+ `WPP.group.addParticipant` - Add a participant to a group
86
+
87
+ `WPP.group.removeParticipant` - Remove a participant from a group.
88
+
89
+ `WPP.group.promoteParticipant` - Promote a participant to admin
90
+
91
+ `WPP.group.demoteParticipant` - Demote a participant from admin.
92
+
93
+ `WPP.group.getGroupInfo` - Get group information.
94
+
95
+ ### Events
96
+ `WPP.chat.on('chat.new_message')` - Event to dispatch on receive a new message
97
+
98
+ To see all events, check: [https://wppconnect.io/wa-js/types/ev.EventTypes.html](https://wppconnect.io/wa-js/types/ev.EventTypes.html)
99
+
43
100
  ## Development
44
101
 
45
102
  Steps to run locally:
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * Copyright 2024 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
+ * Close the chat tab
18
+ *
19
+ * @example
20
+ * ```javascript
21
+ * await WPP.chat.closeChat();
22
+ * ```
23
+ *
24
+ * @category Chat
25
+ */
26
+ export declare function closeChat(): Promise<boolean>;
@@ -18,6 +18,7 @@ export { canMarkPlayed } from './canMarkPlayed';
18
18
  export { canMute } from './canMute';
19
19
  export { canReply } from './canReply';
20
20
  export { clear } from './clear';
21
+ export { closeChat } from './closeChat';
21
22
  export { delete } from './delete';
22
23
  export { deleteMessage, DeleteMessageReturn } from './deleteMessage';
23
24
  export { downloadMedia } from './downloadMedia';
@@ -13,6 +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
17
  import { AuthCode } from '../types';
17
18
  export interface ConnEventTypes {
18
19
  'conn.auth_code_change': AuthCode | null;
@@ -28,6 +29,7 @@ export interface ConnEventTypes {
28
29
  */
29
30
  'conn.authenticated': undefined;
30
31
  'conn.logout': undefined;
32
+ 'conn.logout_reason': LogoutReason;
31
33
  /**
32
34
  * Triggered when the interface is booting
33
35
  *
@@ -16,6 +16,7 @@
16
16
  import './registerAuthCodeChangeEvent';
17
17
  import './registerAuthenticatedEvent';
18
18
  import './registerLogoutEvent';
19
+ import './registerLogoutReasonEvent';
19
20
  import './registerMainInit';
20
21
  import './registerMainLoadedEvent';
21
22
  import './registerMainReadyEvent';
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Copyright 2024 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 {};
@@ -16,15 +16,32 @@
16
16
  /** @whatsapp 83578
17
17
  * @whatsapp 88950 >= 2.2218.4
18
18
  * @whatsapp 788950 >= 2.2222.8
19
+ * @whatsapp WAWebLogoutReasonConstants >= 2.3000.x
19
20
  */
20
21
  export declare enum LogoutReason {
21
- USER_INITIATED = "user_initiated",
22
- SYNCD_FAILURE = "syncd_failure",
23
- CRITICAL_SYNC_TIMEOUT = "critical_sync_timeout",
24
- UNKNOWN_COMPANION = "unknown_companion",
25
- CLIENT_VERSION_OUTDATED = "client_version_outdated",
26
- SYNCD_ERROR_DURING_BOOTSTRAP = "syncd_error_during_bootstrap",
27
- ACCOUNT_SYNC_ERROR = "account_sync_error",
28
- CLIENT_FATAL_ERROR = "client_fatal_error",
22
+ UserInitiated = "user_initiated",
23
+ SyncdFailure = "syncd_failure",
24
+ InvalidAdvStatus = "invalid_adv_status",
25
+ CriticalSyncTimeout = "critical_sync_timeout",
26
+ SyncdTimeout = "syncd_timeout",
27
+ HistorySyncTimeout = "history_sync_timeout",
28
+ AccountSyncTimeout = "account_sync_timeout",
29
+ MDOptOut = "md_opt_out",
30
+ UnknownCompanion = "unknown_companion",
31
+ ClientVersionOutdated = "client_version_outdated",
32
+ SyncdErrorDuringBootstrap = "syncd_error_during_bootstrap",
33
+ AccountSyncError = "account_sync_error",
34
+ ClientFatalError = "client_fatal_error",
35
+ StorageQuotaExceeded = "storage_quota_exceeded",
36
+ PrimaryIdentityKeyChange = "primary_identity_key_change",
37
+ MissingEncSalt = "missing_enc_salt",
38
+ MissingScreenLockSalt = "missing_screen_lock_salt",
39
+ AccountLocked = "account_locked",
29
40
  UNKNOWN = "unknown"
30
41
  }
42
+ export declare enum LOGOUT_REASON_CODE {
43
+ CLIENT_FATAL = "0",
44
+ SYNC_FAIL = "1",
45
+ INITIAL_HISTORY_SYNC_TIMEOUT = "2",
46
+ ACCOUNT_LOCKED = "3"
47
+ }
@@ -0,0 +1,20 @@
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 { LOGOUT_REASON_CODE, LogoutReason } from '../enums';
17
+ /**
18
+ * @whatsapp WAWebLogoutReason >= 2.3000.x
19
+ */
20
+ export declare function getErrorCodeFromLogoutReason(type: LogoutReason): LOGOUT_REASON_CODE | null;
@@ -55,6 +55,7 @@ export * from './getCommunityParticipants';
55
55
  export * from './getCountryShortcodeByPhone';
56
56
  export * from './getCurrentLid';
57
57
  export * from './getEphemeralFields';
58
+ export * from './getErrorCodeFromLogoutReason';
58
59
  export * from './getFanOutList';
59
60
  export * from './getGroupSenderKeyList';
60
61
  export * from './getGroupSizeLimit';