Skip to content

fix(clerk-js): preserve trusted clients after satellite sign-out - #10470

Open
tmilewski wants to merge 6 commits into
mainfrom
tom/satellite-device-trust-investigation
Open

tmilewski wants to merge 6 commits into
mainfrom
tom/satellite-device-trust-investigation

Conversation

@tmilewski

@tmilewski tmilewski commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Description

Signing out on a satellite leaves the primary domain holding a stale client cookie. The next primary password sign-in creates a new client and repeats the Device Trust challenge, even though the browser was already trusted.

Uses the optional repair URL from the companion backend change to refresh the primary cookie before continuing sign-out navigation. Repair applies to production browser satellites with client persistence enabled; the backend only offers it when Device Trust is enabled. Disabled persistence and malformed or unsupported destinations use the original removal path, so URL parsing cannot prevent session removal. Navigation errors still propagate.

Preserves the public signOut overloads and zero-argument callback contract. Built-in UI actions retain their original navigation closures and opt in with an internal return URL resolved through the active router. Only a usable backend repair URL replaces that navigation; missing or invalid responses invoke the original callback. Component-internal, hash/virtual, arbitrary customer callback, targeted multisession, primary, development, and native flows retain their existing paths. The transport method remains concrete-only rather than becoming a required ClientResource member.

Part of CORE-4146

Checklist

  • pnpm test runs as expected. Targeted ClerkJS, UI, and router suites passed; the full monorepo suite was not run.
  • pnpm build runs as expected. Browser bundles and relevant typechecks passed; the full monorepo build was not run.
  • (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:

@changeset-bot

changeset-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fcbf773

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

This PR includes changesets to release 23 packages
Name Type
@clerk/clerk-js Patch
@clerk/shared Patch
@clerk/ui Patch
@clerk/chrome-extension Patch
@clerk/electron Patch
@clerk/expo Patch
@clerk/mosaic Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/localizations Patch
@clerk/msw Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/react Patch
@clerk/swingset Patch
@clerk/tanstack-react-start Patch
@clerk/testing 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

@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Oct 30, 2026 10:07pm UTC
swingset Ready Ready Preview Oct 30, 2026 10:07pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1702463 and fcbf773.

Files selected for processing: 5
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/core/resources/Client.ts
  • packages/clerk-js/src/core/resources/__tests__/Client.test.ts
  • packages/shared/src/types/clerk.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 8 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

Walkthrough

The change adds a client sign-out request that can return a sign-out URL while retaining client data from its response. Clerk uses this request for eligible production satellite sign-outs with valid HTTPS redirects. A new UI hook passes eligible redirect destinations to Clerk, and sign-out components use the hook for last-account and all-account flows. Tests cover client responses, repair eligibility, fallback paths, and UI navigation.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: nikosdouvlis, wobsoriano

Merge Risk: Minimal · up to fcbf7

The reviewed sign-out paths preserve the intended navigation behavior, with no identified issue requiring a fix before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: preserving trusted clients after satellite sign-out.
Description check Passed The description directly explains the stale primary-domain cookie, the repair URL flow, scope limits, fallback behavior, and validation performed. It is related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 21 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: Some configured repositories could not be included in this review. Cross-repository analysis may be incomplete. Please check linked-repository access and settings.

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

@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@10470

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@10470

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@10470

@clerk/expo

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

@clerk/expo-biometrics

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

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@10470

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@10470

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@10470

@clerk/localizations

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

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@10470

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@10470

@clerk/upgrade

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

@clerk/vue

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

commit: fcbf773

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-10-30T22:08:21.131Z

Summary

Metric Count
Packages analyzed 20
Packages with changes 1
🔴 Breaking changes 0
🟡 Non-breaking changes 1
🟢 Additions 0

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/shared

Current version: 4.43.1
Recommended bump: MINOR → 4.44.0

Subpath ./types

🟡 Non-breaking Changes (1)

Modified: SignOutOptions
  type SignOutOptions = {
+   __internal_satelliteSignOutRedirectUrl?: string;
    sessionId?: string;
    redirectUrl?: string;
  };

Static analyzer: Breaking change in type alias SignOutOptions: Type changed: {sessionId?:string;redirectUrl?:string;} → {__internal_satelliteSignOutRedirectUrl?:string;sessionId?:string;redirectUrl?:string;}

🤖 AI review (reclassified as non-breaking) (95%): A new optional property __internal_satelliteSignOutRedirectUrl? was added to SignOutOptions, which is used only as an optional input parameter to SignOut; existing callers that omit this property remain valid, so no well-typed consumer code breaks.


Report generated by Break Check

Last ran on fcbf773.

* Configuration options.
*/
export type SignOutOptions = {
__internal_satelliteSignOutRedirectUrl?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This field is on the public SignOutOptions type but has no /** @internal */ tag, unlike the other __internal_ fields in this file. Our typedoc config uses excludeInternal: true, which hides members by that tag, so this one will appear in the generated signOut() reference docs and in customers' autocomplete. Customers could then pass it to opt arbitrary callbacks into repair, which contradicts the rule that custom callbacks don't opt in. The backend redirect allowlist still limits where users can be sent, so this is about the API contract, not security.

Suggested change
__internal_satelliteSignOutRedirectUrl?: string;
/** @internal */
__internal_satelliteSignOutRedirectUrl?: string;

~ 🤖

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added /** @internal */ to the optional metadata field, matching the existing annotations and excludeInternal configuration. Public signOut overloads and callback signatures remain unchanged. This hides the field from generated reference docs; it is metadata, not a runtime access restriction.

~ 🤖

Comment on lines +107 to +113
path: persistClient ? this.path() + '/sessions' : '/client',
search: { sign_out_redirect_url: redirectUrl },
});
this.fromJSON((json?.response || json) as ClientJSON | null);
SessionTokenCache.clear();
if (!persistClient) {
this.resetClient();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The only caller, clerk.ts:810, gates repair on persistClient, so this method always gets persistClient: true. The DELETE /client path and the resetClient() branch never run. I left a matching note on the backend's clear action in clerk_go#23504. If persistence-disabled repair is out of scope, both sides can drop it, and this method can lose the persistClient parameter.

~ 🤖

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed the unused persistClient parameter and DELETE /client/reset branch from the concrete repair transport. It now only removes sessions while retaining the client. Persistence-disabled sign-out continues through the existing destroy branch with no repair redirect; updated transport tests retain the client-state assertions.

~ 🤖

Satellite sign-out could fail before removing sessions when its destination was malformed, and deliberately discarded clients took an unnecessary trip through the primary. Use the original removal and navigation paths for unsupported destinations and disabled client persistence, preserving callback and navigation error behavior.

Part of CORE-4146

This branch was successfully deployed

2 active deployments
Preview – swingset — fcbf7737 Deployed Oct 30, 2026 by vercel[bot]
Preview – clerk-js-sandbox — fcbf7737 Deployed Oct 30, 2026 by vercel[bot]
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.

2 participants