@finueva/auth 0.11.1 → 0.12.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 +33 -22
- package/dist/device.d.ts +1 -1
- package/dist/device.js +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +53 -0
- package/dist/server.d.ts +4 -2
- package/dist/server.js +55 -0
- package/dist/{types--G_Gwf2r.d.ts → types-Sh23XMKv.d.ts} +11 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Use `@finueva/auth` to add Finueva sign-in, organization access, invitations, and Drive credentials to a browser, server, CLI, or native application.
|
|
4
4
|
|
|
5
|
-
The current published version is `0.11.
|
|
5
|
+
The current published version is `0.11.1`. The package is ESM-only. Node.js consumers require Node.js 22 or later. Other server runtimes must provide compatible Fetch, Web Crypto, URL, and Web Streams APIs. Its interface is Experimental until version `1.0.0`.
|
|
6
6
|
|
|
7
|
-
The platform-status
|
|
7
|
+
The platform-status, organization-authority, and invitation-administration methods below describe this repository's next package candidate. Published version `0.11.1` does not include them.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
@@ -78,25 +78,27 @@ The browser owns the session cookie. The SDK does not expose or persist it.
|
|
|
78
78
|
|
|
79
79
|
## Common Tasks
|
|
80
80
|
|
|
81
|
-
| Task | Browser | Server
|
|
82
|
-
| ----------------------------- | ------------------------------------------- |
|
|
83
|
-
| Create an account | `signUp()` | Not available
|
|
84
|
-
| Read the current session | `getSession()` | `getSession()`
|
|
85
|
-
| Observe session state | `onAuthStateChange()` | Not available
|
|
86
|
-
| Update a profile | `updateProfile()` | Not available
|
|
87
|
-
| Change a password | `changePassword()` | Not available
|
|
88
|
-
| Reset a password | `requestPasswordReset()`, `resetPassword()` | Not available
|
|
89
|
-
| Verify an email | `sendVerificationEmail()` | Not available
|
|
90
|
-
| List organizations | `listOrganizations()` | `listOrganizations()`
|
|
91
|
-
| Create an ordinary team | `createOrganizationTeam()` | `createOrganizationTeam()`
|
|
92
|
-
| Invite an ordinary member | `createOrganizationMemberInvitation()` | `createOrganizationMemberInvitation()`
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
|
81
|
+
| Task | Browser | Server | Device |
|
|
82
|
+
| ----------------------------- | ------------------------------------------- | ----------------------------------------- | -------------------------------------- |
|
|
83
|
+
| Create an account | `signUp()` | Not available | `signUpWithEmail()` |
|
|
84
|
+
| Read the current session | `getSession()` | `getSession()` | `getSession()` |
|
|
85
|
+
| Observe session state | `onAuthStateChange()` | Not available | Not available |
|
|
86
|
+
| Update a profile | `updateProfile()` | Not available | `updateProfile()` |
|
|
87
|
+
| Change a password | `changePassword()` | Not available | `changePassword()` |
|
|
88
|
+
| Reset a password | `requestPasswordReset()`, `resetPassword()` | Not available | Not available |
|
|
89
|
+
| Verify an email | `sendVerificationEmail()` | Not available | Not available |
|
|
90
|
+
| List organizations | `listOrganizations()` | `listOrganizations()` | `listOrganizations()` |
|
|
91
|
+
| Create an ordinary team | `createOrganizationTeam()` | `createOrganizationTeam()` | `createOrganizationTeam()` |
|
|
92
|
+
| Invite an ordinary member | `createOrganizationMemberInvitation()` | `createOrganizationMemberInvitation()` | `createOrganizationMemberInvitation()` |
|
|
93
|
+
| Resend a member invitation | `resendOrganizationInvitation()` | `resendOrganizationInvitation()` (cookie) | Not available |
|
|
94
|
+
| Cancel a member invitation | `cancelOrganizationInvitation()` | `cancelOrganizationInvitation()` (cookie) | Not available |
|
|
95
|
+
| Accept an invitation | `acceptInvitation()` | `acceptInvitation()` | Not available |
|
|
96
|
+
| Enroll a passkey | `addPasskey()` | Not available | Not available |
|
|
97
|
+
| Perform recent authentication | Platform and organization action methods | Not available | Not available |
|
|
98
|
+
| Change manual roles or owners | Organization authority methods | Not available | Not available |
|
|
99
|
+
| Read current platform roles | `getPlatformStatus()` | Not available | Not available |
|
|
100
|
+
| Request Drive access | `getDriveCredential()` | `getDriveCredential()` | `getDriveCredential()` |
|
|
101
|
+
| End the current session | `signOut()` | `signOut()` | `revokeCurrentDevice()` |
|
|
100
102
|
|
|
101
103
|
## Create An Organization Invitation
|
|
102
104
|
|
|
@@ -114,6 +116,15 @@ console.log(invitation.id, invitation.expiresAt);
|
|
|
114
116
|
|
|
115
117
|
If the response is lost, repeat the same request with the same key. The SDK does not retry automatically. The result confirms invitation creation. It does not confirm email delivery.
|
|
116
118
|
|
|
119
|
+
Manual owners and manual administrators can resend or cancel the exact pending invitation through browser-cookie or server-cookie authority:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
const resent = await auth.resendOrganizationInvitation(organizationId, invitation.id, crypto.randomUUID());
|
|
123
|
+
const canceled = await auth.cancelOrganizationInvitation(organizationId, invitation.id, crypto.randomUUID());
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
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.
|
|
127
|
+
|
|
117
128
|
## Perform Recent Authentication
|
|
118
129
|
|
|
119
130
|
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:
|
|
@@ -315,7 +326,7 @@ Use `error.code` for application behavior. Do not parse `error.message`. Except
|
|
|
315
326
|
- Organization collections use page sizes from 1 through 100.
|
|
316
327
|
- Organization Drive context supports at most 50 current teams.
|
|
317
328
|
- Invitation creation supports only the `member` role in ordinary organizations.
|
|
318
|
-
- Invitation resend and cancellation
|
|
329
|
+
- Invitation resend and cancellation require browser-cookie or server-cookie authority and a manual owner or manual administrator.
|
|
319
330
|
- Cross-root SSO, custom refresh tokens, and account deletion are not implemented.
|
|
320
331
|
- Production support gates are incomplete. Ask the Auth operator for the current environment status before adoption.
|
|
321
332
|
|
package/dist/device.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as OrganizationPageInput, D as OrganizationTeamPage, E as OrganizationTeamMemberPage, G as UpdateOrganizationDisplayInput, K as UpdateOrganizationTeamDisplayInput, L as ReceivedOrganizationInvitation, R as ReceivedOrganizationInvitationPage, S as OrganizationPage, T as OrganizationTeamDisplay, U as SocialIdTokenInput, W as SocialIdTokenProvider, X as AuthErrorCode, Y as AuthError, Z as AuthErrorStatus, _ as OrganizationDisplay, b as OrganizationMember, d as CreatedOrganizationMemberInvitation, f as CreatedOrganizationTeam, m as DriveCredentialInput, o as AuthSession, p as DriveCredential, q as UpdateProfileInput, r as AuthOrganization, u as CreateOrganizationMemberInvitationInput, v as OrganizationInvitation, w as OrganizationTeam, x as OrganizationMemberPage, y as OrganizationInvitationPage } from "./types-Sh23XMKv.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 {
|
package/dist/device.js
CHANGED
|
@@ -448,6 +448,7 @@ const messages = {
|
|
|
448
448
|
invalid_invitation: "The invitation is invalid.",
|
|
449
449
|
invitation_unavailable: "The invitation is not available.",
|
|
450
450
|
invitation_recipient_mismatch: "The invitation cannot be accepted by this account.",
|
|
451
|
+
invitation_recovery_required: "Invitation administration requires separate recovery.",
|
|
451
452
|
email_verification_required: "Email verification is required.",
|
|
452
453
|
invalid_workspace_selection: "The workspace selection is invalid.",
|
|
453
454
|
organization_context_too_large: "The organization context is too large.",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as PlatformBootstrapRoleChangeInput, B as ResentOrganizationInvitation, C as OrganizationPageInput, D as OrganizationTeamPage, E as OrganizationTeamMemberPage, F as PlatformRoleFirstApproval, G as UpdateOrganizationDisplayInput, H as SignInInput, I as PlatformStatus, J as WorkspaceSelection, K as UpdateOrganizationTeamDisplayInput, L as ReceivedOrganizationInvitation, M as PlatformRoleApplied, N as PlatformRoleApproval, O as OrganizationWorkspaceSelection, P as PlatformRoleChangeRecentAuthenticationInput, R as ReceivedOrganizationInvitationPage, S as OrganizationPage, T as OrganizationTeamDisplay, U as SocialIdTokenInput, V as SendVerificationEmailInput, W as SocialIdTokenProvider, X as AuthErrorCode, Y as AuthError, Z as AuthErrorStatus, _ as OrganizationDisplay, a as AuthPersistenceDriver, b as OrganizationMember, c as AuthUser, d as CreatedOrganizationMemberInvitation, f as CreatedOrganizationTeam, g as InvitationAcceptance, h as FinuevaAuthClient, i as AuthPersistence, j as PlatformRole, k as PersonalWorkspaceSelection, l as CanceledOrganizationInvitation, m as DriveCredentialInput, n as AuthClientOptions, o as AuthSession, p as DriveCredential, q as UpdateProfileInput, r as AuthOrganization, s as AuthState, t as AcceptInvitationInput, u as CreateOrganizationMemberInvitationInput, v as OrganizationInvitation, w as OrganizationTeam, x as OrganizationMemberPage, y as OrganizationInvitationPage, z as RecentAuthenticationStatus } from "./types-Sh23XMKv.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 CreateOrganizationMemberInvitationInput, type CreatedOrganizationMemberInvitation, type CreatedOrganizationTeam, type DriveCredential, type DriveCredentialInput, type FinuevaAuthClient, type InvitationAcceptance, type OrganizationDisplay, type OrganizationInvitation, type OrganizationInvitationPage, type OrganizationMember, 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 SendVerificationEmailInput, type SignInInput, type SocialIdTokenInput, type SocialIdTokenProvider, type UpdateOrganizationDisplayInput, type UpdateOrganizationTeamDisplayInput, type UpdateProfileInput, 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 CreatedOrganizationMemberInvitation, type CreatedOrganizationTeam, type DriveCredential, type DriveCredentialInput, type FinuevaAuthClient, type InvitationAcceptance, type OrganizationDisplay, type OrganizationInvitation, type OrganizationInvitationPage, type OrganizationMember, 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 WorkspaceSelection, createAuthClient };
|
package/dist/index.js
CHANGED
|
@@ -2544,6 +2544,7 @@ const messages = {
|
|
|
2544
2544
|
invalid_invitation: "The invitation is invalid.",
|
|
2545
2545
|
invitation_unavailable: "The invitation is not available.",
|
|
2546
2546
|
invitation_recipient_mismatch: "The invitation cannot be accepted by this account.",
|
|
2547
|
+
invitation_recovery_required: "Invitation administration requires separate recovery.",
|
|
2547
2548
|
email_verification_required: "Email verification is required.",
|
|
2548
2549
|
invalid_workspace_selection: "The workspace selection is invalid.",
|
|
2549
2550
|
organization_context_too_large: "The organization context is too large.",
|
|
@@ -3067,6 +3068,20 @@ function normalizeCreatedOrganizationMemberInvitation(value) {
|
|
|
3067
3068
|
expiresAt: responseDate(value.expiresAt)
|
|
3068
3069
|
};
|
|
3069
3070
|
}
|
|
3071
|
+
function normalizeResentOrganizationInvitation(value, invitationId) {
|
|
3072
|
+
const invitation = normalizeCreatedOrganizationMemberInvitation(value);
|
|
3073
|
+
if (invitation.id !== invitationId) throw authorityUnavailable();
|
|
3074
|
+
return invitation;
|
|
3075
|
+
}
|
|
3076
|
+
function normalizeOrganizationInvitationAdministrationInput(idempotencyKey) {
|
|
3077
|
+
if (!boundedString(idempotencyKey, 255)) throw new AuthError("invalid_request", 400);
|
|
3078
|
+
return { idempotencyKey };
|
|
3079
|
+
}
|
|
3080
|
+
function normalizeCanceledOrganizationInvitation(value) {
|
|
3081
|
+
exact(value, ["status"]);
|
|
3082
|
+
if (value.status !== "canceled") throw authorityUnavailable();
|
|
3083
|
+
return { status: "canceled" };
|
|
3084
|
+
}
|
|
3070
3085
|
function normalizeOrganizations(value) {
|
|
3071
3086
|
exact(value, ["nextCursor", "organizations"]);
|
|
3072
3087
|
if (!Array.isArray(value.organizations) || value.organizations.length > 100) throw authorityUnavailable();
|
|
@@ -3298,6 +3313,10 @@ function fromOrganizationMutationAuthorityError(value, status, retryAfter) {
|
|
|
3298
3313
|
if (status === 403 && code === "REQUEST_ORIGIN_DENIED") return new AuthError("request_origin_denied", 403);
|
|
3299
3314
|
return fromOrganizationReadAuthorityError(value, status);
|
|
3300
3315
|
}
|
|
3316
|
+
function fromOrganizationInvitationAdministrationError(value, status, retryAfter) {
|
|
3317
|
+
if (status === 422 && isObject(value) && value.code === "RECOVERY_REQUIRED") return new AuthError("invitation_recovery_required", 422);
|
|
3318
|
+
return fromOrganizationMutationAuthorityError(value, status, retryAfter);
|
|
3319
|
+
}
|
|
3301
3320
|
function normalizePlatformRoleChangeRecentAuthenticationInput(value) {
|
|
3302
3321
|
if (!isObject(value) || Object.keys(value).sort().join(",") !== "changeReference,expectedGlobalRevision,expectedTargetRevision,idempotencyKey,reasonCategory,requestedRoles,targetUserId") throw new TypeError("recent authentication input is invalid");
|
|
3303
3322
|
if (!isId(value.targetUserId)) throw new TypeError("targetUserId is invalid");
|
|
@@ -4943,6 +4962,40 @@ function createAuthClient(options) {
|
|
|
4943
4962
|
if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
|
|
4944
4963
|
return normalizeCreatedOrganizationMemberInvitation(value);
|
|
4945
4964
|
},
|
|
4965
|
+
async resendOrganizationInvitation(organizationId, invitationId, idempotencyKey) {
|
|
4966
|
+
const organization = normalizeIdInput(organizationId);
|
|
4967
|
+
const invitation = normalizeIdInput(invitationId);
|
|
4968
|
+
const body = normalizeOrganizationInvitationAdministrationInput(idempotencyKey);
|
|
4969
|
+
if (signOutRequest || activeAccountMutationGeneration !== void 0 || invitationRequest) throw new AuthError("state_conflict", 409);
|
|
4970
|
+
const generation = authorityGeneration;
|
|
4971
|
+
const value = await requestJson(joinURL(authOrigin, "api/v1/auth/organizations", organization, "invitations", invitation, "resend"), {
|
|
4972
|
+
fetch: fetchImpl,
|
|
4973
|
+
timeoutMs,
|
|
4974
|
+
method: "POST",
|
|
4975
|
+
headers: { "content-type": "application/json" },
|
|
4976
|
+
body,
|
|
4977
|
+
mapError: fromOrganizationInvitationAdministrationError
|
|
4978
|
+
});
|
|
4979
|
+
if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
|
|
4980
|
+
return normalizeResentOrganizationInvitation(value, invitation);
|
|
4981
|
+
},
|
|
4982
|
+
async cancelOrganizationInvitation(organizationId, invitationId, idempotencyKey) {
|
|
4983
|
+
const organization = normalizeIdInput(organizationId);
|
|
4984
|
+
const invitation = normalizeIdInput(invitationId);
|
|
4985
|
+
const body = normalizeOrganizationInvitationAdministrationInput(idempotencyKey);
|
|
4986
|
+
if (signOutRequest || activeAccountMutationGeneration !== void 0 || invitationRequest) throw new AuthError("state_conflict", 409);
|
|
4987
|
+
const generation = authorityGeneration;
|
|
4988
|
+
const value = await requestJson(joinURL(authOrigin, "api/v1/auth/organizations", organization, "invitations", invitation, "cancel"), {
|
|
4989
|
+
fetch: fetchImpl,
|
|
4990
|
+
timeoutMs,
|
|
4991
|
+
method: "POST",
|
|
4992
|
+
headers: { "content-type": "application/json" },
|
|
4993
|
+
body,
|
|
4994
|
+
mapError: fromOrganizationInvitationAdministrationError
|
|
4995
|
+
});
|
|
4996
|
+
if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
|
|
4997
|
+
return normalizeCanceledOrganizationInvitation(value);
|
|
4998
|
+
},
|
|
4946
4999
|
async updateOrganizationDisplay(organizationId, input) {
|
|
4947
5000
|
const id = normalizeIdInput(organizationId);
|
|
4948
5001
|
const desired = normalizeOrganizationDisplayInput(input);
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as ResentOrganizationInvitation, C as OrganizationPageInput, D as OrganizationTeamPage, E as OrganizationTeamMemberPage, G as UpdateOrganizationDisplayInput, J as WorkspaceSelection, K as UpdateOrganizationTeamDisplayInput, L as ReceivedOrganizationInvitation, O as OrganizationWorkspaceSelection, R as ReceivedOrganizationInvitationPage, S as OrganizationPage, T as OrganizationTeamDisplay, U as SocialIdTokenInput, W as SocialIdTokenProvider, X as AuthErrorCode, Y as AuthError, Z as AuthErrorStatus, _ as OrganizationDisplay, b as OrganizationMember, c as AuthUser, d as CreatedOrganizationMemberInvitation, f as CreatedOrganizationTeam, g as InvitationAcceptance, k as PersonalWorkspaceSelection, l as CanceledOrganizationInvitation, m as DriveCredentialInput, o as AuthSession, p as DriveCredential, r as AuthOrganization, t as AcceptInvitationInput, u as CreateOrganizationMemberInvitationInput, v as OrganizationInvitation, w as OrganizationTeam, x as OrganizationMemberPage, y as OrganizationInvitationPage } from "./types-Sh23XMKv.js";
|
|
2
2
|
//#region src/server.d.ts
|
|
3
3
|
interface ServerAuthOptions {
|
|
4
4
|
authOrigin: string;
|
|
@@ -24,6 +24,8 @@ interface FinuevaServerAuth {
|
|
|
24
24
|
getOrganization(organizationId: string): Promise<AuthOrganization>;
|
|
25
25
|
createOrganizationTeam(organizationId: string, name: string, idempotencyKey: string): Promise<CreatedOrganizationTeam>;
|
|
26
26
|
createOrganizationMemberInvitation(organizationId: string, input: CreateOrganizationMemberInvitationInput): Promise<CreatedOrganizationMemberInvitation>;
|
|
27
|
+
resendOrganizationInvitation(organizationId: string, invitationId: string, idempotencyKey: string): Promise<ResentOrganizationInvitation>;
|
|
28
|
+
cancelOrganizationInvitation(organizationId: string, invitationId: string, idempotencyKey: string): Promise<CanceledOrganizationInvitation>;
|
|
27
29
|
updateOrganizationDisplay(organizationId: string, input: UpdateOrganizationDisplayInput): Promise<OrganizationDisplay>;
|
|
28
30
|
updateOrganizationTeamDisplay(organizationId: string, teamId: string, input: UpdateOrganizationTeamDisplayInput): Promise<OrganizationTeamDisplay>;
|
|
29
31
|
listOrganizationMembers(organizationId: string, input?: OrganizationPageInput): Promise<OrganizationMemberPage>;
|
|
@@ -39,4 +41,4 @@ interface FinuevaServerAuth {
|
|
|
39
41
|
}
|
|
40
42
|
declare function createServerAuth(options: ServerAuthOptions): FinuevaServerAuth;
|
|
41
43
|
//#endregion
|
|
42
|
-
export { type AcceptInvitationInput, AuthError, type AuthErrorCode, type AuthErrorStatus, type AuthOrganization, type AuthSession, type AuthUser, type CreateOrganizationMemberInvitationInput, type CreatedOrganizationMemberInvitation, type CreatedOrganizationTeam, type DriveCredential, type DriveCredentialInput, FinuevaServerAuth, type InvitationAcceptance, type OrganizationDisplay, type OrganizationInvitation, type OrganizationInvitationPage, type OrganizationMember, type OrganizationMemberPage, type OrganizationPage, type OrganizationPageInput, type OrganizationTeam, type OrganizationTeamDisplay, type OrganizationTeamMemberPage, type OrganizationTeamPage, type OrganizationWorkspaceSelection, type PersonalWorkspaceSelection, type ReceivedOrganizationInvitation, type ReceivedOrganizationInvitationPage, ServerAuthOptions, ServerInvitationAcceptance, ServerSignOutResult, ServerSocialIdTokenSession, type SocialIdTokenInput, type SocialIdTokenProvider, type UpdateOrganizationDisplayInput, type UpdateOrganizationTeamDisplayInput, type WorkspaceSelection, createServerAuth };
|
|
44
|
+
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, FinuevaServerAuth, type InvitationAcceptance, type OrganizationDisplay, type OrganizationInvitation, type OrganizationInvitationPage, type OrganizationMember, type OrganizationMemberPage, type OrganizationPage, type OrganizationPageInput, type OrganizationTeam, type OrganizationTeamDisplay, type OrganizationTeamMemberPage, type OrganizationTeamPage, type OrganizationWorkspaceSelection, type PersonalWorkspaceSelection, type ReceivedOrganizationInvitation, type ReceivedOrganizationInvitationPage, type ResentOrganizationInvitation, ServerAuthOptions, ServerInvitationAcceptance, ServerSignOutResult, ServerSocialIdTokenSession, type SocialIdTokenInput, type SocialIdTokenProvider, type UpdateOrganizationDisplayInput, type UpdateOrganizationTeamDisplayInput, type WorkspaceSelection, createServerAuth };
|
package/dist/server.js
CHANGED
|
@@ -185,6 +185,7 @@ const messages = {
|
|
|
185
185
|
invalid_invitation: "The invitation is invalid.",
|
|
186
186
|
invitation_unavailable: "The invitation is not available.",
|
|
187
187
|
invitation_recipient_mismatch: "The invitation cannot be accepted by this account.",
|
|
188
|
+
invitation_recovery_required: "Invitation administration requires separate recovery.",
|
|
188
189
|
email_verification_required: "Email verification is required.",
|
|
189
190
|
invalid_workspace_selection: "The workspace selection is invalid.",
|
|
190
191
|
organization_context_too_large: "The organization context is too large.",
|
|
@@ -673,6 +674,20 @@ function normalizeCreatedOrganizationMemberInvitation(value) {
|
|
|
673
674
|
expiresAt: responseDate(value.expiresAt)
|
|
674
675
|
};
|
|
675
676
|
}
|
|
677
|
+
function normalizeResentOrganizationInvitation(value, invitationId) {
|
|
678
|
+
const invitation = normalizeCreatedOrganizationMemberInvitation(value);
|
|
679
|
+
if (invitation.id !== invitationId) throw authorityUnavailable();
|
|
680
|
+
return invitation;
|
|
681
|
+
}
|
|
682
|
+
function normalizeOrganizationInvitationAdministrationInput(idempotencyKey) {
|
|
683
|
+
if (!boundedString(idempotencyKey, 255)) throw new AuthError("invalid_request", 400);
|
|
684
|
+
return { idempotencyKey };
|
|
685
|
+
}
|
|
686
|
+
function normalizeCanceledOrganizationInvitation(value) {
|
|
687
|
+
exact(value, ["status"]);
|
|
688
|
+
if (value.status !== "canceled") throw authorityUnavailable();
|
|
689
|
+
return { status: "canceled" };
|
|
690
|
+
}
|
|
676
691
|
function normalizeOrganizations(value) {
|
|
677
692
|
exact(value, ["nextCursor", "organizations"]);
|
|
678
693
|
if (!Array.isArray(value.organizations) || value.organizations.length > 100) throw authorityUnavailable();
|
|
@@ -890,6 +905,10 @@ function fromOrganizationMutationAuthorityError(value, status, retryAfter) {
|
|
|
890
905
|
if (status === 403 && code === "REQUEST_ORIGIN_DENIED") return new AuthError("request_origin_denied", 403);
|
|
891
906
|
return fromOrganizationReadAuthorityError(value, status);
|
|
892
907
|
}
|
|
908
|
+
function fromOrganizationInvitationAdministrationError(value, status, retryAfter) {
|
|
909
|
+
if (status === 422 && isObject(value) && value.code === "RECOVERY_REQUIRED") return new AuthError("invitation_recovery_required", 422);
|
|
910
|
+
return fromOrganizationMutationAuthorityError(value, status, retryAfter);
|
|
911
|
+
}
|
|
893
912
|
function fromInvitationAuthorityError(value, status) {
|
|
894
913
|
const code = isObject(value) && typeof value.code === "string" ? value.code : void 0;
|
|
895
914
|
if (status === 401 && code === "UNAUTHORIZED") return new AuthError("authentication_required", 401);
|
|
@@ -1186,6 +1205,42 @@ function createServerAuth(options) {
|
|
|
1186
1205
|
mapError: fromOrganizationMutationAuthorityError
|
|
1187
1206
|
}));
|
|
1188
1207
|
},
|
|
1208
|
+
async resendOrganizationInvitation(organizationId, invitationId, idempotencyKey) {
|
|
1209
|
+
if (authorization) throw new AuthError("authentication_required", 401);
|
|
1210
|
+
const organization = normalizeIdInput(organizationId);
|
|
1211
|
+
const invitation = normalizeIdInput(invitationId);
|
|
1212
|
+
const body = normalizeOrganizationInvitationAdministrationInput(idempotencyKey);
|
|
1213
|
+
return normalizeResentOrganizationInvitation(await requestJson(joinURL(authOrigin, "api/v1/auth/organizations", organization, "invitations", invitation, "resend"), {
|
|
1214
|
+
fetch: fetchImpl,
|
|
1215
|
+
timeoutMs,
|
|
1216
|
+
method: "POST",
|
|
1217
|
+
credentials,
|
|
1218
|
+
headers: {
|
|
1219
|
+
...authHeaders(),
|
|
1220
|
+
"content-type": "application/json"
|
|
1221
|
+
},
|
|
1222
|
+
body,
|
|
1223
|
+
mapError: fromOrganizationInvitationAdministrationError
|
|
1224
|
+
}), invitation);
|
|
1225
|
+
},
|
|
1226
|
+
async cancelOrganizationInvitation(organizationId, invitationId, idempotencyKey) {
|
|
1227
|
+
if (authorization) throw new AuthError("authentication_required", 401);
|
|
1228
|
+
const organization = normalizeIdInput(organizationId);
|
|
1229
|
+
const invitation = normalizeIdInput(invitationId);
|
|
1230
|
+
const body = normalizeOrganizationInvitationAdministrationInput(idempotencyKey);
|
|
1231
|
+
return normalizeCanceledOrganizationInvitation(await requestJson(joinURL(authOrigin, "api/v1/auth/organizations", organization, "invitations", invitation, "cancel"), {
|
|
1232
|
+
fetch: fetchImpl,
|
|
1233
|
+
timeoutMs,
|
|
1234
|
+
method: "POST",
|
|
1235
|
+
credentials,
|
|
1236
|
+
headers: {
|
|
1237
|
+
...authHeaders(),
|
|
1238
|
+
"content-type": "application/json"
|
|
1239
|
+
},
|
|
1240
|
+
body,
|
|
1241
|
+
mapError: fromOrganizationInvitationAdministrationError
|
|
1242
|
+
}));
|
|
1243
|
+
},
|
|
1189
1244
|
async updateOrganizationDisplay(organizationId, input) {
|
|
1190
1245
|
const id = normalizeIdInput(organizationId);
|
|
1191
1246
|
const desired = normalizeOrganizationDisplayInput(input);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/errors.d.ts
|
|
2
|
-
type AuthErrorCode = "invalid_credentials" | "invalid_auth_input" | "account_conflict" | "password_reset_invalid" | "authentication_required" | "request_origin_denied" | "invalid_request" | "invalid_invitation" | "invitation_unavailable" | "invitation_recipient_mismatch" | "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";
|
|
2
|
+
type AuthErrorCode = "invalid_credentials" | "invalid_auth_input" | "account_conflict" | "password_reset_invalid" | "authentication_required" | "request_origin_denied" | "invalid_request" | "invalid_invitation" | "invitation_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";
|
|
3
3
|
type AuthErrorStatus = 400 | 401 | 403 | 404 | 409 | 413 | 415 | 422 | 429 | 503;
|
|
4
4
|
declare class AuthError extends Error {
|
|
5
5
|
readonly code: AuthErrorCode;
|
|
@@ -86,6 +86,13 @@ interface CreatedOrganizationMemberInvitation {
|
|
|
86
86
|
id: string;
|
|
87
87
|
expiresAt: Date;
|
|
88
88
|
}
|
|
89
|
+
interface ResentOrganizationInvitation {
|
|
90
|
+
id: string;
|
|
91
|
+
expiresAt: Date;
|
|
92
|
+
}
|
|
93
|
+
interface CanceledOrganizationInvitation {
|
|
94
|
+
status: "canceled";
|
|
95
|
+
}
|
|
89
96
|
interface OrganizationTeamPage {
|
|
90
97
|
teams: OrganizationTeam[];
|
|
91
98
|
nextCursor: string | null;
|
|
@@ -282,6 +289,8 @@ interface FinuevaAuthClient {
|
|
|
282
289
|
getOrganization(organizationId: string): Promise<AuthOrganization>;
|
|
283
290
|
createOrganizationTeam(organizationId: string, name: string, idempotencyKey: string): Promise<CreatedOrganizationTeam>;
|
|
284
291
|
createOrganizationMemberInvitation(organizationId: string, input: CreateOrganizationMemberInvitationInput): Promise<CreatedOrganizationMemberInvitation>;
|
|
292
|
+
resendOrganizationInvitation(organizationId: string, invitationId: string, idempotencyKey: string): Promise<ResentOrganizationInvitation>;
|
|
293
|
+
cancelOrganizationInvitation(organizationId: string, invitationId: string, idempotencyKey: string): Promise<CanceledOrganizationInvitation>;
|
|
285
294
|
updateOrganizationDisplay(organizationId: string, input: UpdateOrganizationDisplayInput): Promise<OrganizationDisplay>;
|
|
286
295
|
updateOrganizationTeamDisplay(organizationId: string, teamId: string, input: UpdateOrganizationTeamDisplayInput): Promise<OrganizationTeamDisplay>;
|
|
287
296
|
changeOrganizationMemberManualRole(organizationId: string, targetMembershipId: string, input: OrganizationManualRoleChangeInput): Promise<OrganizationManualRoleChangeResult>;
|
|
@@ -307,4 +316,4 @@ interface FinuevaAuthClient {
|
|
|
307
316
|
onSessionChange(listener: (session: AuthSession | null) => void): () => void;
|
|
308
317
|
}
|
|
309
318
|
//#endregion
|
|
310
|
-
export {
|
|
319
|
+
export { PlatformBootstrapRoleChangeInput as A, ResentOrganizationInvitation as B, OrganizationPageInput as C, OrganizationTeamPage as D, OrganizationTeamMemberPage as E, PlatformRoleFirstApproval as F, UpdateOrganizationDisplayInput as G, SignInInput as H, PlatformStatus as I, WorkspaceSelection as J, UpdateOrganizationTeamDisplayInput as K, ReceivedOrganizationInvitation as L, PlatformRoleApplied as M, PlatformRoleApproval as N, OrganizationWorkspaceSelection as O, PlatformRoleChangeRecentAuthenticationInput as P, ReceivedOrganizationInvitationPage as R, OrganizationPage as S, OrganizationTeamDisplay as T, SocialIdTokenInput as U, SendVerificationEmailInput as V, SocialIdTokenProvider as W, AuthErrorCode as X, AuthError as Y, AuthErrorStatus as Z, OrganizationDisplay as _, AuthPersistenceDriver as a, OrganizationMember as b, AuthUser as c, CreatedOrganizationMemberInvitation as d, CreatedOrganizationTeam as f, InvitationAcceptance as g, FinuevaAuthClient as h, AuthPersistence as i, PlatformRole as j, PersonalWorkspaceSelection as k, CanceledOrganizationInvitation as l, DriveCredentialInput as m, AuthClientOptions as n, AuthSession as o, DriveCredential as p, UpdateProfileInput as q, AuthOrganization as r, AuthState as s, AcceptInvitationInput as t, CreateOrganizationMemberInvitationInput as u, OrganizationInvitation as v, OrganizationTeam as w, OrganizationMemberPage as x, OrganizationInvitationPage as y, RecentAuthenticationStatus as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finueva/auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Public browser and server SDK for Finueva Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"lint": "oxlint . --deny-warnings",
|
|
44
44
|
"prepack": "pnpm build",
|
|
45
45
|
"test": "pnpm test:unit && pnpm build && pnpm test:package",
|
|
46
|
-
"test:composition": "node scripts/test
|
|
47
|
-
"test:package": "node scripts/test
|
|
46
|
+
"test:composition": "node scripts/test/composition/runner.mjs",
|
|
47
|
+
"test:package": "node scripts/test/package.mjs",
|
|
48
48
|
"test:unit": "vitest run",
|
|
49
49
|
"typecheck": "tsc --noEmit"
|
|
50
50
|
},
|