@metamask-previews/keyring-controller 24.0.0-preview-2e88eaea → 24.0.0-preview-b289ac1c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -850,7 +850,7 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
850
850
|
return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
|
|
851
851
|
assertIsValidPassword(password);
|
|
852
852
|
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_deriveEncryptionKey).call(this, password, {
|
|
853
|
-
|
|
853
|
+
ignoreExistingVault: false,
|
|
854
854
|
});
|
|
855
855
|
});
|
|
856
856
|
}
|
|
@@ -922,7 +922,7 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
922
922
|
// If the vault is being upgraded, we want to ignore the metadata
|
|
923
923
|
// that is already in the vault, so we can effectively
|
|
924
924
|
// re-encrypt the vault with the new encryption config.
|
|
925
|
-
|
|
925
|
+
ignoreExistingVault: false,
|
|
926
926
|
});
|
|
927
927
|
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_updateVault).call(this);
|
|
928
928
|
}
|
|
@@ -1045,7 +1045,9 @@ async function _KeyringController_createNewVaultWithKeyring(password, keyring) {
|
|
|
1045
1045
|
delete state.encryptionKey;
|
|
1046
1046
|
delete state.encryptionSalt;
|
|
1047
1047
|
});
|
|
1048
|
-
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_deriveEncryptionKey).call(this, password
|
|
1048
|
+
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_deriveEncryptionKey).call(this, password, {
|
|
1049
|
+
ignoreExistingVault: false,
|
|
1050
|
+
});
|
|
1049
1051
|
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_clearKeyrings).call(this);
|
|
1050
1052
|
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_createKeyringWithFirstAccount).call(this, keyring.type, keyring.opts);
|
|
1051
1053
|
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_setUnlocked).call(this);
|
|
@@ -1059,12 +1061,16 @@ async function _KeyringController_createNewVaultWithKeyring(password, keyring) {
|
|
|
1059
1061
|
* using the salt from the vault. If the vault is empty, a new salt
|
|
1060
1062
|
* is generated and used to derive the key.
|
|
1061
1063
|
*
|
|
1064
|
+
* If `options.ignoreExistingVault` is set to `false`, the existing
|
|
1065
|
+
* vault is completely ignored: the new key won't be able to decrypt
|
|
1066
|
+
* the existing vault, and should be used to re-encrypt it.
|
|
1067
|
+
*
|
|
1062
1068
|
* @param password - The password to use for decryption or derivation.
|
|
1063
1069
|
* @param options - Options for the key derivation.
|
|
1064
|
-
* @param options.
|
|
1070
|
+
* @param options.ignoreExistingVault - Whether to use the existing vault salt and key metadata
|
|
1065
1071
|
*/
|
|
1066
1072
|
async function _KeyringController_deriveEncryptionKey(password, options = {
|
|
1067
|
-
|
|
1073
|
+
ignoreExistingVault: true,
|
|
1068
1074
|
}) {
|
|
1069
1075
|
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
|
|
1070
1076
|
const { vault } = this.state;
|
|
@@ -1072,7 +1078,7 @@ async function _KeyringController_deriveEncryptionKey(password, options = {
|
|
|
1072
1078
|
throw new TypeError(constants_1.KeyringControllerError.WrongPasswordType);
|
|
1073
1079
|
}
|
|
1074
1080
|
let serializedEncryptionKey, salt;
|
|
1075
|
-
if (vault && options.
|
|
1081
|
+
if (vault && options.ignoreExistingVault) {
|
|
1076
1082
|
// The `decryptWithDetail` method is being used here instead of
|
|
1077
1083
|
// `keyFromPassword` + `exportKey` to let the encryptor handle
|
|
1078
1084
|
// any legacy encryption formats and metadata that might be
|