@finueva/auth 0.8.1 → 0.10.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/dist/device.js CHANGED
@@ -444,6 +444,7 @@ const messages = {
444
444
  password_reset_invalid: "The password reset request is invalid.",
445
445
  authentication_required: "Authentication is required.",
446
446
  request_origin_denied: "The request origin is not allowed.",
447
+ invalid_request: "The request is invalid.",
447
448
  invalid_invitation: "The invitation is invalid.",
448
449
  invitation_unavailable: "The invitation is not available.",
449
450
  invitation_recipient_mismatch: "The invitation cannot be accepted by this account.",
@@ -563,6 +564,284 @@ function normalizeDriveCredential(value, now) {
563
564
  expiresAt: new Date(now + value.expiresIn * 1e3)
564
565
  };
565
566
  }
567
+ function normalizeOrganizationPageInput(value) {
568
+ if (value === void 0) return new URLSearchParams();
569
+ if (!isObject(value) || Object.keys(value).some((key) => key !== "limit" && key !== "cursor")) throw new AuthError("invalid_request", 400);
570
+ const input = value;
571
+ const query = new URLSearchParams();
572
+ if (input.limit !== void 0) {
573
+ if (!Number.isSafeInteger(input.limit) || input.limit < 1 || input.limit > 100) throw new AuthError("invalid_request", 400);
574
+ query.set("limit", String(input.limit));
575
+ }
576
+ if (input.cursor !== void 0) {
577
+ if (typeof input.cursor !== "string" || input.cursor.length < 1 || input.cursor.length > 820 || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(input.cursor)) throw new AuthError("invalid_request", 400);
578
+ query.set("cursor", input.cursor);
579
+ }
580
+ return query;
581
+ }
582
+ function normalizeIdInput(value) {
583
+ if (!isId(value)) throw new AuthError("invalid_request", 400);
584
+ return value;
585
+ }
586
+ function normalizeOrganization(value) {
587
+ exact(value, [
588
+ "capabilities",
589
+ "id",
590
+ "lifecycle",
591
+ "logo",
592
+ "name",
593
+ "role",
594
+ "slug"
595
+ ]);
596
+ 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();
597
+ exact(value.capabilities, [
598
+ "readInvitations",
599
+ "readMembers",
600
+ "readTeams"
601
+ ]);
602
+ if (value.capabilities.readMembers !== true || value.capabilities.readTeams !== true || typeof value.capabilities.readInvitations !== "boolean") throw authorityUnavailable();
603
+ return {
604
+ id: value.id,
605
+ name: value.name,
606
+ slug: value.slug,
607
+ logo: nullableHttpsUrl(value.logo),
608
+ lifecycle: value.lifecycle,
609
+ role: value.role,
610
+ capabilities: {
611
+ readMembers: true,
612
+ readTeams: true,
613
+ readInvitations: value.capabilities.readInvitations
614
+ }
615
+ };
616
+ }
617
+ function normalizeOrganizationDisplayInput(value) {
618
+ if (!isObject(value) || Object.keys(value).sort().join(",") !== "logo,name,slug") throw new AuthError("invalid_request", 400);
619
+ if (!boundedString(value.name, 255) || !boundedString(value.slug, 255)) throw new AuthError("invalid_request", 400);
620
+ let logo;
621
+ try {
622
+ logo = nullableHttpsUrl(value.logo);
623
+ } catch {
624
+ throw new AuthError("invalid_request", 400);
625
+ }
626
+ return {
627
+ name: value.name,
628
+ slug: value.slug,
629
+ logo
630
+ };
631
+ }
632
+ function normalizeOrganizationDisplay(value) {
633
+ try {
634
+ return normalizeOrganizationDisplayInput(value);
635
+ } catch {
636
+ throw authorityUnavailable();
637
+ }
638
+ }
639
+ function normalizeOrganizationTeamDisplayInput(value) {
640
+ if (!isObject(value) || Object.keys(value).join(",") !== "name" || !boundedString(value.name, 255)) throw new AuthError("invalid_request", 400);
641
+ return { name: value.name };
642
+ }
643
+ function normalizeOrganizationTeamDisplay(value) {
644
+ try {
645
+ return normalizeOrganizationTeamDisplayInput(value);
646
+ } catch {
647
+ throw authorityUnavailable();
648
+ }
649
+ }
650
+ function normalizeOrganizationTeamCreationInput(name, idempotencyKey) {
651
+ if (!boundedString(name, 255) || !boundedString(idempotencyKey, 255)) throw new AuthError("invalid_request", 400);
652
+ return {
653
+ name,
654
+ idempotencyKey
655
+ };
656
+ }
657
+ function normalizeCreatedOrganizationTeam(value) {
658
+ exact(value, ["id", "name"]);
659
+ if (!isId(value.id) || !boundedString(value.name, 255)) throw authorityUnavailable();
660
+ return {
661
+ id: value.id,
662
+ name: value.name
663
+ };
664
+ }
665
+ function normalizeOrganizationMemberInvitationCreationInput(value) {
666
+ if (!isObject(value)) throw new AuthError("invalid_request", 400);
667
+ const keys = Object.keys(value).sort().join(",");
668
+ if (keys !== "email,idempotencyKey" && keys !== "email,idempotencyKey,teamIds") throw new AuthError("invalid_request", 400);
669
+ let normalizedEmail;
670
+ try {
671
+ normalizedEmail = normalizeEmail(value.email);
672
+ } catch {
673
+ throw new AuthError("invalid_request", 400);
674
+ }
675
+ if (new TextEncoder().encode(normalizedEmail).byteLength > 320 || !boundedString(value.idempotencyKey, 255) || value.teamIds !== void 0 && (!Array.isArray(value.teamIds) || value.teamIds.length > 100)) throw new AuthError("invalid_request", 400);
676
+ const teamIds = value.teamIds?.map((teamId) => normalizeIdInput(teamId));
677
+ if (teamIds && new Set(teamIds).size !== teamIds.length) throw new AuthError("invalid_request", 400);
678
+ return {
679
+ email: normalizedEmail,
680
+ ...teamIds === void 0 ? {} : { teamIds },
681
+ idempotencyKey: value.idempotencyKey
682
+ };
683
+ }
684
+ function normalizeCreatedOrganizationMemberInvitation(value) {
685
+ exact(value, ["expiresAt", "id"]);
686
+ if (!isId(value.id)) throw authorityUnavailable();
687
+ return {
688
+ id: value.id,
689
+ expiresAt: responseDate(value.expiresAt)
690
+ };
691
+ }
692
+ function normalizeOrganizations(value) {
693
+ exact(value, ["nextCursor", "organizations"]);
694
+ if (!Array.isArray(value.organizations) || value.organizations.length > 100) throw authorityUnavailable();
695
+ return {
696
+ organizations: unique(value.organizations.map(normalizeOrganization), (item) => item.id),
697
+ nextCursor: nullableCursor(value.nextCursor)
698
+ };
699
+ }
700
+ function normalizeOrganizationMembers(value) {
701
+ exact(value, ["members", "nextCursor"]);
702
+ if (!Array.isArray(value.members) || value.members.length > 100) throw authorityUnavailable();
703
+ return {
704
+ members: unique(value.members.map((member) => {
705
+ exact(member, [
706
+ "email",
707
+ "id",
708
+ "image",
709
+ "joinedAt",
710
+ "name",
711
+ "owner",
712
+ "role",
713
+ "teamIds",
714
+ "userId"
715
+ ]);
716
+ if (!isId(member.id) || !isId(member.userId) || !boundedString(member.name, 255) || typeof member.email !== "string" || member.email.length > 320 || !email.test(member.email) || !role(member.role) || typeof member.owner !== "boolean" || !Array.isArray(member.teamIds) || member.teamIds.length > 100) throw authorityUnavailable();
717
+ const teamIds = unique(member.teamIds.map((teamId) => normalizeResponseId(teamId)), (item) => item);
718
+ return {
719
+ id: member.id,
720
+ userId: member.userId,
721
+ name: member.name,
722
+ email: member.email,
723
+ image: nullableHttpsUrl(member.image),
724
+ role: member.role,
725
+ owner: member.owner,
726
+ joinedAt: responseDate(member.joinedAt),
727
+ teamIds
728
+ };
729
+ }), (item) => item.id),
730
+ nextCursor: nullableCursor(value.nextCursor)
731
+ };
732
+ }
733
+ function normalizeOrganizationTeams(value) {
734
+ exact(value, ["nextCursor", "teams"]);
735
+ if (!Array.isArray(value.teams) || value.teams.length > 100) throw authorityUnavailable();
736
+ return {
737
+ teams: unique(value.teams.map((team) => {
738
+ exact(team, [
739
+ "category",
740
+ "createdAt",
741
+ "id",
742
+ "name"
743
+ ]);
744
+ if (!isId(team.id) || !boundedString(team.name, 255) || team.category !== "manual" && team.category !== "managed") throw authorityUnavailable();
745
+ return {
746
+ id: team.id,
747
+ name: team.name,
748
+ category: team.category,
749
+ createdAt: responseDate(team.createdAt)
750
+ };
751
+ }), (item) => item.id),
752
+ nextCursor: nullableCursor(value.nextCursor)
753
+ };
754
+ }
755
+ function normalizeOrganizationTeamMembers(value) {
756
+ exact(value, ["memberIds", "nextCursor"]);
757
+ if (!Array.isArray(value.memberIds) || value.memberIds.length > 100) throw authorityUnavailable();
758
+ return {
759
+ memberIds: unique(value.memberIds.map((item) => normalizeResponseId(item)), (item) => item),
760
+ nextCursor: nullableCursor(value.nextCursor)
761
+ };
762
+ }
763
+ function normalizeOrganizationInvitation(value) {
764
+ exact(value, [
765
+ "createdAt",
766
+ "email",
767
+ "expiresAt",
768
+ "id",
769
+ "inviter",
770
+ "role",
771
+ "status",
772
+ "teamIds"
773
+ ]);
774
+ 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();
775
+ exact(value.inviter, ["membershipId", "name"]);
776
+ if (!isId(value.inviter.membershipId) || !boundedString(value.inviter.name, 255)) throw authorityUnavailable();
777
+ return {
778
+ id: value.id,
779
+ email: value.email,
780
+ role: value.role,
781
+ teamIds: unique(value.teamIds.map(normalizeResponseId), (item) => item),
782
+ inviter: {
783
+ membershipId: value.inviter.membershipId,
784
+ name: value.inviter.name
785
+ },
786
+ createdAt: responseDate(value.createdAt),
787
+ expiresAt: responseDate(value.expiresAt),
788
+ status: "pending"
789
+ };
790
+ }
791
+ function normalizeOrganizationInvitations(value) {
792
+ exact(value, ["invitations", "nextCursor"]);
793
+ if (!Array.isArray(value.invitations) || value.invitations.length > 100) throw authorityUnavailable();
794
+ return {
795
+ invitations: unique(value.invitations.map(normalizeOrganizationInvitation), (item) => item.id),
796
+ nextCursor: nullableCursor(value.nextCursor)
797
+ };
798
+ }
799
+ function normalizeReceivedInvitation(value) {
800
+ exact(value, [
801
+ "expiresAt",
802
+ "id",
803
+ "inviterName",
804
+ "organization",
805
+ "role",
806
+ "teams"
807
+ ]);
808
+ if (!isId(value.id) || !boundedString(value.inviterName, 255) || !role(value.role) || !Array.isArray(value.teams) || value.teams.length > 100 || !isObject(value.organization)) throw authorityUnavailable();
809
+ exact(value.organization, [
810
+ "id",
811
+ "logo",
812
+ "name",
813
+ "slug"
814
+ ]);
815
+ if (!isId(value.organization.id) || !boundedString(value.organization.name, 255) || !boundedString(value.organization.slug, 255)) throw authorityUnavailable();
816
+ return {
817
+ id: value.id,
818
+ organization: {
819
+ id: value.organization.id,
820
+ name: value.organization.name,
821
+ slug: value.organization.slug,
822
+ logo: nullableHttpsUrl(value.organization.logo)
823
+ },
824
+ role: value.role,
825
+ teams: unique(value.teams.map((team) => {
826
+ exact(team, ["id", "name"]);
827
+ if (!isId(team.id) || !boundedString(team.name, 255)) throw authorityUnavailable();
828
+ return {
829
+ id: team.id,
830
+ name: team.name
831
+ };
832
+ }), (item) => item.id),
833
+ inviterName: value.inviterName,
834
+ expiresAt: responseDate(value.expiresAt)
835
+ };
836
+ }
837
+ function normalizeReceivedInvitations(value) {
838
+ exact(value, ["invitations", "nextCursor"]);
839
+ if (!Array.isArray(value.invitations) || value.invitations.length > 100) throw authorityUnavailable();
840
+ return {
841
+ invitations: unique(value.invitations.map(normalizeReceivedInvitation), (item) => item.id),
842
+ nextCursor: nullableCursor(value.nextCursor)
843
+ };
844
+ }
566
845
  function normalizeWorkspaceSelection(value) {
567
846
  if (!isObject(value)) throw new AuthError("invalid_workspace_selection", 422);
568
847
  const keys = Object.keys(value);
@@ -600,6 +879,20 @@ function fromSocialIdTokenAuthorityError(value, status, retryAfter) {
600
879
  function authorityUnavailable() {
601
880
  return new AuthError("identity_authority_unavailable", 503);
602
881
  }
882
+ function fromOrganizationReadAuthorityError(value, status) {
883
+ if (status === 400) return new AuthError("invalid_request", 400);
884
+ if (status === 401) return new AuthError("authentication_required", 401);
885
+ if (status === 403) return new AuthError("access_denied", 403);
886
+ return authorityUnavailable();
887
+ }
888
+ function fromOrganizationMutationAuthorityError(value, status, retryAfter) {
889
+ if (status === 400 || status === 413 || status === 415) return new AuthError("invalid_request", 400);
890
+ if (status === 409) return new AuthError("state_conflict", 409);
891
+ if (status === 429) return new AuthError("auth_request_rate_limited", 429, parseRetryAfter(retryAfter));
892
+ const code = isObject(value) && typeof value.code === "string" ? value.code : void 0;
893
+ if (status === 403 && code === "REQUEST_ORIGIN_DENIED") return new AuthError("request_origin_denied", 403);
894
+ return fromOrganizationReadAuthorityError(value, status);
895
+ }
603
896
  function mapError(code, status) {
604
897
  if (code === "authentication_required") return {
605
898
  code,
@@ -674,6 +967,46 @@ function normalizeProfileImage(value) {
674
967
  function isId(value) {
675
968
  return typeof value === "string" && id.test(value);
676
969
  }
970
+ function exact(value, keys) {
971
+ if (!isObject(value) || Object.keys(value).sort().join(",") !== [...keys].sort().join(",")) throw authorityUnavailable();
972
+ }
973
+ function boundedString(value, maximum) {
974
+ return typeof value === "string" && value.length > 0 && new TextEncoder().encode(value).byteLength <= maximum;
975
+ }
976
+ function role(value) {
977
+ return value === "owner" || value === "admin" || value === "member";
978
+ }
979
+ function nullableHttpsUrl(value) {
980
+ if (value === null) return null;
981
+ if (typeof value !== "string" || value.length > 2048) throw authorityUnavailable();
982
+ let url;
983
+ try {
984
+ url = new URL(value);
985
+ } catch {
986
+ throw authorityUnavailable();
987
+ }
988
+ if (url.protocol !== "https:" || url.username || url.password || url.toString() !== value) throw authorityUnavailable();
989
+ return value;
990
+ }
991
+ function responseDate(value) {
992
+ if (typeof value !== "string") throw authorityUnavailable();
993
+ const date = new Date(value);
994
+ if (!Number.isFinite(date.getTime()) || date.toISOString() !== value) throw authorityUnavailable();
995
+ return date;
996
+ }
997
+ function nullableCursor(value) {
998
+ if (value === null) return null;
999
+ if (typeof value !== "string" || value.length < 1 || value.length > 820 || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(value)) throw authorityUnavailable();
1000
+ return value;
1001
+ }
1002
+ function normalizeResponseId(value) {
1003
+ if (!isId(value)) throw authorityUnavailable();
1004
+ return value;
1005
+ }
1006
+ function unique(items, key) {
1007
+ if (new Set(items.map(key)).size !== items.length) throw authorityUnavailable();
1008
+ return items;
1009
+ }
677
1010
  function isObject(value) {
678
1011
  return typeof value === "object" && value !== null && !Array.isArray(value);
679
1012
  }
@@ -700,18 +1033,18 @@ async function requestJsonResponse(url, options) {
700
1033
  }
701
1034
  const contentType = response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase();
702
1035
  if (response.status >= 300 || response.status < 200 || contentType !== "application/json") {
703
- const body = contentType === "application/json" ? await readJson(response) : void 0;
1036
+ const body = contentType === "application/json" ? await readJson(response, options.maxResponseBytes) : void 0;
704
1037
  await response.body?.cancel();
705
1038
  throw (options.mapError ?? fromAuthorityError)(body, response.status, response.headers.get("retry-after"));
706
1039
  }
707
1040
  return {
708
- value: await readJson(response),
1041
+ value: await readJson(response, options.maxResponseBytes),
709
1042
  headers: response.headers
710
1043
  };
711
1044
  }
712
- async function readJson(response) {
1045
+ async function readJson(response, maximum = MAX_RESPONSE_BYTES) {
713
1046
  const length = response.headers.get("content-length");
714
- if (length && (!/^\d+$/.test(length) || Number(length) > MAX_RESPONSE_BYTES)) {
1047
+ if (length && (!/^\d+$/.test(length) || Number(length) > maximum)) {
715
1048
  await response.body?.cancel();
716
1049
  throw authorityUnavailable();
717
1050
  }
@@ -724,7 +1057,7 @@ async function readJson(response) {
724
1057
  const { done, value } = await reader.read();
725
1058
  if (done) break;
726
1059
  size += value.byteLength;
727
- if (size > MAX_RESPONSE_BYTES) throw authorityUnavailable();
1060
+ if (size > maximum) throw authorityUnavailable();
728
1061
  chunks.push(value);
729
1062
  }
730
1063
  } catch (error) {
@@ -1092,6 +1425,20 @@ function createDeviceAuth(options) {
1092
1425
  }
1093
1426
  return session;
1094
1427
  }
1428
+ async function organizationRead(path, input, normalize) {
1429
+ const query = normalizeOrganizationPageInput(input);
1430
+ const current = await readToken();
1431
+ if (!current) throw new AuthError("authentication_required", 401);
1432
+ return normalize((await requestJsonResponse(`${joinURL(authOrigin, "api/v1/auth/organizations", path)}${query.size ? `?${query}` : ""}`, {
1433
+ fetch: requestFetch,
1434
+ timeoutMs,
1435
+ method: "GET",
1436
+ credentials: "omit",
1437
+ headers: { authorization: `Bearer ${current.accessToken}` },
1438
+ mapError: fromOrganizationReadAuthorityError,
1439
+ maxResponseBytes: 256 * 1024
1440
+ })).value);
1441
+ }
1095
1442
  async function removePersisted() {
1096
1443
  if (!options.persistence) return;
1097
1444
  try {
@@ -1117,6 +1464,163 @@ function createDeviceAuth(options) {
1117
1464
  },
1118
1465
  getToken: () => serializeAuthority(async () => copyTokenOrNull(await readToken())),
1119
1466
  getSession: () => serializeAuthority(getSession, true),
1467
+ listOrganizations: (input) => serializeAuthority(() => organizationRead("", input, normalizeOrganizations)),
1468
+ getOrganization(organizationId) {
1469
+ try {
1470
+ return serializeAuthority(() => organizationRead(normalizeIdInput(organizationId), void 0, normalizeOrganization));
1471
+ } catch (error) {
1472
+ return Promise.reject(error);
1473
+ }
1474
+ },
1475
+ createOrganizationTeam(organizationId, name, idempotencyKey) {
1476
+ let id;
1477
+ let body;
1478
+ try {
1479
+ id = normalizeIdInput(organizationId);
1480
+ body = normalizeOrganizationTeamCreationInput(name, idempotencyKey);
1481
+ } catch (error) {
1482
+ return Promise.reject(error);
1483
+ }
1484
+ return serializeAuthority(async () => {
1485
+ const current = await readToken();
1486
+ if (!current) throw new AuthError("authentication_required", 401);
1487
+ return normalizeCreatedOrganizationTeam((await requestJsonResponse(joinURL(authOrigin, "api/v1/auth/organizations", id, "teams"), {
1488
+ fetch: requestFetch,
1489
+ timeoutMs,
1490
+ method: "POST",
1491
+ credentials: "omit",
1492
+ headers: {
1493
+ authorization: `Bearer ${current.accessToken}`,
1494
+ "content-type": "application/json"
1495
+ },
1496
+ body,
1497
+ mapError: fromOrganizationMutationAuthorityError
1498
+ })).value);
1499
+ });
1500
+ },
1501
+ createOrganizationMemberInvitation(organizationId, input) {
1502
+ let id;
1503
+ let body;
1504
+ try {
1505
+ id = normalizeIdInput(organizationId);
1506
+ body = normalizeOrganizationMemberInvitationCreationInput(input);
1507
+ } catch (error) {
1508
+ return Promise.reject(error);
1509
+ }
1510
+ return serializeAuthority(async () => {
1511
+ const current = await readToken();
1512
+ if (!current) throw new AuthError("authentication_required", 401);
1513
+ return normalizeCreatedOrganizationMemberInvitation((await requestJsonResponse(joinURL(authOrigin, "api/v1/auth/organizations", id, "invitations"), {
1514
+ fetch: requestFetch,
1515
+ timeoutMs,
1516
+ method: "POST",
1517
+ credentials: "omit",
1518
+ headers: {
1519
+ authorization: `Bearer ${current.accessToken}`,
1520
+ "content-type": "application/json"
1521
+ },
1522
+ body,
1523
+ mapError: fromOrganizationMutationAuthorityError
1524
+ })).value);
1525
+ });
1526
+ },
1527
+ updateOrganizationDisplay(organizationId, input) {
1528
+ let id;
1529
+ let desired;
1530
+ try {
1531
+ id = normalizeIdInput(organizationId);
1532
+ desired = normalizeOrganizationDisplayInput(input);
1533
+ } catch (error) {
1534
+ return Promise.reject(error);
1535
+ }
1536
+ return serializeAuthority(async () => {
1537
+ const current = await readToken();
1538
+ if (!current) throw new AuthError("authentication_required", 401);
1539
+ return normalizeOrganizationDisplay((await requestJsonResponse(joinURL(authOrigin, "api/v1/auth/organizations", id, "display"), {
1540
+ fetch: requestFetch,
1541
+ timeoutMs,
1542
+ method: "POST",
1543
+ credentials: "omit",
1544
+ headers: {
1545
+ authorization: `Bearer ${current.accessToken}`,
1546
+ "content-type": "application/json"
1547
+ },
1548
+ body: desired,
1549
+ mapError: fromOrganizationMutationAuthorityError
1550
+ })).value);
1551
+ });
1552
+ },
1553
+ updateOrganizationTeamDisplay(organizationId, teamId, input) {
1554
+ let organization;
1555
+ let team;
1556
+ let desired;
1557
+ try {
1558
+ organization = normalizeIdInput(organizationId);
1559
+ team = normalizeIdInput(teamId);
1560
+ desired = normalizeOrganizationTeamDisplayInput(input);
1561
+ } catch (error) {
1562
+ return Promise.reject(error);
1563
+ }
1564
+ return serializeAuthority(async () => {
1565
+ const current = await readToken();
1566
+ if (!current) throw new AuthError("authentication_required", 401);
1567
+ return normalizeOrganizationTeamDisplay((await requestJsonResponse(joinURL(authOrigin, "api/v1/auth/organizations", organization, "teams", team, "display"), {
1568
+ fetch: requestFetch,
1569
+ timeoutMs,
1570
+ method: "POST",
1571
+ credentials: "omit",
1572
+ headers: {
1573
+ authorization: `Bearer ${current.accessToken}`,
1574
+ "content-type": "application/json"
1575
+ },
1576
+ body: desired,
1577
+ mapError: fromOrganizationMutationAuthorityError
1578
+ })).value);
1579
+ });
1580
+ },
1581
+ listOrganizationMembers(organizationId, input) {
1582
+ try {
1583
+ return serializeAuthority(() => organizationRead(`${normalizeIdInput(organizationId)}/members`, input, normalizeOrganizationMembers));
1584
+ } catch (error) {
1585
+ return Promise.reject(error);
1586
+ }
1587
+ },
1588
+ listOrganizationTeams(organizationId, input) {
1589
+ try {
1590
+ return serializeAuthority(() => organizationRead(`${normalizeIdInput(organizationId)}/teams`, input, normalizeOrganizationTeams));
1591
+ } catch (error) {
1592
+ return Promise.reject(error);
1593
+ }
1594
+ },
1595
+ listOrganizationTeamMembers(organizationId, teamId, input) {
1596
+ try {
1597
+ return serializeAuthority(() => organizationRead(`${normalizeIdInput(organizationId)}/teams/${normalizeIdInput(teamId)}/members`, input, normalizeOrganizationTeamMembers));
1598
+ } catch (error) {
1599
+ return Promise.reject(error);
1600
+ }
1601
+ },
1602
+ listOrganizationInvitations(organizationId, input) {
1603
+ try {
1604
+ return serializeAuthority(() => organizationRead(`${normalizeIdInput(organizationId)}/invitations`, input, normalizeOrganizationInvitations));
1605
+ } catch (error) {
1606
+ return Promise.reject(error);
1607
+ }
1608
+ },
1609
+ getOrganizationInvitation(organizationId, invitationId) {
1610
+ try {
1611
+ return serializeAuthority(() => organizationRead(`${normalizeIdInput(organizationId)}/invitations/${normalizeIdInput(invitationId)}`, void 0, normalizeOrganizationInvitation));
1612
+ } catch (error) {
1613
+ return Promise.reject(error);
1614
+ }
1615
+ },
1616
+ listReceivedInvitations: (input) => serializeAuthority(() => organizationRead("received-invitations", input, normalizeReceivedInvitations)),
1617
+ getReceivedInvitation(invitationId) {
1618
+ try {
1619
+ return serializeAuthority(() => organizationRead(`received-invitations/${normalizeIdInput(invitationId)}`, void 0, normalizeReceivedInvitation));
1620
+ } catch (error) {
1621
+ return Promise.reject(error);
1622
+ }
1623
+ },
1120
1624
  signUpWithEmail(email, password, name) {
1121
1625
  let body;
1122
1626
  try {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as AuthErrorStatus, S as AuthErrorCode, _ as SocialIdTokenInput, a as AuthPersistenceDriver, b as WorkspaceSelection, c as AuthUser, d as FinuevaAuthClient, f as InvitationAcceptance, g as SignInInput, h as SendVerificationEmailInput, i as AuthPersistence, l as DriveCredential, m as PersonalWorkspaceSelection, n as AuthClientOptions, o as AuthSession, p as OrganizationWorkspaceSelection, r as AuthOrganization, s as AuthState, t as AcceptInvitationInput, u as DriveCredentialInput, v as SocialIdTokenProvider, x as AuthError, y as UpdateProfileInput } from "./types-DDopQNZR.js";
1
+ import { A as ReceivedOrganizationInvitationPage, B as AuthErrorCode, C as OrganizationTeam, D as OrganizationWorkspaceSelection, E as OrganizationTeamPage, F as UpdateOrganizationDisplayInput, I as UpdateOrganizationTeamDisplayInput, L as UpdateProfileInput, M as SignInInput, N as SocialIdTokenInput, O as PersonalWorkspaceSelection, P as SocialIdTokenProvider, R as WorkspaceSelection, S as OrganizationPageInput, T as OrganizationTeamMemberPage, V as AuthErrorStatus, _ as OrganizationInvitation, a as AuthPersistenceDriver, b as OrganizationMemberPage, c as AuthUser, d as CreatedOrganizationTeam, f as DriveCredential, g as OrganizationDisplay, h as InvitationAcceptance, i as AuthPersistence, j as SendVerificationEmailInput, k as ReceivedOrganizationInvitation, l as CreateOrganizationMemberInvitationInput, m as FinuevaAuthClient, n as AuthClientOptions, o as AuthSession, p as DriveCredentialInput, r as AuthOrganization, s as AuthState, t as AcceptInvitationInput, u as CreatedOrganizationMemberInvitation, v as OrganizationInvitationPage, w as OrganizationTeamDisplay, x as OrganizationPage, y as OrganizationMember, z as AuthError } from "./types-Byw9JQwL.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 DriveCredential, type DriveCredentialInput, type FinuevaAuthClient, type InvitationAcceptance, type OrganizationWorkspaceSelection, type PersonalWorkspaceSelection, type SendVerificationEmailInput, type SignInInput, type SocialIdTokenInput, type SocialIdTokenProvider, 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 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 ReceivedOrganizationInvitation, type ReceivedOrganizationInvitationPage, type SendVerificationEmailInput, type SignInInput, type SocialIdTokenInput, type SocialIdTokenProvider, type UpdateOrganizationDisplayInput, type UpdateOrganizationTeamDisplayInput, type UpdateProfileInput, type WorkspaceSelection, createAuthClient };