From b0d75b50ffde4f4a39cde39b35c98fe479da44a0 Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Tue, 31 Oct 2023 23:22:23 +0200 Subject: [PATCH 1/3] chore(gatsby-plugin-clerk): Drop `CLERK_API_KEY` --- packages/gatsby-plugin-clerk/src/constants.ts | 7 ------- .../gatsby-plugin-clerk/src/ssr/authenticateRequest.ts | 5 ++--- packages/gatsby-plugin-clerk/src/ssr/clerkClient.ts | 6 ++---- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/gatsby-plugin-clerk/src/constants.ts b/packages/gatsby-plugin-clerk/src/constants.ts index 4e8e2abf1f9..c6df26a6086 100644 --- a/packages/gatsby-plugin-clerk/src/constants.ts +++ b/packages/gatsby-plugin-clerk/src/constants.ts @@ -2,13 +2,6 @@ import { deprecated } from '@clerk/shared/deprecated'; export const API_URL = process.env.CLERK_API_URL || 'https://api.clerk.com'; export const API_VERSION = process.env.CLERK_API_VERSION || 'v1'; -/** - * @deprecated Use `CLERK_SECRET_KEY` instead. - */ -export const API_KEY = process.env.CLERK_API_KEY || ''; -if (API_KEY) { - deprecated('CLERK_API_KEY', 'Use `CLERK_SECRET_KEY` environment variable instead.'); -} export const SECRET_KEY = process.env.CLERK_SECRET_KEY || ''; /** * @deprecated Use `PUBLISHABLE_KEY` instead. diff --git a/packages/gatsby-plugin-clerk/src/ssr/authenticateRequest.ts b/packages/gatsby-plugin-clerk/src/ssr/authenticateRequest.ts index dbc6ea783dc..4271e11a6e7 100644 --- a/packages/gatsby-plugin-clerk/src/ssr/authenticateRequest.ts +++ b/packages/gatsby-plugin-clerk/src/ssr/authenticateRequest.ts @@ -1,13 +1,12 @@ import type { GetServerDataProps } from 'gatsby'; -import { API_KEY, FRONTEND_API, PUBLISHABLE_KEY, SECRET_KEY } from '../constants'; +import { FRONTEND_API, PUBLISHABLE_KEY, SECRET_KEY } from '../constants'; import { clerkClient, constants, createIsomorphicRequest } from './clerkClient'; import type { WithServerAuthOptions } from './types'; export function authenticateRequest(context: GetServerDataProps, options: WithServerAuthOptions) { return clerkClient.authenticateRequest({ ...options, - apiKey: API_KEY, secretKey: SECRET_KEY, frontendApi: FRONTEND_API, publishableKey: PUBLISHABLE_KEY, @@ -38,7 +37,7 @@ const returnReferrerAsXForwardedHostToFixLocalDevGatsbyProxy = (headers: Map Date: Tue, 31 Oct 2023 23:24:14 +0200 Subject: [PATCH 2/3] chore(gatsby-plugin-clerk): Drop `GATSBY_CLERK_FRONTEND_API` --- packages/gatsby-plugin-clerk/src/constants.ts | 9 --------- packages/gatsby-plugin-clerk/src/gatsby-browser.tsx | 5 +---- packages/gatsby-plugin-clerk/src/gatsby-ssr.tsx | 5 +---- .../gatsby-plugin-clerk/src/ssr/authenticateRequest.ts | 3 +-- packages/gatsby-plugin-clerk/src/ssr/withServerAuth.ts | 5 +++-- 5 files changed, 6 insertions(+), 21 deletions(-) diff --git a/packages/gatsby-plugin-clerk/src/constants.ts b/packages/gatsby-plugin-clerk/src/constants.ts index c6df26a6086..c736e8e0fcf 100644 --- a/packages/gatsby-plugin-clerk/src/constants.ts +++ b/packages/gatsby-plugin-clerk/src/constants.ts @@ -1,15 +1,6 @@ -import { deprecated } from '@clerk/shared/deprecated'; - export const API_URL = process.env.CLERK_API_URL || 'https://api.clerk.com'; export const API_VERSION = process.env.CLERK_API_VERSION || 'v1'; export const SECRET_KEY = process.env.CLERK_SECRET_KEY || ''; -/** - * @deprecated Use `PUBLISHABLE_KEY` instead. - */ -export const FRONTEND_API = process.env.GATSBY_CLERK_FRONTEND_API || ''; -if (FRONTEND_API) { - deprecated('FRONTEND_API', 'Use `PUBLISHABLE_KEY` environment variable instead.'); -} export const PUBLISHABLE_KEY = process.env.GATSBY_CLERK_PUBLISHABLE_KEY || ''; export const CLERK_JS = process.env.GATSBY_CLERK_JS; diff --git a/packages/gatsby-plugin-clerk/src/gatsby-browser.tsx b/packages/gatsby-plugin-clerk/src/gatsby-browser.tsx index 470fd88d2ec..0e5cbdafdb6 100644 --- a/packages/gatsby-plugin-clerk/src/gatsby-browser.tsx +++ b/packages/gatsby-plugin-clerk/src/gatsby-browser.tsx @@ -1,8 +1,7 @@ -/* eslint-disable turbo/no-undeclared-env-vars */ import type { GatsbyBrowser } from 'gatsby'; import React from 'react'; -import { CLERK_JS, FRONTEND_API, PROXY_URL, PUBLISHABLE_KEY } from './constants'; +import { CLERK_JS, PROXY_URL, PUBLISHABLE_KEY } from './constants'; import { ClerkProvider } from './GatsbyClerkProvider'; export const wrapPageElement: GatsbyBrowser['wrapPageElement'] = ({ element, props }, pluginOptions) => { @@ -13,9 +12,7 @@ export const wrapPageElement: GatsbyBrowser['wrapPageElement'] = ({ element, pro } return ( - // @ts-expect-error { @@ -13,9 +12,7 @@ export const wrapPageElement: GatsbySSR['wrapPageElement'] = ({ element, props } } return ( - // @ts-expect-error { const headers = new Headers(Object.fromEntries(context.headers) as Record); diff --git a/packages/gatsby-plugin-clerk/src/ssr/withServerAuth.ts b/packages/gatsby-plugin-clerk/src/ssr/withServerAuth.ts index 9e50ee83b0e..062ae24429f 100644 --- a/packages/gatsby-plugin-clerk/src/ssr/withServerAuth.ts +++ b/packages/gatsby-plugin-clerk/src/ssr/withServerAuth.ts @@ -1,6 +1,6 @@ import type { GetServerDataProps, GetServerDataReturn } from 'gatsby'; -import { FRONTEND_API, PUBLISHABLE_KEY } from '../constants'; +import { PUBLISHABLE_KEY } from '../constants'; import { authenticateRequest } from './authenticateRequest'; import { clerkClient, constants } from './clerkClient'; import type { WithServerAuthCallback, WithServerAuthOptions, WithServerAuthResult } from './types'; @@ -25,8 +25,9 @@ export const withServerAuth: WithServerAuth = (cbOrOptions: any, options?: any): [constants.Headers.AuthMessage]: requestState.message, [constants.Headers.AuthStatus]: requestState.status, }; + // TODO(@dimkl): use empty string for frontendApi until type is fixed in @clerk/backend to drop it const interstitialHtml = clerkClient.localInterstitial({ - frontendApi: FRONTEND_API, + frontendApi: '', publishableKey: PUBLISHABLE_KEY, }); return injectSSRStateIntoProps({ headers }, { __clerk_ssr_interstitial_html: interstitialHtml }); From 04ff65cd129226b67df002327ebcf034b033c223 Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Tue, 31 Oct 2023 23:27:41 +0200 Subject: [PATCH 3/3] chore(gatsby-plugin-clerk): Add changeset --- .changeset/long-icons-share.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .changeset/long-icons-share.md diff --git a/.changeset/long-icons-share.md b/.changeset/long-icons-share.md new file mode 100644 index 00000000000..24adca8d9ec --- /dev/null +++ b/.changeset/long-icons-share.md @@ -0,0 +1,9 @@ +--- +'gatsby-plugin-clerk': major +--- + +Drop deprecations. Migration steps: +- use `CLERK_SECRET_KEY` instead of `CLERK_API_KEY` env variable +- use `secretKey` instead of `apiKey` +- use `GATSBY_CLERK_PUBLISHABLE_KEY` instead of `GATSBY_CLERK_FRONTEND_API` env variable +- use `publishableKey` instead of `frontendApi` \ No newline at end of file