@workos-inc/node 12.4.0 → 12.4.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.
@@ -10226,13 +10226,6 @@ declare class UserManagement {
10226
10226
  * the token; errors that are not JWT validation failures propagate.
10227
10227
  */
10228
10228
  private verifyJwt;
10229
- /**
10230
- * Whether a jose error means the presented token is invalid, as opposed to
10231
- * a failure to verify it at all. Network errors, JWKS timeouts and crypto
10232
- * failures propagate so they surface as errors rather than as rejected
10233
- * tokens.
10234
- */
10235
- private static isJwtValidationError;
10236
10229
  private prepareAuthenticationResponse;
10237
10230
  private sealSessionDataFromAuthenticationResponse;
10238
10231
  getSessionFromCookie({ sessionData, cookiePassword }: SessionHandlerOptions): Promise<SessionCookieData | undefined>;
@@ -2782,6 +2782,23 @@ let _josePromise;
2782
2782
  function getJose() {
2783
2783
  return _josePromise ??= Promise.resolve().then(() => require("./webapi-rpGT44g1.cjs"));
2784
2784
  }
2785
+ const ALLOWED_JWT_ALGORITHMS = [
2786
+ "RS256",
2787
+ "ES256",
2788
+ "ES384",
2789
+ "ES512",
2790
+ "EdDSA",
2791
+ "Ed25519"
2792
+ ];
2793
+ /**
2794
+ * Whether a jose error means the presented token is invalid, as opposed to
2795
+ * a failure to verify it at all. Network errors, JWKS timeouts and crypto
2796
+ * failures propagate so they surface as errors rather than as rejected tokens.
2797
+ */
2798
+ function isJwtValidationError(e) {
2799
+ if (!(e instanceof Error) || !("code" in e) || typeof e.code !== "string") return false;
2800
+ return e.code.startsWith("ERR_JWT_") || e.code.startsWith("ERR_JWS_") || e.code === "ERR_JWKS_NO_MATCHING_KEY" || e.code === "ERR_JWKS_MULTIPLE_MATCHING_KEYS" || e.code === "ERR_JOSE_NOT_SUPPORTED" || e.code === "ERR_JOSE_ALG_NOT_ALLOWED";
2801
+ }
2785
2802
  // src/agents/serializers/agent-instance-session.serializer.ts
2786
2803
  function deserializeAgentInstanceSession(session) {
2787
2804
  return {
@@ -3223,12 +3240,15 @@ var Agents = class {
3223
3240
  const { jwtVerify } = await getJose();
3224
3241
  const jwks = await this.getJWKS();
3225
3242
  try {
3226
- const { payload } = await jwtVerify(credential, jwks, { audience: audience ?? this.workos.clientId });
3243
+ const { payload } = await jwtVerify(credential, jwks, {
3244
+ algorithms: ALLOWED_JWT_ALGORITHMS,
3245
+ audience: audience ?? this.workos.clientId
3246
+ });
3227
3247
  if (!hasRequiredAgentClaims(payload)) return null;
3228
3248
  if (payload.exp * 1e3 <= Date.now()) return null;
3229
3249
  return deserializeAgentAccessTokenClaims(payload);
3230
3250
  } catch (e) {
3231
- if (e instanceof Error && "code" in e && typeof e.code === "string" && (e.code.startsWith("ERR_JWT_") || e.code.startsWith("ERR_JWS_"))) return null;
3251
+ if (isJwtValidationError(e)) return null;
3232
3252
  throw e;
3233
3253
  }
3234
3254
  }
@@ -7127,23 +7147,16 @@ var UserManagement = class UserManagement {
7127
7147
  const { jwtVerify } = await getJose();
7128
7148
  if (!jwks) throw new Error("Must provide clientId to initialize JWKS");
7129
7149
  try {
7130
- const { payload } = await jwtVerify(accessToken, jwks, this.issuer ? { issuer: this.issuer } : void 0);
7150
+ const { payload } = await jwtVerify(accessToken, jwks, {
7151
+ algorithms: ALLOWED_JWT_ALGORITHMS,
7152
+ ...this.issuer ? { issuer: this.issuer } : {}
7153
+ });
7131
7154
  return payload;
7132
7155
  } catch (e) {
7133
- if (UserManagement.isJwtValidationError(e)) return null;
7156
+ if (isJwtValidationError(e)) return null;
7134
7157
  throw e;
7135
7158
  }
7136
7159
  }
7137
- /**
7138
- * Whether a jose error means the presented token is invalid, as opposed to
7139
- * a failure to verify it at all. Network errors, JWKS timeouts and crypto
7140
- * failures propagate so they surface as errors rather than as rejected
7141
- * tokens.
7142
- */
7143
- static isJwtValidationError(e) {
7144
- if (!(e instanceof Error) || !("code" in e) || typeof e.code !== "string") return false;
7145
- return e.code.startsWith("ERR_JWT_") || e.code.startsWith("ERR_JWS_") || e.code === "ERR_JWKS_NO_MATCHING_KEY" || e.code === "ERR_JWKS_MULTIPLE_MATCHING_KEYS" || e.code === "ERR_JOSE_NOT_SUPPORTED" || e.code === "ERR_JOSE_ALG_NOT_ALLOWED";
7146
- }
7147
7160
  async prepareAuthenticationResponse({ authenticationResponse, session }) {
7148
7161
  if (session?.sealSession) {
7149
7162
  if (!this.workos.key) throw new Error("Session sealing requires server-side usage with an API key. Public clients should store tokens directly (e.g., secure storage on mobile, keychain on desktop).");
@@ -10159,7 +10172,7 @@ var Vault = class {
10159
10172
  }
10160
10173
  };
10161
10174
  // package.json
10162
- var version = "12.4.0";
10175
+ var version = "12.4.1";
10163
10176
  // src/workos.ts
10164
10177
  const DEFAULT_HOSTNAME = "api.workos.com";
10165
10178
  const HEADER_AUTHORIZATION = "Authorization";
@@ -10775,4 +10788,4 @@ Object.defineProperty(exports, "serializeRevokeSessionOptions", {
10775
10788
  }
10776
10789
  });
10777
10790
 
10778
- //# sourceMappingURL=factory-CnNO67Ux.cjs.map
10791
+ //# sourceMappingURL=factory-Eg0FV6MT.cjs.map