@trivikr-test/middleware-signing
Advanced tools
Comparing version 3.170.0-es2016 to 3.170.0-es2017
@@ -1,2 +0,1 @@ | ||
import { __awaiter } from "tslib"; | ||
import { memoize } from "@trivikr-test/property-provider"; | ||
@@ -16,11 +15,9 @@ import { SignatureV4 } from "@trivikr-test/signature-v4"; | ||
signer = () => normalizeProvider(input.region)() | ||
.then((region) => __awaiter(void 0, void 0, void 0, function* () { | ||
return [ | ||
(yield input.regionInfoProvider(region, { | ||
useFipsEndpoint: yield input.useFipsEndpoint(), | ||
useDualstackEndpoint: yield input.useDualstackEndpoint(), | ||
})) || {}, | ||
region, | ||
]; | ||
})) | ||
.then(async (region) => [ | ||
(await input.regionInfoProvider(region, { | ||
useFipsEndpoint: await input.useFipsEndpoint(), | ||
useDualstackEndpoint: await input.useDualstackEndpoint(), | ||
})) || {}, | ||
region, | ||
]) | ||
.then(([regionInfo, region]) => { | ||
@@ -27,0 +24,0 @@ const { signingRegion, signingService } = regionInfo; |
@@ -1,28 +0,25 @@ | ||
import { __awaiter } from "tslib"; | ||
import { HttpRequest, HttpResponse } from "@trivikr-test/protocol-http"; | ||
import { getSkewCorrectedDate } from "./utils/getSkewCorrectedDate"; | ||
import { getUpdatedSystemClockOffset } from "./utils/getUpdatedSystemClockOffset"; | ||
export const awsAuthMiddleware = (options) => (next, context) => function (args) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!HttpRequest.isInstance(args.request)) | ||
return next(args); | ||
const signer = yield options.signer(); | ||
const output = yield next(Object.assign(Object.assign({}, args), { request: yield signer.sign(args.request, { | ||
signingDate: getSkewCorrectedDate(options.systemClockOffset), | ||
signingRegion: context["signing_region"], | ||
signingService: context["signing_service"], | ||
}) })).catch((error) => { | ||
var _a; | ||
const serverTime = (_a = error.ServerTime) !== null && _a !== void 0 ? _a : getDateHeader(error.$response); | ||
if (serverTime) { | ||
options.systemClockOffset = getUpdatedSystemClockOffset(serverTime, options.systemClockOffset); | ||
} | ||
throw error; | ||
}); | ||
const dateHeader = getDateHeader(output.response); | ||
if (dateHeader) { | ||
options.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, options.systemClockOffset); | ||
export const awsAuthMiddleware = (options) => (next, context) => async function (args) { | ||
if (!HttpRequest.isInstance(args.request)) | ||
return next(args); | ||
const signer = await options.signer(); | ||
const output = await next(Object.assign(Object.assign({}, args), { request: await signer.sign(args.request, { | ||
signingDate: getSkewCorrectedDate(options.systemClockOffset), | ||
signingRegion: context["signing_region"], | ||
signingService: context["signing_service"], | ||
}) })).catch((error) => { | ||
var _a; | ||
const serverTime = (_a = error.ServerTime) !== null && _a !== void 0 ? _a : getDateHeader(error.$response); | ||
if (serverTime) { | ||
options.systemClockOffset = getUpdatedSystemClockOffset(serverTime, options.systemClockOffset); | ||
} | ||
return output; | ||
throw error; | ||
}); | ||
const dateHeader = getDateHeader(output.response); | ||
if (dateHeader) { | ||
options.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, options.systemClockOffset); | ||
} | ||
return output; | ||
}; | ||
@@ -29,0 +26,0 @@ const getDateHeader = (response) => { var _a, _b, _c; return HttpResponse.isInstance(response) ? (_b = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.date) !== null && _b !== void 0 ? _b : (_c = response.headers) === null || _c === void 0 ? void 0 : _c.Date : undefined; }; |
{ | ||
"name": "@trivikr-test/middleware-signing", | ||
"version": "3.170.0-es2016", | ||
"version": "3.170.0-es2017", | ||
"scripts": { | ||
@@ -23,6 +23,6 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", | ||
"dependencies": { | ||
"@trivikr-test/property-provider": "3.170.0-es2016", | ||
"@trivikr-test/protocol-http": "3.170.0-es2016", | ||
"@trivikr-test/signature-v4": "3.170.0-es2016", | ||
"@trivikr-test/types": "3.170.0-es2016", | ||
"@trivikr-test/property-provider": "3.170.0-es2017", | ||
"@trivikr-test/protocol-http": "3.170.0-es2017", | ||
"@trivikr-test/signature-v4": "3.170.0-es2017", | ||
"@trivikr-test/types": "3.170.0-es2017", | ||
"tslib": "^2.3.1" | ||
@@ -29,0 +29,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
34065
495
+ Added@trivikr-test/is-array-buffer@3.170.0-es2017(transitive)
+ Added@trivikr-test/property-provider@3.170.0-es2017(transitive)
+ Added@trivikr-test/protocol-http@3.170.0-es2017(transitive)
+ Added@trivikr-test/signature-v4@3.170.0-es2017(transitive)
+ Added@trivikr-test/types@3.170.0-es2017(transitive)
+ Added@trivikr-test/util-hex-encoding@3.170.0-es2017(transitive)
+ Added@trivikr-test/util-middleware@3.170.0-es2017(transitive)
+ Added@trivikr-test/util-uri-escape@3.170.0-es2017(transitive)
- Removed@trivikr-test/is-array-buffer@3.170.0-es2016(transitive)
- Removed@trivikr-test/property-provider@3.170.0-es2016(transitive)
- Removed@trivikr-test/protocol-http@3.170.0-es2016(transitive)
- Removed@trivikr-test/signature-v4@3.170.0-es2016(transitive)
- Removed@trivikr-test/types@3.170.0-es2016(transitive)
- Removed@trivikr-test/util-hex-encoding@3.170.0-es2016(transitive)
- Removed@trivikr-test/util-middleware@3.170.0-es2016(transitive)
- Removed@trivikr-test/util-uri-escape@3.170.0-es2016(transitive)