@workos-inc/node 10.9.0 → 10.11.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-Bd19upQB.cjs → factory-JdOhqH28.cjs} +92 -23
- package/lib/factory-JdOhqH28.cjs.map +1 -0
- package/lib/{factory-DmBBe791.d.mts → factory-VM3aexOH.d.cts} +153 -203
- package/lib/{factory-DmBBe791.d.cts → factory-VM3aexOH.d.mts} +153 -203
- package/lib/{factory-BdXIrbcU.mjs → factory-iK-8FO4O.mjs} +92 -23
- package/lib/factory-iK-8FO4O.mjs.map +1 -0
- package/lib/index.cjs +6 -4
- 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 +6 -4
- package/lib/index.mjs.map +1 -1
- package/lib/index.worker.cjs +3 -2
- 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 +3 -2
- package/lib/index.worker.mjs.map +1 -1
- package/lib/{webapi-BgpV54gi.mjs → webapi-BlhUk1KL.mjs} +1415 -1734
- package/lib/webapi-BlhUk1KL.mjs.map +1 -0
- package/lib/{webapi-BzGFatFp.cjs → webapi-D3QZrB15.cjs} +1415 -1734
- package/lib/webapi-D3QZrB15.cjs.map +1 -0
- package/package.json +2 -2
- package/lib/factory-Bd19upQB.cjs.map +0 -1
- package/lib/factory-BdXIrbcU.mjs.map +0 -1
- package/lib/webapi-BgpV54gi.mjs.map +0 -1
- package/lib/webapi-BzGFatFp.cjs.map +0 -1
|
@@ -1180,6 +1180,7 @@ const deserializeAction = (actionPayload) => {
|
|
|
1180
1180
|
object: actionPayload.object,
|
|
1181
1181
|
userData: deserializeUserData(actionPayload.user_data),
|
|
1182
1182
|
invitation: actionPayload.invitation ? deserializeInvitation(actionPayload.invitation) : void 0,
|
|
1183
|
+
authenticationMethod: actionPayload.authentication_method,
|
|
1183
1184
|
ipAddress: actionPayload.ip_address,
|
|
1184
1185
|
userAgent: actionPayload.user_agent,
|
|
1185
1186
|
deviceFingerprint: actionPayload.device_fingerprint
|
|
@@ -1190,6 +1191,7 @@ const deserializeAction = (actionPayload) => {
|
|
|
1190
1191
|
user: deserializeUser(actionPayload.user),
|
|
1191
1192
|
organization: actionPayload.organization ? deserializeOrganization(actionPayload.organization) : void 0,
|
|
1192
1193
|
organizationMembership: actionPayload.organization_membership ? deserializeOrganizationMembership(actionPayload.organization_membership) : void 0,
|
|
1194
|
+
authenticationMethod: actionPayload.authentication_method,
|
|
1193
1195
|
ipAddress: actionPayload.ip_address,
|
|
1194
1196
|
userAgent: actionPayload.user_agent,
|
|
1195
1197
|
deviceFingerprint: actionPayload.device_fingerprint,
|
|
@@ -1240,7 +1242,8 @@ var Actions = class {
|
|
|
1240
1242
|
tolerance
|
|
1241
1243
|
};
|
|
1242
1244
|
await this.verifyHeader(options);
|
|
1243
|
-
|
|
1245
|
+
const parsed = typeof payload === "string" || isBinaryPayload(payload) ? JSON.parse(decodePayloadToString(payload)) : payload;
|
|
1246
|
+
return deserializeAction(parsed);
|
|
1244
1247
|
}
|
|
1245
1248
|
};
|
|
1246
1249
|
//#endregion
|
|
@@ -2055,7 +2058,8 @@ var Webhooks = class {
|
|
|
2055
2058
|
tolerance
|
|
2056
2059
|
};
|
|
2057
2060
|
await this.verifyHeader(options);
|
|
2058
|
-
|
|
2061
|
+
const webhookPayload = this.parseVerifiedPayload(payload);
|
|
2062
|
+
return deserializeEvent(webhookPayload);
|
|
2059
2063
|
}
|
|
2060
2064
|
parseVerifiedPayload(payload) {
|
|
2061
2065
|
if (typeof payload === "object" && !isBinaryPayload(payload)) return payload;
|
|
@@ -2128,7 +2132,7 @@ let _josePromise;
|
|
|
2128
2132
|
* @returns Promise that resolves to the jose module
|
|
2129
2133
|
*/
|
|
2130
2134
|
function getJose() {
|
|
2131
|
-
return _josePromise ??= Promise.resolve().then(() => require("./webapi-
|
|
2135
|
+
return _josePromise ??= Promise.resolve().then(() => require("./webapi-D3QZrB15.cjs"));
|
|
2132
2136
|
}
|
|
2133
2137
|
//#endregion
|
|
2134
2138
|
//#region src/agents/serializers/agent-registration.serializer.ts
|
|
@@ -2346,7 +2350,7 @@ var Agents = class {
|
|
|
2346
2350
|
const { clientId } = this.workos;
|
|
2347
2351
|
if (!clientId) throw new Error("Missing client ID. Did you provide it when initializing WorkOS?");
|
|
2348
2352
|
const { createRemoteJWKSet } = await getJose();
|
|
2349
|
-
this._jwks ??= createRemoteJWKSet(new URL(`${this.workos.baseURL}/sso/jwks/${clientId}`), { cooldownDuration:
|
|
2353
|
+
this._jwks ??= createRemoteJWKSet(new URL(`${this.workos.baseURL}/sso/jwks/${clientId}`), { cooldownDuration: 3e5 });
|
|
2350
2354
|
return this._jwks;
|
|
2351
2355
|
}
|
|
2352
2356
|
};
|
|
@@ -5035,7 +5039,7 @@ var UserManagement = class {
|
|
|
5035
5039
|
async getJWKS() {
|
|
5036
5040
|
const { createRemoteJWKSet } = await getJose();
|
|
5037
5041
|
if (!this.clientId) return;
|
|
5038
|
-
this._jwks ??= createRemoteJWKSet(new URL(this.getJwksUrl(this.clientId)), { cooldownDuration:
|
|
5042
|
+
this._jwks ??= createRemoteJWKSet(new URL(this.getJwksUrl(this.clientId)), { cooldownDuration: 3e5 });
|
|
5039
5043
|
return this._jwks;
|
|
5040
5044
|
}
|
|
5041
5045
|
/**
|
|
@@ -5945,31 +5949,91 @@ var InMemoryStore = class {
|
|
|
5945
5949
|
};
|
|
5946
5950
|
//#endregion
|
|
5947
5951
|
//#region src/feature-flags/evaluator.ts
|
|
5952
|
+
const TARGET_TYPE_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/;
|
|
5953
|
+
const TARGET_ID_PATTERN = /^[A-Za-z0-9._:-]{1,255}$/;
|
|
5954
|
+
const LEGACY_KEY_TO_TARGET_TYPE = /* @__PURE__ */ new Map([["userId", "user"], ["organizationId", "organization"]]);
|
|
5955
|
+
const isEvaluationResource = (value) => typeof value === "object" && value !== null && "id" in value && typeof value.id === "string";
|
|
5948
5956
|
var Evaluator = class {
|
|
5949
5957
|
store;
|
|
5950
|
-
|
|
5958
|
+
logger;
|
|
5959
|
+
constructor(store, logger) {
|
|
5951
5960
|
this.store = store;
|
|
5961
|
+
this.logger = logger;
|
|
5952
5962
|
}
|
|
5953
5963
|
isEnabled(flagKey, context = {}, defaultValue = false) {
|
|
5954
|
-
|
|
5955
|
-
if (!entry) return defaultValue;
|
|
5956
|
-
if (!entry.enabled) return false;
|
|
5957
|
-
if (context.userId) {
|
|
5958
|
-
const userTarget = entry.targets.users.find((t) => t.id === context.userId);
|
|
5959
|
-
if (userTarget) return userTarget.enabled;
|
|
5960
|
-
}
|
|
5961
|
-
if (context.organizationId) {
|
|
5962
|
-
const orgTarget = entry.targets.organizations.find((t) => t.id === context.organizationId);
|
|
5963
|
-
if (orgTarget) return orgTarget.enabled;
|
|
5964
|
-
}
|
|
5965
|
-
return entry.default_value;
|
|
5964
|
+
return this.evaluate(this.store.get(flagKey), this.normalizeContext(context), defaultValue);
|
|
5966
5965
|
}
|
|
5967
5966
|
getAllFlags(context = {}) {
|
|
5967
|
+
const normalizedContext = this.normalizeContext(context);
|
|
5968
5968
|
const flags = this.store.getAll();
|
|
5969
5969
|
const result = {};
|
|
5970
|
-
for (const slug of Object.keys(flags)) result[slug] = this.
|
|
5970
|
+
for (const slug of Object.keys(flags)) result[slug] = this.evaluate(flags[slug], normalizedContext, false);
|
|
5971
5971
|
return result;
|
|
5972
5972
|
}
|
|
5973
|
+
evaluate(entry, normalizedContext, defaultValue) {
|
|
5974
|
+
if (!entry) return defaultValue;
|
|
5975
|
+
if (!entry.enabled) return false;
|
|
5976
|
+
for (const [targetType, targetId] of normalizedContext) if (this.hasEnabledTarget(entry, targetType, targetId)) return true;
|
|
5977
|
+
return entry.default_value;
|
|
5978
|
+
}
|
|
5979
|
+
/**
|
|
5980
|
+
* Reduces either context form to target type → ID pairs. Evaluation must
|
|
5981
|
+
* never throw in application code, so every invalid piece of context
|
|
5982
|
+
* degrades to "matches no targets" with a logged warning instead of an
|
|
5983
|
+
* error.
|
|
5984
|
+
*/
|
|
5985
|
+
normalizeContext(context) {
|
|
5986
|
+
const normalized = /* @__PURE__ */ new Map();
|
|
5987
|
+
const record = context;
|
|
5988
|
+
const legacyEntries = [];
|
|
5989
|
+
const typedKeys = [];
|
|
5990
|
+
for (const [key, value] of Object.entries(record)) {
|
|
5991
|
+
if (value === void 0 || value === null) continue;
|
|
5992
|
+
const legacyTargetType = LEGACY_KEY_TO_TARGET_TYPE.get(key);
|
|
5993
|
+
if (legacyTargetType) {
|
|
5994
|
+
if (typeof value === "string" && value !== "") legacyEntries.push([legacyTargetType, value]);
|
|
5995
|
+
continue;
|
|
5996
|
+
}
|
|
5997
|
+
typedKeys.push(key);
|
|
5998
|
+
}
|
|
5999
|
+
const resourceShapedKeys = typedKeys.filter((key) => typeof record[key] === "object");
|
|
6000
|
+
if (legacyEntries.length > 0 && resourceShapedKeys.length > 0) {
|
|
6001
|
+
this.logger?.warn("Evaluation context mixes legacy keys (userId/organizationId) with typed target keys; no targets will match", { keys: Object.keys(record) });
|
|
6002
|
+
return normalized;
|
|
6003
|
+
}
|
|
6004
|
+
if (legacyEntries.length > 0) {
|
|
6005
|
+
for (const [targetType, targetId] of legacyEntries) normalized.set(targetType, targetId);
|
|
6006
|
+
return normalized;
|
|
6007
|
+
}
|
|
6008
|
+
for (const key of typedKeys) {
|
|
6009
|
+
if (!TARGET_TYPE_PATTERN.test(key)) {
|
|
6010
|
+
this.logger?.warn(`Ignoring invalid target type in evaluation context: ${key}`);
|
|
6011
|
+
continue;
|
|
6012
|
+
}
|
|
6013
|
+
const value = record[key];
|
|
6014
|
+
if (!isEvaluationResource(value)) {
|
|
6015
|
+
this.logger?.warn(`Ignoring target type with a missing or invalid resource id in evaluation context: ${key}`);
|
|
6016
|
+
continue;
|
|
6017
|
+
}
|
|
6018
|
+
const { id } = value;
|
|
6019
|
+
if (!TARGET_ID_PATTERN.test(id) || id === "." || id === "..") {
|
|
6020
|
+
this.logger?.warn(`Ignoring invalid target id in evaluation context for type: ${key}`);
|
|
6021
|
+
continue;
|
|
6022
|
+
}
|
|
6023
|
+
normalized.set(key, id);
|
|
6024
|
+
}
|
|
6025
|
+
return normalized;
|
|
6026
|
+
}
|
|
6027
|
+
/**
|
|
6028
|
+
* A target participates in evaluation only while its `enabled` is true. A
|
|
6029
|
+
* `false` value is reserved for future disabled overrides and is treated
|
|
6030
|
+
* as if the target were absent.
|
|
6031
|
+
*/
|
|
6032
|
+
hasEnabledTarget(entry, targetType, targetId) {
|
|
6033
|
+
if (targetType === "user") return entry.targets.users.some((t) => t.id === targetId && t.enabled);
|
|
6034
|
+
if (targetType === "organization") return entry.targets.organizations.some((t) => t.id === targetId && t.enabled);
|
|
6035
|
+
return (entry.targets.custom_targets ?? []).some((t) => t.type === targetType && t.id === targetId && t.enabled);
|
|
6036
|
+
}
|
|
5973
6037
|
};
|
|
5974
6038
|
//#endregion
|
|
5975
6039
|
//#region src/feature-flags/runtime-client.ts
|
|
@@ -6011,7 +6075,7 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
|
|
|
6011
6075
|
this.requestTimeoutMs = options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
6012
6076
|
this.logger = options.logger;
|
|
6013
6077
|
this.store = new InMemoryStore();
|
|
6014
|
-
this.evaluator = new Evaluator(this.store);
|
|
6078
|
+
this.evaluator = new Evaluator(this.store, this.logger);
|
|
6015
6079
|
this.readyPromise = new Promise((resolve, reject) => {
|
|
6016
6080
|
this.readyResolve = resolve;
|
|
6017
6081
|
this.readyReject = reject;
|
|
@@ -6156,7 +6220,12 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
|
|
|
6156
6220
|
const map = new Map(ys.map((t) => [t.id, t.enabled]));
|
|
6157
6221
|
return xs.some((t) => map.get(t.id) !== t.enabled);
|
|
6158
6222
|
};
|
|
6159
|
-
|
|
6223
|
+
const customTargetsChanged = (xs, ys) => {
|
|
6224
|
+
if (xs.length !== ys.length) return true;
|
|
6225
|
+
const map = new Map(ys.map((t) => [`${t.type}:${t.id}`, t.enabled]));
|
|
6226
|
+
return xs.some((t) => map.get(`${t.type}:${t.id}`) !== t.enabled);
|
|
6227
|
+
};
|
|
6228
|
+
return targetsChanged(a.targets.users, b.targets.users) || targetsChanged(a.targets.organizations, b.targets.organizations) || customTargetsChanged(a.targets.custom_targets ?? [], b.targets.custom_targets ?? []);
|
|
6160
6229
|
}
|
|
6161
6230
|
};
|
|
6162
6231
|
//#endregion
|
|
@@ -8069,7 +8138,7 @@ var Vault = class {
|
|
|
8069
8138
|
};
|
|
8070
8139
|
//#endregion
|
|
8071
8140
|
//#region package.json
|
|
8072
|
-
var version = "10.
|
|
8141
|
+
var version = "10.11.0";
|
|
8073
8142
|
//#endregion
|
|
8074
8143
|
//#region src/workos.ts
|
|
8075
8144
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
@@ -8606,4 +8675,4 @@ Object.defineProperty(exports, "serializeRevokeSessionOptions", {
|
|
|
8606
8675
|
}
|
|
8607
8676
|
});
|
|
8608
8677
|
|
|
8609
|
-
//# sourceMappingURL=factory-
|
|
8678
|
+
//# sourceMappingURL=factory-JdOhqH28.cjs.map
|