whatsapp-web.js 1.24.0 → 1.26.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.
@@ -44,7 +44,10 @@ class LocalAuth extends BaseAuthStrategy {
44
44
 
45
45
  async logout() {
46
46
  if (this.userDataDir) {
47
- return (fs.rmSync ? fs.rmSync : fs.rmdirSync).call(this, this.userDataDir, { recursive: true, force: true });
47
+ await fs.promises.rm(this.userDataDir, { recursive: true, force: true })
48
+ .catch((e) => {
49
+ throw new Error(e);
50
+ });
48
51
  }
49
52
  }
50
53
 
@@ -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.GroupMetadata.queryAndUpdate(groupWid);
101
+ await window.Store.GroupQueryAndUpdate(groupWid);
102
102
  const groupMetadata = group.groupMetadata;
103
103
  const groupParticipants = groupMetadata?.participants;
104
104
 
@@ -152,7 +152,7 @@ class GroupChat extends Chat {
152
152
 
153
153
  if (autoSendInviteV4 && rpcResultCode === 403) {
154
154
  let userChat, isInviteV4Sent = false;
155
- window.Store.ContactCollection.gadd(pWid, { silent: true });
155
+ window.Store.Contact.gadd(pWid, { silent: true });
156
156
 
157
157
  if (rpcResult.name === 'ParticipantRequestCodeCanBeSent' &&
158
158
  (userChat = await window.Store.Chat.find(pWid))) {
@@ -380,10 +380,18 @@ class GroupChat extends Chat {
380
380
  async getInviteCode() {
381
381
  const codeRes = await this.client.pupPage.evaluate(async chatId => {
382
382
  const chatWid = window.Store.WidFactory.createWid(chatId);
383
- return window.Store.GroupInvite.queryGroupInviteCode(chatWid);
383
+ 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);
387
+ }
388
+ catch (err) {
389
+ if(err.name === 'ServerStatusCodeError') return undefined;
390
+ throw err;
391
+ }
384
392
  }, this.id._serialized);
385
393
 
386
- return codeRes.code;
394
+ return codeRes?.code;
387
395
  }
388
396
 
389
397
  /**
@@ -182,8 +182,8 @@ class Message extends Base {
182
182
  inviteCodeExp: data.inviteCodeExp,
183
183
  groupId: data.inviteGrp,
184
184
  groupName: data.inviteGrpName,
185
- fromId: '_serialized' in data.from ? data.from._serialized : data.from,
186
- toId: '_serialized' in data.to ? data.to._serialized : data.to
185
+ fromId: typeof data.from === 'object' && '_serialized' in data.from ? data.from._serialized : data.from,
186
+ toId: typeof data.to === 'object' && '_serialized' in data.to ? data.to._serialized : data.to
187
187
  } : undefined;
188
188
 
189
189
  /**
@@ -311,9 +311,9 @@ class Message extends Base {
311
311
  * @returns {Promise<Message>}
312
312
  */
313
313
  async reload() {
314
- const newData = await this.client.pupPage.evaluate((msgId) => {
315
- const msg = window.Store.Msg.get(msgId);
316
- if(!msg) return null;
314
+ const newData = await this.client.pupPage.evaluate(async (msgId) => {
315
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
316
+ if (!msg) return null;
317
317
  return window.WWebJS.getMessageModel(msg);
318
318
  }, this.id._serialized);
319
319
 
@@ -370,8 +370,8 @@ class Message extends Base {
370
370
  async getQuotedMessage() {
371
371
  if (!this.hasQuotedMsg) return undefined;
372
372
 
373
- const quotedMsg = await this.client.pupPage.evaluate((msgId) => {
374
- const msg = window.Store.Msg.get(msgId);
373
+ const quotedMsg = await this.client.pupPage.evaluate(async (msgId) => {
374
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
375
375
  const quotedMsg = window.Store.QuotedMsg.getQuotedMsgObj(msg);
376
376
  return window.WWebJS.getMessageModel(quotedMsg);
377
377
  }, this.id._serialized);
@@ -409,9 +409,10 @@ class Message extends Base {
409
409
  */
410
410
  async react(reaction){
411
411
  await this.client.pupPage.evaluate(async (messageId, reaction) => {
412
- if (!messageId) { return undefined; }
413
-
414
- const msg = await window.Store.Msg.get(messageId);
412
+ if (!messageId) return null;
413
+ const msg =
414
+ window.Store.Msg.get(messageId) || (await window.Store.Msg.getMessagesById([messageId]))?.messages?.[0];
415
+ if(!msg) return null;
415
416
  await window.Store.sendReactionToMsg(msg, reaction);
416
417
  }, this.id._serialized, reaction);
417
418
  }
@@ -434,10 +435,7 @@ class Message extends Base {
434
435
  const chatId = typeof chat === 'string' ? chat : chat.id._serialized;
435
436
 
436
437
  await this.client.pupPage.evaluate(async (msgId, chatId) => {
437
- let msg = window.Store.Msg.get(msgId);
438
- let chat = window.Store.Chat.get(chatId);
439
-
440
- return await chat.forwardMessages([msg]);
438
+ return window.WWebJS.forwardMessage(chatId, msgId);
441
439
  }, this.id._serialized, chatId);
442
440
  }
443
441
 
@@ -451,9 +449,9 @@ class Message extends Base {
451
449
  }
452
450
 
453
451
  const result = await this.client.pupPage.evaluate(async (msgId) => {
454
- const msg = window.Store.Msg.get(msgId);
452
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
455
453
  if (!msg || !msg.mediaData) {
456
- return undefined;
454
+ return null;
457
455
  }
458
456
  if (msg.mediaData.mediaStage != 'RESOLVED') {
459
457
  // try to resolve media
@@ -503,12 +501,16 @@ class Message extends Base {
503
501
  */
504
502
  async delete(everyone) {
505
503
  await this.client.pupPage.evaluate(async (msgId, everyone) => {
506
- let msg = window.Store.Msg.get(msgId);
504
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
507
505
  let chat = await window.Store.Chat.find(msg.id.remote);
508
506
 
509
507
  const canRevoke = window.Store.MsgActionChecks.canSenderRevokeMsg(msg) || window.Store.MsgActionChecks.canAdminRevokeMsg(msg);
510
508
  if (everyone && canRevoke) {
511
- return window.Store.Cmd.sendRevokeMsgs(chat, [msg], { clearMedia: true, type: msg.id.fromMe ? 'Sender' : 'Admin' });
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
+ }
512
514
  }
513
515
 
514
516
  return window.Store.Cmd.sendDeleteMsgs(chat, [msg], true);
@@ -520,8 +522,7 @@ class Message extends Base {
520
522
  */
521
523
  async star() {
522
524
  await this.client.pupPage.evaluate(async (msgId) => {
523
- let msg = window.Store.Msg.get(msgId);
524
-
525
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
525
526
  if (window.Store.MsgActionChecks.canStarMsg(msg)) {
526
527
  let chat = await window.Store.Chat.find(msg.id.remote);
527
528
  return window.Store.Cmd.sendStarMsgs(chat, [msg], false);
@@ -534,8 +535,7 @@ class Message extends Base {
534
535
  */
535
536
  async unstar() {
536
537
  await this.client.pupPage.evaluate(async (msgId) => {
537
- let msg = window.Store.Msg.get(msgId);
538
-
538
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
539
539
  if (window.Store.MsgActionChecks.canStarMsg(msg)) {
540
540
  let chat = await window.Store.Chat.find(msg.id.remote);
541
541
  return window.Store.Cmd.sendUnstarMsgs(chat, [msg], false);
@@ -582,7 +582,7 @@ class Message extends Base {
582
582
  */
583
583
  async getInfo() {
584
584
  const info = await this.client.pupPage.evaluate(async (msgId) => {
585
- const msg = window.Store.Msg.get(msgId);
585
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
586
586
  if (!msg || !msg.id.fromMe) return null;
587
587
 
588
588
  return new Promise((resolve) => {
@@ -616,7 +616,7 @@ class Message extends Base {
616
616
  async getPayment() {
617
617
  if (this.type === MessageTypes.PAYMENT) {
618
618
  const msg = await this.client.pupPage.evaluate(async (msgId) => {
619
- const msg = window.Store.Msg.get(msgId);
619
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
620
620
  if(!msg) return null;
621
621
  return msg.serialize();
622
622
  }, this.id._serialized);
@@ -691,11 +691,11 @@ class Message extends Base {
691
691
  return null;
692
692
  }
693
693
  const messageEdit = await this.client.pupPage.evaluate(async (msgId, message, options) => {
694
- let msg = window.Store.Msg.get(msgId);
694
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
695
695
  if (!msg) return null;
696
696
 
697
- let catEdit = window.Store.MsgActionChecks.canEditText(msg) || window.Store.MsgActionChecks.canEditCaption(msg);
698
- if (catEdit) {
697
+ let canEdit = window.Store.MsgActionChecks.canEditText(msg) || window.Store.MsgActionChecks.canEditCaption(msg);
698
+ if (canEdit) {
699
699
  const msgEdit = await window.WWebJS.editMessage(msg, message, options);
700
700
  return msgEdit.serialize();
701
701
  }
@@ -7,7 +7,7 @@ exports.DefaultOptions = {
7
7
  headless: true,
8
8
  defaultViewport: null
9
9
  },
10
- webVersion: '2.2346.52',
10
+ webVersion: '2.3000.1016590837',
11
11
  webVersionCache: {
12
12
  type: 'local',
13
13
  },
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ exports.ExposeAuthStore = () => {
4
+ window.AuthStore = {};
5
+ window.AuthStore.AppState = window.require('WAWebSocketModel').Socket;
6
+ window.AuthStore.Cmd = window.require('WAWebCmd').Cmd;
7
+ window.AuthStore.Conn = window.require('WAWebConnModel').Conn;
8
+ window.AuthStore.OfflineMessageHandler = window.require('WAWebOfflineHandler').OfflineMessageHandler;
9
+ window.AuthStore.PairingCodeLinkUtils = window.require('WAWebAltDeviceLinkingApi');
10
+ window.AuthStore.Base64Tools = window.require('WABase64');
11
+ window.AuthStore.RegistrationUtils = {
12
+ ...window.require('WAWebCompanionRegClientUtils'),
13
+ ...window.require('WAWebAdvSignatureApi'),
14
+ ...window.require('WAWebUserPrefsInfoStore'),
15
+ ...window.require('WAWebSignalStoreApi'),
16
+ };
17
+ };
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ //TODO: To be removed by version 2.3000.x hard release
4
+
5
+ exports.ExposeLegacyAuthStore = (moduleRaidStr) => {
6
+ eval('var moduleRaid = ' + moduleRaidStr);
7
+ // eslint-disable-next-line no-undef
8
+ window.mR = moduleRaid();
9
+ window.AuthStore = {};
10
+ window.AuthStore.AppState = window.mR.findModule('Socket')[0].Socket;
11
+ window.AuthStore.Cmd = window.mR.findModule('Cmd')[0].Cmd;
12
+ window.AuthStore.Conn = window.mR.findModule('Conn')[0].Conn;
13
+ window.AuthStore.OfflineMessageHandler = window.mR.findModule('OfflineMessageHandler')[0].OfflineMessageHandler;
14
+ window.AuthStore.PairingCodeLinkUtils = window.mR.findModule('initializeAltDeviceLinking')[0];
15
+ window.AuthStore.Base64Tools = window.mR.findModule('encodeB64')[0];
16
+ window.AuthStore.RegistrationUtils = {
17
+ ...window.mR.findModule('getCompanionWebClientFromBrowser')[0],
18
+ ...window.mR.findModule('verifyKeyIndexListAccountSignature')[0],
19
+ ...window.mR.findModule('waNoiseInfo')[0],
20
+ ...window.mR.findModule('waSignalStore')[0],
21
+ };
22
+ };
@@ -0,0 +1,146 @@
1
+ 'use strict';
2
+
3
+ //TODO: To be removed by version 2.3000.x hard release
4
+
5
+ // Exposes the internal Store to the WhatsApp Web client
6
+ exports.ExposeLegacyStore = () => {
7
+ window.Store = Object.assign({}, window.mR.findModule(m => m.default && m.default.Chat)[0].default);
8
+ window.Store.AppState = window.mR.findModule('Socket')[0].Socket;
9
+ window.Store.Conn = window.mR.findModule('Conn')[0].Conn;
10
+ window.Store.BlockContact = window.mR.findModule('blockContact')[0];
11
+ window.Store.Call = window.mR.findModule((module) => module.default && module.default.Call)[0].default.Call;
12
+ window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
13
+ window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
14
+ window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;
15
+ window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].default.GroupMetadata;
16
+ window.Store.GroupQueryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;
17
+ window.Store.Label = window.mR.findModule('LabelCollection')[0].LabelCollection;
18
+ window.Store.MediaPrep = window.mR.findModule('prepRawMedia')[0];
19
+ window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
20
+ window.Store.NumberInfo = window.mR.findModule('formattedPhoneNumber')[0];
21
+ window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
22
+ window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
23
+ window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
24
+ window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
25
+ window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
26
+ window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
27
+ window.Store.SendClear = window.mR.findModule('sendClear')[0];
28
+ window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
29
+ window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
30
+ window.Store.EditMessage = window.mR.findModule('addAndSendMessageEdit')[0];
31
+ window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
32
+ window.Store.User = window.mR.findModule('getMaybeMeUser')[0];
33
+ window.Store.ContactMethods = window.mR.findModule('getUserid')[0];
34
+ window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
35
+ window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
36
+ window.Store.Validators = window.mR.findModule('findLinks')[0];
37
+ window.Store.VCard = window.mR.findModule('vcardFromContactModel')[0];
38
+ window.Store.WidFactory = window.mR.findModule('createWid')[0];
39
+ window.Store.ProfilePic = window.mR.findModule('profilePicResync')[0];
40
+ window.Store.PresenceUtils = window.mR.findModule('sendPresenceAvailable')[0];
41
+ window.Store.ChatState = window.mR.findModule('sendChatStateComposing')[0];
42
+ window.Store.findCommonGroups = window.mR.findModule('findCommonGroups')[0].findCommonGroups;
43
+ window.Store.StatusUtils = window.mR.findModule('setMyStatus')[0];
44
+ window.Store.ConversationMsgs = window.mR.findModule('loadEarlierMsgs')[0];
45
+ window.Store.sendReactionToMsg = window.mR.findModule('sendReactionToMsg')[0].sendReactionToMsg;
46
+ window.Store.createOrUpdateReactionsModule = window.mR.findModule('createOrUpdateReactions')[0];
47
+ window.Store.EphemeralFields = window.mR.findModule('getEphemeralFields')[0];
48
+ window.Store.MsgActionChecks = window.mR.findModule('canSenderRevokeMsg')[0];
49
+ window.Store.QuotedMsg = window.mR.findModule('getQuotedMsgObj')[0];
50
+ window.Store.LinkPreview = window.mR.findModule('getLinkPreview')[0];
51
+ window.Store.Socket = window.mR.findModule('deprecatedSendIq')[0];
52
+ window.Store.SocketWap = window.mR.findModule('wap')[0];
53
+ window.Store.SearchContext = window.mR.findModule('getSearchContext')[0].getSearchContext;
54
+ window.Store.DrawerManager = window.mR.findModule('DrawerManager')[0].DrawerManager;
55
+ window.Store.LidUtils = window.mR.findModule('getCurrentLid')[0];
56
+ window.Store.WidToJid = window.mR.findModule('widToUserJid')[0];
57
+ window.Store.JidToWid = window.mR.findModule('userJidToUserWid')[0];
58
+ window.Store.getMsgInfo = (window.mR.findModule('sendQueryMsgInfo')[0] || {}).sendQueryMsgInfo || window.mR.findModule('queryMsgInfo')[0].queryMsgInfo;
59
+ window.Store.pinUnpinMsg = window.mR.findModule('sendPinInChatMsg')[0].sendPinInChatMsg;
60
+
61
+ /* eslint-disable no-undef, no-cond-assign */
62
+ window.Store.QueryExist = ((m = window.mR.findModule('queryExists')[0]) ? m.queryExists : window.mR.findModule('queryExist')[0].queryWidExists);
63
+ window.Store.ReplyUtils = (m = window.mR.findModule('canReplyMsg')).length > 0 && m[0];
64
+ /* eslint-enable no-undef, no-cond-assign */
65
+
66
+ window.Store.Settings = {
67
+ ...window.mR.findModule('ChatlistPanelState')[0],
68
+ setPushname: window.mR.findModule((m) => m.setPushname && !m.ChatlistPanelState)[0].setPushname
69
+ };
70
+ window.Store.StickerTools = {
71
+ ...window.mR.findModule('toWebpSticker')[0],
72
+ ...window.mR.findModule('addWebpMetadata')[0]
73
+ };
74
+ window.Store.GroupUtils = {
75
+ ...window.mR.findModule('createGroup')[0],
76
+ ...window.mR.findModule('setGroupDescription')[0],
77
+ ...window.mR.findModule('sendExitGroup')[0],
78
+ ...window.mR.findModule('sendSetPicture')[0]
79
+ };
80
+ window.Store.GroupParticipants = {
81
+ ...window.mR.findModule('promoteParticipants')[0],
82
+ ...window.mR.findModule('sendAddParticipantsRPC')[0]
83
+ };
84
+ window.Store.GroupInvite = {
85
+ ...window.mR.findModule('resetGroupInviteCode')[0],
86
+ ...window.mR.findModule('queryGroupInvite')[0]
87
+ };
88
+ window.Store.GroupInviteV4 = {
89
+ ...window.mR.findModule('queryGroupInviteV4')[0],
90
+ ...window.mR.findModule('sendGroupInviteMessage')[0]
91
+ };
92
+ window.Store.MembershipRequestUtils = {
93
+ ...window.mR.findModule('getMembershipApprovalRequests')[0],
94
+ ...window.mR.findModule('sendMembershipRequestsActionRPC')[0]
95
+ };
96
+
97
+ if (!window.Store.Chat._find) {
98
+ window.Store.Chat._find = e => {
99
+ const target = window.Store.Chat.get(e);
100
+ return target ? Promise.resolve(target) : Promise.resolve({
101
+ id: e
102
+ });
103
+ };
104
+ }
105
+
106
+ // eslint-disable-next-line no-undef
107
+ if ((m = window.mR.findModule('ChatCollection')[0]) && m.ChatCollection && typeof m.ChatCollection.findImpl === 'undefined' && typeof m.ChatCollection._find !== 'undefined') m.ChatCollection.findImpl = m.ChatCollection._find;
108
+
109
+ const _isMDBackend = window.mR.findModule('isMDBackend');
110
+ if(_isMDBackend && _isMDBackend[0] && _isMDBackend[0].isMDBackend) {
111
+ window.Store.MDBackend = _isMDBackend[0].isMDBackend();
112
+ } else {
113
+ window.Store.MDBackend = true;
114
+ }
115
+
116
+ const _features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0];
117
+ if(_features) {
118
+ window.Store.Features = _features.LegacyPhoneFeatures;
119
+ }
120
+
121
+ /**
122
+ * Target options object description
123
+ * @typedef {Object} TargetOptions
124
+ * @property {string|number} module The name or a key of the target module to search
125
+ * @property {number} index The index value of the target module
126
+ * @property {string} function The function name to get from a module
127
+ */
128
+
129
+ /**
130
+ * Function to modify functions
131
+ * @param {TargetOptions} target Options specifying the target function to search for modifying
132
+ * @param {Function} callback Modified function
133
+ */
134
+ window.injectToFunction = (target, callback) => {
135
+ const module = typeof target.module === 'string'
136
+ ? window.mR.findModule(target.module)
137
+ : window.mR.modules[target.module];
138
+ const originalFunction = module[target.index][target.function];
139
+ const modifiedFunction = (...args) => callback(originalFunction, ...args);
140
+ module[target.index][target.function] = modifiedFunction;
141
+ };
142
+
143
+ window.injectToFunction({ module: 'mediaTypeFromProtobuf', index: 0, function: 'mediaTypeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage ? null : func(...args); });
144
+
145
+ window.injectToFunction({ module: 'typeAttributeFromProtobuf', index: 0, function: 'typeAttributeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage || proto.groupInviteMessage ? 'text' : func(...args); });
146
+ };
@@ -0,0 +1,167 @@
1
+ 'use strict';
2
+
3
+ exports.ExposeStore = () => {
4
+ /**
5
+ * Helper function that compares between two WWeb versions. Its purpose is to help the developer to choose the correct code implementation depending on the comparison value and the WWeb version.
6
+ * @param {string} lOperand The left operand for the WWeb version string to compare with
7
+ * @param {string} operator The comparison operator
8
+ * @param {string} rOperand The right operand for the WWeb version string to compare with
9
+ * @returns {boolean} Boolean value that indicates the result of the comparison
10
+ */
11
+ window.compareWwebVersions = (lOperand, operator, rOperand) => {
12
+ if (!['>', '>=', '<', '<=', '='].includes(operator)) {
13
+ throw new class _ extends Error {
14
+ constructor(m) { super(m); this.name = 'CompareWwebVersionsError'; }
15
+ }('Invalid comparison operator is provided');
16
+
17
+ }
18
+ if (typeof lOperand !== 'string' || typeof rOperand !== 'string') {
19
+ throw new class _ extends Error {
20
+ constructor(m) { super(m); this.name = 'CompareWwebVersionsError'; }
21
+ }('A non-string WWeb version type is provided');
22
+ }
23
+
24
+ lOperand = lOperand.replace(/-beta$/, '');
25
+ rOperand = rOperand.replace(/-beta$/, '');
26
+
27
+ while (lOperand.length !== rOperand.length) {
28
+ lOperand.length > rOperand.length
29
+ ? rOperand = rOperand.concat('0')
30
+ : lOperand = lOperand.concat('0');
31
+ }
32
+
33
+ lOperand = Number(lOperand.replace(/\./g, ''));
34
+ rOperand = Number(rOperand.replace(/\./g, ''));
35
+
36
+ return (
37
+ operator === '>' ? lOperand > rOperand :
38
+ operator === '>=' ? lOperand >= rOperand :
39
+ operator === '<' ? lOperand < rOperand :
40
+ operator === '<=' ? lOperand <= rOperand :
41
+ operator === '=' ? lOperand === rOperand :
42
+ false
43
+ );
44
+ };
45
+
46
+ window.Store = Object.assign({}, window.require('WAWebCollections'));
47
+ window.Store.AppState = window.require('WAWebSocketModel').Socket;
48
+ window.Store.BlockContact = window.require('WAWebBlockContactAction');
49
+ window.Store.Conn = window.require('WAWebConnModel').Conn;
50
+ window.Store.Cmd = window.require('WAWebCmd').Cmd;
51
+ window.Store.DownloadManager = window.require('WAWebDownloadManager').downloadManager;
52
+ window.Store.GroupQueryAndUpdate = window.require('WAWebGroupQueryJob').queryAndUpdateGroupMetadataById;
53
+ window.Store.MediaPrep = window.require('WAWebPrepRawMedia');
54
+ window.Store.MediaObject = window.require('WAWebMediaStorage');
55
+ window.Store.MediaTypes = window.require('WAWebMmsMediaTypes');
56
+ window.Store.MediaUpload = window.require('WAWebMediaMmsV4Upload');
57
+ window.Store.MsgKey = window.require('WAWebMsgKey');
58
+ window.Store.NumberInfo = window.require('WAPhoneUtils');
59
+ window.Store.OpaqueData = window.require('WAWebMediaOpaqueData');
60
+ window.Store.QueryProduct = window.require('WAWebBizProductCatalogBridge');
61
+ window.Store.QueryOrder = window.require('WAWebBizOrderBridge');
62
+ window.Store.SendClear = window.require('WAWebChatClearBridge');
63
+ window.Store.SendDelete = window.require('WAWebDeleteChatAction');
64
+ window.Store.SendMessage = window.require('WAWebSendMsgChatAction');
65
+ window.Store.EditMessage = window.require('WAWebSendMessageEditAction');
66
+ window.Store.SendSeen = window.require('WAWebUpdateUnreadChatAction');
67
+ window.Store.User = window.require('WAWebUserPrefsMeUser');
68
+ window.Store.ContactMethods = window.require('WAWebContactGetters');
69
+ window.Store.UploadUtils = window.require('WAWebUploadManager');
70
+ window.Store.UserConstructor = window.require('WAWebWid');
71
+ window.Store.Validators = window.require('WALinkify');
72
+ window.Store.VCard = window.require('WAWebFrontendVcardUtils');
73
+ window.Store.WidFactory = window.require('WAWebWidFactory');
74
+ window.Store.ProfilePic = window.require('WAWebContactProfilePicThumbBridge');
75
+ window.Store.PresenceUtils = window.require('WAWebPresenceChatAction');
76
+ window.Store.ChatState = window.require('WAWebChatStateBridge');
77
+ window.Store.findCommonGroups = window.require('WAWebFindCommonGroupsContactAction').findCommonGroups;
78
+ window.Store.StatusUtils = window.require('WAWebContactStatusBridge');
79
+ window.Store.ConversationMsgs = window.require('WAWebChatLoadMessages');
80
+ window.Store.sendReactionToMsg = window.require('WAWebSendReactionMsgAction').sendReactionToMsg;
81
+ window.Store.createOrUpdateReactionsModule = window.require('WAWebDBCreateOrUpdateReactions');
82
+ window.Store.EphemeralFields = window.require('WAWebGetEphemeralFieldsMsgActionsUtils');
83
+ window.Store.MsgActionChecks = window.require('WAWebMsgActionCapability');
84
+ window.Store.QuotedMsg = window.require('WAWebQuotedMsgModelUtils');
85
+ window.Store.LinkPreview = window.require('WAWebLinkPreviewChatAction');
86
+ window.Store.Socket = window.require('WADeprecatedSendIq');
87
+ window.Store.SocketWap = window.require('WAWap');
88
+ window.Store.SearchContext = window.require('WAWebChatMessageSearch').getSearchContext;
89
+ window.Store.DrawerManager = window.require('WAWebDrawerManager').DrawerManager;
90
+ window.Store.LidUtils = window.require('WAWebApiContact');
91
+ window.Store.WidToJid = window.require('WAWebWidToJid');
92
+ window.Store.JidToWid = window.require('WAWebJidToWid');
93
+ window.Store.getMsgInfo = window.require('WAWebApiMessageInfoStore').queryMsgInfo;
94
+ window.Store.pinUnpinMsg = window.require('WAWebSendPinMessageAction').sendPinInChatMsg;
95
+ window.Store.QueryExist = window.require('WAWebQueryExistsJob').queryWidExists;
96
+ window.Store.ReplyUtils = window.require('WAWebMsgReply');
97
+ window.Store.Settings = window.require('WAWebUserPrefsGeneral');
98
+ window.Store.BotSecret = window.require('WAWebBotMessageSecret');
99
+ window.Store.BotProfiles = window.require('WAWebBotProfileCollection');
100
+ window.Store.DeviceList = window.require('WAWebApiDeviceList');
101
+ if (window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.1014111620'))
102
+ window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
103
+
104
+ window.Store.ForwardUtils = {
105
+ ...window.require('WAWebForwardMessagesToChat')
106
+ };
107
+
108
+ window.Store.StickerTools = {
109
+ ...window.require('WAWebImageUtils'),
110
+ ...window.require('WAWebAddWebpMetadata')
111
+ };
112
+ window.Store.GroupUtils = {
113
+ ...window.require('WAWebGroupCreateJob'),
114
+ ...window.require('WAWebGroupModifyInfoJob'),
115
+ ...window.require('WAWebExitGroupAction'),
116
+ ...window.require('WAWebContactProfilePicThumbBridge')
117
+ };
118
+ window.Store.GroupParticipants = {
119
+ ...window.require('WAWebModifyParticipantsGroupAction'),
120
+ ...window.require('WASmaxGroupsAddParticipantsRPC')
121
+ };
122
+ window.Store.GroupInvite = {
123
+ ...window.require('WAWebGroupInviteJob'),
124
+ ...window.require('WAWebGroupQueryJob')
125
+ };
126
+ window.Store.GroupInviteV4 = {
127
+ ...window.require('WAWebGroupInviteV4Job'),
128
+ ...window.require('WAWebChatSendMessages')
129
+ };
130
+ window.Store.MembershipRequestUtils = {
131
+ ...window.require('WAWebApiMembershipApprovalRequestStore'),
132
+ ...window.require('WASmaxGroupsMembershipRequestsActionRPC')
133
+ };
134
+
135
+ if (!window.Store.Chat._find || !window.Store.Chat.findImpl) {
136
+ window.Store.Chat._find = e => {
137
+ const target = window.Store.Chat.get(e);
138
+ return target ? Promise.resolve(target) : Promise.resolve({
139
+ id: e
140
+ });
141
+ };
142
+ window.Store.Chat.findImpl = window.Store.Chat._find;
143
+ }
144
+
145
+ /**
146
+ * Target options object description
147
+ * @typedef {Object} TargetOptions
148
+ * @property {string|number} module The target module
149
+ * @property {string} function The function name to get from a module
150
+ */
151
+ /**
152
+ * Function to modify functions
153
+ * @param {TargetOptions} target Options specifying the target function to search for modifying
154
+ * @param {Function} callback Modified function
155
+ */
156
+ window.injectToFunction = (target, callback) => {
157
+ const module = window.require(target.module);
158
+ const originalFunction = module[target.function];
159
+ const modifiedFunction = (...args) => callback(originalFunction, ...args);
160
+ module[target.function] = modifiedFunction;
161
+ };
162
+
163
+ window.injectToFunction({ module: 'WAWebBackendJobsCommon', function: 'mediaTypeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage ? null : func(...args); });
164
+
165
+ window.injectToFunction({ module: 'WAWebE2EProtoUtils', function: 'typeAttributeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage || proto.groupInviteMessage ? 'text' : func(...args); });
166
+
167
+ };