1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Do not cache the seed, retrieve it from the decrypted wallet

This commit is contained in:
Dan Finlay 2016-03-31 10:47:40 -07:00
parent ea7b891729
commit f5105293bf
2 changed files with 21 additions and 15 deletions

View File

@ -88,20 +88,16 @@ ConfigManager.prototype.getWallet = function() {
return this.migrator.getData().wallet return this.migrator.getData().wallet
} }
ConfigManager.prototype.getSeedWords = function() { // Takes a boolean
return this.migrator.getData().seedWords ConfigManager.prototype.setShowSeedWords = function(should) {
}
ConfigManager.prototype.setSeedWords = function(seedWords) {
var data = this.migrator.getData() var data = this.migrator.getData()
data.seedWords = seedWords data.showSeedWords = should
this.setData(data) this.setData(data)
} }
ConfigManager.prototype.clearSeedWords = function() { ConfigManager.prototype.getShouldShowSeedWords = function() {
var data = this.migrator.getData() var data = this.migrator.getData()
delete data.seedWords return data.showSeedWords
this.setData(data)
} }
ConfigManager.prototype.getCurrentRpcAddress = function() { ConfigManager.prototype.getCurrentRpcAddress = function() {

View File

@ -45,11 +45,13 @@ IdentityStore.prototype.createNewVault = function(password, entropy, cb){
configManager.clearWallet() configManager.clearWallet()
this._createIdmgmt(password, null, entropy, (err) => { this._createIdmgmt(password, null, entropy, (err) => {
if (err) return cb(err) if (err) return cb(err)
var seedWords = this._idmgmt.getSeed()
configManager.setSeedWords(seedWords)
this._loadIdentities() this._loadIdentities()
this._didUpdate() this._didUpdate()
this._autoFaucet() this._autoFaucet()
configManager.setShowSeedWords(true)
var seedWords = this._idmgmt.getSeed()
cb(null, seedWords) cb(null, seedWords)
}) })
} }
@ -69,20 +71,28 @@ IdentityStore.prototype.setStore = function(store){
} }
IdentityStore.prototype.clearSeedWordCache = function(cb) { IdentityStore.prototype.clearSeedWordCache = function(cb) {
configManager.clearSeedWords() configManager.setShowSeedWords(false)
cb() cb()
} }
IdentityStore.prototype.getState = function(){ IdentityStore.prototype.getState = function(){
const cachedSeeds = configManager.getSeedWords() var seedWords = this.getSeedIfUnlocked()
var wallet = configManager.getWallet() var wallet = configManager.getWallet()
return clone(extend(this._currentState, { return clone(extend(this._currentState, {
isInitialized: !!configManager.getWallet() && !cachedSeeds, isInitialized: !!configManager.getWallet() && !seedWords,
isUnlocked: this._isUnlocked(), 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(){ IdentityStore.prototype.getSelectedAddress = function(){
return this._currentState.selectedAddress return this._currentState.selectedAddress
} }