@pney/whatsapp-web 1.34.6-3 → 1.34.7-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.
Files changed (59) hide show
  1. package/.env.example +0 -1
  2. package/.gitattributes +4 -0
  3. package/.husky/commit-msg +4 -0
  4. package/.husky/pre-commit +1 -0
  5. package/.lintstagedrc.json +6 -0
  6. package/.prettierignore +8 -0
  7. package/.prettierrc.json +10 -0
  8. package/README.md +83 -80
  9. package/commitlint.config.js +29 -0
  10. package/eslint.config.mjs +67 -0
  11. package/example.js +151 -71
  12. package/index.d.ts +982 -734
  13. package/index.js +4 -4
  14. package/package.json +1 -1
  15. package/shell.js +4 -4
  16. package/src/Client.js +1860 -921
  17. package/src/authStrategies/BaseAuthStrategy.js +4 -2
  18. package/src/authStrategies/LocalAuth.js +25 -12
  19. package/src/authStrategies/NoAuth.js +3 -4
  20. package/src/authStrategies/RemoteAuth.js +92 -43
  21. package/src/factories/ChatFactory.js +1 -1
  22. package/src/factories/ContactFactory.js +2 -2
  23. package/src/structures/Base.js +5 -3
  24. package/src/structures/Broadcast.js +1 -2
  25. package/src/structures/BusinessContact.js +1 -2
  26. package/src/structures/Buttons.js +14 -10
  27. package/src/structures/Call.js +10 -6
  28. package/src/structures/Channel.js +171 -91
  29. package/src/structures/Chat.js +57 -41
  30. package/src/structures/ClientInfo.js +1 -1
  31. package/src/structures/Contact.js +37 -16
  32. package/src/structures/GroupChat.js +425 -228
  33. package/src/structures/GroupNotification.js +21 -12
  34. package/src/structures/Label.js +6 -6
  35. package/src/structures/List.js +22 -14
  36. package/src/structures/Location.js +5 -4
  37. package/src/structures/Message.js +412 -160
  38. package/src/structures/MessageMedia.js +31 -18
  39. package/src/structures/Order.js +4 -4
  40. package/src/structures/Payment.js +6 -3
  41. package/src/structures/Poll.js +2 -2
  42. package/src/structures/PollVote.js +9 -6
  43. package/src/structures/PrivateChat.js +2 -4
  44. package/src/structures/PrivateContact.js +2 -4
  45. package/src/structures/Product.js +1 -1
  46. package/src/structures/ProductMetadata.js +1 -2
  47. package/src/structures/Reaction.js +2 -4
  48. package/src/structures/ScheduledEvent.js +22 -10
  49. package/src/util/Constants.js +8 -6
  50. package/src/util/Injected/AuthStore/AuthStore.js +7 -3
  51. package/src/util/Injected/Utils.js +753 -345
  52. package/src/util/InterfaceController.js +72 -25
  53. package/src/util/Puppeteer.js +1 -1
  54. package/src/util/Util.js +28 -15
  55. package/src/webCache/LocalWebCache.js +7 -5
  56. package/src/webCache/RemoteWebCache.js +10 -4
  57. package/src/webCache/WebCache.js +8 -5
  58. package/src/webCache/WebCacheFactory.js +9 -9
  59. package/CODE_OF_CONDUCT.md +0 -133
@@ -18,7 +18,7 @@ class Contact extends Base {
18
18
  constructor(client, data) {
19
19
  super(client);
20
20
 
21
- if(data) this._patch(data);
21
+ if (data) this._patch(data);
22
22
  }
23
23
 
24
24
  _patch(data) {
@@ -108,7 +108,7 @@ class Contact extends Base {
108
108
  * @type {boolean}
109
109
  */
110
110
  this.isBlocked = data.isBlocked;
111
-
111
+
112
112
  return super._patch(data);
113
113
  }
114
114
 
@@ -127,7 +127,7 @@ class Contact extends Base {
127
127
  async getFormattedNumber() {
128
128
  return await this.client.getFormattedNumber(this.id._serialized);
129
129
  }
130
-
130
+
131
131
  /**
132
132
  * Returns the contact's countrycode, (1541859685@c.us) => (1)
133
133
  * @returns {Promise<string>}
@@ -135,14 +135,14 @@ class Contact extends Base {
135
135
  async getCountryCode() {
136
136
  return await this.client.getCountryCode(this.id._serialized);
137
137
  }
138
-
138
+
139
139
  /**
140
- * Returns the Chat that corresponds to this Contact.
140
+ * Returns the Chat that corresponds to this Contact.
141
141
  * Will return null when getting chat for currently logged in user.
142
142
  * @returns {Promise<Chat>}
143
143
  */
144
144
  async getChat() {
145
- if(this.isMe) return null;
145
+ if (this.isMe) return null;
146
146
 
147
147
  return await this.client.getChatById(this.id._serialized);
148
148
  }
@@ -152,11 +152,21 @@ class Contact extends Base {
152
152
  * @returns {Promise<boolean>}
153
153
  */
154
154
  async block() {
155
- if(this.isGroup) return false;
155
+ if (this.isGroup) return false;
156
156
 
157
157
  await this.client.pupPage.evaluate(async (contactId) => {
158
- const contact = (window.require('WAWebCollections')).Contact.get(contactId);
159
- await (window.require('WAWebBlockContactAction')).blockContact({contact});
158
+ const contact = await window
159
+ .require('WAWebCollections')
160
+ .Contact.find(contactId);
161
+ const resolved = window
162
+ .require('WAWebBlockContactUtils')
163
+ .getContactToBlockOnlyUseIfNoAssociatedChat(
164
+ contact,
165
+ 'ChatListBlock',
166
+ );
167
+ await window
168
+ .require('WAWebBlockContactAction')
169
+ .blockContact({ contact: resolved });
160
170
  }, this.id._serialized);
161
171
 
162
172
  this.isBlocked = true;
@@ -168,11 +178,21 @@ class Contact extends Base {
168
178
  * @returns {Promise<boolean>}
169
179
  */
170
180
  async unblock() {
171
- if(this.isGroup) return false;
181
+ if (this.isGroup) return false;
172
182
 
173
183
  await this.client.pupPage.evaluate(async (contactId) => {
174
- const contact = (window.require('WAWebCollections')).Contact.get(contactId);
175
- await (window.require('WAWebBlockContactAction')).unblockContact(contact);
184
+ const contact = await window
185
+ .require('WAWebCollections')
186
+ .Contact.find(contactId);
187
+ const resolved = window
188
+ .require('WAWebBlockContactUtils')
189
+ .getContactToBlockOnlyUseIfNoAssociatedChat(
190
+ contact,
191
+ 'ChatListBlock',
192
+ );
193
+ await window
194
+ .require('WAWebBlockContactAction')
195
+ .unblockContact(resolved);
176
196
  }, this.id._serialized);
177
197
 
178
198
  this.isBlocked = false;
@@ -186,11 +206,12 @@ class Contact extends Base {
186
206
  async getAbout() {
187
207
  const about = await this.client.pupPage.evaluate(async (contactId) => {
188
208
  const wid = window.require('WAWebWidFactory').createWid(contactId);
189
- return (window.require('WAWebContactStatusBridge')).getStatus({'token':'', 'wid': wid});
209
+ return window
210
+ .require('WAWebContactStatusBridge')
211
+ .getStatus({ token: '', wid: wid });
190
212
  }, this.id._serialized);
191
213
 
192
- if (typeof about.status !== 'string')
193
- return null;
214
+ if (typeof about.status !== 'string') return null;
194
215
 
195
216
  return about.status;
196
217
  }
@@ -206,7 +227,7 @@ class Contact extends Base {
206
227
  /**
207
228
  * Gets the Contact's current status broadcast.
208
229
  * @returns {Promise<Broadcast>}
209
- */
230
+ */
210
231
  async getBroadcast() {
211
232
  return await this.client.getBroadcastById(this.id._serialized);
212
233
  }