@aws-sdk/middleware-sdk-s3 3.186.0 → 3.190.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 +16 -0
- package/dist-es/check-content-length-header.js +18 -26
- package/dist-es/configuration.js +6 -5
- package/dist-es/throw-200-exceptions.js +26 -45
- package/dist-es/validate-bucket-name.js +12 -19
- package/dist-es/write-get-object-response-endpoint.js +27 -40
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.190.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.189.0...v3.190.0) (2022-10-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-sdk/middleware-sdk-s3
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.188.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.187.0...v3.188.0) (2022-10-13)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @aws-sdk/middleware-sdk-s3
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [3.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @aws-sdk/middleware-sdk-s3
|
|
@@ -1,38 +1,30 @@
|
|
|
1
|
-
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
1
|
import { HttpRequest } from "@aws-sdk/protocol-http";
|
|
3
|
-
|
|
2
|
+
const CONTENT_LENGTH_HEADER = "content-length";
|
|
4
3
|
export function checkContentLengthHeader() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (HttpRequest.isInstance(request)) {
|
|
13
|
-
if (!request.headers[CONTENT_LENGTH_HEADER]) {
|
|
14
|
-
message = "Are you using a Stream of unknown length as the Body of a PutObject request? Consider using Upload instead from @aws-sdk/lib-storage.";
|
|
15
|
-
if (typeof ((_a = context === null || context === void 0 ? void 0 : context.logger) === null || _a === void 0 ? void 0 : _a.warn) === "function") {
|
|
16
|
-
context.logger.warn(message);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
console.warn(message);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
4
|
+
return (next, context) => async (args) => {
|
|
5
|
+
const { request } = args;
|
|
6
|
+
if (HttpRequest.isInstance(request)) {
|
|
7
|
+
if (!request.headers[CONTENT_LENGTH_HEADER]) {
|
|
8
|
+
const message = `Are you using a Stream of unknown length as the Body of a PutObject request? Consider using Upload instead from @aws-sdk/lib-storage.`;
|
|
9
|
+
if (typeof context?.logger?.warn === "function") {
|
|
10
|
+
context.logger.warn(message);
|
|
22
11
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
else {
|
|
13
|
+
console.warn(message);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return next({ ...args });
|
|
26
18
|
};
|
|
27
19
|
}
|
|
28
|
-
export
|
|
20
|
+
export const checkContentLengthHeaderMiddlewareOptions = {
|
|
29
21
|
step: "finalizeRequest",
|
|
30
22
|
tags: ["CHECK_CONTENT_LENGTH_HEADER"],
|
|
31
23
|
name: "getCheckContentLengthHeaderPlugin",
|
|
32
24
|
override: true,
|
|
33
25
|
};
|
|
34
|
-
export
|
|
35
|
-
applyToStack:
|
|
26
|
+
export const getCheckContentLengthHeaderPlugin = (unused) => ({
|
|
27
|
+
applyToStack: (clientStack) => {
|
|
36
28
|
clientStack.add(checkContentLengthHeader(), checkContentLengthHeaderMiddlewareOptions);
|
|
37
29
|
},
|
|
38
|
-
});
|
|
30
|
+
});
|
package/dist-es/configuration.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export const resolveS3Config = (input) => ({
|
|
2
|
+
...input,
|
|
3
|
+
forcePathStyle: input.forcePathStyle ?? false,
|
|
4
|
+
useAccelerateEndpoint: input.useAccelerateEndpoint ?? false,
|
|
5
|
+
disableMultiregionAccessPoints: input.disableMultiregionAccessPoints ?? false,
|
|
6
|
+
});
|
|
@@ -1,60 +1,41 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
1
|
import { HttpResponse } from "@aws-sdk/protocol-http";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
bodyString = _a.sent();
|
|
24
|
-
if (bodyBytes.length === 0) {
|
|
25
|
-
err = new Error("S3 aborted request");
|
|
26
|
-
err.name = "InternalError";
|
|
27
|
-
throw err;
|
|
28
|
-
}
|
|
29
|
-
if (bodyString && bodyString.match("<Error>")) {
|
|
30
|
-
response.statusCode = 400;
|
|
31
|
-
}
|
|
32
|
-
response.body = bodyBytes;
|
|
33
|
-
return [2, result];
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}); };
|
|
37
|
-
};
|
|
2
|
+
export const throw200ExceptionsMiddleware = (config) => (next) => async (args) => {
|
|
3
|
+
const result = await next(args);
|
|
4
|
+
const { response } = result;
|
|
5
|
+
if (!HttpResponse.isInstance(response))
|
|
6
|
+
return result;
|
|
7
|
+
const { statusCode, body } = response;
|
|
8
|
+
if (statusCode < 200 || statusCode >= 300)
|
|
9
|
+
return result;
|
|
10
|
+
const bodyBytes = await collectBody(body, config);
|
|
11
|
+
const bodyString = await collectBodyString(bodyBytes, config);
|
|
12
|
+
if (bodyBytes.length === 0) {
|
|
13
|
+
const err = new Error("S3 aborted request");
|
|
14
|
+
err.name = "InternalError";
|
|
15
|
+
throw err;
|
|
16
|
+
}
|
|
17
|
+
if (bodyString && bodyString.match("<Error>")) {
|
|
18
|
+
response.statusCode = 400;
|
|
19
|
+
}
|
|
20
|
+
response.body = bodyBytes;
|
|
21
|
+
return result;
|
|
38
22
|
};
|
|
39
|
-
|
|
40
|
-
if (streamBody === void 0) { streamBody = new Uint8Array(); }
|
|
23
|
+
const collectBody = (streamBody = new Uint8Array(), context) => {
|
|
41
24
|
if (streamBody instanceof Uint8Array) {
|
|
42
25
|
return Promise.resolve(streamBody);
|
|
43
26
|
}
|
|
44
27
|
return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
|
|
45
28
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
49
|
-
export var throw200ExceptionsMiddlewareOptions = {
|
|
29
|
+
const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
|
|
30
|
+
export const throw200ExceptionsMiddlewareOptions = {
|
|
50
31
|
relation: "after",
|
|
51
32
|
toMiddleware: "deserializerMiddleware",
|
|
52
33
|
tags: ["THROW_200_EXCEPTIONS", "S3"],
|
|
53
34
|
name: "throw200ExceptionsMiddleware",
|
|
54
35
|
override: true,
|
|
55
36
|
};
|
|
56
|
-
export
|
|
57
|
-
applyToStack:
|
|
37
|
+
export const getThrow200ExceptionsPlugin = (config) => ({
|
|
38
|
+
applyToStack: (clientStack) => {
|
|
58
39
|
clientStack.addRelativeTo(throw200ExceptionsMiddleware(config), throw200ExceptionsMiddlewareOptions);
|
|
59
40
|
},
|
|
60
|
-
});
|
|
41
|
+
});
|
|
@@ -1,30 +1,23 @@
|
|
|
1
|
-
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
1
|
import { validate as validateArn } from "@aws-sdk/util-arn-parser";
|
|
3
2
|
export function validateBucketNameMiddleware() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
err.name = "InvalidBucketName";
|
|
13
|
-
throw err;
|
|
14
|
-
}
|
|
15
|
-
return [2, next(__assign({}, args))];
|
|
16
|
-
});
|
|
17
|
-
}); };
|
|
3
|
+
return (next) => async (args) => {
|
|
4
|
+
const { input: { Bucket }, } = args;
|
|
5
|
+
if (typeof Bucket === "string" && !validateArn(Bucket) && Bucket.indexOf("/") >= 0) {
|
|
6
|
+
const err = new Error(`Bucket name shouldn't contain '/', received '${Bucket}'`);
|
|
7
|
+
err.name = "InvalidBucketName";
|
|
8
|
+
throw err;
|
|
9
|
+
}
|
|
10
|
+
return next({ ...args });
|
|
18
11
|
};
|
|
19
12
|
}
|
|
20
|
-
export
|
|
13
|
+
export const validateBucketNameMiddlewareOptions = {
|
|
21
14
|
step: "initialize",
|
|
22
15
|
tags: ["VALIDATE_BUCKET_NAME"],
|
|
23
16
|
name: "validateBucketNameMiddleware",
|
|
24
17
|
override: true,
|
|
25
18
|
};
|
|
26
|
-
export
|
|
27
|
-
applyToStack:
|
|
19
|
+
export const getValidateBucketNamePlugin = (unused) => ({
|
|
20
|
+
applyToStack: (clientStack) => {
|
|
28
21
|
clientStack.add(validateBucketNameMiddleware(), validateBucketNameMiddlewareOptions);
|
|
29
22
|
},
|
|
30
|
-
});
|
|
23
|
+
});
|
|
@@ -1,51 +1,38 @@
|
|
|
1
|
-
import { __assign, __awaiter, __generator, __read } from "tslib";
|
|
2
1
|
import { getSuffixForArnEndpoint } from "@aws-sdk/middleware-bucket-endpoint";
|
|
3
2
|
import { HttpRequest } from "@aws-sdk/protocol-http";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
hostname = "".concat(input.RequestRoute, ".").concat(hostname);
|
|
28
|
-
}
|
|
29
|
-
request.hostname = hostname;
|
|
30
|
-
context["signing_service"] = "s3-object-lambda";
|
|
31
|
-
if (config.runtime === "node" && !request.headers["content-length"]) {
|
|
32
|
-
request.headers["transfer-encoding"] = "chunked";
|
|
33
|
-
}
|
|
34
|
-
return [2, next(__assign({}, args))];
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}); };
|
|
38
|
-
};
|
|
3
|
+
export const writeGetObjectResponseEndpointMiddleware = (config) => (next, context) => async (args) => {
|
|
4
|
+
const { region: regionProvider, isCustomEndpoint, disableHostPrefix } = config;
|
|
5
|
+
const region = await regionProvider();
|
|
6
|
+
const { request, input } = args;
|
|
7
|
+
if (!HttpRequest.isInstance(request))
|
|
8
|
+
return next({ ...args });
|
|
9
|
+
let hostname = request.hostname;
|
|
10
|
+
if (hostname.endsWith("s3.amazonaws.com") || hostname.endsWith("s3-external-1.amazonaws.com")) {
|
|
11
|
+
return next({ ...args });
|
|
12
|
+
}
|
|
13
|
+
if (!isCustomEndpoint) {
|
|
14
|
+
const [, suffix] = getSuffixForArnEndpoint(request.hostname);
|
|
15
|
+
hostname = `s3-object-lambda.${region}.${suffix}`;
|
|
16
|
+
}
|
|
17
|
+
if (!disableHostPrefix && input.RequestRoute) {
|
|
18
|
+
hostname = `${input.RequestRoute}.${hostname}`;
|
|
19
|
+
}
|
|
20
|
+
request.hostname = hostname;
|
|
21
|
+
context["signing_service"] = "s3-object-lambda";
|
|
22
|
+
if (config.runtime === "node" && !request.headers["content-length"]) {
|
|
23
|
+
request.headers["transfer-encoding"] = "chunked";
|
|
24
|
+
}
|
|
25
|
+
return next({ ...args });
|
|
39
26
|
};
|
|
40
|
-
export
|
|
27
|
+
export const writeGetObjectResponseEndpointMiddlewareOptions = {
|
|
41
28
|
relation: "after",
|
|
42
29
|
toMiddleware: "contentLengthMiddleware",
|
|
43
30
|
tags: ["WRITE_GET_OBJECT_RESPONSE", "S3", "ENDPOINT"],
|
|
44
31
|
name: "writeGetObjectResponseEndpointMiddleware",
|
|
45
32
|
override: true,
|
|
46
33
|
};
|
|
47
|
-
export
|
|
48
|
-
applyToStack:
|
|
34
|
+
export const getWriteGetObjectResponseEndpointPlugin = (config) => ({
|
|
35
|
+
applyToStack: (clientStack) => {
|
|
49
36
|
clientStack.addRelativeTo(writeGetObjectResponseEndpointMiddleware(config), writeGetObjectResponseEndpointMiddlewareOptions);
|
|
50
37
|
},
|
|
51
|
-
});
|
|
38
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-sdk-s3",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.190.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,10 +20,10 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/middleware-bucket-endpoint": "3.
|
|
24
|
-
"@aws-sdk/protocol-http": "3.
|
|
25
|
-
"@aws-sdk/types": "3.
|
|
26
|
-
"@aws-sdk/util-arn-parser": "3.
|
|
23
|
+
"@aws-sdk/middleware-bucket-endpoint": "3.190.0",
|
|
24
|
+
"@aws-sdk/protocol-http": "3.190.0",
|
|
25
|
+
"@aws-sdk/types": "3.190.0",
|
|
26
|
+
"@aws-sdk/util-arn-parser": "3.188.0",
|
|
27
27
|
"tslib": "^2.3.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|