Refactor: extract shared PKCE helpers into utils/pkce.ts#25878
Refactor: extract shared PKCE helpers into utils/pkce.ts#25878ryan-crabbe-berri merged 1 commit intolitellm_internal_stagingfrom
Conversation
Deduplicates base64UrlEncode, generateCodeVerifier, and generateCodeChallenge which were copy-pasted across useMcpOAuthFlow and useUserMcpOAuthFlow hooks.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR extracts the duplicated PKCE helper functions ( Confidence Score: 5/5Safe to merge — pure deduplication with no behavioral changes and correct PKCE implementation. All three implementations (original No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/utils/pkce.ts | New shared module exporting generateCodeVerifier and generateCodeChallenge; implementation is correct and matches the RFC 7636 PKCE spec (32-byte random verifier, SHA-256 challenge). |
| ui/litellm-dashboard/src/hooks/useMcpOAuthFlow.tsx | Removed local PKCE helpers and replaced with imports from utils/pkce; call sites are unchanged (same function names were already used). |
| ui/litellm-dashboard/src/hooks/useUserMcpOAuthFlow.tsx | Removed local aliases (b64url, genVerifier, genChallenge) and replaced call sites with the canonical names from utils/pkce; behavior is identical. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["useMcpOAuthFlow.tsx"] -->|"imports generateCodeVerifier\ngenerateCodeChallenge"| C["utils/pkce.ts"]
B["useUserMcpOAuthFlow.tsx"] -->|"imports generateCodeVerifier\ngenerateCodeChallenge"| C
C --> D["generateCodeVerifier()\n— 32-byte random, base64url"]
C --> E["generateCodeChallenge(verifier)\n— SHA-256, base64url"]
C --> F["base64UrlEncode(buffer)\n— internal helper"]
Reviews (1): Last reviewed commit: "Extract shared PKCE helpers into src/uti..." | Re-trigger Greptile
c23ce91
into
litellm_internal_staging
Summary
base64UrlEncode,generateCodeVerifier, andgenerateCodeChallengeinto a sharedsrc/utils/pkce.tsmoduleuseMcpOAuthFlowanduseUserMcpOAuthFlowhooks to import from the shared module instead of defining their own copiesTest plan
npm run buildpasses with no type errors