@metamask-previews/keyring-controller 21.0.0-preview-8a8331b2 → 21.0.0-preview-57dc1075
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 +0 -6
- package/dist/KeyringController.cjs +9 -21
- 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 +9 -21
- package/dist/KeyringController.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,12 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Fixed
|
|
11
|
-
|
|
12
|
-
- Fixed duplication of unsupported keyrings ([#5535](https://github.com/MetaMask/core/pull/5535))
|
|
13
|
-
- Enforce keyrings metadata alignment when unlocking existing vault ([#5535](https://github.com/MetaMask/core/pull/5535))
|
|
14
|
-
- Fixed frozen object mutation attempt when updating metadata ([#5535](https://github.com/MetaMask/core/pull/5535))
|
|
15
|
-
|
|
16
10
|
## [21.0.0]
|
|
17
11
|
|
|
18
12
|
### Changed
|
|
@@ -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,
|
|
39
|
+
var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_unsupportedKeyrings, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_keyrings, _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_checkForDuplicate, _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");
|
|
@@ -267,10 +267,10 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
267
267
|
_KeyringController_controllerOperationMutex.set(this, new async_mutex_1.Mutex());
|
|
268
268
|
_KeyringController_vaultOperationMutex.set(this, new async_mutex_1.Mutex());
|
|
269
269
|
_KeyringController_keyringBuilders.set(this, void 0);
|
|
270
|
+
_KeyringController_unsupportedKeyrings.set(this, void 0);
|
|
270
271
|
_KeyringController_encryptor.set(this, void 0);
|
|
271
272
|
_KeyringController_cacheEncryptionKey.set(this, void 0);
|
|
272
273
|
_KeyringController_keyrings.set(this, void 0);
|
|
273
|
-
_KeyringController_unsupportedKeyrings.set(this, void 0);
|
|
274
274
|
_KeyringController_keyringsMetadata.set(this, void 0);
|
|
275
275
|
_KeyringController_password.set(this, void 0);
|
|
276
276
|
_KeyringController_qrKeyringStateListener.set(this, void 0);
|
|
@@ -279,7 +279,7 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
279
279
|
: defaultKeyringBuilders, "f");
|
|
280
280
|
__classPrivateFieldSet(this, _KeyringController_encryptor, encryptor, "f");
|
|
281
281
|
__classPrivateFieldSet(this, _KeyringController_keyrings, [], "f");
|
|
282
|
-
__classPrivateFieldSet(this, _KeyringController_keyringsMetadata, state?.keyringsMetadata
|
|
282
|
+
__classPrivateFieldSet(this, _KeyringController_keyringsMetadata, state?.keyringsMetadata ?? [], "f");
|
|
283
283
|
__classPrivateFieldSet(this, _KeyringController_unsupportedKeyrings, [], "f");
|
|
284
284
|
// This option allows the controller to cache an exported key
|
|
285
285
|
// for use in decrypting and encrypting data without password
|
|
@@ -1123,7 +1123,7 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
1123
1123
|
}
|
|
1124
1124
|
}
|
|
1125
1125
|
exports.KeyringController = KeyringController;
|
|
1126
|
-
_KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_vaultOperationMutex = new WeakMap(), _KeyringController_keyringBuilders = new WeakMap(),
|
|
1126
|
+
_KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_vaultOperationMutex = new WeakMap(), _KeyringController_keyringBuilders = new WeakMap(), _KeyringController_unsupportedKeyrings = new WeakMap(), _KeyringController_encryptor = new WeakMap(), _KeyringController_cacheEncryptionKey = new WeakMap(), _KeyringController_keyrings = new WeakMap(), _KeyringController_keyringsMetadata = new WeakMap(), _KeyringController_password = new WeakMap(), _KeyringController_qrKeyringStateListener = new WeakMap(), _KeyringController_instances = new WeakSet(), _KeyringController_registerMessageHandlers = function _KeyringController_registerMessageHandlers() {
|
|
1127
1127
|
this.messagingSystem.registerActionHandler(`${name}:signMessage`, this.signMessage.bind(this));
|
|
1128
1128
|
this.messagingSystem.registerActionHandler(`${name}:signEip7702Authorization`, this.signEip7702Authorization.bind(this));
|
|
1129
1129
|
this.messagingSystem.registerActionHandler(`${name}:signPersonalMessage`, this.signPersonalMessage.bind(this));
|
|
@@ -1295,9 +1295,6 @@ async function _KeyringController_restoreSerializedKeyrings(serializedKeyrings)
|
|
|
1295
1295
|
for (const serializedKeyring of serializedKeyrings) {
|
|
1296
1296
|
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_restoreKeyring).call(this, serializedKeyring);
|
|
1297
1297
|
}
|
|
1298
|
-
if (__classPrivateFieldGet(this, _KeyringController_keyrings, "f").length !== __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length) {
|
|
1299
|
-
throw new Error(constants_1.KeyringControllerError.KeyringMetadataLengthMismatch);
|
|
1300
|
-
}
|
|
1301
1298
|
}, _KeyringController_unlockKeyrings =
|
|
1302
1299
|
/**
|
|
1303
1300
|
* Unlock Keyrings, decrypting the vault and deserializing all
|
|
@@ -1537,7 +1534,6 @@ async function _KeyringController_clearKeyrings() {
|
|
|
1537
1534
|
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_destroyKeyring).call(this, keyring);
|
|
1538
1535
|
}
|
|
1539
1536
|
__classPrivateFieldSet(this, _KeyringController_keyrings, [], "f");
|
|
1540
|
-
__classPrivateFieldSet(this, _KeyringController_unsupportedKeyrings, [], "f");
|
|
1541
1537
|
}, _KeyringController_restoreKeyring =
|
|
1542
1538
|
/**
|
|
1543
1539
|
* Restore a Keyring from a provided serialized payload.
|
|
@@ -1551,19 +1547,16 @@ async function _KeyringController_restoreKeyring(serialized) {
|
|
|
1551
1547
|
try {
|
|
1552
1548
|
const { type, data } = serialized;
|
|
1553
1549
|
const keyring = await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_createKeyring).call(this, type, data);
|
|
1550
|
+
__classPrivateFieldGet(this, _KeyringController_keyrings, "f").push(keyring);
|
|
1554
1551
|
// If metadata is missing, assume the data is from an installation before
|
|
1555
1552
|
// we had keyring metadata.
|
|
1556
|
-
if (__classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length
|
|
1553
|
+
if (__classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length < __classPrivateFieldGet(this, _KeyringController_keyrings, "f").length) {
|
|
1557
1554
|
console.log(`Adding missing metadata for '${type}' keyring`);
|
|
1558
1555
|
__classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").push(getDefaultKeyringMetadata());
|
|
1559
1556
|
}
|
|
1560
|
-
// The keyring is added to the keyrings array only if it's successfully restored
|
|
1561
|
-
// and the metadata is successfully added to the controller
|
|
1562
|
-
__classPrivateFieldGet(this, _KeyringController_keyrings, "f").push(keyring);
|
|
1563
1557
|
return keyring;
|
|
1564
1558
|
}
|
|
1565
|
-
catch (
|
|
1566
|
-
console.error(error);
|
|
1559
|
+
catch (_) {
|
|
1567
1560
|
__classPrivateFieldGet(this, _KeyringController_unsupportedKeyrings, "f").push(serialized);
|
|
1568
1561
|
return undefined;
|
|
1569
1562
|
}
|
|
@@ -1636,11 +1629,6 @@ async function _KeyringController_checkForDuplicate(type, newAccountArray) {
|
|
|
1636
1629
|
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
|
|
1637
1630
|
this.update((state) => {
|
|
1638
1631
|
state.isUnlocked = true;
|
|
1639
|
-
// If new keyringsMetadata was generated during the unlock operation,
|
|
1640
|
-
// we'll have to update the state with the new array
|
|
1641
|
-
if (__classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length > state.keyringsMetadata.length) {
|
|
1642
|
-
state.keyringsMetadata = __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").slice();
|
|
1643
|
-
}
|
|
1644
1632
|
});
|
|
1645
1633
|
this.messagingSystem.publish(`${name}:unlock`);
|
|
1646
1634
|
}, _KeyringController_assertIsUnlocked = function _KeyringController_assertIsUnlocked() {
|
|
@@ -1681,9 +1669,9 @@ async function _KeyringController_withRollback(callback) {
|
|
|
1681
1669
|
}
|
|
1682
1670
|
catch (e) {
|
|
1683
1671
|
// Keyrings and password are restored to their previous state
|
|
1684
|
-
__classPrivateFieldSet(this, _KeyringController_keyringsMetadata, currentKeyringsMetadata, "f");
|
|
1685
|
-
__classPrivateFieldSet(this, _KeyringController_password, currentPassword, "f");
|
|
1686
1672
|
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_restoreSerializedKeyrings).call(this, currentSerializedKeyrings);
|
|
1673
|
+
__classPrivateFieldSet(this, _KeyringController_password, currentPassword, "f");
|
|
1674
|
+
__classPrivateFieldSet(this, _KeyringController_keyringsMetadata, currentKeyringsMetadata, "f");
|
|
1687
1675
|
throw e;
|
|
1688
1676
|
}
|
|
1689
1677
|
});
|