whatsapp-web-sj.js 1.26.0 → 1.31.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.
@@ -98,7 +98,7 @@ class GroupChat extends Chat {
98
98
  419: 'The participant can\'t be added because the group is full'
99
99
  };
100
100
 
101
- await window.Store.GroupQueryAndUpdate(groupWid);
101
+ await window.Store.GroupQueryAndUpdate({ id: groupId });
102
102
  const groupMetadata = group.groupMetadata;
103
103
  const groupParticipants = groupMetadata?.participants;
104
104
 
@@ -191,8 +191,7 @@ class GroupChat extends Chat {
191
191
  */
192
192
  async removeParticipants(participantIds) {
193
193
  return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
194
- const chatWid = window.Store.WidFactory.createWid(chatId);
195
- const chat = await window.Store.Chat.find(chatWid);
194
+ const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
196
195
  const participants = participantIds.map(p => {
197
196
  return chat.groupMetadata.participants.get(p);
198
197
  }).filter(p => Boolean(p));
@@ -208,8 +207,7 @@ class GroupChat extends Chat {
208
207
  */
209
208
  async promoteParticipants(participantIds) {
210
209
  return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
211
- const chatWid = window.Store.WidFactory.createWid(chatId);
212
- const chat = await window.Store.Chat.find(chatWid);
210
+ const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
213
211
  const participants = participantIds.map(p => {
214
212
  return chat.groupMetadata.participants.get(p);
215
213
  }).filter(p => Boolean(p));
@@ -225,8 +223,7 @@ class GroupChat extends Chat {
225
223
  */
226
224
  async demoteParticipants(participantIds) {
227
225
  return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
228
- const chatWid = window.Store.WidFactory.createWid(chatId);
229
- const chat = await window.Store.Chat.find(chatWid);
226
+ const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
230
227
  const participants = participantIds.map(p => {
231
228
  return chat.groupMetadata.participants.get(p);
232
229
  }).filter(p => Boolean(p));
@@ -381,9 +378,9 @@ class GroupChat extends Chat {
381
378
  const codeRes = await this.client.pupPage.evaluate(async chatId => {
382
379
  const chatWid = window.Store.WidFactory.createWid(chatId);
383
380
  try {
384
- return window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')
385
- ? await window.Store.GroupInvite.queryGroupInviteCode(chatWid, true)
386
- : await window.Store.GroupInvite.queryGroupInviteCode(chatWid);
381
+ return window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.1020730154')
382
+ ? await window.Store.GroupInvite.fetchMexGroupInviteCode(chatId)
383
+ : await window.Store.GroupInvite.queryGroupInviteCode(chatWid, true);
387
384
  }
388
385
  catch (err) {
389
386
  if(err.name === 'ServerStatusCodeError') return undefined;
@@ -391,7 +388,9 @@ class GroupChat extends Chat {
391
388
  }
392
389
  }, this.id._serialized);
393
390
 
394
- return codeRes?.code;
391
+ return codeRes?.code
392
+ ? codeRes?.code
393
+ : codeRes;
395
394
  }
396
395
 
397
396
  /**
@@ -464,8 +463,7 @@ class GroupChat extends Chat {
464
463
  */
465
464
  async leave() {
466
465
  await this.client.pupPage.evaluate(async chatId => {
467
- const chatWid = window.Store.WidFactory.createWid(chatId);
468
- const chat = await window.Store.Chat.find(chatWid);
466
+ const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
469
467
  return window.Store.GroupUtils.sendExitGroup(chat);
470
468
  }, this.id._serialized);
471
469
  }
@@ -6,6 +6,7 @@
6
6
  * @property {string} [name] Location name
7
7
  * @property {string} [address] Location address
8
8
  * @property {string} [url] URL address to be shown within a location message
9
+ * @property {string} [description] Location full description
9
10
  */
10
11
 
11
12
  /**
@@ -45,7 +45,7 @@ class Message extends Base {
45
45
  * Indicates if the message has media available for download
46
46
  * @type {boolean}
47
47
  */
48
- this.hasMedia = Boolean(data.mediaKey && data.directPath);
48
+ this.hasMedia = Boolean(data.directPath);
49
49
 
50
50
  /**
51
51
  * Message content
@@ -186,26 +186,16 @@ class Message extends Base {
186
186
  toId: typeof data.to === 'object' && '_serialized' in data.to ? data.to._serialized : data.to
187
187
  } : undefined;
188
188
 
189
- /**
190
- * @typedef {Object} Mention
191
- * @property {string} server
192
- * @property {string} user
193
- * @property {string} _serialized
194
- */
195
-
196
189
  /**
197
190
  * Indicates the mentions in the message body.
198
- * @type {Mention[]}
191
+ * @type {string[]}
199
192
  */
200
193
  this.mentionedIds = data.mentionedJidList || [];
201
194
 
202
195
  /**
203
196
  * @typedef {Object} GroupMention
204
197
  * @property {string} groupSubject The name of the group
205
- * @property {Object} groupJid The group ID
206
- * @property {string} groupJid.server
207
- * @property {string} groupJid.user
208
- * @property {string} groupJid._serialized
198
+ * @property {string} groupJid The group ID
209
199
  */
210
200
 
211
201
  /**
@@ -498,23 +488,26 @@ class Message extends Base {
498
488
  /**
499
489
  * Deletes a message from the chat
500
490
  * @param {?boolean} everyone If true and the message is sent by the current user or the user is an admin, will delete it for everyone in the chat.
491
+ * @param {?boolean} [clearMedia = true] If true, any associated media will also be deleted from a device.
501
492
  */
502
- async delete(everyone) {
503
- await this.client.pupPage.evaluate(async (msgId, everyone) => {
493
+ async delete(everyone, clearMedia = true) {
494
+ await this.client.pupPage.evaluate(async (msgId, everyone, clearMedia) => {
504
495
  const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
505
- let chat = await window.Store.Chat.find(msg.id.remote);
496
+ const chat = window.Store.Chat.get(msg.id.remote) || (await window.Store.Chat.find(msg.id.remote));
506
497
 
507
- const canRevoke = window.Store.MsgActionChecks.canSenderRevokeMsg(msg) || window.Store.MsgActionChecks.canAdminRevokeMsg(msg);
498
+ const canRevoke =
499
+ window.Store.MsgActionChecks.canSenderRevokeMsg(msg) || window.Store.MsgActionChecks.canAdminRevokeMsg(msg);
500
+
508
501
  if (everyone && canRevoke) {
509
- if (window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')) {
510
- return window.Store.Cmd.sendRevokeMsgs(chat, { list: [msg], type: 'message' }, { clearMedia: true });
511
- } else {
512
- return window.Store.Cmd.sendRevokeMsgs(chat, [msg], { clearMedia: true, type: msg.id.fromMe ? 'Sender' : 'Admin' });
513
- }
502
+ return window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')
503
+ ? window.Store.Cmd.sendRevokeMsgs(chat, { list: [msg], type: 'message' }, { clearMedia: clearMedia })
504
+ : window.Store.Cmd.sendRevokeMsgs(chat, [msg], { clearMedia: true, type: msg.id.fromMe ? 'Sender' : 'Admin' });
514
505
  }
515
506
 
516
- return window.Store.Cmd.sendDeleteMsgs(chat, [msg], true);
517
- }, this.id._serialized, everyone);
507
+ return window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')
508
+ ? window.Store.Cmd.sendDeleteMsgs(chat, { list: [msg], type: 'message' }, clearMedia)
509
+ : window.Store.Cmd.sendDeleteMsgs(chat, [msg], clearMedia);
510
+ }, this.id._serialized, everyone, clearMedia);
518
511
  }
519
512
 
520
513
  /**
@@ -5,6 +5,7 @@ module.exports = {
5
5
  ClientInfo: require('./ClientInfo'),
6
6
  Contact: require('./Contact'),
7
7
  GroupChat: require('./GroupChat'),
8
+ Channel: require('./Channel'),
8
9
  Location: require('./Location'),
9
10
  Message: require('./Message'),
10
11
  MessageMedia: require('./MessageMedia'),
@@ -20,5 +21,6 @@ module.exports = {
20
21
  Payment: require('./Payment'),
21
22
  Reaction: require('./Reaction'),
22
23
  Poll: require('./Poll'),
23
- PollVote: require('./PollVote')
24
+ PollVote: require('./PollVote'),
25
+ Broadcast: require('./Broadcast')
24
26
  };
@@ -7,7 +7,7 @@ exports.DefaultOptions = {
7
7
  headless: true,
8
8
  defaultViewport: null
9
9
  },
10
- webVersion: '2.3000.1016590837',
10
+ webVersion: '2.3000.1017054665',
11
11
  webVersionCache: {
12
12
  type: 'local',
13
13
  },
@@ -55,7 +55,6 @@ exports.ExposeStore = () => {
55
55
  window.Store.MediaTypes = window.require('WAWebMmsMediaTypes');
56
56
  window.Store.MediaUpload = window.require('WAWebMediaMmsV4Upload');
57
57
  window.Store.MsgKey = window.require('WAWebMsgKey');
58
- window.Store.NumberInfo = window.require('WAPhoneUtils');
59
58
  window.Store.OpaqueData = window.require('WAWebMediaOpaqueData');
60
59
  window.Store.QueryProduct = window.require('WAWebBizProductCatalogBridge');
61
60
  window.Store.QueryOrder = window.require('WAWebBizOrderBridge');
@@ -66,10 +65,8 @@ exports.ExposeStore = () => {
66
65
  window.Store.SendSeen = window.require('WAWebUpdateUnreadChatAction');
67
66
  window.Store.User = window.require('WAWebUserPrefsMeUser');
68
67
  window.Store.ContactMethods = window.require('WAWebContactGetters');
69
- window.Store.UploadUtils = window.require('WAWebUploadManager');
70
68
  window.Store.UserConstructor = window.require('WAWebWid');
71
69
  window.Store.Validators = window.require('WALinkify');
72
- window.Store.VCard = window.require('WAWebFrontendVcardUtils');
73
70
  window.Store.WidFactory = window.require('WAWebWidFactory');
74
71
  window.Store.ProfilePic = window.require('WAWebContactProfilePicThumbBridge');
75
72
  window.Store.PresenceUtils = window.require('WAWebPresenceChatAction');
@@ -85,7 +82,7 @@ exports.ExposeStore = () => {
85
82
  window.Store.LinkPreview = window.require('WAWebLinkPreviewChatAction');
86
83
  window.Store.Socket = window.require('WADeprecatedSendIq');
87
84
  window.Store.SocketWap = window.require('WAWap');
88
- window.Store.SearchContext = window.require('WAWebChatMessageSearch').getSearchContext;
85
+ window.Store.SearchContext = window.require('WAWebChatMessageSearch');
89
86
  window.Store.DrawerManager = window.require('WAWebDrawerManager').DrawerManager;
90
87
  window.Store.LidUtils = window.require('WAWebApiContact');
91
88
  window.Store.WidToJid = window.require('WAWebWidToJid');
@@ -94,17 +91,32 @@ exports.ExposeStore = () => {
94
91
  window.Store.pinUnpinMsg = window.require('WAWebSendPinMessageAction').sendPinInChatMsg;
95
92
  window.Store.QueryExist = window.require('WAWebQueryExistsJob').queryWidExists;
96
93
  window.Store.ReplyUtils = window.require('WAWebMsgReply');
97
- window.Store.Settings = window.require('WAWebUserPrefsGeneral');
98
94
  window.Store.BotSecret = window.require('WAWebBotMessageSecret');
99
95
  window.Store.BotProfiles = window.require('WAWebBotProfileCollection');
96
+ window.Store.ContactCollection = window.require('WAWebContactCollection').ContactCollection;
100
97
  window.Store.DeviceList = window.require('WAWebApiDeviceList');
101
- if (window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.1014111620'))
102
- window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
98
+ window.Store.HistorySync = window.require('WAWebSendNonMessageDataRequest');
99
+ window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
100
+ window.Store.ChatGetters = window.require('WAWebChatGetters');
101
+ window.Store.UploadUtils = window.require('WAWebUploadManager');
103
102
 
103
+ window.Store.Settings = {
104
+ ...window.require('WAWebUserPrefsGeneral'),
105
+ ...window.require('WAWebUserPrefsNotifications'),
106
+ setPushname: window.require('WAWebSetPushnameConnAction').setPushname
107
+ };
108
+ window.Store.NumberInfo = {
109
+ ...window.require('WAPhoneUtils'),
110
+ ...window.require('WAPhoneFindCC')
111
+ };
104
112
  window.Store.ForwardUtils = {
105
113
  ...window.require('WAWebForwardMessagesToChat')
106
114
  };
107
-
115
+ window.Store.VCard = {
116
+ ...window.require('WAWebFrontendVcardUtils'),
117
+ ...window.require('WAWebVcardParsingUtils'),
118
+ ...window.require('WAWebVcardGetNameFromParsed')
119
+ };
108
120
  window.Store.StickerTools = {
109
121
  ...window.require('WAWebImageUtils'),
110
122
  ...window.require('WAWebAddWebpMetadata')
@@ -121,7 +133,8 @@ exports.ExposeStore = () => {
121
133
  };
122
134
  window.Store.GroupInvite = {
123
135
  ...window.require('WAWebGroupInviteJob'),
124
- ...window.require('WAWebGroupQueryJob')
136
+ ...window.require('WAWebGroupQueryJob'),
137
+ ...window.require('WAWebMexFetchGroupInviteCodeJob')
125
138
  };
126
139
  window.Store.GroupInviteV4 = {
127
140
  ...window.require('WAWebGroupInviteV4Job'),
@@ -131,6 +144,41 @@ exports.ExposeStore = () => {
131
144
  ...window.require('WAWebApiMembershipApprovalRequestStore'),
132
145
  ...window.require('WASmaxGroupsMembershipRequestsActionRPC')
133
146
  };
147
+ window.Store.ChannelUtils = {
148
+ ...window.require('WAWebLoadNewsletterPreviewChatAction'),
149
+ ...window.require('WAWebNewsletterMetadataQueryJob'),
150
+ ...window.require('WAWebNewsletterCreateQueryJob'),
151
+ ...window.require('WAWebEditNewsletterMetadataAction'),
152
+ ...window.require('WAWebNewsletterDeleteAction'),
153
+ ...window.require('WAWebNewsletterSubscribeAction'),
154
+ ...window.require('WAWebNewsletterUnsubscribeAction'),
155
+ ...window.require('WAWebNewsletterDirectorySearchAction'),
156
+ ...window.require('WAWebNewsletterToggleMuteStateJob'),
157
+ ...window.require('WAWebNewsletterGatingUtils'),
158
+ ...window.require('WAWebNewsletterModelUtils'),
159
+ ...window.require('WAWebMexAcceptNewsletterAdminInviteJob'),
160
+ ...window.require('WAWebMexRevokeNewsletterAdminInviteJob'),
161
+ ...window.require('WAWebChangeNewsletterOwnerAction'),
162
+ ...window.require('WAWebDemoteNewsletterAdminAction'),
163
+ ...window.require('WAWebNewsletterDemoteAdminJob'),
164
+ countryCodesIso: window.require('WAWebCountriesNativeCountryNames'),
165
+ currentRegion: window.require('WAWebL10N').getRegion(),
166
+ };
167
+ window.Store.SendChannelMessage = {
168
+ ...window.require('WAWebNewsletterUpdateMsgsRecordsJob'),
169
+ ...window.require('WAWebMsgDataFromModel'),
170
+ ...window.require('WAWebNewsletterSendMessageJob'),
171
+ ...window.require('WAWebNewsletterSendMsgAction'),
172
+ ...window.require('WAMediaCalculateFilehash')
173
+ };
174
+ window.Store.ChannelSubscribers = {
175
+ ...window.require('WAWebMexFetchNewsletterSubscribersJob'),
176
+ ...window.require('WAWebNewsletterSubscriberListAction')
177
+ };
178
+ window.Store.AddressbookContactUtils = {
179
+ ...window.require('WAWebSaveContactAction'),
180
+ ...window.require('WAWebDeleteContactAction')
181
+ };
134
182
 
135
183
  if (!window.Store.Chat._find || !window.Store.Chat.findImpl) {
136
184
  window.Store.Chat._find = e => {