Skip to content

Commit cfb50e1

Browse files
authored
chore(fastify): Drop deprecations (clerk#1976)
* chore(fastify): Drop `CLERK_API_KEY` * chore(fastify): Drop `CLERK_FRONTEND_API`
1 parent 733b6f3 commit cfb50e1

8 files changed

Lines changed: 16 additions & 37 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@clerk/fastify': major
3+
---
4+
5+
Drop deprecations. Migration steps:
6+
- use `CLERK_SECRET_KEY` instead of `CLERK_API_KEY` env variable
7+
- use `secretKey` instead of `apiKey`
8+
- use `CLERK_PUBLISHABLE_KEY` instead of `CLERK_FRONTEND_API` env variable
9+
- use `publishableKey` instead of `frontendApi`

packages/fastify/jest.setup.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
process.env.CLERK_API_KEY = 'TEST_API_KEY';
2-
process.env.CLERK_SECRET_KEY = 'TEST_API_KEY';
1+
process.env.CLERK_SECRET_KEY = 'TEST_SECRET_KEY';

packages/fastify/src/__snapshots__/clerkClient.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exports[`clerk initializes clerk with constants 1`] = `
77
"apiUrl": "https://api.clerk.com",
88
"apiVersion": "v1",
99
"jwtKey": "",
10-
"secretKey": "TEST_API_KEY",
10+
"secretKey": "TEST_SECRET_KEY",
1111
},
1212
],
1313
]

packages/fastify/src/__snapshots__/constants.test.ts.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
exports[`constants from environment variables 1`] = `
44
{
5-
"API_KEY": "CLERK_API_KEY",
65
"API_URL": "CLERK_API_URL",
76
"API_VERSION": "CLERK_API_VERSION",
87
"Cookies": {
98
"ClientUat": "__client_uat",
109
"Session": "__session",
1110
},
12-
"FRONTEND_API": "CLERK_FRONTEND_API",
1311
"Headers": {
1412
"AuthMessage": "x-clerk-auth-message",
1513
"AuthReason": "x-clerk-auth-reason",

packages/fastify/src/constants.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
const clonedEnvVars = {
22
CLERK_API_URL: process.env.CLERK_API_URL,
33
CLERK_API_VERSION: process.env.CLERK_API_VERSION,
4-
CLERK_API_KEY: process.env.CLERK_API_KEY,
54
CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY,
6-
CLERK_FRONTEND_API: process.env.CLERK_FRONTEND_API,
75
CLERK_PUBLISHABLE_KEY: process.env.CLERK_PUBLISHABLE_KEY,
86
CLERK_JWT_KEY: process.env.CLERK_JWT_KEY,
97
};
108

119
process.env.CLERK_API_URL = 'CLERK_API_URL';
1210
process.env.CLERK_API_VERSION = 'CLERK_API_VERSION';
13-
process.env.CLERK_API_KEY = 'CLERK_API_KEY';
1411
process.env.CLERK_SECRET_KEY = 'CLERK_SECRET_KEY';
15-
process.env.CLERK_FRONTEND_API = 'CLERK_FRONTEND_API';
1612
process.env.CLERK_PUBLISHABLE_KEY = 'CLERK_PUBLISHABLE_KEY';
1713
process.env.CLERK_JWT_KEY = 'CLERK_JWT_KEY';
1814

packages/fastify/src/constants.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
import { constants } from '@clerk/backend';
2-
import { deprecated } from '@clerk/shared/deprecated';
32

43
export const API_URL = process.env.CLERK_API_URL || 'https://api.clerk.com';
54
export const API_VERSION = process.env.CLERK_API_VERSION || 'v1';
6-
/**
7-
* Backend API key
8-
* @deprecated Use `CLERK_SECRET_KEY` instead.
9-
*/
10-
export const API_KEY = process.env.CLERK_API_KEY || '';
11-
if (API_KEY) {
12-
deprecated('CLERK_API_KEY', 'Use `CLERK_SECRET_KEY` environment variable instead.');
13-
}
145
export const SECRET_KEY = process.env.CLERK_SECRET_KEY || '';
15-
/**
16-
* @deprecated Use `CLERK_PUBLISHABLE_KEY` instead.
17-
*/
18-
export const FRONTEND_API = process.env.CLERK_FRONTEND_API || '';
19-
if (FRONTEND_API) {
20-
deprecated('CLERK_FRONTEND_API', 'Use `CLERK_PUBLISHABLE_KEY` environment variable instead.');
21-
}
226
export const PUBLISHABLE_KEY = process.env.CLERK_PUBLISHABLE_KEY || '';
237
export const JWT_KEY = process.env.CLERK_JWT_KEY || '';
248

packages/fastify/src/withClerkMiddleware.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ describe('withClerkMiddleware(options)', () => {
5757
expect(response.body).toEqual(JSON.stringify({ auth: 'mockedAuth' }));
5858
expect(authenticateRequestMock).toBeCalledWith(
5959
expect.objectContaining({
60-
secretKey: 'TEST_API_KEY',
61-
apiKey: 'TEST_API_KEY',
60+
secretKey: 'TEST_SECRET_KEY',
6261
request: expect.any(Request),
6362
}),
6463
);
@@ -97,8 +96,7 @@ describe('withClerkMiddleware(options)', () => {
9796
expect(response.body).toEqual(JSON.stringify({ auth: 'mockedAuth' }));
9897
expect(authenticateRequestMock).toBeCalledWith(
9998
expect.objectContaining({
100-
secretKey: 'TEST_API_KEY',
101-
apiKey: 'TEST_API_KEY',
99+
secretKey: 'TEST_SECRET_KEY',
102100
request: expect.any(Request),
103101
}),
104102
);
@@ -193,8 +191,7 @@ describe('withClerkMiddleware(options)', () => {
193191
expect(response.body).toEqual(JSON.stringify({ auth: 'mockedAuth' }));
194192
expect(authenticateRequestMock).toBeCalledWith(
195193
expect.objectContaining({
196-
secretKey: 'TEST_API_KEY',
197-
apiKey: 'TEST_API_KEY',
194+
secretKey: 'TEST_SECRET_KEY',
198195
request: expect.any(Request),
199196
}),
200197
);

packages/fastify/src/withClerkMiddleware.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ export const withClerkMiddleware = (options: ClerkFastifyOptions) => {
1414
...options,
1515
secretKey,
1616
publishableKey,
17-
apiKey: constants.API_KEY,
18-
frontendApi: constants.FRONTEND_API,
1917
request: createIsomorphicRequest((Request, Headers) => {
2018
const requestHeaders = Object.keys(req.headers).reduce(
2119
(acc, key) => Object.assign(acc, { [key]: req?.headers[key] }),
@@ -43,10 +41,8 @@ export const withClerkMiddleware = (options: ClerkFastifyOptions) => {
4341
}
4442

4543
if (requestState.isInterstitial) {
46-
const interstitialHtmlPage = clerkClient.localInterstitial({
47-
publishableKey,
48-
frontendApi: constants.FRONTEND_API,
49-
});
44+
// TODO(@dimkl): use empty string for frontendApi until type is fixed in @clerk/backend to drop it
45+
const interstitialHtmlPage = clerkClient.localInterstitial({ publishableKey, frontendApi: '' });
5046

5147
return reply
5248
.code(401)

0 commit comments

Comments
 (0)