@aws-sdk/middleware-recursion-detection
Advanced tools
Comparing version 3.183.0 to 3.186.0
@@ -6,2 +6,10 @@ # Change Log | ||
# [3.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06) | ||
**Note:** Version bump only for package @aws-sdk/middleware-recursion-detection | ||
# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03) | ||
@@ -8,0 +16,0 @@ |
@@ -0,24 +1,29 @@ | ||
import { __assign, __awaiter, __generator } from "tslib"; | ||
import { HttpRequest } from "@aws-sdk/protocol-http"; | ||
const TRACE_ID_HEADER_NAME = "X-Amzn-Trace-Id"; | ||
const ENV_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME"; | ||
const ENV_TRACE_ID = "_X_AMZN_TRACE_ID"; | ||
export const recursionDetectionMiddleware = (options) => (next) => async (args) => { | ||
const { request } = args; | ||
if (!HttpRequest.isInstance(request) || | ||
options.runtime !== "node" || | ||
request.headers.hasOwnProperty(TRACE_ID_HEADER_NAME)) { | ||
return next(args); | ||
} | ||
const functionName = process.env[ENV_LAMBDA_FUNCTION_NAME]; | ||
const traceId = process.env[ENV_TRACE_ID]; | ||
const nonEmptyString = (str) => typeof str === "string" && str.length > 0; | ||
if (nonEmptyString(functionName) && nonEmptyString(traceId)) { | ||
request.headers[TRACE_ID_HEADER_NAME] = traceId; | ||
} | ||
return next({ | ||
...args, | ||
request, | ||
}); | ||
var TRACE_ID_HEADER_NAME = "X-Amzn-Trace-Id"; | ||
var ENV_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME"; | ||
var ENV_TRACE_ID = "_X_AMZN_TRACE_ID"; | ||
export var recursionDetectionMiddleware = function (options) { | ||
return function (next) { | ||
return function (args) { return __awaiter(void 0, void 0, void 0, function () { | ||
var request, functionName, traceId, nonEmptyString; | ||
return __generator(this, function (_a) { | ||
request = args.request; | ||
if (!HttpRequest.isInstance(request) || | ||
options.runtime !== "node" || | ||
request.headers.hasOwnProperty(TRACE_ID_HEADER_NAME)) { | ||
return [2, next(args)]; | ||
} | ||
functionName = process.env[ENV_LAMBDA_FUNCTION_NAME]; | ||
traceId = process.env[ENV_TRACE_ID]; | ||
nonEmptyString = function (str) { return typeof str === "string" && str.length > 0; }; | ||
if (nonEmptyString(functionName) && nonEmptyString(traceId)) { | ||
request.headers[TRACE_ID_HEADER_NAME] = traceId; | ||
} | ||
return [2, next(__assign(__assign({}, args), { request: request }))]; | ||
}); | ||
}); }; | ||
}; | ||
}; | ||
export const addRecursionDetectionMiddlewareOptions = { | ||
export var addRecursionDetectionMiddlewareOptions = { | ||
step: "build", | ||
@@ -30,6 +35,6 @@ tags: ["RECURSION_DETECTION"], | ||
}; | ||
export const getRecursionDetectionPlugin = (options) => ({ | ||
applyToStack: (clientStack) => { | ||
export var getRecursionDetectionPlugin = function (options) { return ({ | ||
applyToStack: function (clientStack) { | ||
clientStack.add(recursionDetectionMiddleware(options), addRecursionDetectionMiddlewareOptions); | ||
}, | ||
}); | ||
}); }; |
{ | ||
"name": "@aws-sdk/middleware-recursion-detection", | ||
"version": "3.183.0", | ||
"version": "3.186.0", | ||
"scripts": { | ||
@@ -23,4 +23,4 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", | ||
"dependencies": { | ||
"@aws-sdk/protocol-http": "3.183.0", | ||
"@aws-sdk/types": "3.183.0", | ||
"@aws-sdk/protocol-http": "3.186.0", | ||
"@aws-sdk/types": "3.186.0", | ||
"tslib": "^2.3.1" | ||
@@ -27,0 +27,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20538
108
+ Added@aws-sdk/protocol-http@3.186.0(transitive)
+ Added@aws-sdk/types@3.186.0(transitive)
- Removed@aws-sdk/protocol-http@3.183.0(transitive)
- Removed@aws-sdk/types@3.183.0(transitive)
Updated@aws-sdk/types@3.186.0