-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BREAKING: Refactor encryption to enable caching #2316
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FrederikBolding
force-pushed
the
fb/encryption-refactor
branch
from
April 9, 2024 08:40
a09b48c
to
bab90de
Compare
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/locate-app@2.1.0, npm/n12@0.4.0 |
Mrtenz
requested changes
Apr 9, 2024
Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
hmalik88
approved these changes
Apr 9, 2024
Mrtenz
reviewed
Apr 10, 2024
* @param opts - The options to use for key derivation. | ||
* @returns The encryption key. | ||
*/ | ||
keyFromPassword: <Type>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the key type is used in more functions, I would add it as generic for the type itself.
type ExportableKeyEncryptor<Key> = ... & {
decryptWithKey: (key: Key, ...) => Promise<...>;
importKey: <Key>(key: string) => Promise<Key>;
keyFromPassword: (...) => Promise<Key>;
// etc.
};
That guarantees we use the same key for an encryptor.
Mrtenz
approved these changes
Apr 10, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a refactor of the Snap state encryption logic, it moves the logic from the manageState RPC method implementation to the SnapController. It re-implements the encryption/decryption logic using a different set of methods, as the previously used implementation had encapsulated the encryption key. With this refactor it is now possible to cache the encryption key used by the Snap in the runtime, making continuous requests to update the state much faster (numbers TBD).
With this refactor it is now the responsibility of the SnapController to manage encrypting/decrypting the Snap state and thus the method hooks
getSnapState
andupdateSnapState
have had breaking changes, they are now asynchronous and expected to fully handle encryption/decryption. Because of that, this change required changes to both snaps-jest and snaps-simulator for compatibility.This will not work as-is on mobile, since the encryptor on mobile does not have feature parity with
browser-passworder
. This will need to be addressed before we can use this change on mobile.Closes #2315