Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6b05a93
test(mosaic): start and return from OAuth sign-ups in the fake FAPI
austincalvelage Nov 21, 2026
bc2d1ff
feat(mosaic): sign up with social providers
austincalvelage Nov 21, 2026
139ee07
docs(mosaic): describe the sign-up OAuth return
austincalvelage Nov 21, 2026
6123fd7
chore(repo): add an empty changeset for social sign-up
austincalvelage Nov 21, 2026
128dd1c
feat(mosaic): ask for a required social provider on the sign-up conti…
austincalvelage Nov 21, 2026
592144d
test(mosaic): mirror FAPI's OAuth sign-up behavior more closely in th…
austincalvelage Nov 21, 2026
9fb1253
fix(mosaic): close the gaps a FAPI and legacy check found in social s…
austincalvelage Nov 21, 2026
294832f
docs(mosaic): correct the sign-up OAuth return and on-mount notes
austincalvelage Nov 21, 2026
bb6bcf4
refactor(mosaic): keep the sign-up model under the complexity limit w…
austincalvelage Nov 23, 2026
78f1dc0
test(mosaic): show an invitee's denied Google sign-up without redeemi…
austincalvelage Nov 23, 2026
fce6cb6
fix(mosaic): forget the invitation when a social sign-up comes back w…
austincalvelage Nov 23, 2026
8edab79
test(mosaic): complete a social sign-up return that opens on the cont…
austincalvelage Nov 23, 2026
7876d83
fix(mosaic): complete a social sign-up return on whichever route sign…
austincalvelage Nov 23, 2026
3dd5f06
refactor(mosaic): derive the sign-up OAuth return's busy state from i…
austincalvelage Nov 23, 2026
d28478e
test(mosaic): send the redirect_url as social sign-up's after-sign-up…
austincalvelage Nov 23, 2026
99b3a4e
fix(mosaic): honor redirect_url as the URL a social sign-up lands on
austincalvelage Nov 23, 2026
ab09f7d
test(mosaic): send a social sign-up transfer that needs a second fact…
austincalvelage Nov 23, 2026
f8912f6
fix(mosaic): send a social sign-up transfer to the sign-in step it st…
austincalvelage Nov 23, 2026
4241511
refactor(mosaic): move the sign-up OAuth completion out of the model …
austincalvelage Nov 23, 2026
f1cb410
test(mosaic): cover social sign-up's existing session, Protect after …
austincalvelage Nov 23, 2026
7da0e62
refactor(mosaic): share the redirect hold between sign-up and user pr…
austincalvelage Nov 23, 2026
74cadb8
docs(mosaic): describe the sign-up OAuth return as built
austincalvelage Nov 23, 2026
d3e0965
test(mosaic): cover a sign-up transfer after the Protect check on the…
austincalvelage Nov 23, 2026
73980d1
fix(mosaic): transfer a social sign-up after its Protect check is solved
austincalvelage Nov 23, 2026
c47a771
refactor(mosaic): read the sign-up OAuth return marker through the ro…
austincalvelage Nov 23, 2026
7c336af
test(mosaic): run a Protect check raised on the return from Google
austincalvelage Nov 23, 2026
4b3226e
refactor(mosaic): let the sign-up details controller decide which pro…
austincalvelage Nov 24, 2026
3bd4b5f
fix(mosaic): hide Continue's providers only when legal consent is all…
austincalvelage Nov 24, 2026
a9e2ce4
refactor(mosaic): settle the sign-up OAuth return inside completeReturn
austincalvelage Nov 24, 2026
eedaef3
test(mosaic): land on the redirect_url when a social sign-up turns in…
austincalvelage Nov 24, 2026
c10e743
fix(mosaic): keep redirect_url when a social sign-up turns into a sig…
austincalvelage Nov 24, 2026
841d26c
docs(mosaic): say sign-up OAuth is a full-page redirect and popup OAu…
austincalvelage Nov 24, 2026
7ef145a
test(mosaic): show the blocked notice when a social sign-up return wa…
austincalvelage Nov 24, 2026
5645a61
fix(mosaic): show the blocked notice when a social sign-up return was…
austincalvelage Nov 24, 2026
8723690
test(mosaic): show the blocked notice when starting a social sign-up …
austincalvelage Nov 24, 2026
e855c08
fix(mosaic): show the blocked notice when starting a social sign-up i…
austincalvelage Nov 24, 2026
e9595f0
test(mosaic): give the social sign-up tests their own file
austincalvelage Nov 25, 2026
c128bdb
style(mosaic): sort imports in the sign-up details controller
austincalvelage Nov 25, 2026
bc80eb0
docs(mosaic): stop citing a TODO that sign-up does not have
austincalvelage Nov 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/mosaic-sign-up-oauth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
1 change: 1 addition & 0 deletions packages/mosaic/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Most problems a feature hits already have a shared answer. Find the line for you
- Moving focus after a list row is removed → `useListRemovalFocus` (`src/hooks/`)
- A debounced, abortable async check as the user types → `useDebouncedAsync` (`src/hooks/`)
- A spinner that should not flash or flicker → `useSpinDelay` (`src/hooks/`)
- Keeping an action pending after it starts a full-page redirect, such as to an OAuth provider → `REDIRECT_HOLD_MS` (`src/utils/redirect.ts`)
- A placeholder for content that is still loading → `Skeleton` (`src/components/skeleton/`), see [Skeletons](docs/skeletons.md)
- A date shown to the user → `formatDate` (`src/utils/format-date.ts`)
- Any current time read during render → `useNow` (`src/hooks/`), with `until` to stop ticking at a deadline
Expand Down
23 changes: 17 additions & 6 deletions packages/mosaic/docs/internals/sign-in-sign-up-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FAPI tracks which requirements are outstanding and whether a code has been sent.

Today FAPI sends `status`, `missing_fields` and `unverified_fields`, not a step. Until it sends `nextStep`, `getSignInNextStep` and `getSignUpNextStep` in `shared` compute it from those fields (see [Bridge](#bridge)).

Sign-up's `continue` screen asks for what FAPI lists in `missing_fields`, not for what the instance's settings would require, so the client never re-derives a rule FAPI already applied (`continueFields` in `mosaic/src/features/sign-up/sign-up.utils.ts`). A missing email, phone or username that FAPI also lists in `optional_fields` is a choice, so the form asks for one of them, with the email/phone switch when both are allowed. An email or phone FAPI lists in `unverified_fields` stays on the form, prefilled, so Edit on a verify screen reached from `continue` has an address to change. FAPI drops the old verification whenever an update sends the address, changed or not, so the verify screen sends a new code. Requirements another step owns, such as `enterprise_sso`, don't appear. When FAPI lists a requirement `continue` can't ask for, such as a required `oauth_*` provider, the step is `unknown` and the user sees Start over instead of a form that can't finish. A sign-up that must verify its email on an instance that enables the email link is `unknown` too, until the link screen is built; `ui` shows its link card there (`ui/src/components/SignUp/SignUpVerifyEmail.tsx`). `start` has no sign-up yet, so it reads the instance's settings.
Sign-up's `continue` screen asks for what FAPI lists in `missing_fields`, not for what the instance's settings would require, so the client never re-derives a rule FAPI already applied (`continueFields` in `mosaic/src/features/sign-up/sign-up.utils.ts`). A missing email, phone or username that FAPI also lists in `optional_fields` is a choice, so the form asks for one of them, with the email/phone switch when both are allowed. An email or phone FAPI lists in `unverified_fields` stays on the form, prefilled, so Edit on a verify screen reached from `continue` has an address to change. FAPI drops the old verification whenever an update sends the address, changed or not, so the verify screen sends a new code. Requirements another step owns, such as `enterprise_sso`, don't appear. A missing `oauth_*` provider shows that provider's button, and only the missing ones, since another provider can't satisfy it; the user links the rest from their profile. When FAPI lists a requirement `continue` can't ask for, such as a provider that can't sign the user in, the step is `unknown` and the user sees Start over instead of a form that can't finish. A sign-up that must verify its email on an instance that enables the email link is `unknown` too, until the link screen is built; `ui` shows its link card there (`ui/src/components/SignUp/SignUpVerifyEmail.tsx`). `start` has no sign-up yet, so it reads the instance's settings.

There is no step machine and no local copy of the step. What the step can't say lives in the route, such as the factor the user picked in `factorOne`'s `:factor` param, or whether a sign-up verify screen was reached from `continue`.

Expand Down Expand Up @@ -56,9 +56,9 @@ submitPassword: async (password: string) => {
```

- `complete`: the model's `finalize()`, then leave the flow for the after sign-up URL, which honors `redirect_url` and the redirect query params (`clerk.buildAfterSignUpUrl({ params })`). Creating the session clears the sign-up. Sign-up renders the model it left from while `finalize()` runs, and after it until a task that continues in the flow has its data loaded, so the task replaces the screen with no skeleton between them. It keeps the action pending throughout, the way the switcher holds its `frozenModel` ([Controllers → Wrapping actions](../controllers.md#wrapping-actions)). Once the hold ends with the session signed in, the flow is over: if the host keeps the component mounted, it renders nothing. In a modal, don't `close()` when the flow leaves: `finalize()`'s navigation is the last write and takes the modal with it.
- `transfer`: planned, not built. From sign-in, the model's `transfer()` will call `signUp.create({ transfer: true, unsafeMetadata })`, then `next` with the sign-up's step; a sign-in with sign-up built in holds the sign-up routes under `create/`, otherwise it leaves for the sign-up page. From sign-up, when the identifier already has an account, it will call `signIn.create({ transfer: true })`, then `next` with the sign-in's step. Until then sign-up keeps the current screen on a `transfer` step.
- `transfer`: sign-up transfers only an OAuth account that already has a user. The OAuth return transfers it before a step reaches `next` ([Entry actions](#entry-actions)), unless a Protect check comes first. Then the Protect screen passes `transfer` to `next`, which runs the return's completion again and shows the loading screen while it does. Sign-in's transfer is planned: the model's `transfer()` will call `signUp.create({ transfer: true, unsafeMetadata })`, then `next` with the sign-up's step; a sign-in with sign-up built in holds the sign-up routes under `create/`, otherwise it leaves for the sign-up page.
- `unknown`: nothing. The screen already shows "Start over".
- `blocked`: sign-up's `create`, the Protect proof's `resolve` and the invitation's `redeemTicket` resolve with it, not a step, when FAPI answers `action_blocked`. The controller keeps the details for this mount and shows the notice in place of `start` or the Protect route. The notice is not read from Clerk's sign-up error, which outlives the component, so a remount shows the form again, as `ui`'s card error does.
- `blocked`: sign-up's `create`, the Protect proof's `resolve` and the invitation's `redeemTicket` resolve with it, not a step, when FAPI answers `action_blocked`. The OAuth return's `completeReturn` resolves with it when FAPI stored that error on the external account, and `sso` resolves with it from `start`. From `continue`, `sso` rejects and the error shows inline, as `update`'s does. The controller keeps the details for this mount and shows the notice in place of `start` or the Protect route. The notice is not read from Clerk's sign-up error, which outlives the component, so a remount shows the form again, as `ui`'s card error does.
- Anything else: `go(routeFor(step))`.
- An error from `finalize()` or the transfer stays on the current screen until the user leaves it, so Edit clears it. After an invitation that completed on redemption, that screen is `start` ([Entry actions](#entry-actions)). A sign-up that is already complete skips the request and returns `complete`, so entering the code again, or pressing Continue again on `start` or `continue`, runs `finalize()` again. Sending the request again would fail: the user now exists, so FAPI answers `form_identifier_exists`.

Expand Down Expand Up @@ -111,7 +111,7 @@ With no `:factor`, `factorOne` starts on the factor `ui`'s `determineStartingSig

## Entry actions

Sign-up redeems invitation tickets. The other entries are planned. The controller calls these model callbacks when sign-up opens, then `next(step)`.
Sign-up redeems invitation tickets and completes OAuth returns. The other entries are planned. The controller calls these model callbacks when sign-up opens, then `next(step)`.

- Ticket:
- Read and redeem once. Sign-up reads the ticket from `__clerk_ticket` or `__clerk_invitation_token`, as `ui`'s `SignUpStart` does, redeems it with `signUp.ticket({ unsafeMetadata })`, and shows the loading screen while it redeems. A ticket works only once, so `useSignUpController` keeps the redeemed ticket in a ref, and a remount or StrictMode can't redeem it twice. A failed redemption shows its error on `start` and removes the parameters, so `start` then works as a normal sign-up. A blocked redemption removes them too and shows `actionBlocked`.
Expand All @@ -120,8 +120,19 @@ Sign-up redeems invitation tickets. The other entries are planned. The controlle
- An invitation that needs nothing more. FAPI can answer the redemption with `complete`. The model does not pick the loading screen, so freezing the model alone would show `start` while `finalize()` runs. The ticket action hands `next` the loading screen to freeze with the model, and it stays up through `finalize()` and the wait for a task. If `finalize()` fails, the hold ends and `start` shows the error. `finalize()` has removed the ticket by then, so `start` is a normal sign-up form with its sign-in link.
- Cleanup, and what waits for sign-in. Finishing or starting over removes the parameters. Choosing between `signUp.ticket()` and `signIn.ticket()` by `__clerk_status`, as `ui/src/components/SignIn/SignInStart.tsx` does, is sign-in's job and waits for its controller.
- Email-link return (`__clerk_status`): `verified` with a `__clerk_created_session` this client has activates that session (`clerk-js/src/core/clerk.ts:2620-2636`); any other `verified` continues by step. `transferable` and the error statuses show their own screen, as `ui/src/common/EmailLinkVerify.tsx` does.
- Redirect URLs for email links and OAuth/SAML returns come from the router (the planned `useReturnUrl(name, params)`), never hand-built. That part waits for the routing follow-up.
- A step that is already `complete` or `transfer` on mount, such as a reload before it ran: `next(step)` runs it once, with the same guard as a ticket. The email-link return is handled first.
- Redirect URLs for email links and OAuth/SAML returns will come from the router's `useReturnUrl(name, params)` (#10860). For now the OAuth return builds its callback URL by hand with a marker, described in the next entry. The marker moves to `useReturnUrl()` when that hook lands.
- OAuth return: sign-up's callback URL is the current URL plus the marker `__clerk_mosaic_sign_up=sso-callback`, the way `withUserProfileModalReturn` marks a profile return. It keeps the rest of the query, so `redirect_url` and an invitation's ticket come back with the user. `sso()` sends the after sign-up URL that honors `redirect_url` as the URL to land on after the provider. When sign-up opens with the marker, on any route, `useSignUpController` shows the loading screen from the first paint and runs `completeReturn` once as its `return` action. The loading screen reads the marker until that action has run, then the action's pending state, so busy has one source. The ticket waits until the return is done. `completeReturn` removes the marker and follows `clerk.handleRedirectCallback`'s sign-up branches on the Future API:
- A Protect check comes first. Once it is solved, `next` gets the step that follows, so a transfer after it still runs.
- A `transferable` account becomes a sign-in (`signIn.create({ transfer: true })`). A complete sign-in finishes in place. Otherwise the user goes to the sign-in route its status needs, as `_handleRedirectCallback` does: `factor-one`, `factor-two`, `reset-password`, or `protect-check` when the sign-in has a Protect check. The route goes in the hash of the sign-in URL, which keeps `redirect_url`.
- An `identifier_already_signed_in` account activates that session.
- A session from a transfer or an existing session is a sign-in, so a pending task goes to its task URL rather than staying in sign-up.
- An external-account error removes the ticket, resets the sign-up and shows on `start`, with FAPI's message only for the codes legacy's `SignUpStart` shows and the generic error otherwise. An `action_blocked` error that carries its details resolves with `blocked` instead and shows `actionBlocked`, as legacy's `ActionBlockedCard` does. Removing the ticket keeps the invitation from being redeemed again over the error, as in legacy, where the callback URL has no ticket.
- Anything else is `next(step)`.

The marker is gone once the return starts, so a reload mid-return lands on `start`. OAuth is a full-page redirect only. Sign-up never passes `sso()` a `popup`, so popup OAuth (`oauthFlow: 'popup'`) is not built. An OAuth transport (`__internal_oauthTransport`) is not supported yet. `SignUpFuture.sso()` still navigates the window, so clerk-js has to honor the transport first. Sign-in-to-sign-up transfers start from sign-in, so they wait for its controller.

- `signUp.sso()` updates any sign-up already on the client, so `start` resets a sign-up that isn't the invitation's and calls `sso()` on the client's new sign-up, since the old `SignUpFuture` still points at the reset one; `continue` keeps it. On an instance with no form identifier, where `showFormFields` is false, `start` shows only the providers, without fields or the consent checkbox, as legacy does; consent then comes on `continue`. `continue` hides the providers once the sign-up has a verified external account.
- A step that is already `complete` or `transfer` on mount, such as a reload before it ran, is not handled yet: `routeFor` has no route for `transfer`, and nothing runs `complete` when sign-up mounts. The email-link return will be handled first.
- Hash params: Clerk's URL builders (`redirectToSignUp()`, `buildSignUpUrl`) put the redirect params and initial values in the URL hash, and sign-up reads only the query, so they are not read yet.

## Bridge
Expand Down
Loading
Loading