Skip to content

refactor(forges): route OAuth-app validators through the adapter#2887

Open
afonsojramos wants to merge 3 commits into
mainfrom
refactor-forge-adapter-oauth-app-validators
Open

refactor(forges): route OAuth-app validators through the adapter#2887
afonsojramos wants to merge 3 commits into
mainfrom
refactor-forge-adapter-oauth-app-validators

Conversation

@afonsojramos
Copy link
Copy Markdown
Member

Summary

Follow-up to #2874. routes/LoginWithOAuthApp.tsx imported getNewOAuthAppURL, isValidClientId, isValidToken directly from forges/github/auth. The route is already forge-aware (it pulls forge from route state), but the validators and the "Create new OAuth App" link bypassed the adapter.

  • Add validateOAuthClientId?(id): boolean and getNewOAuthAppUrl?(hostname): Link to ForgeAdapter. Both optional — forges without OAuth-app support omit them.
  • Wire on the GitHub adapter (isValidClientId, getNewOAuthAppURL).
  • validateForm(values, forge) now dispatches through getAdapter(forge). Client-secret format check reuses adapter.validateToken since GitHub's client-secret format happens to match its PAT format.
  • "Create new OAuth App" button hides when the active adapter doesn't expose getNewOAuthAppUrl.

Test plan

  • pnpm exec tsc --noEmit — clean
  • pnpm lint — clean
  • pnpm exec vitest --run src/renderer/routes/LoginWithOAuthApp.test.tsx src/renderer/utils/forges/github/adapter.test.ts — passes

@github-actions github-actions Bot added the refactor Refactoring of existing feature label May 12, 2026
@setchy
Copy link
Copy Markdown
Member

setchy commented May 12, 2026

Instead of ForgeAdapter being flat with many optional, but related functions needed an implementation... Could we encapsulate this differently?

ie: if a forge adapter implementats the OAuth flow then it needs to implement the 3-4 funds. Similarly for PATs and other "groupable" interface fns

@afonsojramos
Copy link
Copy Markdown
Member Author

oOoOoOo I like that 👀

@afonsojramos afonsojramos force-pushed the refactor-forge-adapter-oauth-app-validators branch from fc309d6 to 52b7b74 Compare May 12, 2026 02:20
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactoring of existing feature

Development

Successfully merging this pull request may close these issues.

2 participants