|
1 | 1 | import type { ClerkResource } from './resource'; |
2 | 2 |
|
| 3 | +/** |
| 4 | + * Holds the verification details of an Organization's [Verified Domain](https://clerk.com/docs/guides/organizations/add-members/verified-domains). |
| 5 | + */ |
3 | 6 | export interface OrganizationDomainVerification { |
| 7 | + /** |
| 8 | + * The current status of the domain verification. |
| 9 | + */ |
4 | 10 | status: OrganizationDomainVerificationStatus; |
5 | | - strategy: 'email_code'; // only available value for now |
| 11 | + /** |
| 12 | + * The strategy used to verify the domain. |
| 13 | + */ |
| 14 | + strategy: OrganizationDomainVerificationStrategy; |
| 15 | + /** |
| 16 | + * The number of verification attempts that have been made. |
| 17 | + */ |
6 | 18 | attempts: number; |
| 19 | + /** |
| 20 | + * The date and time when the current verification attempt expires. |
| 21 | + */ |
7 | 22 | expiresAt: Date; |
8 | 23 | } |
9 | 24 |
|
| 25 | +/** @inline */ |
| 26 | +type OrganizationDomainVerificationStrategy = 'email_code'; |
| 27 | + |
10 | 28 | /** @inline */ |
11 | 29 | export type OrganizationDomainVerificationStatus = 'unverified' | 'verified'; |
12 | 30 |
|
13 | 31 | /** @inline */ |
14 | 32 | export type OrganizationEnrollmentMode = 'manual_invitation' | 'automatic_invitation' | 'automatic_suggestion'; |
15 | 33 |
|
16 | 34 | /** |
17 | | - * The `OrganizationDomain` object is the model around an organization domain. |
| 35 | + * The `OrganizationDomain` object is the model around an Organization's [Verified Domain](https://clerk.com/docs/guides/organizations/add-members/verified-domains). |
18 | 36 | * |
19 | 37 | * @interface |
20 | 38 | */ |
21 | 39 | export interface OrganizationDomainResource extends ClerkResource { |
| 40 | + /** |
| 41 | + * The unique identifier for the Verified Domain. |
| 42 | + */ |
22 | 43 | id: string; |
| 44 | + /** |
| 45 | + * The domain name, for example `clerk.com`. |
| 46 | + */ |
23 | 47 | name: string; |
| 48 | + /** |
| 49 | + * The ID of the Organization that the Verified Domain belongs to. |
| 50 | + */ |
24 | 51 | organizationId: string; |
| 52 | + /** |
| 53 | + * The enrollment mode that determines how matching users are added to the Organization. |
| 54 | + * |
| 55 | + * <ul> |
| 56 | + * <li>`manual_invitation`: No automatic enrollment. Users with a matching email domain are not given any [invitation](https://clerk.com/docs/guides/organizations/add-members/verified-domains#automatic-invitations) or [suggestion](https://clerk.com/docs/guides/organizations/add-members/verified-domains#automatic-suggestions); an admin must invite them manually.</li> |
| 57 | + * <li>`automatic_invitation`: Users with a matching email domain automatically receive a pending [invitation](https://clerk.com/docs/reference/types/organizationinvitation) (assigned the Organization's default role) which they can accept to join.</li> |
| 58 | + * <li>`automatic_suggestion`: Users with a matching email domain automatically receive a [suggestion](https://clerk.com/docs/guides/organizations/add-members/verified-domains#automatic-suggestions) to join, which they can request.</li> |
| 59 | + * </ul> |
| 60 | + */ |
25 | 61 | enrollmentMode: OrganizationEnrollmentMode; |
| 62 | + /** |
| 63 | + * The verification details for the domain, or `null` if the domain has not been verified. |
| 64 | + */ |
26 | 65 | verification: OrganizationDomainVerification | null; |
| 66 | + /** |
| 67 | + * The date and time when the domain was created. |
| 68 | + */ |
27 | 69 | createdAt: Date; |
| 70 | + /** |
| 71 | + * The date and time when the domain was last updated. |
| 72 | + */ |
28 | 73 | updatedAt: Date; |
| 74 | + /** |
| 75 | + * The email address used to verify the affiliation with the domain, or `null` if none has been provided. |
| 76 | + */ |
29 | 77 | affiliationEmailAddress: string | null; |
| 78 | + /** |
| 79 | + * The total number of pending [invitations](https://clerk.com/docs/reference/types/organizationinvitation) associated with this domain. |
| 80 | + */ |
30 | 81 | totalPendingInvitations: number; |
| 82 | + /** |
| 83 | + * The total number of pending [suggestions](https://clerk.com/docs/reference/types/organizationsuggestion) associated with this domain. |
| 84 | + */ |
31 | 85 | totalPendingSuggestions: number; |
| 86 | + /** |
| 87 | + * Begins the affiliation verification flow by sending a verification code to the provided email address. |
| 88 | + * |
| 89 | + * @param params - The parameters containing the affiliation email address to verify. |
| 90 | + * @returns A promise that resolves to the updated `OrganizationDomain` object. |
| 91 | + */ |
32 | 92 | prepareAffiliationVerification: (params: PrepareAffiliationVerificationParams) => Promise<OrganizationDomainResource>; |
33 | 93 |
|
| 94 | + /** |
| 95 | + * Completes the affiliation verification flow by validating the code sent to the affiliation email address. |
| 96 | + * |
| 97 | + * @param params - The parameters containing the verification code. |
| 98 | + * @returns A promise that resolves to the updated `OrganizationDomain` object. |
| 99 | + */ |
34 | 100 | attemptAffiliationVerification: (params: AttemptAffiliationVerificationParams) => Promise<OrganizationDomainResource>; |
| 101 | + /** |
| 102 | + * Deletes the Verified Domain. |
| 103 | + * |
| 104 | + * @returns A promise that resolves once the Verified Domain has been deleted. |
| 105 | + */ |
35 | 106 | delete: () => Promise<void>; |
| 107 | + /** |
| 108 | + * Updates the enrollment mode of the Verified Domain. |
| 109 | + * |
| 110 | + * @param params - The parameters containing the new enrollment mode and whether to delete pending invitations or suggestions. |
| 111 | + * @returns A promise that resolves to the updated `OrganizationDomain` object. |
| 112 | + */ |
36 | 113 | updateEnrollmentMode: (params: UpdateEnrollmentModeParams) => Promise<OrganizationDomainResource>; |
37 | 114 | } |
38 | 115 |
|
| 116 | +/** @generateWithEmptyComment */ |
39 | 117 | export type PrepareAffiliationVerificationParams = { |
| 118 | + /** |
| 119 | + * The email address, belonging to the domain, that the verification code is sent to. |
| 120 | + */ |
40 | 121 | affiliationEmailAddress: string; |
41 | 122 | }; |
42 | 123 |
|
| 124 | +/** @generateWithEmptyComment */ |
43 | 125 | export type AttemptAffiliationVerificationParams = { |
| 126 | + /** |
| 127 | + * The verification code that was sent to the affiliation email address. |
| 128 | + */ |
44 | 129 | code: string; |
45 | 130 | }; |
46 | 131 |
|
| 132 | +/** @generateWithEmptyComment */ |
47 | 133 | export type UpdateEnrollmentModeParams = Pick<OrganizationDomainResource, 'enrollmentMode'> & { |
| 134 | + /** |
| 135 | + * Whether to delete any pending [invitations](https://clerk.com/docs/reference/types/organizationinvitation) or [suggestions](https://clerk.com/docs/reference/types/organizationsuggestion) that were created by the previous enrollment mode. |
| 136 | + */ |
48 | 137 | deletePending?: boolean; |
49 | 138 | }; |
0 commit comments