diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-04-01 01:47:40 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-04-01 01:47:40 +0800 |
commit | f5105293bf2d3e6fb325e015b5b2b67baa7d03cc (patch) | |
tree | 1346ea1582acb5ceb0156b023637f3288a525185 | |
parent | ea7b89172973fba27cc7a0b63c87289667175145 (diff) | |
download | tangerine-wallet-browser-f5105293bf2d3e6fb325e015b5b2b67baa7d03cc.tar tangerine-wallet-browser-f5105293bf2d3e6fb325e015b5b2b67baa7d03cc.tar.gz tangerine-wallet-browser-f5105293bf2d3e6fb325e015b5b2b67baa7d03cc.tar.bz2 tangerine-wallet-browser-f5105293bf2d3e6fb325e015b5b2b67baa7d03cc.tar.lz tangerine-wallet-browser-f5105293bf2d3e6fb325e015b5b2b67baa7d03cc.tar.xz tangerine-wallet-browser-f5105293bf2d3e6fb325e015b5b2b67baa7d03cc.tar.zst tangerine-wallet-browser-f5105293bf2d3e6fb325e015b5b2b67baa7d03cc.zip |
Do not cache the seed, retrieve it from the decrypted wallet
-rw-r--r-- | app/scripts/lib/config-manager.js | 14 | ||||
-rw-r--r-- | app/scripts/lib/idStore.js | 22 |
2 files changed, 21 insertions, 15 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index 038774a30..682b34637 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -88,20 +88,16 @@ ConfigManager.prototype.getWallet = function() { return this.migrator.getData().wallet } -ConfigManager.prototype.getSeedWords = function() { - return this.migrator.getData().seedWords -} - -ConfigManager.prototype.setSeedWords = function(seedWords) { +// Takes a boolean +ConfigManager.prototype.setShowSeedWords = function(should) { var data = this.migrator.getData() - data.seedWords = seedWords + data.showSeedWords = should this.setData(data) } -ConfigManager.prototype.clearSeedWords = function() { +ConfigManager.prototype.getShouldShowSeedWords = function() { var data = this.migrator.getData() - delete data.seedWords - this.setData(data) + return data.showSeedWords } ConfigManager.prototype.getCurrentRpcAddress = function() { diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index f8267f6ca..1bc1ebcb2 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -45,11 +45,13 @@ IdentityStore.prototype.createNewVault = function(password, entropy, cb){ configManager.clearWallet() this._createIdmgmt(password, null, entropy, (err) => { if (err) return cb(err) - var seedWords = this._idmgmt.getSeed() - configManager.setSeedWords(seedWords) + this._loadIdentities() this._didUpdate() this._autoFaucet() + + configManager.setShowSeedWords(true) + var seedWords = this._idmgmt.getSeed() cb(null, seedWords) }) } @@ -69,20 +71,28 @@ IdentityStore.prototype.setStore = function(store){ } IdentityStore.prototype.clearSeedWordCache = function(cb) { - configManager.clearSeedWords() + configManager.setShowSeedWords(false) cb() } IdentityStore.prototype.getState = function(){ - const cachedSeeds = configManager.getSeedWords() + var seedWords = this.getSeedIfUnlocked() var wallet = configManager.getWallet() return clone(extend(this._currentState, { - isInitialized: !!configManager.getWallet() && !cachedSeeds, + isInitialized: !!configManager.getWallet() && !seedWords, isUnlocked: this._isUnlocked(), - seedWords: cachedSeeds, + seedWords: seedWords, })) } +IdentityStore.prototype.getSeedIfUnlocked = function() { + var showSeed = configManager.getShouldShowSeedWords() + var idmgmt = this._idmgmt + var shouldShow = showSeed && !!idmgmt + var seedWords = shouldShow ? idmgmt.getSeed() : null + return seedWords +} + IdentityStore.prototype.getSelectedAddress = function(){ return this._currentState.selectedAddress } |