Skip to content

fix(js): account for clock skew in Device Intelligence tokens - #10392

Draft
mwickett wants to merge 5 commits into
mainfrom
mwickett/protect-token-clock-skew
Draft

mwickett wants to merge 5 commits into
mainfrom
mwickett/protect-token-clock-skew

Conversation

@mwickett

@mwickett mwickett commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Description

ClerkJS checks Device Intelligence token expiry against the device's clock, which can discard a fresh token when that clock is ahead or behind the server. Translating the expiry once can also keep an expired token alive locally if that clock is later corrected backward.

Use the loader's server timestamp to establish the remaining lifetime, including time spent loading and awaiting the result. Bound translated tokens by both a monotonic deadline and the translated wall-clock expiry, so a clock correction cannot extend their lifetime. Repeated reads and delayed results keep the original timing reference and expiry margins.

Open pages can share live storage updates by translating the deadline between their time origins without renewing its lifetime. A new page refreshes a persisted result whose timing reference it cannot verify. Each page retains its own usable copy if another page replaces the shared entry. This can require a new check after navigation instead of reusing a persisted translated token. Loaders and entries without timing metadata retain legacy validation, and the existing storage fields remain readable by older runtimes.

Snapshot the highest observed invalidation floor before acquisition. A fresh result from an older page can use that floor, while a result acquired before a later floor change cannot overwrite it. Allow acquisition to retry when the browser clock moves backward past the previous attempt's start time. The token contents and server verification are unchanged.

The additional timing and cache checks add about 0.8 KB compressed per affected entry point compared with the base. Bundle budgets increase as follows: clerk.js 556 to 557 KB, clerk.browser.js 83 to 84 KB, clerk.legacy.browser.js 126 to 127 KB, clerk.no-rhc.js 322.75 to 323.5 KB, and clerk.native.js 82.5 to 83 KB.

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:

@vercel

vercel Bot commented Oct 23, 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 23, 2026 8:41pm UTC
swingset Ready Ready Preview Oct 23, 2026 8:41pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9985a74

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

This PR includes changesets to release 4 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/electron Patch
@clerk/expo 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

@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-biometrics

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

@clerk/expo-google-signin

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

@clerk/expo-native-components

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/mosaic

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 9985a74

This branch was successfully deployed

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

1 participant