Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR adds server-driven UI schema endpoints for sign-in/sign-up (for native clients) and introduces new passkey flows: an authenticated “passkey upgrade” flow and a pre-auth “account creation” flow (Apple system sheet), with supporting validation and helpers.
Changes:
- Add
/api/auth/ui-schema/{signin,signup}endpoints backed by a sharedbuild*Schema()generator and tests. - Add passkey upgrade (
/api/oauth/passkey/upgrade/{options,verify}) and passkey account-creation (/api/oauth/passkey/account-creation/{options,verify}) endpoints with comprehensive unit tests. - Add supporting OAuth validation schemas, Redis challenge-type extensions, a Bearer-token helper, and contact-identifier normalization.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/validations/oauth.ts | Adds request schemas/types for passkey upgrade + account-creation flows. |
| lib/ui-schema/build.ts | Implements UI schema builder (fields/methods/links + Zod-derived validation). |
| lib/ui-schema/build.test.ts | Unit tests for the UI schema builder behavior and feature gating. |
| lib/redis/index.ts | Extends WebAuthnChallengeData.type to include new passkey flows. |
| lib/oauth/contact-identifier.ts | Adds normalization for OS-provided email/phone identifiers. |
| lib/oauth/bearer.ts | Adds shared Bearer token parsing + access token verification helper. |
| app/api/oauth/token/password-grant.test.ts | Updates JWT mock exports to include verifyAccessToken. |
| app/api/oauth/passkey/upgrade/options/route.ts | New authenticated endpoint to mint upgrade registration options + store challenge. |
| app/api/oauth/passkey/upgrade/options/route.test.ts | Tests for upgrade options route behavior and auth failures. |
| app/api/oauth/passkey/upgrade/verify/route.ts | New authenticated endpoint to verify attestation and persist passkey. |
| app/api/oauth/passkey/upgrade/verify/route.test.ts | Tests for upgrade verify route success and error cases. |
| app/api/oauth/passkey/account-creation/options/route.ts | New pre-auth endpoint to mint account-creation options + store challenge. |
| app/api/oauth/passkey/account-creation/options/route.test.ts | Tests for account-creation options gating and client/redirect validation. |
| app/api/oauth/passkey/account-creation/verify/route.ts | New pre-auth endpoint to verify attestation, create user/passkey, issue tokens. |
| app/api/oauth/passkey/account-creation/verify/route.test.ts | Tests for account-creation verify flow (email + phone) and error cases. |
| app/api/auth/ui-schema/signin/route.ts | New public endpoint returning sign-in UI schema. |
| app/api/auth/ui-schema/signin/route.test.ts | Tests for sign-in UI schema endpoint output and error handling. |
| app/api/auth/ui-schema/signup/route.ts | New public endpoint returning sign-up UI schema with sign-up gating/flag. |
| app/api/auth/ui-schema/signup/route.test.ts | Tests for sign-up UI schema endpoint gating and feature flag behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+153
to
+157
| { id: "forgot-password", label: "Forgot password?", href: "/reset" }, | ||
| { | ||
| id: "switch-to-signup", | ||
| label: "Create an account", | ||
| href: "/signup", |
Comment on lines
+146
to
+151
| return { | ||
| flow: "signin", | ||
| title, | ||
| submitLabel: "Sign in", | ||
| fields: [emailField(), passwordField({ autocomplete: "current-password" })], | ||
| supportedMethods: methods, |
Comment on lines
+44
to
+49
| const challengeData = await getWebAuthnChallenge(data.session_id); | ||
| if ( | ||
| !challengeData || | ||
| challengeData.type !== "passkey-upgrade" || | ||
| challengeData.userId !== auth.payload.sub | ||
| ) { |
Comment on lines
+50
to
+52
| // the other native signup routes. checkSignUpAllowed only refuses when | ||
| // global sign-up is disabled (no whitelist match is fine — there's no | ||
| // identifier to check yet; whitelist enforcement defers to /verify). |
Comment on lines
+24
to
+25
| // (marked verified — Apple's flow is system-confirmed), persist the | ||
| // passkey, and issue OAuth tokens. |
Comment on lines
+13
to
+15
| // RFC-ish email check: same shape Zod's .email() validates against. | ||
| const EMAIL_RE = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/; | ||
|
|
Comment on lines
+8
to
+14
| // GET /api/auth/ui-schema/signup?client_id=<id> | ||
| // | ||
| // Public endpoint. Returns a JSON description of the sign-up form. Mirrors | ||
| // /signin but the supportedMethods list is gated on the global sign-up | ||
| // settings (see lib/settings/sign-up.ts): when sign-up is fully disabled the | ||
| // methods list is empty so the client can render its own "sign-up closed" UI | ||
| // without hard-coding the rule. |
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.
No description provided.