@aws-sdk/middleware-signing 3.38.0 → 3.46.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 CHANGED
@@ -3,6 +3,46 @@
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.46.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.45.0...v3.46.0) (2022-01-07)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **middleware-signing:** correct clock skew from error response ([#3133](https://github.com/aws/aws-sdk-js-v3/issues/3133)) ([7a207a9](https://github.com/aws/aws-sdk-js-v3/commit/7a207a9d3173631f62f8b90ee1fbd7f68342133a))
12
+
13
+
14
+ ### Features
15
+
16
+ * **packages:** end support for Node.js 10.x ([#3141](https://github.com/aws/aws-sdk-js-v3/issues/3141)) ([1a62865](https://github.com/aws/aws-sdk-js-v3/commit/1a6286513f7cdb556708845c512861c5f92eb883))
17
+
18
+
19
+
20
+
21
+
22
+ # [3.45.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.44.0...v3.45.0) (2021-12-23)
23
+
24
+ **Note:** Version bump only for package @aws-sdk/middleware-signing
25
+
26
+
27
+
28
+
29
+
30
+ # [3.40.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.39.0...v3.40.0) (2021-11-05)
31
+
32
+ **Note:** Version bump only for package @aws-sdk/middleware-signing
33
+
34
+
35
+
36
+
37
+
38
+ # [3.39.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.38.0...v3.39.0) (2021-10-29)
39
+
40
+ **Note:** Version bump only for package @aws-sdk/middleware-signing
41
+
42
+
43
+
44
+
45
+
6
46
  # [3.38.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.37.0...v3.38.0) (2021-10-22)
7
47
 
8
48
  **Note:** Version bump only for package @aws-sdk/middleware-signing
@@ -15,7 +15,13 @@ const resolveAwsAuthConfig = (input) => {
15
15
  }
16
16
  else {
17
17
  signer = () => normalizeProvider(input.region)()
18
- .then(async (region) => [(await input.regionInfoProvider(region)) || {}, region])
18
+ .then(async (region) => [
19
+ (await input.regionInfoProvider(region, {
20
+ useFipsEndpoint: await input.useFipsEndpoint(),
21
+ useDualstackEndpoint: await input.useDualstackEndpoint(),
22
+ })) || {},
23
+ region,
24
+ ])
19
25
  .then(([regionInfo, region]) => {
20
26
  const { signingRegion, signingService } = regionInfo;
21
27
  input.signingRegion = input.signingRegion || signingRegion || region;
@@ -16,19 +16,21 @@ const awsAuthMiddleware = (options) => (next, context) => async function (args)
16
16
  signingService: context["signing_service"],
17
17
  }),
18
18
  }).catch((error) => {
19
- if (error.ServerTime) {
20
- options.systemClockOffset = getUpdatedSystemClockOffset_1.getUpdatedSystemClockOffset(error.ServerTime, options.systemClockOffset);
19
+ var _a;
20
+ const serverTime = (_a = error.ServerTime) !== null && _a !== void 0 ? _a : getDateHeader(error.$response);
21
+ if (serverTime) {
22
+ options.systemClockOffset = getUpdatedSystemClockOffset_1.getUpdatedSystemClockOffset(serverTime, options.systemClockOffset);
21
23
  }
22
24
  throw error;
23
25
  });
24
- const { headers } = output.response;
25
- const dateHeader = headers && (headers.date || headers.Date);
26
+ const dateHeader = getDateHeader(output.response);
26
27
  if (dateHeader) {
27
28
  options.systemClockOffset = getUpdatedSystemClockOffset_1.getUpdatedSystemClockOffset(dateHeader, options.systemClockOffset);
28
29
  }
29
30
  return output;
30
31
  };
31
32
  exports.awsAuthMiddleware = awsAuthMiddleware;
33
+ const getDateHeader = (response) => { var _a, _b, _c; return protocol_http_1.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; };
32
34
  exports.awsAuthMiddlewareOptions = {
33
35
  name: "awsAuthMiddleware",
34
36
  tags: ["SIGNATURE", "AWSAUTH"],
@@ -14,12 +14,28 @@ export var resolveAwsAuthConfig = function (input) {
14
14
  else {
15
15
  signer = function () {
16
16
  return normalizeProvider(input.region)()
17
- .then(function (region) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
18
- switch (_a.label) {
19
- case 0: return [4, input.regionInfoProvider(region)];
20
- case 1: return [2, [(_a.sent()) || {}, region]];
21
- }
22
- }); }); })
17
+ .then(function (region) { return __awaiter(void 0, void 0, void 0, function () {
18
+ var _a, _b, _c;
19
+ var _d;
20
+ return __generator(this, function (_e) {
21
+ switch (_e.label) {
22
+ case 0:
23
+ _b = (_a = input).regionInfoProvider;
24
+ _c = [region];
25
+ _d = {};
26
+ return [4, input.useFipsEndpoint()];
27
+ case 1:
28
+ _d.useFipsEndpoint = _e.sent();
29
+ return [4, input.useDualstackEndpoint()];
30
+ case 2: return [4, _b.apply(_a, _c.concat([(_d.useDualstackEndpoint = _e.sent(),
31
+ _d)]))];
32
+ case 3: return [2, [
33
+ (_e.sent()) || {},
34
+ region
35
+ ]];
36
+ }
37
+ });
38
+ }); })
23
39
  .then(function (_a) {
24
40
  var _b = __read(_a, 2), regionInfo = _b[0], region = _b[1];
25
41
  var signingRegion = regionInfo.signingRegion, signingService = regionInfo.signingService;
@@ -1,12 +1,12 @@
1
1
  import { __assign, __awaiter, __generator } from "tslib";
2
- import { HttpRequest } from "@aws-sdk/protocol-http";
2
+ import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
3
3
  import { getSkewCorrectedDate } from "./utils/getSkewCorrectedDate";
4
4
  import { getUpdatedSystemClockOffset } from "./utils/getUpdatedSystemClockOffset";
5
5
  export var awsAuthMiddleware = function (options) {
6
6
  return function (next, context) {
7
7
  return function (args) {
8
8
  return __awaiter(this, void 0, void 0, function () {
9
- var signer, output, _a, _b, headers, dateHeader;
9
+ var signer, output, _a, _b, dateHeader;
10
10
  var _c;
11
11
  return __generator(this, function (_d) {
12
12
  switch (_d.label) {
@@ -25,15 +25,16 @@ export var awsAuthMiddleware = function (options) {
25
25
  signingService: context["signing_service"],
26
26
  })];
27
27
  case 2: return [4, _a.apply(void 0, [__assign.apply(void 0, _b.concat([(_c.request = _d.sent(), _c)]))]).catch(function (error) {
28
- if (error.ServerTime) {
29
- options.systemClockOffset = getUpdatedSystemClockOffset(error.ServerTime, options.systemClockOffset);
28
+ var _a;
29
+ var serverTime = (_a = error.ServerTime) !== null && _a !== void 0 ? _a : getDateHeader(error.$response);
30
+ if (serverTime) {
31
+ options.systemClockOffset = getUpdatedSystemClockOffset(serverTime, options.systemClockOffset);
30
32
  }
31
33
  throw error;
32
34
  })];
33
35
  case 3:
34
36
  output = _d.sent();
35
- headers = output.response.headers;
36
- dateHeader = headers && (headers.date || headers.Date);
37
+ dateHeader = getDateHeader(output.response);
37
38
  if (dateHeader) {
38
39
  options.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, options.systemClockOffset);
39
40
  }
@@ -44,6 +45,7 @@ export var awsAuthMiddleware = function (options) {
44
45
  };
45
46
  };
46
47
  };
48
+ var getDateHeader = function (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; };
47
49
  export var awsAuthMiddlewareOptions = {
48
50
  name: "awsAuthMiddleware",
49
51
  tags: ["SIGNATURE", "AWSAUTH"],
@@ -54,6 +54,8 @@ interface PreviouslyResolved {
54
54
  signingName?: string;
55
55
  serviceId: string;
56
56
  sha256: HashConstructor;
57
+ useFipsEndpoint: Provider<boolean>;
58
+ useDualstackEndpoint: Provider<boolean>;
57
59
  }
58
60
  interface SigV4PreviouslyResolved {
59
61
  credentialDefaultProvider: (input: any) => Provider<Credentials>;
@@ -31,6 +31,8 @@ interface PreviouslyResolved {
31
31
  signingName?: string;
32
32
  serviceId: string;
33
33
  sha256: HashConstructor;
34
+ useFipsEndpoint: Provider<boolean>;
35
+ useDualstackEndpoint: Provider<boolean>;
34
36
  }
35
37
  interface SigV4PreviouslyResolved {
36
38
  credentialDefaultProvider: (input: any) => Provider<Credentials>;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-signing",
3
- "version": "3.38.0",
3
+ "version": "3.46.0",
4
4
  "scripts": {
5
5
  "build": "yarn build:cjs && yarn build:es && yarn build:types",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",
7
7
  "build:es": "tsc -p tsconfig.es.json",
8
8
  "build:types": "tsc -p tsconfig.types.json",
9
- "downlevel-dts": "downlevel-dts dist-types dist-types/ts3.4",
9
+ "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
10
10
  "test": "jest"
11
11
  },
12
12
  "main": "./dist-cjs/index.js",
@@ -17,20 +17,15 @@
17
17
  "url": "https://aws.amazon.com/javascript/"
18
18
  },
19
19
  "license": "Apache-2.0",
20
- "devDependencies": {
21
- "@types/jest": "^26.0.4",
22
- "jest": "^26.1.0",
23
- "typescript": "~4.3.5"
24
- },
25
20
  "dependencies": {
26
- "@aws-sdk/property-provider": "3.38.0",
27
- "@aws-sdk/protocol-http": "3.38.0",
28
- "@aws-sdk/signature-v4": "3.38.0",
29
- "@aws-sdk/types": "3.38.0",
21
+ "@aws-sdk/property-provider": "3.46.0",
22
+ "@aws-sdk/protocol-http": "3.46.0",
23
+ "@aws-sdk/signature-v4": "3.46.0",
24
+ "@aws-sdk/types": "3.46.0",
30
25
  "tslib": "^2.3.0"
31
26
  },
32
27
  "engines": {
33
- "node": ">= 10.0.0"
28
+ "node": ">= 12.0.0"
34
29
  },
35
30
  "typesVersions": {
36
31
  "<4.0": {