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

chore(clerk-sdk-node): Drop noisy deprecation of unstable_options in sdk-node #1858

Merged
merged 1 commit into from
Oct 11, 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/seven-shrimps-train.md
Original file line number Diff line number Diff line change
@@ -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`
13 changes: 9 additions & 4 deletions packages/sdk-node/src/clerkClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ import { createClerkExpressRequireAuth } from './clerkExpressRequireAuth';
import { createClerkExpressWithAuth } from './clerkExpressWithAuth';
import { loadApiEnv, loadClientEnv } from './utils';

type ExtendedClerk = ReturnType<typeof _Clerk> & {
expressWithAuth: ReturnType<typeof createClerkExpressWithAuth>;
expressRequireAuth: ReturnType<typeof createClerkExpressRequireAuth>;
verifyToken: typeof _verifyToken;
} & ReturnType<typeof createBasePropForRedwoodCompatibility>;

/**
* 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 });
Expand All @@ -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 = () => {
Expand Down
4 changes: 3 additions & 1 deletion playground/cra-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions playground/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions playground/express/src/routes/private.ts
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
1 change: 1 addition & 0 deletions playground/fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions playground/remix-cf-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions playground/vite-react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down