From 2b57c39d7acd2d8e8c40d22a278be15f934f1a17 Mon Sep 17 00:00:00 2001 From: Bryce Kalow Date: Tue, 17 Dec 2024 14:18:01 -0600 Subject: [PATCH] fix(clerk-js): Revert #4776 (#4797) --- .changeset/wet-jars-tickle.md | 5 +++++ packages/clerk-js/src/core/auth/cookies/devBrowser.ts | 9 ++------- packages/clerk-js/src/core/auth/devBrowser.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 .changeset/wet-jars-tickle.md diff --git a/.changeset/wet-jars-tickle.md b/.changeset/wet-jars-tickle.md new file mode 100644 index 0000000000..36abc6acf0 --- /dev/null +++ b/.changeset/wet-jars-tickle.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Revert #4776 to address new bug. diff --git a/packages/clerk-js/src/core/auth/cookies/devBrowser.ts b/packages/clerk-js/src/core/auth/cookies/devBrowser.ts index 538143d697..7b292a9e65 100644 --- a/packages/clerk-js/src/core/auth/cookies/devBrowser.ts +++ b/packages/clerk-js/src/core/auth/cookies/devBrowser.ts @@ -8,7 +8,7 @@ import { getSecureAttribute } from '../getSecureAttribute'; export type DevBrowserCookieHandler = { set: (jwt: string) => void; - get: (mode?: 'only-suffixed') => string | undefined; + get: () => string | undefined; remove: () => void; }; @@ -22,12 +22,7 @@ export const createDevBrowserCookie = (cookieSuffix: string): DevBrowserCookieHa const devBrowserCookie = createCookieHandler(DEV_BROWSER_JWT_KEY); const suffixedDevBrowserCookie = createCookieHandler(getSuffixedCookieName(DEV_BROWSER_JWT_KEY, cookieSuffix)); - const get = (mode?: 'only-suffixed') => { - if (mode === 'only-suffixed') { - return suffixedDevBrowserCookie.get(); - } - return suffixedDevBrowserCookie.get() || devBrowserCookie.get(); - }; + const get = () => suffixedDevBrowserCookie.get() || devBrowserCookie.get(); const set = (jwt: string) => { const expires = addYears(Date.now(), 1); diff --git a/packages/clerk-js/src/core/auth/devBrowser.ts b/packages/clerk-js/src/core/auth/devBrowser.ts index ad428372dd..2d5e3cb644 100644 --- a/packages/clerk-js/src/core/auth/devBrowser.ts +++ b/packages/clerk-js/src/core/auth/devBrowser.ts @@ -71,8 +71,8 @@ export function createDevBrowser({ cookieSuffix, frontendApi, fapiClient }: Crea return; } - // 2. If no JWT is found in the first step, check if a JWT is already available in the suffixed __clerk_db_jwt JS cookie - if (devBrowserCookie.get('only-suffixed')) { + // 2. If no JWT is found in the first step, check if a JWT is already available in the __clerk_db_jwt JS cookie + if (devBrowserCookie.get()) { return; }