diff --git a/.changeset/weak-bears-cover.md b/.changeset/weak-bears-cover.md new file mode 100644 index 0000000000..02dda535e6 --- /dev/null +++ b/.changeset/weak-bears-cover.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-sdk-node': minor +--- + +Fix error thrown for undefined `Clerk` in case of using default clerkClient from `@clerk/clerk-sdk-node` without secretKey caused by replaced import. \ No newline at end of file diff --git a/packages/sdk-node/src/clerkClient.ts b/packages/sdk-node/src/clerkClient.ts index f29ef9478a..f1e451dcd1 100644 --- a/packages/sdk-node/src/clerkClient.ts +++ b/packages/sdk-node/src/clerkClient.ts @@ -31,7 +31,7 @@ export function createClerkClient(options: ClerkOptions): ClerkClient { let clerkClientSingleton = {} as unknown as ReturnType; export const clerkClient = new Proxy(clerkClientSingleton, { - get(_target, property) { + get(_target, property: string) { const hasBeenInitialised = !!clerkClientSingleton.authenticateRequest; if (hasBeenInitialised) { // @ts-expect-error - Element implicitly has an 'any' type because expression of type 'string | symbol' can't be used to index type 'ExtendedClerk'. @@ -40,13 +40,14 @@ export const clerkClient = new Proxy(clerkClientSingleton, { const env = { ...loadApiEnv(), ...loadClientEnv() }; if (env.secretKey) { - clerkClientSingleton = createClerkClient({ ...env, userAgent: '@clerk/clerk-sdk-node' }); + clerkClientSingleton = createClerkClient({ ...env, userAgent: PACKAGE_NAME }); // @ts-expect-error - Element implicitly has an 'any' type because expression of type 'string | symbol' can't be used to index type 'ExtendedClerk'. return clerkClientSingleton[property]; } + const c = createClerkClient({ ...env, userAgent: PACKAGE_NAME }); // @ts-expect-error - Element implicitly has an 'any' type because expression of type 'string | symbol' can't be used to index type 'ExtendedClerk'. - return Clerk({ ...env, userAgent: '@clerk/clerk-sdk-node' })[property]; + return c[property]; }, set() { return false;