-
Notifications
You must be signed in to change notification settings - Fork 377
feat(clerk-js,types): Signal SignUp APIs #6571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 2b25101 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 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 |
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
📝 WalkthroughWalkthroughAdds a changeset bumping @clerk/clerk-js and @clerk/types minor versions and notes an experimental Signal SignUp API. Expands SignUpFuture in clerk-js with a verifications map (sendEmailCode, verifyEmailCode), a unverifiedFields getter, and async methods: password({ emailAddress, password }), sendEmailCode(), verifyEmailCode({ code }), and finalize({ navigate }). All async operations use runAsyncResourceTask; finalize guards against missing createdSessionId and calls SignUp.clerk.setActive. Updates types to add unverifiedFields, verifications, password, and finalize (navigate?: SetActiveNavigate). Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (6)
.changeset/big-queens-tap.md (1)
6-6
: Expand the changeset body to enumerate the experimental API surfaceConsider listing the new experimental APIs to aid consumers and reviewers:
- SignUpFuture.verifications: sendEmailCode(), verifyEmailCode({ code })
- SignUpFuture.unverifiedFields getter
- SignUpFuture.password({ emailAddress, password })
- SignUpFuture.finalize({ navigate })
This helps changelog readers assess potential usage and migration paths.
packages/types/src/signUp.ts (1)
122-131
: Document and lock down the new SignUpFuture surface (readonly + JSDoc)These are public types; add minimal JSDoc and mark readonly where appropriate to prevent external mutation.
Apply this diff:
export interface SignUpFutureResource { - status: SignUpStatus | null; - unverifiedFields: SignUpIdentificationField[]; - verifications: { + /** @experimental Mirrors SignUp.status */ + readonly status: SignUpStatus | null; + /** @experimental Mirrors SignUp.unverifiedFields */ + readonly unverifiedFields: SignUpIdentificationField[]; + /** @experimental Verification helpers for email-code flows */ + readonly verifications: { sendEmailCode: () => Promise<{ error: unknown }>; verifyEmailCode: (params: { code: string }) => Promise<{ error: unknown }>; }; - password: (params: { emailAddress: string; password: string }) => Promise<{ error: unknown }>; - finalize: (params: { navigate?: SetActiveNavigate }) => Promise<{ error: unknown }>; + /** @experimental Starts email/password sign-up creation */ + password: (params: { emailAddress: string; password: string }) => Promise<{ error: unknown }>; + /** @experimental Finalizes sign-up by activating created session */ + finalize: (params: { navigate?: SetActiveNavigate }) => Promise<{ error: unknown }>; }Optionally, consider exporting a shared async result type (e.g.,
type ResourceTaskResult<T = void> = { result?: T; error: unknown }
) to align these signatures withrunAsyncResourceTask
.packages/clerk-js/src/core/resources/SignUp.ts (4)
499-506
: Prefer reusing existing helpers for email code preparationReusing the typed helper improves maintainability and keeps behavior aligned.
Apply this diff:
- async sendEmailCode(): Promise<{ error: unknown }> { - return runAsyncResourceTask(this.resource, async () => { - await this.resource.__internal_basePost({ - body: { strategy: 'email_code' }, - action: 'prepare_verification', - }); - }); - } + async sendEmailCode(): Promise<{ error: unknown }> { + return runAsyncResourceTask(this.resource, async () => { + await this.resource.prepareEmailAddressVerification(); + }); + }
508-515
: Prefer reusing existing helpers for email code attemptSame reasoning as above; keeps this thin wrapper aligned with the
SignUp
resource API.Apply this diff:
- async verifyEmailCode({ code }: { code: string }): Promise<{ error: unknown }> { - return runAsyncResourceTask(this.resource, async () => { - await this.resource.__internal_basePost({ - body: { strategy: 'email_code', code }, - action: 'attempt_verification', - }); - }); - } + async verifyEmailCode({ code }: { code: string }): Promise<{ error: unknown }> { + return runAsyncResourceTask(this.resource, async () => { + await this.resource.attemptEmailAddressVerification({ code }); + }); + }
517-525
: Throw a typed error when finalizing without a sessionPrefer domain-specific errors to a generic
Error
for consistency and better diagnostics.Apply this diff:
- async finalize({ navigate }: { navigate?: SetActiveNavigate }): Promise<{ error: unknown }> { + async finalize({ navigate }: { navigate?: SetActiveNavigate }): Promise<{ error: unknown }> { return runAsyncResourceTask(this.resource, async () => { if (!this.resource.createdSessionId) { - throw new Error('Cannot finalize sign-up without a created session.'); + throw new ClerkRuntimeError('Cannot finalize sign-up without a created session.', { + code: 'created_session_missing', + }); } await SignUp.clerk.setActive({ session: this.resource.createdSessionId, navigate }); }); }Additionally, consider guarding on
this.resource.status === 'complete'
before activating the session to avoid premature finalization.
474-526
: Add tests for the new Signal SignUpFuture APIsPlease add unit/integration tests covering:
- password(): calls
create
under the hood, respects captcha flow, updates resource state.- sendEmailCode(): triggers prepareEmailAddressVerification and updates verifications state.
- verifyEmailCode(): attempts verification and transitions status appropriately.
- finalize(): throws the typed error when
createdSessionId
is missing; callssetActive
with optional navigate when present.- Ensure eventBus emissions via
runAsyncResourceTask
for success and error paths.I can help scaffold these tests if useful.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
.changeset/big-queens-tap.md
(1 hunks)packages/clerk-js/src/core/resources/SignUp.ts
(3 hunks)packages/types/src/signUp.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
.changeset/**
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/big-queens-tap.md
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/types/src/signUp.ts
packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/types/src/signUp.ts
packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/types/src/signUp.ts
packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/types/src/signUp.ts
packages/clerk-js/src/core/resources/SignUp.ts
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/types/src/signUp.ts
packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/types/src/signUp.ts
packages/clerk-js/src/core/resources/SignUp.ts
**/*
⚙️ CodeRabbit Configuration File
If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.
Files:
packages/types/src/signUp.ts
packages/clerk-js/src/core/resources/SignUp.ts
🧬 Code Graph Analysis (2)
packages/types/src/signUp.ts (1)
packages/types/src/clerk.ts (1)
SetActiveNavigate
(123-123)
packages/clerk-js/src/core/resources/SignUp.ts (2)
packages/clerk-js/src/utils/runAsyncResourceTask.ts (1)
runAsyncResourceTask
(8-30)packages/types/src/clerk.ts (1)
SetActiveNavigate
(123-123)
🪛 ESLint
packages/clerk-js/src/core/resources/SignUp.ts
[error] 1-52: Run autofix to sort these imports!
(simple-import-sort/imports)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Build Packages
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (6)
.changeset/big-queens-tap.md (1)
2-3
: Version bumps and package scope look goodMinor bumps for @clerk/clerk-js and @clerk/types are appropriate given the added API surface.
packages/types/src/signUp.ts (1)
4-4
: Importing SetActiveNavigate from ./clerk is correctThe type-only import matches the new finalize signature usage.
packages/clerk-js/src/core/resources/SignUp.ts (4)
475-479
: Verifications wrapper looks goodBinding to instance methods ensures correct
this
and provides an ergonomic surface for consumers.
486-489
: Getter delegating to resource is correctExposes the same unverified fields in the future API surface.
517-525
: setActive already supportsnavigate
Verified thatSetActiveParams
(packages/types/src/clerk.ts) includesnavigate?: SetActiveNavigate
, and existing tests inclerk.test.ts
cover passing anavigate
callback. No changes needed.
1-29
: Fix lint script dependency & sort importsThe
pnpm lint --fix
run is failing due to a missingzx
module inscripts/lint.mjs
, so ESLint can’t auto–reorder imports yet. Please:
- Add
zx
as a devDependency (e.g.pnpm add -D zx
) or update your lint script so it no longer requireszx
.- Reinstall dependencies (
pnpm install
) and rerunpnpm lint --fix
.- Verify that imports in
packages/clerk-js/src/core/resources/SignUp.ts
(lines 1–29 and 31–53) are grouped and alphabetized according tosimple-import-sort/imports
.
async password({ emailAddress, password }: { emailAddress: string; password: string }): Promise<{ error: unknown }> { | ||
return runAsyncResourceTask(this.resource, async () => { | ||
await this.resource.__internal_basePost({ | ||
path: this.resource.pathRoot, | ||
body: { emailAddress, password }, | ||
}); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Use existing create flow for password sign-ups (captcha, normalization, consistency)
Calling __internal_basePost
here bypasses the logic in create
(captcha handling, normalization, retries). Reuse create
for parity with existing flows and to reduce divergence.
Apply this diff:
- async password({ emailAddress, password }: { emailAddress: string; password: string }): Promise<{ error: unknown }> {
- return runAsyncResourceTask(this.resource, async () => {
- await this.resource.__internal_basePost({
- path: this.resource.pathRoot,
- body: { emailAddress, password },
- });
- });
- }
+ async password({ emailAddress, password }: { emailAddress: string; password: string }): Promise<{ error: unknown }> {
+ return runAsyncResourceTask(this.resource, async () => {
+ await this.resource.create({ emailAddress, password });
+ });
+ }
Notes:
- This preserves captcha gating and any environment reload behavior present in
create
. - It also ensures any parameter normalization used by
create
is applied (e.g., naming conventions).
🏁 Script executed:
#!/bin/bash
set -e
echo "Searching for 'async create' implementation in SignUp.ts..."
rg -nP --type=ts 'async\s+create\b' -C5 -A30 packages/clerk-js/src/core/resources/SignUp.ts
Length of output: 237
🏁 Script executed:
#!/bin/bash
set -e
echo "Listing TypeScript files in resources directory:"
fd -e ts packages/clerk-js/src/core/resources
echo -e "\nSearching for 'async create' definitions in resources directory:"
rg -nP --type=ts 'async\s+create\b' -C3 -n packages/clerk-js/src/core/resources
echo -e "\nSearching for '__internal_basePost' definition sites:"
rg -nP '__internal_basePost\b' -C3 -n packages/clerk-js/src/core/resources
Length of output: 613
🏁 Script executed:
#!/bin/bash
set -e
echo "1) Listing all TS files under packages/clerk-js/src/core/resources:"
find packages/clerk-js/src/core/resources -type f -name '*.ts'
echo -e "\n2) Searching for 'async create' definitions across all TS files:"
rg -nP --type=ts 'async\s+create\b' -C3
echo -e "\n3) Searching for any 'create(' calls within resource classes:"
find packages/clerk-js/src/core/resources -type f -name '*.ts' -print0 \
| xargs -0 rg -nP '\bcreate\s*\(' -C3
echo -e "\n4) Searching for '__internal_basePost' definitions across resource files:"
rg -nP '__internal_basePost\b' -n -C3 --type=ts packages/clerk-js/src/core/resources
echo -e "\n5) Locating the definition of runAsyncResourceTask:"
rg -n 'runAsyncResourceTask' -n -C3 --type=ts packages/clerk-js/src/core
Length of output: 50867
---
🏁 Script executed:
```shell
#!/bin/bash
set -e
echo "1) Locate BaseResource class definition in Base.ts:"
rg -nP 'class\s+BaseResource' -C10 packages/clerk-js/src/core/resources/Base.ts
echo -e "\n2) Search for 'create' method definitions in BaseResource:"
rg -nP '^\s*(static\s+)?async\s+create\b' -n -C5 packages/clerk-js/src/core/resources/Base.ts || true
echo -e "\n3) Search for non-async 'create' declarations (e.g., property) in BaseResource:"
rg -nP '^\s*(static\s+)?create\s*=' -n -C5 packages/clerk-js/src/core/resources/Base.ts || true
echo -e "\n4) Inspect initial 200 lines of Base.ts for context:"
sed -n '1,200p' packages/clerk-js/src/core/resources/Base.ts | sed -e 's/$/↵/'
echo -e "\n5) Look for create overrides in SignUp.ts:"
rg -nP '^\s*(static\s+)?async\s+create\b' -n -C5 packages/clerk-js/src/core/resources/SignUp.ts || true
rg -nP '\bcreate\s*=' -n -C5 packages/clerk-js/src/core/resources/SignUp.ts || true
Length of output: 9002
🏁 Script executed:
#!/bin/bash
set -e
echo "Searching for _basePost definition in BaseResource:"
rg -nP 'protected\s+async\s+_basePost' -n -C5 packages/clerk-js/src/core/resources/Base.ts || true
echo -e "\nSearching for any _basePost implementation elsewhere in core:"
rg -nP 'async\s+_basePost' -n -C5 packages/clerk-js/src/core || true
Length of output: 2717
🏁 Script executed:
#!/bin/bash
set -e
echo "Extracting 'create' implementation in SignUp.ts around its definition:"
rg -nP 'create\s*=\s*async' -n -C15 packages/clerk-js/src/core/resources/SignUp.ts
Length of output: 1561
🏁 Script executed:
#!/bin/bash
set -e
echo "Extracting full 'create' method in SignUp.ts:"
# Extract from the start of create to the matching closing brace by dumping a large context.
sed -n '100,260p' packages/clerk-js/src/core/resources/SignUp.ts
Length of output: 6016
🏁 Script executed:
#!/bin/bash
set -e
echo "Extracting top of SignUp.ts for type definitions:"
sed -n '1,80p' packages/clerk-js/src/core/resources/SignUp.ts
Length of output: 2799
🏁 Script executed:
#!/bin/bash
set -e
echo "Locating runAsyncResourceTask file:"
file_path=$(find packages/clerk-js/src/core -type f -name 'runAsyncResourceTask.ts')
echo "Found at: $file_path"
echo -e "\nDisplaying its contents:"
sed -n '1,200p' "$file_path"
Length of output: 334
Refactor password sign-up to reuse the existing create
flow
Calling __internal_basePost
in the future’s password
method bypasses the captcha gating, parameter normalization, and retry logic in SignUp.create
. Swap it to invoke resource.create(...)
so it stays in sync with other flows.
Locations:
- packages/clerk-js/src/core/resources/SignUp.ts: lines 490–497
Proposed change:
- async password({ emailAddress, password }: { emailAddress: string; password: string }): Promise<{ error: unknown }> {
- return runAsyncResourceTask(this.resource, async () => {
- await this.resource.__internal_basePost({
- path: this.resource.pathRoot,
- body: { emailAddress, password },
- });
- });
- }
+ async password({ emailAddress, password }: { emailAddress: string; password: string }): Promise<{ error: unknown }> {
+ return runAsyncResourceTask(this.resource, async () => {
+ await this.resource.create({ emailAddress, password });
+ });
+ }
This preserves captcha challenges, client reload behavior, retries, and any metadata normalization in create
.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
async password({ emailAddress, password }: { emailAddress: string; password: string }): Promise<{ error: unknown }> { | |
return runAsyncResourceTask(this.resource, async () => { | |
await this.resource.__internal_basePost({ | |
path: this.resource.pathRoot, | |
body: { emailAddress, password }, | |
}); | |
}); | |
} | |
async password({ emailAddress, password }: { emailAddress: string; password: string }): Promise<{ error: unknown }> { | |
return runAsyncResourceTask(this.resource, async () => { | |
await this.resource.create({ emailAddress, password }); | |
}); | |
} |
🤖 Prompt for AI Agents
In packages/clerk-js/src/core/resources/SignUp.ts around lines 490 to 497, the
password sign-up method directly calls this.resource.__internal_basePost which
bypasses captcha gating, parameter normalization, retry logic and other behavior
implemented in SignUp.create; change the method to call this.resource.create({
strategy: "password", emailAddress, password }) (or the equivalent signature
used by create) wrapped in runAsyncResourceTask so it reuses SignUp.create's
flow and preserves captcha, retries, reload behavior and metadata normalization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
packages/clerk-js/src/core/resources/SignUp.ts (1)
490-497
: Do not bypass create flow—this skips captcha gating, normalization, retriesDirectly calling __internal_basePost bypasses SignUp.create(), which handles captcha challenges, environment reloads, parameter normalization, and any retry logic. This can cause security and consistency regressions relative to other sign-up flows.
Apply this diff to reuse the existing flow:
async password({ emailAddress, password }: { emailAddress: string; password: string }): Promise<{ error: unknown }> { return runAsyncResourceTask(this.resource, async () => { - await this.resource.__internal_basePost({ - path: this.resource.pathRoot, - body: { emailAddress, password }, - }); + await this.resource.create({ emailAddress, password }); }); }
🧹 Nitpick comments (6)
packages/clerk-js/src/core/resources/SignUp.ts (6)
475-479
: Nit: Mark verifications as readonlyThis object shouldn’t be reassigned after construction. Marking it readonly communicates intent and prevents accidental mutation.
-class SignUpFuture implements SignUpFutureResource { - verifications = { +class SignUpFuture implements SignUpFutureResource { + readonly verifications = { sendEmailCode: this.sendEmailCode.bind(this), verifyEmailCode: this.verifyEmailCode.bind(this), };
499-506
: Prefer existing prepareEmailAddressVerification() over raw basePostUse the higher-level API to avoid duplication and to stay aligned with any future changes to verification flows.
async sendEmailCode(): Promise<{ error: unknown }> { return runAsyncResourceTask(this.resource, async () => { - await this.resource.__internal_basePost({ - body: { strategy: 'email_code' }, - action: 'prepare_verification', - }); + await this.resource.prepareEmailAddressVerification(); }); }
508-515
: Prefer existing attemptEmailAddressVerification() over raw basePostThis keeps behavior consistent with the rest of the codebase and reduces surface area for divergence.
async verifyEmailCode({ code }: { code: string }): Promise<{ error: unknown }> { return runAsyncResourceTask(this.resource, async () => { - await this.resource.__internal_basePost({ - body: { strategy: 'email_code', code }, - action: 'attempt_verification', - }); + await this.resource.attemptEmailAddressVerification({ code }); }); }
517-525
: Use ClerkRuntimeError with actionable guidance when session is missingThrowing a generic Error makes downstream handling harder and loses error context. Use ClerkRuntimeError with a code and a message suggesting next steps.
async finalize({ navigate }: { navigate?: SetActiveNavigate }): Promise<{ error: unknown }> { return runAsyncResourceTask(this.resource, async () => { if (!this.resource.createdSessionId) { - throw new Error('Cannot finalize sign-up without a created session.'); + throw new ClerkRuntimeError( + 'Cannot finalize sign-up without a created session. Complete verification (e.g. send/verify email code) and ensure create() has produced a createdSessionId before calling finalize().', + { code: 'session_missing' }, + ); } await SignUp.clerk.setActive({ session: this.resource.createdSessionId, navigate }); }); }
474-526
: Add JSDoc for the experimental SignUpFuture APIPublic/experimental surface should be documented for discoverability and to guide integrators. Briefly describe each method, parameters, and return shape.
Example:
/** * @experimental Signal-style future API for orchestrating SignUp flows. * Not intended for public use yet; surface is subject to change. */ class SignUpFuture implements SignUpFutureResource { /** * Triggers (or continues) a password-based sign-up using the default instance configuration. * Returns an object with `error` set when the operation fails; `result` is unused. */ async password(params: { emailAddress: string; password: string }): Promise<{ error: unknown }>; /** * Initiates email verification via code for the current sign-up attempt. */ async sendEmailCode(): Promise<{ error: unknown }>; /** * Attempts to verify the email using the provided code. */ async verifyEmailCode(params: { code: string }): Promise<{ error: unknown }>; /** * Finalizes the sign-up by activating the created session. * Provide `navigate` to customize navigation after activation. */ async finalize(params: { navigate?: SetActiveNavigate }): Promise<{ error: unknown }>; }I can open a follow-up PR adding these JSDoc blocks if helpful.
474-526
: Add targeted tests for the new Signal SignUp APIsThere are no tests shown for this new surface. Add coverage for:
- password(): delegates to SignUp.create with email/password and emits fetch/error events via eventBus
- sendEmailCode(): calls prepareEmailAddressVerification()
- verifyEmailCode(): calls attemptEmailAddressVerification({ code })
- finalize(): throws when createdSessionId is missing; calls Clerk.setActive with navigate when present
Mock the underlying SignUp methods and verify they are invoked correctly, plus ensure runAsyncResourceTask behavior on success/error.
Do you want me to scaffold these tests (e.g., using vitest/jest with spies on resource methods and eventBus)?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/clerk-js/src/core/resources/SignUp.ts
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/core/resources/SignUp.ts
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/core/resources/SignUp.ts
**/*
⚙️ CodeRabbit Configuration File
If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.
Files:
packages/clerk-js/src/core/resources/SignUp.ts
🧬 Code Graph Analysis (1)
packages/clerk-js/src/core/resources/SignUp.ts (2)
packages/clerk-js/src/utils/runAsyncResourceTask.ts (1)
runAsyncResourceTask
(8-30)packages/types/src/clerk.ts (1)
SetActiveNavigate
(123-123)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Build Packages
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
packages/clerk-js/src/core/resources/SignUp.ts (3)
16-16
: LGTM: Type-only import for SetActiveNavigate is correctAccurate usage of a type-only import keeps bundles lean and satisfies typing needs for finalize().
44-44
: LGTM: Standardized async/error handling via runAsyncResourceTaskGood reuse of the shared wrapper to emit events and normalize result/error handling.
486-489
: LGTM: Getter delegates to resourceStraightforward delegation; keeps the future’s surface in sync with the underlying resource.
Description
This PR adds the APIs necessary for sign-ups with the default instance configuration to our Signal implementation, which is not intended for public use yet.
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit
New Features
Documentation
Chores