-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backend): Use
User-Agent
header with package name and version …
…in BAPI requests (#2558) * fix(backend): Use tsup bundling in tests * chore(backend): Rename Clerk-Backend-SDK BAPI request header to User-Agent * feat(backend): Add package version in User-Agent header of BAPI requests * feat(nextjs): Add package@version to BAPI requests User-Agent header * feat(fastify): Add package@version to BAPI requests User-Agent header * feat(gatsby-plugin-clerk): Add package@version to BAPI requests User-Agent header * feat(remix): Add package@version to BAPI requests User-Agent header * feat(clerk-sdk-node): Add package@version to BAPI requests User-Agent header * chore(repo): Add changeset * fix(backend): Extract test-specific build config to tsup.config.test.ts --------- Co-authored-by: Nikos Douvlis <nikosdouvlis@gmail.com>
- Loading branch information
1 parent
41f8832
commit b4e79c1
Showing
15 changed files
with
75 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
'gatsby-plugin-clerk': minor | ||
'@clerk/clerk-sdk-node': minor | ||
'@clerk/backend': minor | ||
'@clerk/fastify': minor | ||
'@clerk/nextjs': minor | ||
'@clerk/remix': minor | ||
--- | ||
|
||
Replace the `Clerk-Backend-SDK` header with `User-Agent` in BAPI requests and update it's value to contain both the package name and the package version of the clerk package | ||
executing the request. Eg request from `@clerk/nextjs` to BAPI with append `User-Agent: @clerk/nextjs@5.0.0-alpha-v5.16` using the latest version. | ||
|
||
Miscellaneous changes: The backend test build changed to use tsup. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { defineConfig } from 'tsup'; | ||
|
||
// @ts-ignore | ||
import { name } from './package.json'; | ||
|
||
export default defineConfig(overrideOptions => { | ||
const isWatch = !!overrideOptions.watch; | ||
|
||
return { | ||
entry: ['./src/**/*.{ts,js}'], | ||
outDir: 'tests/dist/', | ||
define: { | ||
PACKAGE_NAME: `"${name}"`, | ||
// use "test" instead of actual package version to avoid updating the tests | ||
// depending on it (eg userAgent related) on every version bump | ||
PACKAGE_VERSION: `"0.0.0-test"`, | ||
__DEV__: `${isWatch}`, | ||
}, | ||
external: ['#crypto'], | ||
clean: true, | ||
minify: false, | ||
tsconfig: 'tsconfig.test.json', | ||
format: 'cjs', | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
global.fetch = jest.fn(() => Promise.resolve(new Response(null))); | ||
|
||
import { clerkClient } from '../clerkClient'; | ||
|
||
describe('clerkClient', () => { | ||
it('should pass version package to userAgent', async () => { | ||
await clerkClient.users.getUser('user_test'); | ||
|
||
expect(global.fetch).toBeCalled(); | ||
expect((global.fetch as any).mock.calls[0][1].headers).toMatchObject({ | ||
Authorization: 'Bearer TEST_SECRET_KEY', | ||
'Content-Type': 'application/json', | ||
'User-Agent': '@clerk/nextjs@0.0.0-test', | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters