From 1957b3eeb9fbde6fe6ac8fa56c396d32a82348ac 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 00000000000..d5c5fa30451 --- /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 dcce830c915..af690b09cf0 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 6150432f389..b8b91bd1f7c 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 || '', }; };