Skip to content

Conversation

dstaley
Copy link
Member

@dstaley dstaley commented Sep 18, 2025

Description

This PR adds support for the signIn.ticket() and signUp.ticket() methods to our Signal API.

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
    • Adds experimental ticket-based sign-in and sign-up flows in web and React SDKs; tickets can be supplied directly or read from the URL while existing flows remain unchanged.
  • Chores
    • Bumps relevant packages to newer minor versions for compatibility.
  • Documentation
    • Documents the experimental ticket-based authentication in the changelog.

Copy link

changeset-bot bot commented Sep 18, 2025

🦋 Changeset detected

Latest commit: ab0d83c

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 Sep 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 Sep 18, 2025 8:25pm

Copy link
Contributor

coderabbitai bot commented Sep 18, 2025

Walkthrough

Adds experimental ticket-based sign-in and sign-up flows: new ticket methods on SignInFuture and SignUpFuture that read a ticket from params or the __clerk_ticket query param and call create({ ticket }). Types, React state proxy, and a changeset bumping minors are included.

Changes

Cohort / File(s) Summary
Changeset and versioning
\.changeset/two-mangos-rest.md
Adds changeset bumping @clerk/clerk-js and @clerk/types (minor) and documents experimental ticket sign-ins/sign-ups.
Runtime: SignIn/SignUp implementations
packages/clerk-js/src/core/resources/SignIn.ts, packages/clerk-js/src/core/resources/SignUp.ts
Adds SignInFuture.ticket(params?) and SignUpFuture.ticket(params?). Resolve ticket from params.ticket or __clerk_ticket query param (via getClerkQueryParam), then call create({ ticket }). Adds corresponding imports.
Types: API surface additions
packages/types/src/signInFuture.ts, packages/types/src/signUpFuture.ts
Adds optional ticket?: string to *FutureCreateParams; introduces SignInFutureTicketParams and SignUpFutureTicketParams; adds ticket(params?): Promise<{ error: unknown }> to future resource interfaces and updates related docs.
React state proxy
packages/react/src/stateProxy.ts
Exposes ticket method on SignIn and SignUp state proxies via gateMethod(target, 'ticket').

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant C as App Code
  participant SF as SignInFuture
  participant API as Backend

  Note over C,SF: Sign-in via ticket (new)
  U->>C: Initiate sign-in
  C->>SF: call ticket(params?) or SF reads __clerk_ticket
  SF->>API: POST /create { ticket }
  alt Success
    API-->>SF: { error: null }
    SF-->>C: resolved Promise
  else Error
    API-->>SF: { error }
    SF-->>C: Promise with { error }
  end
Loading
sequenceDiagram
  autonumber
  actor U as User
  participant C as App Code
  participant SUF as SignUpFuture
  participant API as Backend

  Note over C,SUF: Sign-up via ticket (new)
  U->>C: Initiate sign-up
  C->>SUF: call ticket(params?) or SUF reads __clerk_ticket
  SUF->>API: POST /create { ticket }
  alt Success
    API-->>SUF: { error: null }
    SUF-->>C: resolved Promise
  else Error
    API-->>SUF: { error }
    SUF-->>C: Promise with { error }
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit with a ticket, light and quick,
I bounce through sign-in with a nimble flick.
Sign-up door swings with a gentle click,
New tunnels dug, experimental trick.
Hopping on, I celebrate—one nifty pick 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately summarizes the primary change: adding ticket-based sign-in and sign-up support in clerk-js and the types package. It follows conventional commit style (feat(scope):) and is concise and clear for reviewers scanning history. The file-level summaries (SignIn/SignUp API additions and corresponding type changes) match the title's wording.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ds.feat/signals-tickets

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

pkg-pr-new bot commented Sep 18, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: ab0d83c

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: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/clerk-js/src/core/resources/SignUp.ts (1)

597-629: Add ticket to SignUpFuture.create POST body

signUp.__internal_future.ticket({ ticket }) calls this.create({ ticket }) but SignUpFuture.create does not forward params.ticket to the POST body — ticket sign-up is broken.

File: packages/clerk-js/src/core/resources/SignUp.ts — SignUpFuture.create (lines ~597–629)

  async create(params: SignUpFutureCreateParams): Promise<{ error: unknown }> {
    return runAsyncResourceTask(this.resource, async () => {
      const { captchaToken, captchaWidgetType, captchaError } = await this.getCaptchaToken();

      const body: Record<string, unknown> = {
        transfer: params.transfer,
        captchaToken,
        captchaWidgetType,
        captchaError,
      };

+      if (params.ticket) {
+        body.ticket = params.ticket;
+      }

Add an integration test asserting the POST to /client/sign_ups includes ticket when signUp.__internal_future.ticket({ ticket }) is called.

🧹 Nitpick comments (6)
.changeset/two-mangos-rest.md (1)

1-6: Clarify the experimental API and list the new public methods explicitly.

Please add bullets naming the new APIs and their optional param behavior, e.g., “SignInFuture.ticket(params?)” and “SignUpFuture.ticket(params?)”, and mention the __clerk_ticket fallback. This helps downstream release notes and docs automation.

packages/types/src/signInFuture.ts (2)

13-14: Document and constrain ticket usage in create params.

Add JSDoc explaining precedence vs. identifier/strategy and consider a discriminated union so ticket cannot be combined with other strategies accidentally.

 export interface SignInFutureCreateParams {
   identifier?: string;
   strategy?: OAuthStrategy | 'saml' | 'enterprise_sso';
   redirectUrl?: string;
   actionCompleteRedirectUrl?: string;
   transfer?: boolean;
-  ticket?: string;
+  /**
+   * Ticket token for ticket-based sign-in. When provided, do not pass identifier/strategy.
+   */
+  ticket?: string;
 }

114-116: Add JSDoc for SignInFutureTicketParams.

Briefly describe what a ticket is and expected shape (opaque string from backend), plus an example.

packages/clerk-js/src/core/resources/SignIn.ts (1)

1-1: Import of inBrowser already present — reuse in ticket().

packages/types/src/signUpFuture.ts (2)

14-15: Document ticket and expected interplay with captcha.

Add JSDoc explaining whether ticket-based sign-up should bypass captcha (product decision). If bypass is intended, reflect that in clerk-js.

 export interface SignUpFutureCreateParams extends SignUpFutureAdditionalParams {
   transfer?: boolean;
-  ticket?: string;
+  /**
+   * Ticket token for ticket-based sign-up. When provided, should other fields be optional and should captcha be bypassed?
+   */
+  ticket?: string;
 }

54-57: Add JSDoc for SignUpFutureTicketParams and justify extending AdditionalParams.

If extra fields (firstName/metadata/legalAccepted) are intended to be honored during ticket sign-up, call it out; otherwise remove the extension to avoid confusion.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • 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 13d08c8 and 268276b.

📒 Files selected for processing (5)
  • .changeset/two-mangos-rest.md (1 hunks)
  • packages/clerk-js/src/core/resources/SignIn.ts (2 hunks)
  • packages/clerk-js/src/core/resources/SignUp.ts (3 hunks)
  • packages/types/src/signInFuture.ts (3 hunks)
  • packages/types/src/signUpFuture.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/two-mangos-rest.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/signUpFuture.ts
  • packages/types/src/signInFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/core/resources/SignIn.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/signUpFuture.ts
  • packages/types/src/signInFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/core/resources/SignIn.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/types/src/signUpFuture.ts
  • packages/types/src/signInFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/core/resources/SignIn.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/signUpFuture.ts
  • packages/types/src/signInFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/core/resources/SignIn.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/signUpFuture.ts
  • packages/types/src/signInFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/core/resources/SignIn.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/signUpFuture.ts
  • packages/types/src/signInFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/core/resources/SignIn.ts
🧬 Code graph analysis (2)
packages/clerk-js/src/core/resources/SignUp.ts (3)
packages/types/src/signUpFuture.ts (1)
  • SignUpFutureTicketParams (54-56)
packages/clerk-js/src/core/resources/SignIn.ts (1)
  • ticket (918-921)
packages/clerk-js/src/utils/getClerkQueryParam.ts (1)
  • getClerkQueryParam (37-40)
packages/clerk-js/src/core/resources/SignIn.ts (3)
packages/types/src/signInFuture.ts (1)
  • SignInFutureTicketParams (114-116)
packages/clerk-js/src/core/resources/SignUp.ts (1)
  • ticket (778-781)
packages/clerk-js/src/utils/getClerkQueryParam.ts (1)
  • getClerkQueryParam (37-40)
⏰ 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). (6)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (5)
packages/clerk-js/src/core/resources/SignIn.ts (2)

47-47: Type-only import looks good.


70-75: Importing getClerkQueryParam here is appropriate.

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

28-29: Type import added correctly.


48-53: OK to source ticket from query via getClerkQueryParam.


151-176: Captcha policy for ticket-based sign-up: confirm intent.

SignUp.create runs captcha unconditionally; with a valid ticket this might be unnecessary friction. If ticket-based sign-up should bypass captcha, add a conditional here (or in getCaptchaToken) when params.ticket is present.

Comment on lines +918 to +921
async ticket(params?: SignInFutureTicketParams): Promise<{ error: unknown }> {
const ticket = params?.ticket ?? getClerkQueryParam('__clerk_ticket');
return this.create({ ticket: ticket ?? undefined });
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

🧩 Analysis chain

SSR safety and empty-ticket guard for signIn.ticket().

Calling this on the server with no param will access window. Guard SSR and provide a clear error when a ticket isn’t available.

-  async ticket(params?: SignInFutureTicketParams): Promise<{ error: unknown }> {
-    const ticket = params?.ticket ?? getClerkQueryParam('__clerk_ticket');
-    return this.create({ ticket: ticket ?? undefined });
-  }
+  async ticket(params?: SignInFutureTicketParams): Promise<{ error: unknown }> {
+    const ticketFromUrl = inBrowser() ? getClerkQueryParam('__clerk_ticket') : null;
+    const ticket = params?.ticket ?? ticketFromUrl ?? undefined;
+    if (!ticket && !inBrowser()) {
+      throw new Error('signIn.ticket() requires a `ticket` param when called outside the browser.');
+    }
+    return this.create({ ticket });
+  }

Add unit tests for:

  • param provided
  • URL param provided (browser)
  • SSR call without param throws

🏁 Script executed:

#!/bin/bash
# Show the ticket method and its surrounding context
sed -n '880,950p' packages/clerk-js/src/core/resources/SignIn.ts

# Verify imports for inBrowser and getClerkQueryParam
rg -nP 'import\s+{\s*inBrowser' -g 'packages/clerk-js/src/core/resources/SignIn.ts'
rg -nP 'import\s+{\s*getClerkQueryParam' -g 'packages/clerk-js/src/core/resources/SignIn.ts'

# Locate implementations to confirm SSR behavior of these helpers
rg -n 'export function inBrowser' -g 'packages/clerk-js/src'
rg -n 'export function getClerkQueryParam' -g 'packages/clerk-js/src'

Length of output: 2998


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "==== SignIn.ts top imports (lines 1-120) ===="
sed -n '1,120p' packages/clerk-js/src/core/resources/SignIn.ts || true

echo
echo "==== Search for occurrences of getClerkQueryParam ===="
rg -n --hidden --no-ignore "getClerkQueryParam" || true

echo
echo "==== Files containing getClerkQueryParam (show up to 200 lines) ===="
rg -n --hidden --no-ignore "getClerkQueryParam" | cut -d: -f1 | sort -u | while read -r f; do
  echo "---- $f ----"
  sed -n '1,200p' "$f" || true
done

echo
echo "==== Search for inBrowser implementation/exports ===="
rg -n --hidden --no-ignore "export .*inBrowser|function inBrowser" -S || true

echo
echo "==== Files referencing inBrowser (show up to 200 lines) ===="
rg -n --hidden --no-ignore "inBrowser" | cut -d: -f1 | sort -u | while read -r f; do
  echo "---- $f ----"
  sed -n '1,200p' "$f" || true
done

Length of output: 113138


SSR guard + empty-ticket validation for signIn.ticket() (apply same to signUp.ticket())

getClerkQueryParam reads window.location.href and will throw during SSR — guard with inBrowser() and throw a clear error when no ticket is provided.

-  async ticket(params?: SignInFutureTicketParams): Promise<{ error: unknown }> {
-    const ticket = params?.ticket ?? getClerkQueryParam('__clerk_ticket');
-    return this.create({ ticket: ticket ?? undefined });
-  }
+  async ticket(params?: SignInFutureTicketParams): Promise<{ error: unknown }> {
+    const ticketFromUrl = inBrowser() ? getClerkQueryParam('__clerk_ticket') : null;
+    const ticket = params?.ticket ?? ticketFromUrl ?? undefined;
+    if (!ticket && !inBrowser()) {
+      throw new Error('signIn.ticket() requires a `ticket` param when called outside the browser.');
+    }
+    return this.create({ ticket });
+  }

Actions:

  • Apply above change to packages/clerk-js/src/core/resources/SignIn.ts (ticket method).
  • Apply the same SSR guard + error to packages/clerk-js/src/core/resources/SignUp.ts (ticket method) and add the inBrowser import if missing.
  • Add unit tests (Vitest) for each method:
    • param provided (returns/create called)
    • URL param provided (simulate browser window.search with __clerk_ticket)
    • SSR call without param throws

Comment on lines 778 to 781
async ticket(params?: SignUpFutureTicketParams): Promise<{ error: unknown }> {
const ticket = params?.ticket ?? getClerkQueryParam('__clerk_ticket');
return this.create({ ticket: ticket ?? undefined });
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

SSR safety and pass-through of additional params for signUp.ticket().

  • Accessing window on the server will throw; guard SSR.
  • If SignUpFutureTicketParams extends AdditionalParams, pass those through to create.
-  async ticket(params?: SignUpFutureTicketParams): Promise<{ error: unknown }> {
-    const ticket = params?.ticket ?? getClerkQueryParam('__clerk_ticket');
-    return this.create({ ticket: ticket ?? undefined });
-  }
+  async ticket(params?: SignUpFutureTicketParams): Promise<{ error: unknown }> {
+    const ticketFromUrl = inBrowser() ? getClerkQueryParam('__clerk_ticket') : null;
+    const ticket = params?.ticket ?? ticketFromUrl ?? undefined;
+    if (!ticket && !inBrowser()) {
+      throw new Error('signUp.ticket() requires a `ticket` param when called outside the browser.');
+    }
+    const { ticket: _t, ...rest } = params ?? {};
+    return this.create({ ...rest, ticket });
+  }

Note: import inBrowser at top if not already present:

+import { inBrowser } from '@clerk/shared/browser';
📝 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 ticket(params?: SignUpFutureTicketParams): Promise<{ error: unknown }> {
const ticket = params?.ticket ?? getClerkQueryParam('__clerk_ticket');
return this.create({ ticket: ticket ?? undefined });
}
import { inBrowser } from '@clerk/shared/browser';
async ticket(params?: SignUpFutureTicketParams): Promise<{ error: unknown }> {
const ticketFromUrl = inBrowser() ? getClerkQueryParam('__clerk_ticket') : null;
const ticket = params?.ticket ?? ticketFromUrl ?? undefined;
if (!ticket && !inBrowser()) {
throw new Error('signUp.ticket() requires a `ticket` param when called outside the browser.');
}
const { ticket: _t, ...rest } = params ?? {};
return this.create({ ...rest, ticket });
}
🤖 Prompt for AI Agents
In packages/clerk-js/src/core/resources/SignUp.ts around lines 778 to 781, the
ticket method currently reads the __clerk_ticket query param unguarded (which
will break SSR by accessing window) and drops any extra fields on
SignUpFutureTicketParams; update it to use inBrowser to read getClerkQueryParam
only in the browser (e.g. const ticket = params?.ticket ?? (inBrowser ?
getClerkQueryParam('__clerk_ticket') : undefined)) and call this.create with the
rest of params passed through (e.g. return this.create({ ...(params as
AdditionalParams), ticket: ticket ?? undefined })) so additional params are
preserved; also add an import for inBrowser at the top if it’s not already
imported.

Comment on lines 124 to 127
* Used to perform a ticket-based sign-up.
*/
ticket: (params: SignUpFutureTicketParams) => Promise<{ error: unknown }>;

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Make params optional to match runtime behavior and URL fallback.

Update the interface to params? and note the __clerk_ticket fallback.

-  ticket: (params: SignUpFutureTicketParams) => Promise<{ error: unknown }>;
+  ticket: (params?: SignUpFutureTicketParams) => Promise<{ error: unknown }>;
📝 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
* Used to perform a ticket-based sign-up.
*/
ticket: (params: SignUpFutureTicketParams) => Promise<{ error: unknown }>;
* Used to perform a ticket-based sign-up.
*/
ticket: (params?: SignUpFutureTicketParams) => Promise<{ error: unknown }>;
🤖 Prompt for AI Agents
In packages/types/src/signUpFuture.ts around lines 124 to 127, the ticket
method's params parameter should be optional to reflect runtime behavior and the
URL fallback; change the signature to accept params?: SignUpFutureTicketParams
(or params?: SignUpFutureTicketParams | undefined) and update the JSDoc to
mention the __clerk_ticket URL fallback so callers know the param can be
omitted.

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

🧹 Nitpick comments (2)
packages/react/src/stateProxy.ts (2)

94-95: Ticket method wired with SSR gating — LGTM; consider grouping with top‑level methods for consistency

Matches existing gateMethod usage. Minor nit: place ticket alongside create/sso/password/finalize (like SignUp) to keep the API surface coherent.

       finalize: this.gateMethod(target, 'finalize'),
+      ticket: this.gateMethod(target, 'ticket'),
 
-      emailCode: this.wrapMethods(() => target().emailCode, ['sendCode', 'verifyCode'] as const),
+      emailCode: this.wrapMethods(() => target().emailCode, ['sendCode', 'verifyCode'] as const),
@@
-      ] as const),
-      ticket: this.gateMethod(target, 'ticket'),
+      ] as const),

161-173: Type tweak: avoid nested Promise in gateMethod with Awaited

Small typing improvement; keeps external type F the same but makes the inner async signature precise.

-    return (async (...args: Parameters<F>): Promise<ReturnType<F>> => {
+    return (async (...args: Parameters<F>): Promise<Awaited<ReturnType<F>>> => {
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • 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 268276b and 0a099ed.

📒 Files selected for processing (1)
  • packages/react/src/stateProxy.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{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/react/src/stateProxy.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/react/src/stateProxy.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/react/src/stateProxy.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/react/src/stateProxy.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/react/src/stateProxy.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/react/src/stateProxy.ts
🔇 Additional comments (2)
packages/react/src/stateProxy.ts (2)

119-125: SignUp.ticket exposure is correct

Gated consistently with other methods; no issues.


94-95: Types + JSDoc verified — no action required

SignIn/SignUp future resources include ticket params and ticket() methods with JSDoc (packages/types/src/signInFuture.ts, packages/types/src/signUpFuture.ts); State references SignInFutureResource/SignUpFutureResource in packages/types/src/state.ts.

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/types/src/signInFuture.ts (1)

274-276: Great: runtime/types now align with optional params.

This addresses the earlier mismatch; params? matches clerk-js behavior. Please extend the JSDoc to mention the __clerk_ticket fallback and precedence when both are present.

   /**
-   * Used to perform a ticket-based sign-in.
+   * Used to perform a ticket-based sign-in.
+   *
+   * If `params` is omitted or `params.ticket` is absent, the implementation will read the
+   * `__clerk_ticket` query parameter from `window.location.search` (if available).
+   * When both are present, `params.ticket` takes precedence.
+   *
+   * Example:
+   * ```ts
+   * await signIn.ticket(); // reads from ?__clerk_ticket=...
+   * await signIn.ticket({ ticket: 'tkt_...' }); // explicit ticket
+   * ```
    */
   ticket: (params?: SignInFutureTicketParams) => Promise<{ error: unknown }>;
🧹 Nitpick comments (2)
packages/types/src/signInFuture.ts (2)

13-14: Document the new ticket field and clarify precedence.

Add JSDoc explaining that ticket enables ticket-based sign-in via create({ ticket }), that it falls back to signIn.ticket(), and clarify what happens if ticket is combined with other fields.

Minimal doc addition:

 export interface SignInFutureCreateParams {
   identifier?: string;
   strategy?: OAuthStrategy | 'saml' | 'enterprise_sso';
   redirectUrl?: string;
   actionCompleteRedirectUrl?: string;
   transfer?: boolean;
-  ticket?: string;
+  /**
+   * One-time ticket for ticket-based sign-in. Equivalent to calling `signIn.ticket({ ticket })`.
+   * If provided, other fields are ignored by the runtime.
+   */
+  ticket?: string;
 }

Optional stronger typing to prevent ambiguous combos:

-export interface SignInFutureCreateParams {
-  identifier?: string;
-  strategy?: OAuthStrategy | 'saml' | 'enterprise_sso';
-  redirectUrl?: string;
-  actionCompleteRedirectUrl?: string;
-  transfer?: boolean;
-  ticket?: string;
-}
+export type SignInFutureCreateParams =
+  | { ticket: string }
+  | {
+      identifier?: string;
+      strategy?: OAuthStrategy | 'saml' | 'enterprise_sso';
+      redirectUrl?: string;
+      actionCompleteRedirectUrl?: string;
+      transfer?: boolean;
+    };

114-116: Add JSDoc and consider readonly for params object.

Briefly document the param and mark it readonly to align with immutable input guidance.

-export interface SignInFutureTicketParams {
-  ticket: string;
-}
+/**
+ * Parameters for ticket-based sign-in.
+ */
+export interface SignInFutureTicketParams {
+  /** One-time ticket value used to authenticate the sign-in. */
+  readonly ticket: string;
+}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • 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 0a099ed and ab0d83c.

📒 Files selected for processing (3)
  • packages/clerk-js/src/core/resources/SignUp.ts (3 hunks)
  • packages/types/src/signInFuture.ts (3 hunks)
  • packages/types/src/signUpFuture.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/types/src/signUpFuture.ts
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{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/signInFuture.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/signInFuture.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/types/src/signInFuture.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/signInFuture.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/signInFuture.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/signInFuture.ts
⏰ 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). (6)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (2)
packages/types/src/signInFuture.ts (2)

278-283: LGTM on finalize docs/signature.

No issues; consistent with existing API surface.


274-276: Verified — ticket(params?) and { ticket } are consistent across surfaces. SignInFuture/SignUpFuture types declare ticket as optional; clerk-js SignIn.ts (async ticket) and SignUp.ts (async ticket) use params?.ticket ?? getClerkQueryParam('__clerk_ticket') and pass ticket into create(); react stateProxy exposes ticket via gateMethod.

@dstaley dstaley merged commit a88ee58 into main Sep 19, 2025
40 checks passed
@dstaley dstaley deleted the ds.feat/signals-tickets branch September 19, 2025 14:08
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.

4 participants