From e68e3ccc2fa912372d48a1382cefb81d843d6d41 Mon Sep 17 00:00:00 2001 From: Connor Bryan Date: Thu, 5 Jul 2018 12:29:23 -0500 Subject: [PATCH 1/4] Tighten web3 network change refresh validation (#2014) * Add a check to make sure a network even exists on the web3Wallet instance * Format snap files --- common/features/config/__snapshots__/sagas.spec.ts.snap | 4 +++- .../deterministicWallets/__snapshots__/sagas.spec.ts.snap | 6 ++++-- common/features/handleMetaMaskPolling.ts | 7 ++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/common/features/config/__snapshots__/sagas.spec.ts.snap b/common/features/config/__snapshots__/sagas.spec.ts.snap index bd0f53b5..5c78d960 100644 --- a/common/features/config/__snapshots__/sagas.spec.ts.snap +++ b/common/features/config/__snapshots__/sagas.spec.ts.snap @@ -12,7 +12,9 @@ Object { } `; -exports[`handleChangeNodeRequested* should select getCustomNodeConfig and match race snapshot 1`] = ` +exports[ + `handleChangeNodeRequested* should select getCustomNodeConfig and match race snapshot 1` +] = ` Object { "@@redux-saga/IO": true, "SELECT": Object { diff --git a/common/features/deterministicWallets/__snapshots__/sagas.spec.ts.snap b/common/features/deterministicWallets/__snapshots__/sagas.spec.ts.snap index 74d459c8..ab5c6333 100644 --- a/common/features/deterministicWallets/__snapshots__/sagas.spec.ts.snap +++ b/common/features/deterministicWallets/__snapshots__/sagas.spec.ts.snap @@ -1,6 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`getDeterministicWallets* starting from publicKey & chainCode should match put snapshot 1`] = ` +exports[ + `getDeterministicWallets* starting from publicKey & chainCode should match put snapshot 1` +] = ` Object { "@@redux-saga/IO": true, "PUT": Object { @@ -215,4 +217,4 @@ Object { }, ], } -`; \ No newline at end of file +`; diff --git a/common/features/handleMetaMaskPolling.ts b/common/features/handleMetaMaskPolling.ts index 9c3d12b1..118ec5f7 100644 --- a/common/features/handleMetaMaskPolling.ts +++ b/common/features/handleMetaMaskPolling.ts @@ -37,7 +37,12 @@ export default async function handleMetaMaskPolling(store: Store): Pro const actualChainId = await getActualChainId(); const actualNetwork = configNetworksSelectors.getNetworkByChainId(state, actualChainId); - if (web3Wallet && actualNetwork && (web3Wallet as Web3Wallet).network !== actualNetwork.id) { + if ( + web3Wallet && + (web3Wallet as Web3Wallet).network && + actualNetwork && + (web3Wallet as Web3Wallet).network !== actualNetwork.id + ) { window.location.reload(); return true; From eb9f65146525b74c0155228d516c876ef4a8922f Mon Sep 17 00:00:00 2001 From: Connor Bryan Date: Thu, 5 Jul 2018 15:04:28 -0500 Subject: [PATCH 2/4] Added a preliminary check before polling --- common/features/store.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/features/store.ts b/common/features/store.ts index 359378fa..b41f0784 100644 --- a/common/features/store.ts +++ b/common/features/store.ts @@ -91,6 +91,9 @@ window.addEventListener('load', () => { }); }); -setInterval(handleMetaMaskPolling.bind(null, store), METAMASK_POLLING_INTERVAL); +/** @desc When MetaMask is loaded as an extension, watch for network changes. */ +if ((window as any).web3) { + setInterval(handleMetaMaskPolling.bind(null, store), METAMASK_POLLING_INTERVAL); +} export default store; From e0c2b10d8625fd0094ac488bfb0de2c0679e0a88 Mon Sep 17 00:00:00 2001 From: Danny Skubak Date: Fri, 6 Jul 2018 09:15:08 -0400 Subject: [PATCH 3/4] MC-01-003: Add CSP to Meta Tag (#2019) * add meta content security policy * inject meta csp based on production status * use correct var * rollback devtoll modification --- common/index.html | 1 + webpack_config/makeConfig.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common/index.html b/common/index.html index cac71d94..8a67e544 100644 --- a/common/index.html +++ b/common/index.html @@ -4,6 +4,7 @@ MyCrypto + diff --git a/webpack_config/makeConfig.js b/webpack_config/makeConfig.js index d9304990..73b2c4bc 100644 --- a/webpack_config/makeConfig.js +++ b/webpack_config/makeConfig.js @@ -166,7 +166,10 @@ module.exports = function(opts = {}) { twitter: { site: config.twitter.creator, creator: config.twitter.creator - } + }, + metaCsp: options.isProduction + ? "default-src 'none'; script-src 'self'; worker-src 'self' blob:; style-src 'self' 'unsafe-inline'; manifest-src 'self'; font-src 'self'; img-src 'self' data: https://shapeshift.io; connect-src *;" + : "" }), new CopyWebpackPlugin([ From 425655ee055664abaccafdb5c9786f07ef7beaad Mon Sep 17 00:00:00 2001 From: James Prado Date: Fri, 6 Jul 2018 14:29:39 +0100 Subject: [PATCH 4/4] Fix meta tag link (#2006) * Fix meta tag link * fix path --- common/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/index.html b/common/index.html index 8a67e544..816d698f 100644 --- a/common/index.html +++ b/common/index.html @@ -13,7 +13,7 @@ - + @@ -74,4 +74,4 @@ - + \ No newline at end of file