aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-07-27 07:30:54 +0800
committerDan Finlay <dan@danfinlay.com>2017-07-27 07:30:54 +0800
commit8b1726cc550d4a5b142a2a525ce6b94713dc04e0 (patch)
treecc24d39b4cf26be15481025591707e53f0b90b9c /app/scripts
parentf147b928b238af3e1f0abdcc4d38b5281f67aba4 (diff)
downloadtangerine-wallet-browser-8b1726cc550d4a5b142a2a525ce6b94713dc04e0.tar
tangerine-wallet-browser-8b1726cc550d4a5b142a2a525ce6b94713dc04e0.tar.gz
tangerine-wallet-browser-8b1726cc550d4a5b142a2a525ce6b94713dc04e0.tar.bz2
tangerine-wallet-browser-8b1726cc550d4a5b142a2a525ce6b94713dc04e0.tar.lz
tangerine-wallet-browser-8b1726cc550d4a5b142a2a525ce6b94713dc04e0.tar.xz
tangerine-wallet-browser-8b1726cc550d4a5b142a2a525ce6b94713dc04e0.tar.zst
tangerine-wallet-browser-8b1726cc550d4a5b142a2a525ce6b94713dc04e0.zip
Live update blacklist from Infura
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/background.js14
-rw-r--r--app/scripts/blacklister.js4
-rw-r--r--app/scripts/inpage.js1
3 files changed, 8 insertions, 11 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index c9505b237..01bb39186 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -91,7 +91,7 @@ function setupController (initState) {
extension.runtime.onConnect.addListener(connectRemote)
function connectRemote (remotePort) {
if (remotePort.name === 'blacklister') {
- return setupBlacklist(connectRemote)
+ return checkBlacklist(remotePort)
}
var isMetaMaskInternalProcess = remotePort.name === 'popup' || remotePort.name === 'notification'
@@ -140,25 +140,23 @@ function setupController (initState) {
}
// Listen for new pages and return if blacklisted:
-function setupBlacklist (port) {
- console.log('Blacklist connection established')
- const handler = handleNewPageLoad.bind(port)
+function checkBlacklist (port) {
+ const handler = handleNewPageLoad.bind(null, port)
port.onMessage.addListener(handler)
setTimeout(() => {
port.onMessage.removeListener(handler)
}, 30000)
}
-function handleNewPageLoad (message) {
+function handleNewPageLoad (port, message) {
const { pageLoaded } = message
- console.log('blaclist message received', message.pageLoaded)
if (!pageLoaded || !global.metamaskController) return
const state = global.metamaskController.getState()
- const { blacklist } = state.metamask
+ const { blacklist } = state
if (blacklist && blacklist.includes(pageLoaded)) {
- this.postMessage({ 'blacklist': pageLoaded })
+ port.postMessage({ 'blacklist': pageLoaded })
}
}
diff --git a/app/scripts/blacklister.js b/app/scripts/blacklister.js
index f5572c11a..37751b595 100644
--- a/app/scripts/blacklister.js
+++ b/app/scripts/blacklister.js
@@ -1,13 +1,11 @@
const extension = require('extensionizer')
-console.log('blacklister content script loaded.')
-const port = extension.runtime.connect({ name: 'blacklister' })
+var port = extension.runtime.connect({name: 'blacklister'})
port.postMessage({ 'pageLoaded': window.location.hostname })
port.onMessage.addListener(redirectIfBlacklisted)
function redirectIfBlacklisted (response) {
const { blacklist } = response
- console.log('blacklister contentscript received blacklist response')
const host = window.location.hostname
if (blacklist && blacklist === host) {
window.location.href = 'https://metamask.io/phishing.html'
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js
index ec764535e..9e98c044b 100644
--- a/app/scripts/inpage.js
+++ b/app/scripts/inpage.js
@@ -65,3 +65,4 @@ function restoreContextAfterImports () {
console.warn('MetaMask - global.define could not be overwritten.')
}
}
+