@aws-sdk/middleware-sdk-s3 3.171.0 → 3.183.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 +19 -0
- package/dist-cjs/configuration.js +13 -0
- package/dist-cjs/index.js +1 -0
- package/dist-es/check-content-length-header.js +18 -26
- package/dist-es/configuration.js +6 -0
- package/dist-es/index.js +1 -0
- 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/dist-types/configuration.d.ts +24 -0
- package/dist-types/index.d.ts +1 -0
- package/dist-types/ts3.4/configuration.d.ts +13 -0
- package/dist-types/ts3.4/index.d.ts +1 -0
- package/dist-types/ts3.4/write-get-object-response-endpoint.d.ts +1 -1
- package/dist-types/write-get-object-response-endpoint.d.ts +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-sdk/middleware-sdk-s3
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **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))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
# [3.171.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.170.0...v3.171.0) (2022-09-14)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @aws-sdk/middleware-sdk-s3
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveS3Config = void 0;
|
|
4
|
+
const resolveS3Config = (input) => {
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
return ({
|
|
7
|
+
...input,
|
|
8
|
+
forcePathStyle: (_a = input.forcePathStyle) !== null && _a !== void 0 ? _a : false,
|
|
9
|
+
useAccelerateEndpoint: (_b = input.useAccelerateEndpoint) !== null && _b !== void 0 ? _b : false,
|
|
10
|
+
disableMultiregionAccessPoints: (_c = input.disableMultiregionAccessPoints) !== null && _c !== void 0 ? _c : false,
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
exports.resolveS3Config = resolveS3Config;
|
package/dist-cjs/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./check-content-length-header"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./configuration"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./throw-200-exceptions"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./validate-bucket-name"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./write-get-object-response-endpoint"), exports);
|
|
@@ -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/index.js
CHANGED
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All endpoint parameters with built-in bindings of AWS::S3::*
|
|
3
|
+
*/
|
|
4
|
+
export interface S3InputConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Whether to force path style URLs for S3 objects
|
|
7
|
+
* (e.g., https://s3.amazonaws.com/<bucketName>/<key> instead of https://<bucketName>.s3.amazonaws.com/<key>
|
|
8
|
+
*/
|
|
9
|
+
forcePathStyle?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to use the S3 Transfer Acceleration endpoint by default
|
|
12
|
+
*/
|
|
13
|
+
useAccelerateEndpoint?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether multi-region access points (MRAP) should be disabled.
|
|
16
|
+
*/
|
|
17
|
+
disableMultiregionAccessPoints?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface S3ResolvedConfig {
|
|
20
|
+
forcePathStyle: boolean;
|
|
21
|
+
useAccelerateEndpoint: boolean;
|
|
22
|
+
disableMultiregionAccessPoints: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const resolveS3Config: <T>(input: T & S3InputConfig) => T & S3ResolvedConfig;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface S3InputConfig {
|
|
2
|
+
forcePathStyle?: boolean;
|
|
3
|
+
useAccelerateEndpoint?: boolean;
|
|
4
|
+
disableMultiregionAccessPoints?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface S3ResolvedConfig {
|
|
7
|
+
forcePathStyle: boolean;
|
|
8
|
+
useAccelerateEndpoint: boolean;
|
|
9
|
+
disableMultiregionAccessPoints: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const resolveS3Config: <T>(
|
|
12
|
+
input: T & S3InputConfig
|
|
13
|
+
) => T & S3ResolvedConfig;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BuildMiddleware, Pluggable, Provider, RelativeMiddlewareOptions } from "@aws-sdk/types";
|
|
2
2
|
declare type PreviouslyResolved = {
|
|
3
3
|
region: Provider<string>;
|
|
4
|
-
isCustomEndpoint
|
|
4
|
+
isCustomEndpoint?: boolean;
|
|
5
5
|
disableHostPrefix: boolean;
|
|
6
6
|
runtime: string;
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-sdk-s3",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.183.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.183.0",
|
|
24
|
+
"@aws-sdk/protocol-http": "3.183.0",
|
|
25
|
+
"@aws-sdk/types": "3.183.0",
|
|
26
|
+
"@aws-sdk/util-arn-parser": "3.183.0",
|
|
27
27
|
"tslib": "^2.3.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|