Skip to content

feat: add sign in schema for ui#43

Merged
sirily11 merged 1 commit into
mainfrom
ui-schema
May 26, 2026
Merged

feat: add sign in schema for ui#43
sirily11 merged 1 commit into
mainfrom
ui-schema

Conversation

@sirily11

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 26, 2026 14:29
@vercel

vercel Bot commented May 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rxlab-auth Ready Ready Preview, Comment May 26, 2026 2:30pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 shared build*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 thread lib/ui-schema/build.ts
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 thread lib/ui-schema/build.ts
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.
@sirily11 sirily11 enabled auto-merge (squash) May 26, 2026 14:39
@sirily11 sirily11 merged commit 7570800 into main May 26, 2026
4 checks passed
@sirily11 sirily11 deleted the ui-schema branch May 26, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants