aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-10-06 18:25:03 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-10-06 18:25:03 +0800
commit0a9b814f11cc423ab1e5541c5f4e0b0b1385a3dd (patch)
tree24d06fc089f27900f71d322ba5df6d2de1dbe79e
parent4ea3246912306ac52d520b8c34180392c0afcba7 (diff)
downloadtangerine-wallet-browser-0a9b814f11cc423ab1e5541c5f4e0b0b1385a3dd.tar
tangerine-wallet-browser-0a9b814f11cc423ab1e5541c5f4e0b0b1385a3dd.tar.gz
tangerine-wallet-browser-0a9b814f11cc423ab1e5541c5f4e0b0b1385a3dd.tar.bz2
tangerine-wallet-browser-0a9b814f11cc423ab1e5541c5f4e0b0b1385a3dd.tar.lz
tangerine-wallet-browser-0a9b814f11cc423ab1e5541c5f4e0b0b1385a3dd.tar.xz
tangerine-wallet-browser-0a9b814f11cc423ab1e5541c5f4e0b0b1385a3dd.tar.zst
tangerine-wallet-browser-0a9b814f11cc423ab1e5541c5f4e0b0b1385a3dd.zip
On update, check whether the TOS has changed using hashes.
-rw-r--r--app/scripts/background.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 652acc113..92a76b31e 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -8,6 +8,9 @@ const messageManager = require('./lib/message-manager')
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
const MetamaskController = require('./metamask-controller')
const extension = require('./lib/extension')
+const fs = require('fs')
+const disclaimer = fs.readFileSync(path.join(__dirname, '..', '..', 'USER_AGREEMENT.md')).toString()
+const stringHash = require('string-hash')
const STORAGE_KEY = 'metamask-config'
var popupIsOpen = false
@@ -29,8 +32,20 @@ function triggerUi () {
// On first install, open a window to MetaMask website to how-it-works.
extension.runtime.onInstalled.addListener(function (details) {
+ const newTOSHash = stringHash(disclaimer)
if (details.reason === 'install') {
- extension.tabs.create({url: 'https://metamask.io/#how-it-works'})
+ controller.setTOSHash(newTOSHash, () => {
+ extension.tabs.create({url: 'https://metamask.io/#how-it-works'})
+ })
+ } else if (details.reason === 'update') {
+ controller.checkTOSChange(newTOSHash, (hasChanged) => {
+ if (hasChanged) {
+ controller.resetDisclaimer()
+ controller.setTOSHash(newTOSHash, () => {
+ extension.tabs.create({url: 'https://metamask.io/terms.html'})
+ })
+ }
+ })
}
})