Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

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

Draft
austincalvelage wants to merge 39 commits into
austin/mosaic-sign-up-invitationsfrom
austin/mosaic-sign-up-oauth
Draft

austincalvelage wants to merge 39 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.
  • In multi-session mode, a Google sign-up that ends with a pending setup-mfa task shows an empty form. This was seen against the fake FAPI only.
  • 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 Nov 30, 2026 9:10pm UTC
mosaic-docs Ready Ready Preview Nov 30, 2026 9:10pm UTC
swingset Ready Ready Preview Nov 30, 2026 9:10pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@changeset-bot

changeset-bot Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bc80eb0

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: bc80eb0

…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.
…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.

This branch was successfully deployed

2 active deployments
Preview – swingset — bc80eb0a Deployed Nov 30, 2026 by vercel[bot]
Preview – clerk-js-sandbox — bc80eb0a Deployed Nov 30, 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.

1 participant