@aws-sdk/s3-presigned-post 3.171.0 → 3.179.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/createPresignedPost.js +12 -2
- package/dist-es/createPresignedPost.js +25 -13
- package/package.json +8 -7
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.179.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.178.0...v3.179.0) (2022-09-26)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **endpoint:** add package dependencies for middleware-endpoint ([#3988](https://github.com/aws/aws-sdk-js-v3/issues/3988)) ([4877469](https://github.com/aws/aws-sdk-js-v3/commit/4877469dea3ad91c2cbd7e7697bd8ba9b430a2b1))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **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))
|
|
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-presigned-post
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createPresignedPost = void 0;
|
|
4
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
5
|
+
const middleware_endpoint_1 = require("@aws-sdk/middleware-endpoint");
|
|
4
6
|
const signature_v4_1 = require("@aws-sdk/signature-v4");
|
|
5
7
|
const util_format_url_1 = require("@aws-sdk/util-format-url");
|
|
6
8
|
const util_hex_encoding_1 = require("@aws-sdk/util-hex-encoding");
|
|
7
9
|
const constants_1 = require("./constants");
|
|
8
10
|
const createPresignedPost = async (client, { Bucket, Key, Conditions = [], Fields = {}, Expires = 3600 }) => {
|
|
11
|
+
var _a, _b;
|
|
9
12
|
const { systemClockOffset, base64Encoder, utf8Decoder, sha256 } = client.config;
|
|
10
13
|
const now = new Date(Date.now() + systemClockOffset);
|
|
11
14
|
const signingDate = iso8601(now).replace(/[\-:]/g, "");
|
|
@@ -36,8 +39,15 @@ const createPresignedPost = async (client, { Bucket, Key, Conditions = [], Field
|
|
|
36
39
|
})));
|
|
37
40
|
const signingKey = await (0, signature_v4_1.getSigningKey)(sha256, clientCredentials, shortDate, clientRegion, "s3");
|
|
38
41
|
const signature = await hmac(sha256, signingKey, encodedPolicy);
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
let endpoint = await ((_b = (_a = client.config) === null || _a === void 0 ? void 0 : _a.endpoint) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
43
|
+
let isEndpointV2 = false;
|
|
44
|
+
if (!endpoint) {
|
|
45
|
+
isEndpointV2 = true;
|
|
46
|
+
endpoint = (0, middleware_endpoint_1.toEndpointV1)(await (0, middleware_endpoint_1.getEndpointFromInstructions)({ Bucket, Key }, client_s3_1.PutObjectCommand, {
|
|
47
|
+
...client.config,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
if (endpoint && !client.config.isCustomEndpoint && !isEndpointV2) {
|
|
41
51
|
endpoint.path = `/${Bucket}`;
|
|
42
52
|
}
|
|
43
53
|
return {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { __assign, __awaiter, __generator, __read, __spreadArray } from "tslib";
|
|
2
|
+
import { PutObjectCommand } from "@aws-sdk/client-s3";
|
|
3
|
+
import { getEndpointFromInstructions, toEndpointV1, } from "@aws-sdk/middleware-endpoint";
|
|
2
4
|
import { createScope, getSigningKey } from "@aws-sdk/signature-v4";
|
|
3
5
|
import { formatUrl } from "@aws-sdk/util-format-url";
|
|
4
6
|
import { toHex } from "@aws-sdk/util-hex-encoding";
|
|
@@ -6,10 +8,11 @@ import { ALGORITHM_IDENTIFIER, ALGORITHM_QUERY_PARAM, AMZ_DATE_QUERY_PARAM, CRED
|
|
|
6
8
|
export var createPresignedPost = function (client, _a) {
|
|
7
9
|
var Bucket = _a.Bucket, Key = _a.Key, _b = _a.Conditions, Conditions = _b === void 0 ? [] : _b, _c = _a.Fields, Fields = _c === void 0 ? {} : _c, _d = _a.Expires, Expires = _d === void 0 ? 3600 : _d;
|
|
8
10
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
9
|
-
var _e, systemClockOffset, base64Encoder, utf8Decoder, sha256, now, signingDate, shortDate, clientRegion, credentialScope, clientCredentials, credential, fields, expiration, conditions, encodedPolicy, signingKey, signature, endpoint;
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
var _e, systemClockOffset, base64Encoder, utf8Decoder, sha256, now, signingDate, shortDate, clientRegion, credentialScope, clientCredentials, credential, fields, expiration, conditions, encodedPolicy, signingKey, signature, endpoint, isEndpointV2, _f;
|
|
12
|
+
var _g, _h, _j;
|
|
13
|
+
var _k, _l;
|
|
14
|
+
return __generator(this, function (_m) {
|
|
15
|
+
switch (_m.label) {
|
|
13
16
|
case 0:
|
|
14
17
|
_e = client.config, systemClockOffset = _e.systemClockOffset, base64Encoder = _e.base64Encoder, utf8Decoder = _e.utf8Decoder, sha256 = _e.sha256;
|
|
15
18
|
now = new Date(Date.now() + systemClockOffset);
|
|
@@ -17,13 +20,13 @@ export var createPresignedPost = function (client, _a) {
|
|
|
17
20
|
shortDate = signingDate.slice(0, 8);
|
|
18
21
|
return [4, client.config.region()];
|
|
19
22
|
case 1:
|
|
20
|
-
clientRegion =
|
|
23
|
+
clientRegion = _m.sent();
|
|
21
24
|
credentialScope = createScope(shortDate, clientRegion, "s3");
|
|
22
25
|
return [4, client.config.credentials()];
|
|
23
26
|
case 2:
|
|
24
|
-
clientCredentials =
|
|
27
|
+
clientCredentials = _m.sent();
|
|
25
28
|
credential = "".concat(clientCredentials.accessKeyId, "/").concat(credentialScope);
|
|
26
|
-
fields = __assign(__assign(__assign({}, Fields), (
|
|
29
|
+
fields = __assign(__assign(__assign({}, Fields), (_g = { bucket: Bucket }, _g[ALGORITHM_QUERY_PARAM] = ALGORITHM_IDENTIFIER, _g[CREDENTIAL_QUERY_PARAM] = credential, _g[AMZ_DATE_QUERY_PARAM] = signingDate, _g)), (clientCredentials.sessionToken ? (_h = {}, _h[TOKEN_QUERY_PARAM] = clientCredentials.sessionToken, _h) : {}));
|
|
27
30
|
expiration = new Date(now.valueOf() + Expires * 1000);
|
|
28
31
|
conditions = __spreadArray(__spreadArray(__spreadArray([], __read(Conditions), false), __read(Object.entries(fields).map(function (_a) {
|
|
29
32
|
var _b;
|
|
@@ -40,19 +43,28 @@ export var createPresignedPost = function (client, _a) {
|
|
|
40
43
|
})));
|
|
41
44
|
return [4, getSigningKey(sha256, clientCredentials, shortDate, clientRegion, "s3")];
|
|
42
45
|
case 3:
|
|
43
|
-
signingKey =
|
|
46
|
+
signingKey = _m.sent();
|
|
44
47
|
return [4, hmac(sha256, signingKey, encodedPolicy)];
|
|
45
48
|
case 4:
|
|
46
|
-
signature =
|
|
47
|
-
return [4, client.config.endpoint()];
|
|
49
|
+
signature = _m.sent();
|
|
50
|
+
return [4, ((_l = (_k = client.config) === null || _k === void 0 ? void 0 : _k.endpoint) === null || _l === void 0 ? void 0 : _l.call(_k))];
|
|
48
51
|
case 5:
|
|
49
|
-
endpoint =
|
|
50
|
-
|
|
52
|
+
endpoint = _m.sent();
|
|
53
|
+
isEndpointV2 = false;
|
|
54
|
+
if (!!endpoint) return [3, 7];
|
|
55
|
+
isEndpointV2 = true;
|
|
56
|
+
_f = toEndpointV1;
|
|
57
|
+
return [4, getEndpointFromInstructions({ Bucket: Bucket, Key: Key }, PutObjectCommand, __assign({}, client.config))];
|
|
58
|
+
case 6:
|
|
59
|
+
endpoint = _f.apply(void 0, [_m.sent()]);
|
|
60
|
+
_m.label = 7;
|
|
61
|
+
case 7:
|
|
62
|
+
if (endpoint && !client.config.isCustomEndpoint && !isEndpointV2) {
|
|
51
63
|
endpoint.path = "/".concat(Bucket);
|
|
52
64
|
}
|
|
53
65
|
return [2, {
|
|
54
66
|
url: formatUrl(endpoint),
|
|
55
|
-
fields: __assign(__assign({}, fields), (
|
|
67
|
+
fields: __assign(__assign({}, fields), (_j = { key: Key, Policy: encodedPolicy }, _j[SIGNATURE_QUERY_PARAM] = toHex(signature), _j)),
|
|
56
68
|
}];
|
|
57
69
|
}
|
|
58
70
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/s3-presigned-post",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.179.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,16 +20,17 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/
|
|
24
|
-
"@aws-sdk/
|
|
25
|
-
"@aws-sdk/
|
|
23
|
+
"@aws-sdk/middleware-endpoint": "3.179.0",
|
|
24
|
+
"@aws-sdk/signature-v4": "3.178.0",
|
|
25
|
+
"@aws-sdk/types": "3.178.0",
|
|
26
|
+
"@aws-sdk/util-format-url": "3.178.0",
|
|
26
27
|
"@aws-sdk/util-hex-encoding": "3.170.0",
|
|
27
28
|
"tslib": "^2.3.1"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@aws-sdk/client-s3": "3.
|
|
31
|
-
"@aws-sdk/hash-node": "3.
|
|
32
|
-
"@aws-sdk/protocol-http": "3.
|
|
31
|
+
"@aws-sdk/client-s3": "3.179.0",
|
|
32
|
+
"@aws-sdk/hash-node": "3.178.0",
|
|
33
|
+
"@aws-sdk/protocol-http": "3.178.0",
|
|
33
34
|
"@tsconfig/recommended": "1.0.1",
|
|
34
35
|
"@types/node": "^12.0.2",
|
|
35
36
|
"concurrently": "7.0.0",
|