@pney/whatsapp-web 1.34.2

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 (56) hide show
  1. package/.env.example +3 -0
  2. package/CODE_OF_CONDUCT.md +133 -0
  3. package/LICENSE +201 -0
  4. package/README.md +155 -0
  5. package/example.js +699 -0
  6. package/index.d.ts +2248 -0
  7. package/index.js +35 -0
  8. package/package.json +63 -0
  9. package/shell.js +36 -0
  10. package/src/Client.js +2447 -0
  11. package/src/authStrategies/BaseAuthStrategy.js +27 -0
  12. package/src/authStrategies/LocalAuth.js +58 -0
  13. package/src/authStrategies/NoAuth.js +12 -0
  14. package/src/authStrategies/RemoteAuth.js +210 -0
  15. package/src/factories/ChatFactory.js +21 -0
  16. package/src/factories/ContactFactory.js +16 -0
  17. package/src/structures/Base.js +22 -0
  18. package/src/structures/Broadcast.js +69 -0
  19. package/src/structures/BusinessContact.js +21 -0
  20. package/src/structures/Buttons.js +82 -0
  21. package/src/structures/Call.js +76 -0
  22. package/src/structures/Channel.js +382 -0
  23. package/src/structures/Chat.js +329 -0
  24. package/src/structures/ClientInfo.js +71 -0
  25. package/src/structures/Contact.js +208 -0
  26. package/src/structures/GroupChat.js +485 -0
  27. package/src/structures/GroupNotification.js +104 -0
  28. package/src/structures/Label.js +50 -0
  29. package/src/structures/List.js +79 -0
  30. package/src/structures/Location.js +62 -0
  31. package/src/structures/Message.js +785 -0
  32. package/src/structures/MessageMedia.js +111 -0
  33. package/src/structures/Order.js +52 -0
  34. package/src/structures/Payment.js +79 -0
  35. package/src/structures/Poll.js +44 -0
  36. package/src/structures/PollVote.js +75 -0
  37. package/src/structures/PrivateChat.js +13 -0
  38. package/src/structures/PrivateContact.js +13 -0
  39. package/src/structures/Product.js +68 -0
  40. package/src/structures/ProductMetadata.js +25 -0
  41. package/src/structures/Reaction.js +69 -0
  42. package/src/structures/ScheduledEvent.js +71 -0
  43. package/src/structures/index.js +27 -0
  44. package/src/util/Constants.js +186 -0
  45. package/src/util/Injected/AuthStore/AuthStore.js +17 -0
  46. package/src/util/Injected/AuthStore/LegacyAuthStore.js +22 -0
  47. package/src/util/Injected/LegacyStore.js +146 -0
  48. package/src/util/Injected/Store.js +265 -0
  49. package/src/util/Injected/Utils.js +1168 -0
  50. package/src/util/InterfaceController.js +126 -0
  51. package/src/util/Puppeteer.js +23 -0
  52. package/src/util/Util.js +186 -0
  53. package/src/webCache/LocalWebCache.js +40 -0
  54. package/src/webCache/RemoteWebCache.js +40 -0
  55. package/src/webCache/WebCache.js +14 -0
  56. package/src/webCache/WebCacheFactory.js +20 -0
@@ -0,0 +1,186 @@
1
+ 'use strict';
2
+
3
+ exports.WhatsWebURL = 'https://web.whatsapp.com/';
4
+
5
+ exports.DefaultOptions = {
6
+ puppeteer: {
7
+ headless: true,
8
+ defaultViewport: null
9
+ },
10
+ webVersion: '2.3000.1017054665',
11
+ webVersionCache: {
12
+ type: 'local',
13
+ },
14
+ authTimeoutMs: 0,
15
+ qrMaxRetries: 0,
16
+ takeoverOnConflict: false,
17
+ takeoverTimeoutMs: 0,
18
+ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36',
19
+ ffmpegPath: 'ffmpeg',
20
+ bypassCSP: false,
21
+ proxyAuthentication: undefined,
22
+ pairWithPhoneNumber: {
23
+ phoneNumber: '',
24
+ showNotification: true,
25
+ intervalMs: 180000,
26
+ },
27
+ };
28
+
29
+ /**
30
+ * Client status
31
+ * @readonly
32
+ * @enum {number}
33
+ */
34
+ exports.Status = {
35
+ INITIALIZING: 0,
36
+ AUTHENTICATING: 1,
37
+ READY: 3
38
+ };
39
+
40
+ /**
41
+ * Events that can be emitted by the client
42
+ * @readonly
43
+ * @enum {string}
44
+ */
45
+ exports.Events = {
46
+ AUTHENTICATED: 'authenticated',
47
+ AUTHENTICATION_FAILURE: 'auth_failure',
48
+ READY: 'ready',
49
+ CHAT_REMOVED: 'chat_removed',
50
+ CHAT_ARCHIVED: 'chat_archived',
51
+ MESSAGE_RECEIVED: 'message',
52
+ MESSAGE_CIPHERTEXT: 'message_ciphertext',
53
+ MESSAGE_CREATE: 'message_create',
54
+ MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
55
+ MESSAGE_REVOKED_ME: 'message_revoke_me',
56
+ MESSAGE_ACK: 'message_ack',
57
+ MESSAGE_EDIT: 'message_edit',
58
+ UNREAD_COUNT: 'unread_count',
59
+ MESSAGE_REACTION: 'message_reaction',
60
+ MEDIA_UPLOADED: 'media_uploaded',
61
+ CONTACT_CHANGED: 'contact_changed',
62
+ GROUP_JOIN: 'group_join',
63
+ GROUP_LEAVE: 'group_leave',
64
+ GROUP_ADMIN_CHANGED: 'group_admin_changed',
65
+ GROUP_MEMBERSHIP_REQUEST: 'group_membership_request',
66
+ GROUP_UPDATE: 'group_update',
67
+ QR_RECEIVED: 'qr',
68
+ CODE_RECEIVED: 'code',
69
+ LOADING_SCREEN: 'loading_screen',
70
+ DISCONNECTED: 'disconnected',
71
+ STATE_CHANGED: 'change_state',
72
+ BATTERY_CHANGED: 'change_battery',
73
+ INCOMING_CALL: 'call',
74
+ REMOTE_SESSION_SAVED: 'remote_session_saved',
75
+ VOTE_UPDATE: 'vote_update'
76
+ };
77
+
78
+ /**
79
+ * Message types
80
+ * @readonly
81
+ * @enum {string}
82
+ */
83
+ exports.MessageTypes = {
84
+ TEXT: 'chat',
85
+ AUDIO: 'audio',
86
+ VOICE: 'ptt',
87
+ IMAGE: 'image',
88
+ ALBUM: 'album',
89
+ VIDEO: 'video',
90
+ DOCUMENT: 'document',
91
+ STICKER: 'sticker',
92
+ LOCATION: 'location',
93
+ CONTACT_CARD: 'vcard',
94
+ CONTACT_CARD_MULTI: 'multi_vcard',
95
+ ORDER: 'order',
96
+ REVOKED: 'revoked',
97
+ PRODUCT: 'product',
98
+ UNKNOWN: 'unknown',
99
+ GROUP_INVITE: 'groups_v4_invite',
100
+ LIST: 'list',
101
+ LIST_RESPONSE: 'list_response',
102
+ BUTTONS_RESPONSE: 'buttons_response',
103
+ PAYMENT: 'payment',
104
+ BROADCAST_NOTIFICATION: 'broadcast_notification',
105
+ CALL_LOG: 'call_log',
106
+ CIPHERTEXT: 'ciphertext',
107
+ DEBUG: 'debug',
108
+ E2E_NOTIFICATION: 'e2e_notification',
109
+ GP2: 'gp2',
110
+ GROUP_NOTIFICATION: 'group_notification',
111
+ HSM: 'hsm',
112
+ INTERACTIVE: 'interactive',
113
+ NATIVE_FLOW: 'native_flow',
114
+ NOTIFICATION: 'notification',
115
+ NOTIFICATION_TEMPLATE: 'notification_template',
116
+ OVERSIZED: 'oversized',
117
+ PROTOCOL: 'protocol',
118
+ REACTION: 'reaction',
119
+ TEMPLATE_BUTTON_REPLY: 'template_button_reply',
120
+ POLL_CREATION: 'poll_creation',
121
+ SCHEDULED_EVENT_CREATION: 'scheduled_event_creation',
122
+ };
123
+
124
+ /**
125
+ * Group notification types
126
+ * @readonly
127
+ * @enum {string}
128
+ */
129
+ exports.GroupNotificationTypes = {
130
+ ADD: 'add',
131
+ INVITE: 'invite',
132
+ REMOVE: 'remove',
133
+ LEAVE: 'leave',
134
+ PROMOTE: 'promote',
135
+ DEMOTE: 'demote',
136
+ SUBJECT: 'subject',
137
+ DESCRIPTION: 'description',
138
+ PICTURE: 'picture',
139
+ ANNOUNCE: 'announce',
140
+ RESTRICT: 'restrict',
141
+ };
142
+
143
+ /**
144
+ * Chat types
145
+ * @readonly
146
+ * @enum {string}
147
+ */
148
+ exports.ChatTypes = {
149
+ SOLO: 'solo',
150
+ GROUP: 'group',
151
+ UNKNOWN: 'unknown'
152
+ };
153
+
154
+ /**
155
+ * WhatsApp state
156
+ * @readonly
157
+ * @enum {string}
158
+ */
159
+ exports.WAState = {
160
+ CONFLICT: 'CONFLICT',
161
+ CONNECTED: 'CONNECTED',
162
+ DEPRECATED_VERSION: 'DEPRECATED_VERSION',
163
+ OPENING: 'OPENING',
164
+ PAIRING: 'PAIRING',
165
+ PROXYBLOCK: 'PROXYBLOCK',
166
+ SMB_TOS_BLOCK: 'SMB_TOS_BLOCK',
167
+ TIMEOUT: 'TIMEOUT',
168
+ TOS_BLOCK: 'TOS_BLOCK',
169
+ UNLAUNCHED: 'UNLAUNCHED',
170
+ UNPAIRED: 'UNPAIRED',
171
+ UNPAIRED_IDLE: 'UNPAIRED_IDLE'
172
+ };
173
+
174
+ /**
175
+ * Message ACK
176
+ * @readonly
177
+ * @enum {number}
178
+ */
179
+ exports.MessageAck = {
180
+ ACK_ERROR: -1,
181
+ ACK_PENDING: 0,
182
+ ACK_SERVER: 1,
183
+ ACK_DEVICE: 2,
184
+ ACK_READ: 3,
185
+ ACK_PLAYED: 4,
186
+ };
@@ -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,265 @@
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.OpaqueData = window.require('WAWebMediaOpaqueData');
59
+ window.Store.QueryProduct = window.require('WAWebBizProductCatalogBridge');
60
+ window.Store.QueryOrder = window.require('WAWebBizOrderBridge');
61
+ window.Store.SendClear = window.require('WAWebChatClearBridge');
62
+ window.Store.SendDelete = window.require('WAWebDeleteChatAction');
63
+ window.Store.SendMessage = window.require('WAWebSendMsgChatAction');
64
+ window.Store.EditMessage = window.require('WAWebSendMessageEditAction');
65
+ window.Store.MediaDataUtils = window.require('WAWebMediaDataUtils');
66
+ window.Store.BlobCache = window.require('WAWebMediaInMemoryBlobCache');
67
+ window.Store.SendSeen = window.require('WAWebUpdateUnreadChatAction');
68
+ window.Store.User = window.require('WAWebUserPrefsMeUser');
69
+ window.Store.ContactMethods = {
70
+ ...window.require('WAWebContactGetters'),
71
+ ...window.require('WAWebFrontendContactGetters')
72
+ };
73
+ window.Store.UserConstructor = window.require('WAWebWid');
74
+ window.Store.Validators = window.require('WALinkify');
75
+ window.Store.WidFactory = window.require('WAWebWidFactory');
76
+ window.Store.ProfilePic = window.require('WAWebContactProfilePicThumbBridge');
77
+ window.Store.PresenceUtils = window.require('WAWebPresenceChatAction');
78
+ window.Store.ChatState = window.require('WAWebChatStateBridge');
79
+ window.Store.findCommonGroups = window.require('WAWebFindCommonGroupsContactAction').findCommonGroups;
80
+ window.Store.StatusUtils = window.require('WAWebContactStatusBridge');
81
+ window.Store.ConversationMsgs = window.require('WAWebChatLoadMessages');
82
+ window.Store.sendReactionToMsg = window.require('WAWebSendReactionMsgAction').sendReactionToMsg;
83
+ window.Store.createOrUpdateReactionsModule = window.require('WAWebDBCreateOrUpdateReactions');
84
+ window.Store.EphemeralFields = window.require('WAWebGetEphemeralFieldsMsgActionsUtils');
85
+ window.Store.MsgActionChecks = window.require('WAWebMsgActionCapability');
86
+ window.Store.QuotedMsg = window.require('WAWebQuotedMsgModelUtils');
87
+ window.Store.LinkPreview = window.require('WAWebLinkPreviewChatAction');
88
+ window.Store.Socket = window.require('WADeprecatedSendIq');
89
+ window.Store.SocketWap = window.require('WAWap');
90
+ window.Store.SearchContext = window.require('WAWebChatMessageSearch');
91
+ window.Store.DrawerManager = window.require('WAWebDrawerManager').DrawerManager;
92
+ window.Store.LidUtils = window.require('WAWebApiContact');
93
+ window.Store.WidToJid = window.require('WAWebWidToJid');
94
+ window.Store.JidToWid = window.require('WAWebJidToWid');
95
+ window.Store.getMsgInfo = window.require('WAWebApiMessageInfoStore').queryMsgInfo;
96
+ window.Store.QueryExist = window.require('WAWebQueryExistsJob').queryWidExists;
97
+ window.Store.ReplyUtils = window.require('WAWebMsgReply');
98
+ window.Store.BotSecret = window.require('WAWebBotMessageSecret');
99
+ window.Store.BotProfiles = window.require('WAWebBotProfileCollection');
100
+ window.Store.ContactCollection = window.require('WAWebContactCollection').ContactCollection;
101
+ window.Store.DeviceList = window.require('WAWebApiDeviceList');
102
+ window.Store.HistorySync = window.require('WAWebSendNonMessageDataRequest');
103
+ window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
104
+ window.Store.AddonPollVoteTable = window.require('WAWebAddonPollVoteTableMode').pollVoteTableMode;
105
+ window.Store.ChatGetters = window.require('WAWebChatGetters');
106
+ window.Store.UploadUtils = window.require('WAWebUploadManager');
107
+ window.Store.WAWebStreamModel = window.require('WAWebStreamModel');
108
+ window.Store.FindOrCreateChat = window.require('WAWebFindChatAction');
109
+ window.Store.CustomerNoteUtils = window.require('WAWebNoteAction');
110
+ window.Store.BusinessGatingUtils = window.require('WAWebBizGatingUtils');
111
+ window.Store.PollsVotesSchema = window.require('WAWebPollsVotesSchema');
112
+ window.Store.PollsSendVote = window.require('WAWebPollsSendVoteMsgAction');
113
+
114
+ window.Store.Settings = {
115
+ ...window.require('WAWebUserPrefsGeneral'),
116
+ ...window.require('WAWebUserPrefsNotifications'),
117
+ setPushname: (() => {
118
+ try {
119
+ const module = window.require('WAWebSetPushnameConnAction');
120
+ return module && module.setPushname ? module.setPushname : async () => { return false; };
121
+ } catch (e) {
122
+ // Module not available, return a no-op function
123
+ return async () => { return false; };
124
+ }
125
+ })()
126
+ };
127
+ window.Store.NumberInfo = {
128
+ ...window.require('WAPhoneUtils'),
129
+ ...window.require('WAPhoneFindCC')
130
+ };
131
+ window.Store.ForwardUtils = {
132
+ ...window.require('WAWebChatForwardMessage')
133
+ };
134
+ window.Store.PinnedMsgUtils = {
135
+ ...window.require('WAWebPinInChatSchema'),
136
+ ...window.require('WAWebSendPinMessageAction')
137
+ };
138
+ window.Store.ScheduledEventMsgUtils = {
139
+ ...window.require('WAWebGenerateEventCallLink'),
140
+ ...window.require('WAWebSendEventEditMsgAction'),
141
+ ...window.require('WAWebSendEventResponseMsgAction')
142
+ };
143
+ window.Store.VCard = {
144
+ ...window.require('WAWebFrontendVcardUtils'),
145
+ ...window.require('WAWebVcardParsingUtils'),
146
+ ...window.require('WAWebVcardGetNameFromParsed')
147
+ };
148
+ window.Store.StickerTools = {
149
+ ...window.require('WAWebImageUtils'),
150
+ ...window.require('WAWebAddWebpMetadata')
151
+ };
152
+ window.Store.GroupUtils = {
153
+ ...window.require('WAWebGroupCreateJob'),
154
+ ...window.require('WAWebGroupModifyInfoJob'),
155
+ ...window.require('WAWebExitGroupAction'),
156
+ ...window.require('WAWebContactProfilePicThumbBridge'),
157
+ ...window.require('WAWebSetPropertyGroupAction')
158
+ };
159
+ window.Store.GroupParticipants = {
160
+ ...window.require('WAWebModifyParticipantsGroupAction'),
161
+ ...window.require('WASmaxGroupsAddParticipantsRPC')
162
+ };
163
+ window.Store.GroupInvite = {
164
+ ...window.require('WAWebGroupInviteJob'),
165
+ ...window.require('WAWebGroupQueryJob'),
166
+ ...window.require('WAWebMexFetchGroupInviteCodeJob')
167
+ };
168
+ window.Store.GroupInviteV4 = {
169
+ ...window.require('WAWebGroupInviteV4Job'),
170
+ ...window.require('WAWebChatSendMessages')
171
+ };
172
+ window.Store.MembershipRequestUtils = {
173
+ ...window.require('WAWebApiMembershipApprovalRequestStore'),
174
+ ...window.require('WASmaxGroupsMembershipRequestsActionRPC')
175
+ };
176
+ window.Store.ChannelUtils = {
177
+ ...window.require('WAWebLoadNewsletterPreviewChatAction'),
178
+ ...window.require('WAWebNewsletterMetadataQueryJob'),
179
+ ...window.require('WAWebNewsletterCreateQueryJob'),
180
+ ...window.require('WAWebEditNewsletterMetadataAction'),
181
+ ...window.require('WAWebNewsletterDeleteAction'),
182
+ ...window.require('WAWebNewsletterSubscribeAction'),
183
+ ...window.require('WAWebNewsletterUnsubscribeAction'),
184
+ ...window.require('WAWebNewsletterDirectorySearchAction'),
185
+ ...window.require('WAWebNewsletterToggleMuteStateJob'),
186
+ ...window.require('WAWebNewsletterGatingUtils'),
187
+ ...window.require('WAWebNewsletterModelUtils'),
188
+ ...window.require('WAWebMexAcceptNewsletterAdminInviteJob'),
189
+ ...window.require('WAWebMexRevokeNewsletterAdminInviteJob'),
190
+ ...window.require('WAWebChangeNewsletterOwnerAction'),
191
+ ...window.require('WAWebDemoteNewsletterAdminAction'),
192
+ ...window.require('WAWebNewsletterDemoteAdminJob'),
193
+ countryCodesIso: window.require('WAWebCountriesNativeCountryNames'),
194
+ currentRegion: window.require('WAWebL10N').getRegion(),
195
+ };
196
+ window.Store.SendChannelMessage = {
197
+ ...window.require('WAWebNewsletterUpdateMsgsRecordsJob'),
198
+ ...window.require('WAWebMsgDataFromModel'),
199
+ ...window.require('WAWebNewsletterSendMessageJob'),
200
+ ...window.require('WAWebNewsletterSendMsgAction'),
201
+ ...window.require('WAMediaCalculateFilehash')
202
+ };
203
+ window.Store.ChannelSubscribers = {
204
+ ...window.require('WAWebMexFetchNewsletterSubscribersJob'),
205
+ ...window.require('WAWebNewsletterSubscriberListAction')
206
+ };
207
+ window.Store.AddressbookContactUtils = {
208
+ ...window.require('WAWebSaveContactAction'),
209
+ ...window.require('WAWebDeleteContactAction')
210
+ };
211
+
212
+ if (!window.Store.Chat._find || !window.Store.Chat.findImpl) {
213
+ window.Store.Chat._find = e => {
214
+ const target = window.Store.Chat.get(e);
215
+ return target ? Promise.resolve(target) : Promise.resolve({
216
+ id: e
217
+ });
218
+ };
219
+ window.Store.Chat.findImpl = window.Store.Chat._find;
220
+ }
221
+
222
+ /**
223
+ * Target options object description
224
+ * @typedef {Object} TargetOptions
225
+ * @property {string|number} module The target module
226
+ * @property {string} function The function name to get from a module
227
+ */
228
+ /**
229
+ * Function to modify functions
230
+ * @param {TargetOptions} target Options specifying the target function to search for modifying
231
+ * @param {Function} callback Modified function
232
+ */
233
+ window.injectToFunction = (target, callback) => {
234
+ try {
235
+ let module = window.require(target.module);
236
+ if (!module) return;
237
+
238
+ const path = target.function.split('.');
239
+ const funcName = path.pop();
240
+
241
+ for (const key of path) {
242
+ if (!module[key]) return;
243
+ module = module[key];
244
+ }
245
+
246
+ const originalFunction = module[funcName];
247
+ if (typeof originalFunction !== 'function') return;
248
+
249
+ module[funcName] = (...args) => {
250
+ try {
251
+ return callback(originalFunction, ...args);
252
+ } catch {
253
+ return originalFunction(...args);
254
+ }
255
+ };
256
+
257
+ } catch {
258
+ return;
259
+ }
260
+ };
261
+
262
+ window.injectToFunction({ module: 'WAWebBackendJobsCommon', function: 'mediaTypeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage ? null : func(...args); });
263
+
264
+ window.injectToFunction({ module: 'WAWebE2EProtoUtils', function: 'typeAttributeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage || proto.groupInviteMessage ? 'text' : func(...args); });
265
+ };