@workos-inc/node 9.0.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-BcKWtJoA.mjs → factory-BQ0MwKRy.mjs} +32 -19
- package/lib/factory-BQ0MwKRy.mjs.map +1 -0
- package/lib/{factory-CgfeO0z2.cjs → factory-jUrF-sdI.cjs} +32 -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-DUcDmctT.d.mts → workos-BfuRJpa_.d.mts} +27 -16
- package/lib/{workos-C6Dd1GJI.d.cts → workos-D7LpLpQz.d.cts} +27 -16
- package/package.json +1 -1
- package/lib/factory-BcKWtJoA.mjs.map +0 -1
- package/lib/factory-CgfeO0z2.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
|
};
|
|
@@ -832,6 +843,7 @@ const deserializeInvitation = (invitation) => ({
|
|
|
832
843
|
organizationId: invitation.organization_id,
|
|
833
844
|
inviterUserId: invitation.inviter_user_id,
|
|
834
845
|
acceptedUserId: invitation.accepted_user_id,
|
|
846
|
+
roleSlug: invitation.role_slug,
|
|
835
847
|
token: invitation.token,
|
|
836
848
|
acceptInvitationUrl: invitation.accept_invitation_url,
|
|
837
849
|
createdAt: invitation.created_at,
|
|
@@ -848,6 +860,7 @@ const deserializeInvitationEvent = (invitation) => ({
|
|
|
848
860
|
organizationId: invitation.organization_id,
|
|
849
861
|
inviterUserId: invitation.inviter_user_id,
|
|
850
862
|
acceptedUserId: invitation.accepted_user_id,
|
|
863
|
+
roleSlug: invitation.role_slug,
|
|
851
864
|
createdAt: invitation.created_at,
|
|
852
865
|
updatedAt: invitation.updated_at
|
|
853
866
|
});
|
|
@@ -5050,7 +5063,7 @@ var Authorization = class {
|
|
|
5050
5063
|
* @throws {NotFoundException} 404
|
|
5051
5064
|
* @throws {UnprocessableEntityException} 422
|
|
5052
5065
|
*/
|
|
5053
|
-
async
|
|
5066
|
+
async setOrganizationRolePermissions(organizationId, slug, options) {
|
|
5054
5067
|
const { data } = await this.workos.put(`/authorization/organizations/${organizationId}/roles/${slug}/permissions`, { permissions: options.permissions });
|
|
5055
5068
|
return deserializeOrganizationRole(data);
|
|
5056
5069
|
}
|
|
@@ -5075,7 +5088,7 @@ var Authorization = class {
|
|
|
5075
5088
|
* @throws {NotFoundException} 404
|
|
5076
5089
|
* @throws {UnprocessableEntityException} 422
|
|
5077
5090
|
*/
|
|
5078
|
-
async
|
|
5091
|
+
async addOrganizationRolePermission(organizationId, slug, options) {
|
|
5079
5092
|
const { data } = await this.workos.post(`/authorization/organizations/${organizationId}/roles/${slug}/permissions`, { slug: options.permissionSlug });
|
|
5080
5093
|
return deserializeOrganizationRole(data);
|
|
5081
5094
|
}
|
|
@@ -5102,7 +5115,7 @@ var Authorization = class {
|
|
|
5102
5115
|
* @throws 403 response from the API.
|
|
5103
5116
|
* @throws {NotFoundException} 404
|
|
5104
5117
|
*/
|
|
5105
|
-
async
|
|
5118
|
+
async removeOrganizationRolePermission(organizationId, slug, options) {
|
|
5106
5119
|
await this.workos.delete(`/authorization/organizations/${organizationId}/roles/${slug}/permissions/${options.permissionSlug}`);
|
|
5107
5120
|
}
|
|
5108
5121
|
/**
|
|
@@ -5286,7 +5299,7 @@ var Authorization = class {
|
|
|
5286
5299
|
* @throws 403 response from the API.
|
|
5287
5300
|
* @throws {NotFoundException} 404
|
|
5288
5301
|
*/
|
|
5289
|
-
async
|
|
5302
|
+
async getResourceByExternalId(options) {
|
|
5290
5303
|
const { organizationId, resourceTypeSlug, externalId } = options;
|
|
5291
5304
|
const { data } = await this.workos.get(`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`);
|
|
5292
5305
|
return deserializeAuthorizationResource(data);
|
|
@@ -5318,7 +5331,7 @@ var Authorization = class {
|
|
|
5318
5331
|
* @throws {ConflictException} 409
|
|
5319
5332
|
* @throws {UnprocessableEntityException} 422
|
|
5320
5333
|
*/
|
|
5321
|
-
async
|
|
5334
|
+
async updateResourceByExternalId(options) {
|
|
5322
5335
|
const { organizationId, resourceTypeSlug, externalId } = options;
|
|
5323
5336
|
const { data } = await this.workos.patch(`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`, serializeUpdateResourceByExternalIdOptions(options));
|
|
5324
5337
|
return deserializeAuthorizationResource(data);
|
|
@@ -5349,7 +5362,7 @@ var Authorization = class {
|
|
|
5349
5362
|
* @throws {NotFoundException} 404
|
|
5350
5363
|
* @throws {ConflictException} 409
|
|
5351
5364
|
*/
|
|
5352
|
-
async
|
|
5365
|
+
async deleteResourceByExternalId(options) {
|
|
5353
5366
|
const { organizationId, resourceTypeSlug, externalId, cascadeDelete } = options;
|
|
5354
5367
|
const query = cascadeDelete !== void 0 ? { cascade_delete: cascadeDelete.toString() } : void 0;
|
|
5355
5368
|
await this.workos.delete(`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`, query);
|
|
@@ -5382,7 +5395,7 @@ var Authorization = class {
|
|
|
5382
5395
|
* @throws 403 response from the API.
|
|
5383
5396
|
* @throws {NotFoundException} 404
|
|
5384
5397
|
*/
|
|
5385
|
-
async
|
|
5398
|
+
async listRoleAssignments(options) {
|
|
5386
5399
|
const { organizationMembershipId, ...queryOptions } = options;
|
|
5387
5400
|
const endpoint = `/authorization/organization_memberships/${organizationMembershipId}/role_assignments`;
|
|
5388
5401
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeRoleAssignment, queryOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeRoleAssignment, params), queryOptions);
|
|
@@ -5432,7 +5445,7 @@ var Authorization = class {
|
|
|
5432
5445
|
* @throws 403 response from the API.
|
|
5433
5446
|
* @throws {NotFoundException} 404
|
|
5434
5447
|
*/
|
|
5435
|
-
async
|
|
5448
|
+
async removeRoleAssignment(options) {
|
|
5436
5449
|
await this.workos.delete(`/authorization/organization_memberships/${options.organizationMembershipId}/role_assignments/${options.roleAssignmentId}`);
|
|
5437
5450
|
}
|
|
5438
5451
|
/**
|
|
@@ -5453,7 +5466,7 @@ var Authorization = class {
|
|
|
5453
5466
|
* @throws {NotFoundException} 404
|
|
5454
5467
|
* @throws {UnprocessableEntityException} 422
|
|
5455
5468
|
*/
|
|
5456
|
-
async
|
|
5469
|
+
async listResourcesForMembership(options) {
|
|
5457
5470
|
const { organizationMembershipId } = options;
|
|
5458
5471
|
const endpoint = `/authorization/organization_memberships/${organizationMembershipId}/resources`;
|
|
5459
5472
|
const serializedOptions = serializeListResourcesForMembershipOptions(options);
|
|
@@ -5502,7 +5515,7 @@ var Authorization = class {
|
|
|
5502
5515
|
* @throws {NotFoundException} 404
|
|
5503
5516
|
* @throws {UnprocessableEntityException} 422
|
|
5504
5517
|
*/
|
|
5505
|
-
async
|
|
5518
|
+
async listMembershipsForResourceByExternalId(options) {
|
|
5506
5519
|
const { organizationId, resourceTypeSlug, externalId } = options;
|
|
5507
5520
|
const endpoint = `/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}/organization_memberships`;
|
|
5508
5521
|
const serializedOptions = serializeListMembershipsForResourceOptions(options);
|
|
@@ -5528,7 +5541,7 @@ var Authorization = class {
|
|
|
5528
5541
|
* @throws {NotFoundException} 404
|
|
5529
5542
|
* @throws {UnprocessableEntityException} 422
|
|
5530
5543
|
*/
|
|
5531
|
-
async
|
|
5544
|
+
async listEffectivePermissions(options) {
|
|
5532
5545
|
const { organizationMembershipId, resourceId } = options;
|
|
5533
5546
|
const endpoint = `/authorization/resources/${resourceId}/organization_memberships/${organizationMembershipId}/permissions`;
|
|
5534
5547
|
const serializedOptions = serializeListEffectivePermissionsOptions(options);
|
|
@@ -5545,8 +5558,8 @@ var Authorization = class {
|
|
|
5545
5558
|
* @throws {UnprocessableEntityException} 422
|
|
5546
5559
|
*/
|
|
5547
5560
|
async listEffectivePermissionsByExternalId(options) {
|
|
5548
|
-
const { organizationMembershipId,
|
|
5549
|
-
const endpoint = `/authorization/
|
|
5561
|
+
const { organizationMembershipId, resourceTypeSlug, externalId } = options;
|
|
5562
|
+
const endpoint = `/authorization/organization_memberships/${organizationMembershipId}/resources/${resourceTypeSlug}/${externalId}/permissions`;
|
|
5550
5563
|
const serializedOptions = serializeListEffectivePermissionsOptions(options);
|
|
5551
5564
|
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializePermission, serializedOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializePermission, params), serializedOptions);
|
|
5552
5565
|
}
|
|
@@ -5845,7 +5858,7 @@ function extractBunVersionFromUserAgent() {
|
|
|
5845
5858
|
}
|
|
5846
5859
|
//#endregion
|
|
5847
5860
|
//#region package.json
|
|
5848
|
-
var version = "9.
|
|
5861
|
+
var version = "9.1.1";
|
|
5849
5862
|
//#endregion
|
|
5850
5863
|
//#region src/workos.ts
|
|
5851
5864
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
@@ -6135,14 +6148,14 @@ var WorkOS = class {
|
|
|
6135
6148
|
const retryAfter = headers.get("Retry-After");
|
|
6136
6149
|
throw new RateLimitExceededException(data.message, requestID, retryAfter ? Number(retryAfter) : null);
|
|
6137
6150
|
}
|
|
6138
|
-
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);
|
|
6139
6153
|
else if (code && errors) throw new BadRequestException({
|
|
6140
6154
|
code,
|
|
6141
6155
|
errors,
|
|
6142
6156
|
message,
|
|
6143
6157
|
requestID
|
|
6144
6158
|
});
|
|
6145
|
-
else if (isAuthenticationErrorData(data)) throw new AuthenticationException(status, data, requestID);
|
|
6146
6159
|
else throw new GenericServerException(status, data.message, data, requestID);
|
|
6147
6160
|
}
|
|
6148
6161
|
}
|
|
@@ -6230,4 +6243,4 @@ function createWorkOS(options) {
|
|
|
6230
6243
|
//#endregion
|
|
6231
6244
|
export { FetchHttpClient as A, NoApiKeyProvidedException as C, isAuthenticationErrorData as D, AuthenticationException as E, GenericServerException as O, NotFoundException as S, BadRequestException as T, UnprocessableEntityException as _, DomainDataState as a, RateLimitExceededException as b, FeatureFlagsRuntimeClient as c, serializeRevokeSessionOptions as d, AuthenticateWithSessionCookieFailureReason as f, Actions as g, Webhooks as h, OrganizationDomainVerificationStrategy as i, SubtleCryptoProvider as j, ApiKeyRequiredException as k, CookieSession as l, PKCE as m, ConnectionType as n, GenerateLinkIntent as o, AutoPaginatable as p, OrganizationDomainState as r, WorkOS as s, createWorkOS as t, RefreshSessionFailureReason as u, UnauthorizedException as v, ConflictException as w, OauthException as x, SignatureVerificationException as y };
|
|
6232
6245
|
|
|
6233
|
-
//# sourceMappingURL=factory-
|
|
6246
|
+
//# sourceMappingURL=factory-BQ0MwKRy.mjs.map
|