Commit 82831ec
## Explanation
<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:
* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->
This PR includes part of the changes originally proposed in [this
PR](#5963) that were inflating its
size:
- Remove the `cacheEncryptionKey` flag from `KeyringController`
constructor options and instance variables
- All code paths that used this flag have been removed (effectively, the
controller behaves as if the flag was always `true`)
- `GenericEncryptor` and `ExportableKeyEncryptor` have been merged into
a single `Encryptor` type.
- The `Encryptor` type has also been fixed to be compatible with
`@metamask/browser-passworder` and `Encryptor` from mobile
- As `Encryptor` now accepts type parameters to specify encryption key
and derivation params types, the `KeyringController` has been updated to
accept these type parameters and pass them to the `Encryptor` instance.
## References
<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?
For example:
* Fixes #12345
* Related to #67890
-->
* Related to #6010
## Checklist
- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Unifies the encryptor interface with a new generic `Encryptor`,
removes `cacheEncryptionKey` and requires an `encryptor` for
`KeyringController`, adds a derivation-options type param to
`SeedlessOnboardingController`, and updates tests/types accordingly.
>
> - **Keyring Controller**:
> - Replace `GenericEncryptor`/`ExportableKeyEncryptor` with a single
generic `Encryptor` (supports key import/export, detailed
encrypt/decrypt, custom result types).
> - Add generic type params `EncryptionKey`,
`SupportedKeyDerivationOptions`, and `EncryptionResult` to
`KeyringController` and `KeyringControllerOptions`.
> - BREAKING: `encryptor` is now required; remove `cacheEncryptionKey`
and related paths/state handling.
> - Fix `decryptWithKey` typing to accept encryption result object.
> - **Seedless Onboarding Controller**:
> - Add optional `SupportedKeyDerivationOptions` type parameter; update
`VaultEncryptor` to use unified `Encryptor`.
> - **Tests/Mocks**:
> - Refactor tests to new encryptor API; remove branches for
`cacheEncryptionKey`; add `createVault` helper and adjust mocks to new
types.
> - **Changelogs/Config**:
> - Update package changelogs to document breaking changes and new
generics.
> - Slightly lower Jest coverage thresholds for `keyring-controller`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
16f68c7. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Frederik Bolding <[email protected]>
1 parent 6ceb161 commit 82831ec
File tree
10 files changed
+942
-1166
lines changed- packages
- keyring-controller
- src
- tests/mocks
- seedless-onboarding-controller
- src
- tests/mocks
10 files changed
+942
-1166
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
10 | 30 | | |
11 | 31 | | |
12 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
0 commit comments