@aws-sdk/middleware-sdk-s3 3.186.0 → 3.188.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,14 @@
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.188.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.187.0...v3.188.0) (2022-10-13)
7
+
8
+ **Note:** Version bump only for package @aws-sdk/middleware-sdk-s3
9
+
10
+
11
+
12
+
13
+
6
14
  # [3.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)
7
15
 
8
16
  **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
- var CONTENT_LENGTH_HEADER = "content-length";
2
+ const CONTENT_LENGTH_HEADER = "content-length";
4
3
  export function checkContentLengthHeader() {
5
- var _this = this;
6
- return function (next, context) {
7
- return function (args) { return __awaiter(_this, void 0, void 0, function () {
8
- var request, message;
9
- var _a;
10
- return __generator(this, function (_b) {
11
- request = args.request;
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
- return [2, next(__assign({}, args))];
24
- });
25
- }); };
12
+ else {
13
+ console.warn(message);
14
+ }
15
+ }
16
+ }
17
+ return next({ ...args });
26
18
  };
27
19
  }
28
- export var checkContentLengthHeaderMiddlewareOptions = {
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 var getCheckContentLengthHeaderPlugin = function (unused) { return ({
35
- applyToStack: function (clientStack) {
26
+ export const getCheckContentLengthHeaderPlugin = (unused) => ({
27
+ applyToStack: (clientStack) => {
36
28
  clientStack.add(checkContentLengthHeader(), checkContentLengthHeaderMiddlewareOptions);
37
29
  },
38
- }); };
30
+ });
@@ -1,5 +1,6 @@
1
- import { __assign } from "tslib";
2
- export var resolveS3Config = function (input) {
3
- var _a, _b, _c;
4
- return (__assign(__assign({}, input), { forcePathStyle: (_a = input.forcePathStyle) !== null && _a !== void 0 ? _a : false, useAccelerateEndpoint: (_b = input.useAccelerateEndpoint) !== null && _b !== void 0 ? _b : false, disableMultiregionAccessPoints: (_c = input.disableMultiregionAccessPoints) !== null && _c !== void 0 ? _c : false }));
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 var throw200ExceptionsMiddleware = function (config) {
4
- return function (next) {
5
- return function (args) { return __awaiter(void 0, void 0, void 0, function () {
6
- var result, response, statusCode, body, bodyBytes, bodyString, err;
7
- return __generator(this, function (_a) {
8
- switch (_a.label) {
9
- case 0: return [4, next(args)];
10
- case 1:
11
- result = _a.sent();
12
- response = result.response;
13
- if (!HttpResponse.isInstance(response))
14
- return [2, result];
15
- statusCode = response.statusCode, body = response.body;
16
- if (statusCode < 200 || statusCode >= 300)
17
- return [2, result];
18
- return [4, collectBody(body, config)];
19
- case 2:
20
- bodyBytes = _a.sent();
21
- return [4, collectBodyString(bodyBytes, config)];
22
- case 3:
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
- var collectBody = function (streamBody, context) {
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
- var collectBodyString = function (streamBody, context) {
47
- return collectBody(streamBody, context).then(function (body) { return context.utf8Encoder(body); });
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 var getThrow200ExceptionsPlugin = function (config) { return ({
57
- applyToStack: function (clientStack) {
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
- var _this = this;
5
- return function (next) {
6
- return function (args) { return __awaiter(_this, void 0, void 0, function () {
7
- var Bucket, err;
8
- return __generator(this, function (_a) {
9
- Bucket = args.input.Bucket;
10
- if (typeof Bucket === "string" && !validateArn(Bucket) && Bucket.indexOf("/") >= 0) {
11
- err = new Error("Bucket name shouldn't contain '/', received '".concat(Bucket, "'"));
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 var validateBucketNameMiddlewareOptions = {
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 var getValidateBucketNamePlugin = function (unused) { return ({
27
- applyToStack: function (clientStack) {
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 var writeGetObjectResponseEndpointMiddleware = function (config) {
5
- return function (next, context) {
6
- return function (args) { return __awaiter(void 0, void 0, void 0, function () {
7
- var regionProvider, isCustomEndpoint, disableHostPrefix, region, request, input, hostname, _a, suffix;
8
- return __generator(this, function (_b) {
9
- switch (_b.label) {
10
- case 0:
11
- regionProvider = config.region, isCustomEndpoint = config.isCustomEndpoint, disableHostPrefix = config.disableHostPrefix;
12
- return [4, regionProvider()];
13
- case 1:
14
- region = _b.sent();
15
- request = args.request, input = args.input;
16
- if (!HttpRequest.isInstance(request))
17
- return [2, next(__assign({}, args))];
18
- hostname = request.hostname;
19
- if (hostname.endsWith("s3.amazonaws.com") || hostname.endsWith("s3-external-1.amazonaws.com")) {
20
- return [2, next(__assign({}, args))];
21
- }
22
- if (!isCustomEndpoint) {
23
- _a = __read(getSuffixForArnEndpoint(request.hostname), 2), suffix = _a[1];
24
- hostname = "s3-object-lambda.".concat(region, ".").concat(suffix);
25
- }
26
- if (!disableHostPrefix && input.RequestRoute) {
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 var writeGetObjectResponseEndpointMiddlewareOptions = {
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 var getWriteGetObjectResponseEndpointPlugin = function (config) { return ({
48
- applyToStack: function (clientStack) {
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.186.0",
3
+ "version": "3.188.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.186.0",
24
- "@aws-sdk/protocol-http": "3.186.0",
25
- "@aws-sdk/types": "3.186.0",
26
- "@aws-sdk/util-arn-parser": "3.186.0",
23
+ "@aws-sdk/middleware-bucket-endpoint": "3.188.0",
24
+ "@aws-sdk/protocol-http": "3.188.0",
25
+ "@aws-sdk/types": "3.188.0",
26
+ "@aws-sdk/util-arn-parser": "3.188.0",
27
27
  "tslib": "^2.3.1"
28
28
  },
29
29
  "devDependencies": {