@aws-sdk/s3-request-presigner 3.171.0 → 3.173.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,17 @@
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.173.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.172.0...v3.173.0) (2022-09-16)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **s3-request-presigner:** add port to host name if missed ([#3897](https://github.com/aws/aws-sdk-js-v3/issues/3897)) ([37f574f](https://github.com/aws/aws-sdk-js-v3/commit/37f574fe33546720177866ed1c34333c68066c8e))
12
+
13
+
14
+
15
+
16
+
6
17
  # [3.171.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.170.0...v3.171.0) (2022-09-14)
7
18
 
8
19
  **Note:** Version bump only for package @aws-sdk/s3-request-presigner
@@ -13,7 +13,7 @@ class S3RequestPresigner {
13
13
  };
14
14
  this.signer = new signature_v4_multi_region_1.SignatureV4MultiRegion(resolvedOptions);
15
15
  }
16
- async presign(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) {
16
+ presign(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) {
17
17
  unsignableHeaders.add("content-type");
18
18
  Object.keys(requestToSign.headers)
19
19
  .map((header) => header.toLowerCase())
@@ -22,11 +22,11 @@ class S3RequestPresigner {
22
22
  unhoistableHeaders.add(header);
23
23
  });
24
24
  requestToSign.headers[constants_1.SHA256_HEADER] = constants_1.UNSIGNED_PAYLOAD;
25
- if (!requestToSign.headers["host"]) {
26
- requestToSign.headers.host = requestToSign.hostname;
27
- if (requestToSign.port) {
28
- requestToSign.headers.host = `${requestToSign.headers.host}:${requestToSign.port}`;
29
- }
25
+ const currentHostHeader = requestToSign.headers.host;
26
+ const port = requestToSign.port;
27
+ const expectedHostHeader = `${requestToSign.hostname}${requestToSign.port != null ? ":" + port : ""}`;
28
+ if (!currentHostHeader || (currentHostHeader === requestToSign.hostname && requestToSign.port != null)) {
29
+ requestToSign.headers.host = expectedHostHeader;
30
30
  }
31
31
  return this.signer.presign(requestToSign, {
32
32
  expiresIn: 900,
@@ -1,4 +1,4 @@
1
- import { __assign, __awaiter, __generator, __rest } from "tslib";
1
+ import { __assign, __rest } from "tslib";
2
2
  import { SignatureV4MultiRegion } from "@aws-sdk/signature-v4-multi-region";
3
3
  import { SHA256_HEADER, UNSIGNED_PAYLOAD } from "./constants";
4
4
  var S3RequestPresigner = (function () {
@@ -9,25 +9,21 @@ var S3RequestPresigner = (function () {
9
9
  S3RequestPresigner.prototype.presign = function (requestToSign, _a) {
10
10
  if (_a === void 0) { _a = {}; }
11
11
  var _b = _a.unsignableHeaders, unsignableHeaders = _b === void 0 ? new Set() : _b, _c = _a.unhoistableHeaders, unhoistableHeaders = _c === void 0 ? new Set() : _c, options = __rest(_a, ["unsignableHeaders", "unhoistableHeaders"]);
12
- return __awaiter(this, void 0, void 0, function () {
13
- return __generator(this, function (_d) {
14
- unsignableHeaders.add("content-type");
15
- Object.keys(requestToSign.headers)
16
- .map(function (header) { return header.toLowerCase(); })
17
- .filter(function (header) { return header.startsWith("x-amz-server-side-encryption"); })
18
- .forEach(function (header) {
19
- unhoistableHeaders.add(header);
20
- });
21
- requestToSign.headers[SHA256_HEADER] = UNSIGNED_PAYLOAD;
22
- if (!requestToSign.headers["host"]) {
23
- requestToSign.headers.host = requestToSign.hostname;
24
- if (requestToSign.port) {
25
- requestToSign.headers.host = "".concat(requestToSign.headers.host, ":").concat(requestToSign.port);
26
- }
27
- }
28
- return [2, this.signer.presign(requestToSign, __assign({ expiresIn: 900, unsignableHeaders: unsignableHeaders, unhoistableHeaders: unhoistableHeaders }, options))];
29
- });
12
+ unsignableHeaders.add("content-type");
13
+ Object.keys(requestToSign.headers)
14
+ .map(function (header) { return header.toLowerCase(); })
15
+ .filter(function (header) { return header.startsWith("x-amz-server-side-encryption"); })
16
+ .forEach(function (header) {
17
+ unhoistableHeaders.add(header);
30
18
  });
19
+ requestToSign.headers[SHA256_HEADER] = UNSIGNED_PAYLOAD;
20
+ var currentHostHeader = requestToSign.headers.host;
21
+ var port = requestToSign.port;
22
+ var expectedHostHeader = "".concat(requestToSign.hostname).concat(requestToSign.port != null ? ":" + port : "");
23
+ if (!currentHostHeader || (currentHostHeader === requestToSign.hostname && requestToSign.port != null)) {
24
+ requestToSign.headers.host = expectedHostHeader;
25
+ }
26
+ return this.signer.presign(requestToSign, __assign({ expiresIn: 900, unsignableHeaders: unsignableHeaders, unhoistableHeaders: unhoistableHeaders }, options));
31
27
  };
32
28
  return S3RequestPresigner;
33
29
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/s3-request-presigner",
3
- "version": "3.171.0",
3
+ "version": "3.173.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",