@workos-inc/node 9.1.0 → 9.2.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/lib/{factory-B7cG7pDB.mjs → factory-CdcF5208.mjs} +79 -19
- package/lib/factory-CdcF5208.mjs.map +1 -0
- package/lib/{factory-D3tT03aV.cjs → factory-DL2F8bWI.cjs} +79 -19
- package/lib/factory-DL2F8bWI.cjs.map +1 -0
- package/lib/index.cjs +1 -1
- package/lib/index.d.cts +2 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.mjs +1 -1
- package/lib/index.worker.cjs +1 -1
- package/lib/index.worker.d.cts +2 -2
- package/lib/index.worker.d.mts +2 -2
- package/lib/index.worker.mjs +1 -1
- package/lib/{workos-DhbLRXvR.d.mts → workos-DQzEZoxn.d.mts} +78 -17
- package/lib/{workos-C0YAqze0.d.cts → workos-DSjps83I.d.cts} +78 -17
- package/package.json +1 -1
- package/lib/factory-B7cG7pDB.mjs.map +0 -1
- package/lib/factory-D3tT03aV.cjs.map +0 -1
|
@@ -405,15 +405,26 @@ const AUTHENTICATION_ERROR_CODES = new Set([
|
|
|
405
405
|
"mfa_verification",
|
|
406
406
|
"sso_required"
|
|
407
407
|
]);
|
|
408
|
+
function parseAuthenticationErrorCode(value) {
|
|
409
|
+
if (typeof value !== "string") return;
|
|
410
|
+
if (!AUTHENTICATION_ERROR_CODES.has(value)) return;
|
|
411
|
+
return value;
|
|
412
|
+
}
|
|
413
|
+
function getAuthenticationErrorCode(data) {
|
|
414
|
+
return parseAuthenticationErrorCode(data.code) ?? parseAuthenticationErrorCode(data.error);
|
|
415
|
+
}
|
|
408
416
|
function isAuthenticationErrorData(data) {
|
|
409
|
-
return
|
|
417
|
+
return getAuthenticationErrorCode(data) !== void 0;
|
|
410
418
|
}
|
|
411
419
|
var AuthenticationException = class extends GenericServerException {
|
|
412
420
|
name = "AuthenticationException";
|
|
421
|
+
code;
|
|
413
422
|
pendingAuthenticationToken;
|
|
414
423
|
constructor(status, rawData, requestID) {
|
|
415
|
-
|
|
424
|
+
const code = getAuthenticationErrorCode(rawData);
|
|
425
|
+
super(status, rawData.message ?? rawData.error_description, rawData, requestID);
|
|
416
426
|
this.rawData = rawData;
|
|
427
|
+
this.code = code;
|
|
417
428
|
this.pendingAuthenticationToken = rawData.pending_authentication_token;
|
|
418
429
|
}
|
|
419
430
|
};
|
|
@@ -4776,6 +4787,7 @@ const serializeListMembershipsForResourceOptions = (options) => ({
|
|
|
4776
4787
|
const deserializeRoleAssignment = (response) => ({
|
|
4777
4788
|
object: response.object,
|
|
4778
4789
|
id: response.id,
|
|
4790
|
+
organizationMembershipId: response.organization_membership_id,
|
|
4779
4791
|
role: response.role,
|
|
4780
4792
|
resource: {
|
|
4781
4793
|
id: response.resource.id,
|
|
@@ -5052,7 +5064,7 @@ var Authorization = class {
|
|
|
5052
5064
|
* @throws {NotFoundException} 404
|
|
5053
5065
|
* @throws {UnprocessableEntityException} 422
|
|
5054
5066
|
*/
|
|
5055
|
-
async
|
|
5067
|
+
async setOrganizationRolePermissions(organizationId, slug, options) {
|
|
5056
5068
|
const { data } = await this.workos.put(`/authorization/organizations/${organizationId}/roles/${slug}/permissions`, { permissions: options.permissions });
|
|
5057
5069
|
return deserializeOrganizationRole(data);
|
|
5058
5070
|
}
|
|
@@ -5077,7 +5089,7 @@ var Authorization = class {
|
|
|
5077
5089
|
* @throws {NotFoundException} 404
|
|
5078
5090
|
* @throws {UnprocessableEntityException} 422
|
|
5079
5091
|
*/
|
|
5080
|
-
async
|
|
5092
|
+
async addOrganizationRolePermission(organizationId, slug, options) {
|
|
5081
5093
|
const { data } = await this.workos.post(`/authorization/organizations/${organizationId}/roles/${slug}/permissions`, { slug: options.permissionSlug });
|
|
5082
5094
|
return deserializeOrganizationRole(data);
|
|
5083
5095
|
}
|
|
@@ -5104,7 +5116,7 @@ var Authorization = class {
|
|
|
5104
5116
|
* @throws 403 response from the API.
|
|
5105
5117
|
* @throws {NotFoundException} 404
|
|
5106
5118
|
*/
|
|
5107
|
-
async
|
|
5119
|
+
async removeOrganizationRolePermission(organizationId, slug, options) {
|
|
5108
5120
|
await this.workos.delete(`/authorization/organizations/${organizationId}/roles/${slug}/permissions/${options.permissionSlug}`);
|
|
5109
5121
|
}
|
|
5110
5122
|
/**
|
|
@@ -5288,7 +5300,7 @@ var Authorization = class {
|
|
|
5288
5300
|
* @throws 403 response from the API.
|
|
5289
5301
|
* @throws {NotFoundException} 404
|
|
5290
5302
|
*/
|
|
5291
|
-
async
|
|
5303
|
+
async getResourceByExternalId(options) {
|
|
5292
5304
|
const { organizationId, resourceTypeSlug, externalId } = options;
|
|
5293
5305
|
const { data } = await this.workos.get(`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`);
|
|
5294
5306
|
return deserializeAuthorizationResource(data);
|
|
@@ -5320,7 +5332,7 @@ var Authorization = class {
|
|
|
5320
5332
|
* @throws {ConflictException} 409
|
|
5321
5333
|
* @throws {UnprocessableEntityException} 422
|
|
5322
5334
|
*/
|
|
5323
|
-
async
|
|
5335
|
+
async updateResourceByExternalId(options) {
|
|
5324
5336
|
const { organizationId, resourceTypeSlug, externalId } = options;
|
|
5325
5337
|
const { data } = await this.workos.patch(`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`, serializeUpdateResourceByExternalIdOptions(options));
|
|
5326
5338
|
return deserializeAuthorizationResource(data);
|
|
@@ -5351,7 +5363,7 @@ var Authorization = class {
|
|
|
5351
5363
|
* @throws {NotFoundException} 404
|
|
5352
5364
|
* @throws {ConflictException} 409
|
|
5353
5365
|
*/
|
|
5354
|
-
async
|
|
5366
|
+
async deleteResourceByExternalId(options) {
|
|
5355
5367
|
const { organizationId, resourceTypeSlug, externalId, cascadeDelete } = options;
|
|
5356
5368
|
const query = cascadeDelete !== void 0 ? { cascade_delete: cascadeDelete.toString() } : void 0;
|
|
5357
5369
|
await this.workos.delete(`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`, query);
|
|
@@ -5384,12 +5396,60 @@ var Authorization = class {
|
|
|
5384
5396
|
* @throws 403 response from the API.
|
|
5385
5397
|
* @throws {NotFoundException} 404
|
|
5386
5398
|
*/
|
|
5387
|
-
async
|
|
5399
|
+
async listRoleAssignments(options) {
|
|
5388
5400
|
const { organizationMembershipId, ...queryOptions } = options;
|
|
5389
5401
|
const endpoint = `/authorization/organization_memberships/${organizationMembershipId}/role_assignments`;
|
|
5390
5402
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeRoleAssignment, queryOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeRoleAssignment, params), queryOptions);
|
|
5391
5403
|
}
|
|
5392
5404
|
/**
|
|
5405
|
+
* List role assignments for a resource
|
|
5406
|
+
*
|
|
5407
|
+
* List all role assignments granted on a resource. This returns every role assignment scoped to the resource, regardless of which organization membership received it.
|
|
5408
|
+
* @param resourceId - The ID of the authorization resource.
|
|
5409
|
+
*
|
|
5410
|
+
* @example
|
|
5411
|
+
* "authz_resource_01HXYZ123456789ABCDEFGHIJ"
|
|
5412
|
+
*
|
|
5413
|
+
* @param options - Pagination and filter options.
|
|
5414
|
+
* @returns {Promise<AutoPaginatable<RoleAssignment>>}
|
|
5415
|
+
* @throws 403 response from the API.
|
|
5416
|
+
* @throws {NotFoundException} 404
|
|
5417
|
+
*/
|
|
5418
|
+
async listRoleAssignmentsForResource(options) {
|
|
5419
|
+
const { resourceId, ...queryOptions } = options;
|
|
5420
|
+
const endpoint = `/authorization/resources/${resourceId}/role_assignments`;
|
|
5421
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeRoleAssignment, queryOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeRoleAssignment, params), queryOptions);
|
|
5422
|
+
}
|
|
5423
|
+
/**
|
|
5424
|
+
* List role assignments for a resource by external ID
|
|
5425
|
+
*
|
|
5426
|
+
* List all role assignments granted on a resource identified by its external ID, organization, and resource type. This returns every role assignment scoped to the resource, regardless of which organization membership received it.
|
|
5427
|
+
* @param organizationId - The ID of the organization that owns the resource.
|
|
5428
|
+
*
|
|
5429
|
+
* @example
|
|
5430
|
+
* "org_01EHZNVPK3SFK441A1RGBFSHRT"
|
|
5431
|
+
*
|
|
5432
|
+
* @param resourceTypeSlug - The slug of the resource type this resource belongs to.
|
|
5433
|
+
*
|
|
5434
|
+
* @example
|
|
5435
|
+
* "project"
|
|
5436
|
+
*
|
|
5437
|
+
* @param externalId - An identifier you provide to reference the resource in your system.
|
|
5438
|
+
*
|
|
5439
|
+
* @example
|
|
5440
|
+
* "proj-456"
|
|
5441
|
+
*
|
|
5442
|
+
* @param options - Pagination and filter options.
|
|
5443
|
+
* @returns {Promise<AutoPaginatable<RoleAssignment>>}
|
|
5444
|
+
* @throws 403 response from the API.
|
|
5445
|
+
* @throws {NotFoundException} 404
|
|
5446
|
+
*/
|
|
5447
|
+
async listResourceRoleAssignments(options) {
|
|
5448
|
+
const { organizationId, resourceTypeSlug, externalId, ...queryOptions } = options;
|
|
5449
|
+
const endpoint = `/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}/role_assignments`;
|
|
5450
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeRoleAssignment, queryOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeRoleAssignment, params), queryOptions);
|
|
5451
|
+
}
|
|
5452
|
+
/**
|
|
5393
5453
|
* Assign a role
|
|
5394
5454
|
*
|
|
5395
5455
|
* Assign a role to an organization membership on a specific resource.
|
|
@@ -5434,7 +5494,7 @@ var Authorization = class {
|
|
|
5434
5494
|
* @throws 403 response from the API.
|
|
5435
5495
|
* @throws {NotFoundException} 404
|
|
5436
5496
|
*/
|
|
5437
|
-
async
|
|
5497
|
+
async removeRoleAssignment(options) {
|
|
5438
5498
|
await this.workos.delete(`/authorization/organization_memberships/${options.organizationMembershipId}/role_assignments/${options.roleAssignmentId}`);
|
|
5439
5499
|
}
|
|
5440
5500
|
/**
|
|
@@ -5455,7 +5515,7 @@ var Authorization = class {
|
|
|
5455
5515
|
* @throws {NotFoundException} 404
|
|
5456
5516
|
* @throws {UnprocessableEntityException} 422
|
|
5457
5517
|
*/
|
|
5458
|
-
async
|
|
5518
|
+
async listResourcesForMembership(options) {
|
|
5459
5519
|
const { organizationMembershipId } = options;
|
|
5460
5520
|
const endpoint = `/authorization/organization_memberships/${organizationMembershipId}/resources`;
|
|
5461
5521
|
const serializedOptions = serializeListResourcesForMembershipOptions(options);
|
|
@@ -5504,7 +5564,7 @@ var Authorization = class {
|
|
|
5504
5564
|
* @throws {NotFoundException} 404
|
|
5505
5565
|
* @throws {UnprocessableEntityException} 422
|
|
5506
5566
|
*/
|
|
5507
|
-
async
|
|
5567
|
+
async listMembershipsForResourceByExternalId(options) {
|
|
5508
5568
|
const { organizationId, resourceTypeSlug, externalId } = options;
|
|
5509
5569
|
const endpoint = `/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}/organization_memberships`;
|
|
5510
5570
|
const serializedOptions = serializeListMembershipsForResourceOptions(options);
|
|
@@ -5530,7 +5590,7 @@ var Authorization = class {
|
|
|
5530
5590
|
* @throws {NotFoundException} 404
|
|
5531
5591
|
* @throws {UnprocessableEntityException} 422
|
|
5532
5592
|
*/
|
|
5533
|
-
async
|
|
5593
|
+
async listEffectivePermissions(options) {
|
|
5534
5594
|
const { organizationMembershipId, resourceId } = options;
|
|
5535
5595
|
const endpoint = `/authorization/resources/${resourceId}/organization_memberships/${organizationMembershipId}/permissions`;
|
|
5536
5596
|
const serializedOptions = serializeListEffectivePermissionsOptions(options);
|
|
@@ -5547,8 +5607,8 @@ var Authorization = class {
|
|
|
5547
5607
|
* @throws {UnprocessableEntityException} 422
|
|
5548
5608
|
*/
|
|
5549
5609
|
async listEffectivePermissionsByExternalId(options) {
|
|
5550
|
-
const { organizationMembershipId,
|
|
5551
|
-
const endpoint = `/authorization/
|
|
5610
|
+
const { organizationMembershipId, resourceTypeSlug, externalId } = options;
|
|
5611
|
+
const endpoint = `/authorization/organization_memberships/${organizationMembershipId}/resources/${resourceTypeSlug}/${externalId}/permissions`;
|
|
5552
5612
|
const serializedOptions = serializeListEffectivePermissionsOptions(options);
|
|
5553
5613
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializePermission, serializedOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializePermission, params), serializedOptions);
|
|
5554
5614
|
}
|
|
@@ -5847,7 +5907,7 @@ function extractBunVersionFromUserAgent() {
|
|
|
5847
5907
|
}
|
|
5848
5908
|
//#endregion
|
|
5849
5909
|
//#region package.json
|
|
5850
|
-
var version = "9.
|
|
5910
|
+
var version = "9.2.0";
|
|
5851
5911
|
//#endregion
|
|
5852
5912
|
//#region src/workos.ts
|
|
5853
5913
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
@@ -6137,14 +6197,14 @@ var WorkOS = class {
|
|
|
6137
6197
|
const retryAfter = headers.get("Retry-After");
|
|
6138
6198
|
throw new RateLimitExceededException(data.message, requestID, retryAfter ? Number(retryAfter) : null);
|
|
6139
6199
|
}
|
|
6140
|
-
default: if (
|
|
6200
|
+
default: if (isAuthenticationErrorData(data)) throw new AuthenticationException(status, data, requestID);
|
|
6201
|
+
else if (error || errorDescription) throw new OauthException(status, requestID, error, errorDescription, data);
|
|
6141
6202
|
else if (code && errors) throw new BadRequestException({
|
|
6142
6203
|
code,
|
|
6143
6204
|
errors,
|
|
6144
6205
|
message,
|
|
6145
6206
|
requestID
|
|
6146
6207
|
});
|
|
6147
|
-
else if (isAuthenticationErrorData(data)) throw new AuthenticationException(status, data, requestID);
|
|
6148
6208
|
else throw new GenericServerException(status, data.message, data, requestID);
|
|
6149
6209
|
}
|
|
6150
6210
|
}
|
|
@@ -6417,4 +6477,4 @@ Object.defineProperty(exports, "serializeRevokeSessionOptions", {
|
|
|
6417
6477
|
}
|
|
6418
6478
|
});
|
|
6419
6479
|
|
|
6420
|
-
//# sourceMappingURL=factory-
|
|
6480
|
+
//# sourceMappingURL=factory-DL2F8bWI.cjs.map
|