feat: make OAuth device auth the default authentication method#253
Open
SBALAVIGNESH123 wants to merge 1 commit intoval-town:mainfrom
Open
feat: make OAuth device auth the default authentication method#253SBALAVIGNESH123 wants to merge 1 commit intoval-town:mainfrom
SBALAVIGNESH123 wants to merge 1 commit intoval-town:mainfrom
Conversation
Closes val-town#230 - Remove Confirm.prompt gate in onboard flow; OAuth device auth now starts automatically when credentials are missing - Gracefully fall back to manual instructions if device auth fails (no browser, network issues, etc.) - Add 'login' and 'upgrade' to auth-exempt commands list (also addresses val-town#242: vt upgrade no longer requires authentication) - Fix token length validation in ensureGlobalVtConfig to accept 43-char OAuth access tokens alongside 32-33 char API keys - Update 401/permissions error messages to suggest 'vt login' as primary recovery action - Fix missing await on globalConfig.saveGlobalConfig() in onboard - Use API_KEY_KEY constant instead of hardcoded string - Update Zod schema validation error message to mention OAuth tokens - Add comprehensive test suite (8 tests) covering schema validation, auth-exempt commands, and error message improvements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #230
Summary
Makes OAuth device authorization the default authentication method, removing the interactive confirmation prompt that previously gated the login flow. Users no longer need to answer a yes/no question — the device auth flow starts automatically when credentials are missing.
Changes
Core: Auto-start OAuth (
src/cmd/flows/onboard.ts)Confirm.promptgate — device auth now starts automaticallytry/catcharound the flow so if the browser can't open or the network fails, the CLI gracefully falls back to clear manual instructions (vt loginorvt config set apiKey)awaitonglobalConfig.saveGlobalConfig()that could cause a race condition where config wasn't written before process exit'VAL_TOWN_API_KEY'string with theAPI_KEY_KEYconstantAuth-exempt commands (
vt.ts)loginandupgradeto the auth-exempt command listloginis the auth flow itself — requiring auth before it creates a circular dependencyupgradejust updates the binary and doesn't need API access (also addresses Don't require being logged in for vt upgrade #242)Token validation fix (
src/vt/VTConfig.ts)ensureGlobalVtConfig()now accepts 43-char OAuth access tokens from theVAL_TOWN_API_KEYenvironment variable (previously only accepted 32-33 char API keys, silently replacing OAuth tokens with a dummy key)Error message improvements (
src/cmd/utils.ts,src/vt/vt/schemas.ts)vt loginas the primary recovery action, withvt config set apiKeyas secondaryTests (
src/cmd/tests/oauth_default_test.ts)8 test cases covering:
vt upgradedoesn't require authentication ✅vt login✅Verification
deno checkpasses on all 80+ source files with zero errorsdeno fmt --checkpasses on all changed filesvt config set apiKeystill works)