@finueva/auth 0.17.0 → 0.18.1

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as UserApiCredential, A as PersonalWorkspaceSelection, B as RecentAuthenticationStatus, C as OrganizationPage, D as OrganizationTeamMemberPage, E as OrganizationTeamDisplay, F as PlatformRoleChangeRecentAuthenticationInput, G as SocialIdTokenProvider, H as SendVerificationEmailInput, I as PlatformRoleFirstApproval, J as UpdateProfileInput, K as UpdateOrganizationDisplayInput, L as PlatformStatus, M as PlatformRole, N as PlatformRoleApplied, O as OrganizationTeamPage, P as PlatformRoleApproval, Q as AuthErrorStatus, R as ReceivedOrganizationInvitation, S as OrganizationMemberPage, T as OrganizationTeam, U as SignInInput, V as ResentOrganizationInvitation, W as SocialIdTokenInput, X as AuthError, Y as WorkspaceSelection, Z as AuthErrorCode, _ as OrganizationDisplay, a as AuthPersistenceDriver, b as OrganizationMember, c as AuthUser, d as CreatedOrganizationMemberInvitation, et as UserApiCredentialInput, f as CreatedOrganizationTeam, g as InvitationAcceptance, h as FinuevaAuthClient, i as AuthPersistence, j as PlatformBootstrapRoleChangeInput, k as OrganizationWorkspaceSelection, l as CanceledOrganizationInvitation, m as DriveCredentialInput, n as AuthClientOptions, o as AuthSession, p as DriveCredential, q as UpdateOrganizationTeamDisplayInput, r as AuthOrganization, s as AuthState, t as AcceptInvitationInput, u as CreateOrganizationMemberInvitationInput, v as OrganizationInvitation, w as OrganizationPageInput, x as OrganizationMemberAuthority, y as OrganizationInvitationPage, z as ReceivedOrganizationInvitationPage } from "./types-CqFT4G95.js";
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
@@ -2291,7 +2291,7 @@ const passkeyClient = () => {
2291
2291
  };
2292
2292
  };
2293
2293
  //#endregion
2294
- //#region ../../node_modules/.pnpm/@chiballc+utils@2.5.1_@hono+zod-openapi@1.5.1_hono@4.13.0_zod@4.4.3__hono@4.13.0_magic-_dfcdb59639d9fe73412dad0223379a88/node_modules/@chiballc/utils/dist/index.mjs
2294
+ //#region ../../node_modules/.pnpm/@chiballc+utils@2.5.1_@hono+zod-openapi@1.5.1_hono@4.13.0_zod@4.4.3__hono@4.13.0_magic-_80fa16dd1813631ddeb36d2ee29b8660/node_modules/@chiballc/utils/dist/index.mjs
2295
2295
  function isPromise(arg) {
2296
2296
  return arg && typeof arg.then === "function";
2297
2297
  }
@@ -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");
@@ -3643,6 +3683,18 @@ function unique(items, key) {
3643
3683
  if (new Set(items.map(key)).size !== items.length) throw authorityUnavailable();
3644
3684
  return items;
3645
3685
  }
3686
+ function credentialSessionId(token) {
3687
+ const parts = token.split(".");
3688
+ if (parts.length !== 3 || !/^[A-Za-z0-9_-]+$/.test(parts[1])) return void 0;
3689
+ try {
3690
+ const base64 = parts[1].replaceAll("-", "+").replaceAll("_", "/");
3691
+ const decoded = atob(base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "="));
3692
+ const payload = JSON.parse(decoded);
3693
+ return isObject(payload) && typeof payload.sid === "string" && payload.sid.length > 0 ? payload.sid : void 0;
3694
+ } catch {
3695
+ return;
3696
+ }
3697
+ }
3646
3698
  function isObject(value) {
3647
3699
  return typeof value === "object" && value !== null && !Array.isArray(value);
3648
3700
  }
@@ -4469,7 +4521,7 @@ function normalizeUserApiCredential(value, startedAt) {
4469
4521
  expiresAt: new Date(startedAt + value.expiresIn * 1e3)
4470
4522
  };
4471
4523
  }
4472
- function createUserApiCredentialCache(issue, now) {
4524
+ function createUserApiCredentialCache(issue, now, currentSessionId = () => void 0) {
4473
4525
  let generation = 0;
4474
4526
  let cached;
4475
4527
  let pending;
@@ -4479,6 +4531,12 @@ function createUserApiCredentialCache(issue, now) {
4479
4531
  });
4480
4532
  return {
4481
4533
  hasAuthority: () => Boolean(cached || pending),
4534
+ retainSession(sessionId) {
4535
+ if (cached?.sessionId === sessionId && !pending) return;
4536
+ generation += 1;
4537
+ cached = void 0;
4538
+ pending = void 0;
4539
+ },
4482
4540
  clear() {
4483
4541
  generation += 1;
4484
4542
  cached = void 0;
@@ -4502,10 +4560,14 @@ function createUserApiCredentialCache(issue, now) {
4502
4560
  const value = normalizeUserApiCredential(await issue(applicationId), startedAt);
4503
4561
  if (epoch !== generation) throw new AuthError("state_conflict", 409);
4504
4562
  if (now() < startedAt || value.expiresAt.getTime() <= now()) throw new AuthError("authentication_required", 401);
4563
+ const sessionId = credentialSessionId(value.token);
4564
+ const observed = currentSessionId();
4565
+ if (observed !== void 0 && sessionId !== void 0 && sessionId !== observed) throw new AuthError("authentication_required", 401);
4505
4566
  cached = {
4506
4567
  applicationId,
4507
4568
  token: value.token,
4508
- expiresAt: value.expiresAt.getTime()
4569
+ expiresAt: value.expiresAt.getTime(),
4570
+ sessionId
4509
4571
  };
4510
4572
  return value;
4511
4573
  })().finally(() => {
@@ -4538,7 +4600,7 @@ function createAuthClient(options) {
4538
4600
  method: "POST",
4539
4601
  headers: { "content-type": "application/json; charset=utf-8" },
4540
4602
  body: { applicationId }
4541
- }), now);
4603
+ }), now, () => sessionId);
4542
4604
  const betterAuth = createAuthClient$1({
4543
4605
  baseURL: authOrigin,
4544
4606
  basePath: "/api/v1/auth",
@@ -4700,9 +4762,12 @@ function createAuthClient(options) {
4700
4762
  credentialGeneration += 1;
4701
4763
  }
4702
4764
  function updateSession(session) {
4703
- const unboundCredential = !sessionId && (credential || credentialRequests.size > 0 || userApiCredentials.hasAuthority());
4704
4765
  const changedSession = sessionId === void 0 ? !sessionAuthorityObserved || session !== null : !session || session.id !== sessionId || session.user.id !== sessionUserId;
4705
- if (!session || unboundCredential || sessionId && (session.id !== sessionId || session.user.id !== sessionUserId)) clearCredential();
4766
+ if (!session || sessionId && (session.id !== sessionId || session.user.id !== sessionUserId)) clearCredential();
4767
+ else if (!sessionId) {
4768
+ if (credential && credential.sessionId !== session.id) credential = void 0;
4769
+ userApiCredentials.retainSession(session.id);
4770
+ }
4706
4771
  if (changedSession || recentAuthenticationStartAttempt && (recentAuthenticationStartAttempt.sessionId !== session?.id || recentAuthenticationStartAttempt.userId !== session?.user.id)) recentAuthenticationStartAttempt = void 0;
4707
4772
  if (changedSession) sessionAuthorityEpoch += 1;
4708
4773
  sessionAuthorityObserved = true;
@@ -5049,6 +5114,21 @@ function createAuthClient(options) {
5049
5114
  const member = normalizeIdInput(memberId);
5050
5115
  return organizationRead(`${organization}/members/${member}/authority`, void 0, (value) => normalizeOrganizationMemberAuthority(value, organization, member));
5051
5116
  },
5117
+ async createOrganization(name, slug, idempotencyKey) {
5118
+ const body = normalizeOrganizationCreationInput(name, slug, idempotencyKey);
5119
+ if (signOutRequest || activeAccountMutationGeneration !== void 0 || invitationRequest) throw new AuthError("state_conflict", 409);
5120
+ const generation = authorityGeneration;
5121
+ const value = await requestJson(joinURL(authOrigin, "api/v1/auth/organizations"), {
5122
+ fetch: fetchImpl,
5123
+ timeoutMs,
5124
+ method: "POST",
5125
+ headers: { "content-type": "application/json" },
5126
+ body,
5127
+ mapError: fromOrganizationMutationAuthorityError
5128
+ });
5129
+ if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
5130
+ return normalizeCreatedOrganization(value);
5131
+ },
5052
5132
  async createOrganizationTeam(organizationId, name, idempotencyKey) {
5053
5133
  const id = normalizeIdInput(organizationId);
5054
5134
  const body = normalizeOrganizationTeamCreationInput(name, idempotencyKey);
@@ -5115,6 +5195,39 @@ function createAuthClient(options) {
5115
5195
  if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
5116
5196
  return normalizeCanceledOrganizationInvitation(value);
5117
5197
  },
5198
+ async removeOrganizationMember(organizationId, memberId, idempotencyKey) {
5199
+ const organization = normalizeIdInput(organizationId);
5200
+ const member = normalizeIdInput(memberId);
5201
+ const body = normalizeOrganizationMembershipRemovalInput(idempotencyKey);
5202
+ if (signOutRequest || activeAccountMutationGeneration !== void 0 || invitationRequest) throw new AuthError("state_conflict", 409);
5203
+ const generation = authorityGeneration;
5204
+ const value = await requestJson(joinURL(authOrigin, "api/v1/auth/organizations", organization, "members", member, "remove"), {
5205
+ fetch: fetchImpl,
5206
+ timeoutMs,
5207
+ method: "POST",
5208
+ headers: { "content-type": "application/json" },
5209
+ body,
5210
+ mapError: fromOrganizationMembershipRemovalError
5211
+ });
5212
+ if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
5213
+ return normalizeRemovedOrganizationMember(value);
5214
+ },
5215
+ async leaveOrganization(organizationId, idempotencyKey) {
5216
+ const organization = normalizeIdInput(organizationId);
5217
+ const body = normalizeOrganizationMembershipRemovalInput(idempotencyKey);
5218
+ if (signOutRequest || activeAccountMutationGeneration !== void 0 || invitationRequest) throw new AuthError("state_conflict", 409);
5219
+ const generation = authorityGeneration;
5220
+ const value = await requestJson(joinURL(authOrigin, "api/v1/auth/organizations", organization, "leave"), {
5221
+ fetch: fetchImpl,
5222
+ timeoutMs,
5223
+ method: "POST",
5224
+ headers: { "content-type": "application/json" },
5225
+ body,
5226
+ mapError: fromOrganizationMembershipRemovalError
5227
+ });
5228
+ if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
5229
+ return normalizeOrganizationDeparture(value);
5230
+ },
5118
5231
  async updateOrganizationDisplay(organizationId, input) {
5119
5232
  const id = normalizeIdInput(organizationId);
5120
5233
  const desired = normalizeOrganizationDisplayInput(input);
@@ -5302,9 +5415,12 @@ function createAuthClient(options) {
5302
5415
  if (error) throw error;
5303
5416
  const nextCredential = normalizeDriveCredential(result, now());
5304
5417
  if (generation !== credentialGeneration) throw new AuthError("authentication_required", 401);
5418
+ const issuedFor = credentialSessionId(nextCredential.token);
5419
+ if (sessionId !== void 0 && issuedFor !== void 0 && issuedFor !== sessionId) throw new AuthError("authentication_required", 401);
5305
5420
  if (selectedWorkspaceKey === workspaceKey) credential = {
5306
5421
  key: workspaceKey,
5307
- value: nextCredential
5422
+ value: nextCredential,
5423
+ sessionId: issuedFor
5308
5424
  };
5309
5425
  return nextCredential;
5310
5426
  })().finally(() => {
package/dist/server.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as UserApiCredential, A as PersonalWorkspaceSelection, C as OrganizationPage, D as OrganizationTeamMemberPage, E as OrganizationTeamDisplay, G as SocialIdTokenProvider, K as UpdateOrganizationDisplayInput, O as OrganizationTeamPage, Q as AuthErrorStatus, R as ReceivedOrganizationInvitation, S as OrganizationMemberPage, T as OrganizationTeam, V as ResentOrganizationInvitation, W as SocialIdTokenInput, X as AuthError, Y as WorkspaceSelection, Z as AuthErrorCode, _ as OrganizationDisplay, b as OrganizationMember, c as AuthUser, d as CreatedOrganizationMemberInvitation, et as UserApiCredentialInput, f as CreatedOrganizationTeam, g as InvitationAcceptance, k as OrganizationWorkspaceSelection, l as CanceledOrganizationInvitation, m as DriveCredentialInput, o as AuthSession, p as DriveCredential, q as UpdateOrganizationTeamDisplayInput, r as AuthOrganization, t as AcceptInvitationInput, u as CreateOrganizationMemberInvitationInput, v as OrganizationInvitation, w as OrganizationPageInput, x as OrganizationMemberAuthority, y as OrganizationInvitationPage, z as ReceivedOrganizationInvitationPage } from "./types-CqFT4G95.js";
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 };