@aws-sdk/middleware-recursion-detection 3.734.0 → 3.772.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/dist-cjs/index.js CHANGED
@@ -19,20 +19,24 @@ var __copyProps = (to, from, except, desc) => {
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
 
21
21
  // src/index.ts
22
- var src_exports = {};
23
- __export(src_exports, {
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
24
  addRecursionDetectionMiddlewareOptions: () => addRecursionDetectionMiddlewareOptions,
25
25
  getRecursionDetectionPlugin: () => getRecursionDetectionPlugin,
26
26
  recursionDetectionMiddleware: () => recursionDetectionMiddleware
27
27
  });
28
- module.exports = __toCommonJS(src_exports);
28
+ module.exports = __toCommonJS(index_exports);
29
29
  var import_protocol_http = require("@smithy/protocol-http");
30
30
  var TRACE_ID_HEADER_NAME = "X-Amzn-Trace-Id";
31
31
  var ENV_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME";
32
32
  var ENV_TRACE_ID = "_X_AMZN_TRACE_ID";
33
33
  var recursionDetectionMiddleware = /* @__PURE__ */ __name((options) => (next) => async (args) => {
34
34
  const { request } = args;
35
- if (!import_protocol_http.HttpRequest.isInstance(request) || options.runtime !== "node" || request.headers.hasOwnProperty(TRACE_ID_HEADER_NAME)) {
35
+ if (!import_protocol_http.HttpRequest.isInstance(request) || options.runtime !== "node") {
36
+ return next(args);
37
+ }
38
+ const traceIdHeader = Object.keys(request.headers ?? {}).find((h) => h.toLowerCase() === TRACE_ID_HEADER_NAME.toLowerCase()) ?? TRACE_ID_HEADER_NAME;
39
+ if (request.headers.hasOwnProperty(traceIdHeader)) {
36
40
  return next(args);
37
41
  }
38
42
  const functionName = process.env[ENV_LAMBDA_FUNCTION_NAME];
@@ -54,9 +58,9 @@ var addRecursionDetectionMiddlewareOptions = {
54
58
  priority: "low"
55
59
  };
56
60
  var getRecursionDetectionPlugin = /* @__PURE__ */ __name((options) => ({
57
- applyToStack: (clientStack) => {
61
+ applyToStack: /* @__PURE__ */ __name((clientStack) => {
58
62
  clientStack.add(recursionDetectionMiddleware(options), addRecursionDetectionMiddlewareOptions);
59
- }
63
+ }, "applyToStack")
60
64
  }), "getRecursionDetectionPlugin");
61
65
  // Annotate the CommonJS export names for ESM import in node:
62
66
 
package/dist-es/index.js CHANGED
@@ -4,9 +4,12 @@ const ENV_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME";
4
4
  const ENV_TRACE_ID = "_X_AMZN_TRACE_ID";
5
5
  export const recursionDetectionMiddleware = (options) => (next) => async (args) => {
6
6
  const { request } = args;
7
- if (!HttpRequest.isInstance(request) ||
8
- options.runtime !== "node" ||
9
- request.headers.hasOwnProperty(TRACE_ID_HEADER_NAME)) {
7
+ if (!HttpRequest.isInstance(request) || options.runtime !== "node") {
8
+ return next(args);
9
+ }
10
+ const traceIdHeader = Object.keys(request.headers ?? {}).find((h) => h.toLowerCase() === TRACE_ID_HEADER_NAME.toLowerCase()) ??
11
+ TRACE_ID_HEADER_NAME;
12
+ if (request.headers.hasOwnProperty(traceIdHeader)) {
10
13
  return next(args);
11
14
  }
12
15
  const functionName = process.env[ENV_LAMBDA_FUNCTION_NAME];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-recursion-detection",
3
- "version": "3.734.0",
3
+ "version": "3.772.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "node ../../scripts/compilation/inline middleware-recursion-detection",