diff --git a/.changeset/seven-shrimps-train.md b/.changeset/seven-shrimps-train.md new file mode 100644 index 0000000000..67aa313ce8 --- /dev/null +++ b/.changeset/seven-shrimps-train.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-sdk-node': patch +--- + +Avoid always showing `__unstable_options` deprecation warning in all applications and SDKs using `@clerk/clerk-sdk-node` diff --git a/packages/sdk-node/src/clerkClient.ts b/packages/sdk-node/src/clerkClient.ts index af690b09cf..6f9cc6a35b 100644 --- a/packages/sdk-node/src/clerkClient.ts +++ b/packages/sdk-node/src/clerkClient.ts @@ -5,12 +5,18 @@ import { createClerkExpressRequireAuth } from './clerkExpressRequireAuth'; import { createClerkExpressWithAuth } from './clerkExpressWithAuth'; import { loadApiEnv, loadClientEnv } from './utils'; +type ExtendedClerk = ReturnType & { + expressWithAuth: ReturnType; + expressRequireAuth: ReturnType; + verifyToken: typeof _verifyToken; +} & ReturnType; + /** * This needs to be a *named* function in order to support the older * new Clerk() syntax for v4 compatibility. * Arrow functions can never be called with the new keyword because they do not have the [[Construct]] method */ -export function Clerk(options: ClerkOptions) { +export function Clerk(options: ClerkOptions): ExtendedClerk { const clerkClient = _Clerk(options); const expressWithAuth = createClerkExpressWithAuth({ ...options, clerkClient }); const expressRequireAuth = createClerkExpressRequireAuth({ ...options, clerkClient }); @@ -19,13 +25,12 @@ export function Clerk(options: ClerkOptions) { return _verifyToken(token, { issuer, ...options, ...verifyOpts }); }; - return { - ...clerkClient, + return Object.assign(clerkClient, { expressWithAuth, expressRequireAuth, verifyToken, ...createBasePropForRedwoodCompatibility(), - }; + }); } const createBasePropForRedwoodCompatibility = () => { diff --git a/playground/cra-js/package.json b/playground/cra-js/package.json index 647ccef25a..4060f4e987 100644 --- a/playground/cra-js/package.json +++ b/playground/cra-js/package.json @@ -3,7 +3,9 @@ "version": "0.1.0", "private": true, "dependencies": { - "@clerk/clerk-react": "*", + "@clerk/clerk-react": "file:.yalc/@clerk/clerk-react", + "@clerk/shared": "file:.yalc/@clerk/shared", + "@clerk/types": "file:.yalc/@clerk/types", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", diff --git a/playground/express/package.json b/playground/express/package.json index 92e2d93118..32d113cb57 100644 --- a/playground/express/package.json +++ b/playground/express/package.json @@ -12,6 +12,7 @@ "dependencies": { "@clerk/backend": "file:.yalc/@clerk/backend", "@clerk/clerk-sdk-node": "file:.yalc/@clerk/clerk-sdk-node", + "@clerk/shared": "file:.yalc/@clerk/shared", "@clerk/types": "file:.yalc/@clerk/types", "dotenv": "^16.0.3", "ejs": "^3.1.6", diff --git a/playground/express/src/routes/private.ts b/playground/express/src/routes/private.ts index e65c46f0f0..9dcbdff9f4 100644 --- a/playground/express/src/routes/private.ts +++ b/playground/express/src/routes/private.ts @@ -1,11 +1,11 @@ import type { Response } from 'express'; -import { ClerkExpressRequireAuth, clerkClient } from '@clerk/clerk-sdk-node'; +import { clerkClient } from '@clerk/clerk-sdk-node'; import { Router } from 'express'; const router = Router(); -router.use(ClerkExpressRequireAuth({ clerkClient })); +router.use((...args)=>clerkClient.expressRequireAuth()(...args)); router.get('/me', async (req, reply: Response) => { return reply.json({ auth: req.auth }); diff --git a/playground/fastify/package.json b/playground/fastify/package.json index 90705bd0f0..b4d475b81b 100644 --- a/playground/fastify/package.json +++ b/playground/fastify/package.json @@ -8,6 +8,7 @@ "dependencies": { "@clerk/backend": "file:.yalc/@clerk/backend", "@clerk/fastify": "file:.yalc/@clerk/fastify", + "@clerk/shared": "file:.yalc/@clerk/shared", "@clerk/types": "file:.yalc/@clerk/types", "@fastify/view": "^8.0.0", "dotenv": "^16.0.3", diff --git a/playground/remix-cf-pages/package.json b/playground/remix-cf-pages/package.json index 470c36473e..997d71eff7 100644 --- a/playground/remix-cf-pages/package.json +++ b/playground/remix-cf-pages/package.json @@ -11,9 +11,9 @@ "yalc:add": "yalc add @clerk/types && yalc add @clerk/remix && yalc add @clerk/backend" }, "dependencies": { - "@clerk/backend": "*", - "@clerk/remix": "*", - "@clerk/types": "*", + "@clerk/backend": "file:.yalc/@clerk/backend", + "@clerk/remix": "file:.yalc/@clerk/remix", + "@clerk/types": "file:.yalc/@clerk/types", "@remix-run/cloudflare": "^2.0.0", "@remix-run/cloudflare-pages": "^2.0.0", "@remix-run/react": "^2.0.0", diff --git a/playground/vite-react-ts/package.json b/playground/vite-react-ts/package.json index 445d34d398..a1f2c35b39 100644 --- a/playground/vite-react-ts/package.json +++ b/playground/vite-react-ts/package.json @@ -12,6 +12,7 @@ "yalc": "yalc add -- @clerk/clerk-react @clerk/types @clerk/shared" }, "dependencies": { + "@clerk/clerk-js": "file:.yalc/@clerk/clerk-js", "@clerk/clerk-react": "file:.yalc/@clerk/clerk-react", "@clerk/shared": "file:.yalc/@clerk/shared", "@clerk/types": "file:.yalc/@clerk/types",