Repository navigation
fix(clerk-js,react): report a failed Protect challenge from HandleSSOCallback #10103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wobsoriano
merged 3 commits into
main
from
rob/prot-968-handle-sso-callback-protect-errors
Oct 7, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
a91f81b
test(clerk-js,react): cover a failed Protect challenge on the SSO cal…
wobsoriano da46628
fix(clerk-js,react): report a failed Protect challenge from HandleSSO…
wobsoriano 8cfcbf2
test(e2e): cover a failed Protect challenge on the custom flow SSO ca…
wobsoriano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@clerk/clerk-js': patch | ||
| '@clerk/react': patch | ||
| --- | ||
|
|
||
| Fix `<HandleSSOCallback />` dropping the error when a Clerk Protect challenge fails on the SSO callback. The error is now available on `errors` from `useSignIn()` or `useSignUp()`, and a failed sign-up challenge calls `navigateToSignUp` instead of `navigateToSignIn`. |
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
21 changes: 21 additions & 0 deletions
21
integration/templates/custom-flows-react-vite/src/routes/SSOCallback.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { HandleSSOCallback } from '@clerk/react'; | ||
| import { useNavigate } from 'react-router'; | ||
|
|
||
| export function SSOCallback() { | ||
| const navigate = useNavigate(); | ||
|
|
||
| return ( | ||
| <HandleSSOCallback | ||
| navigateToApp={({ decorateUrl }) => { | ||
| const destination = decorateUrl('/protected'); | ||
| if (destination.startsWith('http')) { | ||
| window.location.href = destination; | ||
| return; | ||
| } | ||
| navigate(destination); | ||
| }} | ||
| navigateToSignIn={() => navigate('/sign-in')} | ||
| navigateToSignUp={() => navigate('/sign-up')} | ||
| /> | ||
| ); | ||
| } | ||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,6 +198,7 @@ import { OAuthApplication } from './modules/oauthApplication'; | |
| import { Protect } from './protect'; | ||
| import { protectAssertionParams } from './protectAssertion'; | ||
| import { ProtectCheckGate } from './protectCheckGate'; | ||
| import type { SignIn, SignUp } from './resources/internal'; | ||
| import { BaseResource, Client, Environment, Organization, Waitlist } from './resources/internal'; | ||
| import { State } from './state'; | ||
|
|
||
|
|
@@ -1000,11 +1001,19 @@ export class Clerk implements ClerkInterface { | |
| return; | ||
| } | ||
| const gate = ProtectCheckGate.getInstance(); | ||
| const resolve = async (resource: SignInResource | SignUpResource) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win Declare the helper’s return type. Add 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| try { | ||
| await gate.resolve(this, resource); | ||
| } catch (error) { | ||
| eventBus.emit(events.ResourceError, { resource: resource as SignIn | SignUp, error }); | ||
| throw error; | ||
| } | ||
| }; | ||
| if (flow !== 'signUp') { | ||
| await gate.resolve(this, client.signIn); | ||
| await resolve(client.signIn); | ||
| } | ||
| if (flow !== 'signIn') { | ||
| await gate.resolve(this, client.signUp); | ||
| await resolve(client.signUp); | ||
| } | ||
| }; | ||
|
|
||
|
|
||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: clerk/javascript
Length of output: 3808
🏁 Script executed:
Repository: clerk/javascript
Length of output: 7505
🏁 Script executed:
Repository: clerk/javascript
Length of output: 3806
Add explicit return types to the new functions.
The new component, navigation callbacks, test helper, and local
keyfunction omit return types required by the TypeScript guideline. This is a maintainability refactor, not a major functional issue.Suggested fix
🤖 Prompt for AI Agents