@metamask-previews/keyring-controller 21.0.1-preview-7f6d1f4 → 21.0.2-preview-9d7b1fa6

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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [21.0.2]
11
+
12
+ ### Changed
13
+
14
+ - Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](https://github.com/MetaMask/core/pull/5565))
15
+ - Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](https://github.com/MetaMask/core/pull/5565))
16
+
17
+ ### Fixed
18
+
19
+ - Ignore cached encryption key when the vault needs to upgrade its encryption parameters ([#5601](https://github.com/MetaMask/core/pull/5601))
20
+
10
21
  ## [21.0.1]
11
22
 
12
23
  ### Fixed
@@ -726,7 +737,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
726
737
 
727
738
  All changes listed after this point were applied to this package following the monorepo conversion.
728
739
 
729
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.1...HEAD
740
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.2...HEAD
741
+ [21.0.2]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.1...@metamask/keyring-controller@21.0.2
730
742
  [21.0.1]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.0...@metamask/keyring-controller@21.0.1
731
743
  [21.0.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@20.0.0...@metamask/keyring-controller@21.0.0
732
744
  [20.0.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.2.2...@metamask/keyring-controller@20.0.0
@@ -1377,7 +1377,14 @@ async function _KeyringController_unlockKeyrings(password, encryptionKey, encryp
1377
1377
  });
1378
1378
  }, _KeyringController_updateVault = function _KeyringController_updateVault() {
1379
1379
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withVaultLock).call(this, async () => {
1380
- const { encryptionKey, encryptionSalt } = this.state;
1380
+ const { encryptionKey, encryptionSalt, vault } = this.state;
1381
+ // READ THIS CAREFULLY:
1382
+ // We do check if the vault is still considered up-to-date, if not, we would not re-use the
1383
+ // cached key and we will re-generate a new one (based on the password).
1384
+ //
1385
+ // This helps doing seamless updates of the vault. Useful in case we change some cryptographic
1386
+ // parameters to the KDF.
1387
+ const useCachedKey = encryptionKey && vault && __classPrivateFieldGet(this, _KeyringController_encryptor, "f").isVaultUpdated?.(vault);
1381
1388
  if (!__classPrivateFieldGet(this, _KeyringController_password, "f") && !encryptionKey) {
1382
1389
  throw new Error(constants_1.KeyringControllerError.MissingCredentials);
1383
1390
  }
@@ -1388,7 +1395,7 @@ async function _KeyringController_unlockKeyrings(password, encryptionKey, encryp
1388
1395
  const updatedState = {};
1389
1396
  if (__classPrivateFieldGet(this, _KeyringController_cacheEncryptionKey, "f")) {
1390
1397
  assertIsExportableKeyEncryptor(__classPrivateFieldGet(this, _KeyringController_encryptor, "f"));
1391
- if (encryptionKey) {
1398
+ if (useCachedKey) {
1392
1399
  const key = await __classPrivateFieldGet(this, _KeyringController_encryptor, "f").importKey(encryptionKey);
1393
1400
  const vaultJSON = await __classPrivateFieldGet(this, _KeyringController_encryptor, "f").encryptWithKey(key, serializedKeyrings);
1394
1401
  vaultJSON.salt = encryptionSalt;