-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: Encrypt user form data on client side #380
feat: Encrypt user form data on client side #380
Conversation
🦋 Changeset detectedLatest commit: 8ad679d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This is great! Thank you so much for this extremely helpful contribution. It goes a long way toward getting Namesake ready for launch. And thank you for the detailed and thoughtful PR comment; it helps a lot in understanding what's going on and limitations to follow up on. I'm filing a few issues here which address issues you mention in your PR comment:
Appreciate if you have any thoughts or color to add to either of those tickets! Feel free to comment with extra context or opinions. For this PR:
CleanShot.2025-02-06.at.22.26.01.mp4 |
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.
A few small comments and questions, but otherwise very excited to get this merged!
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.
LGTM! Thanks so much for your contribution, @atrakh!
What changed?
/settings/data
page to help demonstrate how the feature works. The forms in the UI are basic and should be updated in the future to properly support intended use cases.list
query to retrieve alluserFormData
for renderingWhy?
Users of namesake should have there data protected -- external parties and operators of namesake should have a minimal amount of PII (Personally Identifiable Information) available to them
How was this change made?
This PR implements a client-side encryption key, stored in IndexedDB in the browser, that is used to encrypt and decrypt data between the client and server.
I initially experimented with a two-key system (implementing a Key Encrypting Key), but found that implementation complicated and likely to not be completely secure.
This simpler implementation is more streamlined, reducing the risk of vulnerability. However, there are some things to consider regarding security:
This implementation does not currently implement convenient portability of the key. If the user logs in from another device, a new key will be generated and data will not load. I recommend we merge this PR as a proof-of-concept and add the portability feature (e.g. allowing the user to download their key and re-enter it later) as a follow-up.
How was this tested?
I added a basic test-suite to test round-trips -- encryption methods and IndexedDB are mocked. I also used the placeholder UI to test manually and confirm encrypted data is stored in Convex.
Anything else?
Migrations! If, after launch, the key-generation / encryption patterns are changed in the future, we'll need to maintain the existing implementation and migrate the database to indicate which implementation was used to encrypt the data for backwards compatability