-
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.
chore(repo): v5 extra cleanups (#2169)
* chore(clerk-expo): Use isomorphicAtob/isomorhpicBtoa to drop base-64 dep * chore(clerk-sdk-node): Add comment and drop todo in interstitial response errors * fix(clerk-react): Rename `HeadlessBrowserClerkConstrutor` / `HeadlessBrowserClerkConstructor` typo * fix(clerk-react): Drop unused import * chore(backend): Refactor merging of props in request/factory * chore(clerk-react,nextjs): Update JSDoc examples with `withServerSideAuth` * chore(shared): Drop `isLegacyFrontendApiKey` * chore(clerk-js): Drop forgotten default exports * chore(clerk-js): Drop node-fetch dependency * chore(backend): Duplicate test * chore(remix): Rename `noSecretKeyOrApiKeyError` to `noSecretKeyError` * chore(clerk-sdk-node): Re-use `isDevelopmentFromApiKey` from `@clerk/shared` * chore(backend): Drop unused `LoadResourcesOptions` export * chore(*): Rename `isDevelopmentFromApiKey` to `isDevelopmentFromSecretKey` * chore(*): Rename `isProductionFromApiKey` to `isProductionFromSecretKey` * chore(repo): Add changeset
- Loading branch information
Showing
33 changed files
with
232 additions
and
193 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,26 @@ | ||
--- | ||
'@clerk/clerk-js': major | ||
'@clerk/shared': major | ||
'@clerk/clerk-sdk-node': minor | ||
'@clerk/backend': minor | ||
'@clerk/nextjs': minor | ||
'@clerk/clerk-react': minor | ||
'@clerk/clerk-expo': minor | ||
--- | ||
|
||
Breaking Changes: | ||
|
||
- Drop `isLegacyFrontendApiKey` from `@clerk/shared` | ||
- Drop default exports from `@clerk/clerk-js` | ||
- on headless Clerk type | ||
- on ui and ui.retheme `Portal` | ||
- Use `isProductionFromSecretKey` instead of `isProductionFromApiKey` | ||
- Use `isDevelopmentFromSecretKey` instead of `isDevelopmentFromApiKey` | ||
|
||
Changes: | ||
|
||
- Rename `HeadlessBrowserClerkConstrutor` / `HeadlessBrowserClerkConstructor` (typo) | ||
- Use `isomorphicAtob` / `isomorhpicBtoa` to replace `base-64` in `@clerk/expo` | ||
- Refactor merging build-time and runtime props in `@clerk/backend` clerk client | ||
- Drop `node-fetch` dependency from `@clerk/backend` | ||
- Drop duplicate test in `@clerk/backend` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,96 @@ | ||
import type QUnit from 'qunit'; | ||
|
||
import type { ApiClient } from '../api'; | ||
import { createAuthenticateRequest } from './factory'; | ||
|
||
export default (QUnit: QUnit) => { | ||
const { module, test } = QUnit; | ||
|
||
module('createAuthenticateRequest({ options, apiClient })', hooks => { | ||
let fakeAuthenticateRequest; | ||
hooks.afterEach(() => { | ||
fakeAuthenticateRequest?.restore(); | ||
}); | ||
|
||
test('fallbacks to build-time options', async assert => { | ||
const buildTimeOptions = { | ||
secretKey: 'sk', | ||
jwtKey: 'jwtKey', | ||
apiUrl: 'apiUrl', | ||
apiVersion: 'apiVersion', | ||
proxyUrl: 'proxyUrl', | ||
publishableKey: 'pk', | ||
isSatellite: false, | ||
domain: 'domain', | ||
audience: 'domain', | ||
}; | ||
|
||
const { authenticateRequest } = createAuthenticateRequest({ | ||
options: buildTimeOptions, | ||
apiClient: {} as ApiClient, | ||
}); | ||
|
||
const requestState = await authenticateRequest({ request: new Request('http://example.com/') }); | ||
assert.propContains(requestState.toAuth()?.debug(), buildTimeOptions); | ||
}); | ||
|
||
test('overrides build-time options with runtime options', async assert => { | ||
const buildTimeOptions = { | ||
secretKey: 'sk', | ||
jwtKey: 'jwtKey', | ||
apiUrl: 'apiUrl', | ||
apiVersion: 'apiVersion', | ||
proxyUrl: 'proxyUrl', | ||
publishableKey: 'pk', | ||
isSatellite: false, | ||
domain: 'domain', | ||
audience: 'domain', | ||
}; | ||
|
||
const { authenticateRequest } = createAuthenticateRequest({ | ||
options: buildTimeOptions, | ||
apiClient: {} as ApiClient, | ||
}); | ||
|
||
const overrides = { | ||
secretKey: 'r-sk', | ||
publishableKey: 'r-pk', | ||
}; | ||
const requestState = await authenticateRequest({ | ||
request: new Request('http://example.com/'), | ||
...overrides, | ||
}); | ||
assert.propContains(requestState.toAuth()?.debug(), { | ||
...buildTimeOptions, | ||
...overrides, | ||
}); | ||
}); | ||
|
||
test('ignore runtime apiUrl and apiVersion options', async assert => { | ||
const buildTimeOptions = { | ||
secretKey: 'sk', | ||
jwtKey: 'jwtKey', | ||
apiUrl: 'apiUrl', | ||
apiVersion: 'apiVersion', | ||
proxyUrl: 'proxyUrl', | ||
publishableKey: 'pk', | ||
isSatellite: false, | ||
domain: 'domain', | ||
audience: 'domain', | ||
}; | ||
|
||
const { authenticateRequest } = createAuthenticateRequest({ | ||
options: buildTimeOptions, | ||
apiClient: {} as ApiClient, | ||
}); | ||
|
||
const requestState = await authenticateRequest({ | ||
request: new Request('http://example.com/'), | ||
// @ts-expect-error is used to check runtime code | ||
apiUrl: 'r-apiUrl', | ||
apiVersion: 'r-apiVersion', | ||
}); | ||
assert.propContains(requestState.toAuth()?.debug(), buildTimeOptions); | ||
}); | ||
}); | ||
}; |
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,8 @@ | ||
export function mergePreDefinedOptions<T extends Record<string, any>>(preDefinedOptions: T, options: Partial<T>): T { | ||
return Object.keys(preDefinedOptions).reduce( | ||
(obj: T, key: string) => { | ||
return { ...obj, [key]: options[key] || obj[key] }; | ||
}, | ||
{ ...preDefinedOptions }, | ||
); | ||
} |
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
Oops, something went wrong.