auth.resend() consistent confirmation flow#2144
auth.resend() consistent confirmation flow#2144weilirs wants to merge 1 commit intosupabase:masterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Cache: Disabled due to Reviews > Disable Cache setting Disabled knowledge base sources:
📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR adds PKCE flow support to the Assessment against linked issues
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@supabase/auth-js
@supabase/functions-js
@supabase/postgrest-js
@supabase/realtime-js
@supabase/storage-js
@supabase/supabase-js
commit: |
🔍 Description
What changed?
When
flowTypeis'pkce',resend()now generates a freshcode_verifier/code_challengepair (via the existinggetCodeChallengeAndMethodhelper), stores the verifier, and includescode_challenge+code_challenge_methodin the request body to/resend. This follows the exact same pattern already used bysignUp()andsignInWithOtp(). See this PRpackages/core/auth-js/src/GoTrueClient.ts— Added PKCE challenge generation in the email branch ofresend(), includedcode_challengeandcode_challenge_methodin the request body, and addedcode-verifiercleanup in the error path.packages/core/auth-js/test/GoTrueClient.test.ts— Added test forresend()with PKCEflowType.No changes to the phone/SMS resend path, user-facing types, or implicit flow behavior.
Why was this change needed?
The GoTrue server has been updated to accept
code_challengeandcode_challenge_methodon the/resendendpoint. Previously,resend()always produced implicit-flow confirmation links (#access_token=...), even when the originalsignUp()used PKCE. This forced developers using server-side frameworks (e.g., Next.js App Router) to implement workarounds for handling hash fragments that aren't accessible in server route handlers.With this change, resend confirmation emails use
?code=...(PKCE) when the SDK is configured for PKCE flow, consistent with the initial signup email.Closes supabase/supabase#42527
📸 Screenshots/Examples
Before (implicit flow on resend — hash fragment not accessible server-side):
After (PKCE flow on resend — query param works with server routes):
🔄 Breaking changes
📋 Checklist
feat(auth-js): add PKCE support to resend()npx nx formatto ensure consistent code formatting📝 Additional notes
resend()call generates a freshcode_verifier/code_challengepair — it does not reuse the pair from the originalsignUp(), since the user may be in a different browser session.ResendParamstype is unchanged; PKCE params are added internally by the SDK based on the configuredflowType, matching howsignUp()andsignInWithOtp()already work.sms,phone_change) are unaffected.