Repository navigation
feat(mosaic): send sign-up phone codes over WhatsApp - #10930
austincalvelage merged 31 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: d9b8d03 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 |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
920ef05 to
2db057f
Compare
2db057f to
7f1d941
Compare
@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: |
7f1d941 to
9e8e980
Compare
9e8e980 to
798166f
Compare
798166f to
d7d887b
Compare
d7d887b to
a568e3a
Compare
A phone error from FAPI now shows on the WhatsApp phone screen, since AuthAlternativeChannel reads the phone field's feedback. A failed WhatsApp send shows FAPI's message. The continue screen offers no WhatsApp buttons. Editing from the code screen and Start over return to the main form. The WhatsApp create sends prefilled values the screen does not show. The country's preferred channel applies only to the first send after the start form, not to resends or a phone entered on the continue screen.
FAPI allows the WhatsApp channel when the instance can send WhatsApp messages, not when the phone attribute lists it, and rejects it with whatsapp_channel_not_enabled otherwise. It can also send by SMS when the WhatsApp quota is used up, and always reports the channel a phone code went out on. The fake now does the same.
… sign-up Continue on the WhatsApp phone screen stays disabled until the phone number is filled. The code screen locks while switching to SMS, starts the resend countdown after a failed send, and clears the typed code on resend and on the switch to SMS.
FAPI creates a sign-up with `strategy: 'phone_code'` and a channel in one transaction, so a code it cannot send creates nothing. The fake now does the same, and the tests check that a WhatsApp sign-up takes one request and that a failed send leaves no sign-up behind.
A WhatsApp sign-up created the sign-up, then sent the code in a second request. When the send failed, the sign-up stayed behind and each retry created another. Create now sends `strategy: 'phone_code'` with the picked or preferred channel, as legacy `SignUpStart` does, so FAPI creates the sign-up and sends the code together. The SMS default still sends no strategy and lets the code screen send the code.
The full form and the WhatsApp phone screen share one form, so a rejected phone number on one stayed under the phone field after switching to the other. Picking a channel and Use another method now clear the phone number's error.
…om WhatsApp Resend clears the channel the code screen picked, so it relies on the model sending over the channel the sign-up last used. The test pins that a resend after switching to SMS stays on SMS.
The fake FAPI dropped the sign-up when the create request could not send the WhatsApp code. clerk_go 8bb8f66dde inserts the sign-up and attaches it to the client before it prepares the code (api/fapi/v1/sign_up/service.go:394-407), prepares it in a later transaction (:529, channel check in pkg/usersettings/clerk/strategies/phone_code.go:352-361), and returns the error with the client (http.go:73-77, wrapper.go:49). clerk-js applies meta.client from an error response (Client.ts getClientResourceFromPayload). The fake now keeps the unverified sign-up with the phone number and sends the client in the error. The test that expected no sign-up now checks that the user stays on the WhatsApp screen with the error and a retry sends the code. A new test goes back to the form and signs up over SMS with the stray sign-up present.
- Fold the one-request create checks into the WhatsApp sign-up test. - Fold the rejected phone number checks into the test that goes back to the form after it. - Drop the unavailable-channel test, which the failed-send retry test repeats before it retries. - Drop the SMS switch test, which the SMS resend and lock tests cover. - Drop the back-to-form test, which two other tests do on the way.
The routing PR no longer uses vi, and these tests fake the resend timer.
…gn-up through the fake FAPI
…the phone channel comments Merges the two WhatsApp phone screen error tests into one that leaves both a field and a global error behind.
…SMS instead After a wrong code on the WhatsApp code screen, Send code via SMS instead emptied the input but kept the Incorrect code error under it, so the SMS screen opened with an error for a code the user had not entered. onSendSms now resets the pending action's error, as legacy does by remounting the code form (SignUpPhoneCodeCard prepareWithSMS).
The SMS and WhatsApp tests move out of the shared sign-up feature test, grouped by what the user is doing, with the phone environment they alone use beside them. The two tests of an error left behind between the form and the WhatsApp phone screen are one test that goes both ways.
…pp phone number The WhatsApp phone screen validates only the phone number, and the submit picked values for those same fields, so a name or username typed on the start form never reached the create request and the continue screen asked for it again. The submit now picks the start form's fields plus the phone, as `ui`'s card submits every active field from the shared form state.
… a prefilled one When the start form hides an optional phone, a prefilled number lands in the hidden values, and those were spread over the submitted ones. The WhatsApp phone screen shows that same number, so an edit there was overwritten and the code went to the prefilled number. A hidden value now fills only a field the active screen does not show.
…ile a code is still sending The code machine ignores the SMS switch while a send is in flight, but the button stays enabled there so the code input is not locked, and pressing it cleared the typed code and reset the error before sending nothing. The press now does nothing until the send settles.
…stance asks for an email or a phone number Submitting from the WhatsApp phone screen sent the start form's fields for the active identifier, so on an instance that asks for an email or a phone number, an email typed before choosing WhatsApp went along with the phone and the user was asked to verify the email first. Choosing WhatsApp makes the phone the identifier, so the submit now takes the start form's fields and hidden values for the phone.
…art from the WhatsApp code screen without pressing Edit
Description
Sends Mosaic sign-up phone codes over WhatsApp. Stacked on #10928.
When an instance turns on WhatsApp for phone numbers, the start screen offers it as a button. Picking it asks for the phone number only, creates the sign-up and sends the code over WhatsApp in the same request. The code screen names the channel, resends over it, and offers "Send code via SMS" instead of going back.
This needs
channelonSignUpFutureCreateParamsfrom #10955, which has merged. clerk-js already sends it, so that PR is a@clerk/sharedtype change. TheAuthAlternativeChannelfix this screen relies on is in #10957.Shared changes (for Mosaic reviewers)
strategy: 'phone_code'prepares the phone in the same request. When the send fails, the sign-up stays on the client with the unverified phone number and the error carries the client, as in clerk_go.1. The details model lists the alternative channels and can create over one.
createtakes an optional channel and sends it withstrategy: 'phone_code', so the code goes out with the create request.2. Picking a channel swaps
startfor the alternative phone screen. The details controller keeps the chosen channel, so the same form asks for the phone number only, and Continue stays disabled until it's filled. Back, Edit from the code screen and Start over all return to the full form. The channel buttons show onstartonly, as in legacy. A phone error from one screen is cleared when you switch to the other.3. The verify screen reads the channel from the sign-up. The verification model reports the channel the code went out on, so a reload still names WhatsApp, and the SMS screen shows when FAPI falls back to SMS because the WhatsApp quota is used up. Resend uses that channel, and the code machine gets a
SEND_SMSevent for the switch to SMS. The screen locks while switching, clears the typed code on resend and on the switch, clears a wrong-code error on the switch, and starts the resend countdown even when a send fails.4. The first code after the start form uses the channel the instance prefers for the number's country, through
getPreferredPhoneCodeChannelByCountry, as legacy does. It goes out with the create request. Resends and a phone entered oncontinuedon't use it. With no preferred channel, create sends no strategy and the code screen sends the SMS code.5. Errors on the WhatsApp path show where the user looks. A rejected phone number shows under the field, through the
AuthAlternativeChannelfix in #10957. A failed WhatsApp send, such aswhatsapp_channel_not_enabled, shows FAPI's message instead of the generic one. A blocked request shows the blocked notice in place of the WhatsApp phone screen.Known gaps
whatsapp_channel_not_enabledmessage. Legacy keeps its card error there.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
🤖 Generated with Claude Code