@workos-inc/node 10.2.1 → 10.4.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-C2wHWEA5.d.cts → factory-B85kMVYe.d.cts} +258 -6
- package/lib/{factory-C2wHWEA5.d.mts → factory-B85kMVYe.d.mts} +258 -6
- package/lib/{factory-Bp8G8dsp.mjs → factory-CRqtXIIK.mjs} +237 -13
- package/lib/factory-CRqtXIIK.mjs.map +1 -0
- package/lib/{factory-BzpScK-h.cjs → factory-CYqsa7gY.cjs} +238 -14
- package/lib/factory-CYqsa7gY.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/package.json +1 -4
- package/lib/factory-Bp8G8dsp.mjs.map +0 -1
- package/lib/factory-BzpScK-h.cjs.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
let eventemitter3 = require("eventemitter3");
|
|
2
1
|
//#region src/common/crypto/crypto-provider.ts
|
|
3
2
|
/**
|
|
4
3
|
* Interface encapsulating the various crypto computations used by the library,
|
|
@@ -4817,7 +4816,7 @@ var UserManagement = class {
|
|
|
4817
4816
|
* Or use getAuthorizationUrlWithPKCE() which handles PKCE automatically.
|
|
4818
4817
|
*/
|
|
4819
4818
|
getAuthorizationUrl(options) {
|
|
4820
|
-
const { claimNonce, connectionId, codeChallenge, codeChallengeMethod, clientId, domainHint, loginHint, organizationId, provider, providerQueryParams, providerScopes, prompt, redirectUri, state, screenHint } = options;
|
|
4819
|
+
const { claimNonce, connectionId, codeChallenge, codeChallengeMethod, clientId, domainHint, invitationToken, loginHint, organizationId, provider, providerQueryParams, providerScopes, prompt, redirectUri, state, screenHint } = options;
|
|
4821
4820
|
const resolvedClientId = this.resolveClientId(clientId);
|
|
4822
4821
|
if (!provider && !connectionId && !organizationId) throw new TypeError(`Incomplete arguments. Need to specify either a 'connectionId', 'organizationId', or 'provider'.`);
|
|
4823
4822
|
if (provider !== "authkit" && screenHint) throw new TypeError(`'screenHint' is only supported for 'authkit' provider`);
|
|
@@ -4828,6 +4827,7 @@ var UserManagement = class {
|
|
|
4828
4827
|
code_challenge_method: codeChallengeMethod,
|
|
4829
4828
|
organization_id: organizationId,
|
|
4830
4829
|
domain_hint: domainHint,
|
|
4830
|
+
invitation_token: invitationToken,
|
|
4831
4831
|
login_hint: loginHint,
|
|
4832
4832
|
provider,
|
|
4833
4833
|
provider_query_params: providerQueryParams,
|
|
@@ -4928,6 +4928,81 @@ var UserManagement = class {
|
|
|
4928
4928
|
}
|
|
4929
4929
|
};
|
|
4930
4930
|
//#endregion
|
|
4931
|
+
//#region src/feature-flags/event-emitter.ts
|
|
4932
|
+
/**
|
|
4933
|
+
* Minimal, runtime-agnostic, typed event emitter.
|
|
4934
|
+
*
|
|
4935
|
+
* Replaces eventemitter3 so the SDK carries no event dependency and works in
|
|
4936
|
+
* edge runtimes where `node:events` is not available. Generic over an event
|
|
4937
|
+
* map (`{ eventName: [arg1, arg2, ...] }`) for compile-time-checked event
|
|
4938
|
+
* names and payloads.
|
|
4939
|
+
*
|
|
4940
|
+
* Unlike eventemitter3, an unhandled `'error'` event throws instead of being
|
|
4941
|
+
* silently dropped — matching Node's `EventEmitter` so failures are never
|
|
4942
|
+
* swallowed.
|
|
4943
|
+
*/
|
|
4944
|
+
var EventEmitter = class {
|
|
4945
|
+
handlers = /* @__PURE__ */ new Map();
|
|
4946
|
+
on(event, fn) {
|
|
4947
|
+
return this.add(event, fn, false);
|
|
4948
|
+
}
|
|
4949
|
+
once(event, fn) {
|
|
4950
|
+
return this.add(event, fn, true);
|
|
4951
|
+
}
|
|
4952
|
+
off(event, fn) {
|
|
4953
|
+
this.remove(event, (h) => h.fn !== fn);
|
|
4954
|
+
return this;
|
|
4955
|
+
}
|
|
4956
|
+
emit(event, ...args) {
|
|
4957
|
+
const list = this.handlers.get(event);
|
|
4958
|
+
if (!list || list.length === 0) {
|
|
4959
|
+
if (event === "error") throw args[0] instanceof Error ? args[0] : new Error(String(args[0]));
|
|
4960
|
+
return false;
|
|
4961
|
+
}
|
|
4962
|
+
for (const h of [...list]) {
|
|
4963
|
+
if (h.once) this.remove(event, (existing) => existing !== h);
|
|
4964
|
+
h.fn(...args);
|
|
4965
|
+
}
|
|
4966
|
+
return true;
|
|
4967
|
+
}
|
|
4968
|
+
listenerCount(event) {
|
|
4969
|
+
return this.handlers.get(event)?.length ?? 0;
|
|
4970
|
+
}
|
|
4971
|
+
removeAllListeners(event) {
|
|
4972
|
+
if (event === void 0) this.handlers.clear();
|
|
4973
|
+
else this.handlers.delete(event);
|
|
4974
|
+
return this;
|
|
4975
|
+
}
|
|
4976
|
+
addListener(event, fn) {
|
|
4977
|
+
return this.on(event, fn);
|
|
4978
|
+
}
|
|
4979
|
+
removeListener(event, fn) {
|
|
4980
|
+
return this.off(event, fn);
|
|
4981
|
+
}
|
|
4982
|
+
listeners(event) {
|
|
4983
|
+
return (this.handlers.get(event) ?? []).map((h) => h.fn);
|
|
4984
|
+
}
|
|
4985
|
+
eventNames() {
|
|
4986
|
+
return [...this.handlers.keys()];
|
|
4987
|
+
}
|
|
4988
|
+
add(event, fn, once) {
|
|
4989
|
+
const list = this.handlers.get(event) ?? [];
|
|
4990
|
+
list.push({
|
|
4991
|
+
fn,
|
|
4992
|
+
once
|
|
4993
|
+
});
|
|
4994
|
+
this.handlers.set(event, list);
|
|
4995
|
+
return this;
|
|
4996
|
+
}
|
|
4997
|
+
remove(event, keep) {
|
|
4998
|
+
const list = this.handlers.get(event);
|
|
4999
|
+
if (!list) return;
|
|
5000
|
+
const next = list.filter(keep);
|
|
5001
|
+
if (next.length) this.handlers.set(event, next);
|
|
5002
|
+
else this.handlers.delete(event);
|
|
5003
|
+
}
|
|
5004
|
+
};
|
|
5005
|
+
//#endregion
|
|
4931
5006
|
//#region src/feature-flags/in-memory-store.ts
|
|
4932
5007
|
var InMemoryStore = class {
|
|
4933
5008
|
flags = {};
|
|
@@ -4982,7 +5057,7 @@ const JITTER_FACTOR = .1;
|
|
|
4982
5057
|
const INITIAL_RETRY_MS = 1e3;
|
|
4983
5058
|
const MAX_RETRY_MS = 6e4;
|
|
4984
5059
|
const BACKOFF_MULTIPLIER = 2;
|
|
4985
|
-
var FeatureFlagsRuntimeClient = class extends
|
|
5060
|
+
var FeatureFlagsRuntimeClient = class extends EventEmitter {
|
|
4986
5061
|
workos;
|
|
4987
5062
|
store;
|
|
4988
5063
|
evaluator;
|
|
@@ -5036,10 +5111,6 @@ var FeatureFlagsRuntimeClient = class extends eventemitter3.EventEmitter {
|
|
|
5036
5111
|
clearTimeout(timeoutId);
|
|
5037
5112
|
});
|
|
5038
5113
|
}
|
|
5039
|
-
emit(event, ...args) {
|
|
5040
|
-
if (event === "error" && this.listenerCount(event) === 0) throw args[0] instanceof Error ? args[0] : new Error(String(args[0]));
|
|
5041
|
-
return super.emit(event, ...args);
|
|
5042
|
-
}
|
|
5043
5114
|
close() {
|
|
5044
5115
|
this.closed = true;
|
|
5045
5116
|
this.pollAbortController?.abort();
|
|
@@ -5087,14 +5158,15 @@ var FeatureFlagsRuntimeClient = class extends eventemitter3.EventEmitter {
|
|
|
5087
5158
|
this.logger?.debug("Poll successful", { flagCount: this.store.size });
|
|
5088
5159
|
} catch (error) {
|
|
5089
5160
|
if (this.closed) return;
|
|
5161
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
5090
5162
|
this.consecutiveErrors++;
|
|
5091
5163
|
this.stats.pollErrorCount++;
|
|
5092
|
-
this.emit("error",
|
|
5093
|
-
this.logger?.error("Poll failed",
|
|
5094
|
-
if (
|
|
5095
|
-
this.emit("failed",
|
|
5164
|
+
this.emit("error", err);
|
|
5165
|
+
this.logger?.error("Poll failed", err);
|
|
5166
|
+
if (err instanceof UnauthorizedException) {
|
|
5167
|
+
this.emit("failed", err);
|
|
5096
5168
|
if (!this.initialized && this.readyReject) {
|
|
5097
|
-
this.readyReject(
|
|
5169
|
+
this.readyReject(err);
|
|
5098
5170
|
this.readyReject = null;
|
|
5099
5171
|
}
|
|
5100
5172
|
return;
|
|
@@ -5666,6 +5738,52 @@ const serializeRemoveRoleOptions = (options) => ({
|
|
|
5666
5738
|
}
|
|
5667
5739
|
});
|
|
5668
5740
|
//#endregion
|
|
5741
|
+
//#region src/authorization/serializers/group-role-assignment.serializer.ts
|
|
5742
|
+
const deserializeGroupRoleAssignment = (response) => ({
|
|
5743
|
+
object: response.object,
|
|
5744
|
+
id: response.id,
|
|
5745
|
+
groupId: response.group_id,
|
|
5746
|
+
role: response.role,
|
|
5747
|
+
resource: {
|
|
5748
|
+
id: response.resource.id,
|
|
5749
|
+
externalId: response.resource.external_id,
|
|
5750
|
+
resourceTypeSlug: response.resource.resource_type_slug
|
|
5751
|
+
},
|
|
5752
|
+
createdAt: response.created_at,
|
|
5753
|
+
updatedAt: response.updated_at
|
|
5754
|
+
});
|
|
5755
|
+
//#endregion
|
|
5756
|
+
//#region src/authorization/serializers/create-group-role-assignment-options.serializer.ts
|
|
5757
|
+
const serializeCreateGroupRoleAssignmentOptions = (options) => ({
|
|
5758
|
+
role_slug: options.roleSlug,
|
|
5759
|
+
..."resourceId" in options && { resource_id: options.resourceId },
|
|
5760
|
+
..."resourceExternalId" in options && {
|
|
5761
|
+
resource_external_id: options.resourceExternalId,
|
|
5762
|
+
resource_type_slug: options.resourceTypeSlug
|
|
5763
|
+
}
|
|
5764
|
+
});
|
|
5765
|
+
//#endregion
|
|
5766
|
+
//#region src/authorization/serializers/remove-group-role-assignments-options.serializer.ts
|
|
5767
|
+
const serializeRemoveGroupRoleAssignmentsOptions = (options) => ({
|
|
5768
|
+
role_slug: options.roleSlug,
|
|
5769
|
+
..."resourceId" in options && { resource_id: options.resourceId },
|
|
5770
|
+
..."resourceExternalId" in options && {
|
|
5771
|
+
resource_external_id: options.resourceExternalId,
|
|
5772
|
+
resource_type_slug: options.resourceTypeSlug
|
|
5773
|
+
}
|
|
5774
|
+
});
|
|
5775
|
+
//#endregion
|
|
5776
|
+
//#region src/authorization/serializers/replace-group-role-assignments-options.serializer.ts
|
|
5777
|
+
const serializeEntry = (entry) => ({
|
|
5778
|
+
role_slug: entry.roleSlug,
|
|
5779
|
+
..."resourceId" in entry && { resource_id: entry.resourceId },
|
|
5780
|
+
..."resourceExternalId" in entry && {
|
|
5781
|
+
resource_external_id: entry.resourceExternalId,
|
|
5782
|
+
resource_type_slug: entry.resourceTypeSlug
|
|
5783
|
+
}
|
|
5784
|
+
});
|
|
5785
|
+
const serializeReplaceGroupRoleAssignmentsOptions = (options) => ({ role_assignments: options.roleAssignments.map(serializeEntry) });
|
|
5786
|
+
//#endregion
|
|
5669
5787
|
//#region src/authorization/serializers/list-effective-permissions-options.serializer.ts
|
|
5670
5788
|
const serializeListEffectivePermissionsOptions = (options) => ({ ...serializePaginationOptions(options) });
|
|
5671
5789
|
//#endregion
|
|
@@ -6350,6 +6468,112 @@ var Authorization = class {
|
|
|
6350
6468
|
await this.workos.delete(`/authorization/organization_memberships/${options.organizationMembershipId}/role_assignments/${options.roleAssignmentId}`);
|
|
6351
6469
|
}
|
|
6352
6470
|
/**
|
|
6471
|
+
* List role assignments for a group
|
|
6472
|
+
*
|
|
6473
|
+
* List all role assignments granted to a group. Each assignment represents a role granted to the group on a resource.
|
|
6474
|
+
* @param options - Pagination options.
|
|
6475
|
+
* @param options.groupId - The ID of the group.
|
|
6476
|
+
*
|
|
6477
|
+
* @example
|
|
6478
|
+
* "group_01HXYZ123456789ABCDEFGHIJ"
|
|
6479
|
+
*
|
|
6480
|
+
* @returns {Promise<AutoPaginatable<GroupRoleAssignment>>}
|
|
6481
|
+
* @throws 403 response from the API.
|
|
6482
|
+
* @throws {NotFoundException} 404
|
|
6483
|
+
*/
|
|
6484
|
+
async listGroupRoleAssignments(options) {
|
|
6485
|
+
const { groupId, ...paginationOptions } = options;
|
|
6486
|
+
const endpoint = `/authorization/groups/${groupId}/role_assignments`;
|
|
6487
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, endpoint, deserializeGroupRoleAssignment, paginationOptions), (params) => fetchAndDeserialize(this.workos, endpoint, deserializeGroupRoleAssignment, params), paginationOptions);
|
|
6488
|
+
}
|
|
6489
|
+
/**
|
|
6490
|
+
* Get a group role assignment
|
|
6491
|
+
*
|
|
6492
|
+
* Get a specific role assignment for a group by its ID.
|
|
6493
|
+
* @param options - Object containing groupId and roleAssignmentId.
|
|
6494
|
+
* @param options.groupId - The ID of the group.
|
|
6495
|
+
*
|
|
6496
|
+
* @example
|
|
6497
|
+
* "group_01HXYZ123456789ABCDEFGHIJ"
|
|
6498
|
+
*
|
|
6499
|
+
* @param options.roleAssignmentId - The ID of the group role assignment.
|
|
6500
|
+
*
|
|
6501
|
+
* @example
|
|
6502
|
+
* "gra_01HXYZ123456789ABCDEFGH"
|
|
6503
|
+
*
|
|
6504
|
+
* @returns {Promise<GroupRoleAssignment>}
|
|
6505
|
+
* @throws 403 response from the API.
|
|
6506
|
+
* @throws {NotFoundException} 404
|
|
6507
|
+
*/
|
|
6508
|
+
async getGroupRoleAssignment(options) {
|
|
6509
|
+
const { data } = await this.workos.get(`/authorization/groups/${options.groupId}/role_assignments/${options.roleAssignmentId}`);
|
|
6510
|
+
return deserializeGroupRoleAssignment(data);
|
|
6511
|
+
}
|
|
6512
|
+
/**
|
|
6513
|
+
* Assign a role to a group
|
|
6514
|
+
*
|
|
6515
|
+
* Assign a role to a group on a specific resource. Omit the resource fields to assign the role on the organization itself.
|
|
6516
|
+
* @param options - Object containing groupId and roleSlug.
|
|
6517
|
+
* @returns {Promise<GroupRoleAssignment>}
|
|
6518
|
+
* @throws 403 response from the API.
|
|
6519
|
+
* @throws {NotFoundException} 404
|
|
6520
|
+
* @throws {ConflictException} 409
|
|
6521
|
+
* @throws {UnprocessableEntityException} 422
|
|
6522
|
+
*/
|
|
6523
|
+
async createGroupRoleAssignment(options) {
|
|
6524
|
+
const { data } = await this.workos.post(`/authorization/groups/${options.groupId}/role_assignments`, serializeCreateGroupRoleAssignmentOptions(options));
|
|
6525
|
+
return deserializeGroupRoleAssignment(data);
|
|
6526
|
+
}
|
|
6527
|
+
/**
|
|
6528
|
+
* Remove a group role assignment
|
|
6529
|
+
*
|
|
6530
|
+
* Remove a specific role assignment from a group by its ID.
|
|
6531
|
+
* @param options - Object containing groupId and roleAssignmentId.
|
|
6532
|
+
* @param options.groupId - The ID of the group.
|
|
6533
|
+
*
|
|
6534
|
+
* @example
|
|
6535
|
+
* "group_01HXYZ123456789ABCDEFGHIJ"
|
|
6536
|
+
*
|
|
6537
|
+
* @param options.roleAssignmentId - The ID of the group role assignment to remove.
|
|
6538
|
+
*
|
|
6539
|
+
* @example
|
|
6540
|
+
* "gra_01HXYZ123456789ABCDEFGH"
|
|
6541
|
+
*
|
|
6542
|
+
* @returns {Promise<void>}
|
|
6543
|
+
* @throws 403 response from the API.
|
|
6544
|
+
* @throws {NotFoundException} 404
|
|
6545
|
+
*/
|
|
6546
|
+
async removeGroupRoleAssignment(options) {
|
|
6547
|
+
await this.workos.delete(`/authorization/groups/${options.groupId}/role_assignments/${options.roleAssignmentId}`);
|
|
6548
|
+
}
|
|
6549
|
+
/**
|
|
6550
|
+
* Remove group role assignments by criteria
|
|
6551
|
+
*
|
|
6552
|
+
* Remove role assignments from a group that match the provided role and resource. Omit the resource fields to target the organization itself.
|
|
6553
|
+
* @param options - Object containing groupId and roleSlug.
|
|
6554
|
+
* @returns {Promise<void>}
|
|
6555
|
+
* @throws 403 response from the API.
|
|
6556
|
+
* @throws {NotFoundException} 404
|
|
6557
|
+
* @throws {UnprocessableEntityException} 422
|
|
6558
|
+
*/
|
|
6559
|
+
async removeGroupRoleAssignments(options) {
|
|
6560
|
+
await this.workos.deleteWithBody(`/authorization/groups/${options.groupId}/role_assignments`, serializeRemoveGroupRoleAssignmentsOptions(options));
|
|
6561
|
+
}
|
|
6562
|
+
/**
|
|
6563
|
+
* Replace role assignments for a group
|
|
6564
|
+
*
|
|
6565
|
+
* Replace all of a group's role assignments with the provided list. Assignments not present in the list are removed and new ones are created. Pass an empty `roleAssignments` array to clear all assignments. Returns the resulting set of assignments.
|
|
6566
|
+
* @param options - Object containing groupId and roleAssignments.
|
|
6567
|
+
* @returns {Promise<List<GroupRoleAssignment>>}
|
|
6568
|
+
* @throws 403 response from the API.
|
|
6569
|
+
* @throws {NotFoundException} 404
|
|
6570
|
+
* @throws {UnprocessableEntityException} 422
|
|
6571
|
+
*/
|
|
6572
|
+
async replaceGroupRoleAssignments(options) {
|
|
6573
|
+
const { data } = await this.workos.put(`/authorization/groups/${options.groupId}/role_assignments`, serializeReplaceGroupRoleAssignmentsOptions(options));
|
|
6574
|
+
return deserializeList(data, deserializeGroupRoleAssignment);
|
|
6575
|
+
}
|
|
6576
|
+
/**
|
|
6353
6577
|
* List resources for organization membership
|
|
6354
6578
|
*
|
|
6355
6579
|
* 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?"
|
|
@@ -6917,7 +7141,7 @@ var Vault = class {
|
|
|
6917
7141
|
};
|
|
6918
7142
|
//#endregion
|
|
6919
7143
|
//#region package.json
|
|
6920
|
-
var version = "10.
|
|
7144
|
+
var version = "10.4.0";
|
|
6921
7145
|
//#endregion
|
|
6922
7146
|
//#region src/workos.ts
|
|
6923
7147
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
@@ -7448,4 +7672,4 @@ Object.defineProperty(exports, "serializeRevokeSessionOptions", {
|
|
|
7448
7672
|
}
|
|
7449
7673
|
});
|
|
7450
7674
|
|
|
7451
|
-
//# sourceMappingURL=factory-
|
|
7675
|
+
//# sourceMappingURL=factory-CYqsa7gY.cjs.map
|