aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/metamask-controller.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-08-03 06:54:59 +0800
committerkumavis <aaron@kumavis.me>2017-08-03 06:54:59 +0800
commit8c6f01b91094564df59d6d95b6f43b811e711824 (patch)
tree19ed66e8fd54b4324d8e5750de061c6562ace19b /app/scripts/metamask-controller.js
parentecaa235b5e3331defab75dad72593951fdf37790 (diff)
downloadtangerine-wallet-browser-8c6f01b91094564df59d6d95b6f43b811e711824.tar
tangerine-wallet-browser-8c6f01b91094564df59d6d95b6f43b811e711824.tar.gz
tangerine-wallet-browser-8c6f01b91094564df59d6d95b6f43b811e711824.tar.bz2
tangerine-wallet-browser-8c6f01b91094564df59d6d95b6f43b811e711824.tar.lz
tangerine-wallet-browser-8c6f01b91094564df59d6d95b6f43b811e711824.tar.xz
tangerine-wallet-browser-8c6f01b91094564df59d6d95b6f43b811e711824.tar.zst
tangerine-wallet-browser-8c6f01b91094564df59d6d95b6f43b811e711824.zip
blacklist controller - breakout from metamask and infura controllers
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r--app/scripts/metamask-controller.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 28c35a13d..6d6cb85ab 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -16,6 +16,7 @@ const NoticeController = require('./notice-controller')
const ShapeShiftController = require('./controllers/shapeshift')
const AddressBookController = require('./controllers/address-book')
const InfuraController = require('./controllers/infura')
+const BlacklistController = require('./controllers/blacklist')
const MessageManager = require('./lib/message-manager')
const PersonalMessageManager = require('./lib/personal-message-manager')
const TransactionController = require('./controllers/transactions')
@@ -23,7 +24,6 @@ const ConfigManager = require('./lib/config-manager')
const nodeify = require('./lib/nodeify')
const accountImporter = require('./account-import-strategies')
const getBuyEthUrl = require('./lib/buy-eth-url')
-const checkForPhishing = require('./lib/is-phish')
const debounce = require('debounce')
const version = require('../manifest.json').version
@@ -70,6 +70,10 @@ module.exports = class MetamaskController extends EventEmitter {
})
this.infuraController.scheduleInfuraNetworkCheck()
+ this.blacklistController = new BlacklistController({
+ initState: initState.BlacklistController,
+ })
+ this.blacklistController.scheduleUpdates()
// rpc provider
this.provider = this.initializeProvider()
@@ -152,6 +156,9 @@ module.exports = class MetamaskController extends EventEmitter {
this.networkController.store.subscribe((state) => {
this.store.updateState({ NetworkController: state })
})
+ this.blacklistController.store.subscribe((state) => {
+ this.store.updateState({ BlacklistController: state })
+ })
this.infuraController.store.subscribe((state) => {
this.store.updateState({ InfuraController: state })
})
@@ -328,7 +335,7 @@ module.exports = class MetamaskController extends EventEmitter {
setupUntrustedCommunication (connectionStream, originDomain) {
// Check if new connection is blacklisted
- if (this.isHostBlacklisted(originDomain)) {
+ if (this.blacklistController.checkForPhishing(originDomain)) {
console.log('MetaMask - sending phishing warning for', originDomain)
this.sendPhishingWarning(connectionStream, originDomain)
return
@@ -349,17 +356,9 @@ module.exports = class MetamaskController extends EventEmitter {
this.setupProviderConnection(mx.createStream('provider'), originDomain)
}
- // Check if a domain is on our blacklist
- isHostBlacklisted (hostname) {
- if (!hostname) return false
- const { blacklist } = this.getState().blacklist
- return checkForPhishing({ blacklist, hostname })
- }
-
sendPhishingWarning (connectionStream, hostname) {
const mx = setupMultiplex(connectionStream)
const phishingStream = mx.createStream('phishing')
- // phishingStream.write(true)
phishingStream.write({ hostname })
}