Skip to content

feat(mosaic): sign up with social providers - #10945

Merged
austincalvelage merged 46 commits into
austin/mosaic-sign-up-invitationsfrom
austin/mosaic-sign-up-oauth
Dec 4, 2026
Merged

austincalvelage merged 46 commits into
austin/mosaic-sign-up-invitationsfrom
austin/mosaic-sign-up-oauth

Conversation

@austincalvelage

@austincalvelage austincalvelage commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Description

Adds social (OAuth) sign-up to Mosaic. Stacked on #10944.

Shared changes (for Mosaic reviewers)

  • REDIRECT_HOLD_MS lives in src/utils/redirect.ts, listed in AGENTS.md's reuse list. The user profile's connected and enterprise accounts sections import it from there.
  • The test fake for sign-up starts OAuth sign-ups, plays the provider's response, raises a Protect check on the return when seeded to, and transfers to sign-in.

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 an oauth_* provider in missing_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 and unsafeMetadata. 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.

await run(() =>
  target.sso({
    strategy,
    redirectCallbackUrl: ssoCallbackUrl(), // current URL + __clerk_mosaic_sign_up=sso-callback
    redirectUrl: afterSignUpUrl, // honors redirect_url
    unsafeMetadata,
    legalAccepted: legalAccepted || undefined,
  }),
);

2. The return is marked in the URL. Mosaic routing is in memory, so the provider's redirect would land back on start with no memory of the flow. Until URL routing lands in #10860, the callback URL carries a marker, the way withUserProfileModalReturn marks a profile return. The marker moves to that PR's useReturnUrl() when it lands. When sign-up opens with the marker, on any route, the controller shows the loading screen from the first paint and runs completeReturn once as its return action. The ticket waits until the return is done.

const isReturning = actions.pendingKey === 'return' || (flow.isReturning && actions.lastKey === undefined);

3. completeReturn follows clerk.handleRedirectCallback's sign-up branches on the Future API.

After the provider Sign-up
A Protect check the protect screen, before anything else. A transfer after it still signs in
Something is still missing next(step): continue or verify
The account already exists signIn.create({ transfer: true }), then finishes in place, or goes to the sign-in route for the factor it still needs
The user is already signed in with it activates that session; a pending task goes to its task URL, as for a transfer
The provider returned an error forgets the ticket, resets the sign-up and shows the error on start: FAPI's message for the codes legacy shows, the generic error otherwise
FAPI blocked the sign-up the blocked notice

A 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.externalAccount after 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.tsx handleOauthError) 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.

Known gaps

  • An OAuth transport (__internal_oauthTransport) is not supported. SignUpFuture.sso() still navigates the window, so clerk-js has to honor the transport first.
  • The marker is gone once the return starts, so a reload mid-return lands on start.
  • OAuth is a full-page redirect only. Popup OAuth is not built.
  • A transfer that lands on needs_first_factor or needs_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 test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Dec 4, 2026 8:17pm UTC
mosaic-docs Ready Ready Preview Dec 4, 2026 8:17pm UTC
swingset Ready Ready Preview Dec 4, 2026 8:17pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The sign-up flow now offers OAuth providers and processes callback returns, including transfers to existing accounts, signed-in sessions, Protect checks, and errors. The fake API and feature tests cover these paths. Test setup uses a shared auth-signal reset helper, and the redirect hold constant is defined in a shared utility.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • clerk/javascript#10944: This base PR adds invitation recognition and ticket handling used by the sign-up flow. Both PRs update the sign-up fake FAPI.
  • clerk/javascript#11022: This stacked PR builds on the OAuth return and redirect behavior added here, including the shared redirect hold constant.
Merge Risk: Low · previous review b24ef

Social sign-up works for the main flows. Two edge cases remain open: a user with two required providers may be sent back to Start over instead of linking the second one, and an earlier form error may hide a later provider failure. These are bounded and recoverable, so address them before or soon after merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(mosaic): sign up with social providers" matches the main change. The PR adds full-page OAuth (social) sign-up to Mosaic, including provider listing, the redirect flow, return handling,…
Description check Passed The description states that the PR adds social (OAuth) sign-up to Mosaic. It lists shared changes such as moving REDIRECT_HOLD_MS to src/utils/redirect.ts and the test fake for OAuth sign-up. It also …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(mosaic): sign up with social providers" matches the main change. The PR adds full-page OAuth (social) sign-up to Mosaic, including provider listing, the redirect flow, return handling, and the test fakes that support it. The title is short, uses conventional commit format, and names the primary feature.

Full details: Description check

Explanation

The description states that the PR adds social (OAuth) sign-up to Mosaic. It lists shared changes such as moving REDIRECT_HOLD_MS to src/utils/redirect.ts and the test fake for OAuth sign-up. It also explains the provider listing, the return marker, completeReturn behavior, error handling, and known gaps. These all match the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: This review skipped 6 repositories. Cross-repository analysis may be incomplete. Check linked repository access and settings.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 903b49e and b24ef62.

Files selected for processing: 2

  • packages/mosaic/src/features/sign-up/sign-up-details/sign-up-details.tsx
  • packages/mosaic/src/features/sign-up/sign-up.model.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 6 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

@changeset-bot

changeset-bot Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 45794f5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When 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

@pkg-pr-new

pkg-pr-new Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@10945

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@10945

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@10945

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@10945

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@10945

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@10945

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@10945

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@10945

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@10945

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@10945

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@10945

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@10945

@clerk/express

npm i https://pkg.pr.new/@clerk/express@10945

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@10945

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@10945

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@10945

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@10945

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@10945

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@10945

@clerk/react

npm i https://pkg.pr.new/@clerk/react@10945

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@10945

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@10945

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@10945

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@10945

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@10945

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@10945

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@10945

commit: 45794f5

…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.
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.
The flow guide said a TODO in useSignUpController covers a sign-up that is already complete on mount. There is no such TODO. The note now says what happens: nothing runs it.
… machine's arrival state

A return marker makes the arrival intent return, so the activity machine starts in completingReturn and its invoke completes the return once. A transfer after a solved Protect check sends COMPLETE_RETURN to the same state. This replaces the return's pending-action key, the lastKey check and the effect that ran it. A ticket that came back with the return is still redeemed once the return is done.
… machine

A transfer or an already signed-in session from the OAuth return now resolves
with signed_in, and next sends it to FINALIZE. The sign-in keeps a pending
organization task in the card, as legacy's callback opens the task under
sign-up.
…at the provider with a task

FAPI can finish a social sign-up at the provider and return with no sign-up on
the client and the new session pending a task sign-up does not show, such as
setup-mfa. Sign-up read that as nothing to do and showed an empty start form.
completeReturn now resolves it as signed in, so the loading screen stays up and
sign-up leaves for the task URL, and a visitor already leaving on arrival does
not complete the return a second time.
…ider starts

Legacy shows the spinner only on the provider the user pressed and disables
Continue. Mosaic also marked Continue busy because the form's pending state
included the provider action.
…er sign-up error

The details banner preferred the form's error over the provider's. The form
error clears only on the next submit or a reset, and starting a provider does
neither, so after a failed Continue a later provider failure still showed the
old message. Submitting already resets the provider action, so the provider's
error, when there is one, is always the newer one and now comes first.
FAPI's pick-one rule lists every provider that can sign the user in as
missing when every identifier is optional and none was given, and a linked
provider satisfies it (checkProgressiveStatus in clerk_go's sign_up service).
The fake listed only email, phone and username, so on an instance with no
other identifier it finished the sign-up when Google started and had nothing
to return to. It now follows the rule and lists optional providers in
optional_fields, as FAPI does.

This branch was successfully deployed

2 active deployments
Preview – swingset — 45794f53 Deployed Dec 4, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 45794f53 Deployed Dec 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants