Skip to content

Commit

Permalink
adding ignorestream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
NiranjanaBinoy committed Sep 12, 2024
1 parent 7c828da commit 7f8e022
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
21 changes: 20 additions & 1 deletion app/scripts/streams/phishing-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
};
Expand Down Expand Up @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions app/scripts/streams/provider-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -170,6 +183,10 @@ const setupLegacyExtensionStreams = () => {
error,
),
);
legacyExtMux.ignoreStream(METAMASK_COOKIE_HANDLER);
legacyExtMux.ignoreStream(LEGACY_PROVIDER);
legacyExtMux.ignoreStream(PHISHING_SAFELIST);
legacyExtMux.ignoreStream(PHISHING_STREAM);
};

/**
Expand Down

0 comments on commit 7f8e022

Please sign in to comment.