-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(clerk-js,types): Surface enterprise accounts in
UserProfile
(#…
- Loading branch information
1 parent
1783025
commit 1c0b500
Showing
20 changed files
with
1,007 additions
and
152 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,6 @@ | ||
--- | ||
'@clerk/clerk-js': minor | ||
'@clerk/types': minor | ||
--- | ||
|
||
Surface enterprise accounts in `UserProfile`, allowing to display more protocols besides SAML |
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,98 @@ | ||
import type { | ||
EnterpriseAccountConnectionJSON, | ||
EnterpriseAccountConnectionResource, | ||
EnterpriseAccountJSON, | ||
EnterpriseAccountResource, | ||
VerificationResource, | ||
} from '@clerk/types'; | ||
|
||
import { unixEpochToDate } from '../../utils/date'; | ||
import { BaseResource } from './Base'; | ||
import { Verification } from './Verification'; | ||
|
||
export class EnterpriseAccount extends BaseResource implements EnterpriseAccountResource { | ||
id!: string; | ||
protocol!: EnterpriseAccountResource['protocol']; | ||
provider!: EnterpriseAccountResource['provider']; | ||
providerUserId: string | null = null; | ||
active!: boolean; | ||
emailAddress = ''; | ||
firstName: string | null = ''; | ||
lastName: string | null = ''; | ||
publicMetadata = {}; | ||
verification: VerificationResource | null = null; | ||
enterpriseConnection: EnterpriseAccountConnectionResource | null = null; | ||
|
||
public constructor(data: Partial<EnterpriseAccountJSON>, pathRoot: string); | ||
public constructor(data: EnterpriseAccountJSON, pathRoot: string) { | ||
super(); | ||
this.pathRoot = pathRoot; | ||
this.fromJSON(data); | ||
} | ||
|
||
protected fromJSON(data: EnterpriseAccountJSON | null): this { | ||
if (!data) { | ||
return this; | ||
} | ||
|
||
this.id = data.id; | ||
this.provider = data.provider; | ||
this.protocol = data.protocol; | ||
this.providerUserId = data.provider_user_id; | ||
this.active = data.active; | ||
this.emailAddress = data.email_address; | ||
this.firstName = data.first_name; | ||
this.lastName = data.last_name; | ||
this.publicMetadata = data.public_metadata; | ||
|
||
if (data.verification) { | ||
this.verification = new Verification(data.verification); | ||
} | ||
|
||
if (data.enterprise_connection) { | ||
this.enterpriseConnection = new EnterpriseAccountConnection(data.enterprise_connection); | ||
} | ||
|
||
return this; | ||
} | ||
} | ||
|
||
export class EnterpriseAccountConnection extends BaseResource implements EnterpriseAccountConnectionResource { | ||
id!: string; | ||
active!: boolean; | ||
allowIdpInitiated!: boolean; | ||
allowSubdomains!: boolean; | ||
disableAdditionalIdentifications!: boolean; | ||
domain!: string; | ||
logoPublicUrl: string | null = ''; | ||
name!: string; | ||
protocol!: EnterpriseAccountResource['protocol']; | ||
provider!: EnterpriseAccountResource['provider']; | ||
syncUserAttributes!: boolean; | ||
createdAt!: Date; | ||
updatedAt!: Date; | ||
|
||
constructor(data: EnterpriseAccountConnectionJSON | null) { | ||
super(); | ||
this.fromJSON(data); | ||
} | ||
|
||
protected fromJSON(data: EnterpriseAccountConnectionJSON | null): this { | ||
if (data) { | ||
this.id = data.id; | ||
this.name = data.name; | ||
this.domain = data.domain; | ||
this.active = data.active; | ||
this.provider = data.provider; | ||
this.logoPublicUrl = data.logo_public_url; | ||
this.syncUserAttributes = data.sync_user_attributes; | ||
this.allowSubdomains = data.allow_subdomains; | ||
this.allowIdpInitiated = data.allow_idp_initiated; | ||
this.disableAdditionalIdentifications = data.disable_additional_identifications; | ||
this.createdAt = unixEpochToDate(data.created_at); | ||
this.updatedAt = unixEpochToDate(data.updated_at); | ||
} | ||
|
||
return this; | ||
} | ||
} |
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
Oops, something went wrong.