From 3d93993a9a5a9b42723cabf1f99dc6650892e22f Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Sat, 1 Jul 2023 01:04:58 +0300 Subject: [PATCH] fix(clerk-sdk-node): Add jwtKey in api envs and use it redwood compatibility --- .changeset/lucky-panthers-draw.md | 5 +++++ packages/sdk-node/src/clerkClient.ts | 3 ++- packages/sdk-node/src/utils.ts | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/lucky-panthers-draw.md diff --git a/.changeset/lucky-panthers-draw.md b/.changeset/lucky-panthers-draw.md new file mode 100644 index 0000000000..d5c5fa3045 --- /dev/null +++ b/.changeset/lucky-panthers-draw.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-sdk-node': patch +--- + +Load `jwtKey` from `CLERK_JWT_KEY` env variable diff --git a/packages/sdk-node/src/clerkClient.ts b/packages/sdk-node/src/clerkClient.ts index dcce830c91..af690b09cf 100644 --- a/packages/sdk-node/src/clerkClient.ts +++ b/packages/sdk-node/src/clerkClient.ts @@ -30,10 +30,11 @@ export function Clerk(options: ClerkOptions) { const createBasePropForRedwoodCompatibility = () => { const verifySessionToken = (token: string) => { + const { jwtKey } = loadApiEnv(); const { payload } = decodeJwt(token); return _verifyToken(token, { issuer: payload.iss, - jwtKey: process.env.CLERK_JWT_KEY, + jwtKey, }); }; return { base: { verifySessionToken } }; diff --git a/packages/sdk-node/src/utils.ts b/packages/sdk-node/src/utils.ts index 6150432f38..b8b91bd1f7 100644 --- a/packages/sdk-node/src/utils.ts +++ b/packages/sdk-node/src/utils.ts @@ -32,5 +32,6 @@ export const loadApiEnv = () => { proxyUrl: process.env.CLERK_PROXY_URL || '', signInUrl: process.env.CLERK_SIGN_IN_URL || '', isSatellite: process.env.CLERK_IS_SATELLITE === 'true', + jwtKey: process.env.CLERK_JWT_KEY || '', }; };