inngest 4.2.5 → 4.2.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # inngest
2
2
 
3
+ ## 4.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1492](https://github.com/inngest/inngest-js/pull/1492) [`68dcd8aa`](https://github.com/inngest/inngest-js/commit/68dcd8aa3810a1285dca62321d63c39476c75840) Thanks [@amh4r](https://github.com/amh4r)! - Reduce response info when unauthorized
8
+
9
+ - [#1490](https://github.com/inngest/inngest-js/pull/1490) [`a8027116`](https://github.com/inngest/inngest-js/commit/a80271163fa5e28b316f218cf5fa81a5600c5048) Thanks [@amh4r](https://github.com/amh4r)! - Authed introspection returns partial signing key hash
10
+
3
11
  ## 4.2.5
4
12
 
5
13
  ### Patch Changes
package/api/api.cjs CHANGED
@@ -2,8 +2,8 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_errors = require('../helpers/errors.cjs');
3
3
  const require_types = require('../types.cjs');
4
4
  const require_schema = require('./schema.cjs');
5
- const require_net = require('../helpers/net.cjs');
6
5
  const require_strings = require('../helpers/strings.cjs');
6
+ const require_net = require('../helpers/net.cjs');
7
7
  let zod_v3 = require("zod/v3");
8
8
 
9
9
  //#region src/api/api.ts
package/api/api.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { getErrorMessage } from "../helpers/errors.js";
2
2
  import { err, ok } from "../types.js";
3
3
  import { batchSchema, errorSchema, stepSchema } from "./schema.js";
4
- import { fetchWithAuthFallback } from "../helpers/net.js";
5
4
  import { hashSigningKey } from "../helpers/strings.js";
5
+ import { fetchWithAuthFallback } from "../helpers/net.js";
6
6
  import { z } from "zod/v3";
7
7
 
8
8
  //#region src/api/api.ts
@@ -3,8 +3,8 @@ const require_env = require('../helpers/env.cjs');
3
3
  const require_errors = require('../helpers/errors.cjs');
4
4
  const require_types = require('../types.cjs');
5
5
  const require_log = require('../helpers/log.cjs');
6
- const require_promises = require('../helpers/promises.cjs');
7
6
  const require_strings = require('../helpers/strings.cjs');
7
+ const require_promises = require('../helpers/promises.cjs');
8
8
  const require_als = require('./execution/als.cjs');
9
9
  const require_api = require('../api/api.cjs');
10
10
  const require_crypto = require('../helpers/crypto.cjs');
@@ -3,8 +3,8 @@ import { getFetch, getProcessEnv, inngestHeaders, normalizeUrl, parseAsBoolean,
3
3
  import { fixEventKeyMissingSteps } from "../helpers/errors.js";
4
4
  import { sendEventResponseSchema } from "../types.js";
5
5
  import { formatLogMessage } from "../helpers/log.js";
6
- import { retryWithBackoff } from "../helpers/promises.js";
7
6
  import { stringify } from "../helpers/strings.js";
7
+ import { retryWithBackoff } from "../helpers/promises.js";
8
8
  import { getAsyncCtx } from "./execution/als.js";
9
9
  import { InngestApi } from "../api/api.js";
10
10
  import { createEntropy } from "../helpers/crypto.js";
@@ -9,10 +9,10 @@ const require_InngestExecution = require('./execution/InngestExecution.cjs');
9
9
  const require_types$1 = require('../helpers/types.cjs');
10
10
  const require_log = require('../helpers/log.cjs');
11
11
  const require_functions = require('../helpers/functions.cjs');
12
+ const require_strings = require('../helpers/strings.cjs');
12
13
  const require_net = require('../helpers/net.cjs');
13
14
  const require_promises = require('../helpers/promises.cjs');
14
15
  const require_ServerTiming = require('../helpers/ServerTiming.cjs');
15
- const require_strings = require('../helpers/strings.cjs');
16
16
  const require_stream = require('../helpers/stream.cjs');
17
17
  const require_als = require('./execution/als.cjs');
18
18
  const require_InngestFunction = require('./InngestFunction.cjs');
@@ -604,7 +604,21 @@ var InngestCommHandler = class {
604
604
  mwInstances
605
605
  }));
606
606
  actionResponseVersion = rawRes.version;
607
- return prepareActionRes(rawRes);
607
+ const prepared = await prepareActionRes(rawRes);
608
+ if (!(await signatureValidation).success) {
609
+ const filteredHeaders = {};
610
+ for (const [k, v] of Object.entries(prepared.headers)) {
611
+ const lower = k.toLowerCase();
612
+ if (lower === "user-agent") continue;
613
+ if (lower.startsWith("x-inngest-") && lower !== require_consts.headerKeys.SdkHandled.toLowerCase()) continue;
614
+ filteredHeaders[k] = v;
615
+ }
616
+ return {
617
+ ...prepared,
618
+ headers: filteredHeaders
619
+ };
620
+ }
621
+ return prepared;
608
622
  };
609
623
  let chainResult;
610
624
  if (method === "POST") {
@@ -782,19 +796,22 @@ var InngestCommHandler = class {
782
796
  if (!forceExecution && isMissingBody) {
783
797
  this.client[require_Inngest.internalLoggerSymbol].error("Missing body when executing, possibly due to missing request body middleware");
784
798
  return {
785
- status: 500,
799
+ status: 401,
786
800
  headers: { "Content-Type": "application/json" },
787
- body: require_strings.stringify(require_errors.serializeError(/* @__PURE__ */ new Error("Missing request body when executing, possibly due to missing request body middleware"))),
801
+ body: require_strings.stringify({ message: "Unauthorized" }),
788
802
  version: void 0
789
803
  };
790
804
  }
791
805
  const validationResult = await signatureValidation;
792
- if (!validationResult.success) return {
793
- status: 401,
794
- headers: { "Content-Type": "application/json" },
795
- body: require_strings.stringify(require_errors.serializeError(validationResult.err)),
796
- version: void 0
797
- };
806
+ if (!validationResult.success) {
807
+ this.client[require_Inngest.internalLoggerSymbol].error({ err: validationResult.err }, "Signature validation failed");
808
+ return {
809
+ status: 401,
810
+ headers: { "Content-Type": "application/json" },
811
+ body: require_strings.stringify({ message: "Unauthorized" }),
812
+ version: void 0
813
+ };
814
+ }
798
815
  let fn;
799
816
  let fnId;
800
817
  if (forceExecution) {
@@ -993,17 +1010,31 @@ var InngestCommHandler = class {
993
1010
  }
994
1011
  }
995
1012
  const env = (await getHeaders())[require_consts.headerKeys.Environment] ?? null;
996
- if (method === "GET") return {
997
- status: 200,
998
- body: require_strings.stringify(await this.introspectionBody({
999
- actions,
1000
- env,
1001
- signatureValidation,
1002
- url
1003
- })),
1004
- headers: { "Content-Type": "application/json" },
1005
- version: void 0
1006
- };
1013
+ if (method === "GET") {
1014
+ if (this.client.mode === "cloud") {
1015
+ const validationResult = await signatureValidation;
1016
+ if (!validationResult.success) {
1017
+ this.client[require_Inngest.internalLoggerSymbol].error({ err: validationResult.err }, "Signature validation failed");
1018
+ return {
1019
+ status: 401,
1020
+ headers: { "Content-Type": "application/json" },
1021
+ body: require_strings.stringify({ message: "Unauthorized" }),
1022
+ version: void 0
1023
+ };
1024
+ }
1025
+ }
1026
+ return {
1027
+ status: 200,
1028
+ body: require_strings.stringify(await this.introspectionBody({
1029
+ actions,
1030
+ env,
1031
+ signatureValidation,
1032
+ url
1033
+ })),
1034
+ headers: { "Content-Type": "application/json" },
1035
+ version: void 0
1036
+ };
1037
+ }
1007
1038
  if (method === "PUT") {
1008
1039
  const [deployId, inBandSyncRequested] = await Promise.all([actions.queryStringWithDefaults("processing deployment request", require_consts.queryKeys.DeployId).then((deployId$1) => {
1009
1040
  return deployId$1 === "undefined" ? void 0 : deployId$1;
@@ -1084,11 +1115,8 @@ var InngestCommHandler = class {
1084
1115
  this.client[require_Inngest.internalLoggerSymbol].error({ method }, "Received unhandled HTTP method; expected POST, PUT, or GET");
1085
1116
  return {
1086
1117
  status: 405,
1087
- body: JSON.stringify({
1088
- message: `No action found; expected POST, PUT, or GET but received "${method}"`,
1089
- mode: this.client.mode
1090
- }),
1091
- headers: {},
1118
+ body: JSON.stringify({ message: "Method not allowed" }),
1119
+ headers: { "Content-Type": "application/json" },
1092
1120
  version: void 0
1093
1121
  };
1094
1122
  }
@@ -1258,6 +1286,10 @@ var InngestCommHandler = class {
1258
1286
  };
1259
1287
  if (this.client.mode === "cloud") try {
1260
1288
  if (!(await signatureValidation).success) throw new Error("Signature validation failed");
1289
+ let signingKeyHash = null;
1290
+ if (this.hashedSigningKey) signingKeyHash = require_strings.removeSigningKeyPrefix(this.hashedSigningKey).slice(0, 12);
1291
+ let signingKeyFallbackHash = null;
1292
+ if (this.hashedSigningKeyFallback) signingKeyFallbackHash = require_strings.removeSigningKeyPrefix(this.hashedSigningKeyFallback).slice(0, 12);
1261
1293
  introspection = {
1262
1294
  ...introspection,
1263
1295
  authentication_succeeded: true,
@@ -1280,8 +1312,8 @@ var InngestCommHandler = class {
1280
1312
  sdk_version: require_version.version,
1281
1313
  serve_origin: this.serveOrigin ?? null,
1282
1314
  serve_path: this.servePath ?? null,
1283
- signing_key_fallback_hash: this.hashedSigningKeyFallback ?? null,
1284
- signing_key_hash: this.hashedSigningKey ?? null
1315
+ signing_key_fallback_hash: signingKeyFallbackHash,
1316
+ signing_key_hash: signingKeyHash
1285
1317
  };
1286
1318
  } catch {
1287
1319
  introspection = { ...introspection };