@workos-inc/node 9.3.0 → 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.
@@ -99,6 +99,8 @@ for (let i = 0; i < byteHexMapping.length; i++) byteHexMapping[i] = i.toString(1
99
99
  //#endregion
100
100
  //#region src/common/net/http-client.ts
101
101
  var HttpClient = class HttpClient {
102
+ baseURL;
103
+ options;
102
104
  MAX_RETRY_ATTEMPTS = 3;
103
105
  BACKOFF_MULTIPLIER = 1.5;
104
106
  MINIMUM_SLEEP_TIME_IN_MILLISECONDS = 500;
@@ -112,14 +114,6 @@ var HttpClient = class HttpClient {
112
114
  this.baseURL = baseURL;
113
115
  this.options = options;
114
116
  }
115
- /** The HTTP client name used for diagnostics */
116
- getClientName() {
117
- throw new Error("getClientName not implemented");
118
- }
119
- addClientToUserAgent(userAgent) {
120
- if (userAgent.indexOf(" ") > -1) return userAgent.replace(/\b\s/, `/${this.getClientName()} `);
121
- else return `${userAgent}/${this.getClientName()}`;
122
- }
123
117
  static getResourceURL(baseURL, path, params) {
124
118
  const queryString = HttpClient.getQueryString(params);
125
119
  return new URL([path, queryString].filter(Boolean).join("?"), baseURL).toString();
@@ -190,6 +184,8 @@ var ParseError = class extends Error {
190
184
  //#region src/common/net/fetch-client.ts
191
185
  const DEFAULT_FETCH_TIMEOUT = 6e4;
192
186
  var FetchHttpClient = class extends HttpClient {
187
+ baseURL;
188
+ options;
193
189
  _fetchFn;
194
190
  constructor(baseURL, options, fetchFn) {
195
191
  super(baseURL, options);
@@ -201,10 +197,6 @@ var FetchHttpClient = class extends HttpClient {
201
197
  }
202
198
  this._fetchFn = fetchFn.bind(globalThis);
203
199
  }
204
- /** @override */
205
- getClientName() {
206
- return "fetch";
207
- }
208
200
  async get(path, options) {
209
201
  const resourceURL = HttpClient.getResourceURL(this.baseURL, path, options.params);
210
202
  if (HttpClient.isPathRetryable(path)) return await this.fetchRequestWithRetry(resourceURL, "GET", null, options.headers);
@@ -275,7 +267,7 @@ var FetchHttpClient = class extends HttpClient {
275
267
  "Content-Type": "application/json",
276
268
  ...this.options?.headers,
277
269
  ...headers,
278
- "User-Agent": this.addClientToUserAgent((userAgent || "workos-node").toString())
270
+ "User-Agent": (userAgent || "workos-node").toString()
279
271
  },
280
272
  body: requestBody,
281
273
  signal: abortController?.signal
@@ -370,6 +362,19 @@ var FetchHttpClientResponse = class FetchHttpClientResponse extends HttpClientRe
370
362
  }
371
363
  };
372
364
  //#endregion
365
+ //#region src/common/crypto/decode-payload.ts
366
+ function isBinaryPayload(payload) {
367
+ return ArrayBuffer.isView(payload) || Object.prototype.toString.call(payload) === "[object ArrayBuffer]";
368
+ }
369
+ function decodePayloadToString(payload) {
370
+ if (typeof payload === "string") return payload;
371
+ if (isBinaryPayload(payload)) {
372
+ const bytes = Object.prototype.toString.call(payload) === "[object ArrayBuffer]" ? new Uint8Array(payload) : payload;
373
+ return new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes);
374
+ }
375
+ return JSON.stringify(payload);
376
+ }
377
+ //#endregion
373
378
  //#region src/common/exceptions/api-key-required.exception.ts
374
379
  var ApiKeyRequiredException = class extends Error {
375
380
  status = 403;
@@ -383,6 +388,9 @@ var ApiKeyRequiredException = class extends Error {
383
388
  //#endregion
384
389
  //#region src/common/exceptions/generic-server.exception.ts
385
390
  var GenericServerException = class extends Error {
391
+ status;
392
+ rawData;
393
+ requestID;
386
394
  name = "GenericServerException";
387
395
  message = "The request could not be completed.";
388
396
  code;
@@ -417,6 +425,7 @@ function isAuthenticationErrorData(data) {
417
425
  return getAuthenticationErrorCode(data) !== void 0;
418
426
  }
419
427
  var AuthenticationException = class extends GenericServerException {
428
+ rawData;
420
429
  name = "AuthenticationException";
421
430
  code;
422
431
  pendingAuthenticationToken;
@@ -486,6 +495,11 @@ var NotFoundException = class extends Error {
486
495
  //#endregion
487
496
  //#region src/common/exceptions/oauth.exception.ts
488
497
  var OauthException = class extends Error {
498
+ status;
499
+ requestID;
500
+ error;
501
+ errorDescription;
502
+ rawData;
489
503
  name = "OauthException";
490
504
  constructor(status, requestID, error, errorDescription, rawData) {
491
505
  super();
@@ -502,6 +516,7 @@ var OauthException = class extends Error {
502
516
  //#endregion
503
517
  //#region src/common/exceptions/rate-limit-exceeded.exception.ts
504
518
  var RateLimitExceededException = class extends GenericServerException {
519
+ retryAfter;
505
520
  name = "RateLimitExceededException";
506
521
  constructor(message, requestID, retryAfter) {
507
522
  super(429, message, {}, requestID);
@@ -519,6 +534,7 @@ var SignatureVerificationException = class extends Error {
519
534
  //#endregion
520
535
  //#region src/common/exceptions/unauthorized.exception.ts
521
536
  var UnauthorizedException = class extends Error {
537
+ requestID;
522
538
  status = 401;
523
539
  name = "UnauthorizedException";
524
540
  message;
@@ -542,7 +558,8 @@ var UnprocessableEntityException = class extends Error {
542
558
  if (message) this.message = message;
543
559
  if (code) this.code = code;
544
560
  if (errors) {
545
- this.message = `The following ${errors.length === 1 ? "requirement" : "requirements"} must be met:\n`;
561
+ const requirement = errors.length === 1 ? "requirement" : "requirements";
562
+ this.message = `The following ${requirement} must be met:\n`;
546
563
  for (const { code } of errors) this.message = this.message.concat(`\t${code}\n`);
547
564
  }
548
565
  }
@@ -570,8 +587,7 @@ var SignatureProvider = class {
570
587
  return [timestamp, signatureHash];
571
588
  }
572
589
  async computeSignature(timestamp, payload, secret) {
573
- payload = JSON.stringify(payload);
574
- const signedPayload = `${timestamp}.${payload}`;
590
+ const signedPayload = `${timestamp}.${decodePayloadToString(payload)}`;
575
591
  return await this.cryptoProvider.computeHMACSignatureAsync(signedPayload, secret);
576
592
  }
577
593
  };
@@ -716,6 +732,43 @@ const deserializeAuthenticationEvent = (authenticationEvent) => ({
716
732
  userId: authenticationEvent.user_id
717
733
  });
718
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
719
772
  //#region src/user-management/serializers/oauth-tokens.serializer.ts
720
773
  const deserializeOauthTokens = (oauthTokens) => oauthTokens ? {
721
774
  accessToken: oauthTokens.access_token,
@@ -794,43 +847,6 @@ const serializeEnrollAuthFactorOptions = (options) => ({
794
847
  totp_secret: options.totpSecret
795
848
  });
796
849
  //#endregion
797
- //#region src/multi-factor-auth/serializers/totp.serializer.ts
798
- const deserializeTotp = (totp) => {
799
- return {
800
- issuer: totp.issuer,
801
- user: totp.user
802
- };
803
- };
804
- const deserializeTotpWithSecrets = (totp) => {
805
- return {
806
- issuer: totp.issuer,
807
- user: totp.user,
808
- qrCode: totp.qr_code,
809
- secret: totp.secret,
810
- uri: totp.uri
811
- };
812
- };
813
- //#endregion
814
- //#region src/user-management/serializers/factor.serializer.ts
815
- const deserializeFactor$1 = (factor) => ({
816
- object: factor.object,
817
- id: factor.id,
818
- createdAt: factor.created_at,
819
- updatedAt: factor.updated_at,
820
- type: factor.type,
821
- totp: deserializeTotp(factor.totp),
822
- userId: factor.user_id
823
- });
824
- const deserializeFactorWithSecrets$1 = (factor) => ({
825
- object: factor.object,
826
- id: factor.id,
827
- createdAt: factor.created_at,
828
- updatedAt: factor.updated_at,
829
- type: factor.type,
830
- totp: deserializeTotpWithSecrets(factor.totp),
831
- userId: factor.user_id
832
- });
833
- //#endregion
834
850
  //#region src/user-management/serializers/invitation.serializer.ts
835
851
  const deserializeInvitation = (invitation) => ({
836
852
  object: invitation.object,
@@ -1062,7 +1078,48 @@ var Actions = class {
1062
1078
  tolerance
1063
1079
  };
1064
1080
  await this.verifyHeader(options);
1065
- return deserializeAction(payload);
1081
+ return deserializeAction(typeof payload === "string" || isBinaryPayload(payload) ? JSON.parse(decodePayloadToString(payload)) : payload);
1082
+ }
1083
+ };
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;
1066
1123
  }
1067
1124
  };
1068
1125
  //#endregion
@@ -1346,30 +1403,30 @@ const deserializeFeatureFlag = (featureFlag) => ({
1346
1403
  updatedAt: featureFlag.updated_at
1347
1404
  });
1348
1405
  //#endregion
1349
- //#region src/groups/serializers/add-group-organization-membership-options.serializer.ts
1350
- const serializeAddGroupOrganizationMembershipOptions = (options) => ({ organization_membership_id: options.organizationMembershipId });
1351
- //#endregion
1352
- //#region src/groups/serializers/create-group-options.serializer.ts
1353
- const serializeCreateGroupOptions = (options) => ({
1354
- name: options.name,
1355
- 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
1356
1410
  });
1357
1411
  //#endregion
1412
+ //#region src/groups/serializers/create-group-membership.serializer.ts
1413
+ const serializeCreateGroupMembership = (model) => ({ organization_membership_id: model.organizationMembershipId });
1414
+ //#endregion
1358
1415
  //#region src/groups/serializers/group.serializer.ts
1359
- const deserializeGroup = (group) => ({
1360
- object: group.object,
1361
- id: group.id,
1362
- organizationId: group.organization_id,
1363
- name: group.name,
1364
- description: group.description,
1365
- createdAt: group.created_at,
1366
- updatedAt: group.updated_at
1367
- });
1368
- //#endregion
1369
- //#region src/groups/serializers/update-group-options.serializer.ts
1370
- const serializeUpdateGroupOptions = (options) => ({
1371
- name: options.name,
1372
- 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
1373
1430
  });
1374
1431
  //#endregion
1375
1432
  //#region src/vault/serializers/vault-event.serializer.ts
@@ -1696,11 +1753,122 @@ const serializePaginationOptions = (options) => ({
1696
1753
  ...options.order && { order: options.order }
1697
1754
  });
1698
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
1699
1796
  //#region src/webhooks/webhooks.ts
1700
1797
  var Webhooks = class {
1701
- signatureProvider;
1702
- constructor(cryptoProvider) {
1703
- 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;
1704
1872
  }
1705
1873
  get verifyHeader() {
1706
1874
  return this.signatureProvider.verifyHeader.bind(this.signatureProvider);
@@ -1719,7 +1887,11 @@ var Webhooks = class {
1719
1887
  tolerance
1720
1888
  };
1721
1889
  await this.verifyHeader(options);
1722
- return deserializeEvent(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));
1723
1895
  }
1724
1896
  };
1725
1897
  //#endregion
@@ -1773,45 +1945,6 @@ var PKCE = class {
1773
1945
  }
1774
1946
  };
1775
1947
  //#endregion
1776
- //#region src/common/utils/pagination.ts
1777
- var AutoPaginatable = class {
1778
- object = "list";
1779
- options;
1780
- constructor(list, apiCall, options) {
1781
- this.list = list;
1782
- this.apiCall = apiCall;
1783
- this.options = options ?? {};
1784
- }
1785
- get data() {
1786
- return this.list.data;
1787
- }
1788
- get listMetadata() {
1789
- return this.list.listMetadata;
1790
- }
1791
- async *generatePages(params) {
1792
- const result = await this.apiCall({
1793
- ...this.options,
1794
- limit: 100,
1795
- after: params.after
1796
- });
1797
- yield result.data;
1798
- if (result.listMetadata.after) {
1799
- await new Promise((resolve) => setTimeout(resolve, 350));
1800
- yield* this.generatePages({ after: result.listMetadata.after });
1801
- }
1802
- }
1803
- /**
1804
- * Automatically paginates over the list of results, returning the complete data set.
1805
- * Returns the first result if `options.limit` is passed to the first request.
1806
- */
1807
- async autoPagination() {
1808
- if (this.options.limit) return this.data;
1809
- const results = [];
1810
- for await (const page of this.generatePages({ after: this.options.after })) results.push(...page);
1811
- return results;
1812
- }
1813
- };
1814
- //#endregion
1815
1948
  //#region src/api-keys/serializers/create-organization-api-key-options.serializer.ts
1816
1949
  function serializeCreateOrganizationApiKeyOptions(options) {
1817
1950
  return {
@@ -1841,23 +1974,9 @@ function deserializeValidateApiKeyResponse(response) {
1841
1974
  return { apiKey: response.api_key ? deserializeApiKey(response.api_key) : null };
1842
1975
  }
1843
1976
  //#endregion
1844
- //#region src/common/utils/fetch-and-deserialize.ts
1845
- const setDefaultOptions = (options) => {
1846
- return {
1847
- ...options,
1848
- order: options?.order || "desc"
1849
- };
1850
- };
1851
- const fetchAndDeserialize = async (workos, endpoint, deserializeFn, options, requestOptions) => {
1852
- const { data } = await workos.get(endpoint, {
1853
- query: setDefaultOptions(options),
1854
- ...requestOptions
1855
- });
1856
- return deserializeList(data, deserializeFn);
1857
- };
1858
- //#endregion
1859
1977
  //#region src/api-keys/api-keys.ts
1860
1978
  var ApiKeys = class {
1979
+ workos;
1861
1980
  constructor(workos) {
1862
1981
  this.workos = workos;
1863
1982
  }
@@ -1927,8 +2046,362 @@ var ApiKeys = class {
1927
2046
  }
1928
2047
  };
1929
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
1930
2402
  //#region src/directory-sync/directory-sync.ts
1931
2403
  var DirectorySync = class {
2404
+ workos;
1932
2405
  constructor(workos) {
1933
2406
  this.workos = workos;
1934
2407
  }
@@ -2050,6 +2523,7 @@ const serializeListEventOptions = (options) => ({
2050
2523
  //#endregion
2051
2524
  //#region src/events/events.ts
2052
2525
  var Events = class {
2526
+ workos;
2053
2527
  constructor(workos) {
2054
2528
  this.workos = workos;
2055
2529
  }
@@ -2070,6 +2544,7 @@ var Events = class {
2070
2544
  //#endregion
2071
2545
  //#region src/organizations/organizations.ts
2072
2546
  var Organizations = class {
2547
+ workos;
2073
2548
  constructor(workos) {
2074
2549
  this.workos = workos;
2075
2550
  }
@@ -2172,6 +2647,7 @@ const serializeCreateOrganizationDomainOptions = (options) => ({
2172
2647
  //#endregion
2173
2648
  //#region src/organization-domains/organization-domains.ts
2174
2649
  var OrganizationDomains = class {
2650
+ workos;
2175
2651
  constructor(workos) {
2176
2652
  this.workos = workos;
2177
2653
  }
@@ -2247,6 +2723,7 @@ const deserializePasswordlessSession = (passwordlessSession) => ({
2247
2723
  //#endregion
2248
2724
  //#region src/passwordless/passwordless.ts
2249
2725
  var Passwordless = class {
2726
+ workos;
2250
2727
  constructor(workos) {
2251
2728
  this.workos = workos;
2252
2729
  }
@@ -2295,17 +2772,140 @@ function deserializeGetAccessTokenResponse(response) {
2295
2772
  //#endregion
2296
2773
  //#region src/pipes/pipes.ts
2297
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 {
2820
+ workos;
2298
2821
  constructor(workos) {
2299
2822
  this.workos = workos;
2300
2823
  }
2301
- async getAccessToken({ provider, ...options }) {
2302
- const { data } = await this.workos.post(`data-integrations/${provider}/token`, serializeGetAccessTokenOptions(options));
2303
- 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));
2304
2903
  }
2305
2904
  };
2306
2905
  //#endregion
2307
2906
  //#region src/admin-portal/admin-portal.ts
2308
2907
  var AdminPortal = class {
2908
+ workos;
2309
2909
  constructor(workos) {
2310
2910
  this.workos = workos;
2311
2911
  }
@@ -2369,6 +2969,7 @@ function encodeRFC1738(str) {
2369
2969
  //#endregion
2370
2970
  //#region src/sso/sso.ts
2371
2971
  var SSO = class {
2972
+ workos;
2372
2973
  constructor(workos) {
2373
2974
  this.workos = workos;
2374
2975
  }
@@ -2571,6 +3172,7 @@ const deserializeVerifyResponse = (verifyResponse) => ({
2571
3172
  //#endregion
2572
3173
  //#region src/multi-factor-auth/multi-factor-auth.ts
2573
3174
  var MultiFactorAuth = class {
3175
+ workos;
2574
3176
  constructor(workos) {
2575
3177
  this.workos = workos;
2576
3178
  }
@@ -2772,6 +3374,7 @@ const deserializeAuditLogSchema = (auditLogSchema) => ({
2772
3374
  //#endregion
2773
3375
  //#region src/audit-logs/audit-logs.ts
2774
3376
  var AuditLogs = class {
3377
+ workos;
2775
3378
  constructor(workos) {
2776
3379
  this.workos = workos;
2777
3380
  }
@@ -3323,7 +3926,7 @@ let _josePromise;
3323
3926
  * @returns Promise that resolves to the jose module
3324
3927
  */
3325
3928
  function getJose() {
3326
- return _josePromise ??= Promise.resolve().then(() => require("./webapi-N7c2LUJd.cjs"));
3929
+ return _josePromise ??= Promise.resolve().then(() => require("./webapi-lTzmUixq.cjs"));
3327
3930
  }
3328
3931
  //#endregion
3329
3932
  //#region src/user-management/session.ts
@@ -3345,16 +3948,16 @@ var CookieSession = class {
3345
3948
  async authenticate() {
3346
3949
  if (!this.sessionData) return {
3347
3950
  authenticated: false,
3348
- reason: AuthenticateWithSessionCookieFailureReason.NO_SESSION_COOKIE_PROVIDED
3951
+ reason: "no_session_cookie_provided"
3349
3952
  };
3350
3953
  const session = await unsealData(this.sessionData, { password: this.cookiePassword });
3351
3954
  if (!session.accessToken) return {
3352
3955
  authenticated: false,
3353
- reason: AuthenticateWithSessionCookieFailureReason.INVALID_SESSION_COOKIE
3956
+ reason: "invalid_session_cookie"
3354
3957
  };
3355
3958
  if (!await this.isValidJwt(session.accessToken)) return {
3356
3959
  authenticated: false,
3357
- reason: AuthenticateWithSessionCookieFailureReason.INVALID_JWT
3960
+ reason: "invalid_jwt"
3358
3961
  };
3359
3962
  const { decodeJwt } = await getJose();
3360
3963
  const { sid: sessionId, org_id: organizationId, role, roles, permissions, entitlements, feature_flags: featureFlags } = decodeJwt(session.accessToken);
@@ -3386,15 +3989,15 @@ var CookieSession = class {
3386
3989
  const session = await unsealData(this.sessionData, { password: this.cookiePassword });
3387
3990
  if (!session.refreshToken || !session.user) return {
3388
3991
  authenticated: false,
3389
- reason: RefreshSessionFailureReason.INVALID_SESSION_COOKIE
3992
+ reason: "invalid_session_cookie"
3390
3993
  };
3391
- const { org_id: organizationIdFromAccessToken } = decodeJwt(session.accessToken);
3994
+ const { org_id: organizationIdFromUserManagementAccessToken } = decodeJwt(session.accessToken);
3392
3995
  try {
3393
3996
  const cookiePassword = options.cookiePassword ?? this.cookiePassword;
3394
3997
  const authenticationResponse = await this.userManagement.authenticateWithRefreshToken({
3395
3998
  clientId: this.userManagement.clientId,
3396
3999
  refreshToken: session.refreshToken,
3397
- organizationId: options.organizationId ?? organizationIdFromAccessToken,
4000
+ organizationId: options.organizationId ?? organizationIdFromUserManagementAccessToken,
3398
4001
  session: {
3399
4002
  sealSession: true,
3400
4003
  cookiePassword
@@ -3419,7 +4022,7 @@ var CookieSession = class {
3419
4022
  impersonator: session.impersonator
3420
4023
  };
3421
4024
  } catch (error) {
3422
- if (error instanceof OauthException && (error.error === RefreshSessionFailureReason.INVALID_GRANT || error.error === RefreshSessionFailureReason.MFA_ENROLLMENT || error.error === RefreshSessionFailureReason.SSO_REQUIRED)) return {
4025
+ if (error instanceof OauthException && (error.error === "invalid_grant" || error.error === "mfa_enrollment" || error.error === "sso_required")) return {
3423
4026
  authenticated: false,
3424
4027
  reason: error.error
3425
4028
  };
@@ -3458,6 +4061,7 @@ var CookieSession = class {
3458
4061
  //#endregion
3459
4062
  //#region src/user-management/user-management.ts
3460
4063
  var UserManagement = class {
4064
+ workos;
3461
4065
  _jwks;
3462
4066
  clientId;
3463
4067
  constructor(workos) {
@@ -3694,16 +4298,16 @@ var UserManagement = class {
3694
4298
  const { decodeJwt } = await getJose();
3695
4299
  if (!sessionData) return {
3696
4300
  authenticated: false,
3697
- reason: AuthenticateWithSessionCookieFailureReason.NO_SESSION_COOKIE_PROVIDED
4301
+ reason: "no_session_cookie_provided"
3698
4302
  };
3699
4303
  const session = await unsealData(sessionData, { password: cookiePassword });
3700
4304
  if (!session.accessToken) return {
3701
4305
  authenticated: false,
3702
- reason: AuthenticateWithSessionCookieFailureReason.INVALID_SESSION_COOKIE
4306
+ reason: "invalid_session_cookie"
3703
4307
  };
3704
4308
  if (!await this.isValidJwt(session.accessToken)) return {
3705
4309
  authenticated: false,
3706
- reason: AuthenticateWithSessionCookieFailureReason.INVALID_JWT
4310
+ reason: "invalid_jwt"
3707
4311
  };
3708
4312
  const { sid: sessionId, org_id: organizationId, role, roles, permissions, entitlements, feature_flags: featureFlags } = decodeJwt(session.accessToken);
3709
4313
  return {
@@ -4238,6 +4842,7 @@ var InMemoryStore = class {
4238
4842
  //#endregion
4239
4843
  //#region src/feature-flags/evaluator.ts
4240
4844
  var Evaluator = class {
4845
+ store;
4241
4846
  constructor(store) {
4242
4847
  this.store = store;
4243
4848
  }
@@ -4273,6 +4878,7 @@ const INITIAL_RETRY_MS = 1e3;
4273
4878
  const MAX_RETRY_MS = 6e4;
4274
4879
  const BACKOFF_MULTIPLIER = 2;
4275
4880
  var FeatureFlagsRuntimeClient = class extends eventemitter3.EventEmitter {
4881
+ workos;
4276
4882
  store;
4277
4883
  evaluator;
4278
4884
  pollingIntervalMs;
@@ -4455,6 +5061,7 @@ var FeatureFlagsRuntimeClient = class extends eventemitter3.EventEmitter {
4455
5061
  //#endregion
4456
5062
  //#region src/feature-flags/feature-flags.ts
4457
5063
  var FeatureFlags = class {
5064
+ workos;
4458
5065
  constructor(workos) {
4459
5066
  this.workos = workos;
4460
5067
  }
@@ -4577,45 +5184,164 @@ var FeatureFlags = class {
4577
5184
  //#endregion
4578
5185
  //#region src/groups/groups.ts
4579
5186
  var Groups = class {
5187
+ workos;
4580
5188
  constructor(workos) {
4581
5189
  this.workos = workos;
4582
5190
  }
4583
- async createGroup(options) {
4584
- const { organizationId, ...payload } = options;
4585
- const { data } = await this.workos.post(`/organizations/${organizationId}/groups`, serializeCreateGroupOptions(payload));
4586
- 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);
4587
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
+ */
4588
5220
  async listGroups(options) {
4589
5221
  const { organizationId, ...paginationOptions } = options;
4590
- 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);
4591
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
+ */
4592
5259
  async getGroup(options) {
4593
5260
  const { organizationId, groupId } = options;
4594
- const { data } = await this.workos.get(`/organizations/${organizationId}/groups/${groupId}`);
5261
+ const { data } = await this.workos.get(`/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}`);
4595
5262
  return deserializeGroup(data);
4596
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
+ */
4597
5283
  async updateGroup(options) {
4598
5284
  const { organizationId, groupId, ...payload } = options;
4599
- 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));
4600
5286
  return deserializeGroup(data);
4601
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
+ */
4602
5301
  async deleteGroup(options) {
4603
5302
  const { organizationId, groupId } = options;
4604
- await this.workos.delete(`/organizations/${organizationId}/groups/${groupId}`);
5303
+ await this.workos.delete(`/organizations/${encodeURIComponent(organizationId)}/groups/${encodeURIComponent(groupId)}`);
4605
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
+ */
4606
5322
  async addOrganizationMembership(options) {
4607
5323
  const { organizationId, groupId, ...payload } = options;
4608
- 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));
4609
5325
  return deserializeGroup(data);
4610
5326
  }
4611
- async listOrganizationMemberships(options) {
4612
- const { organizationId, groupId, ...paginationOptions } = options;
4613
- const endpoint = `/organizations/${organizationId}/groups/${groupId}/organization-memberships`;
4614
- return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, paginationOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, params), paginationOptions);
4615
- }
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
+ */
4616
5342
  async removeOrganizationMembership(options) {
4617
5343
  const { organizationId, groupId, organizationMembershipId } = options;
4618
- 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)}`);
4619
5345
  }
4620
5346
  };
4621
5347
  //#endregion
@@ -4629,6 +5355,7 @@ const deserializeGetTokenResponse = (data) => ({ token: data.token });
4629
5355
  //#endregion
4630
5356
  //#region src/widgets/widgets.ts
4631
5357
  var Widgets = class {
5358
+ workos;
4632
5359
  constructor(workos) {
4633
5360
  this.workos = workos;
4634
5361
  }
@@ -4751,7 +5478,6 @@ const serializeListAuthorizationResourcesOptions = (options) => ({
4751
5478
  ...options.parentResourceId && { parent_resource_id: options.parentResourceId },
4752
5479
  ...options.parentResourceTypeSlug && { parent_resource_type_slug: options.parentResourceTypeSlug },
4753
5480
  ...options.parentExternalId && { parent_external_id: options.parentExternalId },
4754
- ...options.search && { search: options.search },
4755
5481
  ...serializePaginationOptions(options)
4756
5482
  });
4757
5483
  //#endregion
@@ -4837,6 +5563,7 @@ const serializeListEffectivePermissionsOptions = (options) => ({ ...serializePag
4837
5563
  //#endregion
4838
5564
  //#region src/authorization/authorization.ts
4839
5565
  var Authorization = class {
5566
+ workos;
4840
5567
  constructor(workos) {
4841
5568
  this.workos = workos;
4842
5569
  }
@@ -5698,6 +6425,105 @@ function hasContinuationBit(byte) {
5698
6425
  return (byte & CONTINUATION_BIT) !== 0;
5699
6426
  }
5700
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
5701
6527
  //#region src/common/utils/base64.ts
5702
6528
  /**
5703
6529
  * Cross-runtime compatible base64 encoding/decoding utilities
@@ -5727,127 +6553,235 @@ function uint8ArrayToBase64(bytes) {
5727
6553
  else throw new Error("No base64 encoding implementation available");
5728
6554
  }
5729
6555
  //#endregion
5730
- //#region src/vault/serializers/vault-key.serializer.ts
5731
- const deserializeCreateDataKeyResponse = (key) => ({
5732
- context: key.context,
5733
- dataKey: {
5734
- key: key.data_key,
5735
- id: key.id
5736
- },
5737
- encryptedKeys: key.encrypted_keys
5738
- });
5739
- const deserializeDecryptDataKeyResponse = (key) => ({
5740
- key: key.data_key,
5741
- id: key.id
5742
- });
5743
- //#endregion
5744
- //#region src/vault/serializers/vault-object.serializer.ts
5745
- const deserializeObjectMetadata = (metadata) => ({
5746
- context: metadata.context,
5747
- environmentId: metadata.environment_id,
5748
- id: metadata.id,
5749
- keyId: metadata.key_id,
5750
- updatedAt: new Date(Date.parse(metadata.updated_at)),
5751
- updatedBy: metadata.updated_by,
5752
- versionId: metadata.version_id
5753
- });
5754
- const deserializeObject = (object) => ({
5755
- id: object.id,
5756
- name: object.name,
5757
- ...object.value !== void 0 && { value: object.value },
5758
- metadata: deserializeObjectMetadata(object.metadata)
5759
- });
5760
- const deserializeObjectDigest = (digest) => ({
5761
- id: digest.id,
5762
- name: digest.name,
5763
- updatedAt: new Date(Date.parse(digest.updated_at))
5764
- });
5765
- const deserializeListObjects = (list) => ({
5766
- object: "list",
5767
- data: list.data.map(deserializeObjectDigest),
5768
- listMetadata: {
5769
- ...list.list_metadata.after !== void 0 && { after: list.list_metadata.after },
5770
- ...list.list_metadata.before !== void 0 && { before: list.list_metadata.before }
5771
- }
5772
- });
5773
- const desrializeListObjectVersions = (list) => list.data.map(deserializeObjectVersion);
5774
- const deserializeObjectVersion = (version) => ({
5775
- createdAt: new Date(Date.parse(version.created_at)),
5776
- currentVersion: version.current_version,
5777
- id: version.id
5778
- });
5779
- const serializeCreateObjectEntity = (options) => ({
5780
- name: options.name,
5781
- value: options.value,
5782
- key_context: options.context
5783
- });
5784
- const serializeUpdateObjectEntity = (options) => ({
5785
- value: options.value,
5786
- version_check: options.versionCheck
5787
- });
5788
- //#endregion
5789
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
+ };
5790
6568
  var Vault = class {
5791
- cryptoProvider;
6569
+ workos;
5792
6570
  constructor(workos) {
5793
6571
  this.workos = workos;
5794
- this.cryptoProvider = workos.getCryptoProvider();
5795
6572
  }
5796
- decode(payload) {
5797
- const inputData = base64ToUint8Array(payload);
5798
- const iv = new Uint8Array(inputData.subarray(0, 12));
5799
- const tag = new Uint8Array(inputData.subarray(12, 28));
5800
- 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);
5801
6593
  return {
5802
- iv,
5803
- tag,
5804
- keys: uint8ArrayToBase64(inputData.subarray(nextIndex, nextIndex + keyLen)),
5805
- 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
5806
6600
  };
5807
6601
  }
5808
- async createObject(options) {
5809
- const { data } = await this.workos.post(`/vault/v1/kv`, serializeCreateObjectEntity(options));
5810
- 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);
5811
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
+ */
5812
6647
  async listObjects(options) {
5813
- const url = new URL("/vault/v1/kv", this.workos.baseURL);
5814
- if (options?.after) url.searchParams.set("after", options.after);
5815
- if (options?.before) url.searchParams.set("before", options.before);
5816
- if (options?.limit) url.searchParams.set("limit", options.limit.toString());
5817
- if (options?.order) url.searchParams.set("order", options.order);
5818
- const { data } = await this.workos.get(url.toString());
5819
- 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);
5820
6650
  }
5821
- async listObjectVersions(options) {
5822
- const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(options.id)}/versions`);
5823
- 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);
5824
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
+ */
5825
6687
  async readObject(options) {
5826
- const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(options.id)}`);
5827
- 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
+ };
5828
6714
  }
5829
- async readObjectByName(name) {
5830
- const { data } = await this.workos.get(`/vault/v1/kv/name/${encodeURIComponent(name)}`);
5831
- 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 } } });
5832
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
+ */
5833
6743
  async describeObject(options) {
5834
- const { data } = await this.workos.get(`/vault/v1/kv/${encodeURIComponent(options.id)}/metadata`);
5835
- return deserializeObject(data);
5836
- }
5837
- async updateObject(options) {
5838
- const { data } = await this.workos.put(`/vault/v1/kv/${encodeURIComponent(options.id)}`, serializeUpdateObjectEntity(options));
5839
- 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
+ };
5840
6750
  }
5841
- async deleteObject(options) {
5842
- 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;
5843
6766
  }
5844
- async createDataKey(options) {
5845
- const { data } = await this.workos.post(`/vault/v1/keys/data-key`, options);
5846
- 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
+ };
5847
6778
  }
5848
- async decryptDataKey(options) {
5849
- const { data } = await this.workos.post(`/vault/v1/keys/decrypt`, options);
5850
- 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);
5851
6785
  }
5852
6786
  async encrypt(data, context, associatedData) {
5853
6787
  const keyPair = await this.createDataKey({ context });
@@ -5856,8 +6790,9 @@ var Vault = class {
5856
6790
  const keyBlob = base64ToUint8Array(keyPair.encryptedKeys);
5857
6791
  const prefixLenBuffer = encodeUInt32(keyBlob.length);
5858
6792
  const aadBuffer = associatedData ? encoder.encode(associatedData) : void 0;
5859
- const iv = this.cryptoProvider.randomBytes(12);
5860
- 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);
5861
6796
  const resultArray = new Uint8Array(resultIv.length + tag.length + prefixLenBuffer.length + keyBlob.length + ciphertext.length);
5862
6797
  let offset = 0;
5863
6798
  resultArray.set(resultIv, offset);
@@ -5871,60 +6806,10 @@ var Vault = class {
5871
6806
  resultArray.set(ciphertext, offset);
5872
6807
  return uint8ArrayToBase64(resultArray);
5873
6808
  }
5874
- async decrypt(encryptedData, associatedData) {
5875
- const decoded = this.decode(encryptedData);
5876
- const key = base64ToUint8Array((await this.decryptDataKey({ keys: decoded.keys })).key);
5877
- const encoder = new TextEncoder();
5878
- const aadBuffer = associatedData ? encoder.encode(associatedData) : void 0;
5879
- const decrypted = await this.cryptoProvider.decrypt(decoded.ciphertext, key, decoded.iv, decoded.tag, aadBuffer);
5880
- return new TextDecoder().decode(decrypted);
5881
- }
5882
6809
  };
5883
6810
  //#endregion
5884
- //#region src/common/utils/runtime-info.ts
5885
- /**
5886
- * Get runtime information including name and version.
5887
- * Safely extracts version information for different JavaScript runtimes.
5888
- * @returns RuntimeInfo object with name and optional version
5889
- */
5890
- function getRuntimeInfo() {
5891
- const name = detectRuntime();
5892
- let version;
5893
- try {
5894
- switch (name) {
5895
- case "node":
5896
- version = typeof process !== "undefined" ? process.version : void 0;
5897
- break;
5898
- case "deno":
5899
- version = globalThis.Deno?.version?.deno;
5900
- break;
5901
- case "bun":
5902
- version = globalThis.Bun?.version || extractBunVersionFromUserAgent();
5903
- break;
5904
- default:
5905
- version = void 0;
5906
- break;
5907
- }
5908
- } catch {
5909
- version = void 0;
5910
- }
5911
- return {
5912
- name,
5913
- version
5914
- };
5915
- }
5916
- /**
5917
- * Extract Bun version from navigator.userAgent as fallback.
5918
- * @returns Bun version string or undefined
5919
- */
5920
- function extractBunVersionFromUserAgent() {
5921
- try {
5922
- if (typeof navigator !== "undefined" && navigator.userAgent) return navigator.userAgent.match(/Bun\/(\d+\.\d+\.\d+)/)?.[1];
5923
- } catch {}
5924
- }
5925
- //#endregion
5926
6811
  //#region package.json
5927
- var version = "9.3.0";
6812
+ var version = "10.0.0";
5928
6813
  //#endregion
5929
6814
  //#region src/workos.ts
5930
6815
  const DEFAULT_HOSTNAME = "api.workos.com";
@@ -5945,6 +6830,7 @@ var WorkOS = class {
5945
6830
  auditLogs = new AuditLogs(this);
5946
6831
  authorization = new Authorization(this);
5947
6832
  directorySync = new DirectorySync(this);
6833
+ connect = new Connect(this);
5948
6834
  events = new Events(this);
5949
6835
  featureFlags = new FeatureFlags(this);
5950
6836
  groups = new Groups(this);
@@ -5953,6 +6839,7 @@ var WorkOS = class {
5953
6839
  organizationDomains = new OrganizationDomains(this);
5954
6840
  passwordless = new Passwordless(this);
5955
6841
  pipes = new Pipes(this);
6842
+ radar = new Radar(this);
5956
6843
  adminPortal = new AdminPortal(this);
5957
6844
  sso = new SSO(this);
5958
6845
  userManagement;
@@ -6003,18 +6890,11 @@ var WorkOS = class {
6003
6890
  const userAgent = this.createUserAgent(this.options);
6004
6891
  this.client = this.createHttpClient(this.options, userAgent);
6005
6892
  }
6006
- createUserAgent(options) {
6007
- let userAgent = `workos-node/${version}`;
6008
- const { name: runtimeName, version: runtimeVersion } = getRuntimeInfo();
6009
- userAgent += ` (${runtimeName}${runtimeVersion ? `/${runtimeVersion}` : ""})`;
6010
- if (options.appInfo) {
6011
- const { name, version } = options.appInfo;
6012
- userAgent += ` ${name}: ${version}`;
6013
- }
6014
- return userAgent;
6893
+ createUserAgent(_options) {
6894
+ return `workos-node/${version}`;
6015
6895
  }
6016
6896
  createWebhookClient() {
6017
- return new Webhooks(this.getCryptoProvider());
6897
+ return new Webhooks(this);
6018
6898
  }
6019
6899
  createActionsClient() {
6020
6900
  return new Actions(this.getCryptoProvider());
@@ -6481,12 +7361,24 @@ Object.defineProperty(exports, "createWorkOS", {
6481
7361
  return createWorkOS;
6482
7362
  }
6483
7363
  });
7364
+ Object.defineProperty(exports, "deserializeGetTokenResponse", {
7365
+ enumerable: true,
7366
+ get: function() {
7367
+ return deserializeGetTokenResponse;
7368
+ }
7369
+ });
6484
7370
  Object.defineProperty(exports, "isAuthenticationErrorData", {
6485
7371
  enumerable: true,
6486
7372
  get: function() {
6487
7373
  return isAuthenticationErrorData;
6488
7374
  }
6489
7375
  });
7376
+ Object.defineProperty(exports, "serializeGetTokenOptions", {
7377
+ enumerable: true,
7378
+ get: function() {
7379
+ return serializeGetTokenOptions;
7380
+ }
7381
+ });
6490
7382
  Object.defineProperty(exports, "serializeRevokeSessionOptions", {
6491
7383
  enumerable: true,
6492
7384
  get: function() {
@@ -6494,4 +7386,4 @@ Object.defineProperty(exports, "serializeRevokeSessionOptions", {
6494
7386
  }
6495
7387
  });
6496
7388
 
6497
- //# sourceMappingURL=factory-5S80C27h.cjs.map
7389
+ //# sourceMappingURL=factory-CKDJjzbQ.cjs.map