Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 470
chore(backend): Rename machine auth verification methods#7347
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
7beadc7289e04ebac3b5b842f09fc8b3223File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| '@clerk/backend': minor | ||
| --- | ||
| Unified machine token verification methods under a consistent `verify()` API. The previous methods (`verifySecret`, `verifyToken`, `verifyAccessToken`) are now deprecated. | ||
| Before | ||
| ```ts | ||
| await clerkClient.apiKeys.verifySecret('ak_...'); | ||
| await clerkClient.m2m.verifyToken({ token: 'mt_...' }); | ||
| ``` | ||
| After | ||
| ```ts | ||
| await clerkClient.apiKeys.verify('ak_...'); | ||
| await clerkClient.m2m.verify({ token: 'mt_...' }); | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,6 +2,7 @@ import type { ClerkPaginationRequest } from '@clerk/shared/types'; | ||
| import type { PaginatedResourceResponse } from '../../api/resources/Deserializer'; | ||
| import { joinPaths } from '../../util/path'; | ||
| import { deprecated } from '../../util/shared'; | ||
| import type { APIKey } from '../resources/APIKey'; | ||
| import { AbstractAPI } from './AbstractApi'; | ||
| @@ -88,11 +89,19 @@ export class APIKeysAPI extends AbstractAPI { | ||
| }); | ||
| } | ||
| async verifySecret(secret: string) { | ||
| async verify(secret: string) { | ||
| return this.request<APIKey>({ | ||
| method: 'POST', | ||
| path: joinPaths(basePath, 'verify'), | ||
| bodyParams: { secret }, | ||
| }); | ||
| } | ||
| /** | ||
| * @deprecated Use `verify()` instead. This method will be removed in the next major release. | ||
| */ | ||
| async verifySecret(secret: string) { | ||
| deprecated('apiKeys.verifySecret()', 'Use `apiKeys.verify()` instead.'); | ||
| return this.verify(secret); | ||
| } | ||
wobsoriano marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,24 @@ | ||
| import { joinPaths } from '../../util/path'; | ||
| import { deprecated } from '../../util/shared'; | ||
| import type { IdPOAuthAccessToken } from '../resources'; | ||
| import { AbstractAPI } from './AbstractApi'; | ||
| const basePath = '/oauth_applications/access_tokens'; | ||
| export class IdPOAuthAccessTokenApi extends AbstractAPI { | ||
| async verifyAccessToken(accessToken: string) { | ||
| async verify(accessToken: string) { | ||
| return this.request<IdPOAuthAccessToken>({ | ||
| method: 'POST', | ||
| path: joinPaths(basePath, 'verify'), | ||
| bodyParams: { access_token: accessToken }, | ||
| }); | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| /** | ||
| * @deprecated Use `verify()` instead. This method will be removed in the next major release. | ||
| */ | ||
| async verifyAccessToken(accessToken: string) { | ||
| deprecated('idPOAuthAccessToken.verifyAccessToken()', 'Use `idPOAuthAccessToken.verify()` instead.'); | ||
| return this.verify(accessToken); | ||
| } | ||
wobsoriano marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { joinPaths } from '../../util/path'; | ||
| import { deprecated } from '../../util/shared'; | ||
| import type { ClerkBackendApiRequestOptions } from '../request'; | ||
| import type { M2MToken } from '../resources/M2MToken'; | ||
| import { AbstractAPI } from './AbstractApi'; | ||
| @@ -94,7 +95,7 @@ export class M2MTokenApi extends AbstractAPI { | ||
| return this.request<M2MToken>(requestOptions); | ||
| } | ||
| async verifyToken(params: VerifyM2MTokenParams) { | ||
| async verify(params: VerifyM2MTokenParams) { | ||
| const { token, machineSecretKey } = params; | ||
| const requestOptions = this.#createRequestOptions( | ||
| @@ -108,4 +109,12 @@ export class M2MTokenApi extends AbstractAPI { | ||
| return this.request<M2MToken>(requestOptions); | ||
| } | ||
| /** | ||
| * @deprecated Use `verify()` instead. This method will be removed in the next major release. | ||
| */ | ||
| async verifyToken(params: VerifyM2MTokenParams) { | ||
| deprecated('m2m.verifyToken()', 'Use `m2m.verify()` instead.'); | ||
| return this.verify(params); | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.