Skip to content

Commit a0cc247

Browse files
authored
feat(backend): Adds the ability to verify proxy checks to the Backend API client (#5589)
1 parent 75c3be2 commit a0cc247

9 files changed

Lines changed: 79 additions & 0 deletions

File tree

.changeset/fresh-bears-unite.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@clerk/backend': patch
3+
---
4+
5+
Adds the ability to verify proxy checks to the Backend API client.
6+
7+
```ts
8+
import { createClerkClient } from '@clerk/backend';
9+
10+
const clerkClient = createClerkClient(...);
11+
await clerkClient.proxyChecks.verify({
12+
domainId: 'dmn_xxxxxx',
13+
proxyUrl: 'https://[your-domain].com'
14+
});
15+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { ProxyCheck } from '../resources';
2+
import { AbstractAPI } from './AbstractApi';
3+
4+
const basePath = '/proxy_checks';
5+
6+
type VerifyParams = {
7+
domainId: string;
8+
proxyUrl: string;
9+
};
10+
11+
export class ProxyCheckAPI extends AbstractAPI {
12+
public async verify(params: VerifyParams) {
13+
return this.request<ProxyCheck>({
14+
method: 'POST',
15+
path: basePath,
16+
bodyParams: params,
17+
});
18+
}
19+
}

packages/backend/src/api/endpoints/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * from './InvitationApi';
88
export * from './JwksApi';
99
export * from './OrganizationApi';
1010
export * from './PhoneNumberApi';
11+
export * from './ProxyCheckApi';
1112
export * from './RedirectUrlApi';
1213
export * from './SessionApi';
1314
export * from './SignInTokenApi';

packages/backend/src/api/factory.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
JwksAPI,
99
OrganizationAPI,
1010
PhoneNumberAPI,
11+
ProxyCheckAPI,
1112
RedirectUrlAPI,
1213
SamlConnectionAPI,
1314
SessionAPI,
@@ -35,6 +36,7 @@ export function createBackendApiClient(options: CreateBackendApiOptions) {
3536
jwks: new JwksAPI(request),
3637
organizations: new OrganizationAPI(request),
3738
phoneNumbers: new PhoneNumberAPI(request),
39+
proxyChecks: new ProxyCheckAPI(request),
3840
redirectUrls: new RedirectUrlAPI(request),
3941
sessions: new SessionAPI(request),
4042
signInTokens: new SignInTokenAPI(request),

packages/backend/src/api/resources/Deserializer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
OrganizationInvitation,
1212
OrganizationMembership,
1313
PhoneNumber,
14+
ProxyCheck,
1415
RedirectUrl,
1516
Session,
1617
SignInToken,
@@ -91,6 +92,8 @@ function jsonToObject(item: any): any {
9192
return OrganizationMembership.fromJSON(item);
9293
case ObjectType.PhoneNumber:
9394
return PhoneNumber.fromJSON(item);
95+
case ObjectType.ProxyCheck:
96+
return ProxyCheck.fromJSON(item);
9497
case ObjectType.RedirectUrl:
9598
return RedirectUrl.fromJSON(item);
9699
case ObjectType.SignInToken:

packages/backend/src/api/resources/JSON.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const ObjectType = {
2626
OrganizationInvitation: 'organization_invitation',
2727
OrganizationMembership: 'organization_membership',
2828
PhoneNumber: 'phone_number',
29+
ProxyCheck: 'proxy_check',
2930
RedirectUrl: 'redirect_url',
3031
SamlAccount: 'saml_account',
3132
Session: 'session',
@@ -271,6 +272,17 @@ export interface PhoneNumberJSON extends ClerkResourceJSON {
271272
backup_codes: string[];
272273
}
273274

275+
export type ProxyCheckJSON = {
276+
object: typeof ObjectType.ProxyCheck;
277+
id: string;
278+
domain_id: string;
279+
last_run_at: number | null;
280+
proxy_url: string;
281+
successful: boolean;
282+
created_at: number;
283+
updated_at: number;
284+
};
285+
274286
export interface RedirectUrlJSON extends ClerkResourceJSON {
275287
object: typeof ObjectType.RedirectUrl;
276288
url: string;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { ProxyCheckJSON } from './JSON';
2+
3+
export class ProxyCheck {
4+
constructor(
5+
readonly id: string,
6+
readonly domainId: string,
7+
readonly lastRunAt: number | null,
8+
readonly proxyUrl: string,
9+
readonly successful: boolean,
10+
readonly createdAt: number,
11+
readonly updatedAt: number,
12+
) {}
13+
14+
static fromJSON(data: ProxyCheckJSON): ProxyCheck {
15+
return new ProxyCheck(
16+
data.id,
17+
data.domain_id,
18+
data.last_run_at,
19+
data.proxy_url,
20+
data.successful,
21+
data.created_at,
22+
data.updated_at,
23+
);
24+
}
25+
}

packages/backend/src/api/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export * from './Organization';
2525
export * from './OrganizationInvitation';
2626
export * from './OrganizationMembership';
2727
export * from './PhoneNumber';
28+
export * from './ProxyCheck';
2829
export * from './RedirectUrl';
2930
export * from './Session';
3031
export * from './SignInTokens';

packages/backend/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export type {
7373
OrganizationMembershipJSON,
7474
OrganizationMembershipPublicUserDataJSON,
7575
PhoneNumberJSON,
76+
ProxyCheckJSON,
7677
RedirectUrlJSON,
7778
SessionJSON,
7879
SignInJSON,

0 commit comments

Comments
 (0)