@aws-sdk/s3-request-presigner 3.171.0 → 3.178.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 +22 -0
- package/dist-cjs/getSignedUrl.js +15 -1
- package/dist-cjs/presigner.js +6 -6
- package/dist-es/getSignedUrl.js +20 -6
- package/dist-es/presigner.js +15 -19
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **endpoint:** endpoints 2.0 existing package changes ([#3947](https://github.com/aws/aws-sdk-js-v3/issues/3947)) ([df99fc3](https://github.com/aws/aws-sdk-js-v3/commit/df99fc33a43982e1c59000721a535f6fe77a3c23))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.173.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.172.0...v3.173.0) (2022-09-16)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **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))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
# [3.171.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.170.0...v3.171.0) (2022-09-14)
|
|
7
29
|
|
|
8
30
|
**Note:** Version bump only for package @aws-sdk/s3-request-presigner
|
package/dist-cjs/getSignedUrl.js
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSignedUrl = void 0;
|
|
4
|
+
const middleware_endpoint_1 = require("@aws-sdk/middleware-endpoint");
|
|
4
5
|
const protocol_http_1 = require("@aws-sdk/protocol-http");
|
|
5
6
|
const util_format_url_1 = require("@aws-sdk/util-format-url");
|
|
6
7
|
const presigner_1 = require("./presigner");
|
|
7
8
|
const getSignedUrl = async (client, command, options = {}) => {
|
|
8
|
-
|
|
9
|
+
var _a, _b;
|
|
10
|
+
let s3Presigner;
|
|
11
|
+
if (typeof client.config.endpointProvider === "function") {
|
|
12
|
+
const endpointV2 = await (0, middleware_endpoint_1.getEndpointFromInstructions)(command.input, command.constructor, client.config);
|
|
13
|
+
const authScheme = (_b = (_a = endpointV2.properties) === null || _a === void 0 ? void 0 : _a.authSchemes) === null || _b === void 0 ? void 0 : _b[0];
|
|
14
|
+
s3Presigner = new presigner_1.S3RequestPresigner({
|
|
15
|
+
...client.config,
|
|
16
|
+
signingName: authScheme === null || authScheme === void 0 ? void 0 : authScheme.signingName,
|
|
17
|
+
region: async () => authScheme === null || authScheme === void 0 ? void 0 : authScheme.signingScope,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
s3Presigner = new presigner_1.S3RequestPresigner(client.config);
|
|
22
|
+
}
|
|
9
23
|
const presignInterceptMiddleware = (next, context) => async (args) => {
|
|
10
24
|
var _a, _b;
|
|
11
25
|
const { request } = args;
|
package/dist-cjs/presigner.js
CHANGED
|
@@ -13,7 +13,7 @@ class S3RequestPresigner {
|
|
|
13
13
|
};
|
|
14
14
|
this.signer = new signature_v4_multi_region_1.SignatureV4MultiRegion(resolvedOptions);
|
|
15
15
|
}
|
|
16
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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,
|
package/dist-es/getSignedUrl.js
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
|
+
import { getEndpointFromInstructions } from "@aws-sdk/middleware-endpoint";
|
|
2
3
|
import { HttpRequest } from "@aws-sdk/protocol-http";
|
|
3
4
|
import { formatUrl } from "@aws-sdk/util-format-url";
|
|
4
5
|
import { S3RequestPresigner } from "./presigner";
|
|
5
6
|
export var getSignedUrl = function (client, command, options) {
|
|
6
7
|
if (options === void 0) { options = {}; }
|
|
7
8
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
8
|
-
var s3Presigner, presignInterceptMiddleware, middlewareName, clientStack, handler, output, presigned;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
var s3Presigner, endpointV2, authScheme_1, presignInterceptMiddleware, middlewareName, clientStack, handler, output, presigned;
|
|
10
|
+
var _a, _b;
|
|
11
|
+
return __generator(this, function (_c) {
|
|
12
|
+
switch (_c.label) {
|
|
11
13
|
case 0:
|
|
12
|
-
|
|
14
|
+
if (!(typeof client.config.endpointProvider === "function")) return [3, 2];
|
|
15
|
+
return [4, getEndpointFromInstructions(command.input, command.constructor, client.config)];
|
|
16
|
+
case 1:
|
|
17
|
+
endpointV2 = _c.sent();
|
|
18
|
+
authScheme_1 = (_b = (_a = endpointV2.properties) === null || _a === void 0 ? void 0 : _a.authSchemes) === null || _b === void 0 ? void 0 : _b[0];
|
|
19
|
+
s3Presigner = new S3RequestPresigner(__assign(__assign({}, client.config), { signingName: authScheme_1 === null || authScheme_1 === void 0 ? void 0 : authScheme_1.signingName, region: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
20
|
+
return [2, authScheme_1 === null || authScheme_1 === void 0 ? void 0 : authScheme_1.signingScope];
|
|
21
|
+
}); }); } }));
|
|
22
|
+
return [3, 3];
|
|
23
|
+
case 2:
|
|
24
|
+
s3Presigner = new S3RequestPresigner(client.config);
|
|
25
|
+
_c.label = 3;
|
|
26
|
+
case 3:
|
|
13
27
|
presignInterceptMiddleware = function (next, context) { return function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
14
28
|
var request, presigned;
|
|
15
29
|
var _a, _b;
|
|
@@ -46,8 +60,8 @@ export var getSignedUrl = function (client, command, options) {
|
|
|
46
60
|
});
|
|
47
61
|
handler = command.resolveMiddleware(clientStack, client.config, {});
|
|
48
62
|
return [4, handler({ input: command.input })];
|
|
49
|
-
case
|
|
50
|
-
output = (
|
|
63
|
+
case 4:
|
|
64
|
+
output = (_c.sent()).output;
|
|
51
65
|
presigned = output.presigned;
|
|
52
66
|
return [2, formatUrl(presigned)];
|
|
53
67
|
}
|
package/dist-es/presigner.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __assign,
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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.
|
|
3
|
+
"version": "3.178.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",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/middleware-sdk-s3": "3.
|
|
24
|
-
"@aws-sdk/protocol-http": "3.
|
|
25
|
-
"@aws-sdk/signature-v4-multi-region": "3.
|
|
26
|
-
"@aws-sdk/smithy-client": "3.
|
|
27
|
-
"@aws-sdk/types": "3.
|
|
28
|
-
"@aws-sdk/util-create-request": "3.
|
|
29
|
-
"@aws-sdk/util-format-url": "3.
|
|
23
|
+
"@aws-sdk/middleware-sdk-s3": "3.178.0",
|
|
24
|
+
"@aws-sdk/protocol-http": "3.178.0",
|
|
25
|
+
"@aws-sdk/signature-v4-multi-region": "3.178.0",
|
|
26
|
+
"@aws-sdk/smithy-client": "3.178.0",
|
|
27
|
+
"@aws-sdk/types": "3.178.0",
|
|
28
|
+
"@aws-sdk/util-create-request": "3.178.0",
|
|
29
|
+
"@aws-sdk/util-format-url": "3.178.0",
|
|
30
30
|
"tslib": "^2.3.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@aws-sdk/client-s3": "3.
|
|
34
|
-
"@aws-sdk/hash-node": "3.
|
|
33
|
+
"@aws-sdk/client-s3": "3.178.0",
|
|
34
|
+
"@aws-sdk/hash-node": "3.178.0",
|
|
35
35
|
"@tsconfig/recommended": "1.0.1",
|
|
36
36
|
"@types/node": "^12.0.2",
|
|
37
37
|
"concurrently": "7.0.0",
|