feat(core): add experimental signUp flow API and endpoint#183
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Warning Review limit reached
More reviews will be available in 36 minutes and 36 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThis PR introduces a new sign-up feature into the auth system. It adds type contracts for sign-up API options and responses, extends configuration types with a ChangesSign-up Feature Implementation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
packages/core/test/api/signUp.test.ts (1)
60-70: ⚡ Quick winAdd a
toResponse()assertion on the failure case to lock API contract parity.This test already checks the object shape; adding checks for
await output.toResponse().json()(includingerror.code) will prevent silent drift between object and response paths.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/test/api/signUp.test.ts` around lines 60 - 70, The test currently asserts the returned output object shape but not the HTTP response body; add an assertion that calls await output.toResponse().json() and verifies the response JSON matches the failure payload (at minimum that response.error.code === "USER_CREATION_FAILED" and response.error.message matches the expected message) to keep the toResponse() path in sync with the object shape produced by the sign-up flow (look for usages of output and output.toResponse in signUp.test.ts).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/actions/signUp/signUp.ts`:
- Around line 28-37: The signUp handler currently calls signInCredentials
(skipping the sign-up path and onCreateUser), so change the flow to execute the
sign-up callback before signing in: either call the existing signUpCredentials
helper (or invoke onCreateUser directly) to create the user using the
signUp.schema-validated payload and then call signInCredentials to produce the
session/response; ensure the code references the same payload and
request/headers (ctx.request, ctx.request.headers,
ctx.searchParams.redirect/redirectTo) and that onCreateUser is awaited and its
result used when constructing the sign-in call so onCreateUser is not bypassed.
In `@packages/core/src/api/signUp.ts`:
- Around line 65-80: The toResponse() implementation in signUp.ts currently
returns a body without the error payload and omits the response headers; update
the toResponse() function to return a Response.json payload that includes the
same error object (code and message) and other fields (success, redirect,
redirectURL), and attach the existing Headers instance (secureApiHeaders or the
returned headers) to the Response so callers using toResponse() receive
identical body and headers as the top-level return. Locate the toResponse method
in the sign-up response object and ensure it serializes the error object and
uses new Response(..., { headers: headersInstance }) when building the Response.
In `@packages/core/src/createAuth.ts`:
- Line 50: The sign-up route is being registered unconditionally using a forced
cast of config.context.signUp to SignUpConfig, which crashes when signUp is
absent; modify the registration logic in createAuth (where signUpAction(...) is
invoked) to first check that config.context.signUp is defined (e.g., if
(config.context.signUp) ...) and only then call signUpAction with the properly
typed config.context.signUp (avoid the forced cast). Ensure any route array or
middleware list that currently unconditionally includes signUpAction is
conditionally appended based on presence of signUp so initialization skips
sign-up when not configured.
---
Nitpick comments:
In `@packages/core/test/api/signUp.test.ts`:
- Around line 60-70: The test currently asserts the returned output object shape
but not the HTTP response body; add an assertion that calls await
output.toResponse().json() and verifies the response JSON matches the failure
payload (at minimum that response.error.code === "USER_CREATION_FAILED" and
response.error.message matches the expected message) to keep the toResponse()
path in sync with the object shape produced by the sign-up flow (look for usages
of output and output.toResponse in signUp.test.ts).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b65dde41-eb4b-4e1a-9045-a5099fa420fe
📒 Files selected for processing (16)
packages/core/src/@types/api.tspackages/core/src/@types/config.tspackages/core/src/actions/index.tspackages/core/src/actions/signIn/authorization.tspackages/core/src/actions/signUp/signUp.tspackages/core/src/api/createApi.tspackages/core/src/api/index.tspackages/core/src/api/signUp.tspackages/core/src/client/client.tspackages/core/src/createAuth.tspackages/core/src/router/context.tspackages/core/src/shared/identity.tspackages/core/src/shared/logger.tspackages/core/test/api/signUp.test.tspackages/core/test/presets.tspackages/core/test/types.test-d.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/`@types/config.ts:
- Line 18: The AuthConfig type was made stricter by adding a required
SignUpSchema generic, breaking existing AuthConfig<Identity> usage; restore
public compatibility by giving the SignUpSchema generic a default (aligning with
other public types). Update the declaration of AuthConfig to provide a default
for SignUpSchema (using the existing SchemaTypes type) so callers can omit the
second generic; keep the Identity generic bounded by Identities as before and
leave the rest of the type unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 868bc0c6-25f4-42c3-8cb9-0f91558175c3
📒 Files selected for processing (15)
packages/core/src/@types/api.tspackages/core/src/@types/config.tspackages/core/src/actions/signIn/authorization.tspackages/core/src/actions/signUp/signUp.tspackages/core/src/api/createApi.tspackages/core/src/api/signUp.tspackages/core/src/client/client.tspackages/core/src/createAuth.tspackages/core/src/router/context.tspackages/core/src/shared/logger.tspackages/core/test/actions/signUp/signUp.test.tspackages/core/test/api/signInCredentials.test.tspackages/core/test/api/signUp.test.tspackages/core/test/presets.tspackages/core/test/types.test-d.ts
✅ Files skipped from review due to trivial changes (1)
- packages/core/src/client/client.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/core/src/@types/api.ts
- packages/core/src/actions/signIn/authorization.ts
Description
This pull request introduces an experimental
signUpflow for both the API and endpoint definitions.The new action enables user account creation within the authentication system and provides customizable payload validation through supported schema libraries, including Zod, Valibot, TypeBox, and ArkType. To enable this feature, developers must configure the
signUpoption when callingcreateAuth.The sign-up flow is exposed through both the
apiobject and the/signUpendpoint. Both entry points provide the same behavior; the primary difference is their intended usage:api.signUp()is designed for server-side integrations./signUpis designed for client-side and external HTTP integrations.Features
api.signUp()/signUpConfig
Usage (API)
Usage (Endpoint)