@aws-sdk/middleware-signing 3.40.0 → 3.47.1

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.47.1](https://github.com/aws/aws-sdk-js-v3/compare/v3.47.0-release-test-1...v3.47.1) (2022-01-20)
7
+
8
+ **Note:** Version bump only for package @aws-sdk/middleware-signing
9
+
10
+
11
+
12
+
13
+
14
+ # [3.47.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.46.0...v3.47.0) (2022-01-15)
15
+
16
+ **Note:** Version bump only for package @aws-sdk/middleware-signing
17
+
18
+
19
+
20
+
21
+
22
+ # [3.46.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.45.0...v3.46.0) (2022-01-07)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **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))
28
+
29
+
30
+ ### Features
31
+
32
+ * **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))
33
+
34
+
35
+
36
+
37
+
38
+ # [3.45.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.44.0...v3.45.0) (2021-12-23)
39
+
40
+ **Note:** Version bump only for package @aws-sdk/middleware-signing
41
+
42
+
43
+
44
+
45
+
6
46
  # [3.40.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.39.0...v3.40.0) (2021-11-05)
7
47
 
8
48
  **Note:** Version bump only for package @aws-sdk/middleware-signing
@@ -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"],
@@ -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"],
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-signing",
3
- "version": "3.40.0",
3
+ "version": "3.47.1",
4
4
  "scripts": {
5
- "build": "yarn build:cjs && yarn build:es && yarn build:types",
5
+ "build": "concurrently '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
+ "clean": "rimraf ./dist-*",
10
11
  "test": "jest"
11
12
  },
12
13
  "main": "./dist-cjs/index.js",
@@ -17,20 +18,15 @@
17
18
  "url": "https://aws.amazon.com/javascript/"
18
19
  },
19
20
  "license": "Apache-2.0",
20
- "devDependencies": {
21
- "@types/jest": "^26.0.4",
22
- "jest": "^26.1.0",
23
- "typescript": "~4.3.5"
24
- },
25
21
  "dependencies": {
26
- "@aws-sdk/property-provider": "3.40.0",
27
- "@aws-sdk/protocol-http": "3.40.0",
28
- "@aws-sdk/signature-v4": "3.40.0",
29
- "@aws-sdk/types": "3.40.0",
22
+ "@aws-sdk/property-provider": "3.47.1",
23
+ "@aws-sdk/protocol-http": "3.47.1",
24
+ "@aws-sdk/signature-v4": "3.47.1",
25
+ "@aws-sdk/types": "3.47.1",
30
26
  "tslib": "^2.3.0"
31
27
  },
32
28
  "engines": {
33
- "node": ">= 10.0.0"
29
+ "node": ">= 12.0.0"
34
30
  },
35
31
  "typesVersions": {
36
32
  "<4.0": {