Skip to content
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
9 changes: 9 additions & 0 deletions .changeset/lovely-mirrors-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@clerk/fastify': major
---

Drop deprecations. Migration steps:
- use `CLERK_SECRET_KEY` instead of `CLERK_API_KEY` env variable
- use `secretKey` instead of `apiKey`
- use `CLERK_PUBLISHABLE_KEY` instead of `CLERK_FRONTEND_API` env variable
- use `publishableKey` instead of `frontendApi`
3 changes: 1 addition & 2 deletions packages/fastify/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
process.env.CLERK_API_KEY = 'TEST_API_KEY';
process.env.CLERK_SECRET_KEY = 'TEST_API_KEY';
process.env.CLERK_SECRET_KEY = 'TEST_SECRET_KEY';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`clerk initializes clerk with constants 1`] = `
"apiUrl": "https://api.clerk.com",
"apiVersion": "v1",
"jwtKey": "",
"secretKey": "TEST_API_KEY",
"secretKey": "TEST_SECRET_KEY",
},
],
]
Expand Down
2 changes: 0 additions & 2 deletions packages/fastify/src/__snapshots__/constants.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

exports[`constants from environment variables 1`] = `
{
"API_KEY": "CLERK_API_KEY",
"API_URL": "CLERK_API_URL",
"API_VERSION": "CLERK_API_VERSION",
"Cookies": {
"ClientUat": "__client_uat",
"Session": "__session",
},
"FRONTEND_API": "CLERK_FRONTEND_API",
"Headers": {
"AuthMessage": "x-clerk-auth-message",
"AuthReason": "x-clerk-auth-reason",
Expand Down
4 changes: 0 additions & 4 deletions packages/fastify/src/constants.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
const clonedEnvVars = {
CLERK_API_URL: process.env.CLERK_API_URL,
CLERK_API_VERSION: process.env.CLERK_API_VERSION,
CLERK_API_KEY: process.env.CLERK_API_KEY,
CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY,
CLERK_FRONTEND_API: process.env.CLERK_FRONTEND_API,
CLERK_PUBLISHABLE_KEY: process.env.CLERK_PUBLISHABLE_KEY,
CLERK_JWT_KEY: process.env.CLERK_JWT_KEY,
};

process.env.CLERK_API_URL = 'CLERK_API_URL';
process.env.CLERK_API_VERSION = 'CLERK_API_VERSION';
process.env.CLERK_API_KEY = 'CLERK_API_KEY';
process.env.CLERK_SECRET_KEY = 'CLERK_SECRET_KEY';
process.env.CLERK_FRONTEND_API = 'CLERK_FRONTEND_API';
process.env.CLERK_PUBLISHABLE_KEY = 'CLERK_PUBLISHABLE_KEY';
process.env.CLERK_JWT_KEY = 'CLERK_JWT_KEY';

Expand Down
16 changes: 0 additions & 16 deletions packages/fastify/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
import { constants } from '@clerk/backend';
import { deprecated } from '@clerk/shared/deprecated';

export const API_URL = process.env.CLERK_API_URL || 'https://api.clerk.com';
export const API_VERSION = process.env.CLERK_API_VERSION || 'v1';
/**
* Backend API key
* @deprecated Use `CLERK_SECRET_KEY` instead.
*/
export const API_KEY = process.env.CLERK_API_KEY || '';
if (API_KEY) {
deprecated('CLERK_API_KEY', 'Use `CLERK_SECRET_KEY` environment variable instead.');
}
export const SECRET_KEY = process.env.CLERK_SECRET_KEY || '';
/**
* @deprecated Use `CLERK_PUBLISHABLE_KEY` instead.
*/
export const FRONTEND_API = process.env.CLERK_FRONTEND_API || '';
if (FRONTEND_API) {
deprecated('CLERK_FRONTEND_API', 'Use `CLERK_PUBLISHABLE_KEY` environment variable instead.');
}
export const PUBLISHABLE_KEY = process.env.CLERK_PUBLISHABLE_KEY || '';
export const JWT_KEY = process.env.CLERK_JWT_KEY || '';

Expand Down
9 changes: 3 additions & 6 deletions packages/fastify/src/withClerkMiddleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ describe('withClerkMiddleware(options)', () => {
expect(response.body).toEqual(JSON.stringify({ auth: 'mockedAuth' }));
expect(authenticateRequestMock).toBeCalledWith(
expect.objectContaining({
secretKey: 'TEST_API_KEY',
apiKey: 'TEST_API_KEY',
secretKey: 'TEST_SECRET_KEY',
request: expect.any(Request),
}),
);
Expand Down Expand Up @@ -97,8 +96,7 @@ describe('withClerkMiddleware(options)', () => {
expect(response.body).toEqual(JSON.stringify({ auth: 'mockedAuth' }));
expect(authenticateRequestMock).toBeCalledWith(
expect.objectContaining({
secretKey: 'TEST_API_KEY',
apiKey: 'TEST_API_KEY',
secretKey: 'TEST_SECRET_KEY',
request: expect.any(Request),
}),
);
Expand Down Expand Up @@ -193,8 +191,7 @@ describe('withClerkMiddleware(options)', () => {
expect(response.body).toEqual(JSON.stringify({ auth: 'mockedAuth' }));
expect(authenticateRequestMock).toBeCalledWith(
expect.objectContaining({
secretKey: 'TEST_API_KEY',
apiKey: 'TEST_API_KEY',
secretKey: 'TEST_SECRET_KEY',
request: expect.any(Request),
}),
);
Expand Down
8 changes: 2 additions & 6 deletions packages/fastify/src/withClerkMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export const withClerkMiddleware = (options: ClerkFastifyOptions) => {
...options,
secretKey,
publishableKey,
apiKey: constants.API_KEY,
frontendApi: constants.FRONTEND_API,
request: createIsomorphicRequest((Request, Headers) => {
const requestHeaders = Object.keys(req.headers).reduce(
(acc, key) => Object.assign(acc, { [key]: req?.headers[key] }),
Expand Down Expand Up @@ -43,10 +41,8 @@ export const withClerkMiddleware = (options: ClerkFastifyOptions) => {
}

if (requestState.isInterstitial) {
const interstitialHtmlPage = clerkClient.localInterstitial({
publishableKey,
frontendApi: constants.FRONTEND_API,
});
// TODO(@dimkl): use empty string for frontendApi until type is fixed in @clerk/backend to drop it
const interstitialHtmlPage = clerkClient.localInterstitial({ publishableKey, frontendApi: '' });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ oh is this required ? 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. Will be fixed in the @clerk/backend deprecations PR


return reply
.code(401)
Expand Down