Skip to content

Commit

Permalink
Update for 2.0 release (#5)
Browse files Browse the repository at this point in the history
* Update with changes for 2.0 release

* Updated repo based on SDK changes

* Updated service worker
  • Loading branch information
royanger authored Oct 18, 2024
1 parent 1a223b8 commit 1624b27
Show file tree
Hide file tree
Showing 5 changed files with 1,155 additions and 2,929 deletions.
1 change: 1 addition & 0 deletions apps/chrome-extension/.env.development.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
PLASMO_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_FRONTEND_API=
PLASMO_PUBLIC_SYNC_HOST=
8 changes: 5 additions & 3 deletions apps/chrome-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"start:firefox": "web-ext run --source-dir ./build/firefox-mv2-dev"
},
"dependencies": {
"@clerk/chrome-extension": "2.0.0-snapshot.v4fb8995",
"@clerk/chrome-extension": "2.0.0-snapshot.vfdb35cb",
"@clerk/shared": "^2.4.0",
"plasmo": "0.88.0",
"react": "18.2.0",
Expand All @@ -39,11 +39,13 @@
"manifest": {
"permissions": [
"cookies",
"storage"
"storage",
"sidePanel"
],
"host_permissions": [
"$CLERK_FRONTEND_API/*",
"$PLASMO_PUBLIC_CLERK_SYNC_HOST/*"
"$PLASMO_PUBLIC_SYNC_HOST/*",
"http://localhost/*"
],
"key": "$CRX_PUBLIC_KEY"
}
Expand Down
8 changes: 5 additions & 3 deletions apps/chrome-extension/src/background/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { __unstable__createClerkClient as createClerkClient } from '@clerk/chrome-extension/background';
import { createClerkClient } from '@clerk/chrome-extension/background';

console.log('Background Script w/ Clerk createClerkClient() demo loaded')

Expand All @@ -19,8 +19,10 @@ async function getToken() {
// 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) => {
console.log('Handling request for the user\s current token')
getToken().then((token) => sendResponse({ token }));
if (request.greeting === "get-token") {
console.log('Handling request for the user\'s current token')
getToken().then((token) => sendResponse({ token })).catch((error) => console.error(JSON.stringify(error)));
}
return true;
});

Expand Down
9 changes: 5 additions & 4 deletions apps/chrome-extension/src/popup/layouts/root-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {
} from "@clerk/chrome-extension";

const PUBLISHABLE_KEY = process.env.PLASMO_PUBLIC_CLERK_PUBLISHABLE_KEY
console.log('pub key', PUBLISHABLE_KEY)
if (!PUBLISHABLE_KEY) {
throw new Error('Please add the PLASMO_PUBLIC_CLERK_PUBLISHABLE_KEY to the .env.development file')
const SYNC_HOST = process.env.PLASMO_PUBLIC_SYNC_HOST

if (!PUBLISHABLE_KEY || !SYNC_HOST) {
throw new Error('Please add the PLASMO_PUBLIC_CLERK_PUBLISHABLE_KEY and PLASMO_PUBLIC_SYNC_HOST to the .env.development file')
}

export const RootLayout = () => {
Expand All @@ -23,7 +24,7 @@ export const RootLayout = () => {
routerReplace={(to) => navigate(to, { replace: true })}
publishableKey={PUBLISHABLE_KEY}
afterSignOutUrl="/"
syncHost="http://localhost:5173"
syncHost={SYNC_HOST}
>
<div className="plasmo-w-[785px] plasmo-h-[600px] plasmo-flex plasmo-flex-col">
<main className="plasmo-grow plasmo-border-2 plasmo-border-red-500">
Expand Down
Loading

0 comments on commit 1624b27

Please sign in to comment.