Skip to content

Conversation

@tmilewski
Copy link
Member

@tmilewski tmilewski commented Sep 10, 2024

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 storage to the permissions key 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 syncSessionWithTab with syncHost="<YOUR_CLERK_FRONTEND_API_DOMAIN>"
  • Please ensure that the sync host, along with your app host, is listed in host_permissions and appended with /*. e.g.: https://<YOUR_DOMAIN>/* and https://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

  • npm test runs as expected.
  • npm run 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:

@tmilewski tmilewski self-assigned this Sep 10, 2024
@changeset-bot
Copy link

changeset-bot bot commented Sep 10, 2024

🦋 Changeset detected

Latest commit: 9f1f1b9

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

@tmilewski tmilewski requested a review from royanger September 17, 2024 14:10
@tmilewski tmilewski force-pushed the tm/ext-updates branch 4 times, most recently from 0a26a9c to 36fa5a4 Compare October 3, 2024 16:53
@tmilewski tmilewski force-pushed the tm/ext-updates branch 3 times, most recently from 555e2e5 to 5290072 Compare October 9, 2024 20:40
@clerk clerk deleted a comment from clerk-cookie Oct 9, 2024
@tmilewski
Copy link
Member Author

!allow-major

expect(mockedFn.mock.calls.flat()).toEqual(urls.map(url => ({ url, name })));
}

describe('getClientCookie', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Reduced complexity of the getClientCookie thus these tests are no longer necessary.

import { validateManifest } from '../manifest';

describe('Manifest', () => {
describe('validateManifest(manifest)', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Reduced complexity of the validateManifest thus these tests are no longer necessary.

Please see the latest extension [authentication support matrix](https://clerk.com/docs/references/chrome-extension/overview?utm_source=github&utm_medium=clerk_chrome_extension) in the Clerk documentation for more information.

#### Extension Manifest (`manifest.json`)
### Usage
Copy link
Member Author

Choose a reason for hiding this comment

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

Split docs out into separate files as we've found that important details tended to be missed/buried otherwise.

@tmilewski tmilewski marked this pull request as ready for review October 10, 2024 15:18
@clerk clerk deleted a comment from clerk-cookie Oct 10, 2024
@clerk clerk deleted a comment from clerk-cookie Oct 10, 2024
Copy link
Member

@royanger royanger left a comment

Choose a reason for hiding this comment

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

I've been working with this for the last week testing and building apps for documentation and so far there have been no issues. Excited to see this release! 🚀

@clerk clerk deleted a comment from clerk-cookie Oct 28, 2024
@clerk clerk deleted a comment from clerk-cookie Oct 28, 2024
@clerk clerk deleted a comment from clerk-cookie Oct 28, 2024
@clerk clerk deleted a comment from clerk-cookie Oct 28, 2024
@tmilewski tmilewski removed the blocked label Nov 22, 2024
@tmilewski tmilewski merged commit 4da28fa into main Nov 22, 2024
27 checks passed
@tmilewski tmilewski deleted the tm/ext-updates branch November 22, 2024 16:40
wobsoriano pushed a commit that referenced this pull request Feb 8, 2025
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.

3 participants