Skip to content

fix(chrome-extension): avoid remote loaders and initialize production auth - #10565

Merged
mwickett merged 10 commits into
mainfrom
fix/chrome-extension-protect-loader
Nov 3, 2026
Merged

mwickett merged 10 commits into
mainfrom
fix/chrome-extension-protect-loader

Conversation

@mwickett

@mwickett mwickett commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Description

@clerk/chrome-extension uses ClerkJS's no-RHC build, but that build could still insert Device Intelligence scripts supplied by the environment configuration. Chrome extensions cannot load remotely hosted code, so the no-RHC build now omits Device Intelligence loader initialization. Regular browser builds keep the configured loading behavior. The no-RHC build check now fails if the loader code reappears in either the ESM or CommonJS output.

Production extension requests now declare native API mode from the first request, before a client token is stored. Previously only requests with a stored token included it, so a fresh production extension could not initialize authentication.

The chrome-extension integration suite gains live sign-in and sign-up flows against development and production instances, run without a Testing Token and with the extension CSP enforced. The test extension has a fixed ID, so its origin is added once to the shared sessions-prod-1 instance and kept there, and test mode is left enabled on that instance so concurrent CI runs cannot undo each other's setup. Development sign-up from an extension is currently rejected, and the test asserts that rejection.

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:

@changeset-bot

changeset-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0af8faf

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

@vercel

vercel Bot commented Oct 31, 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 3, 2026 10:07pm UTC
swingset Ready Ready Preview Nov 3, 2026 10:07pm UTC

Request Review

@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-biometrics

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

@clerk/expo-google-signin

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

@clerk/expo-native-components

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/mosaic

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 0af8faf

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

The changes conditionally initialize Protect in no-RHC builds and expand checks for no-RHC bundles and Chrome extension loading. They move production request marking before JWT lookup, add a sign-up view to the extension template, and add configurable development and production authentication tests.

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

Suggested reviewers: zourzouvillys, wobsoriano

Merge Risk: Minimal · up to 0af8f

The authentication tests now detect both the documented development rejection and future sign-up success, with no concrete merge-blocking risk remaining.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.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. Documenta… 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 names the chrome-extension package and two changes: avoiding remote loaders in the no-RHC build and initializing production authentication. The changeset matches both: the no-RHC build omits…
Description check Passed The description states the bug and the fix. It explains that the no-RHC build could insert Device Intelligence scripts, and that production extension requests now declare native API mode before a clie…
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 chrome-extension package and two changes: avoiding remote loaders in the no-RHC build and initializing production authentication. The changeset matches both: the no-RHC build omits Device Intelligence loader initialization, and production extension requests now declare native API mode from the first request. The title is specific and describes the main change without listing files.

Full details: Description check

Explanation

The description states the bug and the fix. It explains that the no-RHC build could insert Device Intelligence scripts, and that production extension requests now declare native API mode before a client token is stored. It also covers the new CI check and the new integration tests, which match the changed files.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.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 2 functions across 10 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.

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between dae1f31 and 0af8faf.

Files selected for processing: 1
  • integration/tests/chrome-extension/auth-flows.test.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.

@mwickett mwickett changed the title fix(js): omit Device Intelligence loaders from no-RHC builds fix(chrome-extension): avoid remote loaders and initialize production auth Oct 31, 2026
Pin the test extension ID with a manifest key so its allowed origin is stable,
and only ever add fixture settings: the origin is added once and never removed,
and test mode is enabled once and left on. Concurrent CI runs can no longer
undo each other's setup. When test mode is enabled, wait for the Frontend API
environment to report it before running the flows.
@mwickett
mwickett force-pushed the fix/chrome-extension-protect-loader branch from a6ac584 to 03175fe Compare November 2, 2026 22:34
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-11-03T22:09:48.675Z

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 0af8faf.

@royanger
royanger self-requested a review November 3, 2026 21:28

@royanger royanger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I took a look at the review and it looks like it removes the remotely hosted code that was being included.

I also looked into why this slipped through, as there were checks added by Tom to prevent this. It looks like the guard moved from clerk-js to shared for Core 3, but after that move it was not longer working. I created CORE-4281 to restore those checks.

Thanks @mwickett! 🚀

@blacksmith-sh

blacksmith-sh Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Matches No-RHC build skips Device Intelligence loaders

Tested on dae1f31d, untouched since — Before, the no-RHC bundle inserted both configured loader scripts into the extension popup and Chrome's extension CSP blocked them. After, it inserts none, makes no remote script request and triggers no CSP violation, on both production and development keys.

Merge-base

Extension popup

This PR dae1f31d

Extension popup

Merge-base

Harness output

This PR dae1f31d

Harness output

Also checked · 3 match · 1 not run

Blocked Live extension sign-in and sign-up · Blocked
Matches Prod first request declares native mode
Matches Regular builds still load configured loaders
Matches Build check catches loader code

Important

Blocked on missing secrets

  • Live extension sign-in and sign-up: Still no Clerk development or production instance keys (INTEGRATION_INSTANCE_KEYS) in the sandbox, and the extension origin must be allowed on sessions-prod-1, so the live flows cannot run.

Proof on 0af8fafd (from dae1f31d) · Did Proof get it right? Yes · No

View full Proof report

@coderabbitai coderabbitai Bot left a comment •

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.

  • Fix comments: Fix CodeRabbit comments on this PR

@mwickett
mwickett merged commit 256153a into main Nov 3, 2026
59 checks passed
@mwickett
mwickett deleted the fix/chrome-extension-protect-loader branch November 3, 2026 22:18

This branch was successfully deployed

2 active deployments
Preview – swingset — 0af8fafd Deployed Nov 3, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 0af8fafd Deployed Nov 3, 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