From 7f8e0227ec8586d2e88c72342300fbc2ce727f81 Mon Sep 17 00:00:00 2001 From: Niranjana Binoy <43930900+NiranjanaBinoy@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:16:56 -0400 Subject: [PATCH] adding ignorestream changes --- app/scripts/streams/phishing-stream.ts | 21 ++++++++++++++++++++- app/scripts/streams/provider-stream.ts | 17 +++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/scripts/streams/phishing-stream.ts b/app/scripts/streams/phishing-stream.ts index 064f3e0ac694..a9899407a94e 100644 --- a/app/scripts/streams/phishing-stream.ts +++ b/app/scripts/streams/phishing-stream.ts @@ -10,7 +10,12 @@ import { checkForLastError } from '../../../shared/modules/browser-runtime.utils import { EXTENSION_MESSAGES } from '../../../shared/constants/app'; import { CONTENT_SCRIPT, + LEGACY_PROVIDER, + LEGACY_PUBLIC_CONFIG, + METAMASK_COOKIE_HANDLER, + METAMASK_PROVIDER, PHISHING_SAFELIST, + PHISHING_STREAM, PHISHING_WARNING_PAGE, } from '../constants/stream'; import { logStreamDisconnectWarning, MessageType } from './stream-utils'; @@ -47,6 +52,11 @@ function setupPhishingPageStreams(): void { ); phishingPageChannel = phishingPageMux.createStream(PHISHING_SAFELIST); + phishingPageMux.ignoreStream(METAMASK_COOKIE_HANDLER); + phishingPageMux.ignoreStream(LEGACY_PUBLIC_CONFIG); + phishingPageMux.ignoreStream(LEGACY_PROVIDER); + phishingPageMux.ignoreStream(METAMASK_PROVIDER); + phishingPageMux.ignoreStream(PHISHING_STREAM); } /** Destroys all of the phishing extension streams */ @@ -102,6 +112,12 @@ export const setupPhishingExtStreams = (): void => { ), ); + phishingExtMux.ignoreStream(METAMASK_COOKIE_HANDLER); + phishingExtMux.ignoreStream(LEGACY_PUBLIC_CONFIG); + phishingExtMux.ignoreStream(LEGACY_PROVIDER); + phishingExtMux.ignoreStream(METAMASK_PROVIDER); + phishingExtMux.ignoreStream(PHISHING_STREAM); + // eslint-disable-next-line @typescript-eslint/no-use-before-define phishingExtPort.onDisconnect.addListener(onDisconnectDestroyPhishingStreams); }; @@ -185,7 +201,10 @@ export function connectPhishingChannelToWarningSystem( extensionMux: ObjectMultiplex, ): void { // create a stream specifically for handling phishing-related communications - extensionPhishingStream = extensionMux.createStream('phishing'); + extensionPhishingStream = extensionMux.createStream(PHISHING_STREAM); + extensionMux.ignoreStream(METAMASK_COOKIE_HANDLER); + extensionMux.ignoreStream(LEGACY_PROVIDER); + extensionMux.ignoreStream(PHISHING_SAFELIST); // an event listener for the first piece of data received on this "phishing" channel. // Once data is received, it triggers the redirectToPhishingWarning function extensionPhishingStream.once('data', redirectToPhishingWarning); diff --git a/app/scripts/streams/provider-stream.ts b/app/scripts/streams/provider-stream.ts index fa9797d3cf37..9616253815e8 100644 --- a/app/scripts/streams/provider-stream.ts +++ b/app/scripts/streams/provider-stream.ts @@ -12,8 +12,11 @@ import { LEGACY_INPAGE, LEGACY_PROVIDER, LEGACY_PUBLIC_CONFIG, + METAMASK_COOKIE_HANDLER, METAMASK_INPAGE, METAMASK_PROVIDER, + PHISHING_SAFELIST, + PHISHING_STREAM, } from '../constants/stream'; import { EXTENSION_MESSAGES } from '../../../shared/constants/app'; import { checkForLastError } from '../../../shared/modules/browser-runtime.utils'; @@ -52,6 +55,11 @@ const setupPageStreams = () => { ); pageChannel = pageMux.createStream(METAMASK_PROVIDER); + pageMux.ignoreStream(METAMASK_COOKIE_HANDLER); + pageMux.ignoreStream(LEGACY_PROVIDER); + pageMux.ignoreStream(LEGACY_PUBLIC_CONFIG); + pageMux.ignoreStream(PHISHING_SAFELIST); + pageMux.ignoreStream(PHISHING_STREAM); }; // The field below is used to ensure that replay is done only once for each restart. @@ -127,6 +135,11 @@ const setupLegacyPageStreams = () => { legacyPageMux.createStream(LEGACY_PROVIDER); legacyPagePublicConfigChannel = legacyPageMux.createStream(LEGACY_PUBLIC_CONFIG); + + legacyPageMux.ignoreStream(METAMASK_COOKIE_HANDLER); + legacyPageMux.ignoreStream(METAMASK_PROVIDER); + legacyPageMux.ignoreStream(PHISHING_SAFELIST); + legacyPageMux.ignoreStream(PHISHING_STREAM); }; // TODO:LegacyProvider: Delete @@ -170,6 +183,10 @@ const setupLegacyExtensionStreams = () => { error, ), ); + legacyExtMux.ignoreStream(METAMASK_COOKIE_HANDLER); + legacyExtMux.ignoreStream(LEGACY_PROVIDER); + legacyExtMux.ignoreStream(PHISHING_SAFELIST); + legacyExtMux.ignoreStream(PHISHING_STREAM); }; /**