Skip to content

feat(backend): add resetDeviceTrust to revokeSession and updateUser - #10942

Merged
tmilewski merged 5 commits into
mainfrom
tom/core-4468-reset-client-trust
Nov 24, 2026
Merged

tmilewski merged 5 commits into
mainfrom
tom/core-4468-reset-client-trust

Conversation

@tmilewski

@tmilewski tmilewski commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Description

When a Backend API request sets reset_device_trust to true, Clerk forgets the affected devices for Device Trust by deleting their records. The user's next sign-in on a forgotten device counts as a new device. That sign-in can require a Device Trust challenge, and Clerk can email the user about the new device. Until now, @clerk/backend had no way to send the parameter.

This PR adds a resetDeviceTrust option to two methods.

  • sessions.revokeSession() forgets the device the session was signed in on. For a session that a native app received through hosted auth, it also forgets the browser the user signed in on. A call without params sends no request body, as before.
  • users.updateUser() forgets all of the user's devices. The server rejects the option with a 422 unless the same call sets a new password or passwordDigest and sets signOutOfOtherSessions to true. The type documents that rule but doesn't enforce it, in the same way that it doesn't enforce the password rule for signOutOfOtherSessions.

It also updates the setPasswordCompromised() JSDoc. When the server marks a password compromised, it now also marks all of the user's devices as untrusted, unless the password was already compromised and revokeAllSessions is false.

Companion PRs

  • Backend API renames the parameter to reset_device_trust and keeps reset_client_trust as a deprecated alias. Production ignores a parameter it does not know, so merge this PR after that one is in production.
  • Go SDK adds the same option as ResetDeviceTrust on session.RevokeParams and user.UpdateParams.

Part of CORE-4468.

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:

✎

POST /v1/sessions/{id}/revoke accepts reset_client_trust. When true,
Clerk forgets the device the session was signed in on, so the user's
next sign-in there counts as a new device.

revokeSession now takes optional params and sends them as the body.
Calls without params still send no body.
PATCH /v1/users/{id} accepts reset_client_trust, which makes Clerk
forget every device of the user. The server rejects it unless the
request also sets a new password and signs out of other sessions, and
the type documents that rather than enforcing it.
The server now also marks all of the user's devices untrusted when the
password was not already compromised or revokeAllSessions is true. On
instances with Device Trust enabled, the next password sign-in on those
devices can require a challenge.
@vercel

vercel Bot commented Nov 20, 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 Nov 24, 2026 2:02am UTC
mosaic-docs Ready Ready Preview Nov 24, 2026 2:02am UTC
swingset Ready Ready Preview Nov 24, 2026 2:02am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The backend API adds an optional resetDeviceTrust parameter to sessions.revokeSession() and adds the option to users.updateUser(). Tests verify request serialization for both methods and the empty default body for session revocation. The changeset documents the option and its stated requirements for user updates. API documentation also describes device handling and possible Device Trust challenges.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: alexisintech, dmoerner

Merge Risk: Minimal · up to d1095

This adds an optional device-trust reset option to session revocation and user updates; existing calls behave as before. The server-side behavior depends on the companion Backend API change, which should be in production before this merges.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the feature (resetDeviceTrust) and both methods it touches (revokeSession and updateUser), which match the changeset. It follows the conventional-commit style and is concise. It omits …
Description check Passed The description explains the new resetDeviceTrust option on sessions.revokeSession() and users.updateUser(), the 422 rule for updateUser, the setPasswordCompromised() JSDoc update, and the companion P…
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: Title check

Explanation

The title names the feature (resetDeviceTrust) and both methods it touches (revokeSession and updateUser), which match the changeset. It follows the conventional-commit style and is concise. It omits the companion-PR context, which is expected.

Full details: Description check

Explanation

The description explains the new resetDeviceTrust option on sessions.revokeSession() and users.updateUser(), the 422 rule for updateUser, the setPasswordCompromised() JSDoc update, and the companion PRs. This matches the changes in the diff.

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

Warning

Linked repositories: This review skipped 6 repositories. Cross-repository analysis may be incomplete. Check linked repository access and settings.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f372de0 and d1095b1.

Files selected for processing: 1

  • packages/backend/src/api/endpoints/UserApi.ts
Linked repositories identified

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

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

@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d1095b1

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

This PR includes changesets to release 11 packages
Name Type
@clerk/backend Minor
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/swingset 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

@pkg-pr-new

pkg-pr-new Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-biometrics

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

@clerk/expo-google-signin

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

@clerk/expo-native-components

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/mosaic

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: d1095b1

@tmilewski
tmilewski marked this pull request as ready for review November 20, 2026 20:47
@blacksmith-sh

blacksmith-sh Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Matches revokeSession sends reset_device_trust

Head sends {"reset_device_trust":true} on POST /v1/sessions/sess_123/revoke; base dropped the option and sent an empty body.

Merge-base

Option dropped

This PR d1095b15

reset_device_trust sent

Also checked · 3 match

Matches revokeSession without params sends no body
Matches updateUser sends reset_device_trust
Matches Types accept resetDeviceTrust

Proof on d1095b15 (from f372de0a) · mocked: Clerk Backend API (A loopback stub records the requests the built SDK sends; the claims are about w...) · Did Proof get it right? Yes · No

View full Proof report · React 👎 or comment @codesmith dismiss this proof to dismiss

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-11-24T02:04:16.442Z

Summary

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

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on d1095b1.

The Backend API parameter is now reset_device_trust, the name the product and docs use for Device Trust.
@tmilewski tmilewski changed the title feat(backend): add resetClientTrust to revokeSession and updateUser feat(backend): add resetDeviceTrust to revokeSession and updateUser Nov 23, 2026
@tmilewski
tmilewski merged commit 8092abb into main Nov 24, 2026
61 checks passed
@tmilewski
tmilewski deleted the tom/core-4468-reset-client-trust branch November 24, 2026 02:16

This branch was successfully deployed

2 active deployments
Preview – swingset — d1095b15 Deployed Nov 24, 2026 by vercel[bot]
Preview – clerk-js-sandbox — d1095b15 Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants