Commit beee75c
authored
feat(cli): port login and logout commands to native TypeScript (#5446)
Promotes `supabase login` and `supabase logout` from Phase 0 Go-binary
proxy wrappers to native TypeScript Effect handlers in the legacy shell
(CLI-1302). Parity with the Go CLI is the explicit priority — matching
stdout/stderr strings, streams, exit codes, the OAuth crypto flow, the
credential-delete ordering, and the telemetry stitch.
## login
- **Token path** — resolves the token from `--token` →
`SUPABASE_ACCESS_TOKEN` → piped stdin (non-TTY), saves it, then stitches
telemetry identity and prints `You are now logged in. Happy coding!`.
- **Browser OAuth flow** — ECDH P-256 keypair + AES-256-GCM decrypt
(`LegacyLoginCrypto`), session polling at
`/platform/cli/login/{sessionId}` + best-effort `/v1/profile` gotrue-id
fetch (`LegacyLoginApi`). Verify-with-retries mirrors Go's backoff: 3
attempts total, `Retry (n/2)` printed on the first two failures only.
- **Telemetry** — fetches the gotrue id, stitches or clears the
`distinct_id`, and always captures `cli_login_completed`. The stitch
*aliases* only (no `identify`) to match Go's `StitchLogin`.
- **Profile persistence** — on success, an explicitly-set profile is
written to `~/.supabase/profile` (Go's `PostRunE` / `SaveProfileName`);
`LegacyCliConfig` now reads that file back as the lowest-precedence
profile source.
- Claude Code plugin hint on a TTY stdout.
## logout
- Confirm prompt honoring `--yes`, the not-logged-in stderr path (exits
0, skips the credential sweep), real-removal-failure propagation, and
the project-credential sweep.
## Shared infra
- `LegacyCredentials.deleteAccessToken` reshaped to the Go-faithful
tri-state (`void` | `LegacyNotLoggedInError` | `LegacyDeleteTokenError`)
reproducing Go's file-first / legacy-keyring / profile-keyring ordering
— including the deliberate "file removed yet *not logged in*" quirk on
no-keyring hosts. Adds `deleteAllProjectCredentials`.
- `LegacyTelemetryState` gains `stitchLogin` / `clearDistinctId` (alias
+ persist, sharing one JSON read/merge internal).
## Reviewer-relevant notes
- The profile-file **read** fallback lives in the shared
`LegacyCliConfig` layer, so it now applies to every legacy command
(correct Go parity, wider than just login).
- `~/.supabase/profile` write failure is fatal (exit 1), matching Go's
"block subsequent CI commands on save failure".
SIDE_EFFECTS.md added for both commands; the porting-status tracker is
flipped to `ported`.1 parent f5b186a commit beee75c
34 files changed
Lines changed: 2256 additions & 133 deletions
File tree
- apps/cli
- docs
- src/legacy
- auth
- commands
- login
- logout
- config
- telemetry
- tests/helpers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
265 | | - | |
| 264 | + | |
| 265 | + | |
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
8 | 13 | | |
9 | 14 | | |
10 | 15 | | |
| |||
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
17 | 25 | | |
18 | 26 | | |
19 | 27 | | |
| |||
219 | 227 | | |
220 | 228 | | |
221 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
222 | 316 | | |
223 | 317 | | |
224 | 318 | | |
| |||
307 | 401 | | |
308 | 402 | | |
309 | 403 | | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
321 | 410 | | |
322 | 411 | | |
323 | | - | |
324 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
325 | 434 | | |
326 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
327 | 448 | | |
328 | 449 | | |
329 | 450 | | |
| |||
0 commit comments