aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-08-04 05:25:02 +0800
committerkumavis <aaron@kumavis.me>2017-08-04 05:25:02 +0800
commitd4877cb4e2580db565686e7c736cd3716dc6e02d (patch)
tree0feafb0552717f0f00031d77e90fb59bc7be8702 /app/scripts/controllers
parent8a9d0073b1d6b959e9374180e2f52d12ea8319ca (diff)
downloadtangerine-wallet-browser-d4877cb4e2580db565686e7c736cd3716dc6e02d.tar.gz
tangerine-wallet-browser-d4877cb4e2580db565686e7c736cd3716dc6e02d.tar.zst
tangerine-wallet-browser-d4877cb4e2580db565686e7c736cd3716dc6e02d.zip
blacklist - use module eth-phishing-detect
Diffstat (limited to 'app/scripts/controllers')
-rw-r--r--app/scripts/controllers/blacklist.js28
1 files changed, 18 insertions, 10 deletions
diff --git a/app/scripts/controllers/blacklist.js b/app/scripts/controllers/blacklist.js
index 11e26d5b2..7e01fa386 100644
--- a/app/scripts/controllers/blacklist.js
+++ b/app/scripts/controllers/blacklist.js
@@ -1,13 +1,9 @@
const ObservableStore = require('obs-store')
const extend = require('xtend')
-const communityBlacklistedDomains = require('etheraddresslookup/blacklists/domains.json')
-const communityWhitelistedDomains = require('etheraddresslookup/whitelists/domains.json')
-const checkForPhishing = require('../lib/is-phish')
+const PhishingDetector = require('eth-phishing-detect/src/detector')
// compute phishing lists
-const PHISHING_BLACKLIST = communityBlacklistedDomains.concat(['metamask.com'])
-const PHISHING_WHITELIST = communityWhitelistedDomains.concat(['metamask.io', 'www.metamask.io'])
-const PHISHING_FUZZYLIST = ['myetherwallet', 'myetheroll', 'ledgerwallet', 'metamask']
+const PHISHING_DETECTION_CONFIG = require('eth-phishing-detect/src/config.json')
// every ten minutes
const POLLING_INTERVAL = 10 * 60 * 1000
@@ -15,9 +11,12 @@ class BlacklistController {
constructor (opts = {}) {
const initState = extend({
- phishing: PHISHING_BLACKLIST,
+ phishing: PHISHING_DETECTION_CONFIG,
}, opts.initState)
this.store = new ObservableStore(initState)
+ // phishing detector
+ this._phishingDetector = null
+ this._setupPhishingDetector(initState.phishing)
// polling references
this._phishingUpdateIntervalRef = null
}
@@ -28,14 +27,15 @@ class BlacklistController {
checkForPhishing (hostname) {
if (!hostname) return false
- const { blacklist } = this.store.getState()
- return checkForPhishing({ hostname, blacklist, whitelist: PHISHING_WHITELIST, fuzzylist: PHISHING_FUZZYLIST })
+ const { result } = this._phishingDetector.check(hostname)
+ return result
}
async updatePhishingList () {
- const response = await fetch('https://api.infura.io/v1/blacklist')
+ const response = await fetch('https://api.infura.io/v2/blacklist')
const phishing = await response.json()
this.store.updateState({ phishing })
+ this._setupPhishingDetector(phishing)
return phishing
}
@@ -45,6 +45,14 @@ class BlacklistController {
this.updatePhishingList()
}, POLLING_INTERVAL)
}
+
+ //
+ // PRIVATE METHODS
+ //
+
+ _setupPhishingDetector (config) {
+ this._phishingDetector = new PhishingDetector(config)
+ }
}
module.exports = BlacklistController