Skip to content

Commit 6e09786

Browse files
chore(clerk-js,types,backend): Add enterprise_connection_id to SamlAccount & EnterpriseAccount (#6961)
Co-authored-by: Nicolas Lopes <nicolas@clerk.dev>
1 parent 284b631 commit 6e09786

File tree

8 files changed

+30
-0
lines changed

8 files changed

+30
-0
lines changed

.changeset/flat-teams-trade.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/backend': patch
4+
'@clerk/types': patch
5+
---
6+
7+
Add `enterpriseConnectionId` to `SamlAccount` and `EnterpriseAccount` resources

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ export interface SamlAccountJSON extends ClerkResourceJSON {
247247
verification: VerificationJSON | null;
248248
saml_connection: SamlAccountConnectionJSON | null;
249249
last_authenticated_at: number | null;
250+
enterprise_connection_id: string | null;
250251
}
251252

252253
export interface IdentificationLinkJSON extends ClerkResourceJSON {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export class SamlAccount {
4747
* The date when the SAML account was last authenticated.
4848
*/
4949
readonly lastAuthenticatedAt: number | null,
50+
/**
51+
* The ID of the enterprise connection associated with this SAML account.
52+
*/
53+
readonly enterpriseConnectionId: string | null,
5054
) {}
5155

5256
static fromJSON(data: SamlAccountJSON): SamlAccount {
@@ -61,6 +65,7 @@ export class SamlAccount {
6165
data.verification && Verification.fromJSON(data.verification),
6266
data.saml_connection && SamlAccountConnection.fromJSON(data.saml_connection),
6367
data.last_authenticated_at ?? null,
68+
data.enterprise_connection_id,
6469
);
6570
}
6671
}

packages/clerk-js/src/core/resources/EnterpriseAccount.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class EnterpriseAccount extends BaseResource implements EnterpriseAccount
2525
verification: VerificationResource | null = null;
2626
enterpriseConnection: EnterpriseAccountConnectionResource | null = null;
2727
lastAuthenticatedAt: Date | null = null;
28+
enterpriseConnectionId: string | null = null;
2829

2930
public constructor(data: Partial<EnterpriseAccountJSON | EnterpriseAccountJSONSnapshot>, pathRoot: string);
3031
public constructor(data: EnterpriseAccountJSON | EnterpriseAccountJSONSnapshot, pathRoot: string) {
@@ -48,6 +49,7 @@ export class EnterpriseAccount extends BaseResource implements EnterpriseAccount
4849
this.lastName = data.last_name;
4950
this.publicMetadata = data.public_metadata;
5051
this.lastAuthenticatedAt = data.last_authenticated_at ? unixEpochToDate(data.last_authenticated_at) : null;
52+
this.enterpriseConnectionId = data.enterprise_connection_id;
5153
if (data.verification) {
5254
this.verification = new Verification(data.verification);
5355
}
@@ -74,6 +76,7 @@ export class EnterpriseAccount extends BaseResource implements EnterpriseAccount
7476
verification: this.verification?.__internal_toSnapshot() || null,
7577
enterprise_connection: this.enterpriseConnection?.__internal_toSnapshot() || null,
7678
last_authenticated_at: this.lastAuthenticatedAt ? this.lastAuthenticatedAt.getTime() : null,
79+
enterprise_connection_id: this.enterpriseConnectionId,
7780
};
7881
}
7982
}
@@ -92,6 +95,7 @@ export class EnterpriseAccountConnection extends BaseResource implements Enterpr
9295
syncUserAttributes!: boolean;
9396
createdAt!: Date;
9497
updatedAt!: Date;
98+
enterpriseConnectionId: string | null = '';
9599

96100
constructor(data: EnterpriseAccountConnectionJSON | EnterpriseAccountConnectionJSONSnapshot | null) {
97101
super();
@@ -112,6 +116,7 @@ export class EnterpriseAccountConnection extends BaseResource implements Enterpr
112116
this.disableAdditionalIdentifications = data.disable_additional_identifications;
113117
this.createdAt = unixEpochToDate(data.created_at);
114118
this.updatedAt = unixEpochToDate(data.updated_at);
119+
this.enterpriseConnectionId = data.enterprise_connection_id;
115120
}
116121

117122
return this;
@@ -131,6 +136,7 @@ export class EnterpriseAccountConnection extends BaseResource implements Enterpr
131136
allow_subdomains: this.allowSubdomains,
132137
allow_idp_initiated: this.allowIdpInitiated,
133138
disable_additional_identifications: this.disableAdditionalIdentifications,
139+
enterprise_connection_id: this.enterpriseConnectionId,
134140
created_at: this.createdAt.getTime(),
135141
updated_at: this.updatedAt.getTime(),
136142
};

packages/clerk-js/src/core/resources/SamlAccount.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class SamlAccount extends BaseResource implements SamlAccountResource {
2424
verification: VerificationResource | null = null;
2525
samlConnection: SamlAccountConnectionResource | null = null;
2626
lastAuthenticatedAt: Date | null = null;
27+
enterpriseConnectionId: string | null = null;
2728

2829
public constructor(data: Partial<SamlAccountJSON | SamlAccountJSONSnapshot>, pathRoot: string);
2930
public constructor(data: SamlAccountJSON | SamlAccountJSONSnapshot, pathRoot: string) {
@@ -44,6 +45,7 @@ export class SamlAccount extends BaseResource implements SamlAccountResource {
4445
this.emailAddress = data.email_address;
4546
this.firstName = data.first_name;
4647
this.lastName = data.last_name;
48+
this.enterpriseConnectionId = data.enterprise_connection_id;
4749

4850
if (data.verification) {
4951
this.verification = new Verification(data.verification);
@@ -70,6 +72,7 @@ export class SamlAccount extends BaseResource implements SamlAccountResource {
7072
last_name: this.lastName,
7173
verification: this.verification?.__internal_toSnapshot() || null,
7274
saml_connection: this.samlConnection?.__internal_toSnapshot(),
75+
enterprise_connection_id: this.enterpriseConnectionId,
7376
last_authenticated_at: this.lastAuthenticatedAt ? this.lastAuthenticatedAt.getTime() : null,
7477
};
7578
}

packages/types/src/enterpriseAccount.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ export interface EnterpriseAccountResource extends ClerkResource {
1212
active: boolean;
1313
emailAddress: string;
1414
enterpriseConnection: EnterpriseAccountConnectionResource | null;
15+
enterpriseConnectionId: string | null;
1516
firstName: string | null;
1617
lastName: string | null;
1718
protocol: EnterpriseProtocol;
1819
provider: EnterpriseProvider;
1920
providerUserId: string | null;
2021
publicMetadata: Record<string, unknown> | null;
2122
verification: VerificationResource | null;
23+
lastAuthenticatedAt: Date | null;
2224
__internal_toSnapshot: () => EnterpriseAccountJSONSnapshot;
2325
}
2426

@@ -33,5 +35,6 @@ export interface EnterpriseAccountConnectionResource extends ClerkResource {
3335
protocol: EnterpriseProtocol;
3436
provider: EnterpriseProvider;
3537
syncUserAttributes: boolean;
38+
enterpriseConnectionId: string | null;
3639
__internal_toSnapshot: () => EnterpriseAccountConnectionJSONSnapshot;
3740
}

packages/types/src/json.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ export interface EnterpriseAccountJSON extends ClerkResourceJSON {
253253
public_metadata: Record<string, unknown>;
254254
verification: VerificationJSON | null;
255255
last_authenticated_at: number | null;
256+
enterprise_connection_id: string | null;
256257
}
257258

258259
export interface EnterpriseAccountConnectionJSON extends ClerkResourceJSON {
@@ -268,6 +269,7 @@ export interface EnterpriseAccountConnectionJSON extends ClerkResourceJSON {
268269
sync_user_attributes: boolean;
269270
created_at: number;
270271
updated_at: number;
272+
enterprise_connection_id: string | null;
271273
}
272274

273275
export interface SamlAccountJSON extends ClerkResourceJSON {
@@ -281,6 +283,7 @@ export interface SamlAccountJSON extends ClerkResourceJSON {
281283
verification?: VerificationJSON;
282284
saml_connection?: SamlAccountConnectionJSON;
283285
last_authenticated_at: number | null;
286+
enterprise_connection_id: string | null;
284287
}
285288

286289
export interface UserJSON extends ClerkResourceJSON {

packages/types/src/samlAccount.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ export interface SamlAccountResource extends ClerkResource {
1313
lastName: string;
1414
verification: VerificationResource | null;
1515
samlConnection: SamlAccountConnectionResource | null;
16+
lastAuthenticatedAt: Date | null;
17+
enterpriseConnectionId: string | null;
1618
__internal_toSnapshot: () => SamlAccountJSONSnapshot;
1719
}

0 commit comments

Comments
 (0)