Repository navigation
feat(mosaic): sign up with social providers - #10945
Draft
austincalvelage wants to merge 38 commits into
Draft
austincalvelage wants to merge 38 commits into
austincalvelage wants to merge 38 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
🦋 Changeset detectedLatest commit: 372e71e The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-biometrics
@clerk/expo-google-signin
@clerk/expo-native-components
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/mosaic
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
austincalvelage
force-pushed
the
austin/mosaic-sign-up-oauth
branch
from
November 21, 2026 01:15
32b19f9 to
5a079d9
Compare
austincalvelage
force-pushed
the
austin/mosaic-sign-up-oauth
branch
from
November 21, 2026 04:02
5a079d9 to
dae67b3
Compare
austincalvelage
force-pushed
the
austin/mosaic-sign-up-oauth
branch
from
November 23, 2026 17:09
dae67b3 to
44b178d
Compare
austincalvelage
force-pushed
the
austin/mosaic-sign-up-oauth
branch
from
November 23, 2026 17:14
44b178d to
86336bf
Compare
austincalvelage
force-pushed
the
austin/mosaic-sign-up-oauth
branch
from
November 23, 2026 17:19
86336bf to
644a844
Compare
…ith social sign-up The restack onto the invitation fixes put `useSignUpModel` at a cognitive complexity of 18. Choosing which legal consent start and continue show moves above the returned model, where each choice counts once instead of at the model's nesting depth.
…ng the invitation again
…ith an error The error path reset the sign-up but left the ticket in the URL, so the invitation effect redeemed it again and cleared the provider's error. It now removes the ticket first, as the flow's own reset does. A successful return keeps the ticket, so the invitee stays on the invitation's sign-up.
…-up opens The return only ran on start, so a return that opened on continue showed the loading screen forever. It now runs once on any route, and the guard then moves the screen to the step's route.
…ts pending action The controller kept `isReturning` in its own state beside `usePendingAction`, a second busy flag. It now reads the return marker until the return action has run, then the action's pending key, so the loading screen still shows from the first paint.
`sso` built the after-sign-up URL without the query, so a `redirect_url` on the page was dropped once the provider finished. It now passes the same after-sign-up URL the rest of sign-up uses.
…or to sign-in's factor-two route
…ill needs A transfer that did not complete went to the sign-in root. It now goes to `factor-one`, `factor-two`, `reset-password` or `protect-check` by the sign-in's status, as `clerk.ts` `_handleRedirectCallback` does, on the sign-in URL that keeps `redirect_url`.
…hook The return completion (Protect, transfer, existing session, provider error, next step) becomes a module function, so the return and the Protect check after it share one path.
…the return, and the sso body The fake FAPI can now return an OAuth sign-up for an account already signed in on the client, with FAPI's `identifier_already_signed_in` error and its session id.
…ofile Sign-up imported `REDIRECT_HOLD_MS` from `user-profile.utils`. It moves to `src/utils/redirect.ts`, beside the other cross-feature values, and AGENTS.md lists it.
The flow doc said redirect URLs are never hand-built and that sign-up keeps the screen on every transfer, while the OAuth return builds a marked callback URL and transfers an existing account itself. It now says the marker is temporary until the router's `useReturnUrl()` lands, and describes the return as built: any route, the ticket kept on success and removed on error, the sign-in route a transfer needs, `redirect_url`, and the OAuth transport.
clerk_go 8bb8f66dde runs the sign-up Protect check on the OAuth callback for a new account (api/fapi/v1/oauth/oauth.go:2767, FlowOpOAuthCallback in api/shared/sign_up/flow_stage.go:93-96 surfaces it on the next read). An account that already exists returns before that check (oauth.go:2747-2752), so a check raised on the return never leads to a transfer. The fake FAPI can now raise the check on the return (protectCheckOn: 'oauth_callback'), keeping a pending, unexpired check the way runProtectCheck does. The new test lands on the Protect screen after Google and completes the sign-up once the user solves it.
…viders continue shows
Inlines the one-caller completeOAuth and its actions object, drops a guard the early return already covers, and stops asserting the internal return marker.
…n-in The sign-up model built the after sign-in URL without the query, so a Google account that already had a user, or was already signed in on this client, landed on the sign-in fallback instead of the redirect_url. Both paths now pass the query to buildAfterSignInUrl, as sign-up does for the after sign-up URL and as legacy does (ui/src/contexts/components/SignUp.ts).
…s blocked Fails today. FAPI stores `action_blocked` with its details on the external account verification when Protect blocks the callback, and sign-up shows it as an inline error on the start form. The fake FAPI's OAuth error takes the `meta` FAPI stores with it.
… blocked `completeReturn` resolves with the blocked result when the external account's error is `action_blocked` with its details, as legacy's `SignUpStart` shows `ActionBlockedCard` for it. The controller keeps the result for the mount, like a blocked create. An `action_blocked` error without details still shows inline on the start form.
…is blocked Fails today. The blocked notice now comes from the result a request resolves with, and `sso` still rejects with the error, so the start form shows it inline.
…s blocked `sso` resolves with the blocked result from the start form when FAPI answers `action_blocked`, and the details controller hands it to the flow, which keeps it for the mount. From the continue form it still rejects, so the error shows inline, as a blocked update does and as legacy's `SignUpContinue` shows it.
The social sign-up tests move out of the shared sign-up feature test, with the three provider tests that sat among the continue screen tests, and are grouped by what the user is doing in place of one "SignUp social sign-up" block. Starting with Google, signing in instead, and switching to a signed-in session each had one test for the fallback URL and one for the redirect_url in the query. Each pair is now one table over the two landings.
This branch was successfully deployed
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.
Description
Adds social (OAuth) sign-up to Mosaic. Stacked on #10944.
Review fixes
fix(mosaic): forget the invitation when a social sign-up comes back with an error, covered by "keeps the denial on screen when an invitee comes back from Google, and does not redeem the ticket again".start.fix(mosaic): complete a social sign-up return on whichever route sign-up opens, covered by "completes the return when sign-up opens on the continue route".returnaction has run, then the action's pending state, so busy has one source.refactor(mosaic): derive the sign-up OAuth return's busy state from its pending actionandrefactor(mosaic): read the sign-up OAuth return marker through the router, which reads the marker through the router. Covered by the return tests.sso()sends the after sign-up URL that honorsredirect_urlas the URL to land on.fix(mosaic): honor redirect_url as the URL a social sign-up lands on, covered by "starts Google sign-up with a callback URL that brings the user back to sign-up, then on to $landing".#/factor-one,#/factor-two,#/reset-passwordor#/protect-check), likeclerk.ts_handleRedirectCallback, and keepsredirect_url.fix(mosaic): send a social sign-up transfer to the sign-in step it still needs, covered by "hands a transfer that still needs a second factor to the sign-in factor-two route, keeping redirect_url".fix(mosaic): transfer a social sign-up after its Protect check is solved, covered by "signs in instead after the Protect check when the Google account already belongs to a user".completeReturn.refactor(mosaic): settle the sign-up OAuth return inside completeReturn, a refactor.test(mosaic): cover social sign-up's existing session, Protect after the return, and the sso bodyadds "switches to the session already signed in to the Google account and lands on $landing", "runs the Protect check the sign-up still has after the return, then continues" and "sends the accepted legal terms and the unsafe metadata with the Google sign-up".REDIRECT_HOLD_MSmoved fromuser-profiletosrc/utils/redirect.ts, shared by both features.refactor(mosaic): share the redirect hold between sign-up and user profile.useReturnUrl()(feat(mosaic): Add useReturnUrl and sync query mode links into other modes #10860) when that hook lands.docs(mosaic): describe the sign-up OAuth return as built.test(mosaic): run a Protect check raised on the return from Google, covered by "runs the Protect check raised on the return from Google, then completes the sign-up".continueProvidersalone.fix(mosaic): hide Continue's providers only when legal consent is all a sign-up needs, covered by "offers the provider the sign-up still needs alongside legal consent" and "offers no provider when legal consent is all the sign-up needs".1. The model lists the providers and starts the redirect. The providers come from
userSettings.authenticatableSocialStrategies, custom ones included, sorted the way legacy sorts them. Start shows them next to the WhatsApp buttons. Continue shows them too, until the sign-up has a verified external account. When FAPI lists anoauth_*provider inmissing_fields, continue shows only the missing providers instead of Start over, since another provider can't satisfy the requirement. When more than one provider is required, one sign-in can't satisfy them all, so sign-up still shows Start over. On an instance with no form fields, start shows only the providers, and legal consent is asked on continue. The user links the rest from their profile.sso()sends the consent checkbox andunsafeMetadata.signUp.sso()updates any sign-up already on the client, so start resets a leftover sign-up first, unless it is the invitation's. A blocked request from start shows the blocked notice.2. The return is marked in the URL. Mosaic routing is in memory, so the provider's redirect would land back on
startwith no memory of the flow. Until URL routing lands in #10860, the callback URL carries a marker, the waywithUserProfileModalReturnmarks a profile return. The marker moves to that PR'suseReturnUrl()when it lands. When sign-up opens with the marker, on any route, the controller shows the loading screen from the first paint and runscompleteReturnonce as itsreturnaction. The ticket waits until the return is done.3.
completeReturnfollowsclerk.handleRedirectCallback's sign-up branches on the Future API.next(step): continue or verifysignIn.create({ transfer: true }), then finishes in place, or goes to the sign-in route for the factor it still needsA transfer and a switch to an existing session both keep
redirect_url.The model picks the error copy on purpose. The error is read off
signUp.verifications.externalAccountafter the redirect, not thrown by a Clerk call, so it is a failure the model detects (models.md). It shows FAPI's message for the 17 codes legacy shows (SignUpStart.tsxhandleOauthError) and the generic error for every other code, so server detail stays hidden as it does in legacy. Moving that choice to the error owner would need a new shared option with one caller.Popup mode (
oauthFlow) and enterprise SSO come in stacked follow-ups. The fake FAPI starts OAuth sign-ups, plays the provider's response, raises a Protect check on the return when seeded to, and transfers to sign-in, so the feature tests cover each return.Changes outside sign-up
REDIRECT_HOLD_MSlives insrc/utils/redirect.ts, listed in AGENTS.md's reuse list. The user profile's connected and enterprise accounts sections import it from there.Known gaps
__internal_oauthTransport) is not supported.SignUpFuture.sso()still navigates the window, so clerk-js has to honor the transport first.start.setup-mfatask shows an empty form. This was seen against the fake FAPI only.needs_first_factororneeds_new_password, and a sign-in Protect check after a transfer, are not covered by tests. The fake FAPI has no sign-in Protect or first-factor transfer.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
🤖 Generated with Claude Code