@aws-sdk/middleware-recursion-detection
Advanced tools
Comparing version 3.178.0 to 3.183.0
@@ -6,2 +6,10 @@ # Change Log | ||
# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03) | ||
**Note:** Version bump only for package @aws-sdk/middleware-recursion-detection | ||
# [3.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23) | ||
@@ -8,0 +16,0 @@ |
@@ -1,29 +0,24 @@ | ||
import { __assign, __awaiter, __generator } from "tslib"; | ||
import { HttpRequest } from "@aws-sdk/protocol-http"; | ||
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 }))]; | ||
}); | ||
}); }; | ||
}; | ||
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, | ||
}); | ||
}; | ||
export var addRecursionDetectionMiddlewareOptions = { | ||
export const addRecursionDetectionMiddlewareOptions = { | ||
step: "build", | ||
@@ -35,6 +30,6 @@ tags: ["RECURSION_DETECTION"], | ||
}; | ||
export var getRecursionDetectionPlugin = function (options) { return ({ | ||
applyToStack: function (clientStack) { | ||
export const getRecursionDetectionPlugin = (options) => ({ | ||
applyToStack: (clientStack) => { | ||
clientStack.add(recursionDetectionMiddleware(options), addRecursionDetectionMiddlewareOptions); | ||
}, | ||
}); }; | ||
}); |
{ | ||
"name": "@aws-sdk/middleware-recursion-detection", | ||
"version": "3.178.0", | ||
"version": "3.183.0", | ||
"scripts": { | ||
@@ -23,4 +23,4 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", | ||
"dependencies": { | ||
"@aws-sdk/protocol-http": "3.178.0", | ||
"@aws-sdk/types": "3.178.0", | ||
"@aws-sdk/protocol-http": "3.183.0", | ||
"@aws-sdk/types": "3.183.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
19866
103
+ Added@aws-sdk/protocol-http@3.183.0(transitive)
+ Added@aws-sdk/types@3.183.0(transitive)
- Removed@aws-sdk/protocol-http@3.178.0(transitive)
- Removed@aws-sdk/types@3.178.0(transitive)
Updated@aws-sdk/types@3.183.0