feat(chrome-extension): Handle manifest permissions in a more-deterministic fashion
Description
Breaking Change: Service Workers / Session Handling
The extension now requires the storage permission in order to maintain sessions and provide authenticated access to other extension features, such as service workers.
How to Update:
- Please add
storageto thepermissionskey in your extension manifest.
Breaking Change: Host Session Syncing
The extension no longer infers the sync host as the original implementation led to increased configuration confusion and false positives.
As such, we've replaced syncSessionWithTab with syncHost. You can set syncHost to the host URL you intend to retrieve the authentication state from.
How to Update:
- Please replace
syncSessionWithTabwithsyncHost="<YOUR_CLERK_FRONTEND_API_DOMAIN>" - Please ensure that the sync host, along with your app host, is listed in
host_permissionsand appended with/*. e.g.:https://<YOUR_DOMAIN>/*andhttps://clerk.<YOUR_DOMAIN>/*
Fixes ECO-212
Feature: Service Workers createClerkClient
We've introduced a new method createClerkClient to handle background tasks in your extension!
import { createClerkClient } from '@clerk/chrome-extension/background';
// Create a new Clerk instance and get a fresh token for the user
async function getToken() {
const clerk = await createClerkClient({
publishableKey: process.env.PLASMO_PUBLIC_CLERK_PUBLISHABLE_KEY,
});
return await clerk.session?.getToken();
}
// Create a listener to listen for messages from content scripts
// NOTE: A runtime listener cannot be async.
// It must return true, in order to keep the connection open and send a response later.
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
// You can use the token in the listener to perform actions on behalf of the user
// OR send the token back to the content script
getToken().then(token => sendResponse({ token }));
return true;
});
Fixes ECO-213
Checklist
- [x]
npm testruns as expected. - [x]
npm run buildruns as expected. - [ ] (If applicable) JSDoc comments have been added or updated for any package exports
- [ ] (If applicable) Documentation has been updated
Type of change
- [x] 🐛 Bug fix
- [x] 🌟 New feature
- [x] 🔨 Breaking change
- [x] 📖 Refactoring / dependency upgrade / documentation
- [ ] other:
🦋 Changeset detected
Latest commit: 9f1f1b991878b8ae4a165fd660850d45bead8a99
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 9 packages
| Name | Type |
|---|---|
| @clerk/clerk-js | Patch |
| @clerk/clerk-react | Patch |
| @clerk/chrome-extension | Major |
| @clerk/clerk-expo | Patch |
| @clerk/elements | Patch |
| @clerk/nextjs | Patch |
| @clerk/remix | Patch |
| @clerk/tanstack-start | Patch |
| @clerk/ui | 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
!allow-major
!snapshot
Hey @tmilewski - the snapshot version command generated the following package versions:
| Package | Version |
|---|---|
| @clerk/astro | 1.4.2-snapshot.v5846131 |
| @clerk/backend | 1.15.2-snapshot.v5846131 |
| @clerk/chrome-extension | 2.0.0-snapshot.v5846131 |
| @clerk/clerk-js | 5.30.0-snapshot.v5846131 |
| @clerk/elements | 0.17.2-snapshot.v5846131 |
| @clerk/clerk-expo | 2.2.30-snapshot.v5846131 |
| @clerk/express | 1.3.4-snapshot.v5846131 |
| @clerk/fastify | 2.0.6-snapshot.v5846131 |
| @clerk/localizations | 3.4.1-snapshot.v5846131 |
| @clerk/nextjs | 6.0.3-snapshot.v5846131 |
| @clerk/clerk-react | 5.13.2-snapshot.v5846131 |
| @clerk/remix | 4.2.42-snapshot.v5846131 |
| @clerk/clerk-sdk-node | 5.0.55-snapshot.v5846131 |
| @clerk/shared | 2.10.2-snapshot.v5846131 |
| @clerk/tanstack-start | 0.4.18-snapshot.v5846131 |
| @clerk/testing | 1.3.16-snapshot.v5846131 |
| @clerk/themes | 2.1.40-snapshot.v5846131 |
| @clerk/types | 4.29.0-snapshot.v5846131 |
| @clerk/ui | 0.1.11-snapshot.v5846131 |
| @clerk/upgrade | 1.2.0-snapshot.v5846131 |
Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/astro
npm i @clerk/[email protected] --save-exact
@clerk/backend
npm i @clerk/[email protected] --save-exact
@clerk/chrome-extension
npm i @clerk/[email protected] --save-exact
@clerk/clerk-js
npm i @clerk/[email protected] --save-exact
@clerk/elements
npm i @clerk/[email protected] --save-exact
@clerk/clerk-expo
npm i @clerk/[email protected] --save-exact
@clerk/express
npm i @clerk/[email protected] --save-exact
@clerk/fastify
npm i @clerk/[email protected] --save-exact
@clerk/localizations
npm i @clerk/[email protected] --save-exact
@clerk/nextjs
npm i @clerk/[email protected] --save-exact
@clerk/clerk-react
npm i @clerk/[email protected] --save-exact
@clerk/remix
npm i @clerk/[email protected] --save-exact
@clerk/clerk-sdk-node
npm i @clerk/[email protected] --save-exact
@clerk/shared
npm i @clerk/[email protected] --save-exact
@clerk/tanstack-start
npm i @clerk/[email protected] --save-exact
@clerk/testing
npm i @clerk/[email protected] --save-exact
@clerk/themes
npm i @clerk/[email protected] --save-exact
@clerk/types
npm i @clerk/[email protected] --save-exact
@clerk/ui
npm i @clerk/[email protected] --save-exact
@clerk/upgrade
npm i @clerk/[email protected] --save-exact
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| clerk-js-sandbox | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Nov 22, 2024 2:56pm |