@workos-inc/node 9.1.0 → 9.1.1
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-BQ0MwKRy.mjs} +30 -19
- package/lib/factory-BQ0MwKRy.mjs.map +1 -0
- package/lib/{factory-D3tT03aV.cjs → factory-jUrF-sdI.cjs} +30 -19
- package/lib/factory-jUrF-sdI.cjs.map +1 -0
- package/lib/index.cjs +1 -1
- package/lib/index.d.cts +1 -1
- package/lib/index.d.mts +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.worker.cjs +1 -1
- package/lib/index.worker.d.cts +1 -1
- package/lib/index.worker.d.mts +1 -1
- package/lib/index.worker.mjs +1 -1
- package/lib/{workos-DhbLRXvR.d.mts → workos-BfuRJpa_.d.mts} +22 -16
- package/lib/{workos-C0YAqze0.d.cts → workos-D7LpLpQz.d.cts} +22 -16
- 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
|
};
|
|
@@ -5052,7 +5063,7 @@ var Authorization = class {
|
|
|
5052
5063
|
* @throws {NotFoundException} 404
|
|
5053
5064
|
* @throws {UnprocessableEntityException} 422
|
|
5054
5065
|
*/
|
|
5055
|
-
async
|
|
5066
|
+
async setOrganizationRolePermissions(organizationId, slug, options) {
|
|
5056
5067
|
const { data } = await this.workos.put(`/authorization/organizations/${organizationId}/roles/${slug}/permissions`, { permissions: options.permissions });
|
|
5057
5068
|
return deserializeOrganizationRole(data);
|
|
5058
5069
|
}
|
|
@@ -5077,7 +5088,7 @@ var Authorization = class {
|
|
|
5077
5088
|
* @throws {NotFoundException} 404
|
|
5078
5089
|
* @throws {UnprocessableEntityException} 422
|
|
5079
5090
|
*/
|
|
5080
|
-
async
|
|
5091
|
+
async addOrganizationRolePermission(organizationId, slug, options) {
|
|
5081
5092
|
const { data } = await this.workos.post(`/authorization/organizations/${organizationId}/roles/${slug}/permissions`, { slug: options.permissionSlug });
|
|
5082
5093
|
return deserializeOrganizationRole(data);
|
|
5083
5094
|
}
|
|
@@ -5104,7 +5115,7 @@ var Authorization = class {
|
|
|
5104
5115
|
* @throws 403 response from the API.
|
|
5105
5116
|
* @throws {NotFoundException} 404
|
|
5106
5117
|
*/
|
|
5107
|
-
async
|
|
5118
|
+
async removeOrganizationRolePermission(organizationId, slug, options) {
|
|
5108
5119
|
await this.workos.delete(`/authorization/organizations/${organizationId}/roles/${slug}/permissions/${options.permissionSlug}`);
|
|
5109
5120
|
}
|
|
5110
5121
|
/**
|
|
@@ -5288,7 +5299,7 @@ var Authorization = class {
|
|
|
5288
5299
|
* @throws 403 response from the API.
|
|
5289
5300
|
* @throws {NotFoundException} 404
|
|
5290
5301
|
*/
|
|
5291
|
-
async
|
|
5302
|
+
async getResourceByExternalId(options) {
|
|
5292
5303
|
const { organizationId, resourceTypeSlug, externalId } = options;
|
|
5293
5304
|
const { data } = await this.workos.get(`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`);
|
|
5294
5305
|
return deserializeAuthorizationResource(data);
|
|
@@ -5320,7 +5331,7 @@ var Authorization = class {
|
|
|
5320
5331
|
* @throws {ConflictException} 409
|
|
5321
5332
|
* @throws {UnprocessableEntityException} 422
|
|
5322
5333
|
*/
|
|
5323
|
-
async
|
|
5334
|
+
async updateResourceByExternalId(options) {
|
|
5324
5335
|
const { organizationId, resourceTypeSlug, externalId } = options;
|
|
5325
5336
|
const { data } = await this.workos.patch(`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`, serializeUpdateResourceByExternalIdOptions(options));
|
|
5326
5337
|
return deserializeAuthorizationResource(data);
|
|
@@ -5351,7 +5362,7 @@ var Authorization = class {
|
|
|
5351
5362
|
* @throws {NotFoundException} 404
|
|
5352
5363
|
* @throws {ConflictException} 409
|
|
5353
5364
|
*/
|
|
5354
|
-
async
|
|
5365
|
+
async deleteResourceByExternalId(options) {
|
|
5355
5366
|
const { organizationId, resourceTypeSlug, externalId, cascadeDelete } = options;
|
|
5356
5367
|
const query = cascadeDelete !== void 0 ? { cascade_delete: cascadeDelete.toString() } : void 0;
|
|
5357
5368
|
await this.workos.delete(`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`, query);
|
|
@@ -5384,7 +5395,7 @@ var Authorization = class {
|
|
|
5384
5395
|
* @throws 403 response from the API.
|
|
5385
5396
|
* @throws {NotFoundException} 404
|
|
5386
5397
|
*/
|
|
5387
|
-
async
|
|
5398
|
+
async listRoleAssignments(options) {
|
|
5388
5399
|
const { organizationMembershipId, ...queryOptions } = options;
|
|
5389
5400
|
const endpoint = `/authorization/organization_memberships/${organizationMembershipId}/role_assignments`;
|
|
5390
5401
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeRoleAssignment, queryOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeRoleAssignment, params), queryOptions);
|
|
@@ -5434,7 +5445,7 @@ var Authorization = class {
|
|
|
5434
5445
|
* @throws 403 response from the API.
|
|
5435
5446
|
* @throws {NotFoundException} 404
|
|
5436
5447
|
*/
|
|
5437
|
-
async
|
|
5448
|
+
async removeRoleAssignment(options) {
|
|
5438
5449
|
await this.workos.delete(`/authorization/organization_memberships/${options.organizationMembershipId}/role_assignments/${options.roleAssignmentId}`);
|
|
5439
5450
|
}
|
|
5440
5451
|
/**
|
|
@@ -5455,7 +5466,7 @@ var Authorization = class {
|
|
|
5455
5466
|
* @throws {NotFoundException} 404
|
|
5456
5467
|
* @throws {UnprocessableEntityException} 422
|
|
5457
5468
|
*/
|
|
5458
|
-
async
|
|
5469
|
+
async listResourcesForMembership(options) {
|
|
5459
5470
|
const { organizationMembershipId } = options;
|
|
5460
5471
|
const endpoint = `/authorization/organization_memberships/${organizationMembershipId}/resources`;
|
|
5461
5472
|
const serializedOptions = serializeListResourcesForMembershipOptions(options);
|
|
@@ -5504,7 +5515,7 @@ var Authorization = class {
|
|
|
5504
5515
|
* @throws {NotFoundException} 404
|
|
5505
5516
|
* @throws {UnprocessableEntityException} 422
|
|
5506
5517
|
*/
|
|
5507
|
-
async
|
|
5518
|
+
async listMembershipsForResourceByExternalId(options) {
|
|
5508
5519
|
const { organizationId, resourceTypeSlug, externalId } = options;
|
|
5509
5520
|
const endpoint = `/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}/organization_memberships`;
|
|
5510
5521
|
const serializedOptions = serializeListMembershipsForResourceOptions(options);
|
|
@@ -5530,7 +5541,7 @@ var Authorization = class {
|
|
|
5530
5541
|
* @throws {NotFoundException} 404
|
|
5531
5542
|
* @throws {UnprocessableEntityException} 422
|
|
5532
5543
|
*/
|
|
5533
|
-
async
|
|
5544
|
+
async listEffectivePermissions(options) {
|
|
5534
5545
|
const { organizationMembershipId, resourceId } = options;
|
|
5535
5546
|
const endpoint = `/authorization/resources/${resourceId}/organization_memberships/${organizationMembershipId}/permissions`;
|
|
5536
5547
|
const serializedOptions = serializeListEffectivePermissionsOptions(options);
|
|
@@ -5547,8 +5558,8 @@ var Authorization = class {
|
|
|
5547
5558
|
* @throws {UnprocessableEntityException} 422
|
|
5548
5559
|
*/
|
|
5549
5560
|
async listEffectivePermissionsByExternalId(options) {
|
|
5550
|
-
const { organizationMembershipId,
|
|
5551
|
-
const endpoint = `/authorization/
|
|
5561
|
+
const { organizationMembershipId, resourceTypeSlug, externalId } = options;
|
|
5562
|
+
const endpoint = `/authorization/organization_memberships/${organizationMembershipId}/resources/${resourceTypeSlug}/${externalId}/permissions`;
|
|
5552
5563
|
const serializedOptions = serializeListEffectivePermissionsOptions(options);
|
|
5553
5564
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializePermission, serializedOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializePermission, params), serializedOptions);
|
|
5554
5565
|
}
|
|
@@ -5847,7 +5858,7 @@ function extractBunVersionFromUserAgent() {
|
|
|
5847
5858
|
}
|
|
5848
5859
|
//#endregion
|
|
5849
5860
|
//#region package.json
|
|
5850
|
-
var version = "9.1.
|
|
5861
|
+
var version = "9.1.1";
|
|
5851
5862
|
//#endregion
|
|
5852
5863
|
//#region src/workos.ts
|
|
5853
5864
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
@@ -6137,14 +6148,14 @@ var WorkOS = class {
|
|
|
6137
6148
|
const retryAfter = headers.get("Retry-After");
|
|
6138
6149
|
throw new RateLimitExceededException(data.message, requestID, retryAfter ? Number(retryAfter) : null);
|
|
6139
6150
|
}
|
|
6140
|
-
default: if (
|
|
6151
|
+
default: if (isAuthenticationErrorData(data)) throw new AuthenticationException(status, data, requestID);
|
|
6152
|
+
else if (error || errorDescription) throw new OauthException(status, requestID, error, errorDescription, data);
|
|
6141
6153
|
else if (code && errors) throw new BadRequestException({
|
|
6142
6154
|
code,
|
|
6143
6155
|
errors,
|
|
6144
6156
|
message,
|
|
6145
6157
|
requestID
|
|
6146
6158
|
});
|
|
6147
|
-
else if (isAuthenticationErrorData(data)) throw new AuthenticationException(status, data, requestID);
|
|
6148
6159
|
else throw new GenericServerException(status, data.message, data, requestID);
|
|
6149
6160
|
}
|
|
6150
6161
|
}
|
|
@@ -6417,4 +6428,4 @@ Object.defineProperty(exports, "serializeRevokeSessionOptions", {
|
|
|
6417
6428
|
}
|
|
6418
6429
|
});
|
|
6419
6430
|
|
|
6420
|
-
//# sourceMappingURL=factory-
|
|
6431
|
+
//# sourceMappingURL=factory-jUrF-sdI.cjs.map
|