Skip to content

Commit

Permalink
Rename phishing warning page environment variable
Browse files Browse the repository at this point in the history
The phishing warning page URL environment variable has been renamed
from `PHISHING_PAGE_URL` to `PHISHING_WARNING_PAGE_URL`. We call this
page the "phishing warning page" everywhere else, and this name seemed
better suited (it's not a phishing page itself).

The variable has been listed and documented in `.metamaskrc.dist` as
well.
  • Loading branch information
Gudahtt committed May 16, 2022
1 parent 5a5e541 commit d1ac1a8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .metamaskrc.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ ONBOARDING_V2=
SWAPS_USE_DEV_APIS=
COLLECTIBLES_V1=
TOKEN_DETECTION_V2=

; Set this to test changes to the phishing warning page.
PHISHING_WARNING_PAGE_URL=
4 changes: 2 additions & 2 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if (inTest || process.env.METAMASK_DEBUG) {
global.metamaskGetState = localStore.get.bind(localStore);
}

const phishingPageUrl = new URL(process.env.PHISHING_PAGE_URL);
const phishingPageUrl = new URL(process.env.PHISHING_WARNING_PAGE_URL);

const ONE_SECOND_IN_MILLISECONDS = 1_000;
// Timeout for initializing phishing warning page.
Expand Down Expand Up @@ -161,7 +161,7 @@ async function loadPhishingWarningPage() {
let iframe;
try {
const extensionStartupPhishingPageUrl = new URL(
process.env.PHISHING_PAGE_URL,
process.env.PHISHING_WARNING_PAGE_URL,
);
// The `extensionStartup` hash signals to the phishing warning page that it should not bother
// setting up streams for user interaction. Otherwise this page load would cause a console
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const LEGACY_INPAGE = 'inpage';
const LEGACY_PROVIDER = 'provider';
const LEGACY_PUBLIC_CONFIG = 'publicConfig';

const phishingPageUrl = new URL(process.env.PHISHING_PAGE_URL);
const phishingPageUrl = new URL(process.env.PHISHING_WARNING_PAGE_URL);

if (
window.location.origin === phishingPageUrl.origin &&
Expand Down Expand Up @@ -354,7 +354,7 @@ function blockedDomainCheck() {
*/
function redirectToPhishingWarning() {
console.debug('MetaMask: Routing to Phishing Warning page.');
const baseUrl = process.env.PHISHING_PAGE_URL;
const baseUrl = process.env.PHISHING_WARNING_PAGE_URL;
window.location.href = `${baseUrl}#${querystring.stringify({
hostname: window.location.hostname,
href: window.location.href,
Expand Down
6 changes: 3 additions & 3 deletions development/build/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const metamaskrc = require('rc')('metamask', {
INFURA_PROD_PROJECT_ID: process.env.INFURA_PROD_PROJECT_ID,
ONBOARDING_V2: process.env.ONBOARDING_V2,
COLLECTIBLES_V1: process.env.COLLECTIBLES_V1,
PHISHING_PAGE_URL: process.env.PHISHING_PAGE_URL,
PHISHING_WARNING_PAGE_URL: process.env.PHISHING_WARNING_PAGE_URL,
TOKEN_DETECTION_V2: process.env.TOKEN_DETECTION_V2,
SEGMENT_HOST: process.env.SEGMENT_HOST,
SEGMENT_WRITE_KEY: process.env.SEGMENT_WRITE_KEY,
Expand Down Expand Up @@ -142,7 +142,7 @@ function getSegmentWriteKey({ buildType, environment }) {
* @returns {string} The URL for the phishing warning page, or `undefined` if no URL is set.
*/
function getPhishingWarningPageUrl({ testing }) {
let phishingWarningPageUrl = metamaskrc.PHISHING_PAGE_URL;
let phishingWarningPageUrl = metamaskrc.PHISHING_WARNING_PAGE_URL;

if (!phishingWarningPageUrl) {
phishingWarningPageUrl = testing
Expand Down Expand Up @@ -838,7 +838,7 @@ function getEnvironmentVariables({ buildType, devMode, testing, version }) {
METAMASK_BUILD_TYPE: buildType,
NODE_ENV: devMode ? ENVIRONMENT.DEVELOPMENT : ENVIRONMENT.PRODUCTION,
IN_TEST: testing,
PHISHING_PAGE_URL: getPhishingWarningPageUrl({ testing }),
PHISHING_WARNING_PAGE_URL: getPhishingWarningPageUrl({ testing }),
PUBNUB_SUB_KEY: process.env.PUBNUB_SUB_KEY || '',
PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY || '',
CONF: devMode ? metamaskrc : {},
Expand Down

0 comments on commit d1ac1a8

Please sign in to comment.