@finueva/auth 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -22
- package/dist/device.d.ts +3 -2
- package/dist/device.js +46 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +88 -0
- package/dist/server.d.ts +32 -2
- package/dist/server.js +238 -27
- package/dist/{types-CqFT4G95.d.ts → types-CrdIcEJ3.d.ts} +16 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,28 +94,31 @@ The browser owns the session cookie. The SDK does not expose or persist it.
|
|
|
94
94
|
|
|
95
95
|
## Common Tasks
|
|
96
96
|
|
|
97
|
-
| Task
|
|
98
|
-
|
|
|
99
|
-
| Create an account
|
|
100
|
-
| Read the current session
|
|
101
|
-
| Observe session state
|
|
102
|
-
| Update a profile
|
|
103
|
-
| Change a password
|
|
104
|
-
| Reset a password
|
|
105
|
-
| Verify an email
|
|
106
|
-
| List organizations
|
|
107
|
-
| Read member authority
|
|
108
|
-
| Create an ordinary
|
|
109
|
-
|
|
|
110
|
-
|
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
|
118
|
-
|
|
|
97
|
+
| Task | Browser | Server | Device |
|
|
98
|
+
| ------------------------------- | ------------------------------------------- | ----------------------------------------- | -------------------------------------- |
|
|
99
|
+
| Create an account | `signUp()` | Not available | `signUpWithEmail()` |
|
|
100
|
+
| Read the current session | `getSession()` | `getSession()` | `getSession()` |
|
|
101
|
+
| Observe session state | `onAuthStateChange()` | Not available | Not available |
|
|
102
|
+
| Update a profile | `updateProfile()` | Not available | `updateProfile()` |
|
|
103
|
+
| Change a password | `changePassword()` | Not available | `changePassword()` |
|
|
104
|
+
| Reset a password | `requestPasswordReset()`, `resetPassword()` | Not available | Not available |
|
|
105
|
+
| Verify an email | `sendVerificationEmail()` | Not available | Not available |
|
|
106
|
+
| List organizations | `listOrganizations()` | `listOrganizations()` | `listOrganizations()` |
|
|
107
|
+
| Read member authority | `getOrganizationMemberAuthority()` | `getOrganizationMemberAuthority()` | `getOrganizationMemberAuthority()` |
|
|
108
|
+
| Create an ordinary organization | `createOrganization()` | `createOrganization()` | `createOrganization()` |
|
|
109
|
+
| Create an ordinary team | `createOrganizationTeam()` | `createOrganizationTeam()` | `createOrganizationTeam()` |
|
|
110
|
+
| Invite an ordinary member | `createOrganizationMemberInvitation()` | `createOrganizationMemberInvitation()` | `createOrganizationMemberInvitation()` |
|
|
111
|
+
| Resend a member invitation | `resendOrganizationInvitation()` | `resendOrganizationInvitation()` (cookie) | Not available |
|
|
112
|
+
| Cancel a member invitation | `cancelOrganizationInvitation()` | `cancelOrganizationInvitation()` (cookie) | Not available |
|
|
113
|
+
| Remove an ordinary member | `removeOrganizationMember()` | `removeOrganizationMember()` (cookie) | Not available |
|
|
114
|
+
| Leave an organization | `leaveOrganization()` | `leaveOrganization()` (cookie) | Not available |
|
|
115
|
+
| Accept an invitation | `acceptInvitation()` | `acceptInvitation()` | Not available |
|
|
116
|
+
| Enroll a passkey | `addPasskey()` | Not available | Not available |
|
|
117
|
+
| Perform recent authentication | Platform and organization action methods | Not available | Not available |
|
|
118
|
+
| Change manual roles or owners | Organization authority methods | Not available | Not available |
|
|
119
|
+
| Read current platform roles | `getPlatformStatus()` | Not available | Not available |
|
|
120
|
+
| Request Drive access | `getDriveCredential()` | `getDriveCredential()` | `getDriveCredential()` |
|
|
121
|
+
| End the current session | `signOut()` | `signOut()` | `revokeCurrentDevice()` |
|
|
119
122
|
|
|
120
123
|
## Create An Organization Invitation
|
|
121
124
|
|
|
@@ -142,6 +145,17 @@ const canceled = await auth.cancelOrganizationInvitation(organizationId, invitat
|
|
|
142
145
|
|
|
143
146
|
Resend success confirms the committed expiry. It does not confirm email delivery. Repeat an action with the same key only after a lost response. A bearer-backed server client rejects both methods before network I/O.
|
|
144
147
|
|
|
148
|
+
## Remove An Organization Member
|
|
149
|
+
|
|
150
|
+
Manual owners and manual administrators remove one other member. Every current member can leave. Both operations use browser-cookie or server-cookie authority:
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
const removed = await auth.removeOrganizationMember(organizationId, memberId, crypto.randomUUID());
|
|
154
|
+
const left = await auth.leaveOrganization(organizationId, crypto.randomUUID());
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
An owner target is refused. Transfer ownership first. Repeat a removal with the same key only after a lost response; a membership that is already gone under that key replays the same result. A bearer-backed server client rejects both methods before network I/O.
|
|
158
|
+
|
|
145
159
|
## Perform Recent Authentication
|
|
146
160
|
|
|
147
161
|
The experimental passkey methods run only when the browser page uses the exact Auth Origin. To enroll a passkey, first create a new password-authenticated session on that origin:
|
package/dist/device.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as AuthError, A as OrganizationTeamPage, B as ReceivedOrganizationInvitation, C as OrganizationMemberAuthority, D as OrganizationTeam, E as OrganizationPageInput, J as SocialIdTokenProvider, O as OrganizationTeamDisplay, S as OrganizationMember, T as OrganizationPage, V as ReceivedOrganizationInvitationPage, X as UpdateOrganizationTeamDisplayInput, Y as UpdateOrganizationDisplayInput, Z as UpdateProfileInput, b as OrganizationInvitation, d as CreatedOrganization, et as AuthErrorCode, f as CreatedOrganizationMemberInvitation, h as DriveCredentialInput, k as OrganizationTeamMemberPage, m as DriveCredential, nt as UserApiCredential, o as AuthSession, p as CreatedOrganizationTeam, q as SocialIdTokenInput, r as AuthOrganization, rt as UserApiCredentialInput, tt as AuthErrorStatus, u as CreateOrganizationMemberInvitationInput, w as OrganizationMemberPage, x as OrganizationInvitationPage, y as OrganizationDisplay } from "./types-CrdIcEJ3.js";
|
|
2
2
|
//#region src/device.d.ts
|
|
3
3
|
type DeviceAuthorizationErrorCode = "device_access_denied" | "device_authorization_cancelled" | "device_code_expired" | "invalid_device_authorization" | "identity_authority_unavailable";
|
|
4
4
|
declare class DeviceAuthorizationError extends Error {
|
|
@@ -46,6 +46,7 @@ interface DeviceAuthClient {
|
|
|
46
46
|
listOrganizations(input?: OrganizationPageInput): Promise<OrganizationPage>;
|
|
47
47
|
getOrganization(organizationId: string): Promise<AuthOrganization>;
|
|
48
48
|
getOrganizationMemberAuthority(organizationId: string, memberId: string): Promise<OrganizationMemberAuthority>;
|
|
49
|
+
createOrganization(name: string, slug: string, idempotencyKey: string): Promise<CreatedOrganization>;
|
|
49
50
|
createOrganizationTeam(organizationId: string, name: string, idempotencyKey: string): Promise<CreatedOrganizationTeam>;
|
|
50
51
|
createOrganizationMemberInvitation(organizationId: string, input: CreateOrganizationMemberInvitationInput): Promise<CreatedOrganizationMemberInvitation>;
|
|
51
52
|
updateOrganizationDisplay(organizationId: string, input: UpdateOrganizationDisplayInput): Promise<OrganizationDisplay>;
|
|
@@ -70,4 +71,4 @@ interface DeviceAuthClient {
|
|
|
70
71
|
}
|
|
71
72
|
declare function createDeviceAuth(options: DeviceAuthOptions): DeviceAuthClient;
|
|
72
73
|
//#endregion
|
|
73
|
-
export { AuthError, type AuthErrorCode, type AuthErrorStatus, type AuthOrganization, type CreateOrganizationMemberInvitationInput, type CreatedOrganizationMemberInvitation, type CreatedOrganizationTeam, DeviceAuthClient, DeviceAuthOptions, DeviceAuthorization, DeviceAuthorizationError, DeviceAuthorizationErrorCode, DeviceToken, DeviceTokenPersistence, type OrganizationDisplay, type OrganizationInvitation, type OrganizationInvitationPage, type OrganizationMember, type OrganizationMemberAuthority, type OrganizationMemberPage, type OrganizationPage, type OrganizationPageInput, type OrganizationTeam, type OrganizationTeamDisplay, type OrganizationTeamMemberPage, type OrganizationTeamPage, PollDeviceOptions, type ReceivedOrganizationInvitation, type ReceivedOrganizationInvitationPage, type SocialIdTokenInput, type SocialIdTokenProvider, type UpdateOrganizationDisplayInput, type UpdateOrganizationTeamDisplayInput, type UserApiCredential, type UserApiCredentialInput, createDeviceAuth };
|
|
74
|
+
export { AuthError, type AuthErrorCode, type AuthErrorStatus, type AuthOrganization, type CreateOrganizationMemberInvitationInput, type CreatedOrganization, type CreatedOrganizationMemberInvitation, type CreatedOrganizationTeam, DeviceAuthClient, DeviceAuthOptions, DeviceAuthorization, DeviceAuthorizationError, DeviceAuthorizationErrorCode, DeviceToken, DeviceTokenPersistence, type OrganizationDisplay, type OrganizationInvitation, type OrganizationInvitationPage, type OrganizationMember, type OrganizationMemberAuthority, type OrganizationMemberPage, type OrganizationPage, type OrganizationPageInput, type OrganizationTeam, type OrganizationTeamDisplay, type OrganizationTeamMemberPage, type OrganizationTeamPage, PollDeviceOptions, type ReceivedOrganizationInvitation, type ReceivedOrganizationInvitationPage, type SocialIdTokenInput, type SocialIdTokenProvider, type UpdateOrganizationDisplayInput, type UpdateOrganizationTeamDisplayInput, type UserApiCredential, type UserApiCredentialInput, createDeviceAuth };
|
package/dist/device.js
CHANGED
|
@@ -187,6 +187,7 @@ const messages = {
|
|
|
187
187
|
recipient_unavailable: "The recipient is unavailable.",
|
|
188
188
|
invitation_recipient_mismatch: "The invitation cannot be accepted by this account.",
|
|
189
189
|
invitation_recovery_required: "Invitation administration requires separate recovery.",
|
|
190
|
+
membership_removal_recovery_required: "Membership removal requires separate recovery.",
|
|
190
191
|
email_verification_required: "Email verification is required.",
|
|
191
192
|
invalid_workspace_selection: "The workspace selection is invalid.",
|
|
192
193
|
organization_context_too_large: "The organization context is too large.",
|
|
@@ -716,6 +717,27 @@ function normalizeOrganizationTeamDisplay(value) {
|
|
|
716
717
|
throw authorityUnavailable();
|
|
717
718
|
}
|
|
718
719
|
}
|
|
720
|
+
function normalizeOrganizationCreationInput(name, slug, idempotencyKey) {
|
|
721
|
+
if (!boundedString(name, 255) || !boundedString(idempotencyKey, 255) || typeof slug !== "string" || !/^[a-z0-9-]{1,128}$/.test(slug)) throw new AuthError("invalid_request", 400);
|
|
722
|
+
return {
|
|
723
|
+
name,
|
|
724
|
+
slug,
|
|
725
|
+
idempotencyKey
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
function normalizeCreatedOrganization(value) {
|
|
729
|
+
exact(value, [
|
|
730
|
+
"id",
|
|
731
|
+
"name",
|
|
732
|
+
"slug"
|
|
733
|
+
]);
|
|
734
|
+
if (!isId(value.id) || !boundedString(value.name, 255) || !boundedString(value.slug, 128)) throw authorityUnavailable();
|
|
735
|
+
return {
|
|
736
|
+
id: value.id,
|
|
737
|
+
name: value.name,
|
|
738
|
+
slug: value.slug
|
|
739
|
+
};
|
|
740
|
+
}
|
|
719
741
|
function normalizeOrganizationTeamCreationInput(name, idempotencyKey) {
|
|
720
742
|
if (!boundedString(name, 255) || !boundedString(idempotencyKey, 255)) throw new AuthError("invalid_request", 400);
|
|
721
743
|
return {
|
|
@@ -1595,6 +1617,30 @@ function createDeviceAuth(options) {
|
|
|
1595
1617
|
const member = normalizeIdInput(memberId);
|
|
1596
1618
|
return serializeAuthority(() => organizationRead(`${organization}/members/${member}/authority`, void 0, (value) => normalizeOrganizationMemberAuthority(value, organization, member)));
|
|
1597
1619
|
},
|
|
1620
|
+
createOrganization(name, slug, idempotencyKey) {
|
|
1621
|
+
let body;
|
|
1622
|
+
try {
|
|
1623
|
+
body = normalizeOrganizationCreationInput(name, slug, idempotencyKey);
|
|
1624
|
+
} catch (error) {
|
|
1625
|
+
return Promise.reject(error);
|
|
1626
|
+
}
|
|
1627
|
+
return serializeAuthority(async () => {
|
|
1628
|
+
const current = await readToken();
|
|
1629
|
+
if (!current) throw new AuthError("authentication_required", 401);
|
|
1630
|
+
return normalizeCreatedOrganization((await requestJsonResponse(joinURL(authOrigin, "api/v1/auth/organizations"), {
|
|
1631
|
+
fetch: requestFetch,
|
|
1632
|
+
timeoutMs,
|
|
1633
|
+
method: "POST",
|
|
1634
|
+
credentials: "omit",
|
|
1635
|
+
headers: {
|
|
1636
|
+
authorization: `Bearer ${current.accessToken}`,
|
|
1637
|
+
"content-type": "application/json"
|
|
1638
|
+
},
|
|
1639
|
+
body,
|
|
1640
|
+
mapError: fromOrganizationMutationAuthorityError
|
|
1641
|
+
})).value);
|
|
1642
|
+
});
|
|
1643
|
+
},
|
|
1598
1644
|
createOrganizationTeam(organizationId, name, idempotencyKey) {
|
|
1599
1645
|
let id;
|
|
1600
1646
|
let body;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as AuthError, A as OrganizationTeamPage, B as ReceivedOrganizationInvitation, C as OrganizationMemberAuthority, D as OrganizationTeam, E as OrganizationPageInput, F as PlatformRoleApplied, G as SendVerificationEmailInput, H as RecentAuthenticationStatus, I as PlatformRoleApproval, J as SocialIdTokenProvider, K as SignInInput, L as PlatformRoleChangeRecentAuthenticationInput, M as PersonalWorkspaceSelection, N as PlatformBootstrapRoleChangeInput, O as OrganizationTeamDisplay, P as PlatformRole, Q as WorkspaceSelection, R as PlatformRoleFirstApproval, S as OrganizationMember, T as OrganizationPage, U as RemovedOrganizationMember, V as ReceivedOrganizationInvitationPage, W as ResentOrganizationInvitation, X as UpdateOrganizationTeamDisplayInput, Y as UpdateOrganizationDisplayInput, Z as UpdateProfileInput, _ as InvitationAcceptance, a as AuthPersistenceDriver, b as OrganizationInvitation, c as AuthUser, d as CreatedOrganization, et as AuthErrorCode, f as CreatedOrganizationMemberInvitation, g as FinuevaAuthClient, h as DriveCredentialInput, i as AuthPersistence, j as OrganizationWorkspaceSelection, k as OrganizationTeamMemberPage, l as CanceledOrganizationInvitation, m as DriveCredential, n as AuthClientOptions, nt as UserApiCredential, o as AuthSession, p as CreatedOrganizationTeam, q as SocialIdTokenInput, r as AuthOrganization, rt as UserApiCredentialInput, s as AuthState, t as AcceptInvitationInput, tt as AuthErrorStatus, u as CreateOrganizationMemberInvitationInput, v as OrganizationDeparture, w as OrganizationMemberPage, x as OrganizationInvitationPage, y as OrganizationDisplay, z as PlatformStatus } from "./types-CrdIcEJ3.js";
|
|
2
2
|
//#region src/client.d.ts
|
|
3
3
|
declare function createAuthClient(options: AuthClientOptions): FinuevaAuthClient;
|
|
4
4
|
//#endregion
|
|
5
|
-
export { type AcceptInvitationInput, type AuthClientOptions, AuthError, type AuthErrorCode, type AuthErrorStatus, type AuthOrganization, type AuthPersistence, type AuthPersistenceDriver, type AuthSession, type AuthState, type AuthUser, type CanceledOrganizationInvitation, type CreateOrganizationMemberInvitationInput, type CreatedOrganizationMemberInvitation, type CreatedOrganizationTeam, type DriveCredential, type DriveCredentialInput, type FinuevaAuthClient, type InvitationAcceptance, type OrganizationDisplay, type OrganizationInvitation, type OrganizationInvitationPage, type OrganizationMember, type OrganizationMemberAuthority, type OrganizationMemberPage, type OrganizationPage, type OrganizationPageInput, type OrganizationTeam, type OrganizationTeamDisplay, type OrganizationTeamMemberPage, type OrganizationTeamPage, type OrganizationWorkspaceSelection, type PersonalWorkspaceSelection, type PlatformBootstrapRoleChangeInput, type PlatformRole, type PlatformRoleApplied, type PlatformRoleApproval, type PlatformRoleChangeRecentAuthenticationInput, type PlatformRoleFirstApproval, type PlatformStatus, type ReceivedOrganizationInvitation, type ReceivedOrganizationInvitationPage, type RecentAuthenticationStatus, type ResentOrganizationInvitation, type SendVerificationEmailInput, type SignInInput, type SocialIdTokenInput, type SocialIdTokenProvider, type UpdateOrganizationDisplayInput, type UpdateOrganizationTeamDisplayInput, type UpdateProfileInput, type UserApiCredential, type UserApiCredentialInput, type WorkspaceSelection, createAuthClient };
|
|
5
|
+
export { type AcceptInvitationInput, type AuthClientOptions, AuthError, type AuthErrorCode, type AuthErrorStatus, type AuthOrganization, type AuthPersistence, type AuthPersistenceDriver, type AuthSession, type AuthState, type AuthUser, type CanceledOrganizationInvitation, type CreateOrganizationMemberInvitationInput, type CreatedOrganization, type CreatedOrganizationMemberInvitation, type CreatedOrganizationTeam, type DriveCredential, type DriveCredentialInput, type FinuevaAuthClient, type InvitationAcceptance, type OrganizationDeparture, type OrganizationDisplay, type OrganizationInvitation, type OrganizationInvitationPage, type OrganizationMember, type OrganizationMemberAuthority, type OrganizationMemberPage, type OrganizationPage, type OrganizationPageInput, type OrganizationTeam, type OrganizationTeamDisplay, type OrganizationTeamMemberPage, type OrganizationTeamPage, type OrganizationWorkspaceSelection, type PersonalWorkspaceSelection, type PlatformBootstrapRoleChangeInput, type PlatformRole, type PlatformRoleApplied, type PlatformRoleApproval, type PlatformRoleChangeRecentAuthenticationInput, type PlatformRoleFirstApproval, type PlatformStatus, type ReceivedOrganizationInvitation, type ReceivedOrganizationInvitationPage, type RecentAuthenticationStatus, type RemovedOrganizationMember, type ResentOrganizationInvitation, type SendVerificationEmailInput, type SignInInput, type SocialIdTokenInput, type SocialIdTokenProvider, type UpdateOrganizationDisplayInput, type UpdateOrganizationTeamDisplayInput, type UpdateProfileInput, type UserApiCredential, type UserApiCredentialInput, type WorkspaceSelection, createAuthClient };
|
package/dist/index.js
CHANGED
|
@@ -2546,6 +2546,7 @@ const messages = {
|
|
|
2546
2546
|
recipient_unavailable: "The recipient is unavailable.",
|
|
2547
2547
|
invitation_recipient_mismatch: "The invitation cannot be accepted by this account.",
|
|
2548
2548
|
invitation_recovery_required: "Invitation administration requires separate recovery.",
|
|
2549
|
+
membership_removal_recovery_required: "Membership removal requires separate recovery.",
|
|
2549
2550
|
email_verification_required: "Email verification is required.",
|
|
2550
2551
|
invalid_workspace_selection: "The workspace selection is invalid.",
|
|
2551
2552
|
organization_context_too_large: "The organization context is too large.",
|
|
@@ -3027,6 +3028,27 @@ function normalizeOrganizationTeamDisplay(value) {
|
|
|
3027
3028
|
throw authorityUnavailable();
|
|
3028
3029
|
}
|
|
3029
3030
|
}
|
|
3031
|
+
function normalizeOrganizationCreationInput(name, slug, idempotencyKey) {
|
|
3032
|
+
if (!boundedString(name, 255) || !boundedString(idempotencyKey, 255) || typeof slug !== "string" || !/^[a-z0-9-]{1,128}$/.test(slug)) throw new AuthError("invalid_request", 400);
|
|
3033
|
+
return {
|
|
3034
|
+
name,
|
|
3035
|
+
slug,
|
|
3036
|
+
idempotencyKey
|
|
3037
|
+
};
|
|
3038
|
+
}
|
|
3039
|
+
function normalizeCreatedOrganization(value) {
|
|
3040
|
+
exact(value, [
|
|
3041
|
+
"id",
|
|
3042
|
+
"name",
|
|
3043
|
+
"slug"
|
|
3044
|
+
]);
|
|
3045
|
+
if (!isId(value.id) || !boundedString(value.name, 255) || !boundedString(value.slug, 128)) throw authorityUnavailable();
|
|
3046
|
+
return {
|
|
3047
|
+
id: value.id,
|
|
3048
|
+
name: value.name,
|
|
3049
|
+
slug: value.slug
|
|
3050
|
+
};
|
|
3051
|
+
}
|
|
3030
3052
|
function normalizeOrganizationTeamCreationInput(name, idempotencyKey) {
|
|
3031
3053
|
if (!boundedString(name, 255) || !boundedString(idempotencyKey, 255)) throw new AuthError("invalid_request", 400);
|
|
3032
3054
|
return {
|
|
@@ -3083,6 +3105,20 @@ function normalizeCanceledOrganizationInvitation(value) {
|
|
|
3083
3105
|
if (value.status !== "canceled") throw authorityUnavailable();
|
|
3084
3106
|
return { status: "canceled" };
|
|
3085
3107
|
}
|
|
3108
|
+
function normalizeOrganizationMembershipRemovalInput(idempotencyKey) {
|
|
3109
|
+
if (!boundedString(idempotencyKey, 255)) throw new AuthError("invalid_request", 400);
|
|
3110
|
+
return { idempotencyKey };
|
|
3111
|
+
}
|
|
3112
|
+
function normalizeRemovedOrganizationMember(value) {
|
|
3113
|
+
exact(value, ["status"]);
|
|
3114
|
+
if (value.status !== "removed") throw authorityUnavailable();
|
|
3115
|
+
return { status: "removed" };
|
|
3116
|
+
}
|
|
3117
|
+
function normalizeOrganizationDeparture(value) {
|
|
3118
|
+
exact(value, ["status"]);
|
|
3119
|
+
if (value.status !== "left") throw authorityUnavailable();
|
|
3120
|
+
return { status: "left" };
|
|
3121
|
+
}
|
|
3086
3122
|
function normalizeOrganizations(value) {
|
|
3087
3123
|
exact(value, ["nextCursor", "organizations"]);
|
|
3088
3124
|
if (!Array.isArray(value.organizations) || value.organizations.length > 100) throw authorityUnavailable();
|
|
@@ -3318,6 +3354,10 @@ function fromOrganizationInvitationAdministrationError(value, status, retryAfter
|
|
|
3318
3354
|
if (status === 422 && isObject(value) && value.code === "RECOVERY_REQUIRED") return new AuthError("invitation_recovery_required", 422);
|
|
3319
3355
|
return fromOrganizationMutationAuthorityError(value, status, retryAfter);
|
|
3320
3356
|
}
|
|
3357
|
+
function fromOrganizationMembershipRemovalError(value, status, retryAfter) {
|
|
3358
|
+
if (status === 422 && isObject(value) && value.code === "RECOVERY_REQUIRED") return new AuthError("membership_removal_recovery_required", 422);
|
|
3359
|
+
return fromOrganizationMutationAuthorityError(value, status, retryAfter);
|
|
3360
|
+
}
|
|
3321
3361
|
function normalizePlatformRoleChangeRecentAuthenticationInput(value) {
|
|
3322
3362
|
if (!isObject(value) || Object.keys(value).sort().join(",") !== "changeReference,expectedGlobalRevision,expectedTargetRevision,idempotencyKey,reasonCategory,requestedRoles,targetUserId") throw new TypeError("recent authentication input is invalid");
|
|
3323
3363
|
if (!isId(value.targetUserId)) throw new TypeError("targetUserId is invalid");
|
|
@@ -5049,6 +5089,21 @@ function createAuthClient(options) {
|
|
|
5049
5089
|
const member = normalizeIdInput(memberId);
|
|
5050
5090
|
return organizationRead(`${organization}/members/${member}/authority`, void 0, (value) => normalizeOrganizationMemberAuthority(value, organization, member));
|
|
5051
5091
|
},
|
|
5092
|
+
async createOrganization(name, slug, idempotencyKey) {
|
|
5093
|
+
const body = normalizeOrganizationCreationInput(name, slug, idempotencyKey);
|
|
5094
|
+
if (signOutRequest || activeAccountMutationGeneration !== void 0 || invitationRequest) throw new AuthError("state_conflict", 409);
|
|
5095
|
+
const generation = authorityGeneration;
|
|
5096
|
+
const value = await requestJson(joinURL(authOrigin, "api/v1/auth/organizations"), {
|
|
5097
|
+
fetch: fetchImpl,
|
|
5098
|
+
timeoutMs,
|
|
5099
|
+
method: "POST",
|
|
5100
|
+
headers: { "content-type": "application/json" },
|
|
5101
|
+
body,
|
|
5102
|
+
mapError: fromOrganizationMutationAuthorityError
|
|
5103
|
+
});
|
|
5104
|
+
if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
|
|
5105
|
+
return normalizeCreatedOrganization(value);
|
|
5106
|
+
},
|
|
5052
5107
|
async createOrganizationTeam(organizationId, name, idempotencyKey) {
|
|
5053
5108
|
const id = normalizeIdInput(organizationId);
|
|
5054
5109
|
const body = normalizeOrganizationTeamCreationInput(name, idempotencyKey);
|
|
@@ -5115,6 +5170,39 @@ function createAuthClient(options) {
|
|
|
5115
5170
|
if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
|
|
5116
5171
|
return normalizeCanceledOrganizationInvitation(value);
|
|
5117
5172
|
},
|
|
5173
|
+
async removeOrganizationMember(organizationId, memberId, idempotencyKey) {
|
|
5174
|
+
const organization = normalizeIdInput(organizationId);
|
|
5175
|
+
const member = normalizeIdInput(memberId);
|
|
5176
|
+
const body = normalizeOrganizationMembershipRemovalInput(idempotencyKey);
|
|
5177
|
+
if (signOutRequest || activeAccountMutationGeneration !== void 0 || invitationRequest) throw new AuthError("state_conflict", 409);
|
|
5178
|
+
const generation = authorityGeneration;
|
|
5179
|
+
const value = await requestJson(joinURL(authOrigin, "api/v1/auth/organizations", organization, "members", member, "remove"), {
|
|
5180
|
+
fetch: fetchImpl,
|
|
5181
|
+
timeoutMs,
|
|
5182
|
+
method: "POST",
|
|
5183
|
+
headers: { "content-type": "application/json" },
|
|
5184
|
+
body,
|
|
5185
|
+
mapError: fromOrganizationMembershipRemovalError
|
|
5186
|
+
});
|
|
5187
|
+
if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
|
|
5188
|
+
return normalizeRemovedOrganizationMember(value);
|
|
5189
|
+
},
|
|
5190
|
+
async leaveOrganization(organizationId, idempotencyKey) {
|
|
5191
|
+
const organization = normalizeIdInput(organizationId);
|
|
5192
|
+
const body = normalizeOrganizationMembershipRemovalInput(idempotencyKey);
|
|
5193
|
+
if (signOutRequest || activeAccountMutationGeneration !== void 0 || invitationRequest) throw new AuthError("state_conflict", 409);
|
|
5194
|
+
const generation = authorityGeneration;
|
|
5195
|
+
const value = await requestJson(joinURL(authOrigin, "api/v1/auth/organizations", organization, "leave"), {
|
|
5196
|
+
fetch: fetchImpl,
|
|
5197
|
+
timeoutMs,
|
|
5198
|
+
method: "POST",
|
|
5199
|
+
headers: { "content-type": "application/json" },
|
|
5200
|
+
body,
|
|
5201
|
+
mapError: fromOrganizationMembershipRemovalError
|
|
5202
|
+
});
|
|
5203
|
+
if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
|
|
5204
|
+
return normalizeOrganizationDeparture(value);
|
|
5205
|
+
},
|
|
5118
5206
|
async updateOrganizationDisplay(organizationId, input) {
|
|
5119
5207
|
const id = normalizeIdInput(organizationId);
|
|
5120
5208
|
const desired = normalizeOrganizationDisplayInput(input);
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as AuthError, A as OrganizationTeamPage, B as ReceivedOrganizationInvitation, C as OrganizationMemberAuthority, D as OrganizationTeam, E as OrganizationPageInput, J as SocialIdTokenProvider, M as PersonalWorkspaceSelection, O as OrganizationTeamDisplay, Q as WorkspaceSelection, S as OrganizationMember, T as OrganizationPage, U as RemovedOrganizationMember, V as ReceivedOrganizationInvitationPage, W as ResentOrganizationInvitation, X as UpdateOrganizationTeamDisplayInput, Y as UpdateOrganizationDisplayInput, _ as InvitationAcceptance, b as OrganizationInvitation, c as AuthUser, d as CreatedOrganization, et as AuthErrorCode, f as CreatedOrganizationMemberInvitation, h as DriveCredentialInput, j as OrganizationWorkspaceSelection, k as OrganizationTeamMemberPage, l as CanceledOrganizationInvitation, m as DriveCredential, nt as UserApiCredential, o as AuthSession, p as CreatedOrganizationTeam, q as SocialIdTokenInput, r as AuthOrganization, rt as UserApiCredentialInput, t as AcceptInvitationInput, tt as AuthErrorStatus, u as CreateOrganizationMemberInvitationInput, v as OrganizationDeparture, w as OrganizationMemberPage, x as OrganizationInvitationPage, y as OrganizationDisplay } from "./types-CrdIcEJ3.js";
|
|
2
2
|
//#region src/user-api/verifier.d.ts
|
|
3
3
|
interface UserApiIdentity {
|
|
4
4
|
userId: string;
|
|
@@ -40,6 +40,33 @@ interface FinuevaIdentityResolverAuth {
|
|
|
40
40
|
/** Server-only identity resolution. Keep results private; they grant no product authority. */
|
|
41
41
|
declare function createIdentityResolverAuth(options: IdentityResolverAuthOptions): FinuevaIdentityResolverAuth;
|
|
42
42
|
//#endregion
|
|
43
|
+
//#region src/membership-resolution.d.ts
|
|
44
|
+
interface MembershipResolverAuthOptions {
|
|
45
|
+
authOrigin: string;
|
|
46
|
+
fetch?: typeof globalThis.fetch;
|
|
47
|
+
timeoutMs?: number;
|
|
48
|
+
}
|
|
49
|
+
interface ResolveMembershipInput {
|
|
50
|
+
organizationId: string;
|
|
51
|
+
userId: string;
|
|
52
|
+
}
|
|
53
|
+
type ResolvedMembershipRole = "admin" | "member" | "owner";
|
|
54
|
+
interface ResolvedMembership {
|
|
55
|
+
checkedAt: string;
|
|
56
|
+
manualRole: ResolvedMembershipRole;
|
|
57
|
+
memberCount: number;
|
|
58
|
+
memberId: string;
|
|
59
|
+
organizationId: string;
|
|
60
|
+
owner: boolean;
|
|
61
|
+
role: ResolvedMembershipRole;
|
|
62
|
+
userId: string;
|
|
63
|
+
}
|
|
64
|
+
interface FinuevaMembershipResolverAuth {
|
|
65
|
+
resolveMembership(input: ResolveMembershipInput, clientAssertion: string): Promise<ResolvedMembership | null>;
|
|
66
|
+
}
|
|
67
|
+
/** Server-only organization membership resolution. Keep results private; they are Auth authority, not product authority. */
|
|
68
|
+
declare function createMembershipResolverAuth(options: MembershipResolverAuthOptions): FinuevaMembershipResolverAuth;
|
|
69
|
+
//#endregion
|
|
43
70
|
//#region src/drive-recipients.d.ts
|
|
44
71
|
interface DriveRecipientAuthOptions {
|
|
45
72
|
authOrigin: string;
|
|
@@ -102,10 +129,13 @@ interface FinuevaServerAuth {
|
|
|
102
129
|
listOrganizations(input?: OrganizationPageInput): Promise<OrganizationPage>;
|
|
103
130
|
getOrganization(organizationId: string): Promise<AuthOrganization>;
|
|
104
131
|
getOrganizationMemberAuthority(organizationId: string, memberId: string): Promise<OrganizationMemberAuthority>;
|
|
132
|
+
createOrganization(name: string, slug: string, idempotencyKey: string): Promise<CreatedOrganization>;
|
|
105
133
|
createOrganizationTeam(organizationId: string, name: string, idempotencyKey: string): Promise<CreatedOrganizationTeam>;
|
|
106
134
|
createOrganizationMemberInvitation(organizationId: string, input: CreateOrganizationMemberInvitationInput): Promise<CreatedOrganizationMemberInvitation>;
|
|
107
135
|
resendOrganizationInvitation(organizationId: string, invitationId: string, idempotencyKey: string): Promise<ResentOrganizationInvitation>;
|
|
108
136
|
cancelOrganizationInvitation(organizationId: string, invitationId: string, idempotencyKey: string): Promise<CanceledOrganizationInvitation>;
|
|
137
|
+
removeOrganizationMember(organizationId: string, memberId: string, idempotencyKey: string): Promise<RemovedOrganizationMember>;
|
|
138
|
+
leaveOrganization(organizationId: string, idempotencyKey: string): Promise<OrganizationDeparture>;
|
|
109
139
|
updateOrganizationDisplay(organizationId: string, input: UpdateOrganizationDisplayInput): Promise<OrganizationDisplay>;
|
|
110
140
|
updateOrganizationTeamDisplay(organizationId: string, teamId: string, input: UpdateOrganizationTeamDisplayInput): Promise<OrganizationTeamDisplay>;
|
|
111
141
|
listOrganizationMembers(organizationId: string, input?: OrganizationPageInput): Promise<OrganizationMemberPage>;
|
|
@@ -122,4 +152,4 @@ interface FinuevaServerAuth {
|
|
|
122
152
|
}
|
|
123
153
|
declare function createServerAuth(options: ServerAuthOptions): FinuevaServerAuth;
|
|
124
154
|
//#endregion
|
|
125
|
-
export { type AcceptInvitationInput, AuthError, type AuthErrorCode, type AuthErrorStatus, type AuthOrganization, type AuthSession, type AuthUser, type CanceledOrganizationInvitation, type CreateOrganizationMemberInvitationInput, type CreatedOrganizationMemberInvitation, type CreatedOrganizationTeam, type DriveCredential, type DriveCredentialInput, type DriveProvisioningAuthOptions, type DriveProvisioningCredential, type DriveRecipient, type DriveRecipientAuthOptions, type FinuevaDriveProvisioningAuth, type FinuevaDriveRecipientAuth, type FinuevaIdentityResolverAuth, FinuevaServerAuth, type IdentityResolverAuthOptions, type InvitationAcceptance, type OrganizationDisplay, type OrganizationInvitation, type OrganizationInvitationPage, type OrganizationMember, type OrganizationMemberAuthority, type OrganizationMemberPage, type OrganizationPage, type OrganizationPageInput, type OrganizationTeam, type OrganizationTeamDisplay, type OrganizationTeamMemberPage, type OrganizationTeamPage, type OrganizationWorkspaceSelection, type PersonalWorkspaceSelection, type ReceivedOrganizationInvitation, type ReceivedOrganizationInvitationPage, type ResentOrganizationInvitation, type ResolveDriveRecipientInput, type ResolveIdentityInput, type ResolvedIdentity, ServerAuthOptions, ServerInvitationAcceptance, ServerSignOutResult, ServerSocialIdTokenSession, type SocialIdTokenInput, type SocialIdTokenProvider, type UpdateOrganizationDisplayInput, type UpdateOrganizationTeamDisplayInput, type UserApiCredential, type UserApiCredentialInput, type UserApiIdentity, type UserApiVerifierOptions, type WorkspaceSelection, createDriveProvisioningAuth, createDriveRecipientAuth, createIdentityResolverAuth, createServerAuth, createUserApiVerifier };
|
|
155
|
+
export { type AcceptInvitationInput, AuthError, type AuthErrorCode, type AuthErrorStatus, type AuthOrganization, type AuthSession, type AuthUser, type CanceledOrganizationInvitation, type CreateOrganizationMemberInvitationInput, type CreatedOrganization, type CreatedOrganizationMemberInvitation, type CreatedOrganizationTeam, type DriveCredential, type DriveCredentialInput, type DriveProvisioningAuthOptions, type DriveProvisioningCredential, type DriveRecipient, type DriveRecipientAuthOptions, type FinuevaDriveProvisioningAuth, type FinuevaDriveRecipientAuth, type FinuevaIdentityResolverAuth, type FinuevaMembershipResolverAuth, FinuevaServerAuth, type IdentityResolverAuthOptions, type InvitationAcceptance, type MembershipResolverAuthOptions, type OrganizationDeparture, type OrganizationDisplay, type OrganizationInvitation, type OrganizationInvitationPage, type OrganizationMember, type OrganizationMemberAuthority, type OrganizationMemberPage, type OrganizationPage, type OrganizationPageInput, type OrganizationTeam, type OrganizationTeamDisplay, type OrganizationTeamMemberPage, type OrganizationTeamPage, type OrganizationWorkspaceSelection, type PersonalWorkspaceSelection, type ReceivedOrganizationInvitation, type ReceivedOrganizationInvitationPage, type RemovedOrganizationMember, type ResentOrganizationInvitation, type ResolveDriveRecipientInput, type ResolveIdentityInput, type ResolveMembershipInput, type ResolvedIdentity, type ResolvedMembership, type ResolvedMembershipRole, ServerAuthOptions, ServerInvitationAcceptance, ServerSignOutResult, ServerSocialIdTokenSession, type SocialIdTokenInput, type SocialIdTokenProvider, type UpdateOrganizationDisplayInput, type UpdateOrganizationTeamDisplayInput, type UserApiCredential, type UserApiCredentialInput, type UserApiIdentity, type UserApiVerifierOptions, type WorkspaceSelection, createDriveProvisioningAuth, createDriveRecipientAuth, createIdentityResolverAuth, createMembershipResolverAuth, createServerAuth, createUserApiVerifier };
|
package/dist/server.js
CHANGED
|
@@ -187,6 +187,7 @@ const messages = {
|
|
|
187
187
|
recipient_unavailable: "The recipient is unavailable.",
|
|
188
188
|
invitation_recipient_mismatch: "The invitation cannot be accepted by this account.",
|
|
189
189
|
invitation_recovery_required: "Invitation administration requires separate recovery.",
|
|
190
|
+
membership_removal_recovery_required: "Membership removal requires separate recovery.",
|
|
190
191
|
email_verification_required: "Email verification is required.",
|
|
191
192
|
invalid_workspace_selection: "The workspace selection is invalid.",
|
|
192
193
|
organization_context_too_large: "The organization context is too large.",
|
|
@@ -1632,7 +1633,7 @@ function normalizeIdInput(value) {
|
|
|
1632
1633
|
return value;
|
|
1633
1634
|
}
|
|
1634
1635
|
function normalizeOrganization(value) {
|
|
1635
|
-
exact$
|
|
1636
|
+
exact$3(value, [
|
|
1636
1637
|
"capabilities",
|
|
1637
1638
|
"id",
|
|
1638
1639
|
"lifecycle",
|
|
@@ -1642,7 +1643,7 @@ function normalizeOrganization(value) {
|
|
|
1642
1643
|
"slug"
|
|
1643
1644
|
]);
|
|
1644
1645
|
if (!isId(value.id) || !boundedString(value.name, 255) || !boundedString(value.slug, 255) || value.lifecycle !== "ordinary" && value.lifecycle !== "managed" || !role(value.role) || !isObject(value.capabilities)) throw authorityUnavailable();
|
|
1645
|
-
exact$
|
|
1646
|
+
exact$3(value.capabilities, [
|
|
1646
1647
|
"readInvitations",
|
|
1647
1648
|
"readMembers",
|
|
1648
1649
|
"readTeams"
|
|
@@ -1695,6 +1696,27 @@ function normalizeOrganizationTeamDisplay(value) {
|
|
|
1695
1696
|
throw authorityUnavailable();
|
|
1696
1697
|
}
|
|
1697
1698
|
}
|
|
1699
|
+
function normalizeOrganizationCreationInput(name, slug, idempotencyKey) {
|
|
1700
|
+
if (!boundedString(name, 255) || !boundedString(idempotencyKey, 255) || typeof slug !== "string" || !/^[a-z0-9-]{1,128}$/.test(slug)) throw new AuthError("invalid_request", 400);
|
|
1701
|
+
return {
|
|
1702
|
+
name,
|
|
1703
|
+
slug,
|
|
1704
|
+
idempotencyKey
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
function normalizeCreatedOrganization(value) {
|
|
1708
|
+
exact$3(value, [
|
|
1709
|
+
"id",
|
|
1710
|
+
"name",
|
|
1711
|
+
"slug"
|
|
1712
|
+
]);
|
|
1713
|
+
if (!isId(value.id) || !boundedString(value.name, 255) || !boundedString(value.slug, 128)) throw authorityUnavailable();
|
|
1714
|
+
return {
|
|
1715
|
+
id: value.id,
|
|
1716
|
+
name: value.name,
|
|
1717
|
+
slug: value.slug
|
|
1718
|
+
};
|
|
1719
|
+
}
|
|
1698
1720
|
function normalizeOrganizationTeamCreationInput(name, idempotencyKey) {
|
|
1699
1721
|
if (!boundedString(name, 255) || !boundedString(idempotencyKey, 255)) throw new AuthError("invalid_request", 400);
|
|
1700
1722
|
return {
|
|
@@ -1703,7 +1725,7 @@ function normalizeOrganizationTeamCreationInput(name, idempotencyKey) {
|
|
|
1703
1725
|
};
|
|
1704
1726
|
}
|
|
1705
1727
|
function normalizeCreatedOrganizationTeam(value) {
|
|
1706
|
-
exact$
|
|
1728
|
+
exact$3(value, ["id", "name"]);
|
|
1707
1729
|
if (!isId(value.id) || !boundedString(value.name, 255)) throw authorityUnavailable();
|
|
1708
1730
|
return {
|
|
1709
1731
|
id: value.id,
|
|
@@ -1730,7 +1752,7 @@ function normalizeOrganizationMemberInvitationCreationInput(value) {
|
|
|
1730
1752
|
};
|
|
1731
1753
|
}
|
|
1732
1754
|
function normalizeCreatedOrganizationMemberInvitation(value) {
|
|
1733
|
-
exact$
|
|
1755
|
+
exact$3(value, ["expiresAt", "id"]);
|
|
1734
1756
|
if (!isId(value.id)) throw authorityUnavailable();
|
|
1735
1757
|
return {
|
|
1736
1758
|
id: value.id,
|
|
@@ -1747,12 +1769,26 @@ function normalizeOrganizationInvitationAdministrationInput(idempotencyKey) {
|
|
|
1747
1769
|
return { idempotencyKey };
|
|
1748
1770
|
}
|
|
1749
1771
|
function normalizeCanceledOrganizationInvitation(value) {
|
|
1750
|
-
exact$
|
|
1772
|
+
exact$3(value, ["status"]);
|
|
1751
1773
|
if (value.status !== "canceled") throw authorityUnavailable();
|
|
1752
1774
|
return { status: "canceled" };
|
|
1753
1775
|
}
|
|
1776
|
+
function normalizeOrganizationMembershipRemovalInput(idempotencyKey) {
|
|
1777
|
+
if (!boundedString(idempotencyKey, 255)) throw new AuthError("invalid_request", 400);
|
|
1778
|
+
return { idempotencyKey };
|
|
1779
|
+
}
|
|
1780
|
+
function normalizeRemovedOrganizationMember(value) {
|
|
1781
|
+
exact$3(value, ["status"]);
|
|
1782
|
+
if (value.status !== "removed") throw authorityUnavailable();
|
|
1783
|
+
return { status: "removed" };
|
|
1784
|
+
}
|
|
1785
|
+
function normalizeOrganizationDeparture(value) {
|
|
1786
|
+
exact$3(value, ["status"]);
|
|
1787
|
+
if (value.status !== "left") throw authorityUnavailable();
|
|
1788
|
+
return { status: "left" };
|
|
1789
|
+
}
|
|
1754
1790
|
function normalizeOrganizations(value) {
|
|
1755
|
-
exact$
|
|
1791
|
+
exact$3(value, ["nextCursor", "organizations"]);
|
|
1756
1792
|
if (!Array.isArray(value.organizations) || value.organizations.length > 100) throw authorityUnavailable();
|
|
1757
1793
|
return {
|
|
1758
1794
|
organizations: unique(value.organizations.map(normalizeOrganization), (item) => item.id),
|
|
@@ -1760,11 +1796,11 @@ function normalizeOrganizations(value) {
|
|
|
1760
1796
|
};
|
|
1761
1797
|
}
|
|
1762
1798
|
function normalizeOrganizationMembers(value) {
|
|
1763
|
-
exact$
|
|
1799
|
+
exact$3(value, ["members", "nextCursor"]);
|
|
1764
1800
|
if (!Array.isArray(value.members) || value.members.length > 100) throw authorityUnavailable();
|
|
1765
1801
|
return {
|
|
1766
1802
|
members: unique(value.members.map((member) => {
|
|
1767
|
-
exact$
|
|
1803
|
+
exact$3(member, [
|
|
1768
1804
|
"email",
|
|
1769
1805
|
"id",
|
|
1770
1806
|
"image",
|
|
@@ -1793,11 +1829,11 @@ function normalizeOrganizationMembers(value) {
|
|
|
1793
1829
|
};
|
|
1794
1830
|
}
|
|
1795
1831
|
function normalizeOrganizationTeams(value) {
|
|
1796
|
-
exact$
|
|
1832
|
+
exact$3(value, ["nextCursor", "teams"]);
|
|
1797
1833
|
if (!Array.isArray(value.teams) || value.teams.length > 100) throw authorityUnavailable();
|
|
1798
1834
|
return {
|
|
1799
1835
|
teams: unique(value.teams.map((team) => {
|
|
1800
|
-
exact$
|
|
1836
|
+
exact$3(team, [
|
|
1801
1837
|
"category",
|
|
1802
1838
|
"createdAt",
|
|
1803
1839
|
"id",
|
|
@@ -1815,7 +1851,7 @@ function normalizeOrganizationTeams(value) {
|
|
|
1815
1851
|
};
|
|
1816
1852
|
}
|
|
1817
1853
|
function normalizeOrganizationTeamMembers(value) {
|
|
1818
|
-
exact$
|
|
1854
|
+
exact$3(value, ["memberIds", "nextCursor"]);
|
|
1819
1855
|
if (!Array.isArray(value.memberIds) || value.memberIds.length > 100) throw authorityUnavailable();
|
|
1820
1856
|
return {
|
|
1821
1857
|
memberIds: unique(value.memberIds.map((item) => normalizeResponseId(item)), (item) => item),
|
|
@@ -1823,7 +1859,7 @@ function normalizeOrganizationTeamMembers(value) {
|
|
|
1823
1859
|
};
|
|
1824
1860
|
}
|
|
1825
1861
|
function normalizeOrganizationInvitation(value) {
|
|
1826
|
-
exact$
|
|
1862
|
+
exact$3(value, [
|
|
1827
1863
|
"createdAt",
|
|
1828
1864
|
"email",
|
|
1829
1865
|
"expiresAt",
|
|
@@ -1834,7 +1870,7 @@ function normalizeOrganizationInvitation(value) {
|
|
|
1834
1870
|
"teamIds"
|
|
1835
1871
|
]);
|
|
1836
1872
|
if (!isId(value.id) || typeof value.email !== "string" || value.email.length > 320 || !email.test(value.email) || !role(value.role) || value.status !== "pending" || !Array.isArray(value.teamIds) || value.teamIds.length > 100 || !isObject(value.inviter)) throw authorityUnavailable();
|
|
1837
|
-
exact$
|
|
1873
|
+
exact$3(value.inviter, ["membershipId", "name"]);
|
|
1838
1874
|
if (!isId(value.inviter.membershipId) || !boundedString(value.inviter.name, 255)) throw authorityUnavailable();
|
|
1839
1875
|
return {
|
|
1840
1876
|
id: value.id,
|
|
@@ -1851,7 +1887,7 @@ function normalizeOrganizationInvitation(value) {
|
|
|
1851
1887
|
};
|
|
1852
1888
|
}
|
|
1853
1889
|
function normalizeOrganizationInvitations(value) {
|
|
1854
|
-
exact$
|
|
1890
|
+
exact$3(value, ["invitations", "nextCursor"]);
|
|
1855
1891
|
if (!Array.isArray(value.invitations) || value.invitations.length > 100) throw authorityUnavailable();
|
|
1856
1892
|
return {
|
|
1857
1893
|
invitations: unique(value.invitations.map(normalizeOrganizationInvitation), (item) => item.id),
|
|
@@ -1859,7 +1895,7 @@ function normalizeOrganizationInvitations(value) {
|
|
|
1859
1895
|
};
|
|
1860
1896
|
}
|
|
1861
1897
|
function normalizeReceivedInvitation(value) {
|
|
1862
|
-
exact$
|
|
1898
|
+
exact$3(value, [
|
|
1863
1899
|
"expiresAt",
|
|
1864
1900
|
"id",
|
|
1865
1901
|
"inviterName",
|
|
@@ -1868,7 +1904,7 @@ function normalizeReceivedInvitation(value) {
|
|
|
1868
1904
|
"teams"
|
|
1869
1905
|
]);
|
|
1870
1906
|
if (!isId(value.id) || !boundedString(value.inviterName, 255) || !role(value.role) || !Array.isArray(value.teams) || value.teams.length > 100 || !isObject(value.organization)) throw authorityUnavailable();
|
|
1871
|
-
exact$
|
|
1907
|
+
exact$3(value.organization, [
|
|
1872
1908
|
"id",
|
|
1873
1909
|
"logo",
|
|
1874
1910
|
"name",
|
|
@@ -1885,7 +1921,7 @@ function normalizeReceivedInvitation(value) {
|
|
|
1885
1921
|
},
|
|
1886
1922
|
role: value.role,
|
|
1887
1923
|
teams: unique(value.teams.map((team) => {
|
|
1888
|
-
exact$
|
|
1924
|
+
exact$3(team, ["id", "name"]);
|
|
1889
1925
|
if (!isId(team.id) || !boundedString(team.name, 255)) throw authorityUnavailable();
|
|
1890
1926
|
return {
|
|
1891
1927
|
id: team.id,
|
|
@@ -1897,7 +1933,7 @@ function normalizeReceivedInvitation(value) {
|
|
|
1897
1933
|
};
|
|
1898
1934
|
}
|
|
1899
1935
|
function normalizeReceivedInvitations(value) {
|
|
1900
|
-
exact$
|
|
1936
|
+
exact$3(value, ["invitations", "nextCursor"]);
|
|
1901
1937
|
if (!Array.isArray(value.invitations) || value.invitations.length > 100) throw authorityUnavailable();
|
|
1902
1938
|
return {
|
|
1903
1939
|
invitations: unique(value.invitations.map(normalizeReceivedInvitation), (item) => item.id),
|
|
@@ -1972,8 +2008,12 @@ function fromOrganizationInvitationAdministrationError(value, status, retryAfter
|
|
|
1972
2008
|
if (status === 422 && isObject(value) && value.code === "RECOVERY_REQUIRED") return new AuthError("invitation_recovery_required", 422);
|
|
1973
2009
|
return fromOrganizationMutationAuthorityError(value, status, retryAfter);
|
|
1974
2010
|
}
|
|
2011
|
+
function fromOrganizationMembershipRemovalError(value, status, retryAfter) {
|
|
2012
|
+
if (status === 422 && isObject(value) && value.code === "RECOVERY_REQUIRED") return new AuthError("membership_removal_recovery_required", 422);
|
|
2013
|
+
return fromOrganizationMutationAuthorityError(value, status, retryAfter);
|
|
2014
|
+
}
|
|
1975
2015
|
function normalizeOrganizationMemberAuthority(value, organizationId, memberId) {
|
|
1976
|
-
exact$
|
|
2016
|
+
exact$3(value, [
|
|
1977
2017
|
"organizationId",
|
|
1978
2018
|
"actor",
|
|
1979
2019
|
"target"
|
|
@@ -1991,7 +2031,7 @@ function normalizeOrganizationMemberAuthority(value, organizationId, memberId) {
|
|
|
1991
2031
|
};
|
|
1992
2032
|
}
|
|
1993
2033
|
function normalizeOrganizationAuthorityMemberOutcome(value, includesStatus = false) {
|
|
1994
|
-
exact$
|
|
2034
|
+
exact$3(value, [
|
|
1995
2035
|
"memberId",
|
|
1996
2036
|
"manualRole",
|
|
1997
2037
|
"role",
|
|
@@ -2084,7 +2124,7 @@ function toDate(value) {
|
|
|
2084
2124
|
function isId(value) {
|
|
2085
2125
|
return typeof value === "string" && id.test(value);
|
|
2086
2126
|
}
|
|
2087
|
-
function exact$
|
|
2127
|
+
function exact$3(value, keys) {
|
|
2088
2128
|
if (!isObject(value) || Object.keys(value).sort().join(",") !== [...keys].sort().join(",")) throw authorityUnavailable();
|
|
2089
2129
|
}
|
|
2090
2130
|
function boundedString(value, maximum) {
|
|
@@ -2383,7 +2423,7 @@ function createUserApiVerifier(options) {
|
|
|
2383
2423
|
//#endregion
|
|
2384
2424
|
//#region src/identity-resolution.ts
|
|
2385
2425
|
const emailPattern$1 = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$(?![\s\S])/;
|
|
2386
|
-
function exact$
|
|
2426
|
+
function exact$2(value, keys) {
|
|
2387
2427
|
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
|
|
2388
2428
|
}
|
|
2389
2429
|
function createIdentityResolverAuth(options) {
|
|
@@ -2393,7 +2433,7 @@ function createIdentityResolverAuth(options) {
|
|
|
2393
2433
|
const timeoutMs = normalizeTimeout(options.timeoutMs);
|
|
2394
2434
|
let inFlight = false;
|
|
2395
2435
|
return { async resolveIdentity(input, clientAssertion) {
|
|
2396
|
-
if (!exact$
|
|
2436
|
+
if (!exact$2(input, ["identifier"]) || typeof input.identifier !== "string" || input.identifier.length > 324) throw new AuthError("invalid_request", 400);
|
|
2397
2437
|
const identifier = input.identifier.trim().toLowerCase();
|
|
2398
2438
|
if (!(identifier.length <= 320 && emailPattern$1.test(identifier)) && !/^[a-z0-9_.]{3,30}$(?![\s\S])/.test(identifier)) throw new AuthError("invalid_request", 400);
|
|
2399
2439
|
if (typeof clientAssertion !== "string" || clientAssertion.length + 7 > 16 * 1024 || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$(?![\s\S])/.test(clientAssertion)) throw new AuthError("invalid_request", 400);
|
|
@@ -2445,7 +2485,7 @@ function createIdentityResolverAuth(options) {
|
|
|
2445
2485
|
}
|
|
2446
2486
|
const value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, size)));
|
|
2447
2487
|
if (response.status !== 200) {
|
|
2448
|
-
if (!exact$
|
|
2488
|
+
if (!exact$2(value, ["code", "message"])) throw authorityUnavailable();
|
|
2449
2489
|
if (response.status === 401 && value.code === "UNAUTHORIZED" && value.message === "The identity resolution assertion is invalid.") mappedError = new AuthError("authentication_required", 401);
|
|
2450
2490
|
if (response.status === 429 && value.code === "TOO_MANY_REQUESTS" && value.message === "Identity resolution requests are temporarily limited.") {
|
|
2451
2491
|
const retryAfter = response.headers.get("retry-after");
|
|
@@ -2454,9 +2494,9 @@ function createIdentityResolverAuth(options) {
|
|
|
2454
2494
|
}
|
|
2455
2495
|
throw mappedError ?? authorityUnavailable();
|
|
2456
2496
|
}
|
|
2457
|
-
if (!exact$
|
|
2497
|
+
if (!exact$2(value, ["identity"])) throw authorityUnavailable();
|
|
2458
2498
|
if (value.identity === null) return null;
|
|
2459
|
-
if (!exact$
|
|
2499
|
+
if (!exact$2(value.identity, ["userId"]) || typeof value.identity.userId !== "string" || !/^[A-Za-z0-9_-]{1,128}$(?![\s\S])/.test(value.identity.userId)) throw authorityUnavailable();
|
|
2460
2500
|
return { userId: value.identity.userId };
|
|
2461
2501
|
};
|
|
2462
2502
|
return await Promise.race([exchange().finally(() => {
|
|
@@ -2473,6 +2513,127 @@ function createIdentityResolverAuth(options) {
|
|
|
2473
2513
|
} };
|
|
2474
2514
|
}
|
|
2475
2515
|
//#endregion
|
|
2516
|
+
//#region src/membership-resolution.ts
|
|
2517
|
+
const idPattern = /^[A-Za-z0-9_-]{1,128}$(?![\s\S])/;
|
|
2518
|
+
const isoPattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$(?![\s\S])/;
|
|
2519
|
+
const roles = [
|
|
2520
|
+
"admin",
|
|
2521
|
+
"member",
|
|
2522
|
+
"owner"
|
|
2523
|
+
];
|
|
2524
|
+
const membershipKeys = [
|
|
2525
|
+
"checkedAt",
|
|
2526
|
+
"manualRole",
|
|
2527
|
+
"memberCount",
|
|
2528
|
+
"memberId",
|
|
2529
|
+
"organizationId",
|
|
2530
|
+
"owner",
|
|
2531
|
+
"role",
|
|
2532
|
+
"userId"
|
|
2533
|
+
];
|
|
2534
|
+
function exact$1(value, keys) {
|
|
2535
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
|
|
2536
|
+
}
|
|
2537
|
+
function createMembershipResolverAuth(options) {
|
|
2538
|
+
const url = joinURL(normalizeOrigin(options.authOrigin, "authOrigin"), "api/v1/auth/memberships/resolve");
|
|
2539
|
+
const fetchImpl = options.fetch ?? globalThis.fetch?.bind(globalThis);
|
|
2540
|
+
if (typeof fetchImpl !== "function") throw new TypeError("fetch is required");
|
|
2541
|
+
const timeoutMs = normalizeTimeout(options.timeoutMs);
|
|
2542
|
+
let inFlight = false;
|
|
2543
|
+
return { async resolveMembership(input, clientAssertion) {
|
|
2544
|
+
if (!exact$1(input, ["organizationId", "userId"]) || typeof input.organizationId !== "string" || typeof input.userId !== "string" || !idPattern.test(input.organizationId) || !idPattern.test(input.userId)) throw new AuthError("invalid_request", 400);
|
|
2545
|
+
if (typeof clientAssertion !== "string" || clientAssertion.length + 7 > 16 * 1024 || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$(?![\s\S])/.test(clientAssertion)) throw new AuthError("invalid_request", 400);
|
|
2546
|
+
if (inFlight) throw new AuthError("state_conflict", 409);
|
|
2547
|
+
inFlight = true;
|
|
2548
|
+
const organizationId = input.organizationId;
|
|
2549
|
+
const userId = input.userId;
|
|
2550
|
+
const controller = new AbortController();
|
|
2551
|
+
let reader;
|
|
2552
|
+
let timer;
|
|
2553
|
+
let mappedError;
|
|
2554
|
+
try {
|
|
2555
|
+
const deadline = new Promise((_, reject) => {
|
|
2556
|
+
timer = setTimeout(() => {
|
|
2557
|
+
reject(authorityUnavailable());
|
|
2558
|
+
controller.abort();
|
|
2559
|
+
reader?.cancel().catch(() => {});
|
|
2560
|
+
}, timeoutMs);
|
|
2561
|
+
});
|
|
2562
|
+
const exchange = async () => {
|
|
2563
|
+
const response = await fetchImpl(url, {
|
|
2564
|
+
method: "POST",
|
|
2565
|
+
headers: {
|
|
2566
|
+
authorization: `Bearer ${clientAssertion}`,
|
|
2567
|
+
accept: "application/json",
|
|
2568
|
+
"content-type": "application/json"
|
|
2569
|
+
},
|
|
2570
|
+
body: JSON.stringify({
|
|
2571
|
+
organizationId,
|
|
2572
|
+
userId
|
|
2573
|
+
}),
|
|
2574
|
+
credentials: "omit",
|
|
2575
|
+
cache: "no-store",
|
|
2576
|
+
redirect: "manual",
|
|
2577
|
+
signal: controller.signal
|
|
2578
|
+
});
|
|
2579
|
+
if (controller.signal.aborted) {
|
|
2580
|
+
response.body?.cancel().catch(() => {});
|
|
2581
|
+
throw authorityUnavailable();
|
|
2582
|
+
}
|
|
2583
|
+
if (!response.body) throw authorityUnavailable();
|
|
2584
|
+
reader = response.body.getReader();
|
|
2585
|
+
const length = response.headers.get("content-length");
|
|
2586
|
+
if (response.redirected || response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase() !== "application/json" || length !== null && (!/^\d+$/.test(length) || Number(length) > 1024)) throw authorityUnavailable();
|
|
2587
|
+
const bytes = new Uint8Array(1024);
|
|
2588
|
+
let size = 0;
|
|
2589
|
+
while (true) {
|
|
2590
|
+
const chunk = await reader.read();
|
|
2591
|
+
if (controller.signal.aborted) throw authorityUnavailable();
|
|
2592
|
+
if (chunk.done) break;
|
|
2593
|
+
if (size + chunk.value.byteLength > bytes.length) throw authorityUnavailable();
|
|
2594
|
+
bytes.set(chunk.value, size);
|
|
2595
|
+
size += chunk.value.byteLength;
|
|
2596
|
+
}
|
|
2597
|
+
const value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, size)));
|
|
2598
|
+
if (response.status !== 200) {
|
|
2599
|
+
if (!exact$1(value, ["code", "message"])) throw authorityUnavailable();
|
|
2600
|
+
if (response.status === 401 && value.code === "UNAUTHORIZED" && value.message === "The membership resolution assertion is invalid.") mappedError = new AuthError("authentication_required", 401);
|
|
2601
|
+
if (response.status === 429 && value.code === "TOO_MANY_REQUESTS" && value.message === "Membership resolution requests are temporarily limited.") {
|
|
2602
|
+
const retryAfter = response.headers.get("retry-after");
|
|
2603
|
+
if (retryAfter === null || !/^(?:[1-9]|[1-5][0-9]|60)$/.test(retryAfter)) throw authorityUnavailable();
|
|
2604
|
+
mappedError = new AuthError("auth_request_rate_limited", 429, Number(retryAfter));
|
|
2605
|
+
}
|
|
2606
|
+
throw mappedError ?? authorityUnavailable();
|
|
2607
|
+
}
|
|
2608
|
+
if (!exact$1(value, ["membership"])) throw authorityUnavailable();
|
|
2609
|
+
if (value.membership === null) return null;
|
|
2610
|
+
const membership = value.membership;
|
|
2611
|
+
if (!exact$1(membership, membershipKeys) || typeof membership.checkedAt !== "string" || !isoPattern.test(membership.checkedAt) || Number.isNaN(Date.parse(membership.checkedAt)) || typeof membership.manualRole !== "string" || !roles.includes(membership.manualRole) || typeof membership.role !== "string" || !roles.includes(membership.role) || typeof membership.memberCount !== "number" || !Number.isSafeInteger(membership.memberCount) || membership.memberCount < 0 || typeof membership.memberId !== "string" || !idPattern.test(membership.memberId) || typeof membership.owner !== "boolean" || membership.organizationId !== organizationId || membership.userId !== userId) throw authorityUnavailable();
|
|
2612
|
+
return {
|
|
2613
|
+
checkedAt: membership.checkedAt,
|
|
2614
|
+
manualRole: membership.manualRole,
|
|
2615
|
+
memberCount: membership.memberCount,
|
|
2616
|
+
memberId: membership.memberId,
|
|
2617
|
+
organizationId,
|
|
2618
|
+
owner: membership.owner,
|
|
2619
|
+
role: membership.role,
|
|
2620
|
+
userId
|
|
2621
|
+
};
|
|
2622
|
+
};
|
|
2623
|
+
return await Promise.race([exchange().finally(() => {
|
|
2624
|
+
inFlight = false;
|
|
2625
|
+
}), deadline]);
|
|
2626
|
+
} catch (error) {
|
|
2627
|
+
if (mappedError && mappedError === error) throw mappedError;
|
|
2628
|
+
throw authorityUnavailable();
|
|
2629
|
+
} finally {
|
|
2630
|
+
clearTimeout(timer);
|
|
2631
|
+
controller.abort();
|
|
2632
|
+
reader?.cancel().catch(() => {});
|
|
2633
|
+
}
|
|
2634
|
+
} };
|
|
2635
|
+
}
|
|
2636
|
+
//#endregion
|
|
2476
2637
|
//#region src/drive-recipients.ts
|
|
2477
2638
|
const encoder = new TextEncoder();
|
|
2478
2639
|
const emailPattern = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/;
|
|
@@ -2810,6 +2971,21 @@ function createServerAuth(options) {
|
|
|
2810
2971
|
const member = normalizeIdInput(memberId);
|
|
2811
2972
|
return organizationRead(`${organization}/members/${member}/authority`, void 0, (value) => normalizeOrganizationMemberAuthority(value, organization, member));
|
|
2812
2973
|
},
|
|
2974
|
+
async createOrganization(name, slug, idempotencyKey) {
|
|
2975
|
+
const body = normalizeOrganizationCreationInput(name, slug, idempotencyKey);
|
|
2976
|
+
return normalizeCreatedOrganization(await requestJson(joinURL(authOrigin, "api/v1/auth/organizations"), {
|
|
2977
|
+
fetch: fetchImpl,
|
|
2978
|
+
timeoutMs,
|
|
2979
|
+
method: "POST",
|
|
2980
|
+
credentials,
|
|
2981
|
+
headers: {
|
|
2982
|
+
...authHeaders(!authorization),
|
|
2983
|
+
"content-type": "application/json"
|
|
2984
|
+
},
|
|
2985
|
+
body,
|
|
2986
|
+
mapError: fromOrganizationMutationAuthorityError
|
|
2987
|
+
}));
|
|
2988
|
+
},
|
|
2813
2989
|
async createOrganizationTeam(organizationId, name, idempotencyKey) {
|
|
2814
2990
|
const id = normalizeIdInput(organizationId);
|
|
2815
2991
|
const body = normalizeOrganizationTeamCreationInput(name, idempotencyKey);
|
|
@@ -2878,6 +3054,41 @@ function createServerAuth(options) {
|
|
|
2878
3054
|
mapError: fromOrganizationInvitationAdministrationError
|
|
2879
3055
|
}));
|
|
2880
3056
|
},
|
|
3057
|
+
async removeOrganizationMember(organizationId, memberId, idempotencyKey) {
|
|
3058
|
+
if (authorization) throw new AuthError("authentication_required", 401);
|
|
3059
|
+
const organization = normalizeIdInput(organizationId);
|
|
3060
|
+
const member = normalizeIdInput(memberId);
|
|
3061
|
+
const body = normalizeOrganizationMembershipRemovalInput(idempotencyKey);
|
|
3062
|
+
return normalizeRemovedOrganizationMember(await requestJson(joinURL(authOrigin, "api/v1/auth/organizations", organization, "members", member, "remove"), {
|
|
3063
|
+
fetch: fetchImpl,
|
|
3064
|
+
timeoutMs,
|
|
3065
|
+
method: "POST",
|
|
3066
|
+
credentials,
|
|
3067
|
+
headers: {
|
|
3068
|
+
...authHeaders(),
|
|
3069
|
+
"content-type": "application/json"
|
|
3070
|
+
},
|
|
3071
|
+
body,
|
|
3072
|
+
mapError: fromOrganizationMembershipRemovalError
|
|
3073
|
+
}));
|
|
3074
|
+
},
|
|
3075
|
+
async leaveOrganization(organizationId, idempotencyKey) {
|
|
3076
|
+
if (authorization) throw new AuthError("authentication_required", 401);
|
|
3077
|
+
const organization = normalizeIdInput(organizationId);
|
|
3078
|
+
const body = normalizeOrganizationMembershipRemovalInput(idempotencyKey);
|
|
3079
|
+
return normalizeOrganizationDeparture(await requestJson(joinURL(authOrigin, "api/v1/auth/organizations", organization, "leave"), {
|
|
3080
|
+
fetch: fetchImpl,
|
|
3081
|
+
timeoutMs,
|
|
3082
|
+
method: "POST",
|
|
3083
|
+
credentials,
|
|
3084
|
+
headers: {
|
|
3085
|
+
...authHeaders(),
|
|
3086
|
+
"content-type": "application/json"
|
|
3087
|
+
},
|
|
3088
|
+
body,
|
|
3089
|
+
mapError: fromOrganizationMembershipRemovalError
|
|
3090
|
+
}));
|
|
3091
|
+
},
|
|
2881
3092
|
async updateOrganizationDisplay(organizationId, input) {
|
|
2882
3093
|
const id = normalizeIdInput(organizationId);
|
|
2883
3094
|
const desired = normalizeOrganizationDisplayInput(input);
|
|
@@ -3044,4 +3255,4 @@ function authAuthorizationHeader(value) {
|
|
|
3044
3255
|
return value;
|
|
3045
3256
|
}
|
|
3046
3257
|
//#endregion
|
|
3047
|
-
export { AuthError, createDriveProvisioningAuth, createDriveRecipientAuth, createIdentityResolverAuth, createServerAuth, createUserApiVerifier };
|
|
3258
|
+
export { AuthError, createDriveProvisioningAuth, createDriveRecipientAuth, createIdentityResolverAuth, createMembershipResolverAuth, createServerAuth, createUserApiVerifier };
|
|
@@ -10,7 +10,7 @@ interface UserApiCredential {
|
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/errors.d.ts
|
|
13
|
-
type AuthErrorCode = "invalid_credentials" | "invalid_auth_input" | "account_conflict" | "password_reset_invalid" | "authentication_required" | "request_origin_denied" | "invalid_request" | "invalid_invitation" | "invitation_unavailable" | "recipient_unavailable" | "invitation_recipient_mismatch" | "invitation_recovery_required" | "email_verification_required" | "invalid_workspace_selection" | "organization_context_too_large" | "credential_rate_limited" | "auth_request_rate_limited" | "state_conflict" | "access_denied" | "platform_target_unavailable" | "platform_quorum_unavailable" | "platform_recovery_required" | "identity_authority_unavailable";
|
|
13
|
+
type AuthErrorCode = "invalid_credentials" | "invalid_auth_input" | "account_conflict" | "password_reset_invalid" | "authentication_required" | "request_origin_denied" | "invalid_request" | "invalid_invitation" | "invitation_unavailable" | "recipient_unavailable" | "invitation_recipient_mismatch" | "invitation_recovery_required" | "membership_removal_recovery_required" | "email_verification_required" | "invalid_workspace_selection" | "organization_context_too_large" | "credential_rate_limited" | "auth_request_rate_limited" | "state_conflict" | "access_denied" | "platform_target_unavailable" | "platform_quorum_unavailable" | "platform_recovery_required" | "identity_authority_unavailable";
|
|
14
14
|
type AuthErrorStatus = 400 | 401 | 403 | 404 | 405 | 409 | 413 | 415 | 422 | 429 | 503;
|
|
15
15
|
declare class AuthError extends Error {
|
|
16
16
|
readonly code: AuthErrorCode;
|
|
@@ -84,6 +84,11 @@ interface OrganizationTeam {
|
|
|
84
84
|
category: "manual" | "managed";
|
|
85
85
|
createdAt: Date;
|
|
86
86
|
}
|
|
87
|
+
interface CreatedOrganization {
|
|
88
|
+
id: string;
|
|
89
|
+
name: string;
|
|
90
|
+
slug: string;
|
|
91
|
+
}
|
|
87
92
|
interface CreatedOrganizationTeam {
|
|
88
93
|
id: string;
|
|
89
94
|
name: string;
|
|
@@ -104,6 +109,12 @@ interface ResentOrganizationInvitation {
|
|
|
104
109
|
interface CanceledOrganizationInvitation {
|
|
105
110
|
status: "canceled";
|
|
106
111
|
}
|
|
112
|
+
interface RemovedOrganizationMember {
|
|
113
|
+
status: "removed";
|
|
114
|
+
}
|
|
115
|
+
interface OrganizationDeparture {
|
|
116
|
+
status: "left";
|
|
117
|
+
}
|
|
107
118
|
interface OrganizationTeamPage {
|
|
108
119
|
teams: OrganizationTeam[];
|
|
109
120
|
nextCursor: string | null;
|
|
@@ -304,10 +315,13 @@ interface FinuevaAuthClient {
|
|
|
304
315
|
listOrganizations(input?: OrganizationPageInput): Promise<OrganizationPage>;
|
|
305
316
|
getOrganization(organizationId: string): Promise<AuthOrganization>;
|
|
306
317
|
getOrganizationMemberAuthority(organizationId: string, memberId: string): Promise<OrganizationMemberAuthority>;
|
|
318
|
+
createOrganization(name: string, slug: string, idempotencyKey: string): Promise<CreatedOrganization>;
|
|
307
319
|
createOrganizationTeam(organizationId: string, name: string, idempotencyKey: string): Promise<CreatedOrganizationTeam>;
|
|
308
320
|
createOrganizationMemberInvitation(organizationId: string, input: CreateOrganizationMemberInvitationInput): Promise<CreatedOrganizationMemberInvitation>;
|
|
309
321
|
resendOrganizationInvitation(organizationId: string, invitationId: string, idempotencyKey: string): Promise<ResentOrganizationInvitation>;
|
|
310
322
|
cancelOrganizationInvitation(organizationId: string, invitationId: string, idempotencyKey: string): Promise<CanceledOrganizationInvitation>;
|
|
323
|
+
removeOrganizationMember(organizationId: string, memberId: string, idempotencyKey: string): Promise<RemovedOrganizationMember>;
|
|
324
|
+
leaveOrganization(organizationId: string, idempotencyKey: string): Promise<OrganizationDeparture>;
|
|
311
325
|
updateOrganizationDisplay(organizationId: string, input: UpdateOrganizationDisplayInput): Promise<OrganizationDisplay>;
|
|
312
326
|
updateOrganizationTeamDisplay(organizationId: string, teamId: string, input: UpdateOrganizationTeamDisplayInput): Promise<OrganizationTeamDisplay>;
|
|
313
327
|
changeOrganizationMemberManualRole(organizationId: string, targetMembershipId: string, input: OrganizationManualRoleChangeInput): Promise<OrganizationManualRoleChangeResult>;
|
|
@@ -334,4 +348,4 @@ interface FinuevaAuthClient {
|
|
|
334
348
|
onSessionChange(listener: (session: AuthSession | null) => void): () => void;
|
|
335
349
|
}
|
|
336
350
|
//#endregion
|
|
337
|
-
export {
|
|
351
|
+
export { AuthError as $, OrganizationTeamPage as A, ReceivedOrganizationInvitation as B, OrganizationMemberAuthority as C, OrganizationTeam as D, OrganizationPageInput as E, PlatformRoleApplied as F, SendVerificationEmailInput as G, RecentAuthenticationStatus as H, PlatformRoleApproval as I, SocialIdTokenProvider as J, SignInInput as K, PlatformRoleChangeRecentAuthenticationInput as L, PersonalWorkspaceSelection as M, PlatformBootstrapRoleChangeInput as N, OrganizationTeamDisplay as O, PlatformRole as P, WorkspaceSelection as Q, PlatformRoleFirstApproval as R, OrganizationMember as S, OrganizationPage as T, RemovedOrganizationMember as U, ReceivedOrganizationInvitationPage as V, ResentOrganizationInvitation as W, UpdateOrganizationTeamDisplayInput as X, UpdateOrganizationDisplayInput as Y, UpdateProfileInput as Z, InvitationAcceptance as _, AuthPersistenceDriver as a, OrganizationInvitation as b, AuthUser as c, CreatedOrganization as d, AuthErrorCode as et, CreatedOrganizationMemberInvitation as f, FinuevaAuthClient as g, DriveCredentialInput as h, AuthPersistence as i, OrganizationWorkspaceSelection as j, OrganizationTeamMemberPage as k, CanceledOrganizationInvitation as l, DriveCredential as m, AuthClientOptions as n, UserApiCredential as nt, AuthSession as o, CreatedOrganizationTeam as p, SocialIdTokenInput as q, AuthOrganization as r, UserApiCredentialInput as rt, AuthState as s, AcceptInvitationInput as t, AuthErrorStatus as tt, CreateOrganizationMemberInvitationInput as u, OrganizationDeparture as v, OrganizationMemberPage as w, OrganizationInvitationPage as x, OrganizationDisplay as y, PlatformStatus as z };
|