@workos-inc/node 8.13.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/{factory-HM2NchXm.mjs → factory-B7cG7pDB.mjs} +1691 -588
- package/lib/factory-B7cG7pDB.mjs.map +1 -0
- package/lib/{factory-yopqWYw5.cjs → factory-D3tT03aV.cjs} +1706 -609
- package/lib/factory-D3tT03aV.cjs.map +1 -0
- package/lib/index.cjs +5 -6
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.mjs +2 -2
- package/lib/index.mjs.map +1 -1
- package/lib/index.worker.cjs +5 -6
- package/lib/index.worker.cjs.map +1 -1
- package/lib/index.worker.d.cts +2 -2
- package/lib/index.worker.d.mts +2 -2
- package/lib/index.worker.mjs +2 -2
- package/lib/index.worker.mjs.map +1 -1
- package/lib/{workos-9ENvbxSO.d.cts → workos-C0YAqze0.d.cts} +1943 -549
- package/lib/{workos-CESKLr5j.d.mts → workos-DhbLRXvR.d.mts} +1943 -549
- package/package.json +7 -7
- package/lib/factory-HM2NchXm.mjs.map +0 -1
- package/lib/factory-yopqWYw5.cjs.map +0 -1
|
@@ -140,7 +140,7 @@ var HttpClient = class HttpClient {
|
|
|
140
140
|
return JSON.stringify(entity);
|
|
141
141
|
}
|
|
142
142
|
static isPathRetryable(path) {
|
|
143
|
-
return path.startsWith("/
|
|
143
|
+
return path.startsWith("/vault/") || path.startsWith("/audit_logs/events");
|
|
144
144
|
}
|
|
145
145
|
getSleepTimeInMilliseconds(retryAttempt) {
|
|
146
146
|
return this.MINIMUM_SLEEP_TIME_IN_MILLISECONDS * Math.pow(this.BACKOFF_MULTIPLIER, retryAttempt) * (Math.random() + .5);
|
|
@@ -385,12 +385,36 @@ var ApiKeyRequiredException = class extends Error {
|
|
|
385
385
|
var GenericServerException = class extends Error {
|
|
386
386
|
name = "GenericServerException";
|
|
387
387
|
message = "The request could not be completed.";
|
|
388
|
+
code;
|
|
388
389
|
constructor(status, message, rawData, requestID) {
|
|
389
390
|
super();
|
|
390
391
|
this.status = status;
|
|
391
392
|
this.rawData = rawData;
|
|
392
393
|
this.requestID = requestID;
|
|
393
394
|
if (message) this.message = message;
|
|
395
|
+
this.code = rawData.code;
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/common/exceptions/authentication.exception.ts
|
|
400
|
+
const AUTHENTICATION_ERROR_CODES = new Set([
|
|
401
|
+
"email_verification_required",
|
|
402
|
+
"organization_selection_required",
|
|
403
|
+
"mfa_enrollment",
|
|
404
|
+
"mfa_challenge",
|
|
405
|
+
"mfa_verification",
|
|
406
|
+
"sso_required"
|
|
407
|
+
]);
|
|
408
|
+
function isAuthenticationErrorData(data) {
|
|
409
|
+
return typeof data.code === "string" && AUTHENTICATION_ERROR_CODES.has(data.code);
|
|
410
|
+
}
|
|
411
|
+
var AuthenticationException = class extends GenericServerException {
|
|
412
|
+
name = "AuthenticationException";
|
|
413
|
+
pendingAuthenticationToken;
|
|
414
|
+
constructor(status, rawData, requestID) {
|
|
415
|
+
super(status, rawData.message, rawData, requestID);
|
|
416
|
+
this.rawData = rawData;
|
|
417
|
+
this.pendingAuthenticationToken = rawData.pending_authentication_token;
|
|
394
418
|
}
|
|
395
419
|
};
|
|
396
420
|
//#endregion
|
|
@@ -411,6 +435,22 @@ var BadRequestException = class extends Error {
|
|
|
411
435
|
}
|
|
412
436
|
};
|
|
413
437
|
//#endregion
|
|
438
|
+
//#region src/common/exceptions/conflict.exception.ts
|
|
439
|
+
var ConflictException = class extends Error {
|
|
440
|
+
status = 409;
|
|
441
|
+
name = "ConflictException";
|
|
442
|
+
requestID;
|
|
443
|
+
code;
|
|
444
|
+
constructor({ error, message, requestID, code }) {
|
|
445
|
+
super();
|
|
446
|
+
this.requestID = requestID;
|
|
447
|
+
if (message) this.message = message;
|
|
448
|
+
else if (error) this.message = `Error: ${error}`;
|
|
449
|
+
else this.message = `A conflict has occurred on the server.`;
|
|
450
|
+
this.code = code;
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
//#endregion
|
|
414
454
|
//#region src/common/exceptions/no-api-key-provided.exception.ts
|
|
415
455
|
var NoApiKeyProvidedException = class extends Error {
|
|
416
456
|
status = 500;
|
|
@@ -743,7 +783,7 @@ const serializeEnrollAuthFactorOptions = (options) => ({
|
|
|
743
783
|
totp_secret: options.totpSecret
|
|
744
784
|
});
|
|
745
785
|
//#endregion
|
|
746
|
-
//#region src/
|
|
786
|
+
//#region src/multi-factor-auth/serializers/totp.serializer.ts
|
|
747
787
|
const deserializeTotp = (totp) => {
|
|
748
788
|
return {
|
|
749
789
|
issuer: totp.issuer,
|
|
@@ -792,6 +832,7 @@ const deserializeInvitation = (invitation) => ({
|
|
|
792
832
|
organizationId: invitation.organization_id,
|
|
793
833
|
inviterUserId: invitation.inviter_user_id,
|
|
794
834
|
acceptedUserId: invitation.accepted_user_id,
|
|
835
|
+
roleSlug: invitation.role_slug,
|
|
795
836
|
token: invitation.token,
|
|
796
837
|
acceptInvitationUrl: invitation.accept_invitation_url,
|
|
797
838
|
createdAt: invitation.created_at,
|
|
@@ -808,6 +849,7 @@ const deserializeInvitationEvent = (invitation) => ({
|
|
|
808
849
|
organizationId: invitation.organization_id,
|
|
809
850
|
inviterUserId: invitation.inviter_user_id,
|
|
810
851
|
acceptedUserId: invitation.accepted_user_id,
|
|
852
|
+
roleSlug: invitation.role_slug,
|
|
811
853
|
createdAt: invitation.created_at,
|
|
812
854
|
updatedAt: invitation.updated_at
|
|
813
855
|
});
|
|
@@ -1230,7 +1272,7 @@ function deserializeApiKey(apiKey) {
|
|
|
1230
1272
|
}
|
|
1231
1273
|
//#endregion
|
|
1232
1274
|
//#region src/authorization/serializers/organization-role.serializer.ts
|
|
1233
|
-
const deserializeRole
|
|
1275
|
+
const deserializeRole = (role) => ({
|
|
1234
1276
|
object: role.object,
|
|
1235
1277
|
id: role.id,
|
|
1236
1278
|
name: role.name,
|
|
@@ -1293,6 +1335,32 @@ const deserializeFeatureFlag = (featureFlag) => ({
|
|
|
1293
1335
|
updatedAt: featureFlag.updated_at
|
|
1294
1336
|
});
|
|
1295
1337
|
//#endregion
|
|
1338
|
+
//#region src/groups/serializers/add-group-organization-membership-options.serializer.ts
|
|
1339
|
+
const serializeAddGroupOrganizationMembershipOptions = (options) => ({ organization_membership_id: options.organizationMembershipId });
|
|
1340
|
+
//#endregion
|
|
1341
|
+
//#region src/groups/serializers/create-group-options.serializer.ts
|
|
1342
|
+
const serializeCreateGroupOptions = (options) => ({
|
|
1343
|
+
name: options.name,
|
|
1344
|
+
description: options.description
|
|
1345
|
+
});
|
|
1346
|
+
//#endregion
|
|
1347
|
+
//#region src/groups/serializers/group.serializer.ts
|
|
1348
|
+
const deserializeGroup = (group) => ({
|
|
1349
|
+
object: group.object,
|
|
1350
|
+
id: group.id,
|
|
1351
|
+
organizationId: group.organization_id,
|
|
1352
|
+
name: group.name,
|
|
1353
|
+
description: group.description,
|
|
1354
|
+
createdAt: group.created_at,
|
|
1355
|
+
updatedAt: group.updated_at
|
|
1356
|
+
});
|
|
1357
|
+
//#endregion
|
|
1358
|
+
//#region src/groups/serializers/update-group-options.serializer.ts
|
|
1359
|
+
const serializeUpdateGroupOptions = (options) => ({
|
|
1360
|
+
name: options.name,
|
|
1361
|
+
description: options.description
|
|
1362
|
+
});
|
|
1363
|
+
//#endregion
|
|
1296
1364
|
//#region src/vault/serializers/vault-event.serializer.ts
|
|
1297
1365
|
const deserializeVaultActor = (actor) => ({
|
|
1298
1366
|
actorId: actor.actor_id,
|
|
@@ -1528,6 +1596,22 @@ const deserializeEvent = (event) => {
|
|
|
1528
1596
|
event: event.event,
|
|
1529
1597
|
data: deserializeFeatureFlag(event.data)
|
|
1530
1598
|
};
|
|
1599
|
+
case "group.created":
|
|
1600
|
+
case "group.updated":
|
|
1601
|
+
case "group.deleted": return {
|
|
1602
|
+
...eventBase,
|
|
1603
|
+
event: event.event,
|
|
1604
|
+
data: deserializeGroup(event.data)
|
|
1605
|
+
};
|
|
1606
|
+
case "group.member_added":
|
|
1607
|
+
case "group.member_removed": return {
|
|
1608
|
+
...eventBase,
|
|
1609
|
+
event: event.event,
|
|
1610
|
+
data: {
|
|
1611
|
+
groupId: event.data.group_id,
|
|
1612
|
+
organizationMembershipId: event.data.organization_membership_id
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1531
1615
|
case "vault.data.created": return {
|
|
1532
1616
|
...eventBase,
|
|
1533
1617
|
event: event.event,
|
|
@@ -1578,6 +1662,11 @@ const deserializeEvent = (event) => {
|
|
|
1578
1662
|
event: event.event,
|
|
1579
1663
|
data: deserializeVaultByokKeyVerificationCompletedEvent(event.data)
|
|
1580
1664
|
};
|
|
1665
|
+
default: return {
|
|
1666
|
+
...eventBase,
|
|
1667
|
+
event: event.event,
|
|
1668
|
+
data: event.data
|
|
1669
|
+
};
|
|
1581
1670
|
}
|
|
1582
1671
|
};
|
|
1583
1672
|
//#endregion
|
|
@@ -1673,25 +1762,6 @@ var PKCE = class {
|
|
|
1673
1762
|
}
|
|
1674
1763
|
};
|
|
1675
1764
|
//#endregion
|
|
1676
|
-
//#region src/api-keys/serializers/validate-api-key.serializer.ts
|
|
1677
|
-
function deserializeValidateApiKeyResponse(response) {
|
|
1678
|
-
return { apiKey: response.api_key ? deserializeApiKey(response.api_key) : null };
|
|
1679
|
-
}
|
|
1680
|
-
//#endregion
|
|
1681
|
-
//#region src/api-keys/api-keys.ts
|
|
1682
|
-
var ApiKeys = class {
|
|
1683
|
-
constructor(workos) {
|
|
1684
|
-
this.workos = workos;
|
|
1685
|
-
}
|
|
1686
|
-
async validateApiKey(payload) {
|
|
1687
|
-
const { data } = await this.workos.post("/api_keys/validations", payload);
|
|
1688
|
-
return deserializeValidateApiKeyResponse(data);
|
|
1689
|
-
}
|
|
1690
|
-
async deleteApiKey(id) {
|
|
1691
|
-
await this.workos.delete(`/api_keys/${id}`);
|
|
1692
|
-
}
|
|
1693
|
-
};
|
|
1694
|
-
//#endregion
|
|
1695
1765
|
//#region src/common/utils/pagination.ts
|
|
1696
1766
|
var AutoPaginatable = class {
|
|
1697
1767
|
object = "list";
|
|
@@ -1731,6 +1801,35 @@ var AutoPaginatable = class {
|
|
|
1731
1801
|
}
|
|
1732
1802
|
};
|
|
1733
1803
|
//#endregion
|
|
1804
|
+
//#region src/api-keys/serializers/create-organization-api-key-options.serializer.ts
|
|
1805
|
+
function serializeCreateOrganizationApiKeyOptions(options) {
|
|
1806
|
+
return {
|
|
1807
|
+
name: options.name,
|
|
1808
|
+
permissions: options.permissions
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
//#endregion
|
|
1812
|
+
//#region src/api-keys/serializers/created-api-key.serializer.ts
|
|
1813
|
+
function deserializeCreatedApiKey(apiKey) {
|
|
1814
|
+
return {
|
|
1815
|
+
object: apiKey.object,
|
|
1816
|
+
id: apiKey.id,
|
|
1817
|
+
owner: apiKey.owner,
|
|
1818
|
+
name: apiKey.name,
|
|
1819
|
+
obfuscatedValue: apiKey.obfuscated_value,
|
|
1820
|
+
value: apiKey.value,
|
|
1821
|
+
lastUsedAt: apiKey.last_used_at,
|
|
1822
|
+
permissions: apiKey.permissions,
|
|
1823
|
+
createdAt: apiKey.created_at,
|
|
1824
|
+
updatedAt: apiKey.updated_at
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
//#endregion
|
|
1828
|
+
//#region src/api-keys/serializers/validate-api-key.serializer.ts
|
|
1829
|
+
function deserializeValidateApiKeyResponse(response) {
|
|
1830
|
+
return { apiKey: response.api_key ? deserializeApiKey(response.api_key) : null };
|
|
1831
|
+
}
|
|
1832
|
+
//#endregion
|
|
1734
1833
|
//#region src/common/utils/fetch-and-deserialize.ts
|
|
1735
1834
|
const setDefaultOptions = (options) => {
|
|
1736
1835
|
return {
|
|
@@ -1746,31 +1845,181 @@ const fetchAndDeserialize = async (workos, endpoint, deserializeFn, options, req
|
|
|
1746
1845
|
return deserializeList(data, deserializeFn);
|
|
1747
1846
|
};
|
|
1748
1847
|
//#endregion
|
|
1848
|
+
//#region src/api-keys/api-keys.ts
|
|
1849
|
+
var ApiKeys = class {
|
|
1850
|
+
constructor(workos) {
|
|
1851
|
+
this.workos = workos;
|
|
1852
|
+
}
|
|
1853
|
+
/**
|
|
1854
|
+
* Validate API key
|
|
1855
|
+
*
|
|
1856
|
+
* Validate an API key value and return the API key object if valid.
|
|
1857
|
+
* @param payload - Object containing value.
|
|
1858
|
+
* @returns {Promise<ApiKeyValidationResponse>}
|
|
1859
|
+
* @throws {UnauthorizedException} 401
|
|
1860
|
+
* @throws {UnprocessableEntityException} 422
|
|
1861
|
+
*/
|
|
1862
|
+
async createValidation(payload) {
|
|
1863
|
+
const { data } = await this.workos.post("/api_keys/validations", payload);
|
|
1864
|
+
return deserializeValidateApiKeyResponse(data);
|
|
1865
|
+
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Delete an API key
|
|
1868
|
+
*
|
|
1869
|
+
* Permanently deletes an API key. This action cannot be undone. Once deleted, any requests using this API key will fail authentication.
|
|
1870
|
+
* @param id - The unique ID of the API key.
|
|
1871
|
+
*
|
|
1872
|
+
* @example
|
|
1873
|
+
* "api_key_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
1874
|
+
*
|
|
1875
|
+
* @returns {Promise<void>}
|
|
1876
|
+
* @throws {NotFoundException} 404
|
|
1877
|
+
*/
|
|
1878
|
+
async deleteApiKey(id) {
|
|
1879
|
+
await this.workos.delete(`/api_keys/${id}`);
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* List API keys for an organization
|
|
1883
|
+
*
|
|
1884
|
+
* Get a list of all API keys for an organization.
|
|
1885
|
+
* @param organizationId - Unique identifier of the Organization.
|
|
1886
|
+
*
|
|
1887
|
+
* @example
|
|
1888
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
1889
|
+
*
|
|
1890
|
+
* @param options - Pagination and filter options.
|
|
1891
|
+
* @returns {Promise<AutoPaginatable<ApiKey>>}
|
|
1892
|
+
* @throws {NotFoundException} 404
|
|
1893
|
+
*/
|
|
1894
|
+
async listOrganizationApiKeys(options) {
|
|
1895
|
+
const { organizationId, ...paginationOptions } = options;
|
|
1896
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/organizations/${organizationId}/api_keys`, deserializeApiKey, paginationOptions), (params) => fetchAndDeserialize(this.workos, `/organizations/${organizationId}/api_keys`, deserializeApiKey, params), paginationOptions);
|
|
1897
|
+
}
|
|
1898
|
+
/**
|
|
1899
|
+
* Create an API key for an organization
|
|
1900
|
+
*
|
|
1901
|
+
* Create a new API key for an organization.
|
|
1902
|
+
* @param organizationId - Unique identifier of the Organization.
|
|
1903
|
+
*
|
|
1904
|
+
* @example
|
|
1905
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
1906
|
+
*
|
|
1907
|
+
* @param options - Object containing name.
|
|
1908
|
+
* @returns {Promise<ApiKeyWithValue>}
|
|
1909
|
+
* @throws {NotFoundException} 404
|
|
1910
|
+
* @throws {UnprocessableEntityException} 422
|
|
1911
|
+
*/
|
|
1912
|
+
async createOrganizationApiKey(options, requestOptions = {}) {
|
|
1913
|
+
const { organizationId } = options;
|
|
1914
|
+
const { data } = await this.workos.post(`/organizations/${organizationId}/api_keys`, serializeCreateOrganizationApiKeyOptions(options), requestOptions);
|
|
1915
|
+
return deserializeCreatedApiKey(data);
|
|
1916
|
+
}
|
|
1917
|
+
};
|
|
1918
|
+
//#endregion
|
|
1749
1919
|
//#region src/directory-sync/directory-sync.ts
|
|
1750
1920
|
var DirectorySync = class {
|
|
1751
1921
|
constructor(workos) {
|
|
1752
1922
|
this.workos = workos;
|
|
1753
1923
|
}
|
|
1924
|
+
/**
|
|
1925
|
+
* List Directories
|
|
1926
|
+
*
|
|
1927
|
+
* Get a list of all of your existing directories matching the criteria specified.
|
|
1928
|
+
* @param options - Pagination and filter options.
|
|
1929
|
+
* @returns {Promise<AutoPaginatable<Directory, SerializedListDirectoriesOptions>>}
|
|
1930
|
+
* @throws 403 response from the API.
|
|
1931
|
+
* @throws {UnprocessableEntityException} 422
|
|
1932
|
+
*/
|
|
1754
1933
|
async listDirectories(options) {
|
|
1755
1934
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/directories", deserializeDirectory, options ? serializeListDirectoriesOptions(options) : void 0), (params) => fetchAndDeserialize(this.workos, "/directories", deserializeDirectory, params), options ? serializeListDirectoriesOptions(options) : void 0);
|
|
1756
1935
|
}
|
|
1936
|
+
/**
|
|
1937
|
+
* Get a Directory
|
|
1938
|
+
*
|
|
1939
|
+
* Get the details of an existing directory.
|
|
1940
|
+
* @param id - Unique identifier for the Directory.
|
|
1941
|
+
*
|
|
1942
|
+
* @example
|
|
1943
|
+
* "directory_01ECAZ4NV9QMV47GW873HDCX74"
|
|
1944
|
+
*
|
|
1945
|
+
* @returns {Promise<Directory>}
|
|
1946
|
+
* @throws 403 response from the API.
|
|
1947
|
+
* @throws {NotFoundException} 404
|
|
1948
|
+
*/
|
|
1757
1949
|
async getDirectory(id) {
|
|
1758
1950
|
const { data } = await this.workos.get(`/directories/${id}`);
|
|
1759
1951
|
return deserializeDirectory(data);
|
|
1760
1952
|
}
|
|
1953
|
+
/**
|
|
1954
|
+
* Delete a Directory
|
|
1955
|
+
*
|
|
1956
|
+
* Permanently deletes an existing directory. It cannot be undone.
|
|
1957
|
+
* @param id - Unique identifier for the Directory.
|
|
1958
|
+
*
|
|
1959
|
+
* @example
|
|
1960
|
+
* "directory_01ECAZ4NV9QMV47GW873HDCX74"
|
|
1961
|
+
*
|
|
1962
|
+
* @returns {Promise<void>}
|
|
1963
|
+
* @throws 403 response from the API.
|
|
1964
|
+
*/
|
|
1761
1965
|
async deleteDirectory(id) {
|
|
1762
1966
|
await this.workos.delete(`/directories/${id}`);
|
|
1763
1967
|
}
|
|
1968
|
+
/**
|
|
1969
|
+
* List Directory Groups
|
|
1970
|
+
*
|
|
1971
|
+
* Get a list of all of existing directory groups matching the criteria specified.
|
|
1972
|
+
* @param options - Pagination and filter options.
|
|
1973
|
+
* @returns {Promise<AutoPaginatable<DirectoryGroup, ListDirectoryGroupsOptions>>}
|
|
1974
|
+
* @throws 403 response from the API.
|
|
1975
|
+
* @throws {NotFoundException} 404
|
|
1976
|
+
* @throws {UnprocessableEntityException} 422
|
|
1977
|
+
*/
|
|
1764
1978
|
async listGroups(options) {
|
|
1765
1979
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/directory_groups", deserializeDirectoryGroup, options), (params) => fetchAndDeserialize(this.workos, "/directory_groups", deserializeDirectoryGroup, params), options);
|
|
1766
1980
|
}
|
|
1981
|
+
/**
|
|
1982
|
+
* List Directory Users
|
|
1983
|
+
*
|
|
1984
|
+
* Get a list of all of existing Directory Users matching the criteria specified.
|
|
1985
|
+
* @param options - Pagination and filter options.
|
|
1986
|
+
* @returns {Promise<AutoPaginatable<DirectoryUserWithGroups<TCustomAttributes>, ListDirectoryUsersOptions>>}
|
|
1987
|
+
* @throws 403 response from the API.
|
|
1988
|
+
* @throws {NotFoundException} 404
|
|
1989
|
+
* @throws {UnprocessableEntityException} 422
|
|
1990
|
+
* @throws {RateLimitExceededException} 429
|
|
1991
|
+
*/
|
|
1767
1992
|
async listUsers(options) {
|
|
1768
1993
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/directory_users", deserializeDirectoryUserWithGroups, options), (params) => fetchAndDeserialize(this.workos, "/directory_users", deserializeDirectoryUserWithGroups, params), options);
|
|
1769
1994
|
}
|
|
1995
|
+
/**
|
|
1996
|
+
* Get a Directory User
|
|
1997
|
+
*
|
|
1998
|
+
* Get the details of an existing Directory User.
|
|
1999
|
+
* @param user - Unique identifier for the Directory User.
|
|
2000
|
+
*
|
|
2001
|
+
* @example
|
|
2002
|
+
* "directory_user_01E1JG7J09H96KYP8HM9B0G5SJ"
|
|
2003
|
+
* @returns {Promise<DirectoryUserWithGroups<TCustomAttributes>>}
|
|
2004
|
+
* @throws 403 response from the API.
|
|
2005
|
+
* @throws {NotFoundException} 404
|
|
2006
|
+
*/
|
|
1770
2007
|
async getUser(user) {
|
|
1771
2008
|
const { data } = await this.workos.get(`/directory_users/${user}`);
|
|
1772
2009
|
return deserializeDirectoryUserWithGroups(data);
|
|
1773
2010
|
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Get a Directory Group
|
|
2013
|
+
*
|
|
2014
|
+
* Get the details of an existing Directory Group.
|
|
2015
|
+
* @param group - Unique identifier for the Directory Group.
|
|
2016
|
+
*
|
|
2017
|
+
* @example
|
|
2018
|
+
* "directory_group_01E1JJS84MFPPQ3G655FHTKX6Z"
|
|
2019
|
+
* @returns {Promise<DirectoryGroup>}
|
|
2020
|
+
* @throws 403 response from the API.
|
|
2021
|
+
* @throws {NotFoundException} 404
|
|
2022
|
+
*/
|
|
1774
2023
|
async getGroup(group) {
|
|
1775
2024
|
const { data } = await this.workos.get(`/directory_groups/${group}`);
|
|
1776
2025
|
return deserializeDirectoryGroup(data);
|
|
@@ -1793,99 +2042,115 @@ var Events = class {
|
|
|
1793
2042
|
constructor(workos) {
|
|
1794
2043
|
this.workos = workos;
|
|
1795
2044
|
}
|
|
2045
|
+
/**
|
|
2046
|
+
* List events
|
|
2047
|
+
*
|
|
2048
|
+
* List events for the current environment.
|
|
2049
|
+
* @param options - Pagination and filter options.
|
|
2050
|
+
* @returns {Promise<List<Event>>}
|
|
2051
|
+
* @throws {BadRequestException} 400
|
|
2052
|
+
* @throws {UnprocessableEntityException} 422
|
|
2053
|
+
*/
|
|
1796
2054
|
async listEvents(options) {
|
|
1797
2055
|
const { data } = await this.workos.get(`/events`, { query: options ? serializeListEventOptions(options) : void 0 });
|
|
1798
2056
|
return deserializeList(data, deserializeEvent);
|
|
1799
2057
|
}
|
|
1800
2058
|
};
|
|
1801
2059
|
//#endregion
|
|
1802
|
-
//#region src/roles/serializers/role.serializer.ts
|
|
1803
|
-
const deserializeRole = (role) => ({
|
|
1804
|
-
object: role.object,
|
|
1805
|
-
id: role.id,
|
|
1806
|
-
name: role.name,
|
|
1807
|
-
slug: role.slug,
|
|
1808
|
-
description: role.description,
|
|
1809
|
-
permissions: role.permissions,
|
|
1810
|
-
resourceTypeSlug: role.resource_type_slug,
|
|
1811
|
-
type: role.type,
|
|
1812
|
-
createdAt: role.created_at,
|
|
1813
|
-
updatedAt: role.updated_at
|
|
1814
|
-
});
|
|
1815
|
-
//#endregion
|
|
1816
|
-
//#region src/api-keys/serializers/create-organization-api-key-options.serializer.ts
|
|
1817
|
-
function serializeCreateOrganizationApiKeyOptions(options) {
|
|
1818
|
-
return {
|
|
1819
|
-
name: options.name,
|
|
1820
|
-
permissions: options.permissions
|
|
1821
|
-
};
|
|
1822
|
-
}
|
|
1823
|
-
//#endregion
|
|
1824
|
-
//#region src/api-keys/serializers/created-api-key.serializer.ts
|
|
1825
|
-
function deserializeCreatedApiKey(apiKey) {
|
|
1826
|
-
return {
|
|
1827
|
-
object: apiKey.object,
|
|
1828
|
-
id: apiKey.id,
|
|
1829
|
-
owner: apiKey.owner,
|
|
1830
|
-
name: apiKey.name,
|
|
1831
|
-
obfuscatedValue: apiKey.obfuscated_value,
|
|
1832
|
-
value: apiKey.value,
|
|
1833
|
-
lastUsedAt: apiKey.last_used_at,
|
|
1834
|
-
permissions: apiKey.permissions,
|
|
1835
|
-
createdAt: apiKey.created_at,
|
|
1836
|
-
updatedAt: apiKey.updated_at
|
|
1837
|
-
};
|
|
1838
|
-
}
|
|
1839
|
-
//#endregion
|
|
1840
2060
|
//#region src/organizations/organizations.ts
|
|
1841
2061
|
var Organizations = class {
|
|
1842
2062
|
constructor(workos) {
|
|
1843
2063
|
this.workos = workos;
|
|
1844
2064
|
}
|
|
2065
|
+
/**
|
|
2066
|
+
* List Organizations
|
|
2067
|
+
*
|
|
2068
|
+
* Get a list of all of your existing organizations matching the criteria specified.
|
|
2069
|
+
* @param options - Pagination and filter options.
|
|
2070
|
+
* @returns {Promise<AutoPaginatable<Organization, ListOrganizationsOptions>>}
|
|
2071
|
+
* @throws {UnprocessableEntityException} 422
|
|
2072
|
+
*/
|
|
1845
2073
|
async listOrganizations(options) {
|
|
1846
2074
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/organizations", deserializeOrganization, options), (params) => fetchAndDeserialize(this.workos, "/organizations", deserializeOrganization, params), options);
|
|
1847
2075
|
}
|
|
2076
|
+
/**
|
|
2077
|
+
* Create an Organization
|
|
2078
|
+
*
|
|
2079
|
+
* Creates a new organization in the current environment.
|
|
2080
|
+
* @param payload - Object containing name.
|
|
2081
|
+
* @returns {Promise<Organization>}
|
|
2082
|
+
* @throws {BadRequestException} 400
|
|
2083
|
+
* @throws {ConflictException} 409
|
|
2084
|
+
* @throws {UnprocessableEntityException} 422
|
|
2085
|
+
*/
|
|
1848
2086
|
async createOrganization(payload, requestOptions = {}) {
|
|
1849
2087
|
const { data } = await this.workos.post("/organizations", serializeCreateOrganizationOptions(payload), requestOptions);
|
|
1850
2088
|
return deserializeOrganization(data);
|
|
1851
2089
|
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Delete an Organization
|
|
2092
|
+
*
|
|
2093
|
+
* Permanently deletes an organization in the current environment. It cannot be undone.
|
|
2094
|
+
* @param id - Unique identifier of the Organization.
|
|
2095
|
+
*
|
|
2096
|
+
* @example
|
|
2097
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
2098
|
+
*
|
|
2099
|
+
* @returns {Promise<void>}
|
|
2100
|
+
* @throws 403 response from the API.
|
|
2101
|
+
*/
|
|
1852
2102
|
async deleteOrganization(id) {
|
|
1853
2103
|
await this.workos.delete(`/organizations/${id}`);
|
|
1854
2104
|
}
|
|
2105
|
+
/**
|
|
2106
|
+
* Get an Organization
|
|
2107
|
+
*
|
|
2108
|
+
* Get the details of an existing organization.
|
|
2109
|
+
* @param id - Unique identifier of the Organization.
|
|
2110
|
+
*
|
|
2111
|
+
* @example
|
|
2112
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
2113
|
+
*
|
|
2114
|
+
* @returns {Promise<Organization>}
|
|
2115
|
+
* @throws {NotFoundException} 404
|
|
2116
|
+
*/
|
|
1855
2117
|
async getOrganization(id) {
|
|
1856
2118
|
const { data } = await this.workos.get(`/organizations/${id}`);
|
|
1857
2119
|
return deserializeOrganization(data);
|
|
1858
2120
|
}
|
|
2121
|
+
/**
|
|
2122
|
+
* Get an Organization by External ID
|
|
2123
|
+
*
|
|
2124
|
+
* Get the details of an existing organization by an [external identifier](https://workos.com/docs/authkit/metadata/external-identifiers).
|
|
2125
|
+
* @param externalId - The external ID of the Organization.
|
|
2126
|
+
*
|
|
2127
|
+
* @example
|
|
2128
|
+
* "2fe01467-f7ea-4dd2-8b79-c2b4f56d0191"
|
|
2129
|
+
*
|
|
2130
|
+
* @returns {Promise<Organization>}
|
|
2131
|
+
* @throws {NotFoundException} 404
|
|
2132
|
+
*/
|
|
1859
2133
|
async getOrganizationByExternalId(externalId) {
|
|
1860
2134
|
const { data } = await this.workos.get(`/organizations/external_id/${externalId}`);
|
|
1861
2135
|
return deserializeOrganization(data);
|
|
1862
2136
|
}
|
|
2137
|
+
/**
|
|
2138
|
+
* Update an Organization
|
|
2139
|
+
*
|
|
2140
|
+
* Updates an organization in the current environment.
|
|
2141
|
+
* @param payload - The request body.
|
|
2142
|
+
* @returns {Promise<Organization>}
|
|
2143
|
+
* @throws {BadRequestException} 400
|
|
2144
|
+
* @throws 403 response from the API.
|
|
2145
|
+
* @throws {NotFoundException} 404
|
|
2146
|
+
* @throws {ConflictException} 409
|
|
2147
|
+
* @throws {UnprocessableEntityException} 422
|
|
2148
|
+
*/
|
|
1863
2149
|
async updateOrganization(options) {
|
|
1864
2150
|
const { organization: organizationId, ...payload } = options;
|
|
1865
2151
|
const { data } = await this.workos.put(`/organizations/${organizationId}`, serializeUpdateOrganizationOptions(payload));
|
|
1866
2152
|
return deserializeOrganization(data);
|
|
1867
2153
|
}
|
|
1868
|
-
async listOrganizationRoles(options) {
|
|
1869
|
-
const { organizationId } = options;
|
|
1870
|
-
const { data: response } = await this.workos.get(`/organizations/${organizationId}/roles`);
|
|
1871
|
-
return {
|
|
1872
|
-
object: "list",
|
|
1873
|
-
data: response.data.map((role) => deserializeRole(role))
|
|
1874
|
-
};
|
|
1875
|
-
}
|
|
1876
|
-
async listOrganizationFeatureFlags(options) {
|
|
1877
|
-
const { organizationId, ...paginationOptions } = options;
|
|
1878
|
-
return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/organizations/${organizationId}/feature-flags`, deserializeFeatureFlag, paginationOptions), (params) => fetchAndDeserialize(this.workos, `/organizations/${organizationId}/feature-flags`, deserializeFeatureFlag, params), paginationOptions);
|
|
1879
|
-
}
|
|
1880
|
-
async listOrganizationApiKeys(options) {
|
|
1881
|
-
const { organizationId, ...paginationOptions } = options;
|
|
1882
|
-
return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/organizations/${organizationId}/api_keys`, deserializeApiKey, paginationOptions), (params) => fetchAndDeserialize(this.workos, `/organizations/${organizationId}/api_keys`, deserializeApiKey, params), paginationOptions);
|
|
1883
|
-
}
|
|
1884
|
-
async createOrganizationApiKey(options, requestOptions = {}) {
|
|
1885
|
-
const { organizationId } = options;
|
|
1886
|
-
const { data } = await this.workos.post(`/organizations/${organizationId}/api_keys`, serializeCreateOrganizationApiKeyOptions(options), requestOptions);
|
|
1887
|
-
return deserializeCreatedApiKey(data);
|
|
1888
|
-
}
|
|
1889
2154
|
};
|
|
1890
2155
|
//#endregion
|
|
1891
2156
|
//#region src/organization-domains/serializers/create-organization-domain-options.serializer.ts
|
|
@@ -1899,19 +2164,63 @@ var OrganizationDomains = class {
|
|
|
1899
2164
|
constructor(workos) {
|
|
1900
2165
|
this.workos = workos;
|
|
1901
2166
|
}
|
|
1902
|
-
|
|
2167
|
+
/**
|
|
2168
|
+
* Get an Organization Domain
|
|
2169
|
+
*
|
|
2170
|
+
* Get the details of an existing organization domain.
|
|
2171
|
+
* @param id - Unique identifier of the organization domain.
|
|
2172
|
+
*
|
|
2173
|
+
* @example
|
|
2174
|
+
* "org_domain_01EHZNVPK2QXHMVWCEDQEKY69A"
|
|
2175
|
+
*
|
|
2176
|
+
* @returns {Promise<OrganizationDomain>}
|
|
2177
|
+
* @throws {NotFoundException} 404
|
|
2178
|
+
*/
|
|
2179
|
+
async getOrganizationDomain(id) {
|
|
1903
2180
|
const { data } = await this.workos.get(`/organization_domains/${id}`);
|
|
1904
2181
|
return deserializeOrganizationDomain(data);
|
|
1905
2182
|
}
|
|
1906
|
-
|
|
1907
|
-
|
|
2183
|
+
/**
|
|
2184
|
+
* Verify an Organization Domain
|
|
2185
|
+
*
|
|
2186
|
+
* Initiates verification process for an Organization Domain.
|
|
2187
|
+
* @param id - Unique identifier of the organization domain.
|
|
2188
|
+
*
|
|
2189
|
+
* @example
|
|
2190
|
+
* "org_domain_01EHZNVPK2QXHMVWCEDQEKY69A"
|
|
2191
|
+
*
|
|
2192
|
+
* @returns {Promise<OrganizationDomain>}
|
|
2193
|
+
* @throws {BadRequestException} 400
|
|
2194
|
+
*/
|
|
2195
|
+
async verifyOrganizationDomain(id) {
|
|
2196
|
+
const { data } = await this.workos.post(`/organization_domains/${id}/verify`, {});
|
|
1908
2197
|
return deserializeOrganizationDomain(data);
|
|
1909
2198
|
}
|
|
1910
|
-
|
|
2199
|
+
/**
|
|
2200
|
+
* Create an Organization Domain
|
|
2201
|
+
*
|
|
2202
|
+
* Creates a new Organization Domain.
|
|
2203
|
+
* @param payload - Object containing domain, organizationId.
|
|
2204
|
+
* @returns {Promise<OrganizationDomain>}
|
|
2205
|
+
* @throws {ConflictException} 409
|
|
2206
|
+
*/
|
|
2207
|
+
async createOrganizationDomain(payload) {
|
|
1911
2208
|
const { data } = await this.workos.post(`/organization_domains`, serializeCreateOrganizationDomainOptions(payload));
|
|
1912
2209
|
return deserializeOrganizationDomain(data);
|
|
1913
2210
|
}
|
|
1914
|
-
|
|
2211
|
+
/**
|
|
2212
|
+
* Delete an Organization Domain
|
|
2213
|
+
*
|
|
2214
|
+
* Permanently deletes an organization domain. It cannot be undone.
|
|
2215
|
+
* @param id - Unique identifier of the organization domain.
|
|
2216
|
+
*
|
|
2217
|
+
* @example
|
|
2218
|
+
* "org_domain_01EHZNVPK2QXHMVWCEDQEKY69A"
|
|
2219
|
+
*
|
|
2220
|
+
* @returns {Promise<void>}
|
|
2221
|
+
* @throws {NotFoundException} 404
|
|
2222
|
+
*/
|
|
2223
|
+
async deleteOrganizationDomain(id) {
|
|
1915
2224
|
await this.workos.delete(`/organization_domains/${id}`);
|
|
1916
2225
|
}
|
|
1917
2226
|
};
|
|
@@ -1984,17 +2293,33 @@ var Pipes = class {
|
|
|
1984
2293
|
}
|
|
1985
2294
|
};
|
|
1986
2295
|
//#endregion
|
|
1987
|
-
//#region src/portal/portal.ts
|
|
1988
|
-
var
|
|
2296
|
+
//#region src/admin-portal/admin-portal.ts
|
|
2297
|
+
var AdminPortal = class {
|
|
1989
2298
|
constructor(workos) {
|
|
1990
2299
|
this.workos = workos;
|
|
1991
2300
|
}
|
|
1992
|
-
|
|
2301
|
+
/**
|
|
2302
|
+
* Generate a Portal Link
|
|
2303
|
+
*
|
|
2304
|
+
* Generate a Portal Link scoped to an Organization.
|
|
2305
|
+
* @param payload - Object containing organization.
|
|
2306
|
+
* @returns {Promise<{ link: string; }>}
|
|
2307
|
+
* @throws {BadRequestException} 400
|
|
2308
|
+
* @throws 403 response from the API.
|
|
2309
|
+
* @throws {NotFoundException} 404
|
|
2310
|
+
* @throws {UnprocessableEntityException} 422
|
|
2311
|
+
*/
|
|
2312
|
+
async generateLink({ intent, organization, returnUrl, successUrl, intentOptions, adminEmails }) {
|
|
1993
2313
|
const { data } = await this.workos.post("/portal/generate_link", {
|
|
1994
2314
|
intent,
|
|
1995
2315
|
organization,
|
|
1996
2316
|
return_url: returnUrl,
|
|
1997
|
-
success_url: successUrl
|
|
2317
|
+
success_url: successUrl,
|
|
2318
|
+
intent_options: intentOptions ? { sso: {
|
|
2319
|
+
bookmark_slug: intentOptions.sso.bookmarkSlug,
|
|
2320
|
+
provider_type: intentOptions.sso.providerType
|
|
2321
|
+
} } : void 0,
|
|
2322
|
+
admin_emails: adminEmails
|
|
1998
2323
|
});
|
|
1999
2324
|
return data;
|
|
2000
2325
|
}
|
|
@@ -2036,9 +2361,31 @@ var SSO = class {
|
|
|
2036
2361
|
constructor(workos) {
|
|
2037
2362
|
this.workos = workos;
|
|
2038
2363
|
}
|
|
2364
|
+
/**
|
|
2365
|
+
* List Connections
|
|
2366
|
+
*
|
|
2367
|
+
* Get a list of all of your existing connections matching the criteria specified.
|
|
2368
|
+
* @param options - Pagination and filter options.
|
|
2369
|
+
* @returns {Promise<AutoPaginatable<Connection, SerializedListConnectionsOptions>>}
|
|
2370
|
+
* @throws 403 response from the API.
|
|
2371
|
+
* @throws {UnprocessableEntityException} 422
|
|
2372
|
+
*/
|
|
2039
2373
|
async listConnections(options) {
|
|
2040
2374
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/connections", deserializeConnection, options ? serializeListConnectionsOptions(options) : void 0), (params) => fetchAndDeserialize(this.workos, "/connections", deserializeConnection, params), options ? serializeListConnectionsOptions(options) : void 0);
|
|
2041
2375
|
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Delete a Connection
|
|
2378
|
+
*
|
|
2379
|
+
* Permanently deletes an existing connection. It cannot be undone.
|
|
2380
|
+
* @param id - Unique identifier for the Connection.
|
|
2381
|
+
*
|
|
2382
|
+
* @example
|
|
2383
|
+
* "conn_01E4ZCR3C56J083X43JQXF3JK5"
|
|
2384
|
+
*
|
|
2385
|
+
* @returns {Promise<void>}
|
|
2386
|
+
* @throws 403 response from the API.
|
|
2387
|
+
* @throws {NotFoundException} 404
|
|
2388
|
+
*/
|
|
2042
2389
|
async deleteConnection(id) {
|
|
2043
2390
|
await this.workos.delete(`/connections/${id}`);
|
|
2044
2391
|
}
|
|
@@ -2112,6 +2459,19 @@ var SSO = class {
|
|
|
2112
2459
|
codeVerifier: pkce.codeVerifier
|
|
2113
2460
|
};
|
|
2114
2461
|
}
|
|
2462
|
+
/**
|
|
2463
|
+
* Get a Connection
|
|
2464
|
+
*
|
|
2465
|
+
* Get the details of an existing connection.
|
|
2466
|
+
* @param id - Unique identifier for the Connection.
|
|
2467
|
+
*
|
|
2468
|
+
* @example
|
|
2469
|
+
* "conn_01E4ZCR3C56J083X43JQXF3JK5"
|
|
2470
|
+
*
|
|
2471
|
+
* @returns {Promise<Connection>}
|
|
2472
|
+
* @throws 403 response from the API.
|
|
2473
|
+
* @throws {NotFoundException} 404
|
|
2474
|
+
*/
|
|
2115
2475
|
async getConnection(id) {
|
|
2116
2476
|
const { data } = await this.workos.get(`/connections/${id}`);
|
|
2117
2477
|
return deserializeConnection(data);
|
|
@@ -2144,13 +2504,21 @@ var SSO = class {
|
|
|
2144
2504
|
const { data } = await this.workos.post("/sso/token", form, { skipApiKeyCheck: !hasApiKey });
|
|
2145
2505
|
return deserializeProfileAndToken(data);
|
|
2146
2506
|
}
|
|
2507
|
+
/**
|
|
2508
|
+
* Get a User Profile
|
|
2509
|
+
*
|
|
2510
|
+
* Exchange an access token for a user's [Profile](https://workos.com/docs/reference/sso/profile). Because this profile is returned in the [Get a Profile and Token endpoint](https://workos.com/docs/reference/sso/profile/get-profile-and-token) your application usually does not need to call this endpoint. It is available for any authentication flows that require an additional endpoint to retrieve a user's profile.
|
|
2511
|
+
* @returns {Promise<Profile<CustomAttributesType>>}
|
|
2512
|
+
* @throws {UnauthorizedException} 401
|
|
2513
|
+
* @throws {NotFoundException} 404
|
|
2514
|
+
*/
|
|
2147
2515
|
async getProfile({ accessToken }) {
|
|
2148
2516
|
const { data } = await this.workos.get("/sso/profile", { accessToken });
|
|
2149
2517
|
return deserializeProfile(data);
|
|
2150
2518
|
}
|
|
2151
2519
|
};
|
|
2152
2520
|
//#endregion
|
|
2153
|
-
//#region src/
|
|
2521
|
+
//#region src/multi-factor-auth/serializers/challenge.serializer.ts
|
|
2154
2522
|
const deserializeChallenge = (challenge) => ({
|
|
2155
2523
|
object: challenge.object,
|
|
2156
2524
|
id: challenge.id,
|
|
@@ -2161,10 +2529,10 @@ const deserializeChallenge = (challenge) => ({
|
|
|
2161
2529
|
authenticationFactorId: challenge.authentication_factor_id
|
|
2162
2530
|
});
|
|
2163
2531
|
//#endregion
|
|
2164
|
-
//#region src/
|
|
2532
|
+
//#region src/multi-factor-auth/serializers/sms.serializer.ts
|
|
2165
2533
|
const deserializeSms = (sms) => ({ phoneNumber: sms.phone_number });
|
|
2166
2534
|
//#endregion
|
|
2167
|
-
//#region src/
|
|
2535
|
+
//#region src/multi-factor-auth/serializers/factor.serializer.ts
|
|
2168
2536
|
const deserializeFactor = (factor) => ({
|
|
2169
2537
|
object: factor.object,
|
|
2170
2538
|
id: factor.id,
|
|
@@ -2184,24 +2552,56 @@ const deserializeFactorWithSecrets = (factor) => ({
|
|
|
2184
2552
|
...factor.totp ? { totp: deserializeTotpWithSecrets(factor.totp) } : {}
|
|
2185
2553
|
});
|
|
2186
2554
|
//#endregion
|
|
2187
|
-
//#region src/
|
|
2555
|
+
//#region src/multi-factor-auth/serializers/verify-response.serializer.ts
|
|
2188
2556
|
const deserializeVerifyResponse = (verifyResponse) => ({
|
|
2189
2557
|
challenge: deserializeChallenge(verifyResponse.challenge),
|
|
2190
2558
|
valid: verifyResponse.valid
|
|
2191
2559
|
});
|
|
2192
2560
|
//#endregion
|
|
2193
|
-
//#region src/
|
|
2194
|
-
var
|
|
2561
|
+
//#region src/multi-factor-auth/multi-factor-auth.ts
|
|
2562
|
+
var MultiFactorAuth = class {
|
|
2195
2563
|
constructor(workos) {
|
|
2196
2564
|
this.workos = workos;
|
|
2197
2565
|
}
|
|
2566
|
+
/**
|
|
2567
|
+
* Delete Factor
|
|
2568
|
+
*
|
|
2569
|
+
* Permanently deletes an Authentication Factor. It cannot be undone.
|
|
2570
|
+
* @param id - The unique ID of the Factor.
|
|
2571
|
+
*
|
|
2572
|
+
* @example
|
|
2573
|
+
* "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ"
|
|
2574
|
+
*
|
|
2575
|
+
* @returns {Promise<void>}
|
|
2576
|
+
* @throws {NotFoundException} 404
|
|
2577
|
+
*/
|
|
2198
2578
|
async deleteFactor(id) {
|
|
2199
2579
|
await this.workos.delete(`/auth/factors/${id}`);
|
|
2200
2580
|
}
|
|
2581
|
+
/**
|
|
2582
|
+
* Get Factor
|
|
2583
|
+
*
|
|
2584
|
+
* Gets an Authentication Factor.
|
|
2585
|
+
* @param id - The unique ID of the Factor.
|
|
2586
|
+
*
|
|
2587
|
+
* @example
|
|
2588
|
+
* "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ"
|
|
2589
|
+
*
|
|
2590
|
+
* @returns {Promise<Factor>}
|
|
2591
|
+
* @throws {NotFoundException} 404
|
|
2592
|
+
*/
|
|
2201
2593
|
async getFactor(id) {
|
|
2202
2594
|
const { data } = await this.workos.get(`/auth/factors/${id}`);
|
|
2203
2595
|
return deserializeFactor(data);
|
|
2204
2596
|
}
|
|
2597
|
+
/**
|
|
2598
|
+
* Enroll Factor
|
|
2599
|
+
*
|
|
2600
|
+
* Enrolls an Authentication Factor to be used as an additional factor of authentication. The returned ID should be used to create an authentication Challenge.
|
|
2601
|
+
* @param options - Object containing type.
|
|
2602
|
+
* @returns {Promise<FactorWithSecrets>}
|
|
2603
|
+
* @throws {UnprocessableEntityException} 422
|
|
2604
|
+
*/
|
|
2205
2605
|
async enrollFactor(options) {
|
|
2206
2606
|
const { data } = await this.workos.post("/auth/factors/enroll", {
|
|
2207
2607
|
type: options.type,
|
|
@@ -2218,14 +2618,60 @@ var Mfa = class {
|
|
|
2218
2618
|
});
|
|
2219
2619
|
return deserializeFactorWithSecrets(data);
|
|
2220
2620
|
}
|
|
2621
|
+
/**
|
|
2622
|
+
* Challenge Factor
|
|
2623
|
+
*
|
|
2624
|
+
* Creates a Challenge for an Authentication Factor.
|
|
2625
|
+
* @param options - The request body.
|
|
2626
|
+
* @returns {Promise<Challenge>}
|
|
2627
|
+
* @throws {NotFoundException} 404
|
|
2628
|
+
* @throws {UnprocessableEntityException} 422
|
|
2629
|
+
*/
|
|
2221
2630
|
async challengeFactor(options) {
|
|
2222
2631
|
const { data } = await this.workos.post(`/auth/factors/${options.authenticationFactorId}/challenge`, { sms_template: "smsTemplate" in options ? options.smsTemplate : void 0 });
|
|
2223
2632
|
return deserializeChallenge(data);
|
|
2224
2633
|
}
|
|
2634
|
+
/**
|
|
2635
|
+
* Verify Challenge
|
|
2636
|
+
*
|
|
2637
|
+
* Verifies an Authentication Challenge.
|
|
2638
|
+
* @param options - Object containing code.
|
|
2639
|
+
* @returns {Promise<VerifyResponse>}
|
|
2640
|
+
* @throws {BadRequestException} 400
|
|
2641
|
+
* @throws {NotFoundException} 404
|
|
2642
|
+
* @throws {UnprocessableEntityException} 422
|
|
2643
|
+
*/
|
|
2225
2644
|
async verifyChallenge(options) {
|
|
2226
2645
|
const { data } = await this.workos.post(`/auth/challenges/${options.authenticationChallengeId}/verify`, { code: options.code });
|
|
2227
2646
|
return deserializeVerifyResponse(data);
|
|
2228
2647
|
}
|
|
2648
|
+
/**
|
|
2649
|
+
* Enroll an authentication factor
|
|
2650
|
+
*
|
|
2651
|
+
* Enrolls a user in a new [authentication factor](https://workos.com/docs/reference/authkit/mfa/authentication-factor).
|
|
2652
|
+
* @param payload - Object containing type.
|
|
2653
|
+
* @returns {Promise<{authenticationFactor: UMFactorWithSecrets; authenticationChallenge: Challenge}>}
|
|
2654
|
+
* @throws {UnprocessableEntityException} 422
|
|
2655
|
+
*/
|
|
2656
|
+
async createUserAuthFactor(payload) {
|
|
2657
|
+
const { data } = await this.workos.post(`/user_management/users/${payload.userId}/auth_factors`, serializeEnrollAuthFactorOptions(payload));
|
|
2658
|
+
return {
|
|
2659
|
+
authenticationFactor: deserializeFactorWithSecrets$1(data.authentication_factor),
|
|
2660
|
+
authenticationChallenge: deserializeChallenge(data.authentication_challenge)
|
|
2661
|
+
};
|
|
2662
|
+
}
|
|
2663
|
+
/**
|
|
2664
|
+
* List authentication factors
|
|
2665
|
+
*
|
|
2666
|
+
* Lists the [authentication factors](https://workos.com/docs/reference/authkit/mfa/authentication-factor) for a user.
|
|
2667
|
+
* @param options - Pagination and filter options.
|
|
2668
|
+
* @returns {Promise<AutoPaginatable<UMFactor, PaginationOptions>>}
|
|
2669
|
+
* @throws {UnprocessableEntityException} 422
|
|
2670
|
+
*/
|
|
2671
|
+
async listUserAuthFactors(options) {
|
|
2672
|
+
const { userId, ...restOfOptions } = options;
|
|
2673
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/user_management/users/${userId}/auth_factors`, deserializeFactor$1, restOfOptions), (params) => fetchAndDeserialize(this.workos, `/user_management/users/${userId}/auth_factors`, deserializeFactor$1, params), restOfOptions);
|
|
2674
|
+
}
|
|
2229
2675
|
};
|
|
2230
2676
|
//#endregion
|
|
2231
2677
|
//#region src/audit-logs/serializers/audit-log-export.serializer.ts
|
|
@@ -2304,13 +2750,11 @@ function deserializeMetadata(metadata) {
|
|
|
2304
2750
|
const deserializeAuditLogSchema = (auditLogSchema) => ({
|
|
2305
2751
|
object: auditLogSchema.object,
|
|
2306
2752
|
version: auditLogSchema.version,
|
|
2307
|
-
targets: auditLogSchema.targets.map((target) => {
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
}),
|
|
2313
|
-
actor: { metadata: deserializeMetadata(auditLogSchema.actor?.metadata) },
|
|
2753
|
+
targets: auditLogSchema.targets.map((target) => ({
|
|
2754
|
+
type: target.type,
|
|
2755
|
+
metadata: target.metadata ? deserializeMetadata(target.metadata) : void 0
|
|
2756
|
+
})),
|
|
2757
|
+
actor: auditLogSchema.actor ? { metadata: deserializeMetadata(auditLogSchema.actor.metadata) } : void 0,
|
|
2314
2758
|
metadata: auditLogSchema.metadata ? deserializeMetadata(auditLogSchema.metadata) : void 0,
|
|
2315
2759
|
createdAt: auditLogSchema.created_at
|
|
2316
2760
|
});
|
|
@@ -2320,6 +2764,23 @@ var AuditLogs = class {
|
|
|
2320
2764
|
constructor(workos) {
|
|
2321
2765
|
this.workos = workos;
|
|
2322
2766
|
}
|
|
2767
|
+
/**
|
|
2768
|
+
* Create Event
|
|
2769
|
+
*
|
|
2770
|
+
* Create an Audit Log Event.
|
|
2771
|
+
*
|
|
2772
|
+
* This API supports idempotency which guarantees that performing the same operation multiple times will have the same result as if the operation were performed only once. This is handy in situations where you may need to retry a request due to a failure or prevent accidental duplicate requests from creating more than one resource.
|
|
2773
|
+
*
|
|
2774
|
+
* To achieve idempotency, you can add `Idempotency-Key` request header to a Create Event request with a unique string as the value. Each subsequent request matching this unique string will return the same response. We suggest using [v4 UUIDs](https://en.wikipedia.org/wiki/Universally_unique_identifier) for idempotency keys to avoid collisions.
|
|
2775
|
+
*
|
|
2776
|
+
* Idempotency keys expire after 24 hours. The API will generate a new response if you submit a request with an expired key.
|
|
2777
|
+
* @param payload - Object containing organizationId, event.
|
|
2778
|
+
* @returns {Promise<void>}
|
|
2779
|
+
* @throws {BadRequestException} 400
|
|
2780
|
+
* @throws {NotFoundException} 404
|
|
2781
|
+
* @throws {UnprocessableEntityException} 422
|
|
2782
|
+
* @throws {RateLimitExceededException} 429
|
|
2783
|
+
*/
|
|
2323
2784
|
async createEvent(organization, event, options = {}) {
|
|
2324
2785
|
const optionsWithIdempotency = {
|
|
2325
2786
|
...options,
|
|
@@ -2330,18 +2791,50 @@ var AuditLogs = class {
|
|
|
2330
2791
|
organization_id: organization
|
|
2331
2792
|
}, optionsWithIdempotency);
|
|
2332
2793
|
}
|
|
2794
|
+
/**
|
|
2795
|
+
* Create Export
|
|
2796
|
+
*
|
|
2797
|
+
* Create an Audit Log Export. Exports are scoped to a single organization within a specified date range.
|
|
2798
|
+
* @param payload - Object containing organizationId, rangeStart, rangeEnd.
|
|
2799
|
+
* @returns {Promise<AuditLogExport>}
|
|
2800
|
+
* @throws {BadRequestException} 400
|
|
2801
|
+
*/
|
|
2333
2802
|
async createExport(options) {
|
|
2334
2803
|
const { data } = await this.workos.post("/audit_logs/exports", serializeAuditLogExportOptions(options));
|
|
2335
2804
|
return deserializeAuditLogExport(data);
|
|
2336
2805
|
}
|
|
2806
|
+
/**
|
|
2807
|
+
* Get Export
|
|
2808
|
+
*
|
|
2809
|
+
* Get an Audit Log Export. The URL will expire after 10 minutes. If the export is needed again at a later time, refetching the export will regenerate the URL.
|
|
2810
|
+
* @param auditLogExportId - The unique ID of the Audit Log Export.
|
|
2811
|
+
*
|
|
2812
|
+
* @example
|
|
2813
|
+
* "audit_log_export_01GBZK5MP7TD1YCFQHFR22180V"
|
|
2814
|
+
*
|
|
2815
|
+
* @returns {Promise<AuditLogExport>}
|
|
2816
|
+
* @throws {NotFoundException} 404
|
|
2817
|
+
*/
|
|
2337
2818
|
async getExport(auditLogExportId) {
|
|
2338
2819
|
const { data } = await this.workos.get(`/audit_logs/exports/${auditLogExportId}`);
|
|
2339
2820
|
return deserializeAuditLogExport(data);
|
|
2340
2821
|
}
|
|
2822
|
+
/**
|
|
2823
|
+
* Create Schema
|
|
2824
|
+
*
|
|
2825
|
+
* Creates a new Audit Log schema used to validate the payload of incoming Audit Log Events. If the `action` does not exist, it will also be created.
|
|
2826
|
+
* @param payload - Object containing targets.
|
|
2827
|
+
* @returns {Promise<AuditLogSchema>}
|
|
2828
|
+
* @throws {UnprocessableEntityException} 422
|
|
2829
|
+
*/
|
|
2341
2830
|
async createSchema(schema, options = {}) {
|
|
2342
2831
|
const { data } = await this.workos.post(`/audit_logs/actions/${schema.action}/schemas`, serializeCreateAuditLogSchemaOptions(schema), options);
|
|
2343
2832
|
return deserializeAuditLogSchema(data);
|
|
2344
2833
|
}
|
|
2834
|
+
async listSchemas(action, options) {
|
|
2835
|
+
const endpoint = `/audit_logs/actions/${action}/schemas`;
|
|
2836
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeAuditLogSchema, options), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeAuditLogSchema, params), options);
|
|
2837
|
+
}
|
|
2345
2838
|
};
|
|
2346
2839
|
//#endregion
|
|
2347
2840
|
//#region node_modules/uint8array-extras/index.js
|
|
@@ -2730,12 +3223,16 @@ const serializeCreateOrganizationMembershipOptions = (options) => ({
|
|
|
2730
3223
|
});
|
|
2731
3224
|
//#endregion
|
|
2732
3225
|
//#region src/user-management/serializers/identity.serializer.ts
|
|
3226
|
+
const normalizeProvider = (provider) => {
|
|
3227
|
+
if (provider === "GithubOAuth") return "GitHubOAuth";
|
|
3228
|
+
return provider;
|
|
3229
|
+
};
|
|
2733
3230
|
const deserializeIdentities = (identities) => {
|
|
2734
3231
|
return identities.map((identity) => {
|
|
2735
3232
|
return {
|
|
2736
3233
|
idpId: identity.idp_id,
|
|
2737
3234
|
type: identity.type,
|
|
2738
|
-
provider: identity.provider
|
|
3235
|
+
provider: normalizeProvider(identity.provider)
|
|
2739
3236
|
};
|
|
2740
3237
|
});
|
|
2741
3238
|
};
|
|
@@ -2983,21 +3480,60 @@ var UserManagement = class {
|
|
|
2983
3480
|
loadSealedSession(options) {
|
|
2984
3481
|
return new CookieSession(this, options.sessionData, options.cookiePassword);
|
|
2985
3482
|
}
|
|
3483
|
+
/**
|
|
3484
|
+
* Get a user
|
|
3485
|
+
*
|
|
3486
|
+
* Get the details of an existing user.
|
|
3487
|
+
* @param userId - The unique ID of the user.
|
|
3488
|
+
* @returns {Promise<User>}
|
|
3489
|
+
* @throws {NotFoundException} 404
|
|
3490
|
+
*/
|
|
2986
3491
|
async getUser(userId) {
|
|
2987
3492
|
const { data } = await this.workos.get(`/user_management/users/${userId}`);
|
|
2988
3493
|
return deserializeUser(data);
|
|
2989
3494
|
}
|
|
3495
|
+
/**
|
|
3496
|
+
* Get a user by external ID
|
|
3497
|
+
*
|
|
3498
|
+
* Get the details of an existing user by an [external identifier](https://workos.com/docs/authkit/metadata/external-identifiers).
|
|
3499
|
+
* @param externalId - The external ID of the user.
|
|
3500
|
+
*
|
|
3501
|
+
* @example
|
|
3502
|
+
* "f1ffa2b2-c20b-4d39-be5c-212726e11222"
|
|
3503
|
+
*
|
|
3504
|
+
* @returns {Promise<User>}
|
|
3505
|
+
* @throws {NotFoundException} 404
|
|
3506
|
+
*/
|
|
2990
3507
|
async getUserByExternalId(externalId) {
|
|
2991
3508
|
const { data } = await this.workos.get(`/user_management/users/external_id/${externalId}`);
|
|
2992
3509
|
return deserializeUser(data);
|
|
2993
3510
|
}
|
|
3511
|
+
/**
|
|
3512
|
+
* List users
|
|
3513
|
+
*
|
|
3514
|
+
* Get a list of all of your existing users matching the criteria specified.
|
|
3515
|
+
* @param options - Pagination and filter options.
|
|
3516
|
+
* @returns {Promise<AutoPaginatable<User, SerializedListUsersOptions>>}
|
|
3517
|
+
* @throws {UnprocessableEntityException} 422
|
|
3518
|
+
*/
|
|
2994
3519
|
async listUsers(options) {
|
|
2995
3520
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/user_management/users", deserializeUser, options ? serializeListUsersOptions(options) : void 0), (params) => fetchAndDeserialize(this.workos, "/user_management/users", deserializeUser, params), options ? serializeListUsersOptions(options) : void 0);
|
|
2996
3521
|
}
|
|
3522
|
+
/**
|
|
3523
|
+
* Create a user
|
|
3524
|
+
*
|
|
3525
|
+
* Create a new user in the current environment.
|
|
3526
|
+
* @param payload - Object containing email.
|
|
3527
|
+
* @returns {Promise<User>}
|
|
3528
|
+
* @throws {BadRequestException} 400
|
|
3529
|
+
* @throws {NotFoundException} 404
|
|
3530
|
+
* @throws {UnprocessableEntityException} 422
|
|
3531
|
+
*/
|
|
2997
3532
|
async createUser(payload) {
|
|
2998
3533
|
const { data } = await this.workos.post("/user_management/users", serializeCreateUserOptions(payload));
|
|
2999
3534
|
return deserializeUser(data);
|
|
3000
3535
|
}
|
|
3536
|
+
/** Authenticate with magic auth. */
|
|
3001
3537
|
async authenticateWithMagicAuth(payload) {
|
|
3002
3538
|
const { session, clientId, ...remainingPayload } = payload;
|
|
3003
3539
|
const resolvedClientId = this.resolveClientId(clientId);
|
|
@@ -3011,6 +3547,7 @@ var UserManagement = class {
|
|
|
3011
3547
|
session
|
|
3012
3548
|
});
|
|
3013
3549
|
}
|
|
3550
|
+
/** Authenticate with password. */
|
|
3014
3551
|
async authenticateWithPassword(payload) {
|
|
3015
3552
|
const { session, clientId, ...remainingPayload } = payload;
|
|
3016
3553
|
const resolvedClientId = this.resolveClientId(clientId);
|
|
@@ -3098,6 +3635,7 @@ var UserManagement = class {
|
|
|
3098
3635
|
session
|
|
3099
3636
|
});
|
|
3100
3637
|
}
|
|
3638
|
+
/** Authenticate with totp. */
|
|
3101
3639
|
async authenticateWithTotp(payload) {
|
|
3102
3640
|
const { session, clientId, ...remainingPayload } = payload;
|
|
3103
3641
|
const resolvedClientId = this.resolveClientId(clientId);
|
|
@@ -3111,6 +3649,7 @@ var UserManagement = class {
|
|
|
3111
3649
|
session
|
|
3112
3650
|
});
|
|
3113
3651
|
}
|
|
3652
|
+
/** Authenticate with email verification. */
|
|
3114
3653
|
async authenticateWithEmailVerification(payload) {
|
|
3115
3654
|
const { session, clientId, ...remainingPayload } = payload;
|
|
3116
3655
|
const resolvedClientId = this.resolveClientId(clientId);
|
|
@@ -3124,6 +3663,7 @@ var UserManagement = class {
|
|
|
3124
3663
|
session
|
|
3125
3664
|
});
|
|
3126
3665
|
}
|
|
3666
|
+
/** Authenticate with organization selection. */
|
|
3127
3667
|
async authenticateWithOrganizationSelection(payload) {
|
|
3128
3668
|
const { session, clientId, ...remainingPayload } = payload;
|
|
3129
3669
|
const resolvedClientId = this.resolveClientId(clientId);
|
|
@@ -3211,26 +3751,76 @@ var UserManagement = class {
|
|
|
3211
3751
|
if (!cookiePassword) throw new Error("Cookie password is required");
|
|
3212
3752
|
if (sessionData) return unsealData(sessionData, { password: cookiePassword });
|
|
3213
3753
|
}
|
|
3754
|
+
/**
|
|
3755
|
+
* Get an email verification code
|
|
3756
|
+
*
|
|
3757
|
+
* Get the details of an existing email verification code that can be used to send an email to a user for verification.
|
|
3758
|
+
* @returns {Promise<EmailVerification>}
|
|
3759
|
+
* @throws {NotFoundException} 404
|
|
3760
|
+
*/
|
|
3214
3761
|
async getEmailVerification(emailVerificationId) {
|
|
3215
3762
|
const { data } = await this.workos.get(`/user_management/email_verification/${emailVerificationId}`);
|
|
3216
3763
|
return deserializeEmailVerification(data);
|
|
3217
3764
|
}
|
|
3765
|
+
/**
|
|
3766
|
+
* Send verification email
|
|
3767
|
+
*
|
|
3768
|
+
* Sends an email that contains a one-time code used to verify a user’s email address.
|
|
3769
|
+
* @returns {Promise<{ user: User; }>}
|
|
3770
|
+
* @throws {BadRequestException} 400
|
|
3771
|
+
* @throws {NotFoundException} 404
|
|
3772
|
+
* @throws {RateLimitExceededException} 429
|
|
3773
|
+
*/
|
|
3218
3774
|
async sendVerificationEmail({ userId }) {
|
|
3219
3775
|
const { data } = await this.workos.post(`/user_management/users/${userId}/email_verification/send`, {});
|
|
3220
3776
|
return { user: deserializeUser(data.user) };
|
|
3221
3777
|
}
|
|
3778
|
+
/**
|
|
3779
|
+
* Get Magic Auth code details
|
|
3780
|
+
*
|
|
3781
|
+
* Get the details of an existing [Magic Auth](https://workos.com/docs/reference/authkit/magic-auth) code that can be used to send an email to a user for authentication.
|
|
3782
|
+
* @returns {Promise<MagicAuth>}
|
|
3783
|
+
* @throws {NotFoundException} 404
|
|
3784
|
+
*/
|
|
3222
3785
|
async getMagicAuth(magicAuthId) {
|
|
3223
3786
|
const { data } = await this.workos.get(`/user_management/magic_auth/${magicAuthId}`);
|
|
3224
3787
|
return deserializeMagicAuth(data);
|
|
3225
3788
|
}
|
|
3789
|
+
/**
|
|
3790
|
+
* Create a Magic Auth code
|
|
3791
|
+
*
|
|
3792
|
+
* Creates a one-time authentication code that can be sent to the user's email address. The code expires in 10 minutes. To verify the code, [authenticate the user with Magic Auth](https://workos.com/docs/reference/authkit/authentication/magic-auth).
|
|
3793
|
+
* @param options - Object containing email.
|
|
3794
|
+
* @returns {Promise<MagicAuth>}
|
|
3795
|
+
* @throws {BadRequestException} 400
|
|
3796
|
+
* @throws {UnprocessableEntityException} 422
|
|
3797
|
+
* @throws {RateLimitExceededException} 429
|
|
3798
|
+
*/
|
|
3226
3799
|
async createMagicAuth(options) {
|
|
3227
3800
|
const { data } = await this.workos.post("/user_management/magic_auth", serializeCreateMagicAuthOptions({ ...options }));
|
|
3228
3801
|
return deserializeMagicAuth(data);
|
|
3229
3802
|
}
|
|
3803
|
+
/**
|
|
3804
|
+
* Verify email
|
|
3805
|
+
*
|
|
3806
|
+
* Verifies an email address using the one-time code received by the user.
|
|
3807
|
+
* @param options - Object containing code.
|
|
3808
|
+
* @returns {Promise<{ user: User; }>}
|
|
3809
|
+
* @throws {BadRequestException} 400
|
|
3810
|
+
* @throws {NotFoundException} 404
|
|
3811
|
+
* @throws {UnprocessableEntityException} 422
|
|
3812
|
+
*/
|
|
3230
3813
|
async verifyEmail({ code, userId }) {
|
|
3231
3814
|
const { data } = await this.workos.post(`/user_management/users/${userId}/email_verification/confirm`, { code });
|
|
3232
3815
|
return { user: deserializeUser(data.user) };
|
|
3233
3816
|
}
|
|
3817
|
+
/**
|
|
3818
|
+
* Get a password reset token
|
|
3819
|
+
*
|
|
3820
|
+
* Get the details of an existing password reset token that can be used to reset a user's password.
|
|
3821
|
+
* @returns {Promise<PasswordReset>}
|
|
3822
|
+
* @throws {NotFoundException} 404
|
|
3823
|
+
*/
|
|
3234
3824
|
async getPasswordReset(passwordResetId) {
|
|
3235
3825
|
const { data } = await this.workos.get(`/user_management/password_reset/${passwordResetId}`);
|
|
3236
3826
|
return deserializePasswordReset(data);
|
|
@@ -3239,94 +3829,260 @@ var UserManagement = class {
|
|
|
3239
3829
|
const { data } = await this.workos.post("/user_management/password_reset", serializeCreatePasswordResetOptions({ ...options }));
|
|
3240
3830
|
return deserializePasswordReset(data);
|
|
3241
3831
|
}
|
|
3832
|
+
/**
|
|
3833
|
+
* Reset the password
|
|
3834
|
+
*
|
|
3835
|
+
* Sets a new password using the `token` query parameter from the link that
|
|
3836
|
+
* the user received. Successfully resetting the password will verify a
|
|
3837
|
+
* user's email, if it hasn't been verified yet.
|
|
3838
|
+
* @param payload - Object containing the reset token and new password.
|
|
3839
|
+
* @returns {Promise<{ user: User; }>}
|
|
3840
|
+
* @throws 403 response from the API.
|
|
3841
|
+
* @throws {NotFoundException} 404
|
|
3842
|
+
* @throws {UnprocessableEntityException} 422
|
|
3843
|
+
* @throws {RateLimitExceededException} 429
|
|
3844
|
+
*/
|
|
3242
3845
|
async resetPassword(payload) {
|
|
3243
3846
|
const { data } = await this.workos.post("/user_management/password_reset/confirm", serializeResetPasswordOptions(payload));
|
|
3244
3847
|
return { user: deserializeUser(data.user) };
|
|
3245
3848
|
}
|
|
3849
|
+
/**
|
|
3850
|
+
* Update a user
|
|
3851
|
+
*
|
|
3852
|
+
* Updates properties of a user. The omitted properties will be left unchanged.
|
|
3853
|
+
* @param payload - The request body.
|
|
3854
|
+
* @returns {Promise<User>}
|
|
3855
|
+
* @throws {BadRequestException} 400
|
|
3856
|
+
* @throws {UnprocessableEntityException} 422
|
|
3857
|
+
*/
|
|
3246
3858
|
async updateUser(payload) {
|
|
3247
3859
|
const { data } = await this.workos.put(`/user_management/users/${payload.userId}`, serializeUpdateUserOptions(payload));
|
|
3248
3860
|
return deserializeUser(data);
|
|
3249
3861
|
}
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
}
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/user_management/users/${userId}/auth_factors`, deserializeFactor$1, restOfOptions), (params) => fetchAndDeserialize(this.workos, `/user_management/users/${userId}/auth_factors`, deserializeFactor$1, params), restOfOptions);
|
|
3260
|
-
}
|
|
3261
|
-
async listUserFeatureFlags(options) {
|
|
3262
|
-
const { userId, ...paginationOptions } = options;
|
|
3263
|
-
return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/user_management/users/${userId}/feature-flags`, deserializeFeatureFlag, paginationOptions), (params) => fetchAndDeserialize(this.workos, `/user_management/users/${userId}/feature-flags`, deserializeFeatureFlag, params), paginationOptions);
|
|
3264
|
-
}
|
|
3862
|
+
/**
|
|
3863
|
+
* List sessions
|
|
3864
|
+
*
|
|
3865
|
+
* Get a list of all active sessions for a specific user.
|
|
3866
|
+
* @param options - Pagination and filter options.
|
|
3867
|
+
* @returns {Promise<AutoPaginatable<Session, SerializedListSessionsOptions>>}
|
|
3868
|
+
* @throws {NotFoundException} 404
|
|
3869
|
+
* @throws {UnprocessableEntityException} 422
|
|
3870
|
+
*/
|
|
3265
3871
|
async listSessions(userId, options) {
|
|
3266
3872
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/user_management/users/${userId}/sessions`, deserializeSession, options ? serializeListSessionsOptions(options) : void 0), (params) => fetchAndDeserialize(this.workos, `/user_management/users/${userId}/sessions`, deserializeSession, params), options ? serializeListSessionsOptions(options) : void 0);
|
|
3267
3873
|
}
|
|
3874
|
+
/**
|
|
3875
|
+
* Delete a user
|
|
3876
|
+
*
|
|
3877
|
+
* Permanently deletes a user in the current environment. It cannot be undone.
|
|
3878
|
+
* @returns {Promise<void>}
|
|
3879
|
+
* @throws {NotFoundException} 404
|
|
3880
|
+
*/
|
|
3268
3881
|
async deleteUser(userId) {
|
|
3269
3882
|
await this.workos.delete(`/user_management/users/${userId}`);
|
|
3270
3883
|
}
|
|
3884
|
+
/**
|
|
3885
|
+
* Get user identities
|
|
3886
|
+
*
|
|
3887
|
+
* Get a list of identities associated with the user. A user can have multiple associated identities after going through [identity linking](https://workos.com/docs/authkit/identity-linking). Currently only OAuth identities are supported. More provider types may be added in the future.
|
|
3888
|
+
* @returns {Promise<Identity[]>}
|
|
3889
|
+
* @throws {NotFoundException} 404
|
|
3890
|
+
*/
|
|
3271
3891
|
async getUserIdentities(userId) {
|
|
3272
3892
|
if (!userId) throw new TypeError(`Incomplete arguments. Need to specify 'userId'.`);
|
|
3273
3893
|
const { data } = await this.workos.get(`/user_management/users/${userId}/identities`);
|
|
3274
3894
|
return deserializeIdentities(data);
|
|
3275
3895
|
}
|
|
3896
|
+
/**
|
|
3897
|
+
* Get an organization membership
|
|
3898
|
+
*
|
|
3899
|
+
* Get the details of an existing organization membership.
|
|
3900
|
+
* @returns {Promise<OrganizationMembership>}
|
|
3901
|
+
* @throws {NotFoundException} 404
|
|
3902
|
+
*/
|
|
3276
3903
|
async getOrganizationMembership(organizationMembershipId) {
|
|
3277
3904
|
const { data } = await this.workos.get(`/user_management/organization_memberships/${organizationMembershipId}`);
|
|
3278
3905
|
return deserializeOrganizationMembership(data);
|
|
3279
3906
|
}
|
|
3907
|
+
/**
|
|
3908
|
+
* List organization memberships
|
|
3909
|
+
*
|
|
3910
|
+
* Get a list of all organization memberships matching the criteria specified. At least one of `user_id` or `organization_id` must be provided. By default only active memberships are returned. Use the `statuses` parameter to filter by other statuses.
|
|
3911
|
+
* @param options - Pagination and filter options.
|
|
3912
|
+
* @returns {Promise<AutoPaginatable<OrganizationMembership, SerializedListOrganizationMembershipsOptions>>}
|
|
3913
|
+
* @throws {BadRequestException} 400
|
|
3914
|
+
* @throws {NotFoundException} 404
|
|
3915
|
+
* @throws {UnprocessableEntityException} 422
|
|
3916
|
+
*/
|
|
3280
3917
|
async listOrganizationMemberships(options) {
|
|
3281
3918
|
const serializedOptions = serializeListOrganizationMembershipsOptions(options);
|
|
3282
3919
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/user_management/organization_memberships", deserializeOrganizationMembership, serializedOptions), (params) => fetchAndDeserialize(this.workos, "/user_management/organization_memberships", deserializeOrganizationMembership, params), serializedOptions);
|
|
3283
3920
|
}
|
|
3921
|
+
/**
|
|
3922
|
+
* Create an organization membership
|
|
3923
|
+
*
|
|
3924
|
+
* Creates a new `active` organization membership for the given organization and user.
|
|
3925
|
+
*
|
|
3926
|
+
* Calling this API with an organization and user that match an `inactive` organization membership will activate the membership with the specified role(s).
|
|
3927
|
+
* @param options - Object containing userId, organizationId.
|
|
3928
|
+
* @returns {Promise<OrganizationMembership>}
|
|
3929
|
+
* @throws {BadRequestException} 400
|
|
3930
|
+
* @throws {NotFoundException} 404
|
|
3931
|
+
* @throws {UnprocessableEntityException} 422
|
|
3932
|
+
*/
|
|
3284
3933
|
async createOrganizationMembership(options) {
|
|
3285
3934
|
const { data } = await this.workos.post("/user_management/organization_memberships", serializeCreateOrganizationMembershipOptions(options));
|
|
3286
3935
|
return deserializeOrganizationMembership(data);
|
|
3287
3936
|
}
|
|
3937
|
+
/**
|
|
3938
|
+
* Update an organization membership
|
|
3939
|
+
*
|
|
3940
|
+
* Update the details of an existing organization membership.
|
|
3941
|
+
* @param options - The request body.
|
|
3942
|
+
* @returns {Promise<OrganizationMembership>}
|
|
3943
|
+
* @throws {NotFoundException} 404
|
|
3944
|
+
* @throws {UnprocessableEntityException} 422
|
|
3945
|
+
*/
|
|
3288
3946
|
async updateOrganizationMembership(organizationMembershipId, options) {
|
|
3289
3947
|
const { data } = await this.workos.put(`/user_management/organization_memberships/${organizationMembershipId}`, serializeUpdateOrganizationMembershipOptions(options));
|
|
3290
3948
|
return deserializeOrganizationMembership(data);
|
|
3291
3949
|
}
|
|
3950
|
+
/**
|
|
3951
|
+
* Delete an organization membership
|
|
3952
|
+
*
|
|
3953
|
+
* Permanently deletes an existing organization membership. It cannot be undone.
|
|
3954
|
+
* @returns {Promise<void>}
|
|
3955
|
+
* @throws {NotFoundException} 404
|
|
3956
|
+
*/
|
|
3292
3957
|
async deleteOrganizationMembership(organizationMembershipId) {
|
|
3293
3958
|
await this.workos.delete(`/user_management/organization_memberships/${organizationMembershipId}`);
|
|
3294
3959
|
}
|
|
3960
|
+
/**
|
|
3961
|
+
* Deactivate an organization membership
|
|
3962
|
+
*
|
|
3963
|
+
* Deactivates an `active` organization membership. Emits an [organization_membership.updated](https://workos.com/docs/events/organization-membership) event upon successful deactivation.
|
|
3964
|
+
*
|
|
3965
|
+
* - Deactivating an `inactive` membership is a no-op and does not emit an event.
|
|
3966
|
+
* - Deactivating a `pending` membership returns an error. This membership should be [deleted](https://workos.com/docs/reference/authkit/organization-membership/delete) instead.
|
|
3967
|
+
*
|
|
3968
|
+
* See the [membership management documentation](https://workos.com/docs/authkit/users-organizations/organizations/membership-management) for additional details.
|
|
3969
|
+
* @returns {Promise<OrganizationMembership>}
|
|
3970
|
+
* @throws {BadRequestException} 400
|
|
3971
|
+
* @throws {NotFoundException} 404
|
|
3972
|
+
* @throws {UnprocessableEntityException} 422
|
|
3973
|
+
*/
|
|
3295
3974
|
async deactivateOrganizationMembership(organizationMembershipId) {
|
|
3296
3975
|
const { data } = await this.workos.put(`/user_management/organization_memberships/${organizationMembershipId}/deactivate`, {});
|
|
3297
3976
|
return deserializeOrganizationMembership(data);
|
|
3298
3977
|
}
|
|
3978
|
+
/**
|
|
3979
|
+
* Reactivate an organization membership
|
|
3980
|
+
*
|
|
3981
|
+
* Reactivates an `inactive` organization membership, retaining the pre-existing role(s). Emits an [organization_membership.updated](https://workos.com/docs/events/organization-membership) event upon successful reactivation.
|
|
3982
|
+
*
|
|
3983
|
+
* - Reactivating an `active` membership is a no-op and does not emit an event.
|
|
3984
|
+
* - Reactivating a `pending` membership returns an error. The user needs to [accept the invitation](https://workos.com/docs/authkit/invitations) instead.
|
|
3985
|
+
*
|
|
3986
|
+
* See the [membership management documentation](https://workos.com/docs/authkit/users-organizations/organizations/membership-management) for additional details.
|
|
3987
|
+
* @returns {Promise<OrganizationMembership>}
|
|
3988
|
+
* @throws {BadRequestException} 400
|
|
3989
|
+
* @throws {NotFoundException} 404
|
|
3990
|
+
* @throws {UnprocessableEntityException} 422
|
|
3991
|
+
*/
|
|
3299
3992
|
async reactivateOrganizationMembership(organizationMembershipId) {
|
|
3300
3993
|
const { data } = await this.workos.put(`/user_management/organization_memberships/${organizationMembershipId}/reactivate`, {});
|
|
3301
3994
|
return deserializeOrganizationMembership(data);
|
|
3302
3995
|
}
|
|
3996
|
+
async listGroupsForOrganizationMembership(options) {
|
|
3997
|
+
const { organizationMembershipId, ...paginationOptions } = options;
|
|
3998
|
+
const endpoint = `/user_management/organization_memberships/${organizationMembershipId}/groups`;
|
|
3999
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeGroup, paginationOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeGroup, params), paginationOptions);
|
|
4000
|
+
}
|
|
3303
4001
|
async getInvitation(invitationId) {
|
|
3304
4002
|
const { data } = await this.workos.get(`/user_management/invitations/${invitationId}`);
|
|
3305
4003
|
return deserializeInvitation(data);
|
|
3306
4004
|
}
|
|
4005
|
+
/**
|
|
4006
|
+
* Find an invitation by token
|
|
4007
|
+
*
|
|
4008
|
+
* Retrieve an existing invitation using the token.
|
|
4009
|
+
* @returns {Promise<Invitation>}
|
|
4010
|
+
* @throws {NotFoundException} 404
|
|
4011
|
+
*/
|
|
3307
4012
|
async findInvitationByToken(invitationToken) {
|
|
3308
4013
|
const { data } = await this.workos.get(`/user_management/invitations/by_token/${invitationToken}`);
|
|
3309
4014
|
return deserializeInvitation(data);
|
|
3310
4015
|
}
|
|
4016
|
+
/**
|
|
4017
|
+
* List invitations
|
|
4018
|
+
*
|
|
4019
|
+
* Get a list of all of invitations matching the criteria specified.
|
|
4020
|
+
* @param options - Pagination and filter options.
|
|
4021
|
+
* @returns {Promise<AutoPaginatable<Invitation, SerializedListInvitationsOptions>>}
|
|
4022
|
+
* @throws {UnprocessableEntityException} 422
|
|
4023
|
+
*/
|
|
3311
4024
|
async listInvitations(options) {
|
|
3312
4025
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/user_management/invitations", deserializeInvitation, options ? serializeListInvitationsOptions(options) : void 0), (params) => fetchAndDeserialize(this.workos, "/user_management/invitations", deserializeInvitation, params), options ? serializeListInvitationsOptions(options) : void 0);
|
|
3313
4026
|
}
|
|
4027
|
+
/**
|
|
4028
|
+
* Send an invitation
|
|
4029
|
+
*
|
|
4030
|
+
* Sends an invitation email to the recipient.
|
|
4031
|
+
* @param payload - Object containing email.
|
|
4032
|
+
* @returns {Promise<Invitation>}
|
|
4033
|
+
* @throws {BadRequestException} 400
|
|
4034
|
+
* @throws {NotFoundException} 404
|
|
4035
|
+
* @throws {UnprocessableEntityException} 422
|
|
4036
|
+
*/
|
|
3314
4037
|
async sendInvitation(payload) {
|
|
3315
4038
|
const { data } = await this.workos.post("/user_management/invitations", serializeSendInvitationOptions({ ...payload }));
|
|
3316
4039
|
return deserializeInvitation(data);
|
|
3317
4040
|
}
|
|
4041
|
+
/**
|
|
4042
|
+
* Accept an invitation
|
|
4043
|
+
*
|
|
4044
|
+
* Accepts an invitation and, if linked to an organization, activates the user's membership in that organization.
|
|
4045
|
+
* @returns {Promise<Invitation>}
|
|
4046
|
+
* @throws {BadRequestException} 400
|
|
4047
|
+
* @throws {NotFoundException} 404
|
|
4048
|
+
*/
|
|
3318
4049
|
async acceptInvitation(invitationId) {
|
|
3319
4050
|
const { data } = await this.workos.post(`/user_management/invitations/${invitationId}/accept`, null);
|
|
3320
4051
|
return deserializeInvitation(data);
|
|
3321
4052
|
}
|
|
4053
|
+
/**
|
|
4054
|
+
* Revoke an invitation
|
|
4055
|
+
*
|
|
4056
|
+
* Revokes an existing invitation.
|
|
4057
|
+
* @returns {Promise<Invitation>}
|
|
4058
|
+
* @throws {BadRequestException} 400
|
|
4059
|
+
*/
|
|
3322
4060
|
async revokeInvitation(invitationId) {
|
|
3323
4061
|
const { data } = await this.workos.post(`/user_management/invitations/${invitationId}/revoke`, null);
|
|
3324
4062
|
return deserializeInvitation(data);
|
|
3325
4063
|
}
|
|
4064
|
+
/**
|
|
4065
|
+
* Resend an invitation
|
|
4066
|
+
*
|
|
4067
|
+
* Resends an invitation email to the recipient. The invitation must be in a pending state.
|
|
4068
|
+
* @param options - The request body.
|
|
4069
|
+
* @returns {Promise<Invitation>}
|
|
4070
|
+
* @throws {BadRequestException} 400
|
|
4071
|
+
* @throws {NotFoundException} 404
|
|
4072
|
+
* @throws {UnprocessableEntityException} 422
|
|
4073
|
+
*/
|
|
3326
4074
|
async resendInvitation(invitationId, options) {
|
|
3327
4075
|
const { data } = await this.workos.post(`/user_management/invitations/${invitationId}/resend`, options ? serializeResendInvitationOptions(options) : {});
|
|
3328
4076
|
return deserializeInvitation(data);
|
|
3329
4077
|
}
|
|
4078
|
+
/**
|
|
4079
|
+
* Revoke Session
|
|
4080
|
+
*
|
|
4081
|
+
* Revoke a [user session](https://workos.com/docs/reference/authkit/session).
|
|
4082
|
+
* @param payload - Object containing sessionId.
|
|
4083
|
+
* @returns {Promise<void>}
|
|
4084
|
+
* @throws {BadRequestException} 400
|
|
4085
|
+
*/
|
|
3330
4086
|
async revokeSession(payload) {
|
|
3331
4087
|
await this.workos.post("/user_management/sessions/revoke", serializeRevokeSessionOptions(payload));
|
|
3332
4088
|
}
|
|
@@ -3421,6 +4177,23 @@ var UserManagement = class {
|
|
|
3421
4177
|
codeVerifier: pkce.codeVerifier
|
|
3422
4178
|
};
|
|
3423
4179
|
}
|
|
4180
|
+
/**
|
|
4181
|
+
* Logout
|
|
4182
|
+
*
|
|
4183
|
+
* Logout a user from the current [session](https://workos.com/docs/reference/authkit/session).
|
|
4184
|
+
* @param options.sessionId - The ID of the session to revoke. This can be extracted from the `sid` claim of the access token.
|
|
4185
|
+
*
|
|
4186
|
+
* @example
|
|
4187
|
+
* "session_01H93ZY4F80QPBEZ1R5B2SHQG8"
|
|
4188
|
+
*
|
|
4189
|
+
* @param options.returnTo - The URL to redirect the user to after session revocation.
|
|
4190
|
+
*
|
|
4191
|
+
* @example
|
|
4192
|
+
* "https://example.com"
|
|
4193
|
+
*
|
|
4194
|
+
* @returns {string}
|
|
4195
|
+
* @throws {UnprocessableEntityException} 422
|
|
4196
|
+
*/
|
|
3424
4197
|
getLogoutUrl(options) {
|
|
3425
4198
|
const { sessionId, returnTo } = options;
|
|
3426
4199
|
if (!sessionId) throw new TypeError(`Incomplete arguments. Need to specify 'sessionId'.`);
|
|
@@ -3435,374 +4208,20 @@ var UserManagement = class {
|
|
|
3435
4208
|
}
|
|
3436
4209
|
};
|
|
3437
4210
|
//#endregion
|
|
3438
|
-
//#region src/
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
}
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
}
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
//#endregion
|
|
3453
|
-
//#region src/fga/serializers/check-options.serializer.ts
|
|
3454
|
-
const serializeCheckOptions = (options) => ({
|
|
3455
|
-
op: options.op,
|
|
3456
|
-
checks: options.checks.map(serializeCheckWarrantOptions),
|
|
3457
|
-
debug: options.debug
|
|
3458
|
-
});
|
|
3459
|
-
const serializeCheckBatchOptions = (options) => ({
|
|
3460
|
-
op: "batch",
|
|
3461
|
-
checks: options.checks.map(serializeCheckWarrantOptions),
|
|
3462
|
-
debug: options.debug
|
|
3463
|
-
});
|
|
3464
|
-
const serializeCheckWarrantOptions = (warrant) => {
|
|
3465
|
-
return {
|
|
3466
|
-
resource_type: isResourceInterface(warrant.resource) ? warrant.resource.getResourceType() : warrant.resource.resourceType,
|
|
3467
|
-
resource_id: isResourceInterface(warrant.resource) ? warrant.resource.getResourceId() : warrant.resource.resourceId ? warrant.resource.resourceId : "",
|
|
3468
|
-
relation: warrant.relation,
|
|
3469
|
-
subject: isSubject(warrant.subject) ? {
|
|
3470
|
-
resource_type: warrant.subject.resourceType,
|
|
3471
|
-
resource_id: warrant.subject.resourceId
|
|
3472
|
-
} : {
|
|
3473
|
-
resource_type: warrant.subject.getResourceType(),
|
|
3474
|
-
resource_id: warrant.subject.getResourceId()
|
|
3475
|
-
},
|
|
3476
|
-
context: warrant.context ?? {}
|
|
3477
|
-
};
|
|
3478
|
-
};
|
|
3479
|
-
const deserializeDecisionTreeNode = (response) => {
|
|
3480
|
-
return {
|
|
3481
|
-
check: {
|
|
3482
|
-
resource: {
|
|
3483
|
-
resourceType: response.check.resource_type,
|
|
3484
|
-
resourceId: response.check.resource_id
|
|
3485
|
-
},
|
|
3486
|
-
relation: response.check.relation,
|
|
3487
|
-
subject: {
|
|
3488
|
-
resourceType: response.check.subject.resource_type,
|
|
3489
|
-
resourceId: response.check.subject.resource_id
|
|
3490
|
-
},
|
|
3491
|
-
context: response.check.context
|
|
3492
|
-
},
|
|
3493
|
-
policy: response.policy,
|
|
3494
|
-
decision: response.decision,
|
|
3495
|
-
processingTime: response.processing_time,
|
|
3496
|
-
children: response.children.map(deserializeDecisionTreeNode)
|
|
3497
|
-
};
|
|
3498
|
-
};
|
|
3499
|
-
//#endregion
|
|
3500
|
-
//#region src/fga/interfaces/check.interface.ts
|
|
3501
|
-
const CHECK_RESULT_AUTHORIZED = "authorized";
|
|
3502
|
-
var CheckResult = class {
|
|
3503
|
-
result;
|
|
3504
|
-
isImplicit;
|
|
3505
|
-
warrantToken;
|
|
3506
|
-
debugInfo;
|
|
3507
|
-
warnings;
|
|
3508
|
-
constructor(json) {
|
|
3509
|
-
this.result = json.result;
|
|
3510
|
-
this.isImplicit = json.is_implicit;
|
|
3511
|
-
this.warrantToken = json.warrant_token;
|
|
3512
|
-
this.debugInfo = json.debug_info ? {
|
|
3513
|
-
processingTime: json.debug_info.processing_time,
|
|
3514
|
-
decisionTree: deserializeDecisionTreeNode(json.debug_info.decision_tree)
|
|
3515
|
-
} : void 0;
|
|
3516
|
-
this.warnings = json.warnings;
|
|
3517
|
-
}
|
|
3518
|
-
isAuthorized() {
|
|
3519
|
-
return this.result === CHECK_RESULT_AUTHORIZED;
|
|
3520
|
-
}
|
|
3521
|
-
};
|
|
3522
|
-
//#endregion
|
|
3523
|
-
//#region src/fga/interfaces/resource-op.enum.ts
|
|
3524
|
-
let ResourceOp = /* @__PURE__ */ function(ResourceOp) {
|
|
3525
|
-
ResourceOp["Create"] = "create";
|
|
3526
|
-
ResourceOp["Delete"] = "delete";
|
|
3527
|
-
return ResourceOp;
|
|
3528
|
-
}({});
|
|
3529
|
-
//#endregion
|
|
3530
|
-
//#region src/fga/interfaces/warrant-op.enum.ts
|
|
3531
|
-
let WarrantOp = /* @__PURE__ */ function(WarrantOp) {
|
|
3532
|
-
WarrantOp["Create"] = "create";
|
|
3533
|
-
WarrantOp["Delete"] = "delete";
|
|
3534
|
-
return WarrantOp;
|
|
3535
|
-
}({});
|
|
3536
|
-
//#endregion
|
|
3537
|
-
//#region src/fga/serializers/create-resource-options.serializer.ts
|
|
3538
|
-
const serializeCreateResourceOptions$1 = (options) => ({
|
|
3539
|
-
resource_type: isResourceInterface(options.resource) ? options.resource.getResourceType() : options.resource.resourceType,
|
|
3540
|
-
resource_id: isResourceInterface(options.resource) ? options.resource.getResourceId() : options.resource.resourceId ? options.resource.resourceId : "",
|
|
3541
|
-
meta: options.meta
|
|
3542
|
-
});
|
|
3543
|
-
//#endregion
|
|
3544
|
-
//#region src/fga/serializers/delete-resource-options.serializer.ts
|
|
3545
|
-
const serializeDeleteResourceOptions = (options) => ({
|
|
3546
|
-
resource_type: isResourceInterface(options) ? options.getResourceType() : options.resourceType,
|
|
3547
|
-
resource_id: isResourceInterface(options) ? options.getResourceId() : options.resourceId ? options.resourceId : ""
|
|
3548
|
-
});
|
|
3549
|
-
//#endregion
|
|
3550
|
-
//#region src/fga/serializers/batch-write-resources-options.serializer.ts
|
|
3551
|
-
const serializeBatchWriteResourcesOptions = (options) => {
|
|
3552
|
-
let serializedResources = [];
|
|
3553
|
-
if (options.op === ResourceOp.Create) serializedResources = options.resources.map((options) => serializeCreateResourceOptions$1(options));
|
|
3554
|
-
else if (options.op === ResourceOp.Delete) serializedResources = options.resources.map((options) => serializeDeleteResourceOptions(options));
|
|
3555
|
-
return {
|
|
3556
|
-
op: options.op,
|
|
3557
|
-
resources: serializedResources
|
|
3558
|
-
};
|
|
3559
|
-
};
|
|
3560
|
-
//#endregion
|
|
3561
|
-
//#region src/fga/serializers/list-resources-options.serializer.ts
|
|
3562
|
-
const serializeListResourceOptions = (options) => ({
|
|
3563
|
-
resource_type: options.resourceType,
|
|
3564
|
-
search: options.search,
|
|
3565
|
-
limit: options.limit,
|
|
3566
|
-
before: options.before,
|
|
3567
|
-
after: options.after,
|
|
3568
|
-
order: options.order
|
|
3569
|
-
});
|
|
3570
|
-
//#endregion
|
|
3571
|
-
//#region src/fga/serializers/list-warrants-options.serializer.ts
|
|
3572
|
-
const serializeListWarrantsOptions = (options) => ({
|
|
3573
|
-
resource_type: options.resourceType,
|
|
3574
|
-
resource_id: options.resourceId,
|
|
3575
|
-
relation: options.relation,
|
|
3576
|
-
subject_type: options.subjectType,
|
|
3577
|
-
subject_id: options.subjectId,
|
|
3578
|
-
subject_relation: options.subjectRelation,
|
|
3579
|
-
limit: options.limit,
|
|
3580
|
-
after: options.after
|
|
3581
|
-
});
|
|
3582
|
-
//#endregion
|
|
3583
|
-
//#region src/fga/serializers/query-options.serializer.ts
|
|
3584
|
-
const serializeQueryOptions = (options) => ({
|
|
3585
|
-
q: options.q,
|
|
3586
|
-
context: JSON.stringify(options.context),
|
|
3587
|
-
limit: options.limit,
|
|
3588
|
-
before: options.before,
|
|
3589
|
-
after: options.after,
|
|
3590
|
-
order: options.order
|
|
3591
|
-
});
|
|
3592
|
-
//#endregion
|
|
3593
|
-
//#region src/fga/serializers/query-result.serializer.ts
|
|
3594
|
-
const deserializeQueryResult = (queryResult) => ({
|
|
3595
|
-
resourceType: queryResult.resource_type,
|
|
3596
|
-
resourceId: queryResult.resource_id,
|
|
3597
|
-
relation: queryResult.relation,
|
|
3598
|
-
warrant: {
|
|
3599
|
-
resourceType: queryResult.warrant.resource_type,
|
|
3600
|
-
resourceId: queryResult.warrant.resource_id,
|
|
3601
|
-
relation: queryResult.warrant.relation,
|
|
3602
|
-
subject: {
|
|
3603
|
-
resourceType: queryResult.warrant.subject.resource_type,
|
|
3604
|
-
resourceId: queryResult.warrant.subject.resource_id,
|
|
3605
|
-
relation: queryResult.warrant.subject.relation
|
|
3606
|
-
}
|
|
3607
|
-
},
|
|
3608
|
-
isImplicit: queryResult.is_implicit,
|
|
3609
|
-
meta: queryResult.meta
|
|
3610
|
-
});
|
|
3611
|
-
//#endregion
|
|
3612
|
-
//#region src/fga/serializers/resource.serializer.ts
|
|
3613
|
-
const deserializeResource = (response) => ({
|
|
3614
|
-
resourceType: response.resource_type,
|
|
3615
|
-
resourceId: response.resource_id,
|
|
3616
|
-
meta: response.meta
|
|
3617
|
-
});
|
|
3618
|
-
const deserializeBatchWriteResourcesResponse = (response) => {
|
|
3619
|
-
return response.data.map((resource) => deserializeResource(resource));
|
|
3620
|
-
};
|
|
3621
|
-
//#endregion
|
|
3622
|
-
//#region src/fga/serializers/warrant-token.serializer.ts
|
|
3623
|
-
const deserializeWarrantToken = (warrantToken) => ({ warrantToken: warrantToken.warrant_token });
|
|
3624
|
-
//#endregion
|
|
3625
|
-
//#region src/fga/serializers/warrant.serializer.ts
|
|
3626
|
-
const deserializeWarrant = (warrant) => ({
|
|
3627
|
-
resourceType: warrant.resource_type,
|
|
3628
|
-
resourceId: warrant.resource_id,
|
|
3629
|
-
relation: warrant.relation,
|
|
3630
|
-
subject: {
|
|
3631
|
-
resourceType: warrant.subject.resource_type,
|
|
3632
|
-
resourceId: warrant.subject.resource_id,
|
|
3633
|
-
relation: warrant.subject.relation
|
|
3634
|
-
},
|
|
3635
|
-
policy: warrant.policy
|
|
3636
|
-
});
|
|
3637
|
-
//#endregion
|
|
3638
|
-
//#region src/fga/serializers/write-warrant-options.serializer.ts
|
|
3639
|
-
const serializeWriteWarrantOptions = (warrant) => ({
|
|
3640
|
-
op: warrant.op,
|
|
3641
|
-
resource_type: isResourceInterface(warrant.resource) ? warrant.resource.getResourceType() : warrant.resource.resourceType,
|
|
3642
|
-
resource_id: isResourceInterface(warrant.resource) ? warrant.resource.getResourceId() : warrant.resource.resourceId ? warrant.resource.resourceId : "",
|
|
3643
|
-
relation: warrant.relation,
|
|
3644
|
-
subject: isSubject(warrant.subject) ? {
|
|
3645
|
-
resource_type: warrant.subject.resourceType,
|
|
3646
|
-
resource_id: warrant.subject.resourceId
|
|
3647
|
-
} : {
|
|
3648
|
-
resource_type: warrant.subject.getResourceType(),
|
|
3649
|
-
resource_id: warrant.subject.getResourceId()
|
|
3650
|
-
},
|
|
3651
|
-
policy: warrant.policy
|
|
3652
|
-
});
|
|
3653
|
-
//#endregion
|
|
3654
|
-
//#region src/fga/serializers/list.serializer.ts
|
|
3655
|
-
const deserializeFGAList = (response, deserializeFn) => ({
|
|
3656
|
-
object: "list",
|
|
3657
|
-
data: response.data.map(deserializeFn),
|
|
3658
|
-
listMetadata: response.list_metadata,
|
|
3659
|
-
warnings: response.warnings
|
|
3660
|
-
});
|
|
3661
|
-
//#endregion
|
|
3662
|
-
//#region src/fga/utils/fga-paginatable.ts
|
|
3663
|
-
var FgaPaginatable = class extends AutoPaginatable {
|
|
3664
|
-
list;
|
|
3665
|
-
constructor(list, apiCall, options) {
|
|
3666
|
-
super(list, apiCall, options);
|
|
3667
|
-
this.list = list;
|
|
3668
|
-
}
|
|
3669
|
-
get warnings() {
|
|
3670
|
-
return this.list.warnings;
|
|
3671
|
-
}
|
|
3672
|
-
};
|
|
3673
|
-
//#endregion
|
|
3674
|
-
//#region src/fga/utils/fetch-and-deserialize-list.ts
|
|
3675
|
-
const fetchAndDeserializeFGAList = async (workos, endpoint, deserializeFn, options, requestOptions) => {
|
|
3676
|
-
const { data: response } = await workos.get(endpoint, {
|
|
3677
|
-
query: options,
|
|
3678
|
-
...requestOptions
|
|
3679
|
-
});
|
|
3680
|
-
return deserializeFGAList(response, deserializeFn);
|
|
3681
|
-
};
|
|
3682
|
-
//#endregion
|
|
3683
|
-
//#region src/fga/fga.ts
|
|
3684
|
-
/**
|
|
3685
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3686
|
-
* @see src/authorization/authorization.ts
|
|
3687
|
-
*/
|
|
3688
|
-
var FGA = class {
|
|
3689
|
-
constructor(workos) {
|
|
3690
|
-
this.workos = workos;
|
|
3691
|
-
}
|
|
3692
|
-
/**
|
|
3693
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3694
|
-
* @see src/authorization/authorization.ts
|
|
3695
|
-
*/
|
|
3696
|
-
async check(checkOptions, options = {}) {
|
|
3697
|
-
const { data } = await this.workos.post(`/fga/v1/check`, serializeCheckOptions(checkOptions), options);
|
|
3698
|
-
return new CheckResult(data);
|
|
3699
|
-
}
|
|
3700
|
-
/**
|
|
3701
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3702
|
-
* @see src/authorization/authorization.ts
|
|
3703
|
-
*/
|
|
3704
|
-
async checkBatch(checkOptions, options = {}) {
|
|
3705
|
-
const { data } = await this.workos.post(`/fga/v1/check`, serializeCheckBatchOptions(checkOptions), options);
|
|
3706
|
-
return data.map((checkResult) => new CheckResult(checkResult));
|
|
3707
|
-
}
|
|
3708
|
-
/**
|
|
3709
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3710
|
-
* @see src/authorization/authorization.ts
|
|
3711
|
-
*/
|
|
3712
|
-
async createResource(resource) {
|
|
3713
|
-
const { data } = await this.workos.post("/fga/v1/resources", serializeCreateResourceOptions$1(resource));
|
|
3714
|
-
return deserializeResource(data);
|
|
3715
|
-
}
|
|
3716
|
-
/**
|
|
3717
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3718
|
-
* @see src/authorization/authorization.ts
|
|
3719
|
-
*/
|
|
3720
|
-
async getResource(resource) {
|
|
3721
|
-
const resourceType = isResourceInterface(resource) ? resource.getResourceType() : resource.resourceType;
|
|
3722
|
-
const resourceId = isResourceInterface(resource) ? resource.getResourceId() : resource.resourceId;
|
|
3723
|
-
const { data } = await this.workos.get(`/fga/v1/resources/${resourceType}/${resourceId}`);
|
|
3724
|
-
return deserializeResource(data);
|
|
3725
|
-
}
|
|
3726
|
-
/**
|
|
3727
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3728
|
-
* @see src/authorization/authorization.ts
|
|
3729
|
-
*/
|
|
3730
|
-
async listResources(options) {
|
|
3731
|
-
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/fga/v1/resources", deserializeResource, options ? serializeListResourceOptions(options) : void 0), (params) => fetchAndDeserialize(this.workos, "/fga/v1/resources", deserializeResource, params), options ? serializeListResourceOptions(options) : void 0);
|
|
3732
|
-
}
|
|
3733
|
-
/**
|
|
3734
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3735
|
-
* @see src/authorization/authorization.ts
|
|
3736
|
-
*/
|
|
3737
|
-
async updateResource(options) {
|
|
3738
|
-
const resourceType = isResourceInterface(options.resource) ? options.resource.getResourceType() : options.resource.resourceType;
|
|
3739
|
-
const resourceId = isResourceInterface(options.resource) ? options.resource.getResourceId() : options.resource.resourceId;
|
|
3740
|
-
const { data } = await this.workos.put(`/fga/v1/resources/${resourceType}/${resourceId}`, { meta: options.meta });
|
|
3741
|
-
return deserializeResource(data);
|
|
3742
|
-
}
|
|
3743
|
-
/**
|
|
3744
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3745
|
-
* @see src/authorization/authorization.ts
|
|
3746
|
-
*/
|
|
3747
|
-
async deleteResource(resource) {
|
|
3748
|
-
const resourceType = isResourceInterface(resource) ? resource.getResourceType() : resource.resourceType;
|
|
3749
|
-
const resourceId = isResourceInterface(resource) ? resource.getResourceId() : resource.resourceId;
|
|
3750
|
-
await this.workos.delete(`/fga/v1/resources/${resourceType}/${resourceId}`);
|
|
3751
|
-
}
|
|
3752
|
-
/**
|
|
3753
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3754
|
-
* @see src/authorization/authorization.ts
|
|
3755
|
-
*/
|
|
3756
|
-
async batchWriteResources(options) {
|
|
3757
|
-
const { data } = await this.workos.post("/fga/v1/resources/batch", serializeBatchWriteResourcesOptions(options));
|
|
3758
|
-
return deserializeBatchWriteResourcesResponse(data);
|
|
3759
|
-
}
|
|
3760
|
-
/**
|
|
3761
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3762
|
-
* @see src/authorization/authorization.ts
|
|
3763
|
-
*/
|
|
3764
|
-
async writeWarrant(options) {
|
|
3765
|
-
const { data } = await this.workos.post("/fga/v1/warrants", serializeWriteWarrantOptions(options));
|
|
3766
|
-
return deserializeWarrantToken(data);
|
|
3767
|
-
}
|
|
3768
|
-
/**
|
|
3769
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3770
|
-
* @see src/authorization/authorization.ts
|
|
3771
|
-
*/
|
|
3772
|
-
async batchWriteWarrants(options) {
|
|
3773
|
-
const { data: warrantToken } = await this.workos.post("/fga/v1/warrants", options.map(serializeWriteWarrantOptions));
|
|
3774
|
-
return deserializeWarrantToken(warrantToken);
|
|
3775
|
-
}
|
|
3776
|
-
/**
|
|
3777
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3778
|
-
* @see src/authorization/authorization.ts
|
|
3779
|
-
*/
|
|
3780
|
-
async listWarrants(options, requestOptions) {
|
|
3781
|
-
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/fga/v1/warrants", deserializeWarrant, options ? serializeListWarrantsOptions(options) : void 0, requestOptions), (params) => fetchAndDeserialize(this.workos, "/fga/v1/warrants", deserializeWarrant, params, requestOptions), options ? serializeListWarrantsOptions(options) : void 0);
|
|
3782
|
-
}
|
|
3783
|
-
/**
|
|
3784
|
-
* @deprecated The FGA module is deprecated. Use the Authorization module instead.
|
|
3785
|
-
* @see src/authorization/authorization.ts
|
|
3786
|
-
*/
|
|
3787
|
-
async query(options, requestOptions = {}) {
|
|
3788
|
-
return new FgaPaginatable(await fetchAndDeserializeFGAList(this.workos, "/fga/v1/query", deserializeQueryResult, serializeQueryOptions(options), requestOptions), (params) => fetchAndDeserializeFGAList(this.workos, "/fga/v1/query", deserializeQueryResult, params, requestOptions), serializeQueryOptions(options));
|
|
3789
|
-
}
|
|
3790
|
-
};
|
|
3791
|
-
//#endregion
|
|
3792
|
-
//#region src/feature-flags/in-memory-store.ts
|
|
3793
|
-
var InMemoryStore = class {
|
|
3794
|
-
flags = {};
|
|
3795
|
-
swap(newFlags) {
|
|
3796
|
-
this.flags = { ...newFlags };
|
|
3797
|
-
}
|
|
3798
|
-
get(slug) {
|
|
3799
|
-
return this.flags[slug];
|
|
3800
|
-
}
|
|
3801
|
-
getAll() {
|
|
3802
|
-
return { ...this.flags };
|
|
3803
|
-
}
|
|
3804
|
-
get size() {
|
|
3805
|
-
return Object.keys(this.flags).length;
|
|
4211
|
+
//#region src/feature-flags/in-memory-store.ts
|
|
4212
|
+
var InMemoryStore = class {
|
|
4213
|
+
flags = {};
|
|
4214
|
+
swap(newFlags) {
|
|
4215
|
+
this.flags = { ...newFlags };
|
|
4216
|
+
}
|
|
4217
|
+
get(slug) {
|
|
4218
|
+
return this.flags[slug];
|
|
4219
|
+
}
|
|
4220
|
+
getAll() {
|
|
4221
|
+
return { ...this.flags };
|
|
4222
|
+
}
|
|
4223
|
+
get size() {
|
|
4224
|
+
return Object.keys(this.flags).length;
|
|
3806
4225
|
}
|
|
3807
4226
|
};
|
|
3808
4227
|
//#endregion
|
|
@@ -4028,34 +4447,167 @@ var FeatureFlags = class {
|
|
|
4028
4447
|
constructor(workos) {
|
|
4029
4448
|
this.workos = workos;
|
|
4030
4449
|
}
|
|
4450
|
+
/**
|
|
4451
|
+
* List feature flags
|
|
4452
|
+
*
|
|
4453
|
+
* Get a list of all of your existing feature flags matching the criteria specified.
|
|
4454
|
+
* @param options - Pagination and filter options.
|
|
4455
|
+
* @returns {Promise<AutoPaginatable<FeatureFlag>>}
|
|
4456
|
+
* @throws {BadRequestException} 400
|
|
4457
|
+
* @throws {NotFoundException} 404
|
|
4458
|
+
* @throws {UnprocessableEntityException} 422
|
|
4459
|
+
*/
|
|
4031
4460
|
async listFeatureFlags(options) {
|
|
4032
4461
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/feature-flags", deserializeFeatureFlag, options), (params) => fetchAndDeserialize(this.workos, "/feature-flags", deserializeFeatureFlag, params), options);
|
|
4033
4462
|
}
|
|
4463
|
+
/**
|
|
4464
|
+
* Get a feature flag
|
|
4465
|
+
*
|
|
4466
|
+
* Get the details of an existing feature flag by its slug.
|
|
4467
|
+
* @param slug - A unique key to reference the Feature Flag.
|
|
4468
|
+
*
|
|
4469
|
+
* @example
|
|
4470
|
+
* "advanced-analytics"
|
|
4471
|
+
*
|
|
4472
|
+
* @returns {Promise<FeatureFlag>}
|
|
4473
|
+
* @throws {NotFoundException} 404
|
|
4474
|
+
*/
|
|
4034
4475
|
async getFeatureFlag(slug) {
|
|
4035
4476
|
const { data } = await this.workos.get(`/feature-flags/${slug}`);
|
|
4036
4477
|
return deserializeFeatureFlag(data);
|
|
4037
4478
|
}
|
|
4479
|
+
/**
|
|
4480
|
+
* Enable a feature flag
|
|
4481
|
+
*
|
|
4482
|
+
* Enables a feature flag in the current environment.
|
|
4483
|
+
* @param slug - A unique key to reference the Feature Flag.
|
|
4484
|
+
*
|
|
4485
|
+
* @example
|
|
4486
|
+
* "advanced-analytics"
|
|
4487
|
+
*
|
|
4488
|
+
* @returns {Promise<FeatureFlag>}
|
|
4489
|
+
* @throws {NotFoundException} 404
|
|
4490
|
+
*/
|
|
4038
4491
|
async enableFeatureFlag(slug) {
|
|
4039
4492
|
const { data } = await this.workos.put(`/feature-flags/${slug}/enable`, {});
|
|
4040
4493
|
return deserializeFeatureFlag(data);
|
|
4041
4494
|
}
|
|
4495
|
+
/**
|
|
4496
|
+
* Disable a feature flag
|
|
4497
|
+
*
|
|
4498
|
+
* Disables a feature flag in the current environment.
|
|
4499
|
+
* @param slug - A unique key to reference the Feature Flag.
|
|
4500
|
+
*
|
|
4501
|
+
* @example
|
|
4502
|
+
* "advanced-analytics"
|
|
4503
|
+
*
|
|
4504
|
+
* @returns {Promise<FeatureFlag>}
|
|
4505
|
+
* @throws {NotFoundException} 404
|
|
4506
|
+
*/
|
|
4042
4507
|
async disableFeatureFlag(slug) {
|
|
4043
4508
|
const { data } = await this.workos.put(`/feature-flags/${slug}/disable`, {});
|
|
4044
4509
|
return deserializeFeatureFlag(data);
|
|
4045
4510
|
}
|
|
4511
|
+
/**
|
|
4512
|
+
* Add a feature flag target
|
|
4513
|
+
*
|
|
4514
|
+
* Enables a feature flag for a specific target in the current environment. Currently, supported targets include users and organizations.
|
|
4515
|
+
* @params options - Object containing slug and targetId.
|
|
4516
|
+
* @returns {Promise<void>}
|
|
4517
|
+
* @throws {BadRequestException} 400
|
|
4518
|
+
* @throws 403 response from the API.
|
|
4519
|
+
* @throws {NotFoundException} 404
|
|
4520
|
+
*/
|
|
4046
4521
|
async addFlagTarget(options) {
|
|
4047
4522
|
const { slug, targetId } = options;
|
|
4048
4523
|
await this.workos.post(`/feature-flags/${slug}/targets/${targetId}`, {});
|
|
4049
4524
|
}
|
|
4525
|
+
/**
|
|
4526
|
+
* Remove a feature flag target
|
|
4527
|
+
*
|
|
4528
|
+
* Removes a target from the feature flag's target list in the current environment. Currently, supported targets include users and organizations.
|
|
4529
|
+
* @params options - Object containing slug and targetId.
|
|
4530
|
+
* @returns {Promise<void>}
|
|
4531
|
+
* @throws {BadRequestException} 400
|
|
4532
|
+
* @throws 403 response from the API.
|
|
4533
|
+
* @throws {NotFoundException} 404
|
|
4534
|
+
*/
|
|
4050
4535
|
async removeFlagTarget(options) {
|
|
4051
4536
|
const { slug, targetId } = options;
|
|
4052
4537
|
await this.workos.delete(`/feature-flags/${slug}/targets/${targetId}`);
|
|
4053
4538
|
}
|
|
4539
|
+
/**
|
|
4540
|
+
* List enabled feature flags for an organization
|
|
4541
|
+
*
|
|
4542
|
+
* Get a list of all enabled feature flags for an organization.
|
|
4543
|
+
* @param options - Pagination and filter options.
|
|
4544
|
+
* @returns {Promise<AutoPaginatable<FeatureFlag>>}
|
|
4545
|
+
* @throws {NotFoundException} 404
|
|
4546
|
+
*/
|
|
4547
|
+
async listOrganizationFeatureFlags(options) {
|
|
4548
|
+
const { organizationId, ...paginationOptions } = options;
|
|
4549
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/organizations/${organizationId}/feature-flags`, deserializeFeatureFlag, paginationOptions), (params) => fetchAndDeserialize(this.workos, `/organizations/${organizationId}/feature-flags`, deserializeFeatureFlag, params), paginationOptions);
|
|
4550
|
+
}
|
|
4551
|
+
/**
|
|
4552
|
+
* List enabled feature flags for a user
|
|
4553
|
+
*
|
|
4554
|
+
* @param options - Pagination and filter options.
|
|
4555
|
+
* @returns {Promise<AutoPaginatable<Flag>>}
|
|
4556
|
+
* @throws {NotFoundException} 404
|
|
4557
|
+
*/
|
|
4558
|
+
async listUserFeatureFlags(options) {
|
|
4559
|
+
const { userId, ...paginationOptions } = options;
|
|
4560
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/user_management/users/${userId}/feature-flags`, deserializeFeatureFlag, paginationOptions), (params) => fetchAndDeserialize(this.workos, `/user_management/users/${userId}/feature-flags`, deserializeFeatureFlag, params), paginationOptions);
|
|
4561
|
+
}
|
|
4054
4562
|
createRuntimeClient(options) {
|
|
4055
4563
|
return new FeatureFlagsRuntimeClient(this.workos, options);
|
|
4056
4564
|
}
|
|
4057
4565
|
};
|
|
4058
4566
|
//#endregion
|
|
4567
|
+
//#region src/groups/groups.ts
|
|
4568
|
+
var Groups = class {
|
|
4569
|
+
constructor(workos) {
|
|
4570
|
+
this.workos = workos;
|
|
4571
|
+
}
|
|
4572
|
+
async createGroup(options) {
|
|
4573
|
+
const { organizationId, ...payload } = options;
|
|
4574
|
+
const { data } = await this.workos.post(`/organizations/${organizationId}/groups`, serializeCreateGroupOptions(payload));
|
|
4575
|
+
return deserializeGroup(data);
|
|
4576
|
+
}
|
|
4577
|
+
async listGroups(options) {
|
|
4578
|
+
const { organizationId, ...paginationOptions } = options;
|
|
4579
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/organizations/${organizationId}/groups`, deserializeGroup, paginationOptions), (params) => fetchAndDeserialize(this.workos, `/organizations/${organizationId}/groups`, deserializeGroup, params), paginationOptions);
|
|
4580
|
+
}
|
|
4581
|
+
async getGroup(options) {
|
|
4582
|
+
const { organizationId, groupId } = options;
|
|
4583
|
+
const { data } = await this.workos.get(`/organizations/${organizationId}/groups/${groupId}`);
|
|
4584
|
+
return deserializeGroup(data);
|
|
4585
|
+
}
|
|
4586
|
+
async updateGroup(options) {
|
|
4587
|
+
const { organizationId, groupId, ...payload } = options;
|
|
4588
|
+
const { data } = await this.workos.patch(`/organizations/${organizationId}/groups/${groupId}`, serializeUpdateGroupOptions(payload));
|
|
4589
|
+
return deserializeGroup(data);
|
|
4590
|
+
}
|
|
4591
|
+
async deleteGroup(options) {
|
|
4592
|
+
const { organizationId, groupId } = options;
|
|
4593
|
+
await this.workos.delete(`/organizations/${organizationId}/groups/${groupId}`);
|
|
4594
|
+
}
|
|
4595
|
+
async addOrganizationMembership(options) {
|
|
4596
|
+
const { organizationId, groupId, ...payload } = options;
|
|
4597
|
+
const { data } = await this.workos.post(`/organizations/${organizationId}/groups/${groupId}/organization-memberships`, serializeAddGroupOrganizationMembershipOptions(payload));
|
|
4598
|
+
return deserializeGroup(data);
|
|
4599
|
+
}
|
|
4600
|
+
async listOrganizationMemberships(options) {
|
|
4601
|
+
const { organizationId, groupId, ...paginationOptions } = options;
|
|
4602
|
+
const endpoint = `/organizations/${organizationId}/groups/${groupId}/organization-memberships`;
|
|
4603
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, paginationOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, params), paginationOptions);
|
|
4604
|
+
}
|
|
4605
|
+
async removeOrganizationMembership(options) {
|
|
4606
|
+
const { organizationId, groupId, organizationMembershipId } = options;
|
|
4607
|
+
await this.workos.delete(`/organizations/${organizationId}/groups/${groupId}/organization-memberships/${organizationMembershipId}`);
|
|
4608
|
+
}
|
|
4609
|
+
};
|
|
4610
|
+
//#endregion
|
|
4059
4611
|
//#region src/widgets/interfaces/get-token.ts
|
|
4060
4612
|
const serializeGetTokenOptions = (options) => ({
|
|
4061
4613
|
organization_id: options.organizationId,
|
|
@@ -4069,9 +4621,19 @@ var Widgets = class {
|
|
|
4069
4621
|
constructor(workos) {
|
|
4070
4622
|
this.workos = workos;
|
|
4071
4623
|
}
|
|
4072
|
-
|
|
4624
|
+
/**
|
|
4625
|
+
* Generate a widget token
|
|
4626
|
+
*
|
|
4627
|
+
* Generate a widget token scoped to an organization and user with the specified scopes.
|
|
4628
|
+
* @param payload - Object containing organizationId.
|
|
4629
|
+
* @returns {Promise<GetTokenResponse>}
|
|
4630
|
+
* @throws {BadRequestException} 400
|
|
4631
|
+
* @throws {NotFoundException} 404
|
|
4632
|
+
* @throws {UnprocessableEntityException} 422
|
|
4633
|
+
*/
|
|
4634
|
+
async createToken(payload) {
|
|
4073
4635
|
const { data } = await this.workos.post("/widgets/token", serializeGetTokenOptions(payload));
|
|
4074
|
-
return deserializeGetTokenResponse(data)
|
|
4636
|
+
return deserializeGetTokenResponse(data);
|
|
4075
4637
|
}
|
|
4076
4638
|
};
|
|
4077
4639
|
//#endregion
|
|
@@ -4244,15 +4806,37 @@ const serializeRemoveRoleOptions = (options) => ({
|
|
|
4244
4806
|
}
|
|
4245
4807
|
});
|
|
4246
4808
|
//#endregion
|
|
4809
|
+
//#region src/authorization/serializers/list-effective-permissions-options.serializer.ts
|
|
4810
|
+
const serializeListEffectivePermissionsOptions = (options) => ({ ...serializePaginationOptions(options) });
|
|
4811
|
+
//#endregion
|
|
4247
4812
|
//#region src/authorization/authorization.ts
|
|
4248
4813
|
var Authorization = class {
|
|
4249
4814
|
constructor(workos) {
|
|
4250
4815
|
this.workos = workos;
|
|
4251
4816
|
}
|
|
4817
|
+
/**
|
|
4818
|
+
* Create an environment role
|
|
4819
|
+
*
|
|
4820
|
+
* Create a new environment role.
|
|
4821
|
+
* @param options - Object containing slug, name.
|
|
4822
|
+
* @returns {Promise<EnvironmentRole>}
|
|
4823
|
+
* @throws {BadRequestException} 400
|
|
4824
|
+
* @throws 403 response from the API.
|
|
4825
|
+
* @throws {NotFoundException} 404
|
|
4826
|
+
* @throws {ConflictException} 409
|
|
4827
|
+
* @throws {UnprocessableEntityException} 422
|
|
4828
|
+
*/
|
|
4252
4829
|
async createEnvironmentRole(options) {
|
|
4253
4830
|
const { data } = await this.workos.post("/authorization/roles", serializeCreateEnvironmentRoleOptions(options));
|
|
4254
4831
|
return deserializeEnvironmentRole(data);
|
|
4255
4832
|
}
|
|
4833
|
+
/**
|
|
4834
|
+
* List environment roles
|
|
4835
|
+
*
|
|
4836
|
+
* List all environment roles in priority order.
|
|
4837
|
+
* @returns {Promise<EnvironmentRoleList>}
|
|
4838
|
+
* @throws 403 response from the API.
|
|
4839
|
+
*/
|
|
4256
4840
|
async listEnvironmentRoles() {
|
|
4257
4841
|
const { data } = await this.workos.get("/authorization/roles");
|
|
4258
4842
|
return {
|
|
@@ -4260,185 +4844,713 @@ var Authorization = class {
|
|
|
4260
4844
|
data: data.data.map(deserializeEnvironmentRole)
|
|
4261
4845
|
};
|
|
4262
4846
|
}
|
|
4847
|
+
/**
|
|
4848
|
+
* Get an environment role
|
|
4849
|
+
*
|
|
4850
|
+
* Get an environment role by its slug.
|
|
4851
|
+
* @param slug - The slug of the environment role.
|
|
4852
|
+
*
|
|
4853
|
+
* @example
|
|
4854
|
+
* "admin"
|
|
4855
|
+
*
|
|
4856
|
+
* @returns {Promise<EnvironmentRole>}
|
|
4857
|
+
* @throws 403 response from the API.
|
|
4858
|
+
* @throws {NotFoundException} 404
|
|
4859
|
+
*/
|
|
4263
4860
|
async getEnvironmentRole(slug) {
|
|
4264
4861
|
const { data } = await this.workos.get(`/authorization/roles/${slug}`);
|
|
4265
4862
|
return deserializeEnvironmentRole(data);
|
|
4266
4863
|
}
|
|
4864
|
+
/**
|
|
4865
|
+
* Update an environment role
|
|
4866
|
+
*
|
|
4867
|
+
* Update an existing environment role.
|
|
4868
|
+
* @param slug - The slug of the environment role.
|
|
4869
|
+
*
|
|
4870
|
+
* @example
|
|
4871
|
+
* "admin"
|
|
4872
|
+
*
|
|
4873
|
+
* @param options - The request body.
|
|
4874
|
+
* @returns {Promise<EnvironmentRole>}
|
|
4875
|
+
* @throws {BadRequestException} 400
|
|
4876
|
+
* @throws 403 response from the API.
|
|
4877
|
+
* @throws {NotFoundException} 404
|
|
4878
|
+
* @throws {UnprocessableEntityException} 422
|
|
4879
|
+
*/
|
|
4267
4880
|
async updateEnvironmentRole(slug, options) {
|
|
4268
4881
|
const { data } = await this.workos.patch(`/authorization/roles/${slug}`, serializeUpdateEnvironmentRoleOptions(options));
|
|
4269
4882
|
return deserializeEnvironmentRole(data);
|
|
4270
4883
|
}
|
|
4884
|
+
/**
|
|
4885
|
+
* Set permissions for an environment role
|
|
4886
|
+
*
|
|
4887
|
+
* Replace all permissions on an environment role with the provided list.
|
|
4888
|
+
* @param slug - The slug of the environment role.
|
|
4889
|
+
*
|
|
4890
|
+
* @example
|
|
4891
|
+
* "admin"
|
|
4892
|
+
*
|
|
4893
|
+
* @param options - Object containing permissions.
|
|
4894
|
+
* @returns {Promise<EnvironmentRole>}
|
|
4895
|
+
* @throws {BadRequestException} 400
|
|
4896
|
+
* @throws 403 response from the API.
|
|
4897
|
+
* @throws {NotFoundException} 404
|
|
4898
|
+
* @throws {UnprocessableEntityException} 422
|
|
4899
|
+
*/
|
|
4271
4900
|
async setEnvironmentRolePermissions(slug, options) {
|
|
4272
4901
|
const { data } = await this.workos.put(`/authorization/roles/${slug}/permissions`, { permissions: options.permissions });
|
|
4273
4902
|
return deserializeEnvironmentRole(data);
|
|
4274
4903
|
}
|
|
4904
|
+
/**
|
|
4905
|
+
* Add a permission to an environment role
|
|
4906
|
+
*
|
|
4907
|
+
* Add a single permission to an environment role. If the permission is already assigned to the role, this operation has no effect.
|
|
4908
|
+
* @param slug - The slug of the environment role.
|
|
4909
|
+
*
|
|
4910
|
+
* @example
|
|
4911
|
+
* "admin"
|
|
4912
|
+
*
|
|
4913
|
+
* @param options - Object containing slug.
|
|
4914
|
+
* @returns {Promise<EnvironmentRole>}
|
|
4915
|
+
* @throws {BadRequestException} 400
|
|
4916
|
+
* @throws 403 response from the API.
|
|
4917
|
+
* @throws {NotFoundException} 404
|
|
4918
|
+
* @throws {UnprocessableEntityException} 422
|
|
4919
|
+
*/
|
|
4275
4920
|
async addEnvironmentRolePermission(slug, options) {
|
|
4276
4921
|
const { data } = await this.workos.post(`/authorization/roles/${slug}/permissions`, { slug: options.permissionSlug });
|
|
4277
4922
|
return deserializeEnvironmentRole(data);
|
|
4278
4923
|
}
|
|
4924
|
+
/**
|
|
4925
|
+
* Create a custom role
|
|
4926
|
+
*
|
|
4927
|
+
* Create a new custom role for this organization.
|
|
4928
|
+
* @param organizationId - The ID of the organization.
|
|
4929
|
+
*
|
|
4930
|
+
* @example
|
|
4931
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
4932
|
+
*
|
|
4933
|
+
* @param options - Object containing name.
|
|
4934
|
+
* @returns {Promise<OrganizationRole>}
|
|
4935
|
+
* @throws {BadRequestException} 400
|
|
4936
|
+
* @throws 403 response from the API.
|
|
4937
|
+
* @throws {NotFoundException} 404
|
|
4938
|
+
* @throws {ConflictException} 409
|
|
4939
|
+
* @throws {UnprocessableEntityException} 422
|
|
4940
|
+
*/
|
|
4279
4941
|
async createOrganizationRole(organizationId, options) {
|
|
4280
4942
|
const { data } = await this.workos.post(`/authorization/organizations/${organizationId}/roles`, serializeCreateOrganizationRoleOptions(options));
|
|
4281
4943
|
return deserializeOrganizationRole(data);
|
|
4282
4944
|
}
|
|
4945
|
+
/**
|
|
4946
|
+
* List custom roles
|
|
4947
|
+
*
|
|
4948
|
+
* Get a list of all roles that apply to an organization. This includes both environment roles and custom roles, returned in priority order.
|
|
4949
|
+
* @param organizationId - The ID of the organization.
|
|
4950
|
+
*
|
|
4951
|
+
* @example
|
|
4952
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
4953
|
+
*
|
|
4954
|
+
* @returns {Promise<RoleList>}
|
|
4955
|
+
* @throws 403 response from the API.
|
|
4956
|
+
* @throws {NotFoundException} 404
|
|
4957
|
+
*/
|
|
4283
4958
|
async listOrganizationRoles(organizationId) {
|
|
4284
4959
|
const { data } = await this.workos.get(`/authorization/organizations/${organizationId}/roles`);
|
|
4285
4960
|
return {
|
|
4286
4961
|
object: "list",
|
|
4287
|
-
data: data.data.map(deserializeRole
|
|
4962
|
+
data: data.data.map(deserializeRole)
|
|
4288
4963
|
};
|
|
4289
4964
|
}
|
|
4965
|
+
/**
|
|
4966
|
+
* Get a custom role
|
|
4967
|
+
*
|
|
4968
|
+
* Retrieve a role that applies to an organization by its slug. This can return either an environment role or a custom role.
|
|
4969
|
+
* @param organizationId - The ID of the organization.
|
|
4970
|
+
*
|
|
4971
|
+
* @example
|
|
4972
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
4973
|
+
*
|
|
4974
|
+
* @param slug - The slug of the role.
|
|
4975
|
+
*
|
|
4976
|
+
* @example
|
|
4977
|
+
* "org-billing-admin"
|
|
4978
|
+
*
|
|
4979
|
+
* @returns {Promise<Role>}
|
|
4980
|
+
* @throws 403 response from the API.
|
|
4981
|
+
* @throws {NotFoundException} 404
|
|
4982
|
+
*/
|
|
4290
4983
|
async getOrganizationRole(organizationId, slug) {
|
|
4291
4984
|
const { data } = await this.workos.get(`/authorization/organizations/${organizationId}/roles/${slug}`);
|
|
4292
|
-
return deserializeRole
|
|
4985
|
+
return deserializeRole(data);
|
|
4293
4986
|
}
|
|
4987
|
+
/**
|
|
4988
|
+
* Update a custom role
|
|
4989
|
+
*
|
|
4990
|
+
* Update an existing custom role. Only the fields provided in the request body will be updated.
|
|
4991
|
+
* @param organizationId - The ID of the organization.
|
|
4992
|
+
*
|
|
4993
|
+
* @example
|
|
4994
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
4995
|
+
*
|
|
4996
|
+
* @param slug - The slug of the role.
|
|
4997
|
+
*
|
|
4998
|
+
* @example
|
|
4999
|
+
* "org-billing-admin"
|
|
5000
|
+
*
|
|
5001
|
+
* @param options - The request body.
|
|
5002
|
+
* @returns {Promise<OrganizationRole>}
|
|
5003
|
+
* @throws {BadRequestException} 400
|
|
5004
|
+
* @throws 403 response from the API.
|
|
5005
|
+
* @throws {NotFoundException} 404
|
|
5006
|
+
* @throws {UnprocessableEntityException} 422
|
|
5007
|
+
*/
|
|
4294
5008
|
async updateOrganizationRole(organizationId, slug, options) {
|
|
4295
5009
|
const { data } = await this.workos.patch(`/authorization/organizations/${organizationId}/roles/${slug}`, serializeUpdateOrganizationRoleOptions(options));
|
|
4296
5010
|
return deserializeOrganizationRole(data);
|
|
4297
5011
|
}
|
|
5012
|
+
/**
|
|
5013
|
+
* Delete a custom role
|
|
5014
|
+
*
|
|
5015
|
+
* Delete an existing custom role.
|
|
5016
|
+
* @param organizationId - The ID of the organization.
|
|
5017
|
+
*
|
|
5018
|
+
* @example
|
|
5019
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
5020
|
+
*
|
|
5021
|
+
* @param slug - The slug of the role.
|
|
5022
|
+
*
|
|
5023
|
+
* @example
|
|
5024
|
+
* "org-admin"
|
|
5025
|
+
*
|
|
5026
|
+
* @returns {Promise<void>}
|
|
5027
|
+
* @throws {BadRequestException} 400
|
|
5028
|
+
* @throws 403 response from the API.
|
|
5029
|
+
* @throws {NotFoundException} 404
|
|
5030
|
+
* @throws {ConflictException} 409
|
|
5031
|
+
*/
|
|
4298
5032
|
async deleteOrganizationRole(organizationId, slug) {
|
|
4299
5033
|
await this.workos.delete(`/authorization/organizations/${organizationId}/roles/${slug}`);
|
|
4300
5034
|
}
|
|
4301
|
-
|
|
5035
|
+
/**
|
|
5036
|
+
* Set permissions for a custom role
|
|
5037
|
+
*
|
|
5038
|
+
* Replace all permissions on a custom role with the provided list.
|
|
5039
|
+
* @param organizationId - The ID of the organization.
|
|
5040
|
+
*
|
|
5041
|
+
* @example
|
|
5042
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
5043
|
+
*
|
|
5044
|
+
* @param slug - The slug of the role.
|
|
5045
|
+
*
|
|
5046
|
+
* @example
|
|
5047
|
+
* "org-admin"
|
|
5048
|
+
*
|
|
5049
|
+
* @param options - Object containing permissions.
|
|
5050
|
+
* @returns {Promise<Role>}
|
|
5051
|
+
* @throws 403 response from the API.
|
|
5052
|
+
* @throws {NotFoundException} 404
|
|
5053
|
+
* @throws {UnprocessableEntityException} 422
|
|
5054
|
+
*/
|
|
5055
|
+
async updateRolePermissions(organizationId, slug, options) {
|
|
4302
5056
|
const { data } = await this.workos.put(`/authorization/organizations/${organizationId}/roles/${slug}/permissions`, { permissions: options.permissions });
|
|
4303
5057
|
return deserializeOrganizationRole(data);
|
|
4304
5058
|
}
|
|
4305
|
-
|
|
5059
|
+
/**
|
|
5060
|
+
* Add a permission to a custom role
|
|
5061
|
+
*
|
|
5062
|
+
* Add a single permission to a custom role. If the permission is already assigned to the role, this operation has no effect.
|
|
5063
|
+
* @param organizationId - The ID of the organization.
|
|
5064
|
+
*
|
|
5065
|
+
* @example
|
|
5066
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
5067
|
+
*
|
|
5068
|
+
* @param slug - The slug of the role.
|
|
5069
|
+
*
|
|
5070
|
+
* @example
|
|
5071
|
+
* "org-admin"
|
|
5072
|
+
*
|
|
5073
|
+
* @param options - Object containing slug.
|
|
5074
|
+
* @returns {Promise<Role>}
|
|
5075
|
+
* @throws {BadRequestException} 400
|
|
5076
|
+
* @throws 403 response from the API.
|
|
5077
|
+
* @throws {NotFoundException} 404
|
|
5078
|
+
* @throws {UnprocessableEntityException} 422
|
|
5079
|
+
*/
|
|
5080
|
+
async createRolePermission(organizationId, slug, options) {
|
|
4306
5081
|
const { data } = await this.workos.post(`/authorization/organizations/${organizationId}/roles/${slug}/permissions`, { slug: options.permissionSlug });
|
|
4307
5082
|
return deserializeOrganizationRole(data);
|
|
4308
5083
|
}
|
|
4309
|
-
|
|
5084
|
+
/**
|
|
5085
|
+
* Remove a permission from a custom role
|
|
5086
|
+
*
|
|
5087
|
+
* Remove a single permission from a custom role by its slug.
|
|
5088
|
+
* @param organizationId - The ID of the organization.
|
|
5089
|
+
*
|
|
5090
|
+
* @example
|
|
5091
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
5092
|
+
*
|
|
5093
|
+
* @param slug - The slug of the role.
|
|
5094
|
+
*
|
|
5095
|
+
* @example
|
|
5096
|
+
* "org-admin"
|
|
5097
|
+
*
|
|
5098
|
+
* @param permissionSlug - The slug of the permission to remove.
|
|
5099
|
+
*
|
|
5100
|
+
* @example
|
|
5101
|
+
* "documents:read"
|
|
5102
|
+
*
|
|
5103
|
+
* @returns {Promise<void>}
|
|
5104
|
+
* @throws 403 response from the API.
|
|
5105
|
+
* @throws {NotFoundException} 404
|
|
5106
|
+
*/
|
|
5107
|
+
async deleteRolePermission(organizationId, slug, options) {
|
|
4310
5108
|
await this.workos.delete(`/authorization/organizations/${organizationId}/roles/${slug}/permissions/${options.permissionSlug}`);
|
|
4311
5109
|
}
|
|
5110
|
+
/**
|
|
5111
|
+
* Create a permission
|
|
5112
|
+
*
|
|
5113
|
+
* Create a new permission in your WorkOS environment. The permission can then be assigned to environment roles and custom roles.
|
|
5114
|
+
* @param options - Object containing slug, name.
|
|
5115
|
+
* @returns {Promise<Permission>}
|
|
5116
|
+
* @throws {BadRequestException} 400
|
|
5117
|
+
* @throws {NotFoundException} 404
|
|
5118
|
+
* @throws {ConflictException} 409
|
|
5119
|
+
* @throws {UnprocessableEntityException} 422
|
|
5120
|
+
*/
|
|
4312
5121
|
async createPermission(options) {
|
|
4313
5122
|
const { data } = await this.workos.post("/authorization/permissions", serializeCreatePermissionOptions(options));
|
|
4314
5123
|
return deserializePermission(data);
|
|
4315
5124
|
}
|
|
5125
|
+
/**
|
|
5126
|
+
* List permissions
|
|
5127
|
+
*
|
|
5128
|
+
* Get a list of all permissions in your WorkOS environment.
|
|
5129
|
+
* @param options - Pagination and filter options.
|
|
5130
|
+
* @returns {Promise<AutoPaginatable<Permission, PaginationOptions>>}
|
|
5131
|
+
* @throws {NotFoundException} 404
|
|
5132
|
+
*/
|
|
4316
5133
|
async listPermissions(options) {
|
|
4317
|
-
|
|
4318
|
-
return {
|
|
4319
|
-
object: "list",
|
|
4320
|
-
data: data.data.map(deserializePermission),
|
|
4321
|
-
listMetadata: {
|
|
4322
|
-
before: data.list_metadata.before,
|
|
4323
|
-
after: data.list_metadata.after
|
|
4324
|
-
}
|
|
4325
|
-
};
|
|
5134
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/authorization/permissions", deserializePermission, options), (params) => fetchAndDeserialize(this.workos, "/authorization/permissions", deserializePermission, params), options);
|
|
4326
5135
|
}
|
|
5136
|
+
/**
|
|
5137
|
+
* Get a permission
|
|
5138
|
+
*
|
|
5139
|
+
* Retrieve a permission by its unique slug.
|
|
5140
|
+
* @param slug - A unique key to reference the permission. Must be lowercase and contain only letters, numbers, hyphens, underscores, colons, periods, and asterisks.
|
|
5141
|
+
*
|
|
5142
|
+
* @example
|
|
5143
|
+
* "documents:read"
|
|
5144
|
+
*
|
|
5145
|
+
* @returns {Promise<Permission>}
|
|
5146
|
+
* @throws {NotFoundException} 404
|
|
5147
|
+
*/
|
|
4327
5148
|
async getPermission(slug) {
|
|
4328
5149
|
const { data } = await this.workos.get(`/authorization/permissions/${slug}`);
|
|
4329
5150
|
return deserializePermission(data);
|
|
4330
5151
|
}
|
|
5152
|
+
/**
|
|
5153
|
+
* Update a permission
|
|
5154
|
+
*
|
|
5155
|
+
* Update an existing permission. Only the fields provided in the request body will be updated.
|
|
5156
|
+
* @param slug - A unique key to reference the permission. Must be lowercase and contain only letters, numbers, hyphens, underscores, colons, periods, and asterisks.
|
|
5157
|
+
*
|
|
5158
|
+
* @example
|
|
5159
|
+
* "documents:read"
|
|
5160
|
+
*
|
|
5161
|
+
* @param options - The request body.
|
|
5162
|
+
* @returns {Promise<Permission>}
|
|
5163
|
+
* @throws 403 response from the API.
|
|
5164
|
+
* @throws {NotFoundException} 404
|
|
5165
|
+
* @throws {UnprocessableEntityException} 422
|
|
5166
|
+
*/
|
|
4331
5167
|
async updatePermission(slug, options) {
|
|
4332
5168
|
const { data } = await this.workos.patch(`/authorization/permissions/${slug}`, serializeUpdatePermissionOptions(options));
|
|
4333
5169
|
return deserializePermission(data);
|
|
4334
5170
|
}
|
|
5171
|
+
/**
|
|
5172
|
+
* Delete a permission
|
|
5173
|
+
*
|
|
5174
|
+
* Delete an existing permission. System permissions cannot be deleted.
|
|
5175
|
+
* @param slug - A unique key to reference the permission. Must be lowercase and contain only letters, numbers, hyphens, underscores, colons, periods, and asterisks.
|
|
5176
|
+
*
|
|
5177
|
+
* @example
|
|
5178
|
+
* "documents:read"
|
|
5179
|
+
*
|
|
5180
|
+
* @returns {Promise<void>}
|
|
5181
|
+
* @throws 403 response from the API.
|
|
5182
|
+
* @throws {NotFoundException} 404
|
|
5183
|
+
*/
|
|
4335
5184
|
async deletePermission(slug) {
|
|
4336
5185
|
await this.workos.delete(`/authorization/permissions/${slug}`);
|
|
4337
5186
|
}
|
|
5187
|
+
/**
|
|
5188
|
+
* Get a resource
|
|
5189
|
+
*
|
|
5190
|
+
* Retrieve the details of an authorization resource by its ID.
|
|
5191
|
+
* @param resourceId - The ID of the authorization resource.
|
|
5192
|
+
*
|
|
5193
|
+
* @example
|
|
5194
|
+
* "authz_resource_01HXYZ123456789ABCDEFGHIJ"
|
|
5195
|
+
*
|
|
5196
|
+
* @returns {Promise<AuthorizationResource>}
|
|
5197
|
+
* @throws 403 response from the API.
|
|
5198
|
+
* @throws {NotFoundException} 404
|
|
5199
|
+
* @throws {UnprocessableEntityException} 422
|
|
5200
|
+
*/
|
|
4338
5201
|
async getResource(resourceId) {
|
|
4339
5202
|
const { data } = await this.workos.get(`/authorization/resources/${resourceId}`);
|
|
4340
5203
|
return deserializeAuthorizationResource(data);
|
|
4341
5204
|
}
|
|
5205
|
+
/**
|
|
5206
|
+
* Create an authorization resource
|
|
5207
|
+
*
|
|
5208
|
+
* Create a new authorization resource.
|
|
5209
|
+
* @param options - Object containing externalId, name, resourceTypeSlug, organizationId.
|
|
5210
|
+
* @returns {Promise<AuthorizationResource>}
|
|
5211
|
+
* @throws {BadRequestException} 400
|
|
5212
|
+
* @throws 403 response from the API.
|
|
5213
|
+
* @throws {NotFoundException} 404
|
|
5214
|
+
* @throws {ConflictException} 409
|
|
5215
|
+
* @throws {UnprocessableEntityException} 422
|
|
5216
|
+
*/
|
|
4342
5217
|
async createResource(options) {
|
|
4343
5218
|
const { data } = await this.workos.post("/authorization/resources", serializeCreateResourceOptions(options));
|
|
4344
5219
|
return deserializeAuthorizationResource(data);
|
|
4345
5220
|
}
|
|
5221
|
+
/**
|
|
5222
|
+
* Update a resource
|
|
5223
|
+
*
|
|
5224
|
+
* Update an existing authorization resource.
|
|
5225
|
+
* @param options - The request body.
|
|
5226
|
+
* @returns {Promise<AuthorizationResource>}
|
|
5227
|
+
* @throws {BadRequestException} 400
|
|
5228
|
+
* @throws 403 response from the API.
|
|
5229
|
+
* @throws {NotFoundException} 404
|
|
5230
|
+
* @throws {ConflictException} 409
|
|
5231
|
+
* @throws {UnprocessableEntityException} 422
|
|
5232
|
+
*/
|
|
4346
5233
|
async updateResource(options) {
|
|
4347
5234
|
const { data } = await this.workos.patch(`/authorization/resources/${options.resourceId}`, serializeUpdateResourceOptions(options));
|
|
4348
5235
|
return deserializeAuthorizationResource(data);
|
|
4349
5236
|
}
|
|
5237
|
+
/**
|
|
5238
|
+
* Delete an authorization resource
|
|
5239
|
+
*
|
|
5240
|
+
* Delete an authorization resource and all its descendants.
|
|
5241
|
+
* @param options.cascadeDelete - If true, deletes all descendant resources and role assignments. If not set and the resource has children or assignments, the request will fail.
|
|
5242
|
+
* @default false
|
|
5243
|
+
* @param options - Additional query options.
|
|
5244
|
+
* @returns {Promise<void>}
|
|
5245
|
+
* @throws {BadRequestException} 400
|
|
5246
|
+
* @throws 403 response from the API.
|
|
5247
|
+
* @throws {NotFoundException} 404
|
|
5248
|
+
* @throws {ConflictException} 409
|
|
5249
|
+
*/
|
|
4350
5250
|
async deleteResource(options) {
|
|
4351
5251
|
const { resourceId, cascadeDelete } = options;
|
|
4352
5252
|
const query = cascadeDelete !== void 0 ? { cascade_delete: cascadeDelete.toString() } : void 0;
|
|
4353
5253
|
await this.workos.delete(`/authorization/resources/${resourceId}`, query);
|
|
4354
5254
|
}
|
|
5255
|
+
/**
|
|
5256
|
+
* List resources
|
|
5257
|
+
*
|
|
5258
|
+
* Get a paginated list of authorization resources.
|
|
5259
|
+
* @param options - Pagination and filter options.
|
|
5260
|
+
* @returns {Promise<AutoPaginatable<AuthorizationResource, PaginationOptions>>}
|
|
5261
|
+
* @throws 403 response from the API.
|
|
5262
|
+
* @throws {UnprocessableEntityException} 422
|
|
5263
|
+
*/
|
|
4355
5264
|
async listResources(options = {}) {
|
|
4356
|
-
const
|
|
4357
|
-
return
|
|
4358
|
-
object: "list",
|
|
4359
|
-
data: data.data.map(deserializeAuthorizationResource),
|
|
4360
|
-
listMetadata: {
|
|
4361
|
-
before: data.list_metadata.before,
|
|
4362
|
-
after: data.list_metadata.after
|
|
4363
|
-
}
|
|
4364
|
-
};
|
|
5265
|
+
const serializedOptions = serializeListAuthorizationResourcesOptions(options);
|
|
5266
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/authorization/resources", deserializeAuthorizationResource, serializedOptions), (params) => fetchAndDeserialize(this.workos, "/authorization/resources", deserializeAuthorizationResource, params), serializedOptions);
|
|
4365
5267
|
}
|
|
4366
|
-
|
|
5268
|
+
/**
|
|
5269
|
+
* Get a resource by external ID
|
|
5270
|
+
*
|
|
5271
|
+
* Retrieve the details of an authorization resource by its external ID, organization, and resource type. This is useful when you only have the external ID from your system and need to fetch the full resource details.
|
|
5272
|
+
* @param organizationId - The ID of the organization that owns the resource.
|
|
5273
|
+
*
|
|
5274
|
+
* @example
|
|
5275
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
5276
|
+
*
|
|
5277
|
+
* @param resourceTypeSlug - The slug of the resource type.
|
|
5278
|
+
*
|
|
5279
|
+
* @example
|
|
5280
|
+
* "project"
|
|
5281
|
+
*
|
|
5282
|
+
* @param externalId - An identifier you provide to reference the resource in your system.
|
|
5283
|
+
*
|
|
5284
|
+
* @example
|
|
5285
|
+
* "proj-456"
|
|
5286
|
+
*
|
|
5287
|
+
* @returns {Promise<AuthorizationResource>}
|
|
5288
|
+
* @throws 403 response from the API.
|
|
5289
|
+
* @throws {NotFoundException} 404
|
|
5290
|
+
*/
|
|
5291
|
+
async getOrganizationResource(options) {
|
|
4367
5292
|
const { organizationId, resourceTypeSlug, externalId } = options;
|
|
4368
5293
|
const { data } = await this.workos.get(`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`);
|
|
4369
5294
|
return deserializeAuthorizationResource(data);
|
|
4370
5295
|
}
|
|
4371
|
-
|
|
5296
|
+
/**
|
|
5297
|
+
* Update a resource by external ID
|
|
5298
|
+
*
|
|
5299
|
+
* Update an existing authorization resource using its external ID.
|
|
5300
|
+
* @param organizationId - The ID of the organization that owns the resource.
|
|
5301
|
+
*
|
|
5302
|
+
* @example
|
|
5303
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
5304
|
+
*
|
|
5305
|
+
* @param resourceTypeSlug - The slug of the resource type.
|
|
5306
|
+
*
|
|
5307
|
+
* @example
|
|
5308
|
+
* "project"
|
|
5309
|
+
*
|
|
5310
|
+
* @param externalId - An identifier you provide to reference the resource in your system.
|
|
5311
|
+
*
|
|
5312
|
+
* @example
|
|
5313
|
+
* "proj-456"
|
|
5314
|
+
*
|
|
5315
|
+
* @param options - The request body.
|
|
5316
|
+
* @returns {Promise<AuthorizationResource>}
|
|
5317
|
+
* @throws {BadRequestException} 400
|
|
5318
|
+
* @throws 403 response from the API.
|
|
5319
|
+
* @throws {NotFoundException} 404
|
|
5320
|
+
* @throws {ConflictException} 409
|
|
5321
|
+
* @throws {UnprocessableEntityException} 422
|
|
5322
|
+
*/
|
|
5323
|
+
async updateOrganizationResource(options) {
|
|
4372
5324
|
const { organizationId, resourceTypeSlug, externalId } = options;
|
|
4373
5325
|
const { data } = await this.workos.patch(`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`, serializeUpdateResourceByExternalIdOptions(options));
|
|
4374
5326
|
return deserializeAuthorizationResource(data);
|
|
4375
5327
|
}
|
|
4376
|
-
|
|
5328
|
+
/**
|
|
5329
|
+
* Delete an authorization resource by external ID
|
|
5330
|
+
*
|
|
5331
|
+
* Delete an authorization resource by organization, resource type, and external ID. This also deletes all descendant resources.
|
|
5332
|
+
* @param organizationId - The ID of the organization that owns the resource.
|
|
5333
|
+
*
|
|
5334
|
+
* @example
|
|
5335
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
5336
|
+
*
|
|
5337
|
+
* @param resourceTypeSlug - The slug of the resource type.
|
|
5338
|
+
*
|
|
5339
|
+
* @example
|
|
5340
|
+
* "project"
|
|
5341
|
+
*
|
|
5342
|
+
* @param externalId - An identifier you provide to reference the resource in your system.
|
|
5343
|
+
*
|
|
5344
|
+
* @example
|
|
5345
|
+
* "proj-456"
|
|
5346
|
+
*
|
|
5347
|
+
* @param options - Additional query options.
|
|
5348
|
+
* @returns {Promise<void>}
|
|
5349
|
+
* @throws {BadRequestException} 400
|
|
5350
|
+
* @throws 403 response from the API.
|
|
5351
|
+
* @throws {NotFoundException} 404
|
|
5352
|
+
* @throws {ConflictException} 409
|
|
5353
|
+
*/
|
|
5354
|
+
async deleteOrganizationResource(options) {
|
|
4377
5355
|
const { organizationId, resourceTypeSlug, externalId, cascadeDelete } = options;
|
|
4378
5356
|
const query = cascadeDelete !== void 0 ? { cascade_delete: cascadeDelete.toString() } : void 0;
|
|
4379
5357
|
await this.workos.delete(`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`, query);
|
|
4380
5358
|
}
|
|
5359
|
+
/**
|
|
5360
|
+
* Check authorization
|
|
5361
|
+
*
|
|
5362
|
+
* Check if an organization membership has a specific permission on a resource. Supports identification by resource_id OR by resource_external_id + resource_type_slug.
|
|
5363
|
+
* @param options - Object containing permissionSlug.
|
|
5364
|
+
* @returns {Promise<AuthorizationCheckResult>}
|
|
5365
|
+
* @throws 403 response from the API.
|
|
5366
|
+
* @throws {NotFoundException} 404
|
|
5367
|
+
* @throws {UnprocessableEntityException} 422
|
|
5368
|
+
*/
|
|
4381
5369
|
async check(options) {
|
|
4382
5370
|
const { data } = await this.workos.post(`/authorization/organization_memberships/${options.organizationMembershipId}/check`, serializeAuthorizationCheckOptions(options));
|
|
4383
5371
|
return data;
|
|
4384
5372
|
}
|
|
4385
|
-
|
|
5373
|
+
/**
|
|
5374
|
+
* List role assignments
|
|
5375
|
+
*
|
|
5376
|
+
* List all role assignments for an organization membership. This returns all roles that have been assigned to the user on resources, including organization-level and sub-resource roles.
|
|
5377
|
+
* @param organizationMembershipId - The ID of the organization membership.
|
|
5378
|
+
*
|
|
5379
|
+
* @example
|
|
5380
|
+
* "om_01HXYZ123456789ABCDEFGHIJ"
|
|
5381
|
+
*
|
|
5382
|
+
* @param options - Pagination and filter options.
|
|
5383
|
+
* @returns {Promise<AutoPaginatable<RoleAssignment>>}
|
|
5384
|
+
* @throws 403 response from the API.
|
|
5385
|
+
* @throws {NotFoundException} 404
|
|
5386
|
+
*/
|
|
5387
|
+
async listOrganizationMembershipRoleAssignments(options) {
|
|
4386
5388
|
const { organizationMembershipId, ...queryOptions } = options;
|
|
4387
|
-
const
|
|
4388
|
-
return
|
|
4389
|
-
object: "list",
|
|
4390
|
-
data: data.data.map(deserializeRoleAssignment),
|
|
4391
|
-
listMetadata: {
|
|
4392
|
-
before: data.list_metadata.before,
|
|
4393
|
-
after: data.list_metadata.after
|
|
4394
|
-
}
|
|
4395
|
-
};
|
|
5389
|
+
const endpoint = `/authorization/organization_memberships/${organizationMembershipId}/role_assignments`;
|
|
5390
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeRoleAssignment, queryOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeRoleAssignment, params), queryOptions);
|
|
4396
5391
|
}
|
|
5392
|
+
/**
|
|
5393
|
+
* Assign a role
|
|
5394
|
+
*
|
|
5395
|
+
* Assign a role to an organization membership on a specific resource.
|
|
5396
|
+
* @param options - Object containing roleSlug.
|
|
5397
|
+
* @returns {Promise<RoleAssignment>}
|
|
5398
|
+
* @throws 403 response from the API.
|
|
5399
|
+
* @throws {NotFoundException} 404
|
|
5400
|
+
* @throws {UnprocessableEntityException} 422
|
|
5401
|
+
*/
|
|
4397
5402
|
async assignRole(options) {
|
|
4398
5403
|
const { data } = await this.workos.post(`/authorization/organization_memberships/${options.organizationMembershipId}/role_assignments`, serializeAssignRoleOptions(options));
|
|
4399
5404
|
return deserializeRoleAssignment(data);
|
|
4400
5405
|
}
|
|
5406
|
+
/**
|
|
5407
|
+
* Remove a role assignment
|
|
5408
|
+
*
|
|
5409
|
+
* Remove a role assignment by role slug and resource.
|
|
5410
|
+
* @param options - Object containing roleSlug.
|
|
5411
|
+
* @returns {Promise<void>}
|
|
5412
|
+
* @throws 403 response from the API.
|
|
5413
|
+
* @throws {NotFoundException} 404
|
|
5414
|
+
* @throws {UnprocessableEntityException} 422
|
|
5415
|
+
*/
|
|
4401
5416
|
async removeRole(options) {
|
|
4402
5417
|
await this.workos.deleteWithBody(`/authorization/organization_memberships/${options.organizationMembershipId}/role_assignments`, serializeRemoveRoleOptions(options));
|
|
4403
5418
|
}
|
|
4404
|
-
|
|
5419
|
+
/**
|
|
5420
|
+
* Remove a role assignment by ID
|
|
5421
|
+
*
|
|
5422
|
+
* Remove a role assignment using its ID.
|
|
5423
|
+
* @param organizationMembershipId - The ID of the organization membership.
|
|
5424
|
+
*
|
|
5425
|
+
* @example
|
|
5426
|
+
* "om_01HXYZ123456789ABCDEFGHIJ"
|
|
5427
|
+
*
|
|
5428
|
+
* @param roleAssignmentId - The ID of the role assignment to remove.
|
|
5429
|
+
*
|
|
5430
|
+
* @example
|
|
5431
|
+
* "role_assignment_01HXYZ123456789ABCDEFGH"
|
|
5432
|
+
*
|
|
5433
|
+
* @returns {Promise<void>}
|
|
5434
|
+
* @throws 403 response from the API.
|
|
5435
|
+
* @throws {NotFoundException} 404
|
|
5436
|
+
*/
|
|
5437
|
+
async deleteOrganizationMembershipRoleAssignment(options) {
|
|
4405
5438
|
await this.workos.delete(`/authorization/organization_memberships/${options.organizationMembershipId}/role_assignments/${options.roleAssignmentId}`);
|
|
4406
5439
|
}
|
|
4407
|
-
|
|
5440
|
+
/**
|
|
5441
|
+
* List resources for organization membership
|
|
5442
|
+
*
|
|
5443
|
+
* Returns all child resources of a parent resource where the organization membership has a specific permission. This is useful for resource discovery—answering "What projects can this user access in this workspace?"
|
|
5444
|
+
*
|
|
5445
|
+
* You must provide either `parent_resource_id` or both `parent_resource_external_id` and `parent_resource_type_slug` to identify the parent resource.
|
|
5446
|
+
* @param organizationMembershipId - The ID of the organization membership.
|
|
5447
|
+
*
|
|
5448
|
+
* @example
|
|
5449
|
+
* "om_01HXYZ123456789ABCDEFGHIJ"
|
|
5450
|
+
*
|
|
5451
|
+
* @param options - Pagination and filter options.
|
|
5452
|
+
* @returns {Promise<AutoPaginatable<AuthorizationResource>>}
|
|
5453
|
+
* @throws {BadRequestException} 400
|
|
5454
|
+
* @throws 403 response from the API.
|
|
5455
|
+
* @throws {NotFoundException} 404
|
|
5456
|
+
* @throws {UnprocessableEntityException} 422
|
|
5457
|
+
*/
|
|
5458
|
+
async listOrganizationMembershipResources(options) {
|
|
4408
5459
|
const { organizationMembershipId } = options;
|
|
4409
|
-
const
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
data: data.data.map(deserializeAuthorizationResource),
|
|
4413
|
-
listMetadata: {
|
|
4414
|
-
before: data.list_metadata.before,
|
|
4415
|
-
after: data.list_metadata.after
|
|
4416
|
-
}
|
|
4417
|
-
};
|
|
5460
|
+
const endpoint = `/authorization/organization_memberships/${organizationMembershipId}/resources`;
|
|
5461
|
+
const serializedOptions = serializeListResourcesForMembershipOptions(options);
|
|
5462
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationResource, serializedOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationResource, params), serializedOptions);
|
|
4418
5463
|
}
|
|
5464
|
+
/**
|
|
5465
|
+
* List organization memberships for resource
|
|
5466
|
+
*
|
|
5467
|
+
* Returns all organization memberships that have a specific permission on a resource instance. This is useful for answering "Who can access this resource?".
|
|
5468
|
+
* @param options - Pagination and filter options.
|
|
5469
|
+
* @returns {Promise<AutoPaginatable<BaseOrganizationMembership, PaginationOptions>>}
|
|
5470
|
+
* @throws {BadRequestException} 400
|
|
5471
|
+
* @throws 403 response from the API.
|
|
5472
|
+
* @throws {NotFoundException} 404
|
|
5473
|
+
* @throws {UnprocessableEntityException} 422
|
|
5474
|
+
*/
|
|
4419
5475
|
async listMembershipsForResource(options) {
|
|
4420
5476
|
const { resourceId } = options;
|
|
4421
|
-
const
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
data: data.data.map(deserializeAuthorizationOrganizationMembership),
|
|
4425
|
-
listMetadata: {
|
|
4426
|
-
before: data.list_metadata.before,
|
|
4427
|
-
after: data.list_metadata.after
|
|
4428
|
-
}
|
|
4429
|
-
};
|
|
5477
|
+
const endpoint = `/authorization/resources/${resourceId}/organization_memberships`;
|
|
5478
|
+
const serializedOptions = serializeListMembershipsForResourceOptions(options);
|
|
5479
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, serializedOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, params), serializedOptions);
|
|
4430
5480
|
}
|
|
4431
|
-
|
|
5481
|
+
/**
|
|
5482
|
+
* List memberships for a resource by external ID
|
|
5483
|
+
*
|
|
5484
|
+
* Returns all organization memberships that have a specific permission on a resource, using the resource's external ID. This is useful for answering "Who can access this resource?" when you only have the external ID.
|
|
5485
|
+
* @param organizationId - The ID of the organization that owns the resource.
|
|
5486
|
+
*
|
|
5487
|
+
* @example
|
|
5488
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
5489
|
+
*
|
|
5490
|
+
* @param resourceTypeSlug - The slug of the resource type this resource belongs to.
|
|
5491
|
+
*
|
|
5492
|
+
* @example
|
|
5493
|
+
* "project"
|
|
5494
|
+
*
|
|
5495
|
+
* @param externalId - An identifier you provide to reference the resource in your system.
|
|
5496
|
+
*
|
|
5497
|
+
* @example
|
|
5498
|
+
* "proj-456"
|
|
5499
|
+
*
|
|
5500
|
+
* @param options - Pagination and filter options.
|
|
5501
|
+
* @returns {Promise<AutoPaginatable<UserOrganizationMembershipBaseListData>>}
|
|
5502
|
+
* @throws {BadRequestException} 400
|
|
5503
|
+
* @throws 403 response from the API.
|
|
5504
|
+
* @throws {NotFoundException} 404
|
|
5505
|
+
* @throws {UnprocessableEntityException} 422
|
|
5506
|
+
*/
|
|
5507
|
+
async listResourceOrganizationMemberships(options) {
|
|
4432
5508
|
const { organizationId, resourceTypeSlug, externalId } = options;
|
|
4433
|
-
const
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
5509
|
+
const endpoint = `/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}/organization_memberships`;
|
|
5510
|
+
const serializedOptions = serializeListMembershipsForResourceOptions(options);
|
|
5511
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, serializedOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeAuthorizationOrganizationMembership, params), serializedOptions);
|
|
5512
|
+
}
|
|
5513
|
+
/**
|
|
5514
|
+
* List effective permissions for an organization membership on a resource
|
|
5515
|
+
*
|
|
5516
|
+
* Returns all permissions the organization membership effectively has on a resource, including permissions inherited through roles assigned to ancestor resources.
|
|
5517
|
+
* @param organizationMembershipId - The ID of the organization membership.
|
|
5518
|
+
*
|
|
5519
|
+
* @example
|
|
5520
|
+
* "om_01HXYZ123456789ABCDEFGHIJ"
|
|
5521
|
+
*
|
|
5522
|
+
* @param resourceId - The ID of the authorization resource.
|
|
5523
|
+
*
|
|
5524
|
+
* @example
|
|
5525
|
+
* "authz_resource_01HXYZ123456789ABCDEFGHIJ"
|
|
5526
|
+
*
|
|
5527
|
+
* @param options - Pagination and filter options.
|
|
5528
|
+
* @returns {Promise<AutoPaginatable<AuthorizationPermission>>}
|
|
5529
|
+
* @throws 403 response from the API.
|
|
5530
|
+
* @throws {NotFoundException} 404
|
|
5531
|
+
* @throws {UnprocessableEntityException} 422
|
|
5532
|
+
*/
|
|
5533
|
+
async listResourcePermissions(options) {
|
|
5534
|
+
const { organizationMembershipId, resourceId } = options;
|
|
5535
|
+
const endpoint = `/authorization/resources/${resourceId}/organization_memberships/${organizationMembershipId}/permissions`;
|
|
5536
|
+
const serializedOptions = serializeListEffectivePermissionsOptions(options);
|
|
5537
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializePermission, serializedOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializePermission, params), serializedOptions);
|
|
5538
|
+
}
|
|
5539
|
+
/**
|
|
5540
|
+
* List effective permissions for an organization membership on a resource by external ID
|
|
5541
|
+
*
|
|
5542
|
+
* Returns all permissions the organization membership effectively has on a resource identified by its external ID, including permissions inherited through roles assigned to ancestor resources.
|
|
5543
|
+
* @param options - Pagination and filter options.
|
|
5544
|
+
* @returns {Promise<AutoPaginatable<Permission, PaginationOptions>>}
|
|
5545
|
+
* @throws 403 response from the API.
|
|
5546
|
+
* @throws {NotFoundException} 404
|
|
5547
|
+
* @throws {UnprocessableEntityException} 422
|
|
5548
|
+
*/
|
|
5549
|
+
async listEffectivePermissionsByExternalId(options) {
|
|
5550
|
+
const { organizationMembershipId, organizationId, resourceTypeSlug, externalId } = options;
|
|
5551
|
+
const endpoint = `/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}/organization_memberships/${organizationMembershipId}/permissions`;
|
|
5552
|
+
const serializedOptions = serializeListEffectivePermissionsOptions(options);
|
|
5553
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializePermission, serializedOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializePermission, params), serializedOptions);
|
|
4442
5554
|
}
|
|
4443
5555
|
};
|
|
4444
5556
|
//#endregion
|
|
@@ -4692,20 +5804,6 @@ var Vault = class {
|
|
|
4692
5804
|
}
|
|
4693
5805
|
};
|
|
4694
5806
|
//#endregion
|
|
4695
|
-
//#region src/common/exceptions/conflict.exception.ts
|
|
4696
|
-
var ConflictException = class extends Error {
|
|
4697
|
-
status = 409;
|
|
4698
|
-
name = "ConflictException";
|
|
4699
|
-
requestID;
|
|
4700
|
-
constructor({ error, message, requestID }) {
|
|
4701
|
-
super();
|
|
4702
|
-
this.requestID = requestID;
|
|
4703
|
-
if (message) this.message = message;
|
|
4704
|
-
else if (error) this.message = `Error: ${error}`;
|
|
4705
|
-
else this.message = `An conflict has occurred on the server.`;
|
|
4706
|
-
}
|
|
4707
|
-
};
|
|
4708
|
-
//#endregion
|
|
4709
5807
|
//#region src/common/utils/runtime-info.ts
|
|
4710
5808
|
/**
|
|
4711
5809
|
* Get runtime information including name and version.
|
|
@@ -4749,13 +5847,14 @@ function extractBunVersionFromUserAgent() {
|
|
|
4749
5847
|
}
|
|
4750
5848
|
//#endregion
|
|
4751
5849
|
//#region package.json
|
|
4752
|
-
var version = "
|
|
5850
|
+
var version = "9.1.0";
|
|
4753
5851
|
//#endregion
|
|
4754
5852
|
//#region src/workos.ts
|
|
4755
5853
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
4756
5854
|
const HEADER_AUTHORIZATION = "Authorization";
|
|
4757
5855
|
const HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
|
|
4758
5856
|
const HEADER_WARRANT_TOKEN = "Warrant-Token";
|
|
5857
|
+
/** WorkOS REST API */
|
|
4759
5858
|
var WorkOS = class {
|
|
4760
5859
|
baseURL;
|
|
4761
5860
|
client;
|
|
@@ -4771,13 +5870,13 @@ var WorkOS = class {
|
|
|
4771
5870
|
directorySync = new DirectorySync(this);
|
|
4772
5871
|
events = new Events(this);
|
|
4773
5872
|
featureFlags = new FeatureFlags(this);
|
|
4774
|
-
|
|
4775
|
-
|
|
5873
|
+
groups = new Groups(this);
|
|
5874
|
+
multiFactorAuth = new MultiFactorAuth(this);
|
|
4776
5875
|
organizations = new Organizations(this);
|
|
4777
5876
|
organizationDomains = new OrganizationDomains(this);
|
|
4778
5877
|
passwordless = new Passwordless(this);
|
|
4779
5878
|
pipes = new Pipes(this);
|
|
4780
|
-
|
|
5879
|
+
adminPortal = new AdminPortal(this);
|
|
4781
5880
|
sso = new SSO(this);
|
|
4782
5881
|
userManagement;
|
|
4783
5882
|
vault = new Vault(this);
|
|
@@ -5019,7 +6118,8 @@ var WorkOS = class {
|
|
|
5019
6118
|
case 409: throw new ConflictException({
|
|
5020
6119
|
requestID,
|
|
5021
6120
|
message,
|
|
5022
|
-
error
|
|
6121
|
+
error,
|
|
6122
|
+
code
|
|
5023
6123
|
});
|
|
5024
6124
|
case 422: throw new UnprocessableEntityException({
|
|
5025
6125
|
code,
|
|
@@ -5044,12 +6144,24 @@ var WorkOS = class {
|
|
|
5044
6144
|
message,
|
|
5045
6145
|
requestID
|
|
5046
6146
|
});
|
|
6147
|
+
else if (isAuthenticationErrorData(data)) throw new AuthenticationException(status, data, requestID);
|
|
5047
6148
|
else throw new GenericServerException(status, data.message, data, requestID);
|
|
5048
6149
|
}
|
|
5049
6150
|
}
|
|
5050
6151
|
}
|
|
5051
6152
|
};
|
|
5052
6153
|
//#endregion
|
|
6154
|
+
//#region src/common/interfaces/generate-link-intent.interface.ts
|
|
6155
|
+
const GenerateLinkIntent = {
|
|
6156
|
+
SSO: "sso",
|
|
6157
|
+
DSync: "dsync",
|
|
6158
|
+
AuditLogs: "audit_logs",
|
|
6159
|
+
LogStreams: "log_streams",
|
|
6160
|
+
DomainVerification: "domain_verification",
|
|
6161
|
+
CertificateRenewal: "certificate_renewal",
|
|
6162
|
+
BringYourOwnKey: "bring_your_own_key"
|
|
6163
|
+
};
|
|
6164
|
+
//#endregion
|
|
5053
6165
|
//#region src/organizations/interfaces/domain-data.interface.ts
|
|
5054
6166
|
let DomainDataState = /* @__PURE__ */ function(DomainDataState) {
|
|
5055
6167
|
DomainDataState["Verified"] = "verified";
|
|
@@ -5070,18 +6182,6 @@ let OrganizationDomainVerificationStrategy = /* @__PURE__ */ function(Organizati
|
|
|
5070
6182
|
return OrganizationDomainVerificationStrategy;
|
|
5071
6183
|
}({});
|
|
5072
6184
|
//#endregion
|
|
5073
|
-
//#region src/portal/interfaces/generate-portal-link-intent.interface.ts
|
|
5074
|
-
let GeneratePortalLinkIntent = /* @__PURE__ */ function(GeneratePortalLinkIntent) {
|
|
5075
|
-
GeneratePortalLinkIntent["AuditLogs"] = "audit_logs";
|
|
5076
|
-
GeneratePortalLinkIntent["DomainVerification"] = "domain_verification";
|
|
5077
|
-
GeneratePortalLinkIntent["DSync"] = "dsync";
|
|
5078
|
-
GeneratePortalLinkIntent["LogStreams"] = "log_streams";
|
|
5079
|
-
GeneratePortalLinkIntent["SSO"] = "sso";
|
|
5080
|
-
GeneratePortalLinkIntent["CertificateRenewal"] = "certificate_renewal";
|
|
5081
|
-
GeneratePortalLinkIntent["BringYourOwnKey"] = "bring_your_own_key";
|
|
5082
|
-
return GeneratePortalLinkIntent;
|
|
5083
|
-
}({});
|
|
5084
|
-
//#endregion
|
|
5085
6185
|
//#region src/sso/interfaces/connection-type.enum.ts
|
|
5086
6186
|
let ConnectionType = /* @__PURE__ */ function(ConnectionType) {
|
|
5087
6187
|
ConnectionType["ADFSSAML"] = "ADFSSAML";
|
|
@@ -5090,10 +6190,12 @@ let ConnectionType = /* @__PURE__ */ function(ConnectionType) {
|
|
|
5090
6190
|
ConnectionType["Auth0SAML"] = "Auth0SAML";
|
|
5091
6191
|
ConnectionType["AzureSAML"] = "AzureSAML";
|
|
5092
6192
|
ConnectionType["CasSAML"] = "CasSAML";
|
|
6193
|
+
ConnectionType["CleverOIDC"] = "CleverOIDC";
|
|
5093
6194
|
ConnectionType["ClassLinkSAML"] = "ClassLinkSAML";
|
|
5094
6195
|
ConnectionType["CloudflareSAML"] = "CloudflareSAML";
|
|
5095
6196
|
ConnectionType["CyberArkSAML"] = "CyberArkSAML";
|
|
5096
6197
|
ConnectionType["DuoSAML"] = "DuoSAML";
|
|
6198
|
+
ConnectionType["EntraIdOIDC"] = "EntraIdOIDC";
|
|
5097
6199
|
ConnectionType["GenericOIDC"] = "GenericOIDC";
|
|
5098
6200
|
ConnectionType["GenericSAML"] = "GenericSAML";
|
|
5099
6201
|
ConnectionType["GitHubOAuth"] = "GitHubOAuth";
|
|
@@ -5107,6 +6209,7 @@ let ConnectionType = /* @__PURE__ */ function(ConnectionType) {
|
|
|
5107
6209
|
ConnectionType["MicrosoftOAuth"] = "MicrosoftOAuth";
|
|
5108
6210
|
ConnectionType["MiniOrangeSAML"] = "MiniOrangeSAML";
|
|
5109
6211
|
ConnectionType["NetIqSAML"] = "NetIqSAML";
|
|
6212
|
+
ConnectionType["OktaOIDC"] = "OktaOIDC";
|
|
5110
6213
|
ConnectionType["OktaSAML"] = "OktaSAML";
|
|
5111
6214
|
ConnectionType["OneLoginSAML"] = "OneLoginSAML";
|
|
5112
6215
|
ConnectionType["OracleSAML"] = "OracleSAML";
|
|
@@ -5127,6 +6230,6 @@ function createWorkOS(options) {
|
|
|
5127
6230
|
return new WorkOS(options);
|
|
5128
6231
|
}
|
|
5129
6232
|
//#endregion
|
|
5130
|
-
export {
|
|
6233
|
+
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 };
|
|
5131
6234
|
|
|
5132
|
-
//# sourceMappingURL=factory-
|
|
6235
|
+
//# sourceMappingURL=factory-B7cG7pDB.mjs.map
|