Commit Graph
29 Commits
Author SHA1 Message Date
ZacharyZhang-NY 74b3de54ed Add email + OTP sign-in flow for cloud sync
Replace the "drop a session token in a file" workflow with a real
Chrome-style email login. The Cloudflare worker already had Better
Auth's `email-otp` plugin wired into `SEND_EMAIL`; this commit
builds the renderer-side counterpart.

Worker side:
- Move the OTP sender from `auth@elydora.com` to `browser@elydora.com`
  (wrangler.toml `allowed_sender_addresses` + better_auth.ts
  `EMAIL_OTP_FROM_ADDRESS`). Worker must be redeployed to pick this up.

Client side (`ely_sync_client::email_otp`):
- `send_email_otp(config, email)` POSTs `/api/auth/email-otp/send-verification-otp`
  with `{ email, type: "sign-in" }`.
- `verify_email_otp(config, email, otp)` POSTs `/api/auth/sign-in/email-otp`,
  reads the Better Auth session token from the JSON body's `token` field
  with the `Set-Cookie: better-auth.session_token=…` header as the
  documented fallback channel, and returns it as a `BearerToken`.

Shell side (`shell/auth.rs` + `shell/internal_pages/sync.rs`):
- New `AuthFlowPhase` (Idle / SendingCode / AwaitingOtp / Verifying /
  Error) tracks the in-flight form. Two off-thread workers run the
  HTTP exchanges so the GPUI render loop never blocks.
- Successful verify saves the bearer via `SyncEngine::install_bearer`
  and triggers an immediate snapshot upload, so the user is signed in
  + initial-synced in one click.
- Sync settings page replaces the bare "Sync now" button row with an
  account card: when SignedOut → email field + Send code → OTP field
  + Verify / Resend; when signed in → an account chip + Sign out.
- `trigger_cloud_sync_upload` no longer takes a `Context` param so
  the post-auth path can fire it from the inbox-drain pass without
  needing a window context.
2026-05-15 21:32:50 -04:00
ZacharyZhang-NY 5d678c274a Use Cloudflare Email Send for OTP 2026-05-09 13:05:42 -04:00
ZacharyZhang-NY e7a2afeec0 Add Cloudflare public cache publisher 2026-05-09 12:10:20 -04:00
ZacharyZhang-NY a5d215564a Bind Cloudflare worker to browser resources 2026-05-09 12:08:09 -04:00
ZacharyZhang-NY 91821a0fc9 Add account deletion cleanup route 2026-05-09 06:50:22 -04:00
ZacharyZhang-NY c86091a81f Add telemetry diagnostics route 2026-05-09 05:31:04 -04:00
ZacharyZhang-NY 2dda91c50b Bind Better Auth sessions to devices 2026-05-09 03:46:15 -04:00
ZacharyZhang-NY 0c64a7721e Read Better Auth sessions from D1 2026-05-09 03:44:00 -04:00
ZacharyZhang-NY 5c253062ca Add Better Auth D1 schema 2026-05-09 03:37:32 -04:00
ZacharyZhang-NY 0178940e0f Add Better Auth worker route 2026-05-09 03:35:00 -04:00
ZacharyZhang-NY ed44db3034 Expose sync reset API 2026-05-08 19:10:04 -04:00
ZacharyZhang-NY e9f8b1eb43 Expose sync status API 2026-05-08 19:02:21 -04:00
ZacharyZhang-NY 5752eefea9 Reject same-clock sync push races 2026-05-08 18:56:57 -04:00
ZacharyZhang-NY 0f0cd0355c Expose sync snapshot API 2026-05-08 18:55:03 -04:00
ZacharyZhang-NY 2b3eea861a Expose sync push API 2026-05-08 18:46:21 -04:00
ZacharyZhang-NY 3544f644b1 Protect sync pull with approved devices 2026-05-08 18:20:01 -04:00
ZacharyZhang-NY b4b862517a Revoke devices through Cloudflare API 2026-05-08 18:12:52 -04:00
ZacharyZhang-NY da7694d5d2 Approve devices through Cloudflare API 2026-05-08 18:04:28 -04:00
ZacharyZhang-NY c8ed3128ed Register devices through Cloudflare API 2026-05-08 17:54:40 -04:00
ZacharyZhang-NY e645b2348a Expose authenticated devices list 2026-05-08 17:33:23 -04:00
ZacharyZhang-NY 73cd631d3e Add authenticated API controls 2026-05-08 17:22:51 -04:00
ZacharyZhang-NY 8284992e11 Add R2 storage contracts 2026-05-08 17:14:10 -04:00
ZacharyZhang-NY 0ff5585b96 Add D1 migration baseline 2026-05-08 17:05:29 -04:00
ZacharyZhang-NY edced5f5c0 Add Cloudflare API controls 2026-05-08 16:55:22 -04:00
ZacharyZhang-NY e6eda3bf1f Expose plugin registry API 2026-05-08 16:37:20 -04:00
ZacharyZhang-NY 7c392295bf Expose release signature API 2026-05-08 16:23:20 -04:00
ZacharyZhang-NY c8a7a32673 Expose release manifest API 2026-05-08 16:18:02 -04:00
ZacharyZhang-NY e425ea903c Expose plugin signing keys API 2026-05-08 16:12:42 -04:00
ZacharyZhang-NY 1013a22915 Add Cloudflare signing key contract 2026-05-07 23:58:36 -04:00