aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-10-02 06:58:46 +0800
committerWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-10-02 21:13:46 +0800
commit4dd6c8168f3dbec5a0e910069a4a29a640e39942 (patch)
tree75f720e1871414cd582a8b7c390fc1ea423579e0 /app/scripts
parent343ae7c143c4a729e2d94cf6dd95661d2e5f73ba (diff)
downloadtangerine-wallet-browser-4dd6c8168f3dbec5a0e910069a4a29a640e39942.tar
tangerine-wallet-browser-4dd6c8168f3dbec5a0e910069a4a29a640e39942.tar.gz
tangerine-wallet-browser-4dd6c8168f3dbec5a0e910069a4a29a640e39942.tar.bz2
tangerine-wallet-browser-4dd6c8168f3dbec5a0e910069a4a29a640e39942.tar.lz
tangerine-wallet-browser-4dd6c8168f3dbec5a0e910069a4a29a640e39942.tar.xz
tangerine-wallet-browser-4dd6c8168f3dbec5a0e910069a4a29a640e39942.tar.zst
tangerine-wallet-browser-4dd6c8168f3dbec5a0e910069a4a29a640e39942.zip
Add ability to whitelist a blacklisted domain at runtime
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/controllers/blacklist.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/scripts/controllers/blacklist.js b/app/scripts/controllers/blacklist.js
index 1d2191433..89c7cc888 100644
--- a/app/scripts/controllers/blacklist.js
+++ b/app/scripts/controllers/blacklist.js
@@ -29,6 +29,7 @@ class BlacklistController {
constructor (opts = {}) {
const initState = extend({
phishing: PHISHING_DETECTION_CONFIG,
+ whitelist: [],
}, opts.initState)
this.store = new ObservableStore(initState)
// phishing detector
@@ -39,6 +40,21 @@ class BlacklistController {
}
/**
+ * Adds the given hostname to the runtime whitelist
+ * @param {string} hostname the hostname to whitelist
+ */
+ whitelistDomain (hostname) {
+ if (!hostname) {
+ return
+ }
+
+ const { whitelist } = this.store.getState()
+ this.store.updateState({
+ whitelist: [...new Set([hostname, ...whitelist])],
+ })
+ }
+
+ /**
* Given a url, returns the result of checking if that url is in the store.phishing blacklist
*
* @param {string} hostname The hostname portion of a url; the one that will be checked against the white and
@@ -48,6 +64,12 @@ class BlacklistController {
*/
checkForPhishing (hostname) {
if (!hostname) return false
+
+ const { whitelist } = this.store.getState()
+ if (whitelist.some((e) => e === hostname)) {
+ return false
+ }
+
const { result } = this._phishingDetector.check(hostname)
return result
}