clerk / javascript

Official Javascript repository for Clerk authentication
https://clerk.com
MIT License
1.12k stars 246 forks source link

feat(chrome-extension): Handle manifest permissions in a more-deterministic fashion #4133

Open tmilewski opened 1 month ago

tmilewski commented 1 month ago

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:

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:

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

Type of change

changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: 746194fc132f2bb4a247d234874847b2e35fc1e7

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

This PR includes changesets to release 1 package | Name | Type | | ----------------------- | ----- | | @clerk/chrome-extension | Major |

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 commented 4 weeks ago

!snapshot

clerk-cookie commented 4 weeks ago
Hey @tmilewski - the snapshot version command generated the following package versions: Package Version
@clerk/chrome-extension 2.0.0-snapshot.vde23c83

Tip: Use the snippet copy button below to quickly install the required packages. @clerk/chrome-extension

npm i @clerk/chrome-extension@2.0.0-snapshot.vde23c83 --save-exact
tmilewski commented 3 weeks ago

!snapshot

clerk-cookie commented 3 weeks ago
Hey @tmilewski - the snapshot version command generated the following package versions: Package Version
@clerk/chrome-extension 2.0.0-snapshot.v68bae83

Tip: Use the snippet copy button below to quickly install the required packages. @clerk/chrome-extension

npm i @clerk/chrome-extension@2.0.0-snapshot.v68bae83 --save-exact
tmilewski commented 3 weeks ago

!snapshot

clerk-cookie commented 3 weeks ago
Hey @tmilewski - the snapshot version command generated the following package versions: Package Version
@clerk/chrome-extension 2.0.0-snapshot.v731dc50

Tip: Use the snippet copy button below to quickly install the required packages. @clerk/chrome-extension

npm i @clerk/chrome-extension@2.0.0-snapshot.v731dc50 --save-exact
tmilewski commented 3 weeks ago

!snapshot

clerk-cookie commented 3 weeks ago
Hey @tmilewski - the snapshot version command generated the following package versions: Package Version
@clerk/chrome-extension 2.0.0-snapshot.vb1ee34a

Tip: Use the snippet copy button below to quickly install the required packages. @clerk/chrome-extension

npm i @clerk/chrome-extension@2.0.0-snapshot.vb1ee34a --save-exact
tmilewski commented 2 weeks ago

!snapshot

clerk-cookie commented 2 weeks ago
Hey @tmilewski - the snapshot version command generated the following package versions: Package Version
@clerk/chrome-extension 2.0.0-snapshot.vb92ba42

Tip: Use the snippet copy button below to quickly install the required packages. @clerk/chrome-extension

npm i @clerk/chrome-extension@2.0.0-snapshot.vb92ba42 --save-exact
tmilewski commented 2 weeks ago

!snapshot

tmilewski commented 1 week ago

!allow-major

tmilewski commented 1 week ago

!snapshot

clerk-cookie commented 1 week ago
Hey @tmilewski - the snapshot version command generated the following package versions: Package Version
@clerk/chrome-extension 2.0.0-snapshot.v8e3bb7e

Tip: Use the snippet copy button below to quickly install the required packages. @clerk/chrome-extension

npm i @clerk/chrome-extension@2.0.0-snapshot.v8e3bb7e --save-exact
tmilewski commented 1 week ago

!snapshot

clerk-cookie commented 1 week ago
Hey @tmilewski - the snapshot version command generated the following package versions: Package Version
@clerk/chrome-extension 2.0.0-snapshot.v163bb22
@clerk/elements 0.16.0-snapshot.v163bb22

Tip: Use the snippet copy button below to quickly install the required packages. @clerk/chrome-extension

npm i @clerk/chrome-extension@2.0.0-snapshot.v163bb22 --save-exact

@clerk/elements

npm i @clerk/elements@0.16.0-snapshot.v163bb22 --save-exact
tmilewski commented 1 day ago

!snapshot

clerk-cookie commented 1 day ago
Hey @tmilewski - the snapshot version command generated the following package versions: Package Version
@clerk/chrome-extension 2.0.0-snapshot.v6940054

Tip: Use the snippet copy button below to quickly install the required packages. @clerk/chrome-extension

npm i @clerk/chrome-extension@2.0.0-snapshot.v6940054 --save-exact
tmilewski commented 1 day ago

!snapshot

clerk-cookie commented 1 day ago
Hey @tmilewski - the snapshot version command generated the following package versions: Package Version
@clerk/chrome-extension 2.0.0-snapshot.vfdb35cb

Tip: Use the snippet copy button below to quickly install the required packages. @clerk/chrome-extension

npm i @clerk/chrome-extension@2.0.0-snapshot.vfdb35cb --save-exact
tmilewski commented 5 hours ago

!snapshot

clerk-cookie commented 5 hours ago
Hey @tmilewski - the snapshot version command generated the following package versions: Package Version
@clerk/chrome-extension 2.0.0-snapshot.v746194f

Tip: Use the snippet copy button below to quickly install the required packages. @clerk/chrome-extension

npm i @clerk/chrome-extension@2.0.0-snapshot.v746194f --save-exact