From a265b7442a5340ab9e192a75f3c9b4223bbf40c8 Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Thu, 26 Oct 2023 11:05:16 -0700 Subject: [PATCH 1/2] fix(clerk-sdk-node): Fix types of ClerkExpressWithAuth/ClerkExpressRequireAuth args (#1939) https://github.com/clerkinc/javascript/issues/1938 --- .changeset/tasty-countries-walk.md | 5 +++++ packages/sdk-node/src/clerkClient.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/tasty-countries-walk.md diff --git a/.changeset/tasty-countries-walk.md b/.changeset/tasty-countries-walk.md new file mode 100644 index 00000000000..f6ceef5af0a --- /dev/null +++ b/.changeset/tasty-countries-walk.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-sdk-node': patch +--- + +Fix types of ClerkExpressWithAuth/ClerkExpressRequireAuth args diff --git a/packages/sdk-node/src/clerkClient.ts b/packages/sdk-node/src/clerkClient.ts index 6f9cc6a35b8..b562f450791 100644 --- a/packages/sdk-node/src/clerkClient.ts +++ b/packages/sdk-node/src/clerkClient.ts @@ -75,13 +75,13 @@ export const clerkClient = new Proxy(clerkClientSingleton, { /** * Stand-alone express middlewares bound to the pre-initialised clerkClient */ -export const ClerkExpressRequireAuth = (...args: any) => { +export const ClerkExpressRequireAuth = (...args: Parameters>) => { const env = { ...loadApiEnv(), ...loadClientEnv() }; const fn = createClerkExpressRequireAuth({ clerkClient, ...env }); return fn(...args); }; -export const ClerkExpressWithAuth = (...args: any) => { +export const ClerkExpressWithAuth = (...args: Parameters>) => { const env = { ...loadApiEnv(), ...loadClientEnv() }; const fn = createClerkExpressWithAuth({ clerkClient, ...env }); return fn(...args); From 427122debde46517016e46f528db300ce5b6b3a4 Mon Sep 17 00:00:00 2001 From: George Desipris <73396808+desiprisg@users.noreply.github.com> Date: Fri, 27 Oct 2023 00:28:20 +0300 Subject: [PATCH 2/2] fix(backend): Support NextJS 14 (#1948) * fix(backend): Fix for next 14 fetch bind issue * fix(nextjs): Use named imports for fetch runtime polyfill Next14 seems to have changed the way it handles default exports when using the webpack bundler for some of their build variants when using `npm run dev`. This commit ensures that we no longer use the default export in an effort to improve compat between the different nextjs versions. More information can be found here: https://esbuild.github.io/content-types/#default-interop and here: https://github.com/clerkinc/javascript/pull/612 * Create late-dolphins-peel.md --------- Co-authored-by: Nikos Douvlis --- .changeset/late-dolphins-peel.md | 5 +++++ packages/backend/src/runtime/browser/fetch.mjs | 1 + packages/backend/src/runtime/index.ts | 4 ++-- packages/backend/src/runtime/node/fetch.js | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/late-dolphins-peel.md diff --git a/.changeset/late-dolphins-peel.md b/.changeset/late-dolphins-peel.md new file mode 100644 index 00000000000..04e3344490e --- /dev/null +++ b/.changeset/late-dolphins-peel.md @@ -0,0 +1,5 @@ +--- +"@clerk/backend": minor +--- + +Add support for NextJS 14 diff --git a/packages/backend/src/runtime/browser/fetch.mjs b/packages/backend/src/runtime/browser/fetch.mjs index 86ef402b1ce..3c3e70ae40f 100644 --- a/packages/backend/src/runtime/browser/fetch.mjs +++ b/packages/backend/src/runtime/browser/fetch.mjs @@ -5,3 +5,4 @@ export const RuntimeHeaders = Headers; export const RuntimeRequest = Request; export const RuntimeResponse = Response; export const RuntimeAbortController = AbortController; +export const RuntimeFetch = fetch; diff --git a/packages/backend/src/runtime/index.ts b/packages/backend/src/runtime/index.ts index f77338cb6d5..89a1d7c1a77 100644 --- a/packages/backend/src/runtime/index.ts +++ b/packages/backend/src/runtime/index.ts @@ -18,7 +18,7 @@ import crypto from '#crypto'; import * as fetchApisPolyfill from '#fetch'; const { - default: fetch, + RuntimeFetch, RuntimeAbortController, RuntimeBlob, RuntimeFormData, @@ -44,7 +44,7 @@ type Runtime = { // The globalThis object is supported for Node >= 12.0. // // https://github.com/supabase/supabase/issues/4417 -const globalFetch = fetch.bind(globalThis); +const globalFetch = RuntimeFetch.bind(globalThis); // DO NOT CHANGE: Runtime needs to be imported as a default export so that we can stub its dependencies with Sinon.js // For more information refer to https://sinonjs.org/how-to/stub-dependency/ const runtime: Runtime = { diff --git a/packages/backend/src/runtime/node/fetch.js b/packages/backend/src/runtime/node/fetch.js index 58b33cabadc..38f0e8de6ea 100644 --- a/packages/backend/src/runtime/node/fetch.js +++ b/packages/backend/src/runtime/node/fetch.js @@ -8,3 +8,4 @@ module.exports.RuntimeHeaders = Headers; module.exports.RuntimeRequest = Request; module.exports.RuntimeResponse = Response; module.exports.RuntimeAbortController = AbortController; +module.exports.RuntimeFetch = fetch;