{{ message }}
refactor(oauth): add Zod validation for OAuth responses#22
Merged
Conversation
Replace unsafe type assertions with runtime Zod validation for OAuth device flow responses. This ensures malformed responses from the OAuth server are caught and reported with helpful error messages. Changes: - Add Zod schemas for DeviceCodeResponse, TokenResponse, TokenErrorResponse - Use safeParse for discriminating success/error responses in pollForToken - Wrap validation errors in ApiError for user-friendly messages - Replace plain Error throws with ConfigError, ApiError, DeviceFlowError - Add .passthrough() to schemas for API resilience - Improve JSDoc with @returns and @throws documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
BYK
added a commit
that referenced
this pull request
Jun 23, 2026
Fixes 5 open Dependabot alerts: | Alert | Package | Severity | Fix | |-------|---------|----------|-----| | #10 | vite@8.0.13 (fs.deny bypass) | High | → 8.0.16 | | #9 | vite@8.0.13 (NTLM hash leak) | Moderate | → 8.0.16 | | #22 | form-data@4.0.5 (CRLF injection) | Moderate | → 4.0.6 | | #14 | js-yaml@4.1.1 docs (DoS) | Moderate | → 4.2.0 | | #13 | @babel/core@7.29.0 docs (arbitrary file read) | Low | → 7.29.6 | **Accepted as tolerable risk:** - Alert #21: js-yaml@3.14.2 in main lockfile — `gray-matter` pins `^3.13.1` with no v3 patch backport; dev-only transitive dep used at build time All patches applied via `pnpm.overrides` in respective `package.json` files. `check:deps` ✓, `lint` ✓, `typecheck` has a pre-existing unrelated error in `src/commands/api.ts`.
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.

Summary
Adds runtime validation for OAuth device flow responses using Zod schemas. Previously, responses were cast with
astype assertions which could hide malformed data. Now validation errors are caught and reported with helpful messages.Changes
safeParsefor proper validationApiErrorwith clear error messagesErrorthrows with proper error classes (ConfigError,ApiError,DeviceFlowError).passthrough()to schemas so extra API fields don't cause failuresTest plan
bun run typecheck- passesbun test- existing tests pass (171 pass, failures are pre-existing config test issues)sentry auth loginstill works with valid OAuth server responses🤖 Generated with Claude Code