You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(login): browser-based loopback OAuth flow with device-code fallback
Adds an RFC 8252 authorization-code-with-PKCE login path as the default,
matching gcloud, gh, claude. The existing RFC 8628 device-code flow is
kept as automatic fallback and explicit opt-out via --device-code.
- core/auth/pkce.ts — S256 code_verifier/challenge + state generator.
- core/auth/loopback-server.ts — picks a free port via get-port, binds
127.0.0.1, awaits /callback, validates state, returns success HTML,
then unref() + closeAllConnections() so Node exits promptly after
login completes.
- core/auth/api.ts — buildAuthorizeUrl() and exchangeCodeForToken().
Scope set to "apps:read apps:write offline" so the auth-code grant
receives a refresh_token (device-code path unchanged in behavior).
- cli/commands/auth/loopback-flow.ts — orchestrates browser open, callback
wait, token exchange. isHeadlessEnv() detects SSH/CI/no-DISPLAY.
- cli/commands/auth/login-flow.ts — tries loopback first, falls back to
device-code on headless env or any loopback failure.
- cli/commands/auth/login.ts — new --device-code flag.
Reuses existing writeAuth/refreshAndSaveTokens/AuthDataSchema — credential
file layout unchanged, refresh flow unchanged. No new runtime dependencies
(open, get-port already in devDependencies and bundled).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments