Skip to content

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

Merged
merged 2 commits into from
Aug 19, 2025
Merged

Conversation

dstaley
Copy link
Member

@dstaley dstaley commented Aug 18, 2025

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.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Experimental SignUp enhancements: send and verify email codes, set email/password credentials, view unverified fields, and finalize sign up with optional navigation.
  • Documentation

    • Added note highlighting the experimental "Signal SignUp" APIs.
  • Chores

    • Minor version bumps for @clerk/clerk-js and @clerk/types.

Copy link

changeset-bot bot commented Aug 18, 2025

🦋 Changeset detected

Latest commit: 2b25101

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@clerk/clerk-js Minor
@clerk/types Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/localizations Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/shared Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/vue Patch

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

Copy link

vercel bot commented Aug 18, 2025

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

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Aug 18, 2025 9:22pm

Copy link

pkg-pr-new bot commented Aug 18, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6571

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6571

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6571

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6571

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6571

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6571

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6571

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6571

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6571

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6571

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6571

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6571

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6571

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6571

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6571

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6571

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6571

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6571

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6571

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6571

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6571

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6571

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6571

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6571

commit: 2b25101

Copy link
Contributor

coderabbitai bot commented Aug 18, 2025

📝 Walkthrough

Walkthrough

Adds 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.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 surface

Consider 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 with runAsyncResourceTask.

packages/clerk-js/src/core/resources/SignUp.ts (4)

499-506: Prefer reusing existing helpers for email code preparation

Reusing 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 attempt

Same 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 session

Prefer 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 APIs

Please 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; calls setActive 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.

📥 Commits

Reviewing files that changed from the base of the PR and between bcb905b and 053a873.

📒 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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly 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
Use const assertions for literal types: as const
Use satisfies 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly 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 good

Minor 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 correct

The type-only import matches the new finalize signature usage.

packages/clerk-js/src/core/resources/SignUp.ts (4)

475-479: Verifications wrapper looks good

Binding to instance methods ensures correct this and provides an ergonomic surface for consumers.


486-489: Getter delegating to resource is correct

Exposes the same unverified fields in the future API surface.


517-525: setActive already supports navigate
Verified that SetActiveParams (packages/types/src/clerk.ts) includes navigate?: SetActiveNavigate, and existing tests in clerk.test.ts cover passing a navigate callback. No changes needed.


1-29: Fix lint script dependency & sort imports

The pnpm lint --fix run is failing due to a missing zx module in scripts/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 requires zx.
  • Reinstall dependencies (pnpm install) and rerun pnpm 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 to simple-import-sort/imports.

Comment on lines +490 to +497
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 },
});
});
}
Copy link
Contributor

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.

Suggested 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 });
});
}
🤖 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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, retries

Directly 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 readonly

This 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 basePost

Use 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 basePost

This 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 missing

Throwing 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 API

Public/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 APIs

There 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 053a873 and 2b25101.

📒 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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly 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
Use const assertions for literal types: as const
Use satisfies 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly 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 correct

Accurate usage of a type-only import keeps bundles lean and satisfies typing needs for finalize().


44-44: LGTM: Standardized async/error handling via runAsyncResourceTask

Good reuse of the shared wrapper to emit events and normalize result/error handling.


486-489: LGTM: Getter delegates to resource

Straightforward delegation; keeps the future’s surface in sync with the underlying resource.

@dstaley dstaley merged commit 8dc6bad into main Aug 19, 2025
39 checks passed
@dstaley dstaley deleted the ds.feat/signals-signup-api branch August 19, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants