@aws-sdk/middleware-recursion-detection 3.186.0 → 3.188.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/CHANGELOG.md +8 -0
- package/dist-es/index.js +24 -29
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.188.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.187.0...v3.188.0) (2022-10-13)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-sdk/middleware-recursion-detection
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [3.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @aws-sdk/middleware-recursion-detection
|
package/dist-es/index.js
CHANGED
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
1
|
import { HttpRequest } from "@aws-sdk/protocol-http";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return [2, next(__assign(__assign({}, args), { request: request }))];
|
|
24
|
-
});
|
|
25
|
-
}); };
|
|
26
|
-
};
|
|
2
|
+
const TRACE_ID_HEADER_NAME = "X-Amzn-Trace-Id";
|
|
3
|
+
const ENV_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME";
|
|
4
|
+
const ENV_TRACE_ID = "_X_AMZN_TRACE_ID";
|
|
5
|
+
export const recursionDetectionMiddleware = (options) => (next) => async (args) => {
|
|
6
|
+
const { request } = args;
|
|
7
|
+
if (!HttpRequest.isInstance(request) ||
|
|
8
|
+
options.runtime !== "node" ||
|
|
9
|
+
request.headers.hasOwnProperty(TRACE_ID_HEADER_NAME)) {
|
|
10
|
+
return next(args);
|
|
11
|
+
}
|
|
12
|
+
const functionName = process.env[ENV_LAMBDA_FUNCTION_NAME];
|
|
13
|
+
const traceId = process.env[ENV_TRACE_ID];
|
|
14
|
+
const nonEmptyString = (str) => typeof str === "string" && str.length > 0;
|
|
15
|
+
if (nonEmptyString(functionName) && nonEmptyString(traceId)) {
|
|
16
|
+
request.headers[TRACE_ID_HEADER_NAME] = traceId;
|
|
17
|
+
}
|
|
18
|
+
return next({
|
|
19
|
+
...args,
|
|
20
|
+
request,
|
|
21
|
+
});
|
|
27
22
|
};
|
|
28
|
-
export
|
|
23
|
+
export const addRecursionDetectionMiddlewareOptions = {
|
|
29
24
|
step: "build",
|
|
30
25
|
tags: ["RECURSION_DETECTION"],
|
|
31
26
|
name: "recursionDetectionMiddleware",
|
|
32
27
|
override: true,
|
|
33
28
|
priority: "low",
|
|
34
29
|
};
|
|
35
|
-
export
|
|
36
|
-
applyToStack:
|
|
30
|
+
export const getRecursionDetectionPlugin = (options) => ({
|
|
31
|
+
applyToStack: (clientStack) => {
|
|
37
32
|
clientStack.add(recursionDetectionMiddleware(options), addRecursionDetectionMiddlewareOptions);
|
|
38
33
|
},
|
|
39
|
-
});
|
|
34
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-recursion-detection",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.188.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
6
6
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/protocol-http": "3.
|
|
24
|
-
"@aws-sdk/types": "3.
|
|
23
|
+
"@aws-sdk/protocol-http": "3.188.0",
|
|
24
|
+
"@aws-sdk/types": "3.188.0",
|
|
25
25
|
"tslib": "^2.3.1"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|