@workos-inc/node 9.3.1 → 10.1.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.
@@ -667,7 +667,8 @@ const serializeAuthenticateWithMagicAuthOptions = (options) => ({
667
667
  invitation_token: options.invitationToken,
668
668
  link_authorization_code: options.linkAuthorizationCode,
669
669
  ip_address: options.ipAddress,
670
- user_agent: options.userAgent
670
+ user_agent: options.userAgent,
671
+ radar_auth_attempt_id: options.radarAuthAttemptId
671
672
  });
672
673
  //#endregion
673
674
  //#region src/user-management/serializers/authenticate-with-password-options.serializer.ts
@@ -679,7 +680,8 @@ const serializeAuthenticateWithPasswordOptions = (options) => ({
679
680
  password: options.password,
680
681
  invitation_token: options.invitationToken,
681
682
  ip_address: options.ipAddress,
682
- user_agent: options.userAgent
683
+ user_agent: options.userAgent,
684
+ radar_auth_attempt_id: options.radarAuthAttemptId
683
685
  });
684
686
  //#endregion
685
687
  //#region src/user-management/serializers/authenticate-with-refresh-token.options.serializer.ts
@@ -732,6 +734,43 @@ const deserializeAuthenticationEvent = (authenticationEvent) => ({
732
734
  userId: authenticationEvent.user_id
733
735
  });
734
736
  //#endregion
737
+ //#region src/multi-factor-auth/serializers/totp.serializer.ts
738
+ const deserializeTotp = (totp) => {
739
+ return {
740
+ issuer: totp.issuer,
741
+ user: totp.user
742
+ };
743
+ };
744
+ const deserializeTotpWithSecrets = (totp) => {
745
+ return {
746
+ issuer: totp.issuer,
747
+ user: totp.user,
748
+ qrCode: totp.qr_code,
749
+ secret: totp.secret,
750
+ uri: totp.uri
751
+ };
752
+ };
753
+ //#endregion
754
+ //#region src/user-management/serializers/authentication-factor.serializer.ts
755
+ const deserializeFactor$1 = (factor) => ({
756
+ object: factor.object,
757
+ id: factor.id,
758
+ createdAt: factor.created_at,
759
+ updatedAt: factor.updated_at,
760
+ type: factor.type,
761
+ totp: deserializeTotp(factor.totp),
762
+ userId: factor.user_id
763
+ });
764
+ const deserializeFactorWithSecrets$1 = (factor) => ({
765
+ object: factor.object,
766
+ id: factor.id,
767
+ createdAt: factor.created_at,
768
+ updatedAt: factor.updated_at,
769
+ type: factor.type,
770
+ totp: deserializeTotpWithSecrets(factor.totp),
771
+ userId: factor.user_id
772
+ });
773
+ //#endregion
735
774
  //#region src/user-management/serializers/oauth-tokens.serializer.ts
736
775
  const deserializeOauthTokens = (oauthTokens) => oauthTokens ? {
737
776
  accessToken: oauthTokens.access_token,
@@ -746,6 +785,7 @@ const deserializeUser = (user) => ({
746
785
  id: user.id,
747
786
  email: user.email,
748
787
  emailVerified: user.email_verified,
788
+ name: user.name ?? null,
749
789
  firstName: user.first_name,
750
790
  profilePictureUrl: user.profile_picture_url,
751
791
  lastName: user.last_name,
@@ -775,7 +815,10 @@ const deserializeAuthenticationResponse = (authenticationResponse) => {
775
815
  //#region src/user-management/serializers/create-magic-auth-options.serializer.ts
776
816
  const serializeCreateMagicAuthOptions = (options) => ({
777
817
  email: options.email,
778
- invitation_token: options.invitationToken
818
+ invitation_token: options.invitationToken,
819
+ ip_address: options.ipAddress,
820
+ user_agent: options.userAgent,
821
+ radar_auth_attempt_id: options.radarAuthAttemptId
779
822
  });
780
823
  //#endregion
781
824
  //#region src/user-management/serializers/create-password-reset-options.serializer.ts
@@ -810,43 +853,6 @@ const serializeEnrollAuthFactorOptions = (options) => ({
810
853
  totp_secret: options.totpSecret
811
854
  });
812
855
  //#endregion
813
- //#region src/multi-factor-auth/serializers/totp.serializer.ts
814
- const deserializeTotp = (totp) => {
815
- return {
816
- issuer: totp.issuer,
817
- user: totp.user
818
- };
819
- };
820
- const deserializeTotpWithSecrets = (totp) => {
821
- return {
822
- issuer: totp.issuer,
823
- user: totp.user,
824
- qrCode: totp.qr_code,
825
- secret: totp.secret,
826
- uri: totp.uri
827
- };
828
- };
829
- //#endregion
830
- //#region src/user-management/serializers/factor.serializer.ts
831
- const deserializeFactor$1 = (factor) => ({
832
- object: factor.object,
833
- id: factor.id,
834
- createdAt: factor.created_at,
835
- updatedAt: factor.updated_at,
836
- type: factor.type,
837
- totp: deserializeTotp(factor.totp),
838
- userId: factor.user_id
839
- });
840
- const deserializeFactorWithSecrets$1 = (factor) => ({
841
- object: factor.object,
842
- id: factor.id,
843
- createdAt: factor.created_at,
844
- updatedAt: factor.updated_at,
845
- type: factor.type,
846
- totp: deserializeTotpWithSecrets(factor.totp),
847
- userId: factor.user_id
848
- });
849
- //#endregion
850
856
  //#region src/user-management/serializers/invitation.serializer.ts
851
857
  const deserializeInvitation = (invitation) => ({
852
858
  object: invitation.object,
@@ -954,17 +960,21 @@ const serializeCreateUserOptions = (options) => ({
954
960
  password: options.password,
955
961
  password_hash: options.passwordHash,
956
962
  password_hash_type: options.passwordHashType,
963
+ name: options.name,
957
964
  first_name: options.firstName,
958
965
  last_name: options.lastName,
959
966
  email_verified: options.emailVerified,
960
967
  external_id: options.externalId,
961
- metadata: options.metadata
968
+ metadata: options.metadata,
969
+ ip_address: options.ipAddress,
970
+ user_agent: options.userAgent
962
971
  });
963
972
  //#endregion
964
973
  //#region src/user-management/serializers/update-user-options.serializer.ts
965
974
  const serializeUpdateUserOptions = (options) => ({
966
975
  email: options.email,
967
976
  email_verified: options.emailVerified,
977
+ name: options.name,
968
978
  first_name: options.firstName,
969
979
  last_name: options.lastName,
970
980
  password: options.password,
@@ -1007,6 +1017,7 @@ const deserializeUserData = (userData) => {
1007
1017
  return {
1008
1018
  object: userData.object,
1009
1019
  email: userData.email,
1020
+ name: userData.name ?? null,
1010
1021
  firstName: userData.first_name,
1011
1022
  lastName: userData.last_name
1012
1023
  };
@@ -1082,6 +1093,47 @@ var Actions = class {
1082
1093
  }
1083
1094
  };
1084
1095
  //#endregion
1096
+ //#region src/common/utils/pagination.ts
1097
+ var AutoPaginatable = class {
1098
+ list;
1099
+ apiCall;
1100
+ object = "list";
1101
+ options;
1102
+ constructor(list, apiCall, options) {
1103
+ this.list = list;
1104
+ this.apiCall = apiCall;
1105
+ this.options = options ?? {};
1106
+ }
1107
+ get data() {
1108
+ return this.list.data;
1109
+ }
1110
+ get listMetadata() {
1111
+ return this.list.listMetadata;
1112
+ }
1113
+ async *generatePages(params) {
1114
+ const result = await this.apiCall({
1115
+ ...this.options,
1116
+ limit: 100,
1117
+ after: params.after
1118
+ });
1119
+ yield result.data;
1120
+ if (result.listMetadata.after) {
1121
+ await new Promise((resolve) => setTimeout(resolve, 350));
1122
+ yield* this.generatePages({ after: result.listMetadata.after });
1123
+ }
1124
+ }
1125
+ /**
1126
+ * Automatically paginates over the list of results, returning the complete data set.
1127
+ * Returns the first result if `options.limit` is passed to the first request.
1128
+ */
1129
+ async autoPagination() {
1130
+ if (this.options.limit) return this.data;
1131
+ const results = [];
1132
+ for await (const page of this.generatePages({ after: this.options.after })) results.push(...page);
1133
+ return results;
1134
+ }
1135
+ };
1136
+ //#endregion
1085
1137
  //#region src/directory-sync/serializers/directory-group.serializer.ts
1086
1138
  const deserializeDirectoryGroup = (directoryGroup) => ({
1087
1139
  id: directoryGroup.id,
@@ -1246,6 +1298,7 @@ const deserializeProfile = (profile) => ({
1246
1298
  connectionId: profile.connection_id,
1247
1299
  connectionType: profile.connection_type,
1248
1300
  email: profile.email,
1301
+ ...profile.name !== void 0 && { name: profile.name },
1249
1302
  ...profile.first_name !== void 0 && { firstName: profile.first_name },
1250
1303
  ...profile.last_name !== void 0 && { lastName: profile.last_name },
1251
1304
  ...profile.role !== void 0 && { role: profile.role },
@@ -1362,30 +1415,30 @@ const deserializeFeatureFlag = (featureFlag) => ({
1362
1415
  updatedAt: featureFlag.updated_at
1363
1416
  });
1364
1417
  //#endregion
1365
- //#region src/groups/serializers/add-group-organization-membership-options.serializer.ts
1366
- const serializeAddGroupOrganizationMembershipOptions = (options) => ({ organization_membership_id: options.organizationMembershipId });
1367
- //#endregion
1368
- //#region src/groups/serializers/create-group-options.serializer.ts
1369
- const serializeCreateGroupOptions = (options) => ({
1370
- name: options.name,
1371
- description: options.description
1418
+ //#region src/groups/serializers/create-group.serializer.ts
1419
+ const serializeCreateGroup = (model) => ({
1420
+ name: model.name,
1421
+ description: model.description ?? null
1372
1422
  });
1373
1423
  //#endregion
1424
+ //#region src/groups/serializers/create-group-membership.serializer.ts
1425
+ const serializeCreateGroupMembership = (model) => ({ organization_membership_id: model.organizationMembershipId });
1426
+ //#endregion
1374
1427
  //#region src/groups/serializers/group.serializer.ts
1375
- const deserializeGroup = (group) => ({
1376
- object: group.object,
1377
- id: group.id,
1378
- organizationId: group.organization_id,
1379
- name: group.name,
1380
- description: group.description,
1381
- createdAt: group.created_at,
1382
- updatedAt: group.updated_at
1383
- });
1384
- //#endregion
1385
- //#region src/groups/serializers/update-group-options.serializer.ts
1386
- const serializeUpdateGroupOptions = (options) => ({
1387
- name: options.name,
1388
- description: options.description
1428
+ const deserializeGroup = (response) => ({
1429
+ object: response.object,
1430
+ id: response.id,
1431
+ organizationId: response.organization_id,
1432
+ name: response.name,
1433
+ description: response.description ?? null,
1434
+ createdAt: new Date(response.created_at),
1435
+ updatedAt: new Date(response.updated_at)
1436
+ });
1437
+ //#endregion
1438
+ //#region src/groups/serializers/update-group.serializer.ts
1439
+ const serializeUpdateGroup = (model) => ({
1440
+ name: model.name,
1441
+ description: model.description ?? null
1389
1442
  });
1390
1443
  //#endregion
1391
1444
  //#region src/vault/serializers/vault-event.serializer.ts
@@ -1712,15 +1765,122 @@ const serializePaginationOptions = (options) => ({
1712
1765
  ...options.order && { order: options.order }
1713
1766
  });
1714
1767
  //#endregion
1768
+ //#region src/common/utils/fetch-and-deserialize.ts
1769
+ const setDefaultOptions = (options) => {
1770
+ return {
1771
+ ...options,
1772
+ order: options?.order || "desc"
1773
+ };
1774
+ };
1775
+ const fetchAndDeserialize = async (workos, endpoint, deserializeFn, options, requestOptions) => {
1776
+ const { data } = await workos.get(endpoint, {
1777
+ query: setDefaultOptions(options),
1778
+ ...requestOptions
1779
+ });
1780
+ return deserializeList(data, deserializeFn);
1781
+ };
1782
+ //#endregion
1783
+ //#region src/webhooks/serializers/webhook-endpoint.serializer.ts
1784
+ const deserializeWebhookEndpoint = (response) => ({
1785
+ object: response.object,
1786
+ id: response.id,
1787
+ endpointUrl: response.endpoint_url,
1788
+ secret: response.secret,
1789
+ status: response.status,
1790
+ events: response.events,
1791
+ createdAt: new Date(response.created_at),
1792
+ updatedAt: new Date(response.updated_at)
1793
+ });
1794
+ //#endregion
1795
+ //#region src/webhooks/serializers/create-webhook-endpoint.serializer.ts
1796
+ const serializeCreateWebhookEndpoint = (model) => ({
1797
+ endpoint_url: model.endpointUrl,
1798
+ events: model.events
1799
+ });
1800
+ //#endregion
1801
+ //#region src/webhooks/serializers/update-webhook-endpoint.serializer.ts
1802
+ const serializeUpdateWebhookEndpoint = (model) => ({
1803
+ endpoint_url: model.endpointUrl,
1804
+ status: model.status,
1805
+ events: model.events
1806
+ });
1807
+ //#endregion
1715
1808
  //#region src/webhooks/webhooks.ts
1716
- function parseVerifiedPayload(payload) {
1717
- if (typeof payload === "object" && !isBinaryPayload(payload)) return payload;
1718
- return JSON.parse(decodePayloadToString(payload));
1719
- }
1720
1809
  var Webhooks = class {
1721
- signatureProvider;
1722
- constructor(cryptoProvider) {
1723
- this.signatureProvider = new SignatureProvider(cryptoProvider);
1810
+ workos;
1811
+ constructor(workos) {
1812
+ this.workos = workos;
1813
+ }
1814
+ /**
1815
+ * List Webhook Endpoints
1816
+ *
1817
+ * Get a list of all of your existing webhook endpoints.
1818
+ * @param options - Pagination and filter options.
1819
+ * @returns {Promise<AutoPaginatable<WebhookEndpoint, PaginationOptions>>}
1820
+ */
1821
+ async listWebhookEndpoints(options) {
1822
+ const paginationOptions = options;
1823
+ return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/webhook_endpoints", deserializeWebhookEndpoint, paginationOptions), (params) => fetchAndDeserialize(this.workos, "/webhook_endpoints", deserializeWebhookEndpoint, params), paginationOptions);
1824
+ }
1825
+ /**
1826
+ * Create a Webhook Endpoint
1827
+ *
1828
+ * Create a new webhook endpoint to receive event notifications.
1829
+ * @param options - Object containing endpointUrl, events.
1830
+ * @param options.endpointUrl - The HTTPS URL where webhooks will be sent.
1831
+ * @example "https://example.com/webhooks"
1832
+ * @param options.events - The events that the Webhook Endpoint is subscribed to.
1833
+ * @example ["user.created","dsync.user.created"]
1834
+ * @returns {Promise<WebhookEndpoint>}
1835
+ * @throws {ConflictException} 409
1836
+ * @throws {UnprocessableEntityException} 422
1837
+ */
1838
+ async createWebhookEndpoint(options) {
1839
+ const payload = options;
1840
+ const { data } = await this.workos.post("/webhook_endpoints", serializeCreateWebhookEndpoint(payload));
1841
+ return deserializeWebhookEndpoint(data);
1842
+ }
1843
+ /**
1844
+ * Update a Webhook Endpoint
1845
+ *
1846
+ * Update the properties of an existing webhook endpoint.
1847
+ * @param options - The request body.
1848
+ * @param options.id - Unique identifier of the Webhook Endpoint.
1849
+ * @example "we_0123456789"
1850
+ * @param options.endpointUrl - The HTTPS URL where webhooks will be sent.
1851
+ * @example "https://example.com/webhooks"
1852
+ * @param options.status - Whether the Webhook Endpoint is enabled or disabled.
1853
+ * @example "enabled"
1854
+ * @param options.events - The events that the Webhook Endpoint is subscribed to.
1855
+ * @example ["user.created","dsync.user.created"]
1856
+ * @returns {Promise<WebhookEndpoint>}
1857
+ * @throws {NotFoundException} 404
1858
+ * @throws {ConflictException} 409
1859
+ * @throws {UnprocessableEntityException} 422
1860
+ */
1861
+ async updateWebhookEndpoint(options) {
1862
+ const { id, ...payload } = options;
1863
+ const { data } = await this.workos.patch(`/webhook_endpoints/${encodeURIComponent(id)}`, serializeUpdateWebhookEndpoint(payload));
1864
+ return deserializeWebhookEndpoint(data);
1865
+ }
1866
+ /**
1867
+ * Delete a Webhook Endpoint
1868
+ *
1869
+ * Delete an existing webhook endpoint.
1870
+ * @param options - The request options.
1871
+ * @param options.id - Unique identifier of the Webhook Endpoint.
1872
+ * @example "we_0123456789"
1873
+ * @returns {Promise<void>}
1874
+ * @throws {NotFoundException} 404
1875
+ */
1876
+ async deleteWebhookEndpoint(options) {
1877
+ const { id } = options;
1878
+ await this.workos.delete(`/webhook_endpoints/${encodeURIComponent(id)}`);
1879
+ }
1880
+ _signatureProvider;
1881
+ get signatureProvider() {
1882
+ if (!this._signatureProvider) this._signatureProvider = new SignatureProvider(this.workos.getCryptoProvider());
1883
+ return this._signatureProvider;
1724
1884
  }
1725
1885
  get verifyHeader() {
1726
1886
  return this.signatureProvider.verifyHeader.bind(this.signatureProvider);
@@ -1739,7 +1899,11 @@ var Webhooks = class {
1739
1899
  tolerance
1740
1900
  };
1741
1901
  await this.verifyHeader(options);
1742
- return deserializeEvent(parseVerifiedPayload(payload));
1902
+ return deserializeEvent(this.parseVerifiedPayload(payload));
1903
+ }
1904
+ parseVerifiedPayload(payload) {
1905
+ if (typeof payload === "object" && !isBinaryPayload(payload)) return payload;
1906
+ return JSON.parse(decodePayloadToString(payload));
1743
1907
  }
1744
1908
  };
1745
1909
  //#endregion
@@ -1793,47 +1957,6 @@ var PKCE = class {
1793
1957
  }
1794
1958
  };
1795
1959
  //#endregion
1796
- //#region src/common/utils/pagination.ts
1797
- var AutoPaginatable = class {
1798
- list;
1799
- apiCall;
1800
- object = "list";
1801
- options;
1802
- constructor(list, apiCall, options) {
1803
- this.list = list;
1804
- this.apiCall = apiCall;
1805
- this.options = options ?? {};
1806
- }
1807
- get data() {
1808
- return this.list.data;
1809
- }
1810
- get listMetadata() {
1811
- return this.list.listMetadata;
1812
- }
1813
- async *generatePages(params) {
1814
- const result = await this.apiCall({
1815
- ...this.options,
1816
- limit: 100,
1817
- after: params.after
1818
- });
1819
- yield result.data;
1820
- if (result.listMetadata.after) {
1821
- await new Promise((resolve) => setTimeout(resolve, 350));
1822
- yield* this.generatePages({ after: result.listMetadata.after });
1823
- }
1824
- }
1825
- /**
1826
- * Automatically paginates over the list of results, returning the complete data set.
1827
- * Returns the first result if `options.limit` is passed to the first request.
1828
- */
1829
- async autoPagination() {
1830
- if (this.options.limit) return this.data;
1831
- const results = [];
1832
- for await (const page of this.generatePages({ after: this.options.after })) results.push(...page);
1833
- return results;
1834
- }
1835
- };
1836
- //#endregion
1837
1960
  //#region src/api-keys/serializers/create-organization-api-key-options.serializer.ts
1838
1961
  function serializeCreateOrganizationApiKeyOptions(options) {
1839
1962
  return {
@@ -1863,21 +1986,6 @@ function deserializeValidateApiKeyResponse(response) {
1863
1986
  return { apiKey: response.api_key ? deserializeApiKey(response.api_key) : null };
1864
1987
  }
1865
1988
  //#endregion
1866
- //#region src/common/utils/fetch-and-deserialize.ts
1867
- const setDefaultOptions = (options) => {
1868
- return {
1869
- ...options,
1870
- order: options?.order || "desc"
1871
- };
1872
- };
1873
- const fetchAndDeserialize = async (workos, endpoint, deserializeFn, options, requestOptions) => {
1874
- const { data } = await workos.get(endpoint, {
1875
- query: setDefaultOptions(options),
1876
- ...requestOptions
1877
- });
1878
- return deserializeList(data, deserializeFn);
1879
- };
1880
- //#endregion
1881
1989
  //#region src/api-keys/api-keys.ts
1882
1990
  var ApiKeys = class {
1883
1991
  workos;
@@ -1950,6 +2058,358 @@ var ApiKeys = class {
1950
2058
  }
1951
2059
  };
1952
2060
  //#endregion
2061
+ //#region src/connect/serializers/external-auth-complete-response.serializer.ts
2062
+ const deserializeExternalAuthCompleteResponse = (response) => ({ redirectUri: response.redirect_uri });
2063
+ //#endregion
2064
+ //#region src/connect/serializers/connect-application-redirect-uri.serializer.ts
2065
+ const deserializeConnectApplicationRedirectUri = (response) => ({
2066
+ uri: response.uri,
2067
+ default: response.default
2068
+ });
2069
+ //#endregion
2070
+ //#region src/connect/serializers/connect-application.serializer.ts
2071
+ const deserializeConnectApplication = (response) => {
2072
+ switch (response.application_type) {
2073
+ case "oauth": return {
2074
+ object: response.object,
2075
+ id: response.id,
2076
+ clientId: response.client_id,
2077
+ description: response.description,
2078
+ name: response.name,
2079
+ scopes: response.scopes,
2080
+ createdAt: new Date(response.created_at),
2081
+ updatedAt: new Date(response.updated_at),
2082
+ applicationType: "oauth",
2083
+ redirectUris: response.redirect_uris.map(deserializeConnectApplicationRedirectUri),
2084
+ usesPkce: response.uses_pkce,
2085
+ isFirstParty: response.is_first_party,
2086
+ wasDynamicallyRegistered: response.was_dynamically_registered,
2087
+ organizationId: response.organization_id
2088
+ };
2089
+ case "m2m": return {
2090
+ object: response.object,
2091
+ id: response.id,
2092
+ clientId: response.client_id,
2093
+ description: response.description,
2094
+ name: response.name,
2095
+ scopes: response.scopes,
2096
+ createdAt: new Date(response.created_at),
2097
+ updatedAt: new Date(response.updated_at),
2098
+ applicationType: "m2m",
2099
+ organizationId: response.organization_id
2100
+ };
2101
+ default: throw new Error(`Unknown application_type: ${response.application_type}`);
2102
+ }
2103
+ };
2104
+ //#endregion
2105
+ //#region src/connect/serializers/application-credentials-list-item.serializer.ts
2106
+ const deserializeApplicationCredentialsListItem = (response) => ({
2107
+ object: response.object,
2108
+ id: response.id,
2109
+ secretHint: response.secret_hint,
2110
+ lastUsedAt: response.last_used_at != null ? new Date(response.last_used_at) : null,
2111
+ createdAt: new Date(response.created_at),
2112
+ updatedAt: new Date(response.updated_at)
2113
+ });
2114
+ //#endregion
2115
+ //#region src/connect/serializers/new-connect-application-secret.serializer.ts
2116
+ const deserializeNewConnectApplicationSecret = (response) => ({
2117
+ object: response.object,
2118
+ id: response.id,
2119
+ secretHint: response.secret_hint,
2120
+ lastUsedAt: response.last_used_at != null ? new Date(response.last_used_at) : null,
2121
+ createdAt: new Date(response.created_at),
2122
+ updatedAt: new Date(response.updated_at),
2123
+ secret: response.secret
2124
+ });
2125
+ //#endregion
2126
+ //#region src/connect/serializers/user-object.serializer.ts
2127
+ const serializeUserObject = (model) => ({
2128
+ id: model.id,
2129
+ email: model.email,
2130
+ first_name: model.firstName,
2131
+ last_name: model.lastName,
2132
+ metadata: model.metadata
2133
+ });
2134
+ //#endregion
2135
+ //#region src/connect/serializers/user-consent-option-choice.serializer.ts
2136
+ const serializeUserConsentOptionChoice = (model) => ({
2137
+ value: model.value,
2138
+ label: model.label
2139
+ });
2140
+ //#endregion
2141
+ //#region src/connect/serializers/user-consent-option.serializer.ts
2142
+ const serializeUserConsentOption = (model) => ({
2143
+ claim: model.claim,
2144
+ type: model.type,
2145
+ label: model.label,
2146
+ choices: model.choices.map(serializeUserConsentOptionChoice)
2147
+ });
2148
+ //#endregion
2149
+ //#region src/connect/serializers/user-management-login-request.serializer.ts
2150
+ const serializeUserManagementLoginRequest = (model) => ({
2151
+ external_auth_id: model.externalAuthId,
2152
+ user: serializeUserObject(model.user),
2153
+ user_consent_options: model.userConsentOptions != null ? model.userConsentOptions.map(serializeUserConsentOption) : void 0
2154
+ });
2155
+ //#endregion
2156
+ //#region src/connect/serializers/redirect-uri-input.serializer.ts
2157
+ const serializeRedirectUriInput = (model) => ({
2158
+ uri: model.uri,
2159
+ default: model.default ?? null
2160
+ });
2161
+ //#endregion
2162
+ //#region src/connect/serializers/create-oauth-application.serializer.ts
2163
+ const serializeCreateOAuthApplication = (model) => ({
2164
+ name: model.name,
2165
+ application_type: model.applicationType,
2166
+ description: model.description ?? null,
2167
+ scopes: model.scopes ?? null,
2168
+ redirect_uris: model.redirectUris != null ? model.redirectUris.map(serializeRedirectUriInput) : null,
2169
+ uses_pkce: model.usesPkce ?? null,
2170
+ is_first_party: model.isFirstParty,
2171
+ organization_id: model.organizationId ?? null
2172
+ });
2173
+ //#endregion
2174
+ //#region src/connect/serializers/create-m2m-application.serializer.ts
2175
+ const serializeCreateM2MApplication = (model) => ({
2176
+ name: model.name,
2177
+ application_type: model.applicationType,
2178
+ description: model.description ?? null,
2179
+ scopes: model.scopes ?? null,
2180
+ organization_id: model.organizationId
2181
+ });
2182
+ //#endregion
2183
+ //#region src/connect/serializers/update-oauth-application.serializer.ts
2184
+ const serializeUpdateOAuthApplication = (model) => ({
2185
+ name: model.name,
2186
+ description: model.description ?? null,
2187
+ scopes: model.scopes ?? null,
2188
+ redirect_uris: model.redirectUris != null ? model.redirectUris.map(serializeRedirectUriInput) : null
2189
+ });
2190
+ //#endregion
2191
+ //#region src/connect/serializers/create-application-secret.serializer.ts
2192
+ const serializeCreateApplicationSecret = (_model) => ({});
2193
+ //#endregion
2194
+ //#region src/connect/connect.ts
2195
+ const serializeListApplicationsOptions = (options) => {
2196
+ const wire = {
2197
+ limit: options.limit,
2198
+ before: options.before,
2199
+ after: options.after,
2200
+ order: options.order
2201
+ };
2202
+ if (options.organizationId !== void 0) wire.organization_id = options.organizationId;
2203
+ return wire;
2204
+ };
2205
+ var Connect = class {
2206
+ workos;
2207
+ constructor(workos) {
2208
+ this.workos = workos;
2209
+ }
2210
+ /**
2211
+ * Complete external authentication
2212
+ *
2213
+ * Completes an external authentication flow and returns control to AuthKit. This endpoint is used with [Standalone Connect](https://workos.com/docs/authkit/connect/standalone) to bridge your existing authentication system with the Connect OAuth API infrastructure.
2214
+ *
2215
+ * After successfully authenticating a user in your application, calling this endpoint will:
2216
+ *
2217
+ * - Create or update the user in AuthKit, using the given `id` as its `external_id`.
2218
+ * - Return a `redirect_uri` your application should redirect to in order for AuthKit to complete the flow
2219
+ *
2220
+ * Users are automatically created or updated based on the `id` and `email` provided. If a user with the same `id` exists, their information is updated. Otherwise, a new user is created.
2221
+ *
2222
+ * If you provide a new `id` with an `email` that already belongs to an existing user, the request will fail with an error as email addresses are unique to a user.
2223
+ * @param options - Object containing externalAuthId, user.
2224
+ * @param options.externalAuthId - Identifier provided when AuthKit redirected to your login page.
2225
+ * @example "ext_auth_01HXYZ123456789ABCDEFGHIJ"
2226
+ * @param options.user - The user to create or update in AuthKit.
2227
+ * @param options.userConsentOptions - Array of [User Consent Options](https://workos.com/docs/reference/workos-connect/standalone/user-consent-options) to store with the session.
2228
+ * @returns {Promise<ExternalAuthCompleteResponse>}
2229
+ * @throws {BadRequestException} 400
2230
+ * @throws {NotFoundException} 404
2231
+ * @throws {UnprocessableEntityException} 422
2232
+ */
2233
+ async completeOAuth2(options) {
2234
+ const payload = options;
2235
+ const { data } = await this.workos.post("/authkit/oauth2/complete", serializeUserManagementLoginRequest(payload));
2236
+ return deserializeExternalAuthCompleteResponse(data);
2237
+ }
2238
+ /**
2239
+ * List Connect Applications
2240
+ *
2241
+ * List all Connect Applications in the current environment with optional filtering.
2242
+ * @param options - Pagination and filter options.
2243
+ * @returns {Promise<AutoPaginatable<ConnectApplication, ListApplicationsOptions>>}
2244
+ * @throws {UnprocessableEntityException} 422
2245
+ */
2246
+ async listApplications(options) {
2247
+ return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/connect/applications", deserializeConnectApplication, options ? serializeListApplicationsOptions(options) : void 0), (params) => fetchAndDeserialize(this.workos, "/connect/applications", deserializeConnectApplication, params), options ? serializeListApplicationsOptions(options) : void 0);
2248
+ }
2249
+ /**
2250
+ * Create a Connect Application
2251
+ *
2252
+ * Create a new Connect Application. Supports both OAuth and Machine-to-Machine (M2M) application types.
2253
+ * @param options - The request body.
2254
+ * @returns {Promise<ConnectApplication>}
2255
+ * @throws {NotFoundException} 404
2256
+ * @throws {UnprocessableEntityException} 422
2257
+ */
2258
+ async createApplication(options) {
2259
+ const payload = options;
2260
+ const { data } = await this.workos.post("/connect/applications", (() => {
2261
+ switch (payload.applicationType) {
2262
+ case "oauth": return serializeCreateOAuthApplication(payload);
2263
+ case "m2m": return serializeCreateM2MApplication(payload);
2264
+ default: throw new Error(`Unknown applicationType: ${payload.applicationType}`);
2265
+ }
2266
+ })());
2267
+ return deserializeConnectApplication(data);
2268
+ }
2269
+ /**
2270
+ * Create oauth application.
2271
+ * @param name - The name of the application.
2272
+ * @param isFirstParty - Whether this is a first-party application. Third-party applications require an organization_id.
2273
+ * @param description - A description for the application.
2274
+ * @param scopes - The OAuth scopes granted to the application.
2275
+ * @param redirectUris - Redirect URIs for the application.
2276
+ * @param usesPkce - Whether the application uses PKCE (Proof Key for Code Exchange).
2277
+ * @param organizationId - The organization ID this application belongs to. Required when is_first_party is false.
2278
+ * @returns {Promise<ConnectApplication>}
2279
+ */
2280
+ async createOAuthApplication(name, isFirstParty, description, scopes, redirectUris, usesPkce, organizationId) {
2281
+ const body = {
2282
+ application_type: "oauth",
2283
+ name,
2284
+ is_first_party: isFirstParty
2285
+ };
2286
+ if (description !== void 0) body.description = description;
2287
+ if (scopes !== void 0) body.scopes = scopes;
2288
+ if (redirectUris !== void 0) body.redirect_uris = redirectUris;
2289
+ if (usesPkce !== void 0) body.uses_pkce = usesPkce;
2290
+ if (organizationId !== void 0) body.organization_id = organizationId;
2291
+ const { data } = await this.workos.post("/connect/applications", body);
2292
+ return deserializeConnectApplication(data);
2293
+ }
2294
+ /**
2295
+ * Create m2m application.
2296
+ * @param name - The name of the application.
2297
+ * @param organizationId - The organization ID this application belongs to.
2298
+ * @param description - A description for the application.
2299
+ * @param scopes - The OAuth scopes granted to the application.
2300
+ * @returns {Promise<ConnectApplication>}
2301
+ */
2302
+ async createM2MApplication(name, organizationId, description, scopes) {
2303
+ const body = {
2304
+ application_type: "m2m",
2305
+ name,
2306
+ organization_id: organizationId
2307
+ };
2308
+ if (description !== void 0) body.description = description;
2309
+ if (scopes !== void 0) body.scopes = scopes;
2310
+ const { data } = await this.workos.post("/connect/applications", body);
2311
+ return deserializeConnectApplication(data);
2312
+ }
2313
+ /**
2314
+ * Get a Connect Application
2315
+ *
2316
+ * Retrieve details for a specific Connect Application by ID or client ID.
2317
+ * @param options - The request options.
2318
+ * @param options.id - The application ID or client ID of the Connect Application.
2319
+ * @example "conn_app_01HXYZ123456789ABCDEFGHIJ"
2320
+ * @returns {Promise<ConnectApplication>}
2321
+ * @throws {NotFoundException} 404
2322
+ */
2323
+ async getApplication(options) {
2324
+ const { id } = options;
2325
+ const { data } = await this.workos.get(`/connect/applications/${encodeURIComponent(id)}`);
2326
+ return deserializeConnectApplication(data);
2327
+ }
2328
+ /**
2329
+ * Update a Connect Application
2330
+ *
2331
+ * Update an existing Connect Application. For OAuth applications, you can update redirect URIs. For all applications, you can update the name, description, and scopes.
2332
+ * @param options - The request body.
2333
+ * @param options.id - The application ID or client ID of the Connect Application.
2334
+ * @example "conn_app_01HXYZ123456789ABCDEFGHIJ"
2335
+ * @param options.name - The name of the application.
2336
+ * @example "My Application"
2337
+ * @param options.description - A description for the application.
2338
+ * @example "An application for managing user access"
2339
+ * @param options.scopes - The OAuth scopes granted to the application.
2340
+ * @example ["openid","profile","email"]
2341
+ * @param options.redirectUris - Updated redirect URIs for the application. OAuth applications only.
2342
+ * @example [{"uri":"https://example.com/callback","default":true}]
2343
+ * @returns {Promise<ConnectApplication>}
2344
+ * @throws {NotFoundException} 404
2345
+ * @throws {UnprocessableEntityException} 422
2346
+ */
2347
+ async updateApplication(options) {
2348
+ const { id, ...payload } = options;
2349
+ const { data } = await this.workos.put(`/connect/applications/${encodeURIComponent(id)}`, serializeUpdateOAuthApplication(payload));
2350
+ return deserializeConnectApplication(data);
2351
+ }
2352
+ /**
2353
+ * Delete a Connect Application
2354
+ *
2355
+ * Delete an existing Connect Application.
2356
+ * @param options - The request options.
2357
+ * @param options.id - The application ID or client ID of the Connect Application.
2358
+ * @example "conn_app_01HXYZ123456789ABCDEFGHIJ"
2359
+ * @returns {Promise<void>}
2360
+ * @throws {NotFoundException} 404
2361
+ */
2362
+ async deleteApplication(options) {
2363
+ const { id } = options;
2364
+ await this.workos.delete(`/connect/applications/${encodeURIComponent(id)}`);
2365
+ }
2366
+ /**
2367
+ * List Client Secrets for a Connect Application
2368
+ *
2369
+ * List all client secrets associated with a Connect Application.
2370
+ * @param options - The request options.
2371
+ * @param options.id - The application ID or client ID of the Connect Application.
2372
+ * @example "conn_app_01HXYZ123456789ABCDEFGHIJ"
2373
+ * @returns {Promise<ApplicationCredentialsListItem[]>}
2374
+ * @throws {NotFoundException} 404
2375
+ */
2376
+ async listApplicationClientSecrets(options) {
2377
+ const { id } = options;
2378
+ const { data } = await this.workos.get(`/connect/applications/${encodeURIComponent(id)}/client_secrets`);
2379
+ return data.map(deserializeApplicationCredentialsListItem);
2380
+ }
2381
+ /**
2382
+ * Create a new client secret for a Connect Application
2383
+ *
2384
+ * Create new secrets for a Connect Application.
2385
+ * @param options - The request body.
2386
+ * @param options.id - The application ID or client ID of the Connect Application.
2387
+ * @example "conn_app_01HXYZ123456789ABCDEFGHIJ"
2388
+ * @returns {Promise<NewConnectApplicationSecret>}
2389
+ * @throws {NotFoundException} 404
2390
+ * @throws {UnprocessableEntityException} 422
2391
+ */
2392
+ async createApplicationClientSecret(options) {
2393
+ const { id, ...payload } = options;
2394
+ const { data } = await this.workos.post(`/connect/applications/${encodeURIComponent(id)}/client_secrets`, serializeCreateApplicationSecret(payload));
2395
+ return deserializeNewConnectApplicationSecret(data);
2396
+ }
2397
+ /**
2398
+ * Delete a Client Secret
2399
+ *
2400
+ * Delete (revoke) an existing client secret.
2401
+ * @param options - The request options.
2402
+ * @param options.id - The unique ID of the client secret.
2403
+ * @example "secret_01J9Q2Z3X4Y5W6V7U8T9S0R1Q"
2404
+ * @returns {Promise<void>}
2405
+ * @throws {NotFoundException} 404
2406
+ */
2407
+ async deleteClientSecret(options) {
2408
+ const { id } = options;
2409
+ await this.workos.delete(`/connect/client_secrets/${encodeURIComponent(id)}`);
2410
+ }
2411
+ };
2412
+ //#endregion
1953
2413
  //#region src/directory-sync/directory-sync.ts
1954
2414
  var DirectorySync = class {
1955
2415
  workos;
@@ -2321,15 +2781,136 @@ function deserializeGetAccessTokenResponse(response) {
2321
2781
  };
2322
2782
  }
2323
2783
  //#endregion
2324
- //#region src/pipes/pipes.ts
2325
- var Pipes = class {
2784
+ //#region src/pipes/pipes.ts
2785
+ var Pipes = class {
2786
+ workos;
2787
+ constructor(workos) {
2788
+ this.workos = workos;
2789
+ }
2790
+ async getAccessToken({ provider, ...options }) {
2791
+ const { data } = await this.workos.post(`data-integrations/${provider}/token`, serializeGetAccessTokenOptions(options));
2792
+ return deserializeGetAccessTokenResponse(data);
2793
+ }
2794
+ };
2795
+ //#endregion
2796
+ //#region src/radar/serializers/radar-standalone-response.serializer.ts
2797
+ const deserializeRadarStandaloneResponse = (response) => ({
2798
+ verdict: response.verdict,
2799
+ reason: response.reason,
2800
+ attemptId: response.attempt_id,
2801
+ control: response.control,
2802
+ blocklistType: response.blocklist_type
2803
+ });
2804
+ //#endregion
2805
+ //#region src/radar/serializers/radar-list-entry-already-present-response.serializer.ts
2806
+ const deserializeRadarListEntryAlreadyPresentResponse = (response) => ({ message: response.message });
2807
+ //#endregion
2808
+ //#region src/radar/serializers/radar-standalone-assess-request.serializer.ts
2809
+ const serializeRadarStandaloneAssessRequest = (model) => ({
2810
+ ip_address: model.ipAddress,
2811
+ user_agent: model.userAgent,
2812
+ email: model.email,
2813
+ auth_method: model.authMethod,
2814
+ action: model.action
2815
+ });
2816
+ //#endregion
2817
+ //#region src/radar/serializers/radar-standalone-update-radar-attempt-request.serializer.ts
2818
+ const serializeRadarStandaloneUpdateRadarAttemptRequest = (model) => ({
2819
+ challenge_status: model.challengeStatus,
2820
+ attempt_status: model.attemptStatus
2821
+ });
2822
+ //#endregion
2823
+ //#region src/radar/serializers/radar-standalone-update-radar-list-request.serializer.ts
2824
+ const serializeRadarStandaloneUpdateRadarListRequest = (model) => ({ entry: model.entry });
2825
+ //#endregion
2826
+ //#region src/radar/serializers/radar-standalone-delete-radar-list-entry-request.serializer.ts
2827
+ const serializeRadarStandaloneDeleteRadarListEntryRequest = (model) => ({ entry: model.entry });
2828
+ //#endregion
2829
+ //#region src/radar/radar.ts
2830
+ var Radar = class {
2326
2831
  workos;
2327
2832
  constructor(workos) {
2328
2833
  this.workos = workos;
2329
2834
  }
2330
- async getAccessToken({ provider, ...options }) {
2331
- const { data } = await this.workos.post(`data-integrations/${provider}/token`, serializeGetAccessTokenOptions(options));
2332
- return deserializeGetAccessTokenResponse(data);
2835
+ /**
2836
+ * Create an attempt
2837
+ *
2838
+ * Assess a request for risk using the Radar engine and receive a verdict.
2839
+ * @param options - Object containing ipAddress, userAgent, email, authMethod, action.
2840
+ * @param options.ipAddress - The IP address of the request to assess.
2841
+ * @example "49.78.240.97"
2842
+ * @param options.userAgent - The user agent string of the request to assess.
2843
+ * @example "Mozilla/5.0"
2844
+ * @param options.email - The email address of the user making the request.
2845
+ * @example "user@example.com"
2846
+ * @param options.authMethod - The authentication method being used.
2847
+ * @example "Password"
2848
+ * @param options.action - The action being performed.
2849
+ * @example "sign-in"
2850
+ * @returns {Promise<RadarStandaloneResponse>}
2851
+ * @throws {BadRequestException} 400
2852
+ */
2853
+ async createAttempt(options) {
2854
+ const payload = options;
2855
+ const { data } = await this.workos.post("/radar/attempts", serializeRadarStandaloneAssessRequest(payload));
2856
+ return deserializeRadarStandaloneResponse(data);
2857
+ }
2858
+ /**
2859
+ * Update a Radar attempt
2860
+ *
2861
+ * You may optionally inform Radar that an authentication attempt or challenge was successful using this endpoint. Some Radar controls depend on tracking recent successful attempts, such as impossible travel.
2862
+ * @param options - The request body.
2863
+ * @param options.id - The unique identifier of the Radar attempt to update.
2864
+ * @example "radar_att_01HZBC6N1EB1ZY7KG32X"
2865
+ * @param options.challengeStatus - Set to `"success"` to mark the challenge as completed.
2866
+ * @example "success"
2867
+ * @param options.attemptStatus - Set to `"success"` to mark the authentication attempt as successful.
2868
+ * @example "success"
2869
+ * @returns {Promise<void>}
2870
+ * @throws {BadRequestException} 400
2871
+ * @throws {NotFoundException} 404
2872
+ */
2873
+ async updateAttempt(options) {
2874
+ const { id, ...payload } = options;
2875
+ await this.workos.put(`/radar/attempts/${encodeURIComponent(id)}`, serializeRadarStandaloneUpdateRadarAttemptRequest(payload));
2876
+ }
2877
+ /**
2878
+ * Add an entry to a Radar list
2879
+ *
2880
+ * Add an entry to a Radar list.
2881
+ * @param options - Object containing entry.
2882
+ * @param options.type - The type of the Radar list (e.g. ip_address, domain, email).
2883
+ * @example "ip_address"
2884
+ * @param options.action - The list action indicating whether to add the entry to the allow or block list.
2885
+ * @example "block"
2886
+ * @param options.entry - The value to add to the list. Must match the format of the list type (e.g. a valid IP address for `ip_address`, a valid email for `email`).
2887
+ * @example "198.51.100.42"
2888
+ * @returns {Promise<RadarListEntryAlreadyPresentResponse>}
2889
+ * @throws {BadRequestException} 400
2890
+ */
2891
+ async addListEntry(options) {
2892
+ const { type, action, ...payload } = options;
2893
+ const { data } = await this.workos.post(`/radar/lists/${encodeURIComponent(type)}/${encodeURIComponent(action)}`, serializeRadarStandaloneUpdateRadarListRequest(payload));
2894
+ return deserializeRadarListEntryAlreadyPresentResponse(data);
2895
+ }
2896
+ /**
2897
+ * Remove an entry from a Radar list
2898
+ *
2899
+ * Remove an entry from a Radar list.
2900
+ * @param options - Object containing entry.
2901
+ * @param options.type - The type of the Radar list (e.g. ip_address, domain, email).
2902
+ * @example "ip_address"
2903
+ * @param options.action - The list action indicating whether to remove the entry from the allow or block list.
2904
+ * @example "block"
2905
+ * @param options.entry - The value to remove from the list. Must match an existing entry.
2906
+ * @example "198.51.100.42"
2907
+ * @returns {Promise<void>}
2908
+ * @throws {BadRequestException} 400
2909
+ * @throws {NotFoundException} 404
2910
+ */
2911
+ async removeListEntry(options) {
2912
+ const { type, action, ...payload } = options;
2913
+ await this.workos.deleteWithBody(`/radar/lists/${encodeURIComponent(type)}/${encodeURIComponent(action)}`, serializeRadarStandaloneDeleteRadarListEntryRequest(payload));
2333
2914
  }
2334
2915
  };
2335
2916
  //#endregion
@@ -3421,13 +4002,13 @@ var CookieSession = class {
3421
4002
  authenticated: false,
3422
4003
  reason: "invalid_session_cookie"
3423
4004
  };
3424
- const { org_id: organizationIdFromAccessToken } = decodeJwt(session.accessToken);
4005
+ const { org_id: organizationIdFromUserManagementAccessToken } = decodeJwt(session.accessToken);
3425
4006
  try {
3426
4007
  const cookiePassword = options.cookiePassword ?? this.cookiePassword;
3427
4008
  const authenticationResponse = await this.userManagement.authenticateWithRefreshToken({
3428
4009
  clientId: this.userManagement.clientId,
3429
4010
  refreshToken: session.refreshToken,
3430
- organizationId: options.organizationId ?? organizationIdFromAccessToken,
4011
+ organizationId: options.organizationId ?? organizationIdFromUserManagementAccessToken,
3431
4012
  session: {
3432
4013
  sealSession: true,
3433
4014
  cookiePassword
@@ -3569,14 +4150,18 @@ var UserManagement = class {
3569
4150
  *
3570
4151
  * Create a new user in the current environment.
3571
4152
  * @param payload - Object containing email.
3572
- * @returns {Promise<User>}
4153
+ * @returns {Promise<CreateUserResponse>}
3573
4154
  * @throws {BadRequestException} 400
3574
4155
  * @throws {NotFoundException} 404
3575
4156
  * @throws {UnprocessableEntityException} 422
3576
4157
  */
3577
4158
  async createUser(payload) {
3578
4159
  const { data } = await this.workos.post("/user_management/users", serializeCreateUserOptions(payload));
3579
- return deserializeUser(data);
4160
+ const { radar_auth_attempt_id, ...userResponse } = data;
4161
+ return {
4162
+ ...deserializeUser(userResponse),
4163
+ ...radar_auth_attempt_id ? { radarAuthAttemptId: radar_auth_attempt_id } : void 0
4164
+ };
3580
4165
  }
3581
4166
  /** Authenticate with magic auth. */
3582
4167
  async authenticateWithMagicAuth(payload) {
@@ -3836,14 +4421,18 @@ var UserManagement = class {
3836
4421
  *
3837
4422
  * Creates a one-time authentication code that can be sent to the user's email address. The code expires in 10 minutes. To verify the code, [authenticate the user with Magic Auth](https://workos.com/docs/reference/authkit/authentication/magic-auth).
3838
4423
  * @param options - Object containing email.
3839
- * @returns {Promise<MagicAuth>}
4424
+ * @returns {Promise<CreateMagicAuthResponse>}
3840
4425
  * @throws {BadRequestException} 400
3841
4426
  * @throws {UnprocessableEntityException} 422
3842
4427
  * @throws {RateLimitExceededException} 429
3843
4428
  */
3844
4429
  async createMagicAuth(options) {
3845
4430
  const { data } = await this.workos.post("/user_management/magic_auth", serializeCreateMagicAuthOptions({ ...options }));
3846
- return deserializeMagicAuth(data);
4431
+ const { radar_auth_attempt_id, ...magicAuthResponse } = data;
4432
+ return {
4433
+ ...deserializeMagicAuth(magicAuthResponse),
4434
+ ...radar_auth_attempt_id ? { radarAuthAttemptId: radar_auth_attempt_id } : void 0
4435
+ };
3847
4436
  }
3848
4437
  /**
3849
4438
  * Verify email
@@ -4618,42 +5207,160 @@ var Groups = class {
4618
5207
  constructor(workos) {
4619
5208
  this.workos = workos;
4620
5209
  }
4621
- async createGroup(options) {
4622
- const { organizationId, ...payload } = options;
4623
- const { data } = await this.workos.post(`/organizations/${organizationId}/groups`, serializeCreateGroupOptions(payload));
4624
- return deserializeGroup(data);
5210
+ /**
5211
+ * List Group members
5212
+ *
5213
+ * Get a list of organization memberships in a group.
5214
+ * @param options - Pagination and filter options.
5215
+ * @param options.organizationId - Unique identifier of the Organization.
5216
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5217
+ * @param options.groupId - Unique identifier of the Group.
5218
+ * @example "group_01HXYZ123456789ABCDEFGHIJ"
5219
+ * @returns {Promise<AutoPaginatable<AuthorizationOrganizationMembership>>}
5220
+ * @throws {AuthorizationException} 403
5221
+ * @throws {NotFoundException} 404
5222
+ */
5223
+ async listOrganizationMemberships(options) {
5224
+ const { organizationId, groupId, ...paginationOptions } = options;
5225
+ const endpoint = `/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}/organization-memberships`;
5226
+ return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, paginationOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, params), paginationOptions);
4625
5227
  }
5228
+ /**
5229
+ * List groups
5230
+ *
5231
+ * Get a paginated list of groups within an organization.
5232
+ * @param options - Pagination and filter options.
5233
+ * @param options.organizationId - The ID of the organization.
5234
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5235
+ * @returns {Promise<AutoPaginatable<Group, PaginationOptions>>}
5236
+ * @throws {AuthorizationException} 403
5237
+ * @throws {NotFoundException} 404
5238
+ */
4626
5239
  async listGroups(options) {
4627
5240
  const { organizationId, ...paginationOptions } = options;
4628
- return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/organizations/${organizationId}/groups`, deserializeGroup, paginationOptions), (params) => fetchAndDeserialize(this.workos, `/organizations/${organizationId}/groups`, deserializeGroup, params), paginationOptions);
5241
+ return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/organizations/${encodeURIComponent(organizationId)}/groups`, deserializeGroup, paginationOptions), (params) => fetchAndDeserialize(this.workos, `/organizations/${encodeURIComponent(organizationId)}/groups`, deserializeGroup, params), paginationOptions);
5242
+ }
5243
+ /**
5244
+ * Create a group
5245
+ *
5246
+ * Create a new group within an organization.
5247
+ * @param options - Object containing name.
5248
+ * @param options.organizationId - The ID of the organization.
5249
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5250
+ * @param options.name - The name of the Group.
5251
+ * @example "Engineering"
5252
+ * @param options.description - An optional description of the Group.
5253
+ * @example "The engineering team"
5254
+ * @returns {Promise<Group>}
5255
+ * @throws {BadRequestException} 400
5256
+ * @throws {AuthorizationException} 403
5257
+ * @throws {NotFoundException} 404
5258
+ * @throws {UnprocessableEntityException} 422
5259
+ */
5260
+ async createGroup(options) {
5261
+ const { organizationId, ...payload } = options;
5262
+ const { data } = await this.workos.post(`/organizations/${encodeURIComponent(organizationId)}/groups`, serializeCreateGroup(payload));
5263
+ return deserializeGroup(data);
4629
5264
  }
5265
+ /**
5266
+ * Get a group
5267
+ *
5268
+ * Retrieve a group by its ID within an organization.
5269
+ * @param options - The request options.
5270
+ * @param options.organizationId - The ID of the organization.
5271
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5272
+ * @param options.groupId - The ID of the group.
5273
+ * @example "group_01HXYZ123456789ABCDEFGHIJ"
5274
+ * @returns {Promise<Group>}
5275
+ * @throws {AuthorizationException} 403
5276
+ * @throws {NotFoundException} 404
5277
+ */
4630
5278
  async getGroup(options) {
4631
5279
  const { organizationId, groupId } = options;
4632
- const { data } = await this.workos.get(`/organizations/${organizationId}/groups/${groupId}`);
5280
+ const { data } = await this.workos.get(`/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}`);
4633
5281
  return deserializeGroup(data);
4634
5282
  }
5283
+ /**
5284
+ * Update a group
5285
+ *
5286
+ * Update an existing group. Only the fields provided in the request body will be updated.
5287
+ * @param options - The request body.
5288
+ * @param options.organizationId - The ID of the organization.
5289
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5290
+ * @param options.groupId - The ID of the group.
5291
+ * @example "group_01HXYZ123456789ABCDEFGHIJ"
5292
+ * @param options.name - The name of the Group.
5293
+ * @example "Engineering"
5294
+ * @param options.description - An optional description of the Group.
5295
+ * @example "The engineering team"
5296
+ * @returns {Promise<Group>}
5297
+ * @throws {BadRequestException} 400
5298
+ * @throws {AuthorizationException} 403
5299
+ * @throws {NotFoundException} 404
5300
+ * @throws {UnprocessableEntityException} 422
5301
+ */
4635
5302
  async updateGroup(options) {
4636
5303
  const { organizationId, groupId, ...payload } = options;
4637
- const { data } = await this.workos.patch(`/organizations/${organizationId}/groups/${groupId}`, serializeUpdateGroupOptions(payload));
5304
+ const { data } = await this.workos.patch(`/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}`, serializeUpdateGroup(payload));
4638
5305
  return deserializeGroup(data);
4639
5306
  }
5307
+ /**
5308
+ * Delete a group
5309
+ *
5310
+ * Delete a group from an organization.
5311
+ * @param options - The request options.
5312
+ * @param options.organizationId - The ID of the organization.
5313
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5314
+ * @param options.groupId - The ID of the group.
5315
+ * @example "group_01HXYZ123456789ABCDEFGHIJ"
5316
+ * @returns {Promise<void>}
5317
+ * @throws {AuthorizationException} 403
5318
+ * @throws {NotFoundException} 404
5319
+ */
4640
5320
  async deleteGroup(options) {
4641
5321
  const { organizationId, groupId } = options;
4642
- await this.workos.delete(`/organizations/${organizationId}/groups/${groupId}`);
5322
+ await this.workos.delete(`/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}`);
4643
5323
  }
5324
+ /**
5325
+ * Add a member to a Group
5326
+ *
5327
+ * Add an organization membership to a group.
5328
+ * @param options - Object containing organizationMembershipId.
5329
+ * @param options.organizationId - Unique identifier of the Organization.
5330
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5331
+ * @param options.groupId - Unique identifier of the Group.
5332
+ * @example "group_01HXYZ123456789ABCDEFGHIJ"
5333
+ * @param options.organizationMembershipId - The ID of the Organization Membership to add to the group.
5334
+ * @example "om_01HXYZ123456789ABCDEFGHIJ"
5335
+ * @returns {Promise<Group>}
5336
+ * @throws {BadRequestException} 400
5337
+ * @throws {AuthorizationException} 403
5338
+ * @throws {NotFoundException} 404
5339
+ * @throws {UnprocessableEntityException} 422
5340
+ */
4644
5341
  async addOrganizationMembership(options) {
4645
5342
  const { organizationId, groupId, ...payload } = options;
4646
- const { data } = await this.workos.post(`/organizations/${organizationId}/groups/${groupId}/organization-memberships`, serializeAddGroupOrganizationMembershipOptions(payload));
5343
+ const { data } = await this.workos.post(`/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}/organization-memberships`, serializeCreateGroupMembership(payload));
4647
5344
  return deserializeGroup(data);
4648
5345
  }
4649
- async listOrganizationMemberships(options) {
4650
- const { organizationId, groupId, ...paginationOptions } = options;
4651
- const endpoint = `/organizations/${organizationId}/groups/${groupId}/organization-memberships`;
4652
- return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, paginationOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, params), paginationOptions);
4653
- }
5346
+ /**
5347
+ * Remove a member from a Group
5348
+ *
5349
+ * Remove an organization membership from a group.
5350
+ * @param options - The request options.
5351
+ * @param options.organizationId - Unique identifier of the Organization.
5352
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5353
+ * @param options.groupId - Unique identifier of the Group.
5354
+ * @example "group_01HXYZ123456789ABCDEFGHIJ"
5355
+ * @param options.omId - Unique identifier of the Organization Membership.
5356
+ * @example "om_01HXYZ123456789ABCDEFGHIJ"
5357
+ * @returns {Promise<void>}
5358
+ * @throws {AuthorizationException} 403
5359
+ * @throws {NotFoundException} 404
5360
+ */
4654
5361
  async removeOrganizationMembership(options) {
4655
5362
  const { organizationId, groupId, organizationMembershipId } = options;
4656
- await this.workos.delete(`/organizations/${organizationId}/groups/${groupId}/organization-memberships/${organizationMembershipId}`);
5363
+ await this.workos.delete(`/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}/organization-memberships/${encodeURIComponent(organizationMembershipId)}`);
4657
5364
  }
4658
5365
  };
4659
5366
  //#endregion
@@ -4790,7 +5497,6 @@ const serializeListAuthorizationResourcesOptions = (options) => ({
4790
5497
  ...options.parentResourceId && { parent_resource_id: options.parentResourceId },
4791
5498
  ...options.parentResourceTypeSlug && { parent_resource_type_slug: options.parentResourceTypeSlug },
4792
5499
  ...options.parentExternalId && { parent_external_id: options.parentExternalId },
4793
- ...options.search && { search: options.search },
4794
5500
  ...serializePaginationOptions(options)
4795
5501
  });
4796
5502
  //#endregion
@@ -5738,6 +6444,105 @@ function hasContinuationBit(byte) {
5738
6444
  return (byte & CONTINUATION_BIT) !== 0;
5739
6445
  }
5740
6446
  //#endregion
6447
+ //#region src/vault/serializers/create-data-key-response.serializer.ts
6448
+ const deserializeCreateDataKeyResponse = (response) => ({
6449
+ context: response.context,
6450
+ dataKey: response.data_key,
6451
+ encryptedKeys: response.encrypted_keys,
6452
+ id: response.id
6453
+ });
6454
+ //#endregion
6455
+ //#region src/vault/serializers/decrypt-response.serializer.ts
6456
+ const deserializeDecryptResponse = (response) => ({
6457
+ dataKey: response.data_key,
6458
+ id: response.id
6459
+ });
6460
+ //#endregion
6461
+ //#region src/vault/serializers/actor.serializer.ts
6462
+ const deserializeActor = (response) => ({
6463
+ id: response.id,
6464
+ name: response.name
6465
+ });
6466
+ //#endregion
6467
+ //#region src/vault/serializers/object-metadata.serializer.ts
6468
+ const deserializeObjectMetadata = (response) => ({
6469
+ context: response.context,
6470
+ environmentId: response.environment_id,
6471
+ id: response.id,
6472
+ keyId: response.key_id,
6473
+ updatedAt: new Date(response.updated_at),
6474
+ updatedBy: deserializeActor(response.updated_by),
6475
+ versionId: response.version_id ?? null
6476
+ });
6477
+ //#endregion
6478
+ //#region src/vault/serializers/vault-object.serializer.ts
6479
+ const deserializeVaultObject = (response) => ({
6480
+ id: response.id,
6481
+ metadata: deserializeObjectMetadata(response.metadata),
6482
+ name: response.name,
6483
+ value: response.value
6484
+ });
6485
+ //#endregion
6486
+ //#region src/vault/serializers/object-without-value.serializer.ts
6487
+ const deserializeObjectWithoutValue = (response) => ({
6488
+ id: response.id,
6489
+ metadata: deserializeObjectMetadata(response.metadata),
6490
+ name: response.name
6491
+ });
6492
+ //#endregion
6493
+ //#region src/vault/serializers/object-version.serializer.ts
6494
+ const deserializeObjectVersion = (response) => ({
6495
+ createdAt: new Date(response.created_at),
6496
+ currentVersion: response.current_version,
6497
+ etag: response.etag ?? "",
6498
+ id: response.id,
6499
+ size: response.size ?? 0
6500
+ });
6501
+ //#endregion
6502
+ //#region src/vault/serializers/list-metadata.serializer.ts
6503
+ const deserializeListMetadata = (response) => ({
6504
+ after: response.after ?? null,
6505
+ before: response.before ?? null
6506
+ });
6507
+ //#endregion
6508
+ //#region src/vault/serializers/version-list-response.serializer.ts
6509
+ const deserializeVersionListResponse = (response) => ({
6510
+ data: response.data.map(deserializeObjectVersion),
6511
+ listMetadata: deserializeListMetadata(response.list_metadata)
6512
+ });
6513
+ //#endregion
6514
+ //#region src/vault/serializers/object-summary.serializer.ts
6515
+ const deserializeObjectSummary = (response) => ({
6516
+ id: response.id,
6517
+ name: response.name,
6518
+ updatedAt: response.updated_at != null ? new Date(response.updated_at) : null
6519
+ });
6520
+ //#endregion
6521
+ //#region src/vault/serializers/create-data-key-request.serializer.ts
6522
+ const serializeCreateDataKeyRequest = (model) => ({ context: model.context });
6523
+ //#endregion
6524
+ //#region src/vault/serializers/decrypt-request.serializer.ts
6525
+ const serializeDecryptRequest = (model) => ({ keys: model.keys });
6526
+ //#endregion
6527
+ //#region src/vault/serializers/rekey-request.serializer.ts
6528
+ const serializeRekeyRequest = (model) => ({
6529
+ context: model.context,
6530
+ encrypted_keys: model.encryptedKeys
6531
+ });
6532
+ //#endregion
6533
+ //#region src/vault/serializers/create-object-request.serializer.ts
6534
+ const serializeCreateObjectRequest = (model) => ({
6535
+ key_context: model.keyContext,
6536
+ name: model.name,
6537
+ value: model.value
6538
+ });
6539
+ //#endregion
6540
+ //#region src/vault/serializers/update-object-request.serializer.ts
6541
+ const serializeUpdateObjectRequest = (model) => ({
6542
+ value: model.value,
6543
+ version_check: model.versionCheck ?? null
6544
+ });
6545
+ //#endregion
5741
6546
  //#region src/common/utils/base64.ts
5742
6547
  /**
5743
6548
  * Cross-runtime compatible base64 encoding/decoding utilities
@@ -5767,128 +6572,235 @@ function uint8ArrayToBase64(bytes) {
5767
6572
  else throw new Error("No base64 encoding implementation available");
5768
6573
  }
5769
6574
  //#endregion
5770
- //#region src/vault/serializers/vault-key.serializer.ts
5771
- const deserializeCreateDataKeyResponse = (key) => ({
5772
- context: key.context,
5773
- dataKey: {
5774
- key: key.data_key,
5775
- id: key.id
5776
- },
5777
- encryptedKeys: key.encrypted_keys
5778
- });
5779
- const deserializeDecryptDataKeyResponse = (key) => ({
5780
- key: key.data_key,
5781
- id: key.id
5782
- });
5783
- //#endregion
5784
- //#region src/vault/serializers/vault-object.serializer.ts
5785
- const deserializeObjectMetadata = (metadata) => ({
5786
- context: metadata.context,
5787
- environmentId: metadata.environment_id,
5788
- id: metadata.id,
5789
- keyId: metadata.key_id,
5790
- updatedAt: new Date(Date.parse(metadata.updated_at)),
5791
- updatedBy: metadata.updated_by,
5792
- versionId: metadata.version_id
5793
- });
5794
- const deserializeObject = (object) => ({
5795
- id: object.id,
5796
- name: object.name,
5797
- ...object.value !== void 0 && { value: object.value },
5798
- metadata: deserializeObjectMetadata(object.metadata)
5799
- });
5800
- const deserializeObjectDigest = (digest) => ({
5801
- id: digest.id,
5802
- name: digest.name,
5803
- updatedAt: new Date(Date.parse(digest.updated_at))
5804
- });
5805
- const deserializeListObjects = (list) => ({
5806
- object: "list",
5807
- data: list.data.map(deserializeObjectDigest),
5808
- listMetadata: {
5809
- ...list.list_metadata.after !== void 0 && { after: list.list_metadata.after },
5810
- ...list.list_metadata.before !== void 0 && { before: list.list_metadata.before }
5811
- }
5812
- });
5813
- const desrializeListObjectVersions = (list) => list.data.map(deserializeObjectVersion);
5814
- const deserializeObjectVersion = (version) => ({
5815
- createdAt: new Date(Date.parse(version.created_at)),
5816
- currentVersion: version.current_version,
5817
- id: version.id
5818
- });
5819
- const serializeCreateObjectEntity = (options) => ({
5820
- name: options.name,
5821
- value: options.value,
5822
- key_context: options.context
5823
- });
5824
- const serializeUpdateObjectEntity = (options) => ({
5825
- value: options.value,
5826
- version_check: options.versionCheck
5827
- });
5828
- //#endregion
5829
6575
  //#region src/vault/vault.ts
6576
+ const serializeListObjectsOptions = (options) => {
6577
+ const wire = {
6578
+ limit: options.limit,
6579
+ before: options.before,
6580
+ after: options.after,
6581
+ order: options.order
6582
+ };
6583
+ if (options.search !== void 0) wire.search = options.search;
6584
+ if (options.updatedAfter !== void 0) wire.updated_after = options.updatedAfter;
6585
+ return wire;
6586
+ };
5830
6587
  var Vault = class {
5831
6588
  workos;
5832
- cryptoProvider;
5833
6589
  constructor(workos) {
5834
6590
  this.workos = workos;
5835
- this.cryptoProvider = workos.getCryptoProvider();
5836
6591
  }
5837
- decode(payload) {
5838
- const inputData = base64ToUint8Array(payload);
5839
- const iv = new Uint8Array(inputData.subarray(0, 12));
5840
- const tag = new Uint8Array(inputData.subarray(12, 28));
5841
- const { value: keyLen, nextIndex } = decodeUInt32(inputData, 28);
6592
+ async readObjectByName(options) {
6593
+ const name = typeof options === "string" ? options : options.name;
6594
+ const { data } = await this.workos.get(`/vault/v1/kv/name/${encodeURIComponent(name)}`);
6595
+ return deserializeVaultObject(data);
6596
+ }
6597
+ /**
6598
+ * Create a data key
6599
+ *
6600
+ * Generate an isolated encryption key for local encryption operations.
6601
+ * @param options - Object containing context.
6602
+ * @param options.context - Map of values used to determine the encryption key.
6603
+ * @example {"organization_id":"org_01K8ZYT4AWJ6XP0E0S8CTBHE3P"}
6604
+ * @returns {Promise<DataKeyPair>}
6605
+ * @throws {BadRequestException} 400
6606
+ * @throws {UnprocessableEntityException} 422
6607
+ */
6608
+ async createDataKey(options) {
6609
+ const payload = options;
6610
+ const { data } = await this.workos.post("/vault/v1/keys/data-key", serializeCreateDataKeyRequest(payload));
6611
+ const result = deserializeCreateDataKeyResponse(data);
5842
6612
  return {
5843
- iv,
5844
- tag,
5845
- keys: uint8ArrayToBase64(inputData.subarray(nextIndex, nextIndex + keyLen)),
5846
- ciphertext: new Uint8Array(inputData.subarray(nextIndex + keyLen))
6613
+ context: result.context,
6614
+ dataKey: {
6615
+ key: result.dataKey,
6616
+ id: result.id
6617
+ },
6618
+ encryptedKeys: result.encryptedKeys
5847
6619
  };
5848
6620
  }
5849
- async createObject(options) {
5850
- const { data } = await this.workos.post(`/vault/v1/kv`, serializeCreateObjectEntity(options));
5851
- return deserializeObjectMetadata(data);
6621
+ /**
6622
+ * Decrypt a data key
6623
+ *
6624
+ * Decrypt a previously encrypted data key from WorkOS Vault.
6625
+ * @param options - Object containing keys.
6626
+ * @param options.keys - Base64-encoded encrypted data key to decrypt.
6627
+ * @example "V09TLkVLTS52MQBiZjUxY2NlYy03OGI0LTUyMDAtYjM4My0zNTczMGU3MWVmNjEBATEBJGJmNjVlMzI2LTQzYTAtNGIyMC04OGM0LTA3ZmYzZGU1NDM0YwF0YmY2NWUzMjYtNDNhMC00YjIwLTg4YzQtMDdmZjNkZTU0MzRj"
6628
+ * @returns {Promise<DataKey>}
6629
+ * @throws {BadRequestException} 400
6630
+ */
6631
+ async decryptDataKey(options) {
6632
+ const payload = options;
6633
+ const { data } = await this.workos.post("/vault/v1/keys/decrypt", serializeDecryptRequest(payload));
6634
+ const result = deserializeDecryptResponse(data);
6635
+ return {
6636
+ key: result.dataKey,
6637
+ id: result.id
6638
+ };
6639
+ }
6640
+ /**
6641
+ * Re-encrypt a data key
6642
+ *
6643
+ * Decrypt an existing data key and re-encrypt it under a new key context.
6644
+ * @param options - Object containing context, encryptedKeys.
6645
+ * @param options.context - Map of values used to determine the new encryption key.
6646
+ * @example {"organization_id":"org_01K8ZYT4AWJ6XP0E0S8CTBHE3P"}
6647
+ * @param options.encryptedKeys - Base64-encoded encrypted data key blob to re-encrypt.
6648
+ * @example "V09TLkVLTS52MQBiZjUxY2NlYy03OGI0LTUyMDAtYjM4My0zNTczMGU3MWVmNjEBATEBJGJmNjVlMzI2LTQzYTAtNGIyMC04OGM0LTA3ZmYzZGU1NDM0YwF0YmY2NWUzMjYtNDNhMC00YjIwLTg4YzQtMDdmZjNkZTU0MzRj"
6649
+ * @returns {Promise<CreateDataKeyResponse>}
6650
+ * @throws {BadRequestException} 400
6651
+ * @throws {UnprocessableEntityException} 422
6652
+ */
6653
+ async createRekey(options) {
6654
+ const payload = options;
6655
+ const { data } = await this.workos.post("/vault/v1/keys/rekey", serializeRekeyRequest(payload));
6656
+ return deserializeCreateDataKeyResponse(data);
5852
6657
  }
6658
+ /**
6659
+ * List objects
6660
+ *
6661
+ * List all encrypted objects with cursor-based pagination.
6662
+ * @param options - Pagination and filter options.
6663
+ * @returns {Promise<AutoPaginatable<ObjectSummary, PaginationOptions>>}
6664
+ * @throws {BadRequestException} 400
6665
+ */
5853
6666
  async listObjects(options) {
5854
- const url = new URL("/vault/v1/kv", this.workos.baseURL);
5855
- if (options?.after) url.searchParams.set("after", options.after);
5856
- if (options?.before) url.searchParams.set("before", options.before);
5857
- if (options?.limit) url.searchParams.set("limit", options.limit.toString());
5858
- if (options?.order) url.searchParams.set("order", options.order);
5859
- const { data } = await this.workos.get(url.toString());
5860
- return deserializeListObjects(data);
6667
+ const paginationOptions = options;
6668
+ return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/vault/v1/kv", deserializeObjectSummary, options ? serializeListObjectsOptions(options) : void 0), (params) => fetchAndDeserialize(this.workos, "/vault/v1/kv", deserializeObjectSummary, params), paginationOptions);
5861
6669
  }
5862
- async listObjectVersions(options) {
5863
- const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(options.id)}/versions`);
5864
- return desrializeListObjectVersions(data);
6670
+ /**
6671
+ * Create an object
6672
+ *
6673
+ * Encrypt and store a new key-value object.
6674
+ * @param options - Object containing keyContext, name, value.
6675
+ * @param options.keyContext - Map of values used to determine the encryption key.
6676
+ * @example {"organization_id":"org_01K8ZYT4AWJ6XP0E0S8CTBHE3P"}
6677
+ * @param options.name - Unique name for the object.
6678
+ * @example "my-secret"
6679
+ * @param options.value - Plaintext data to encrypt and store.
6680
+ * @example "s3cr3t-v4lu3"
6681
+ * @returns {Promise<ObjectMetadata>}
6682
+ * @throws {BadRequestException} 400
6683
+ * @throws {ConflictException} 409
6684
+ * @throws {UnprocessableEntityException} 422
6685
+ */
6686
+ async createObject(options) {
6687
+ const payload = options;
6688
+ const requestPayload = {
6689
+ ...payload,
6690
+ keyContext: payload.context
6691
+ };
6692
+ const { data } = await this.workos.post("/vault/v1/kv", serializeCreateObjectRequest(requestPayload));
6693
+ return deserializeObjectMetadata(data);
5865
6694
  }
6695
+ /**
6696
+ * Read an object by ID
6697
+ *
6698
+ * Fetch and decrypt an object by its unique identifier.
6699
+ * @param options - The request options.
6700
+ * @param options.id - Unique identifier of the object.
6701
+ * @example "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
6702
+ * @returns {Promise<VaultObject>}
6703
+ * @throws {BadRequestException} 400
6704
+ * @throws {NotFoundException} 404
6705
+ */
5866
6706
  async readObject(options) {
5867
- const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(options.id)}`);
5868
- return deserializeObject(data);
6707
+ const { id } = options;
6708
+ const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(id)}`);
6709
+ return deserializeVaultObject(data);
6710
+ }
6711
+ /**
6712
+ * Update an object
6713
+ *
6714
+ * Update the value of an existing encrypted object.
6715
+ * @param options - Object containing value.
6716
+ * @param options.id - Unique identifier of the object.
6717
+ * @example "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
6718
+ * @param options.value - New plaintext value.
6719
+ * @example "upd4t3d-v4lu3"
6720
+ * @param options.versionCheck - ID of the expected current version for optimistic locking.
6721
+ * @example "c3d4e5f6-7890-abcd-ef12-34567890abcd"
6722
+ * @returns {Promise<VaultObject>}
6723
+ * @throws {BadRequestException} 400
6724
+ * @throws {ConflictException} 409
6725
+ */
6726
+ async updateObject(options) {
6727
+ const { id, ...payload } = options;
6728
+ const { data } = await this.workos.put(`/vault/v1/kv/${encodeURIComponent(id)}`, serializeUpdateObjectRequest(payload));
6729
+ return {
6730
+ ...deserializeObjectWithoutValue(data),
6731
+ value: void 0
6732
+ };
5869
6733
  }
5870
- async readObjectByName(name) {
5871
- const { data } = await this.workos.get(`/vault/v1/kv/name/${encodeURIComponent(name)}`);
5872
- return deserializeObject(data);
6734
+ /**
6735
+ * Delete an object
6736
+ *
6737
+ * Delete an encrypted object.
6738
+ * @param options - Additional query options.
6739
+ * @param options.id - Unique identifier of the object.
6740
+ * @example "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
6741
+ * @param options.versionCheck - Expected current version for optimistic locking.
6742
+ * @example "c3d4e5f6-7890-abcd-ef12-34567890abcd"
6743
+ * @returns {Promise<void>}
6744
+ * @throws {NotFoundException} 404
6745
+ * @throws {ConflictException} 409
6746
+ */
6747
+ async deleteObject(options) {
6748
+ const { id } = options;
6749
+ await this.workos.delete(`/vault/v1/kv/${encodeURIComponent(id)}`, { query: { ...options.versionCheck !== void 0 && { version_check: options.versionCheck } } });
5873
6750
  }
6751
+ /**
6752
+ * Describe an object
6753
+ *
6754
+ * Fetch metadata for an object without decrypting it.
6755
+ * @param options - The request options.
6756
+ * @param options.id - Unique identifier of the object.
6757
+ * @example "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
6758
+ * @returns {Promise<VaultObject>}
6759
+ * @throws {BadRequestException} 400
6760
+ * @throws {NotFoundException} 404
6761
+ */
5874
6762
  async describeObject(options) {
5875
- const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(options.id)}/metadata`);
5876
- return deserializeObject(data);
5877
- }
5878
- async updateObject(options) {
5879
- const { data } = await this.workos.put(`/vault/v1/kv/${encodeURIComponent(options.id)}`, serializeUpdateObjectEntity(options));
5880
- return deserializeObject(data);
6763
+ const { id } = options;
6764
+ const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(id)}/metadata`);
6765
+ return {
6766
+ ...deserializeObjectWithoutValue(data),
6767
+ value: void 0
6768
+ };
5881
6769
  }
5882
- async deleteObject(options) {
5883
- return this.workos.delete(`/vault/v1/kv/${encodeURIComponent(options.id)}`);
6770
+ /**
6771
+ * List object versions
6772
+ *
6773
+ * Retrieve all versions for a specific object.
6774
+ * @param options - The request options.
6775
+ * @param options.id - Unique identifier of the object.
6776
+ * @example "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
6777
+ * @returns {Promise<ObjectVersion[]>}
6778
+ * @throws {BadRequestException} 400
6779
+ * @throws {NotFoundException} 404
6780
+ */
6781
+ async listObjectVersions(options) {
6782
+ const { id } = options;
6783
+ const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(id)}/versions`);
6784
+ return deserializeVersionListResponse(data).data;
5884
6785
  }
5885
- async createDataKey(options) {
5886
- const { data } = await this.workos.post(`/vault/v1/keys/data-key`, options);
5887
- return deserializeCreateDataKeyResponse(data);
6786
+ decode(payload) {
6787
+ const inputData = base64ToUint8Array(payload);
6788
+ const iv = new Uint8Array(inputData.subarray(0, 12));
6789
+ const tag = new Uint8Array(inputData.subarray(12, 28));
6790
+ const { value: keyLen, nextIndex } = decodeUInt32(inputData, 28);
6791
+ return {
6792
+ iv,
6793
+ tag,
6794
+ keys: uint8ArrayToBase64(inputData.subarray(nextIndex, nextIndex + keyLen)),
6795
+ ciphertext: new Uint8Array(inputData.subarray(nextIndex + keyLen))
6796
+ };
5888
6797
  }
5889
- async decryptDataKey(options) {
5890
- const { data } = await this.workos.post(`/vault/v1/keys/decrypt`, options);
5891
- return deserializeDecryptDataKeyResponse(data);
6798
+ async decrypt(encryptedData, associatedData) {
6799
+ const decoded = this.decode(encryptedData);
6800
+ const key = base64ToUint8Array((await this.decryptDataKey({ keys: decoded.keys })).key);
6801
+ const aadBuffer = associatedData ? new TextEncoder().encode(associatedData) : void 0;
6802
+ const decrypted = await this.workos.getCryptoProvider().decrypt(decoded.ciphertext, key, decoded.iv, decoded.tag, aadBuffer);
6803
+ return new TextDecoder().decode(decrypted);
5892
6804
  }
5893
6805
  async encrypt(data, context, associatedData) {
5894
6806
  const keyPair = await this.createDataKey({ context });
@@ -5897,8 +6809,9 @@ var Vault = class {
5897
6809
  const keyBlob = base64ToUint8Array(keyPair.encryptedKeys);
5898
6810
  const prefixLenBuffer = encodeUInt32(keyBlob.length);
5899
6811
  const aadBuffer = associatedData ? encoder.encode(associatedData) : void 0;
5900
- const iv = this.cryptoProvider.randomBytes(12);
5901
- const { ciphertext, iv: resultIv, tag } = await this.cryptoProvider.encrypt(encoder.encode(data), key, iv, aadBuffer);
6812
+ const cryptoProvider = this.workos.getCryptoProvider();
6813
+ const iv = cryptoProvider.randomBytes(12);
6814
+ const { ciphertext, iv: resultIv, tag } = await cryptoProvider.encrypt(encoder.encode(data), key, iv, aadBuffer);
5902
6815
  const resultArray = new Uint8Array(resultIv.length + tag.length + prefixLenBuffer.length + keyBlob.length + ciphertext.length);
5903
6816
  let offset = 0;
5904
6817
  resultArray.set(resultIv, offset);
@@ -5912,18 +6825,10 @@ var Vault = class {
5912
6825
  resultArray.set(ciphertext, offset);
5913
6826
  return uint8ArrayToBase64(resultArray);
5914
6827
  }
5915
- async decrypt(encryptedData, associatedData) {
5916
- const decoded = this.decode(encryptedData);
5917
- const key = base64ToUint8Array((await this.decryptDataKey({ keys: decoded.keys })).key);
5918
- const encoder = new TextEncoder();
5919
- const aadBuffer = associatedData ? encoder.encode(associatedData) : void 0;
5920
- const decrypted = await this.cryptoProvider.decrypt(decoded.ciphertext, key, decoded.iv, decoded.tag, aadBuffer);
5921
- return new TextDecoder().decode(decrypted);
5922
- }
5923
6828
  };
5924
6829
  //#endregion
5925
6830
  //#region package.json
5926
- var version = "9.3.1";
6831
+ var version = "10.1.0";
5927
6832
  //#endregion
5928
6833
  //#region src/workos.ts
5929
6834
  const DEFAULT_HOSTNAME = "api.workos.com";
@@ -5944,6 +6849,7 @@ var WorkOS = class {
5944
6849
  auditLogs = new AuditLogs(this);
5945
6850
  authorization = new Authorization(this);
5946
6851
  directorySync = new DirectorySync(this);
6852
+ connect = new Connect(this);
5947
6853
  events = new Events(this);
5948
6854
  featureFlags = new FeatureFlags(this);
5949
6855
  groups = new Groups(this);
@@ -5952,6 +6858,7 @@ var WorkOS = class {
5952
6858
  organizationDomains = new OrganizationDomains(this);
5953
6859
  passwordless = new Passwordless(this);
5954
6860
  pipes = new Pipes(this);
6861
+ radar = new Radar(this);
5955
6862
  adminPortal = new AdminPortal(this);
5956
6863
  sso = new SSO(this);
5957
6864
  userManagement;
@@ -6006,7 +6913,7 @@ var WorkOS = class {
6006
6913
  return `workos-node/${version}`;
6007
6914
  }
6008
6915
  createWebhookClient() {
6009
- return new Webhooks(this.getCryptoProvider());
6916
+ return new Webhooks(this);
6010
6917
  }
6011
6918
  createActionsClient() {
6012
6919
  return new Actions(this.getCryptoProvider());
@@ -6299,6 +7206,6 @@ function createWorkOS(options) {
6299
7206
  return new WorkOS(options);
6300
7207
  }
6301
7208
  //#endregion
6302
- export { FetchHttpClient as A, NoApiKeyProvidedException as C, isAuthenticationErrorData as D, AuthenticationException as E, GenericServerException as O, NotFoundException as S, BadRequestException as T, UnprocessableEntityException as _, DomainDataState as a, RateLimitExceededException as b, FeatureFlagsRuntimeClient as c, serializeRevokeSessionOptions as d, AuthenticateWithSessionCookieFailureReason as f, Actions as g, Webhooks as h, OrganizationDomainVerificationStrategy as i, SubtleCryptoProvider as j, ApiKeyRequiredException as k, CookieSession as l, PKCE as m, ConnectionType as n, GenerateLinkIntent as o, AutoPaginatable as p, OrganizationDomainState as r, WorkOS as s, createWorkOS as t, RefreshSessionFailureReason as u, UnauthorizedException as v, ConflictException as w, OauthException as x, SignatureVerificationException as y };
7209
+ export { GenericServerException as A, OauthException as C, BadRequestException as D, ConflictException as E, FetchHttpClient as M, SubtleCryptoProvider as N, AuthenticationException as O, RateLimitExceededException as S, NoApiKeyProvidedException as T, AutoPaginatable as _, DomainDataState as a, UnauthorizedException as b, deserializeGetTokenResponse as c, CookieSession as d, RefreshSessionFailureReason as f, Webhooks as g, PKCE as h, OrganizationDomainVerificationStrategy as i, ApiKeyRequiredException as j, isAuthenticationErrorData as k, serializeGetTokenOptions as l, AuthenticateWithSessionCookieFailureReason as m, ConnectionType as n, GenerateLinkIntent as o, serializeRevokeSessionOptions as p, OrganizationDomainState as r, WorkOS as s, createWorkOS as t, FeatureFlagsRuntimeClient as u, Actions as v, NotFoundException as w, SignatureVerificationException as x, UnprocessableEntityException as y };
6303
7210
 
6304
- //# sourceMappingURL=factory-B2N5WzoO.mjs.map
7211
+ //# sourceMappingURL=factory-B6eXwJEX.mjs.map