@metamask-previews/keyring-controller 21.0.4-preview-5ea27f10 → 21.0.5-preview-20e2defb
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 +8 -1
- package/dist/KeyringController.cjs +28 -13
- package/dist/KeyringController.cjs.map +1 -1
- package/dist/KeyringController.d.cts.map +1 -1
- package/dist/KeyringController.d.mts.map +1 -1
- package/dist/KeyringController.mjs +28 -13
- package/dist/KeyringController.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [21.0.5]
|
|
11
|
+
|
|
10
12
|
### Changed
|
|
11
13
|
|
|
12
14
|
- Bump `@metamask/base-controller` from ^8.0.0 to ^8.0.1 ([#5722](https://github.com/MetaMask/core/pull/5722))
|
|
13
15
|
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- The vault encryption upgrade fails gracefully during login ([#5740](https://github.com/MetaMask/core/pull/5740))
|
|
19
|
+
|
|
14
20
|
## [21.0.4]
|
|
15
21
|
|
|
16
22
|
### Fixed
|
|
@@ -758,7 +764,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
758
764
|
|
|
759
765
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
760
766
|
|
|
761
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.
|
|
767
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.5...HEAD
|
|
768
|
+
[21.0.5]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.4...@metamask/keyring-controller@21.0.5
|
|
762
769
|
[21.0.4]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.3...@metamask/keyring-controller@21.0.4
|
|
763
770
|
[21.0.3]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.2...@metamask/keyring-controller@21.0.3
|
|
764
771
|
[21.0.2]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.1...@metamask/keyring-controller@21.0.2
|
|
@@ -36,7 +36,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
|
-
var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_keyrings, _KeyringController_unsupportedKeyrings, _KeyringController_keyringsMetadata, _KeyringController_password, _KeyringController_qrKeyringStateListener, _KeyringController_registerMessageHandlers, _KeyringController_getKeyringById, _KeyringController_getKeyringByIdOrDefault, _KeyringController_getKeyringMetadata, _KeyringController_getKeyringBuilderForType, _KeyringController_addQRKeyring, _KeyringController_subscribeToQRKeyringEvents, _KeyringController_unsubscribeFromQRKeyringsEvents, _KeyringController_createNewVaultWithKeyring, _KeyringController_verifySeedPhrase, _KeyringController_getUpdatedKeyrings, _KeyringController_getSerializedKeyrings, _KeyringController_restoreSerializedKeyrings, _KeyringController_unlockKeyrings, _KeyringController_updateVault, _KeyringController_getAccountsFromKeyrings, _KeyringController_createKeyringWithFirstAccount, _KeyringController_newKeyring, _KeyringController_createKeyring, _KeyringController_clearKeyrings, _KeyringController_restoreKeyring, _KeyringController_destroyKeyring, _KeyringController_removeEmptyKeyrings, _KeyringController_assertNoDuplicateAccounts, _KeyringController_setUnlocked, _KeyringController_assertIsUnlocked, _KeyringController_persistOrRollback, _KeyringController_withRollback, _KeyringController_assertControllerMutexIsLocked, _KeyringController_withControllerLock, _KeyringController_withVaultLock;
|
|
39
|
+
var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_keyrings, _KeyringController_unsupportedKeyrings, _KeyringController_keyringsMetadata, _KeyringController_password, _KeyringController_qrKeyringStateListener, _KeyringController_registerMessageHandlers, _KeyringController_getKeyringById, _KeyringController_getKeyringByIdOrDefault, _KeyringController_getKeyringMetadata, _KeyringController_getKeyringBuilderForType, _KeyringController_addQRKeyring, _KeyringController_subscribeToQRKeyringEvents, _KeyringController_unsubscribeFromQRKeyringsEvents, _KeyringController_createNewVaultWithKeyring, _KeyringController_verifySeedPhrase, _KeyringController_getUpdatedKeyrings, _KeyringController_getSerializedKeyrings, _KeyringController_restoreSerializedKeyrings, _KeyringController_unlockKeyrings, _KeyringController_updateVault, _KeyringController_upgradeVaultEncryptionParams, _KeyringController_getAccountsFromKeyrings, _KeyringController_createKeyringWithFirstAccount, _KeyringController_newKeyring, _KeyringController_createKeyring, _KeyringController_clearKeyrings, _KeyringController_restoreKeyring, _KeyringController_destroyKeyring, _KeyringController_removeEmptyKeyrings, _KeyringController_assertNoDuplicateAccounts, _KeyringController_setUnlocked, _KeyringController_assertIsUnlocked, _KeyringController_persistOrRollback, _KeyringController_withRollback, _KeyringController_assertControllerMutexIsLocked, _KeyringController_withControllerLock, _KeyringController_withVaultLock;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.KeyringController = exports.getDefaultKeyringState = exports.keyringBuilderFactory = exports.SignTypedDataVersion = exports.AccountImportStrategy = exports.isCustodyKeyring = exports.KeyringTypes = void 0;
|
|
42
42
|
const util_1 = require("@ethereumjs/util");
|
|
@@ -874,10 +874,20 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
874
874
|
* @returns Promise resolving when the operation completes.
|
|
875
875
|
*/
|
|
876
876
|
async submitPassword(password) {
|
|
877
|
-
|
|
877
|
+
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withRollback).call(this, async () => {
|
|
878
878
|
__classPrivateFieldSet(this, _KeyringController_keyrings, await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_unlockKeyrings).call(this, password), "f");
|
|
879
879
|
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_setUnlocked).call(this);
|
|
880
880
|
});
|
|
881
|
+
try {
|
|
882
|
+
// If there are stronger encryption params available, we
|
|
883
|
+
// can attempt to upgrade the vault.
|
|
884
|
+
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withRollback).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_upgradeVaultEncryptionParams).call(this));
|
|
885
|
+
}
|
|
886
|
+
catch (error) {
|
|
887
|
+
// We don't want to throw an error if the upgrade fails
|
|
888
|
+
// since the controller is already unlocked.
|
|
889
|
+
console.error('Failed to upgrade vault encryption params:', error);
|
|
890
|
+
}
|
|
881
891
|
}
|
|
882
892
|
/**
|
|
883
893
|
* Verifies the that the seed phrase restores the current keychain's accounts.
|
|
@@ -1306,7 +1316,7 @@ async function _KeyringController_restoreSerializedKeyrings(serializedKeyrings)
|
|
|
1306
1316
|
* @returns A promise resolving to the deserialized keyrings array.
|
|
1307
1317
|
*/
|
|
1308
1318
|
async function _KeyringController_unlockKeyrings(password, encryptionKey, encryptionSalt) {
|
|
1309
|
-
return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withVaultLock).call(this, async (
|
|
1319
|
+
return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withVaultLock).call(this, async () => {
|
|
1310
1320
|
const encryptedVault = this.state.vault;
|
|
1311
1321
|
if (!encryptedVault) {
|
|
1312
1322
|
throw new Error(constants_1.KeyringControllerError.VaultError);
|
|
@@ -1365,16 +1375,6 @@ async function _KeyringController_unlockKeyrings(password, encryptionKey, encryp
|
|
|
1365
1375
|
state.encryptionSalt = updatedState.encryptionSalt;
|
|
1366
1376
|
}
|
|
1367
1377
|
});
|
|
1368
|
-
if (__classPrivateFieldGet(this, _KeyringController_password, "f") &&
|
|
1369
|
-
(!__classPrivateFieldGet(this, _KeyringController_cacheEncryptionKey, "f") || !encryptionKey) &&
|
|
1370
|
-
__classPrivateFieldGet(this, _KeyringController_encryptor, "f").isVaultUpdated &&
|
|
1371
|
-
!__classPrivateFieldGet(this, _KeyringController_encryptor, "f").isVaultUpdated(encryptedVault)) {
|
|
1372
|
-
// The lock needs to be released before persisting the keyrings
|
|
1373
|
-
// to avoid deadlock
|
|
1374
|
-
releaseLock();
|
|
1375
|
-
// Re-encrypt the vault with safer method if one is available
|
|
1376
|
-
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_updateVault).call(this);
|
|
1377
|
-
}
|
|
1378
1378
|
return __classPrivateFieldGet(this, _KeyringController_keyrings, "f");
|
|
1379
1379
|
});
|
|
1380
1380
|
}, _KeyringController_updateVault = function _KeyringController_updateVault() {
|
|
@@ -1433,6 +1433,21 @@ async function _KeyringController_unlockKeyrings(password, encryptionKey, encryp
|
|
|
1433
1433
|
});
|
|
1434
1434
|
return true;
|
|
1435
1435
|
});
|
|
1436
|
+
}, _KeyringController_upgradeVaultEncryptionParams =
|
|
1437
|
+
/**
|
|
1438
|
+
* Upgrade the vault encryption parameters if needed.
|
|
1439
|
+
*
|
|
1440
|
+
* @returns A promise resolving to `void`.
|
|
1441
|
+
*/
|
|
1442
|
+
async function _KeyringController_upgradeVaultEncryptionParams() {
|
|
1443
|
+
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
|
|
1444
|
+
const { vault } = this.state;
|
|
1445
|
+
if (vault &&
|
|
1446
|
+
__classPrivateFieldGet(this, _KeyringController_password, "f") &&
|
|
1447
|
+
__classPrivateFieldGet(this, _KeyringController_encryptor, "f").isVaultUpdated &&
|
|
1448
|
+
!__classPrivateFieldGet(this, _KeyringController_encryptor, "f").isVaultUpdated(vault)) {
|
|
1449
|
+
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_updateVault).call(this);
|
|
1450
|
+
}
|
|
1436
1451
|
}, _KeyringController_getAccountsFromKeyrings =
|
|
1437
1452
|
/**
|
|
1438
1453
|
* Retrieves all the accounts from keyrings instances
|