@metamask-previews/keyring-controller 22.0.2-preview-01cb507d → 22.0.2-preview-08a4995
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 -8
- package/dist/KeyringController.cjs +7 -28
- package/dist/KeyringController.cjs.map +1 -1
- package/dist/KeyringController.d.cts +4 -11
- package/dist/KeyringController.d.cts.map +1 -1
- package/dist/KeyringController.d.mts +4 -11
- package/dist/KeyringController.d.mts.map +1 -1
- package/dist/KeyringController.mjs +7 -28
- package/dist/KeyringController.mjs.map +1 -1
- package/dist/constants.cjs +0 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +0 -1
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +0 -1
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +0 -1
- package/dist/constants.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,14 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
- Add method `exportEncryptionKey` ([#5984](https://github.com/MetaMask/core/pull/5984))
|
|
13
|
-
|
|
14
|
-
### Changed
|
|
15
|
-
|
|
16
|
-
- Make salt optional with method `submitEncryptionKey` ([#5984](https://github.com/MetaMask/core/pull/5984))
|
|
17
|
-
|
|
18
10
|
## [22.0.2]
|
|
19
11
|
|
|
20
12
|
### Fixed
|
|
@@ -154,17 +154,6 @@ function assertIsExportableKeyEncryptor(encryptor) {
|
|
|
154
154
|
throw new Error(constants_1.KeyringControllerError.UnsupportedEncryptionKeyExport);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
/**
|
|
158
|
-
* Assert that the encryption key is set.
|
|
159
|
-
*
|
|
160
|
-
* @param encryptionKey - The encryption key to check.
|
|
161
|
-
* @throws If the encryption key is not set.
|
|
162
|
-
*/
|
|
163
|
-
function assertIsEncryptionKeySet(encryptionKey) {
|
|
164
|
-
if (!encryptionKey) {
|
|
165
|
-
throw new Error(constants_1.KeyringControllerError.EncryptionKeyNotSet);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
157
|
/**
|
|
169
158
|
* Assert that the provided password is a valid non-empty string.
|
|
170
159
|
*
|
|
@@ -869,12 +858,11 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
869
858
|
});
|
|
870
859
|
}
|
|
871
860
|
/**
|
|
872
|
-
* Attempts to decrypt the current vault and load its keyrings,
|
|
873
|
-
* given encryption key and salt.
|
|
874
|
-
* consistency with the vault salt.
|
|
861
|
+
* Attempts to decrypt the current vault and load its keyrings,
|
|
862
|
+
* using the given encryption key and salt.
|
|
875
863
|
*
|
|
876
864
|
* @param encryptionKey - Key to unlock the keychain.
|
|
877
|
-
* @param encryptionSalt -
|
|
865
|
+
* @param encryptionSalt - Salt to unlock the keychain.
|
|
878
866
|
* @returns Promise resolving when the operation completes.
|
|
879
867
|
*/
|
|
880
868
|
async submitEncryptionKey(encryptionKey, encryptionSalt) {
|
|
@@ -898,15 +886,6 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
898
886
|
console.error('Failed to update vault during login:', error);
|
|
899
887
|
}
|
|
900
888
|
}
|
|
901
|
-
/**
|
|
902
|
-
* Exports the vault encryption key.
|
|
903
|
-
*
|
|
904
|
-
* @returns The vault encryption key.
|
|
905
|
-
*/
|
|
906
|
-
async exportEncryptionKey() {
|
|
907
|
-
assertIsEncryptionKeySet(this.state.encryptionKey);
|
|
908
|
-
return this.state.encryptionKey;
|
|
909
|
-
}
|
|
910
889
|
/**
|
|
911
890
|
* Attempts to decrypt the current vault and load its keyrings,
|
|
912
891
|
* using the given password.
|
|
@@ -1405,12 +1384,9 @@ async function _KeyringController_unlockKeyrings(password, encryptionKey, encryp
|
|
|
1405
1384
|
}
|
|
1406
1385
|
else {
|
|
1407
1386
|
const parsedEncryptedVault = JSON.parse(encryptedVault);
|
|
1408
|
-
if (encryptionSalt
|
|
1387
|
+
if (encryptionSalt !== parsedEncryptedVault.salt) {
|
|
1409
1388
|
throw new Error(constants_1.KeyringControllerError.ExpiredCredentials);
|
|
1410
1389
|
}
|
|
1411
|
-
else {
|
|
1412
|
-
encryptionSalt = parsedEncryptedVault.salt;
|
|
1413
|
-
}
|
|
1414
1390
|
if (typeof encryptionKey !== 'string') {
|
|
1415
1391
|
throw new TypeError(constants_1.KeyringControllerError.WrongPasswordType);
|
|
1416
1392
|
}
|
|
@@ -1419,6 +1395,9 @@ async function _KeyringController_unlockKeyrings(password, encryptionKey, encryp
|
|
|
1419
1395
|
// This call is required on the first call because encryptionKey
|
|
1420
1396
|
// is not yet inside the memStore
|
|
1421
1397
|
updatedState.encryptionKey = encryptionKey;
|
|
1398
|
+
// we can safely assume that encryptionSalt is defined here
|
|
1399
|
+
// because we compare it with the salt from the vault
|
|
1400
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1422
1401
|
updatedState.encryptionSalt = encryptionSalt;
|
|
1423
1402
|
}
|
|
1424
1403
|
}
|