Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(clerk-sdk-node): Fix forgotten Clerk instead of createClerkClient #2368

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/weak-bears-cover.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 4 additions & 3 deletions packages/sdk-node/src/clerkClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function createClerkClient(options: ClerkOptions): ClerkClient {
let clerkClientSingleton = {} as unknown as ReturnType<typeof createClerkClient>;

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'.
Expand All @@ -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;
Expand Down
Loading