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