From 5e2e9dd1399f1e07cdac0c1cf3f809f26c67c530 Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Fri, 22 Apr 2022 00:15:00 +0300 Subject: [PATCH] Fix: Cannot read properties of undefined (reading 'features') // original: (#1407) (#1410) * Fix: Cannot read properties of undefined (reading 'features') (#1407) * Fix: Cannot read properties of undefined (reading 'features') Find MD backend without features * Fix for tests * Update Client.js * Update LegacySessionAuth.js Co-authored-by: Shir Serlui <70711723+shirser121@users.noreply.github.com> --- src/Client.js | 2 +- src/authStrategies/LegacySessionAuth.js | 4 ++-- src/util/Injected.js | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Client.js b/src/Client.js index b8a45a2..9d35edd 100644 --- a/src/Client.js +++ b/src/Client.js @@ -733,7 +733,7 @@ class Client extends EventEmitter { const couldSet = await this.pupPage.evaluate(async displayName => { if(!window.Store.Conn.canSetMyPushname()) return false; - if(window.Store.Features.features.MD_BACKEND) { + if(window.Store.MDBackend) { // TODO return false; } else { diff --git a/src/authStrategies/LegacySessionAuth.js b/src/authStrategies/LegacySessionAuth.js index 8dfe406..dd09f7b 100644 --- a/src/authStrategies/LegacySessionAuth.js +++ b/src/authStrategies/LegacySessionAuth.js @@ -51,7 +51,7 @@ class LegacySessionAuth extends BaseAuthStrategy { async getAuthEventPayload() { const isMD = await this.client.pupPage.evaluate(() => { - return window.Store.Features.features.MD_BACKEND; + return window.Store.MDBackend; }); if(isMD) throw new Error('Authenticating via JSON session is not supported for MultiDevice-enabled WhatsApp accounts.'); @@ -69,4 +69,4 @@ class LegacySessionAuth extends BaseAuthStrategy { } } -module.exports = LegacySessionAuth; \ No newline at end of file +module.exports = LegacySessionAuth; diff --git a/src/util/Injected.js b/src/util/Injected.js index 8addf6c..ca18070 100644 --- a/src/util/Injected.js +++ b/src/util/Injected.js @@ -13,7 +13,7 @@ exports.ExposeStore = (moduleRaidStr) => { window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd; window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0]; window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager; - window.Store.Features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0].GK; + window.Store.MDBackend = window.mR.findModule('isMDBackend')[0].isMDBackend(); window.Store.GroupMetadata = window.mR.findModule((module) => module.default && module.default.handlePendingInvite)[0].default; window.Store.Invite = window.mR.findModule('sendJoinGroupViaInvite')[0]; window.Store.InviteInfo = window.mR.findModule('sendQueryGroupInvite')[0]; @@ -159,7 +159,7 @@ exports.LoadUtils = () => { delete options.linkPreview; // Not supported yet by WhatsApp Web on MD - if(!window.Store.Features.features.MD_BACKEND) { + if(!window.Store.MDBackend) { const link = window.Store.Validators.findLink(content); if (link) { const preview = await window.Store.Wap.queryLinkPreview(link.url); @@ -211,7 +211,7 @@ exports.LoadUtils = () => { } const meUser = window.Store.User.getMaybeMeUser(); - const isMD = window.Store.Features.features.MD_BACKEND; + const isMD = window.Store.MDBackend; const newMsgId = new window.Store.MsgKey({ from: meUser, @@ -512,7 +512,7 @@ exports.LoadUtils = () => { }; window.WWebJS.sendChatstate = async (state, chatId) => { - if (window.Store.Features.features.MD_BACKEND) { + if (window.Store.MDBackend) { chatId = window.Store.WidFactory.createWid(chatId); } switch (state) {