aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/background.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-08-03 05:26:10 +0800
committerkumavis <aaron@kumavis.me>2017-08-03 05:26:10 +0800
commitecaa235b5e3331defab75dad72593951fdf37790 (patch)
tree61b6813459085c4797df99986dccc6d3fe40c59e /app/scripts/background.js
parentaea5735b29c87d0a9aad3bfa86d854ed9b20bdf7 (diff)
downloadtangerine-wallet-browser-ecaa235b5e3331defab75dad72593951fdf37790.tar
tangerine-wallet-browser-ecaa235b5e3331defab75dad72593951fdf37790.tar.gz
tangerine-wallet-browser-ecaa235b5e3331defab75dad72593951fdf37790.tar.bz2
tangerine-wallet-browser-ecaa235b5e3331defab75dad72593951fdf37790.tar.lz
tangerine-wallet-browser-ecaa235b5e3331defab75dad72593951fdf37790.tar.xz
tangerine-wallet-browser-ecaa235b5e3331defab75dad72593951fdf37790.tar.zst
tangerine-wallet-browser-ecaa235b5e3331defab75dad72593951fdf37790.zip
phishing detection - move phishing detection into contentscript and metamask controller
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r--app/scripts/background.js34
1 files changed, 4 insertions, 30 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index bc0fbdc37..a235afff3 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -11,7 +11,6 @@ const NotificationManager = require('./lib/notification-manager.js')
const MetamaskController = require('./metamask-controller')
const extension = require('extensionizer')
const firstTimeState = require('./first-time-state')
-const isPhish = require('./lib/is-phish')
const STORAGE_KEY = 'metamask-config'
const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG'
@@ -91,16 +90,12 @@ function setupController (initState) {
extension.runtime.onConnect.addListener(connectRemote)
function connectRemote (remotePort) {
- if (remotePort.name === 'blacklister') {
- return checkBlacklist(remotePort)
- }
-
- var isMetaMaskInternalProcess = remotePort.name === 'popup' || remotePort.name === 'notification'
- var portStream = new PortStream(remotePort)
+ const isMetaMaskInternalProcess = remotePort.name === 'popup' || remotePort.name === 'notification'
+ const portStream = new PortStream(remotePort)
if (isMetaMaskInternalProcess) {
// communication with popup
popupIsOpen = popupIsOpen || (remotePort.name === 'popup')
- controller.setupTrustedCommunication(portStream, 'MetaMask', remotePort.name)
+ controller.setupTrustedCommunication(portStream, 'MetaMask')
// record popup as closed
if (remotePort.name === 'popup') {
endOfStream(portStream, () => {
@@ -109,7 +104,7 @@ function setupController (initState) {
}
} else {
// communication with page
- var originDomain = urlUtil.parse(remotePort.sender.url).hostname
+ const originDomain = urlUtil.parse(remotePort.sender.url).hostname
controller.setupUntrustedCommunication(portStream, originDomain)
}
}
@@ -140,27 +135,6 @@ function setupController (initState) {
return Promise.resolve()
}
-// Listen for new pages and return if blacklisted:
-function checkBlacklist (port) {
- const handler = handleNewPageLoad.bind(null, port)
- port.onMessage.addListener(handler)
- setTimeout(() => {
- port.onMessage.removeListener(handler)
- }, 30000)
-}
-
-function handleNewPageLoad (port, message) {
- const { pageLoaded } = message
- if (!pageLoaded || !global.metamaskController) return
-
- const state = global.metamaskController.getState()
- const updatedBlacklist = state.blacklist
-
- if (isPhish({ updatedBlacklist, hostname: pageLoaded })) {
- port.postMessage({ 'blacklist': pageLoaded })
- }
-}
-
//
// Etc...
//