@workos-inc/node 9.3.1 → 10.0.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.
@@ -732,6 +732,43 @@ const deserializeAuthenticationEvent = (authenticationEvent) => ({
732
732
  userId: authenticationEvent.user_id
733
733
  });
734
734
  //#endregion
735
+ //#region src/multi-factor-auth/serializers/totp.serializer.ts
736
+ const deserializeTotp = (totp) => {
737
+ return {
738
+ issuer: totp.issuer,
739
+ user: totp.user
740
+ };
741
+ };
742
+ const deserializeTotpWithSecrets = (totp) => {
743
+ return {
744
+ issuer: totp.issuer,
745
+ user: totp.user,
746
+ qrCode: totp.qr_code,
747
+ secret: totp.secret,
748
+ uri: totp.uri
749
+ };
750
+ };
751
+ //#endregion
752
+ //#region src/user-management/serializers/authentication-factor.serializer.ts
753
+ const deserializeFactor$1 = (factor) => ({
754
+ object: factor.object,
755
+ id: factor.id,
756
+ createdAt: factor.created_at,
757
+ updatedAt: factor.updated_at,
758
+ type: factor.type,
759
+ totp: deserializeTotp(factor.totp),
760
+ userId: factor.user_id
761
+ });
762
+ const deserializeFactorWithSecrets$1 = (factor) => ({
763
+ object: factor.object,
764
+ id: factor.id,
765
+ createdAt: factor.created_at,
766
+ updatedAt: factor.updated_at,
767
+ type: factor.type,
768
+ totp: deserializeTotpWithSecrets(factor.totp),
769
+ userId: factor.user_id
770
+ });
771
+ //#endregion
735
772
  //#region src/user-management/serializers/oauth-tokens.serializer.ts
736
773
  const deserializeOauthTokens = (oauthTokens) => oauthTokens ? {
737
774
  accessToken: oauthTokens.access_token,
@@ -810,43 +847,6 @@ const serializeEnrollAuthFactorOptions = (options) => ({
810
847
  totp_secret: options.totpSecret
811
848
  });
812
849
  //#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
850
  //#region src/user-management/serializers/invitation.serializer.ts
851
851
  const deserializeInvitation = (invitation) => ({
852
852
  object: invitation.object,
@@ -1082,6 +1082,47 @@ var Actions = class {
1082
1082
  }
1083
1083
  };
1084
1084
  //#endregion
1085
+ //#region src/common/utils/pagination.ts
1086
+ var AutoPaginatable = class {
1087
+ list;
1088
+ apiCall;
1089
+ object = "list";
1090
+ options;
1091
+ constructor(list, apiCall, options) {
1092
+ this.list = list;
1093
+ this.apiCall = apiCall;
1094
+ this.options = options ?? {};
1095
+ }
1096
+ get data() {
1097
+ return this.list.data;
1098
+ }
1099
+ get listMetadata() {
1100
+ return this.list.listMetadata;
1101
+ }
1102
+ async *generatePages(params) {
1103
+ const result = await this.apiCall({
1104
+ ...this.options,
1105
+ limit: 100,
1106
+ after: params.after
1107
+ });
1108
+ yield result.data;
1109
+ if (result.listMetadata.after) {
1110
+ await new Promise((resolve) => setTimeout(resolve, 350));
1111
+ yield* this.generatePages({ after: result.listMetadata.after });
1112
+ }
1113
+ }
1114
+ /**
1115
+ * Automatically paginates over the list of results, returning the complete data set.
1116
+ * Returns the first result if `options.limit` is passed to the first request.
1117
+ */
1118
+ async autoPagination() {
1119
+ if (this.options.limit) return this.data;
1120
+ const results = [];
1121
+ for await (const page of this.generatePages({ after: this.options.after })) results.push(...page);
1122
+ return results;
1123
+ }
1124
+ };
1125
+ //#endregion
1085
1126
  //#region src/directory-sync/serializers/directory-group.serializer.ts
1086
1127
  const deserializeDirectoryGroup = (directoryGroup) => ({
1087
1128
  id: directoryGroup.id,
@@ -1362,30 +1403,30 @@ const deserializeFeatureFlag = (featureFlag) => ({
1362
1403
  updatedAt: featureFlag.updated_at
1363
1404
  });
1364
1405
  //#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
1406
+ //#region src/groups/serializers/create-group.serializer.ts
1407
+ const serializeCreateGroup = (model) => ({
1408
+ name: model.name,
1409
+ description: model.description ?? null
1372
1410
  });
1373
1411
  //#endregion
1412
+ //#region src/groups/serializers/create-group-membership.serializer.ts
1413
+ const serializeCreateGroupMembership = (model) => ({ organization_membership_id: model.organizationMembershipId });
1414
+ //#endregion
1374
1415
  //#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
1416
+ const deserializeGroup = (response) => ({
1417
+ object: response.object,
1418
+ id: response.id,
1419
+ organizationId: response.organization_id,
1420
+ name: response.name,
1421
+ description: response.description ?? null,
1422
+ createdAt: new Date(response.created_at),
1423
+ updatedAt: new Date(response.updated_at)
1424
+ });
1425
+ //#endregion
1426
+ //#region src/groups/serializers/update-group.serializer.ts
1427
+ const serializeUpdateGroup = (model) => ({
1428
+ name: model.name,
1429
+ description: model.description ?? null
1389
1430
  });
1390
1431
  //#endregion
1391
1432
  //#region src/vault/serializers/vault-event.serializer.ts
@@ -1712,15 +1753,122 @@ const serializePaginationOptions = (options) => ({
1712
1753
  ...options.order && { order: options.order }
1713
1754
  });
1714
1755
  //#endregion
1756
+ //#region src/common/utils/fetch-and-deserialize.ts
1757
+ const setDefaultOptions = (options) => {
1758
+ return {
1759
+ ...options,
1760
+ order: options?.order || "desc"
1761
+ };
1762
+ };
1763
+ const fetchAndDeserialize = async (workos, endpoint, deserializeFn, options, requestOptions) => {
1764
+ const { data } = await workos.get(endpoint, {
1765
+ query: setDefaultOptions(options),
1766
+ ...requestOptions
1767
+ });
1768
+ return deserializeList(data, deserializeFn);
1769
+ };
1770
+ //#endregion
1771
+ //#region src/webhooks/serializers/webhook-endpoint.serializer.ts
1772
+ const deserializeWebhookEndpoint = (response) => ({
1773
+ object: response.object,
1774
+ id: response.id,
1775
+ endpointUrl: response.endpoint_url,
1776
+ secret: response.secret,
1777
+ status: response.status,
1778
+ events: response.events,
1779
+ createdAt: new Date(response.created_at),
1780
+ updatedAt: new Date(response.updated_at)
1781
+ });
1782
+ //#endregion
1783
+ //#region src/webhooks/serializers/create-webhook-endpoint.serializer.ts
1784
+ const serializeCreateWebhookEndpoint = (model) => ({
1785
+ endpoint_url: model.endpointUrl,
1786
+ events: model.events
1787
+ });
1788
+ //#endregion
1789
+ //#region src/webhooks/serializers/update-webhook-endpoint.serializer.ts
1790
+ const serializeUpdateWebhookEndpoint = (model) => ({
1791
+ endpoint_url: model.endpointUrl,
1792
+ status: model.status,
1793
+ events: model.events
1794
+ });
1795
+ //#endregion
1715
1796
  //#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
1797
  var Webhooks = class {
1721
- signatureProvider;
1722
- constructor(cryptoProvider) {
1723
- this.signatureProvider = new SignatureProvider(cryptoProvider);
1798
+ workos;
1799
+ constructor(workos) {
1800
+ this.workos = workos;
1801
+ }
1802
+ /**
1803
+ * List Webhook Endpoints
1804
+ *
1805
+ * Get a list of all of your existing webhook endpoints.
1806
+ * @param options - Pagination and filter options.
1807
+ * @returns {Promise<AutoPaginatable<WebhookEndpoint, PaginationOptions>>}
1808
+ */
1809
+ async listWebhookEndpoints(options) {
1810
+ const paginationOptions = options;
1811
+ return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/webhook_endpoints", deserializeWebhookEndpoint, paginationOptions), (params) => fetchAndDeserialize(this.workos, "/webhook_endpoints", deserializeWebhookEndpoint, params), paginationOptions);
1812
+ }
1813
+ /**
1814
+ * Create a Webhook Endpoint
1815
+ *
1816
+ * Create a new webhook endpoint to receive event notifications.
1817
+ * @param options - Object containing endpointUrl, events.
1818
+ * @param options.endpointUrl - The HTTPS URL where webhooks will be sent.
1819
+ * @example "https://example.com/webhooks"
1820
+ * @param options.events - The events that the Webhook Endpoint is subscribed to.
1821
+ * @example ["user.created","dsync.user.created"]
1822
+ * @returns {Promise<WebhookEndpoint>}
1823
+ * @throws {ConflictException} 409
1824
+ * @throws {UnprocessableEntityException} 422
1825
+ */
1826
+ async createWebhookEndpoint(options) {
1827
+ const payload = options;
1828
+ const { data } = await this.workos.post("/webhook_endpoints", serializeCreateWebhookEndpoint(payload));
1829
+ return deserializeWebhookEndpoint(data);
1830
+ }
1831
+ /**
1832
+ * Update a Webhook Endpoint
1833
+ *
1834
+ * Update the properties of an existing webhook endpoint.
1835
+ * @param options - The request body.
1836
+ * @param options.id - Unique identifier of the Webhook Endpoint.
1837
+ * @example "we_0123456789"
1838
+ * @param options.endpointUrl - The HTTPS URL where webhooks will be sent.
1839
+ * @example "https://example.com/webhooks"
1840
+ * @param options.status - Whether the Webhook Endpoint is enabled or disabled.
1841
+ * @example "enabled"
1842
+ * @param options.events - The events that the Webhook Endpoint is subscribed to.
1843
+ * @example ["user.created","dsync.user.created"]
1844
+ * @returns {Promise<WebhookEndpoint>}
1845
+ * @throws {NotFoundException} 404
1846
+ * @throws {ConflictException} 409
1847
+ * @throws {UnprocessableEntityException} 422
1848
+ */
1849
+ async updateWebhookEndpoint(options) {
1850
+ const { id, ...payload } = options;
1851
+ const { data } = await this.workos.patch(`/webhook_endpoints/${encodeURIComponent(id)}`, serializeUpdateWebhookEndpoint(payload));
1852
+ return deserializeWebhookEndpoint(data);
1853
+ }
1854
+ /**
1855
+ * Delete a Webhook Endpoint
1856
+ *
1857
+ * Delete an existing webhook endpoint.
1858
+ * @param options - The request options.
1859
+ * @param options.id - Unique identifier of the Webhook Endpoint.
1860
+ * @example "we_0123456789"
1861
+ * @returns {Promise<void>}
1862
+ * @throws {NotFoundException} 404
1863
+ */
1864
+ async deleteWebhookEndpoint(options) {
1865
+ const { id } = options;
1866
+ await this.workos.delete(`/webhook_endpoints/${encodeURIComponent(id)}`);
1867
+ }
1868
+ _signatureProvider;
1869
+ get signatureProvider() {
1870
+ if (!this._signatureProvider) this._signatureProvider = new SignatureProvider(this.workos.getCryptoProvider());
1871
+ return this._signatureProvider;
1724
1872
  }
1725
1873
  get verifyHeader() {
1726
1874
  return this.signatureProvider.verifyHeader.bind(this.signatureProvider);
@@ -1739,7 +1887,11 @@ var Webhooks = class {
1739
1887
  tolerance
1740
1888
  };
1741
1889
  await this.verifyHeader(options);
1742
- return deserializeEvent(parseVerifiedPayload(payload));
1890
+ return deserializeEvent(this.parseVerifiedPayload(payload));
1891
+ }
1892
+ parseVerifiedPayload(payload) {
1893
+ if (typeof payload === "object" && !isBinaryPayload(payload)) return payload;
1894
+ return JSON.parse(decodePayloadToString(payload));
1743
1895
  }
1744
1896
  };
1745
1897
  //#endregion
@@ -1793,47 +1945,6 @@ var PKCE = class {
1793
1945
  }
1794
1946
  };
1795
1947
  //#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
1948
  //#region src/api-keys/serializers/create-organization-api-key-options.serializer.ts
1838
1949
  function serializeCreateOrganizationApiKeyOptions(options) {
1839
1950
  return {
@@ -1863,21 +1974,6 @@ function deserializeValidateApiKeyResponse(response) {
1863
1974
  return { apiKey: response.api_key ? deserializeApiKey(response.api_key) : null };
1864
1975
  }
1865
1976
  //#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
1977
  //#region src/api-keys/api-keys.ts
1882
1978
  var ApiKeys = class {
1883
1979
  workos;
@@ -1950,6 +2046,359 @@ var ApiKeys = class {
1950
2046
  }
1951
2047
  };
1952
2048
  //#endregion
2049
+ //#region src/connect/serializers/external-auth-complete-response.serializer.ts
2050
+ const deserializeExternalAuthCompleteResponse = (response) => ({ redirectUri: response.redirect_uri });
2051
+ //#endregion
2052
+ //#region src/connect/serializers/connect-application-redirect-uri.serializer.ts
2053
+ const deserializeConnectApplicationRedirectUri = (response) => ({
2054
+ uri: response.uri,
2055
+ default: response.default
2056
+ });
2057
+ //#endregion
2058
+ //#region src/connect/serializers/connect-application.serializer.ts
2059
+ const deserializeConnectApplication = (response) => {
2060
+ switch (response.application_type) {
2061
+ case "oauth": return {
2062
+ object: response.object,
2063
+ id: response.id,
2064
+ clientId: response.client_id,
2065
+ description: response.description,
2066
+ name: response.name,
2067
+ scopes: response.scopes,
2068
+ createdAt: new Date(response.created_at),
2069
+ updatedAt: new Date(response.updated_at),
2070
+ applicationType: "oauth",
2071
+ redirectUris: response.redirect_uris.map(deserializeConnectApplicationRedirectUri),
2072
+ usesPkce: response.uses_pkce,
2073
+ isFirstParty: response.is_first_party,
2074
+ wasDynamicallyRegistered: response.was_dynamically_registered,
2075
+ organizationId: response.organization_id
2076
+ };
2077
+ case "m2m": return {
2078
+ object: response.object,
2079
+ id: response.id,
2080
+ clientId: response.client_id,
2081
+ description: response.description,
2082
+ name: response.name,
2083
+ scopes: response.scopes,
2084
+ createdAt: new Date(response.created_at),
2085
+ updatedAt: new Date(response.updated_at),
2086
+ applicationType: "m2m",
2087
+ organizationId: response.organization_id
2088
+ };
2089
+ default: throw new Error(`Unknown application_type: ${response.application_type}`);
2090
+ }
2091
+ };
2092
+ //#endregion
2093
+ //#region src/connect/serializers/application-credentials-list-item.serializer.ts
2094
+ const deserializeApplicationCredentialsListItem = (response) => ({
2095
+ object: response.object,
2096
+ id: response.id,
2097
+ secretHint: response.secret_hint,
2098
+ lastUsedAt: response.last_used_at != null ? new Date(response.last_used_at) : null,
2099
+ createdAt: new Date(response.created_at),
2100
+ updatedAt: new Date(response.updated_at)
2101
+ });
2102
+ //#endregion
2103
+ //#region src/connect/serializers/new-connect-application-secret.serializer.ts
2104
+ const deserializeNewConnectApplicationSecret = (response) => ({
2105
+ object: response.object,
2106
+ id: response.id,
2107
+ secretHint: response.secret_hint,
2108
+ lastUsedAt: response.last_used_at != null ? new Date(response.last_used_at) : null,
2109
+ createdAt: new Date(response.created_at),
2110
+ updatedAt: new Date(response.updated_at),
2111
+ secret: response.secret
2112
+ });
2113
+ //#endregion
2114
+ //#region src/connect/serializers/user-object.serializer.ts
2115
+ const serializeUserObject = (model) => ({
2116
+ id: model.id,
2117
+ email: model.email,
2118
+ first_name: model.firstName,
2119
+ last_name: model.lastName,
2120
+ metadata: model.metadata
2121
+ });
2122
+ //#endregion
2123
+ //#region src/connect/serializers/user-consent-option-choice.serializer.ts
2124
+ const serializeUserConsentOptionChoice = (model) => ({
2125
+ value: model.value,
2126
+ label: model.label
2127
+ });
2128
+ //#endregion
2129
+ //#region src/connect/serializers/user-consent-option.serializer.ts
2130
+ const serializeUserConsentOption = (model) => ({
2131
+ claim: model.claim,
2132
+ type: model.type,
2133
+ label: model.label,
2134
+ choices: model.choices.map(serializeUserConsentOptionChoice)
2135
+ });
2136
+ //#endregion
2137
+ //#region src/connect/serializers/user-management-login-request.serializer.ts
2138
+ const serializeUserManagementLoginRequest = (model) => ({
2139
+ external_auth_id: model.externalAuthId,
2140
+ user: serializeUserObject(model.user),
2141
+ user_consent_options: model.userConsentOptions != null ? model.userConsentOptions.map(serializeUserConsentOption) : void 0
2142
+ });
2143
+ //#endregion
2144
+ //#region src/connect/serializers/redirect-uri-input.serializer.ts
2145
+ const serializeRedirectUriInput = (model) => ({
2146
+ uri: model.uri,
2147
+ default: model.default ?? null
2148
+ });
2149
+ //#endregion
2150
+ //#region src/connect/serializers/create-oauth-application.serializer.ts
2151
+ const serializeCreateOAuthApplication = (model) => ({
2152
+ name: model.name,
2153
+ application_type: model.applicationType,
2154
+ description: model.description ?? null,
2155
+ scopes: model.scopes ?? null,
2156
+ redirect_uris: model.redirectUris != null ? model.redirectUris.map(serializeRedirectUriInput) : null,
2157
+ uses_pkce: model.usesPkce ?? null,
2158
+ is_first_party: model.isFirstParty,
2159
+ organization_id: model.organizationId ?? null
2160
+ });
2161
+ //#endregion
2162
+ //#region src/connect/serializers/create-m2m-application.serializer.ts
2163
+ const serializeCreateM2MApplication = (model) => ({
2164
+ name: model.name,
2165
+ application_type: model.applicationType,
2166
+ description: model.description ?? null,
2167
+ scopes: model.scopes ?? null,
2168
+ organization_id: model.organizationId
2169
+ });
2170
+ //#endregion
2171
+ //#region src/connect/serializers/update-oauth-application.serializer.ts
2172
+ const serializeUpdateOAuthApplication = (model) => ({
2173
+ name: model.name,
2174
+ description: model.description ?? null,
2175
+ scopes: model.scopes ?? null,
2176
+ redirect_uris: model.redirectUris != null ? model.redirectUris.map(serializeRedirectUriInput) : null
2177
+ });
2178
+ //#endregion
2179
+ //#region src/connect/serializers/create-application-secret.serializer.ts
2180
+ const serializeCreateApplicationSecret = (_model) => ({});
2181
+ //#endregion
2182
+ //#region src/connect/connect.ts
2183
+ const serializeListApplicationsOptions = (options) => {
2184
+ const wire = {
2185
+ limit: options.limit,
2186
+ before: options.before,
2187
+ after: options.after,
2188
+ order: options.order
2189
+ };
2190
+ if (options.organizationId !== void 0) wire.organization_id = options.organizationId;
2191
+ return wire;
2192
+ };
2193
+ var Connect = class {
2194
+ workos;
2195
+ constructor(workos) {
2196
+ this.workos = workos;
2197
+ }
2198
+ /**
2199
+ * Complete external authentication
2200
+ *
2201
+ * 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.
2202
+ *
2203
+ * After successfully authenticating a user in your application, calling this endpoint will:
2204
+ *
2205
+ * - Create or update the user in AuthKit, using the given `id` as its `external_id`.
2206
+ * - Return a `redirect_uri` your application should redirect to in order for AuthKit to complete the flow
2207
+ *
2208
+ * 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.
2209
+ *
2210
+ * 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.
2211
+ * @param options - Object containing externalAuthId, user.
2212
+ * @param options.externalAuthId - Identifier provided when AuthKit redirected to your login page.
2213
+ * @example "ext_auth_01HXYZ123456789ABCDEFGHIJ"
2214
+ * @param options.user - The user to create or update in AuthKit.
2215
+ * @param options.userConsentOptions - Array of [User Consent Options](https://workos.com/docs/reference/workos-connect/standalone/user-consent-options) to store with the session.
2216
+ * @returns {Promise<ExternalAuthCompleteResponse>}
2217
+ * @throws {BadRequestException} 400
2218
+ * @throws {NotFoundException} 404
2219
+ * @throws {UnprocessableEntityException} 422
2220
+ */
2221
+ async completeOAuth2(options) {
2222
+ const payload = options;
2223
+ const { data } = await this.workos.post("/authkit/oauth2/complete", serializeUserManagementLoginRequest(payload));
2224
+ return deserializeExternalAuthCompleteResponse(data);
2225
+ }
2226
+ /**
2227
+ * List Connect Applications
2228
+ *
2229
+ * List all Connect Applications in the current environment with optional filtering.
2230
+ * @param options - Pagination and filter options.
2231
+ * @returns {Promise<AutoPaginatable<ConnectApplication, ListApplicationsOptions>>}
2232
+ * @throws {UnprocessableEntityException} 422
2233
+ */
2234
+ async listApplications(options) {
2235
+ const paginationOptions = options;
2236
+ return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/connect/applications", deserializeConnectApplication, options ? serializeListApplicationsOptions(options) : void 0), (params) => fetchAndDeserialize(this.workos, "/connect/applications", deserializeConnectApplication, params), paginationOptions);
2237
+ }
2238
+ /**
2239
+ * Create a Connect Application
2240
+ *
2241
+ * Create a new Connect Application. Supports both OAuth and Machine-to-Machine (M2M) application types.
2242
+ * @param options - The request body.
2243
+ * @returns {Promise<ConnectApplication>}
2244
+ * @throws {NotFoundException} 404
2245
+ * @throws {UnprocessableEntityException} 422
2246
+ */
2247
+ async createApplication(options) {
2248
+ const payload = options;
2249
+ const { data } = await this.workos.post("/connect/applications", (() => {
2250
+ switch (payload.applicationType) {
2251
+ case "oauth": return serializeCreateOAuthApplication(payload);
2252
+ case "m2m": return serializeCreateM2MApplication(payload);
2253
+ default: throw new Error(`Unknown applicationType: ${payload.applicationType}`);
2254
+ }
2255
+ })());
2256
+ return deserializeConnectApplication(data);
2257
+ }
2258
+ /**
2259
+ * Create oauth application.
2260
+ * @param name - The name of the application.
2261
+ * @param isFirstParty - Whether this is a first-party application. Third-party applications require an organization_id.
2262
+ * @param description - A description for the application.
2263
+ * @param scopes - The OAuth scopes granted to the application.
2264
+ * @param redirectUris - Redirect URIs for the application.
2265
+ * @param usesPkce - Whether the application uses PKCE (Proof Key for Code Exchange).
2266
+ * @param organizationId - The organization ID this application belongs to. Required when is_first_party is false.
2267
+ * @returns {Promise<ConnectApplication>}
2268
+ */
2269
+ async createOAuthApplication(name, isFirstParty, description, scopes, redirectUris, usesPkce, organizationId) {
2270
+ const body = {
2271
+ application_type: "oauth",
2272
+ name,
2273
+ is_first_party: isFirstParty
2274
+ };
2275
+ if (description !== void 0) body.description = description;
2276
+ if (scopes !== void 0) body.scopes = scopes;
2277
+ if (redirectUris !== void 0) body.redirect_uris = redirectUris;
2278
+ if (usesPkce !== void 0) body.uses_pkce = usesPkce;
2279
+ if (organizationId !== void 0) body.organization_id = organizationId;
2280
+ const { data } = await this.workos.post("/connect/applications", body);
2281
+ return deserializeConnectApplication(data);
2282
+ }
2283
+ /**
2284
+ * Create m2m application.
2285
+ * @param name - The name of the application.
2286
+ * @param organizationId - The organization ID this application belongs to.
2287
+ * @param description - A description for the application.
2288
+ * @param scopes - The OAuth scopes granted to the application.
2289
+ * @returns {Promise<ConnectApplication>}
2290
+ */
2291
+ async createM2MApplication(name, organizationId, description, scopes) {
2292
+ const body = {
2293
+ application_type: "m2m",
2294
+ name,
2295
+ organization_id: organizationId
2296
+ };
2297
+ if (description !== void 0) body.description = description;
2298
+ if (scopes !== void 0) body.scopes = scopes;
2299
+ const { data } = await this.workos.post("/connect/applications", body);
2300
+ return deserializeConnectApplication(data);
2301
+ }
2302
+ /**
2303
+ * Get a Connect Application
2304
+ *
2305
+ * Retrieve details for a specific Connect Application by ID or client ID.
2306
+ * @param options - The request options.
2307
+ * @param options.id - The application ID or client ID of the Connect Application.
2308
+ * @example "conn_app_01HXYZ123456789ABCDEFGHIJ"
2309
+ * @returns {Promise<ConnectApplication>}
2310
+ * @throws {NotFoundException} 404
2311
+ */
2312
+ async getApplication(options) {
2313
+ const { id } = options;
2314
+ const { data } = await this.workos.get(`/connect/applications/${encodeURIComponent(id)}`);
2315
+ return deserializeConnectApplication(data);
2316
+ }
2317
+ /**
2318
+ * Update a Connect Application
2319
+ *
2320
+ * Update an existing Connect Application. For OAuth applications, you can update redirect URIs. For all applications, you can update the name, description, and scopes.
2321
+ * @param options - The request body.
2322
+ * @param options.id - The application ID or client ID of the Connect Application.
2323
+ * @example "conn_app_01HXYZ123456789ABCDEFGHIJ"
2324
+ * @param options.name - The name of the application.
2325
+ * @example "My Application"
2326
+ * @param options.description - A description for the application.
2327
+ * @example "An application for managing user access"
2328
+ * @param options.scopes - The OAuth scopes granted to the application.
2329
+ * @example ["openid","profile","email"]
2330
+ * @param options.redirectUris - Updated redirect URIs for the application. OAuth applications only.
2331
+ * @example [{"uri":"https://example.com/callback","default":true}]
2332
+ * @returns {Promise<ConnectApplication>}
2333
+ * @throws {NotFoundException} 404
2334
+ * @throws {UnprocessableEntityException} 422
2335
+ */
2336
+ async updateApplication(options) {
2337
+ const { id, ...payload } = options;
2338
+ const { data } = await this.workos.put(`/connect/applications/${encodeURIComponent(id)}`, serializeUpdateOAuthApplication(payload));
2339
+ return deserializeConnectApplication(data);
2340
+ }
2341
+ /**
2342
+ * Delete a Connect Application
2343
+ *
2344
+ * Delete an existing Connect Application.
2345
+ * @param options - The request options.
2346
+ * @param options.id - The application ID or client ID of the Connect Application.
2347
+ * @example "conn_app_01HXYZ123456789ABCDEFGHIJ"
2348
+ * @returns {Promise<void>}
2349
+ * @throws {NotFoundException} 404
2350
+ */
2351
+ async deleteApplication(options) {
2352
+ const { id } = options;
2353
+ await this.workos.delete(`/connect/applications/${encodeURIComponent(id)}`);
2354
+ }
2355
+ /**
2356
+ * List Client Secrets for a Connect Application
2357
+ *
2358
+ * List all client secrets associated with a Connect Application.
2359
+ * @param options - The request options.
2360
+ * @param options.id - The application ID or client ID of the Connect Application.
2361
+ * @example "conn_app_01HXYZ123456789ABCDEFGHIJ"
2362
+ * @returns {Promise<ApplicationCredentialsListItem[]>}
2363
+ * @throws {NotFoundException} 404
2364
+ */
2365
+ async listApplicationClientSecrets(options) {
2366
+ const { id } = options;
2367
+ const { data } = await this.workos.get(`/connect/applications/${encodeURIComponent(id)}/client_secrets`);
2368
+ return data.map(deserializeApplicationCredentialsListItem);
2369
+ }
2370
+ /**
2371
+ * Create a new client secret for a Connect Application
2372
+ *
2373
+ * Create new secrets for a Connect Application.
2374
+ * @param options - The request body.
2375
+ * @param options.id - The application ID or client ID of the Connect Application.
2376
+ * @example "conn_app_01HXYZ123456789ABCDEFGHIJ"
2377
+ * @returns {Promise<NewConnectApplicationSecret>}
2378
+ * @throws {NotFoundException} 404
2379
+ * @throws {UnprocessableEntityException} 422
2380
+ */
2381
+ async createApplicationClientSecret(options) {
2382
+ const { id, ...payload } = options;
2383
+ const { data } = await this.workos.post(`/connect/applications/${encodeURIComponent(id)}/client_secrets`, serializeCreateApplicationSecret(payload));
2384
+ return deserializeNewConnectApplicationSecret(data);
2385
+ }
2386
+ /**
2387
+ * Delete a Client Secret
2388
+ *
2389
+ * Delete (revoke) an existing client secret.
2390
+ * @param options - The request options.
2391
+ * @param options.id - The unique ID of the client secret.
2392
+ * @example "secret_01J9Q2Z3X4Y5W6V7U8T9S0R1Q"
2393
+ * @returns {Promise<void>}
2394
+ * @throws {NotFoundException} 404
2395
+ */
2396
+ async deleteClientSecret(options) {
2397
+ const { id } = options;
2398
+ await this.workos.delete(`/connect/client_secrets/${encodeURIComponent(id)}`);
2399
+ }
2400
+ };
2401
+ //#endregion
1953
2402
  //#region src/directory-sync/directory-sync.ts
1954
2403
  var DirectorySync = class {
1955
2404
  workos;
@@ -2321,15 +2770,136 @@ function deserializeGetAccessTokenResponse(response) {
2321
2770
  };
2322
2771
  }
2323
2772
  //#endregion
2324
- //#region src/pipes/pipes.ts
2325
- var Pipes = class {
2773
+ //#region src/pipes/pipes.ts
2774
+ var Pipes = class {
2775
+ workos;
2776
+ constructor(workos) {
2777
+ this.workos = workos;
2778
+ }
2779
+ async getAccessToken({ provider, ...options }) {
2780
+ const { data } = await this.workos.post(`data-integrations/${provider}/token`, serializeGetAccessTokenOptions(options));
2781
+ return deserializeGetAccessTokenResponse(data);
2782
+ }
2783
+ };
2784
+ //#endregion
2785
+ //#region src/radar/serializers/radar-standalone-response.serializer.ts
2786
+ const deserializeRadarStandaloneResponse = (response) => ({
2787
+ verdict: response.verdict,
2788
+ reason: response.reason,
2789
+ attemptId: response.attempt_id,
2790
+ control: response.control,
2791
+ blocklistType: response.blocklist_type
2792
+ });
2793
+ //#endregion
2794
+ //#region src/radar/serializers/radar-list-entry-already-present-response.serializer.ts
2795
+ const deserializeRadarListEntryAlreadyPresentResponse = (response) => ({ message: response.message });
2796
+ //#endregion
2797
+ //#region src/radar/serializers/radar-standalone-assess-request.serializer.ts
2798
+ const serializeRadarStandaloneAssessRequest = (model) => ({
2799
+ ip_address: model.ipAddress,
2800
+ user_agent: model.userAgent,
2801
+ email: model.email,
2802
+ auth_method: model.authMethod,
2803
+ action: model.action
2804
+ });
2805
+ //#endregion
2806
+ //#region src/radar/serializers/radar-standalone-update-radar-attempt-request.serializer.ts
2807
+ const serializeRadarStandaloneUpdateRadarAttemptRequest = (model) => ({
2808
+ challenge_status: model.challengeStatus,
2809
+ attempt_status: model.attemptStatus
2810
+ });
2811
+ //#endregion
2812
+ //#region src/radar/serializers/radar-standalone-update-radar-list-request.serializer.ts
2813
+ const serializeRadarStandaloneUpdateRadarListRequest = (model) => ({ entry: model.entry });
2814
+ //#endregion
2815
+ //#region src/radar/serializers/radar-standalone-delete-radar-list-entry-request.serializer.ts
2816
+ const serializeRadarStandaloneDeleteRadarListEntryRequest = (model) => ({ entry: model.entry });
2817
+ //#endregion
2818
+ //#region src/radar/radar.ts
2819
+ var Radar = class {
2326
2820
  workos;
2327
2821
  constructor(workos) {
2328
2822
  this.workos = workos;
2329
2823
  }
2330
- async getAccessToken({ provider, ...options }) {
2331
- const { data } = await this.workos.post(`data-integrations/${provider}/token`, serializeGetAccessTokenOptions(options));
2332
- return deserializeGetAccessTokenResponse(data);
2824
+ /**
2825
+ * Create an attempt
2826
+ *
2827
+ * Assess a request for risk using the Radar engine and receive a verdict.
2828
+ * @param options - Object containing ipAddress, userAgent, email, authMethod, action.
2829
+ * @param options.ipAddress - The IP address of the request to assess.
2830
+ * @example "49.78.240.97"
2831
+ * @param options.userAgent - The user agent string of the request to assess.
2832
+ * @example "Mozilla/5.0"
2833
+ * @param options.email - The email address of the user making the request.
2834
+ * @example "user@example.com"
2835
+ * @param options.authMethod - The authentication method being used.
2836
+ * @example "Password"
2837
+ * @param options.action - The action being performed.
2838
+ * @example "sign-in"
2839
+ * @returns {Promise<RadarStandaloneResponse>}
2840
+ * @throws {BadRequestException} 400
2841
+ */
2842
+ async createAttempt(options) {
2843
+ const payload = options;
2844
+ const { data } = await this.workos.post("/radar/attempts", serializeRadarStandaloneAssessRequest(payload));
2845
+ return deserializeRadarStandaloneResponse(data);
2846
+ }
2847
+ /**
2848
+ * Update a Radar attempt
2849
+ *
2850
+ * 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.
2851
+ * @param options - The request body.
2852
+ * @param options.id - The unique identifier of the Radar attempt to update.
2853
+ * @example "radar_att_01HZBC6N1EB1ZY7KG32X"
2854
+ * @param options.challengeStatus - Set to `"success"` to mark the challenge as completed.
2855
+ * @example "success"
2856
+ * @param options.attemptStatus - Set to `"success"` to mark the authentication attempt as successful.
2857
+ * @example "success"
2858
+ * @returns {Promise<void>}
2859
+ * @throws {BadRequestException} 400
2860
+ * @throws {NotFoundException} 404
2861
+ */
2862
+ async updateAttempt(options) {
2863
+ const { id, ...payload } = options;
2864
+ await this.workos.put(`/radar/attempts/${encodeURIComponent(id)}`, serializeRadarStandaloneUpdateRadarAttemptRequest(payload));
2865
+ }
2866
+ /**
2867
+ * Add an entry to a Radar list
2868
+ *
2869
+ * Add an entry to a Radar list.
2870
+ * @param options - Object containing entry.
2871
+ * @param options.type - The type of the Radar list (e.g. ip_address, domain, email).
2872
+ * @example "ip_address"
2873
+ * @param options.action - The list action indicating whether to add the entry to the allow or block list.
2874
+ * @example "block"
2875
+ * @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`).
2876
+ * @example "198.51.100.42"
2877
+ * @returns {Promise<RadarListEntryAlreadyPresentResponse>}
2878
+ * @throws {BadRequestException} 400
2879
+ */
2880
+ async addListEntry(options) {
2881
+ const { type, action, ...payload } = options;
2882
+ const { data } = await this.workos.post(`/radar/lists/${encodeURIComponent(type)}/${encodeURIComponent(action)}`, serializeRadarStandaloneUpdateRadarListRequest(payload));
2883
+ return deserializeRadarListEntryAlreadyPresentResponse(data);
2884
+ }
2885
+ /**
2886
+ * Remove an entry from a Radar list
2887
+ *
2888
+ * Remove an entry from a Radar list.
2889
+ * @param options - Object containing entry.
2890
+ * @param options.type - The type of the Radar list (e.g. ip_address, domain, email).
2891
+ * @example "ip_address"
2892
+ * @param options.action - The list action indicating whether to remove the entry from the allow or block list.
2893
+ * @example "block"
2894
+ * @param options.entry - The value to remove from the list. Must match an existing entry.
2895
+ * @example "198.51.100.42"
2896
+ * @returns {Promise<void>}
2897
+ * @throws {BadRequestException} 400
2898
+ * @throws {NotFoundException} 404
2899
+ */
2900
+ async removeListEntry(options) {
2901
+ const { type, action, ...payload } = options;
2902
+ await this.workos.deleteWithBody(`/radar/lists/${encodeURIComponent(type)}/${encodeURIComponent(action)}`, serializeRadarStandaloneDeleteRadarListEntryRequest(payload));
2333
2903
  }
2334
2904
  };
2335
2905
  //#endregion
@@ -3421,13 +3991,13 @@ var CookieSession = class {
3421
3991
  authenticated: false,
3422
3992
  reason: "invalid_session_cookie"
3423
3993
  };
3424
- const { org_id: organizationIdFromAccessToken } = decodeJwt(session.accessToken);
3994
+ const { org_id: organizationIdFromUserManagementAccessToken } = decodeJwt(session.accessToken);
3425
3995
  try {
3426
3996
  const cookiePassword = options.cookiePassword ?? this.cookiePassword;
3427
3997
  const authenticationResponse = await this.userManagement.authenticateWithRefreshToken({
3428
3998
  clientId: this.userManagement.clientId,
3429
3999
  refreshToken: session.refreshToken,
3430
- organizationId: options.organizationId ?? organizationIdFromAccessToken,
4000
+ organizationId: options.organizationId ?? organizationIdFromUserManagementAccessToken,
3431
4001
  session: {
3432
4002
  sealSession: true,
3433
4003
  cookiePassword
@@ -4618,42 +5188,160 @@ var Groups = class {
4618
5188
  constructor(workos) {
4619
5189
  this.workos = workos;
4620
5190
  }
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);
5191
+ /**
5192
+ * List Group members
5193
+ *
5194
+ * Get a list of organization memberships in a group.
5195
+ * @param options - Pagination and filter options.
5196
+ * @param options.organizationId - Unique identifier of the Organization.
5197
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5198
+ * @param options.groupId - Unique identifier of the Group.
5199
+ * @example "group_01HXYZ123456789ABCDEFGHIJ"
5200
+ * @returns {Promise<AutoPaginatable<AuthorizationOrganizationMembership>>}
5201
+ * @throws {AuthorizationException} 403
5202
+ * @throws {NotFoundException} 404
5203
+ */
5204
+ async listOrganizationMemberships(options) {
5205
+ const { organizationId, groupId, ...paginationOptions } = options;
5206
+ const endpoint = `/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}/organization-memberships`;
5207
+ return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, paginationOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, params), paginationOptions);
4625
5208
  }
5209
+ /**
5210
+ * List groups
5211
+ *
5212
+ * Get a paginated list of groups within an organization.
5213
+ * @param options - Pagination and filter options.
5214
+ * @param options.organizationId - The ID of the organization.
5215
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5216
+ * @returns {Promise<AutoPaginatable<Group, PaginationOptions>>}
5217
+ * @throws {AuthorizationException} 403
5218
+ * @throws {NotFoundException} 404
5219
+ */
4626
5220
  async listGroups(options) {
4627
5221
  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);
5222
+ return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/organizations/${encodeURIComponent(organizationId)}/groups`, deserializeGroup, paginationOptions), (params) => fetchAndDeserialize(this.workos, `/organizations/${encodeURIComponent(organizationId)}/groups`, deserializeGroup, params), paginationOptions);
5223
+ }
5224
+ /**
5225
+ * Create a group
5226
+ *
5227
+ * Create a new group within an organization.
5228
+ * @param options - Object containing name.
5229
+ * @param options.organizationId - The ID of the organization.
5230
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5231
+ * @param options.name - The name of the Group.
5232
+ * @example "Engineering"
5233
+ * @param options.description - An optional description of the Group.
5234
+ * @example "The engineering team"
5235
+ * @returns {Promise<Group>}
5236
+ * @throws {BadRequestException} 400
5237
+ * @throws {AuthorizationException} 403
5238
+ * @throws {NotFoundException} 404
5239
+ * @throws {UnprocessableEntityException} 422
5240
+ */
5241
+ async createGroup(options) {
5242
+ const { organizationId, ...payload } = options;
5243
+ const { data } = await this.workos.post(`/organizations/${encodeURIComponent(organizationId)}/groups`, serializeCreateGroup(payload));
5244
+ return deserializeGroup(data);
4629
5245
  }
5246
+ /**
5247
+ * Get a group
5248
+ *
5249
+ * Retrieve a group by its ID within an organization.
5250
+ * @param options - The request options.
5251
+ * @param options.organizationId - The ID of the organization.
5252
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5253
+ * @param options.groupId - The ID of the group.
5254
+ * @example "group_01HXYZ123456789ABCDEFGHIJ"
5255
+ * @returns {Promise<Group>}
5256
+ * @throws {AuthorizationException} 403
5257
+ * @throws {NotFoundException} 404
5258
+ */
4630
5259
  async getGroup(options) {
4631
5260
  const { organizationId, groupId } = options;
4632
- const { data } = await this.workos.get(`/organizations/${organizationId}/groups/${groupId}`);
5261
+ const { data } = await this.workos.get(`/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}`);
4633
5262
  return deserializeGroup(data);
4634
5263
  }
5264
+ /**
5265
+ * Update a group
5266
+ *
5267
+ * Update an existing group. Only the fields provided in the request body will be updated.
5268
+ * @param options - The request body.
5269
+ * @param options.organizationId - The ID of the organization.
5270
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5271
+ * @param options.groupId - The ID of the group.
5272
+ * @example "group_01HXYZ123456789ABCDEFGHIJ"
5273
+ * @param options.name - The name of the Group.
5274
+ * @example "Engineering"
5275
+ * @param options.description - An optional description of the Group.
5276
+ * @example "The engineering team"
5277
+ * @returns {Promise<Group>}
5278
+ * @throws {BadRequestException} 400
5279
+ * @throws {AuthorizationException} 403
5280
+ * @throws {NotFoundException} 404
5281
+ * @throws {UnprocessableEntityException} 422
5282
+ */
4635
5283
  async updateGroup(options) {
4636
5284
  const { organizationId, groupId, ...payload } = options;
4637
- const { data } = await this.workos.patch(`/organizations/${organizationId}/groups/${groupId}`, serializeUpdateGroupOptions(payload));
5285
+ const { data } = await this.workos.patch(`/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}`, serializeUpdateGroup(payload));
4638
5286
  return deserializeGroup(data);
4639
5287
  }
5288
+ /**
5289
+ * Delete a group
5290
+ *
5291
+ * Delete a group from an organization.
5292
+ * @param options - The request options.
5293
+ * @param options.organizationId - The ID of the organization.
5294
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5295
+ * @param options.groupId - The ID of the group.
5296
+ * @example "group_01HXYZ123456789ABCDEFGHIJ"
5297
+ * @returns {Promise<void>}
5298
+ * @throws {AuthorizationException} 403
5299
+ * @throws {NotFoundException} 404
5300
+ */
4640
5301
  async deleteGroup(options) {
4641
5302
  const { organizationId, groupId } = options;
4642
- await this.workos.delete(`/organizations/${organizationId}/groups/${groupId}`);
5303
+ await this.workos.delete(`/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}`);
4643
5304
  }
5305
+ /**
5306
+ * Add a member to a Group
5307
+ *
5308
+ * Add an organization membership to a group.
5309
+ * @param options - Object containing organizationMembershipId.
5310
+ * @param options.organizationId - Unique identifier of the Organization.
5311
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5312
+ * @param options.groupId - Unique identifier of the Group.
5313
+ * @example "group_01HXYZ123456789ABCDEFGHIJ"
5314
+ * @param options.organizationMembershipId - The ID of the Organization Membership to add to the group.
5315
+ * @example "om_01HXYZ123456789ABCDEFGHIJ"
5316
+ * @returns {Promise<Group>}
5317
+ * @throws {BadRequestException} 400
5318
+ * @throws {AuthorizationException} 403
5319
+ * @throws {NotFoundException} 404
5320
+ * @throws {UnprocessableEntityException} 422
5321
+ */
4644
5322
  async addOrganizationMembership(options) {
4645
5323
  const { organizationId, groupId, ...payload } = options;
4646
- const { data } = await this.workos.post(`/organizations/${organizationId}/groups/${groupId}/organization-memberships`, serializeAddGroupOrganizationMembershipOptions(payload));
5324
+ const { data } = await this.workos.post(`/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}/organization-memberships`, serializeCreateGroupMembership(payload));
4647
5325
  return deserializeGroup(data);
4648
5326
  }
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
- }
5327
+ /**
5328
+ * Remove a member from a Group
5329
+ *
5330
+ * Remove an organization membership from a group.
5331
+ * @param options - The request options.
5332
+ * @param options.organizationId - Unique identifier of the Organization.
5333
+ * @example "org_01EHWNCE74X7JSDV0X3SZ3KJNY"
5334
+ * @param options.groupId - Unique identifier of the Group.
5335
+ * @example "group_01HXYZ123456789ABCDEFGHIJ"
5336
+ * @param options.omId - Unique identifier of the Organization Membership.
5337
+ * @example "om_01HXYZ123456789ABCDEFGHIJ"
5338
+ * @returns {Promise<void>}
5339
+ * @throws {AuthorizationException} 403
5340
+ * @throws {NotFoundException} 404
5341
+ */
4654
5342
  async removeOrganizationMembership(options) {
4655
5343
  const { organizationId, groupId, organizationMembershipId } = options;
4656
- await this.workos.delete(`/organizations/${organizationId}/groups/${groupId}/organization-memberships/${organizationMembershipId}`);
5344
+ await this.workos.delete(`/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}/organization-memberships/${encodeURIComponent(organizationMembershipId)}`);
4657
5345
  }
4658
5346
  };
4659
5347
  //#endregion
@@ -4790,7 +5478,6 @@ const serializeListAuthorizationResourcesOptions = (options) => ({
4790
5478
  ...options.parentResourceId && { parent_resource_id: options.parentResourceId },
4791
5479
  ...options.parentResourceTypeSlug && { parent_resource_type_slug: options.parentResourceTypeSlug },
4792
5480
  ...options.parentExternalId && { parent_external_id: options.parentExternalId },
4793
- ...options.search && { search: options.search },
4794
5481
  ...serializePaginationOptions(options)
4795
5482
  });
4796
5483
  //#endregion
@@ -5738,6 +6425,105 @@ function hasContinuationBit(byte) {
5738
6425
  return (byte & CONTINUATION_BIT) !== 0;
5739
6426
  }
5740
6427
  //#endregion
6428
+ //#region src/vault/serializers/create-data-key-response.serializer.ts
6429
+ const deserializeCreateDataKeyResponse = (response) => ({
6430
+ context: response.context,
6431
+ dataKey: response.data_key,
6432
+ encryptedKeys: response.encrypted_keys,
6433
+ id: response.id
6434
+ });
6435
+ //#endregion
6436
+ //#region src/vault/serializers/decrypt-response.serializer.ts
6437
+ const deserializeDecryptResponse = (response) => ({
6438
+ dataKey: response.data_key,
6439
+ id: response.id
6440
+ });
6441
+ //#endregion
6442
+ //#region src/vault/serializers/actor.serializer.ts
6443
+ const deserializeActor = (response) => ({
6444
+ id: response.id,
6445
+ name: response.name
6446
+ });
6447
+ //#endregion
6448
+ //#region src/vault/serializers/object-metadata.serializer.ts
6449
+ const deserializeObjectMetadata = (response) => ({
6450
+ context: response.context,
6451
+ environmentId: response.environment_id,
6452
+ id: response.id,
6453
+ keyId: response.key_id,
6454
+ updatedAt: new Date(response.updated_at),
6455
+ updatedBy: deserializeActor(response.updated_by),
6456
+ versionId: response.version_id ?? null
6457
+ });
6458
+ //#endregion
6459
+ //#region src/vault/serializers/vault-object.serializer.ts
6460
+ const deserializeVaultObject = (response) => ({
6461
+ id: response.id,
6462
+ metadata: deserializeObjectMetadata(response.metadata),
6463
+ name: response.name,
6464
+ value: response.value
6465
+ });
6466
+ //#endregion
6467
+ //#region src/vault/serializers/object-without-value.serializer.ts
6468
+ const deserializeObjectWithoutValue = (response) => ({
6469
+ id: response.id,
6470
+ metadata: deserializeObjectMetadata(response.metadata),
6471
+ name: response.name
6472
+ });
6473
+ //#endregion
6474
+ //#region src/vault/serializers/object-version.serializer.ts
6475
+ const deserializeObjectVersion = (response) => ({
6476
+ createdAt: new Date(response.created_at),
6477
+ currentVersion: response.current_version,
6478
+ etag: response.etag ?? "",
6479
+ id: response.id,
6480
+ size: response.size ?? 0
6481
+ });
6482
+ //#endregion
6483
+ //#region src/vault/serializers/list-metadata.serializer.ts
6484
+ const deserializeListMetadata = (response) => ({
6485
+ after: response.after ?? null,
6486
+ before: response.before ?? null
6487
+ });
6488
+ //#endregion
6489
+ //#region src/vault/serializers/version-list-response.serializer.ts
6490
+ const deserializeVersionListResponse = (response) => ({
6491
+ data: response.data.map(deserializeObjectVersion),
6492
+ listMetadata: deserializeListMetadata(response.list_metadata)
6493
+ });
6494
+ //#endregion
6495
+ //#region src/vault/serializers/object-summary.serializer.ts
6496
+ const deserializeObjectSummary = (response) => ({
6497
+ id: response.id,
6498
+ name: response.name,
6499
+ updatedAt: response.updated_at != null ? new Date(response.updated_at) : null
6500
+ });
6501
+ //#endregion
6502
+ //#region src/vault/serializers/create-data-key-request.serializer.ts
6503
+ const serializeCreateDataKeyRequest = (model) => ({ context: model.context });
6504
+ //#endregion
6505
+ //#region src/vault/serializers/decrypt-request.serializer.ts
6506
+ const serializeDecryptRequest = (model) => ({ keys: model.keys });
6507
+ //#endregion
6508
+ //#region src/vault/serializers/rekey-request.serializer.ts
6509
+ const serializeRekeyRequest = (model) => ({
6510
+ context: model.context,
6511
+ encrypted_keys: model.encryptedKeys
6512
+ });
6513
+ //#endregion
6514
+ //#region src/vault/serializers/create-object-request.serializer.ts
6515
+ const serializeCreateObjectRequest = (model) => ({
6516
+ key_context: model.keyContext,
6517
+ name: model.name,
6518
+ value: model.value
6519
+ });
6520
+ //#endregion
6521
+ //#region src/vault/serializers/update-object-request.serializer.ts
6522
+ const serializeUpdateObjectRequest = (model) => ({
6523
+ value: model.value,
6524
+ version_check: model.versionCheck ?? null
6525
+ });
6526
+ //#endregion
5741
6527
  //#region src/common/utils/base64.ts
5742
6528
  /**
5743
6529
  * Cross-runtime compatible base64 encoding/decoding utilities
@@ -5767,128 +6553,235 @@ function uint8ArrayToBase64(bytes) {
5767
6553
  else throw new Error("No base64 encoding implementation available");
5768
6554
  }
5769
6555
  //#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
6556
  //#region src/vault/vault.ts
6557
+ const serializeListObjectsOptions = (options) => {
6558
+ const wire = {
6559
+ limit: options.limit,
6560
+ before: options.before,
6561
+ after: options.after,
6562
+ order: options.order
6563
+ };
6564
+ if (options.search !== void 0) wire.search = options.search;
6565
+ if (options.updatedAfter !== void 0) wire.updated_after = options.updatedAfter;
6566
+ return wire;
6567
+ };
5830
6568
  var Vault = class {
5831
6569
  workos;
5832
- cryptoProvider;
5833
6570
  constructor(workos) {
5834
6571
  this.workos = workos;
5835
- this.cryptoProvider = workos.getCryptoProvider();
5836
6572
  }
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);
6573
+ async readObjectByName(options) {
6574
+ const name = typeof options === "string" ? options : options.name;
6575
+ const { data } = await this.workos.get(`/vault/v1/kv/name/${encodeURIComponent(name)}`);
6576
+ return deserializeVaultObject(data);
6577
+ }
6578
+ /**
6579
+ * Create a data key
6580
+ *
6581
+ * Generate an isolated encryption key for local encryption operations.
6582
+ * @param options - Object containing context.
6583
+ * @param options.context - Map of values used to determine the encryption key.
6584
+ * @example {"organization_id":"org_01K8ZYT4AWJ6XP0E0S8CTBHE3P"}
6585
+ * @returns {Promise<DataKeyPair>}
6586
+ * @throws {BadRequestException} 400
6587
+ * @throws {UnprocessableEntityException} 422
6588
+ */
6589
+ async createDataKey(options) {
6590
+ const payload = options;
6591
+ const { data } = await this.workos.post("/vault/v1/keys/data-key", serializeCreateDataKeyRequest(payload));
6592
+ const result = deserializeCreateDataKeyResponse(data);
5842
6593
  return {
5843
- iv,
5844
- tag,
5845
- keys: uint8ArrayToBase64(inputData.subarray(nextIndex, nextIndex + keyLen)),
5846
- ciphertext: new Uint8Array(inputData.subarray(nextIndex + keyLen))
6594
+ context: result.context,
6595
+ dataKey: {
6596
+ key: result.dataKey,
6597
+ id: result.id
6598
+ },
6599
+ encryptedKeys: result.encryptedKeys
5847
6600
  };
5848
6601
  }
5849
- async createObject(options) {
5850
- const { data } = await this.workos.post(`/vault/v1/kv`, serializeCreateObjectEntity(options));
5851
- return deserializeObjectMetadata(data);
6602
+ /**
6603
+ * Decrypt a data key
6604
+ *
6605
+ * Decrypt a previously encrypted data key from WorkOS Vault.
6606
+ * @param options - Object containing keys.
6607
+ * @param options.keys - Base64-encoded encrypted data key to decrypt.
6608
+ * @example "V09TLkVLTS52MQBiZjUxY2NlYy03OGI0LTUyMDAtYjM4My0zNTczMGU3MWVmNjEBATEBJGJmNjVlMzI2LTQzYTAtNGIyMC04OGM0LTA3ZmYzZGU1NDM0YwF0YmY2NWUzMjYtNDNhMC00YjIwLTg4YzQtMDdmZjNkZTU0MzRj"
6609
+ * @returns {Promise<DataKey>}
6610
+ * @throws {BadRequestException} 400
6611
+ */
6612
+ async decryptDataKey(options) {
6613
+ const payload = options;
6614
+ const { data } = await this.workos.post("/vault/v1/keys/decrypt", serializeDecryptRequest(payload));
6615
+ const result = deserializeDecryptResponse(data);
6616
+ return {
6617
+ key: result.dataKey,
6618
+ id: result.id
6619
+ };
6620
+ }
6621
+ /**
6622
+ * Re-encrypt a data key
6623
+ *
6624
+ * Decrypt an existing data key and re-encrypt it under a new key context.
6625
+ * @param options - Object containing context, encryptedKeys.
6626
+ * @param options.context - Map of values used to determine the new encryption key.
6627
+ * @example {"organization_id":"org_01K8ZYT4AWJ6XP0E0S8CTBHE3P"}
6628
+ * @param options.encryptedKeys - Base64-encoded encrypted data key blob to re-encrypt.
6629
+ * @example "V09TLkVLTS52MQBiZjUxY2NlYy03OGI0LTUyMDAtYjM4My0zNTczMGU3MWVmNjEBATEBJGJmNjVlMzI2LTQzYTAtNGIyMC04OGM0LTA3ZmYzZGU1NDM0YwF0YmY2NWUzMjYtNDNhMC00YjIwLTg4YzQtMDdmZjNkZTU0MzRj"
6630
+ * @returns {Promise<CreateDataKeyResponse>}
6631
+ * @throws {BadRequestException} 400
6632
+ * @throws {UnprocessableEntityException} 422
6633
+ */
6634
+ async createRekey(options) {
6635
+ const payload = options;
6636
+ const { data } = await this.workos.post("/vault/v1/keys/rekey", serializeRekeyRequest(payload));
6637
+ return deserializeCreateDataKeyResponse(data);
5852
6638
  }
6639
+ /**
6640
+ * List objects
6641
+ *
6642
+ * List all encrypted objects with cursor-based pagination.
6643
+ * @param options - Pagination and filter options.
6644
+ * @returns {Promise<AutoPaginatable<ObjectSummary, PaginationOptions>>}
6645
+ * @throws {BadRequestException} 400
6646
+ */
5853
6647
  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);
6648
+ const paginationOptions = options;
6649
+ 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
6650
  }
5862
- async listObjectVersions(options) {
5863
- const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(options.id)}/versions`);
5864
- return desrializeListObjectVersions(data);
6651
+ /**
6652
+ * Create an object
6653
+ *
6654
+ * Encrypt and store a new key-value object.
6655
+ * @param options - Object containing keyContext, name, value.
6656
+ * @param options.keyContext - Map of values used to determine the encryption key.
6657
+ * @example {"organization_id":"org_01K8ZYT4AWJ6XP0E0S8CTBHE3P"}
6658
+ * @param options.name - Unique name for the object.
6659
+ * @example "my-secret"
6660
+ * @param options.value - Plaintext data to encrypt and store.
6661
+ * @example "s3cr3t-v4lu3"
6662
+ * @returns {Promise<ObjectMetadata>}
6663
+ * @throws {BadRequestException} 400
6664
+ * @throws {ConflictException} 409
6665
+ * @throws {UnprocessableEntityException} 422
6666
+ */
6667
+ async createObject(options) {
6668
+ const payload = options;
6669
+ const requestPayload = {
6670
+ ...payload,
6671
+ keyContext: payload.context
6672
+ };
6673
+ const { data } = await this.workos.post("/vault/v1/kv", serializeCreateObjectRequest(requestPayload));
6674
+ return deserializeObjectMetadata(data);
5865
6675
  }
6676
+ /**
6677
+ * Read an object by ID
6678
+ *
6679
+ * Fetch and decrypt an object by its unique identifier.
6680
+ * @param options - The request options.
6681
+ * @param options.id - Unique identifier of the object.
6682
+ * @example "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
6683
+ * @returns {Promise<VaultObject>}
6684
+ * @throws {BadRequestException} 400
6685
+ * @throws {NotFoundException} 404
6686
+ */
5866
6687
  async readObject(options) {
5867
- const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(options.id)}`);
5868
- return deserializeObject(data);
6688
+ const { id } = options;
6689
+ const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(id)}`);
6690
+ return deserializeVaultObject(data);
6691
+ }
6692
+ /**
6693
+ * Update an object
6694
+ *
6695
+ * Update the value of an existing encrypted object.
6696
+ * @param options - Object containing value.
6697
+ * @param options.id - Unique identifier of the object.
6698
+ * @example "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
6699
+ * @param options.value - New plaintext value.
6700
+ * @example "upd4t3d-v4lu3"
6701
+ * @param options.versionCheck - ID of the expected current version for optimistic locking.
6702
+ * @example "c3d4e5f6-7890-abcd-ef12-34567890abcd"
6703
+ * @returns {Promise<VaultObject>}
6704
+ * @throws {BadRequestException} 400
6705
+ * @throws {ConflictException} 409
6706
+ */
6707
+ async updateObject(options) {
6708
+ const { id, ...payload } = options;
6709
+ const { data } = await this.workos.put(`/vault/v1/kv/${encodeURIComponent(id)}`, serializeUpdateObjectRequest(payload));
6710
+ return {
6711
+ ...deserializeObjectWithoutValue(data),
6712
+ value: void 0
6713
+ };
5869
6714
  }
5870
- async readObjectByName(name) {
5871
- const { data } = await this.workos.get(`/vault/v1/kv/name/${encodeURIComponent(name)}`);
5872
- return deserializeObject(data);
6715
+ /**
6716
+ * Delete an object
6717
+ *
6718
+ * Delete an encrypted object.
6719
+ * @param options - Additional query options.
6720
+ * @param options.id - Unique identifier of the object.
6721
+ * @example "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
6722
+ * @param options.versionCheck - Expected current version for optimistic locking.
6723
+ * @example "c3d4e5f6-7890-abcd-ef12-34567890abcd"
6724
+ * @returns {Promise<void>}
6725
+ * @throws {NotFoundException} 404
6726
+ * @throws {ConflictException} 409
6727
+ */
6728
+ async deleteObject(options) {
6729
+ const { id } = options;
6730
+ await this.workos.delete(`/vault/v1/kv/${encodeURIComponent(id)}`, { query: { ...options.versionCheck !== void 0 && { version_check: options.versionCheck } } });
5873
6731
  }
6732
+ /**
6733
+ * Describe an object
6734
+ *
6735
+ * Fetch metadata for an object without decrypting it.
6736
+ * @param options - The request options.
6737
+ * @param options.id - Unique identifier of the object.
6738
+ * @example "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
6739
+ * @returns {Promise<VaultObject>}
6740
+ * @throws {BadRequestException} 400
6741
+ * @throws {NotFoundException} 404
6742
+ */
5874
6743
  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);
6744
+ const { id } = options;
6745
+ const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(id)}/metadata`);
6746
+ return {
6747
+ ...deserializeObjectWithoutValue(data),
6748
+ value: void 0
6749
+ };
5881
6750
  }
5882
- async deleteObject(options) {
5883
- return this.workos.delete(`/vault/v1/kv/${encodeURIComponent(options.id)}`);
6751
+ /**
6752
+ * List object versions
6753
+ *
6754
+ * Retrieve all versions for a specific object.
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<ObjectVersion[]>}
6759
+ * @throws {BadRequestException} 400
6760
+ * @throws {NotFoundException} 404
6761
+ */
6762
+ async listObjectVersions(options) {
6763
+ const { id } = options;
6764
+ const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(id)}/versions`);
6765
+ return deserializeVersionListResponse(data).data;
5884
6766
  }
5885
- async createDataKey(options) {
5886
- const { data } = await this.workos.post(`/vault/v1/keys/data-key`, options);
5887
- return deserializeCreateDataKeyResponse(data);
6767
+ decode(payload) {
6768
+ const inputData = base64ToUint8Array(payload);
6769
+ const iv = new Uint8Array(inputData.subarray(0, 12));
6770
+ const tag = new Uint8Array(inputData.subarray(12, 28));
6771
+ const { value: keyLen, nextIndex } = decodeUInt32(inputData, 28);
6772
+ return {
6773
+ iv,
6774
+ tag,
6775
+ keys: uint8ArrayToBase64(inputData.subarray(nextIndex, nextIndex + keyLen)),
6776
+ ciphertext: new Uint8Array(inputData.subarray(nextIndex + keyLen))
6777
+ };
5888
6778
  }
5889
- async decryptDataKey(options) {
5890
- const { data } = await this.workos.post(`/vault/v1/keys/decrypt`, options);
5891
- return deserializeDecryptDataKeyResponse(data);
6779
+ async decrypt(encryptedData, associatedData) {
6780
+ const decoded = this.decode(encryptedData);
6781
+ const key = base64ToUint8Array((await this.decryptDataKey({ keys: decoded.keys })).key);
6782
+ const aadBuffer = associatedData ? new TextEncoder().encode(associatedData) : void 0;
6783
+ const decrypted = await this.workos.getCryptoProvider().decrypt(decoded.ciphertext, key, decoded.iv, decoded.tag, aadBuffer);
6784
+ return new TextDecoder().decode(decrypted);
5892
6785
  }
5893
6786
  async encrypt(data, context, associatedData) {
5894
6787
  const keyPair = await this.createDataKey({ context });
@@ -5897,8 +6790,9 @@ var Vault = class {
5897
6790
  const keyBlob = base64ToUint8Array(keyPair.encryptedKeys);
5898
6791
  const prefixLenBuffer = encodeUInt32(keyBlob.length);
5899
6792
  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);
6793
+ const cryptoProvider = this.workos.getCryptoProvider();
6794
+ const iv = cryptoProvider.randomBytes(12);
6795
+ const { ciphertext, iv: resultIv, tag } = await cryptoProvider.encrypt(encoder.encode(data), key, iv, aadBuffer);
5902
6796
  const resultArray = new Uint8Array(resultIv.length + tag.length + prefixLenBuffer.length + keyBlob.length + ciphertext.length);
5903
6797
  let offset = 0;
5904
6798
  resultArray.set(resultIv, offset);
@@ -5912,18 +6806,10 @@ var Vault = class {
5912
6806
  resultArray.set(ciphertext, offset);
5913
6807
  return uint8ArrayToBase64(resultArray);
5914
6808
  }
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
6809
  };
5924
6810
  //#endregion
5925
6811
  //#region package.json
5926
- var version = "9.3.1";
6812
+ var version = "10.0.0";
5927
6813
  //#endregion
5928
6814
  //#region src/workos.ts
5929
6815
  const DEFAULT_HOSTNAME = "api.workos.com";
@@ -5944,6 +6830,7 @@ var WorkOS = class {
5944
6830
  auditLogs = new AuditLogs(this);
5945
6831
  authorization = new Authorization(this);
5946
6832
  directorySync = new DirectorySync(this);
6833
+ connect = new Connect(this);
5947
6834
  events = new Events(this);
5948
6835
  featureFlags = new FeatureFlags(this);
5949
6836
  groups = new Groups(this);
@@ -5952,6 +6839,7 @@ var WorkOS = class {
5952
6839
  organizationDomains = new OrganizationDomains(this);
5953
6840
  passwordless = new Passwordless(this);
5954
6841
  pipes = new Pipes(this);
6842
+ radar = new Radar(this);
5955
6843
  adminPortal = new AdminPortal(this);
5956
6844
  sso = new SSO(this);
5957
6845
  userManagement;
@@ -6006,7 +6894,7 @@ var WorkOS = class {
6006
6894
  return `workos-node/${version}`;
6007
6895
  }
6008
6896
  createWebhookClient() {
6009
- return new Webhooks(this.getCryptoProvider());
6897
+ return new Webhooks(this);
6010
6898
  }
6011
6899
  createActionsClient() {
6012
6900
  return new Actions(this.getCryptoProvider());
@@ -6299,6 +7187,6 @@ function createWorkOS(options) {
6299
7187
  return new WorkOS(options);
6300
7188
  }
6301
7189
  //#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 };
7190
+ 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
7191
 
6304
- //# sourceMappingURL=factory-B2N5WzoO.mjs.map
7192
+ //# sourceMappingURL=factory-fIHNXxrd.mjs.map