Skip to content

feat(mosaic): run the Protect check in sign-up - #10928

Draft
austincalvelage wants to merge 21 commits into
austin/mosaic-sign-up-routingfrom
austin/mosaic-sign-up-protect
Draft

austincalvelage wants to merge 21 commits into
austin/mosaic-sign-up-routingfrom
austin/mosaic-sign-up-protect

Conversation

@austincalvelage

@austincalvelage austincalvelage commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Description

Runs the Clerk Protect check in Mosaic sign-up. Stacked on #10881.

When an instance has "Challenge suspicious sign-ups" on and Clerk flags a sign-up, signUp.create() comes back with a challenge. Sign-up moves to the protect-check route, runs the challenge, submits the proof and goes on to the next step, usually the code screen. A challenge raised from the continue screen goes to continue/protect-check instead.

SignUpFuture has no reload, so the runner reloads the classic sign-up the future wraps. No clerk-js change is needed.

Review fixes

  • The screen runs the challenge through shared runProtectCheck with the classic sign-up's reload(), the runner ui uses through useProtectCheckRunner. fix(mosaic): reload the classic sign-up in the Protect runner switches that reload to the classic sign-up, since SignUpFuture has no reload. fix(mosaic): run the sign-up Protect check through the shared runner, covered by "continues with the sign-up the 404 returns when the Protect check was resolved elsewhere" and "shows the timeout when a reload returns the Protect check expired, and reloads again on each Try again".
  • A challenge raised on the continue screen keeps continue as the place to edit. fix(mosaic): run the sign-up Protect check through the shared runner, covered by "keeps the continue screen as the place to edit after a Protect check raised on it".
  • A blocked proof shows the blocked notice. fix(mosaic): run the sign-up Protect check through the shared runner, covered by "replaces the Protect check with the blocked notice when the proof is blocked".
  • Try again clears the failed widget and resets its visibility, so the spinner shows. fix(mosaic): run the sign-up Protect check through the shared runner, covered by "clears the failed widget before Try again runs the Protect check again" and "shows the loading spinner on Try again when the failed widget left itself shown".
  • The fake FAPI follows clerk_go: a proof for a check that is no longer pending is a 404 carrying the client, a GET reload never reissues, a rejected proof returns a replacement challenge, and an update keeps a pending check. test(mosaic): match the fake sign-up Protect check to clerk_go, covered by "runs the replacement Protect check Clerk issues for a rejected proof" and the two tests above.
  • The Swingset /sign-up redirect and the legacy signUpUrl change are out of this PR, since they aren't part of Protect.
features/sign-up/
└── sign-up-protect/
    ├── sign-up-protect.controller.ts   runs the challenge on mount, Try again
    └── sign-up-protect.tsx             the screen, on the shared AuthProtectCheck block

1. The model gets a protect group. It runs the challenge with runProtectCheck from @clerk/shared, which submits the proof and reloads an expired check under the shared cap. Then it returns the next step. When the check was already resolved elsewhere, FAPI answers the proof with a 404 that carries the client, and sign-up moves on to the step that sign-up reports.

protect: {
  challengeId: signUp.protectCheck?.token,
  resolve: async ({ container, setWidgetVisible }) => {
    await runProtectCheck(
      {
        getProtectCheck: () => signUp.protectCheck,
        getResource: () => signUp,
        reload: () => clerk.client?.signUp.reload() ?? Promise.resolve(),
        submitProtectCheck: async params => { await run(() => signUp.submitProtectCheck(params)); return signUp; },
      },
      challenge,
      { container, expiredReloads, setWidgetVisible, loadTimeoutMs }, // expiredReloads: a ref the flow controller holds
    );
    return next(signUp);
  },
},

2. The screen runs the challenge when it mounts. A submit, a reload and a second challenge all arrive the same way. It takes the challenge token as its key, so when Clerk issues another challenge the screen remounts and runs it. The flow controller keeps the expired-reload count, so the cap holds across those remounts.

protectCheck={<SignUpProtect key={protectCheck.protect.challengeId} logo={logo} {...protectCheck} />}

3. The card shows a spinner until the challenge asks to show something. The script calls setWidgetVisible(true) before it draws in the card, the same handshake legacy uses. A failed challenge shows the error with Try again. Try again empties the container and hides the widget before it runs again, so the spinner comes back. A check that completes the sign-up keeps the screen busy while the session activates. If activation fails, the screen shows the error and Try again runs the activation again.

4. A challenge from continue stays under continue. continueProtectCheck is continue/protect-check, so the next code screen and its Edit link go back to continue, not start. A blocked proof shows the blocked notice on either Protect route. The proof returns the blocked result the same way create does in #10881.

case 'protect':
  return underContinue ? 'continueProtectCheck' : 'protectCheck';

Try again resets the expired-reload count, covered by "shows the timeout when a reload returns the Protect check expired, and reloads again on each Try again". The screen takes the protect group whole.

Changes outside sign-up

  • SignUpViewProps takes logo?: { src, alt } in place of applicationLogoUrl, built once and shared with the Protect screen. protectCheck is now a slot (ReactNode) the wrapper fills with SignUpProtect.
  • The test fake for sign-up can issue Protect challenges, serves a challenge script with pass and fail buttons, and checks the proof token. It answers the way clerk_go does: a proof for a check that is no longer pending is a 404 resource_not_found with the client, a GET reload only returns the sign-up, a rejected proof returns 200 with a replacement challenge, and an update keeps a pending, unexpired check.

Known gaps

  • clerk-js opens its own Protect modal inside signUp.create() whenever the legacy UI is loaded, so this screen only runs when it isn't. The flow doc says a Mosaic host must not load the legacy UI (prefetchUI={false} on the provider).
  • Nothing stops a Protect run when its screen unmounts.
  • An expired challenge ends in the timeout error. FAPI's GET reload never issues a fresh challenge, so the reload returns the same expired check. Try again reloads and ends the same way.
  • An invisible challenge shows the "Verifying your request" screen with a spinner, like legacy. Holding the form instead is a follow-up that needs a clerk-js change.

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 20, 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 25, 2026 7:39pm UTC
mosaic-docs Ready Ready Preview Nov 25, 2026 7:39pm UTC
swingset Ready Ready Preview Nov 25, 2026 7:39pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7de6146

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

@coderabbitai

coderabbitai Bot commented Nov 20, 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

@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-biometrics

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

@clerk/expo-google-signin

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

@clerk/expo-native-components

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/mosaic

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 7de6146

When Clerk returns a Protect challenge, sign-up shows its protect screen, runs the challenge script in it, submits the proof and moves to the next step. A failed challenge shows the error with Try again, and a second challenge remounts the screen to run it. The fake FAPI can issue challenges and serves a challenge script for the feature tests.
… tests

Two Protect tests ended on the verify screen without waiting for the code send, so a late send could write their sign-up into Clerk's shared signals during the next test, which then failed to find the challenge on CI.
- Resolve the challenge with `runProtectCheck`, so an already-resolved proof
  reloads and continues, and an expired challenge reloads under the shared cap.
  The controller keeps the reload count, since the screen remounts for each
  reissued challenge.
- Route a challenge raised on the continue screen to `continue/protect-check`,
  so the next verify step and Edit stay under continue.
- Show the blocked notice when the proof is blocked.
- Clear the container and the widget visibility before each run, so Try again
  starts from an empty container with the spinner.
The fake FAPI let the Protect tests pass on recoveries the real backend
never offers. It now follows clerk_go 8bb8f66dde:

- A proof for a check that is no longer pending is a 404
  resource_not_found carrying the client (api/shared/sign_up/service.go:2746-2748,
  api/fapi/v1/wrapper/wrapper.go:49). protect_check_already_resolved is sign-in only.
- A GET reload only serializes the sign-up (api/fapi/v1/sign_up/http.go:173-195),
  so the reissue-on-reload seed is gone.
- A rejected proof returns 200 with a replacement challenge
  (api/shared/sign_up/service.go:2774-2809), not protect_check_invalid.
- An update keeps a pending, unexpired check unchanged
  (api/shared/sign_up/service.go:2508-2514).

The resolved-elsewhere test now expects the sign-up from the 404 to carry
the user on to email verification. The expired test also checks that Try
again is offered instead of a stuck spinner. A new test runs the
replacement challenge after a rejected proof.
SignUpFuture has no reload, so the shared runner reloads the classic sign-up the future wraps. FAPI's GET reload never reissues an expired check, so the reload only confirms the expiry.
The route table test already pins where protect and verify sit under
continue. The feature test keeps the screens and where Edit lands.
…ontroller

The model holds no React state, so the count that outlives each challenge's
remount moves to the flow controller, as the flow guide already says. The
Protect screen passes it to resolve and resets it on Try again.
A Protect check can be the last requirement, so resolving it returns
`complete` and the flow activates the new session from the Protect screen.
The tests hold and fail that activation. Two fail: the screen shows no
spinner while the activation runs, and a failed activation shows no error
and no way to run it again.
When resolving the Protect check completes the sign-up, the flow activates
the new session while the Protect screen stays up. The flow controller gave
that screen no finish state, so it showed its title with no spinner, and a
failed activation showed no error and no way forward.

The Protect screen now receives the flow's pending state and finish error,
as the verify screens do. After a failed activation, Try again runs the
activation again. No challenge is left at that point, so the model's
`resolve` returns `complete` without running one.
The tests render SignUp and follow the check from the start form through the code screen, the continue screen and the session activation, so the file sits in sign-up/__tests__ with the other sign-up feature tests. They are grouped by what the user is doing, and the two tests that asserted sign-up left once now wait for the card to empty instead of two event-loop turns.
…w hold

The routing branch replaced isFinishing with the hold outcome.

This branch was successfully deployed

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