mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
On update, check whether the TOS has changed using hashes.
This commit is contained in:
parent
4ea3246912
commit
0a9b814f11
@ -8,6 +8,9 @@ const messageManager = require('./lib/message-manager')
|
|||||||
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
|
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
|
||||||
const MetamaskController = require('./metamask-controller')
|
const MetamaskController = require('./metamask-controller')
|
||||||
const extension = require('./lib/extension')
|
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'
|
const STORAGE_KEY = 'metamask-config'
|
||||||
var popupIsOpen = false
|
var popupIsOpen = false
|
||||||
@ -29,8 +32,20 @@ function triggerUi () {
|
|||||||
// On first install, open a window to MetaMask website to how-it-works.
|
// On first install, open a window to MetaMask website to how-it-works.
|
||||||
|
|
||||||
extension.runtime.onInstalled.addListener(function (details) {
|
extension.runtime.onInstalled.addListener(function (details) {
|
||||||
|
const newTOSHash = stringHash(disclaimer)
|
||||||
if (details.reason === 'install') {
|
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'})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user