mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 09:23:21 +01:00
Fix new encryptor migration logic
This commit is contained in:
parent
1e46d858e9
commit
05c8658ff3
@ -118,6 +118,7 @@ module.exports = class KeyringController extends EventEmitter {
|
||||
return this.idStoreMigrator.migratedVaultForPassword(password)
|
||||
.then((serialized) => {
|
||||
if (serialized && shouldMigrate) {
|
||||
this.password = password
|
||||
const keyring = this.restoreKeyring(serialized)
|
||||
this.keyrings.push(keyring)
|
||||
this.configManager.setSelectedAccount(keyring.getAccounts()[0])
|
||||
@ -185,7 +186,6 @@ module.exports = class KeyringController extends EventEmitter {
|
||||
cb(null, this.getState())
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
cb(err)
|
||||
})
|
||||
}
|
||||
@ -558,7 +558,7 @@ module.exports = class KeyringController extends EventEmitter {
|
||||
}
|
||||
|
||||
setLocked (cb) {
|
||||
this.key = null
|
||||
this.password = null
|
||||
this.keyrings = []
|
||||
this.emit('update')
|
||||
cb()
|
||||
|
@ -42,7 +42,6 @@ function encryptWithKey (key, dataObj) {
|
||||
var data = JSON.stringify(dataObj)
|
||||
var dataBuffer = convertStringToArrayBufferView(data)
|
||||
var vector = global.crypto.getRandomValues(new Uint8Array(16))
|
||||
|
||||
return global.crypto.subtle.encrypt({
|
||||
name: 'AES-GCM',
|
||||
iv: vector,
|
||||
|
@ -44,3 +44,14 @@ QUnit.test('keyringController:submitPassword', function (assert) {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
QUnit.test('keyringController:setLocked', function (assert) {
|
||||
var done = assert.async()
|
||||
var self = this
|
||||
|
||||
this.keyringController.setLocked(function(err) {
|
||||
assert.notOk(self.keyringController.password, 'password should be deallocated')
|
||||
assert.deepEqual(self.keyringController.keyrings, [], 'keyrings should be deallocated')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user