Repository navigation
feat(mosaic,nextjs): add OAuthDeviceVerification - #11135
Draft
austincalvelage wants to merge 5 commits into
Draft
austincalvelage wants to merge 5 commits into
austincalvelage wants to merge 5 commits into
Conversation
Serve POST /v1/me/oauth/device/lookup and POST /v1/me/oauth/device the way FAPI does: an unknown code or one decided by another user answers 404 resource_not_found, an expired pending code 400 oauth_device_code_expired, a decision on a code that is no longer pending 400 bad_request, and a rate-limited instance 429 too_many_requests. Record every lookup and decision body so feature tests can assert what reached FAPI.
Export ConsentLogos, typed to the logo fields it reads, and pull the single-organization select out of OrganizationField as OrganizationSelect, which takes its label as a string. The device verification confirmation shows the same logos and organization select with its own copy.
Port the legacy OAuthDeviceVerification component tests and user code tests: code entry and normalization, URL prefill, each view a lookup or a decision can end on, approve and deny, the organization select, and the signed-out guard. They fail until the component exists.
Port the legacy OAuthDeviceVerification component to Mosaic and export it from @clerk/nextjs/preview. A state machine owns the flow from code entry through lookup, confirmation, and the decision, and tables map each FAPI status and error code to the view the user lands on.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 20a2fa7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
@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: |
Cover what the legacy component does that no Mosaic test pinned: an unexpected lookup failure offers another code, an unknown code stays in the field, an expired or rate-limited code at lookup offers no action, and a user without an email address is named by phone number.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
OAuthDeviceVerificationto Mosaic and exports it from@clerk/nextjs/preview. A signed-in user enters the code a device shows, or arrives with it inuser_code, reviews the request, picks an organization, and approves or denies. It lands on the same views as@clerk/ui's<OAuthDeviceVerification />, using the existinguseOAuthDeviceVerificationdata layer and Mosaic's model, controller and view split.Shared changes (for Mosaic reviewers)
oauth-consent.view.tsxexportsConsentLogosand a newOrganizationSelect, which consent's own single-org branch now uses.PRIVATE_METADATA_SCOPEmoves intooauth-consent.utils.tsbeside the other scope constants.oauth2_idpservice.1. Every FAPI answer leads where
ui's switch sends it. The flow is one state machine in the controller, and three tables decide each transition, mirroringui'sshowLookupResult,showLookupErrorand decision handler.Anything else goes to the error view, the only one that offers "Enter another code", as in
ui.2. Code entry matches
ui's rules. Eight slots in two groups of four. The code is normalized and validated withui's pattern, so an invalid code shows "Enter a valid 8-character code." and sends nothing, and an unknown code returns to entry with the field still editable. A validuser_codein the URL is looked up once.3. The confirmation screen reuses consent's pieces. The two logos, the scope list styles and the organization select come from
oauth-consent.offline_accessis hidden from the list and turns on the offline notice. The organization select shows only withuser:org:readand organizations enabled, and defaults to the last active organization. Approve and deny each send one decision, and only the chosen button shows pending.JSDoc for review.
Known gaps
uishows a separate loading view during lookup. Mosaic keeps entry on screen with Continue pending and the field disabled.uiaccepts any text and rejects it on submit. Digits and vowels still get in and are rejected on submit withui's message.utils.tsis copied fromui, not shared. Moving it to@clerk/sharedwould give both one validation rule.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
🤖 Generated with Claude Code