THU-420: E2EE Config Updates#602
THU-420: E2EE Config Updates#602raivieiraadriano92 wants to merge 13 commits intoraivieiraadriano92/public-config-endpointfrom
Conversation
Semgrep Security ScanNo security issues found. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
58eb73c to
3caac3f
Compare
3caac3f to
2b9ecac
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
0f70bab to
7cf3273
Compare
This comment was marked as outdated.
This comment was marked as outdated.
3 similar comments
|
Fixed in 9cbe8e2 — |
1 similar comment
|
Fixed in 9cbe8e2 — |
1 similar comment
5fb96a0 to
3a64402
Compare
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
No issues found. The initialization is sequential (config fetch → DB init), the sign-in modal renders only after |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
e9ccc6f to
d8f93ae
Compare
…t with localStorage caching
When fetchConfig fails (network error, timeout), return null instead of a hardcoded default with e2eeEnabled: false. This prevents silently overwriting a previously-stored E2EE=true in localStorage during transient outages, which would disable encryption and cause data corruption when encrypted data arrives without decryption middleware. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
No circular dependency between config.ts and key-storage.ts. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
handleSignInSuccess was async but passed as () => void callback, causing unhandled promise rejections if needsSyncSetupWizard or setSyncEnabled failed. Wrap async work with .catch(console.error) at the source so errors are logged instead of silently swallowed. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…rage Remove setEncryptionEnabled, e2eeStorageKey, and the separate e2ee_enabled localStorage key. isEncryptionEnabled now reads from the Zustand config store (persisted via thunderbolt-config), which is already hydrated from the /config endpoint during app initialization. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…isabled Exercises the allowNewDevice branch where the device doesn't exist in DB, verifying auto-creation with correct userId, trusted: true, and device name. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
98ec48d to
a0087cf
Compare
…raadriano92/thu-420-make-e2ee-not-enabled-by-default
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 834b290. Configure here.
| this.powerSync = new ThunderboltPowerSyncDatabase(options) | ||
| // Use ThunderboltPowerSyncDatabase (with TransformableBucketStorage) only when E2EE is enabled. | ||
| // When disabled, the standard PowerSyncDatabase avoids unnecessary middleware overhead. | ||
| this.powerSync = isEncryptionEnabled() ? new ThunderboltPowerSyncDatabase(options) : new PowerSyncDatabase(options) |
There was a problem hiding this comment.
Encryption decision made twice independently in initialize
Low Severity
isEncryptionEnabled() is read independently in getPowerSyncOptions (to configure transformers and sync worker) and again in initialize (to pick the database class). These two decisions are tightly coupled — ThunderboltPowerSyncDatabase is needed precisely when transformers are included — yet they're made via separate, uncorrelated reads. While safe today because both calls are synchronous with no intervening await, this creates a non-obvious coupling where future modifications could cause an inconsistency between the options and the database class.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 834b290. Configure here.


Summary
VITE_E2EE_ENABLED(frontend) andE2EE_ENABLED(backend) default tofalse, so sync works out of the box without encryption."true"to enable E2EE.Frontend
isEncryptionEnabled()to require explicitVITE_E2EE_ENABLED="true"needsSyncSetupWizard()shared helper used by both sign-in flow and sync toggle.env.examplecommentsBackend
e2eeEnabledsetting (E2EE_ENABLEDenv var, defaultfalse)validateDeviceForSyncwhen E2EE is disabledapprovalPending)allowNewDevicebypass to token path only — upload still requires device to exist (defense-in-depth).env.examplewith new env varDocs
docs/e2e-encryption.mdConfiguration section with both FE and BE env varsTest plan
bun testpasses in backend (55 powersync tests, 3 new E2EE settings tests)make checkpasses (typecheck, lint, format)"true"→ encryption wizard appears on first sync🤖 Generated with Claude Code
Note
Medium Risk
Changes sync gating and device trust behavior in
powersynctoken/upload paths; incorrect flag handling could weaken device enforcement or break sync enablement flows.Overview
E2EE is now disabled by default and controlled by a single backend flag (
E2EE_ENABLED), exposed via a new/expanded unauthenticatedGET /configresponse ({ e2eeEnabled }) that the frontend persists in its config store.PowerSync device enforcement is updated to respect this flag: when E2EE is off, token issuance can create/auto-trust devices (and upgrades existing devices to trusted), while uploads still require an existing non-revoked device; when E2EE is on, the existing trusted-device requirement remains.
On the frontend,
isEncryptionEnabled()now reads the persisted backend config (removingVITE_E2EE_ENABLED), addsneedsSyncSetupWizard()to gate sync enablement in both sign-in and the sync toggle, and avoids showing pending-device notifications when encryption is disabled; docs/tests are updated accordingly.Reviewed by Cursor Bugbot for commit 834b290. Bugbot is set up for automated code reviews on this repo. Configure here.