@aws-sdk/middleware-sdk-s3 3.183.0 → 3.186.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.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)
7
+
8
+ **Note:** Version bump only for package @aws-sdk/middleware-sdk-s3
9
+
10
+
11
+
12
+
13
+
6
14
  # [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
7
15
 
8
16
  **Note:** Version bump only for package @aws-sdk/middleware-sdk-s3
@@ -1,30 +1,38 @@
1
+ import { __assign, __awaiter, __generator } from "tslib";
1
2
  import { HttpRequest } from "@aws-sdk/protocol-http";
2
- const CONTENT_LENGTH_HEADER = "content-length";
3
+ var CONTENT_LENGTH_HEADER = "content-length";
3
4
  export function checkContentLengthHeader() {
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);
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
+ }
11
22
  }
12
- else {
13
- console.warn(message);
14
- }
15
- }
16
- }
17
- return next({ ...args });
23
+ return [2, next(__assign({}, args))];
24
+ });
25
+ }); };
18
26
  };
19
27
  }
20
- export const checkContentLengthHeaderMiddlewareOptions = {
28
+ export var checkContentLengthHeaderMiddlewareOptions = {
21
29
  step: "finalizeRequest",
22
30
  tags: ["CHECK_CONTENT_LENGTH_HEADER"],
23
31
  name: "getCheckContentLengthHeaderPlugin",
24
32
  override: true,
25
33
  };
26
- export const getCheckContentLengthHeaderPlugin = (unused) => ({
27
- applyToStack: (clientStack) => {
34
+ export var getCheckContentLengthHeaderPlugin = function (unused) { return ({
35
+ applyToStack: function (clientStack) {
28
36
  clientStack.add(checkContentLengthHeader(), checkContentLengthHeaderMiddlewareOptions);
29
37
  },
30
- });
38
+ }); };
@@ -1,6 +1,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
+ 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,41 +1,60 @@
1
+ import { __awaiter, __generator } from "tslib";
1
2
  import { HttpResponse } from "@aws-sdk/protocol-http";
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;
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
+ };
22
38
  };
23
- const collectBody = (streamBody = new Uint8Array(), context) => {
39
+ var collectBody = function (streamBody, context) {
40
+ if (streamBody === void 0) { streamBody = new Uint8Array(); }
24
41
  if (streamBody instanceof Uint8Array) {
25
42
  return Promise.resolve(streamBody);
26
43
  }
27
44
  return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
28
45
  };
29
- const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
30
- export const throw200ExceptionsMiddlewareOptions = {
46
+ var collectBodyString = function (streamBody, context) {
47
+ return collectBody(streamBody, context).then(function (body) { return context.utf8Encoder(body); });
48
+ };
49
+ export var throw200ExceptionsMiddlewareOptions = {
31
50
  relation: "after",
32
51
  toMiddleware: "deserializerMiddleware",
33
52
  tags: ["THROW_200_EXCEPTIONS", "S3"],
34
53
  name: "throw200ExceptionsMiddleware",
35
54
  override: true,
36
55
  };
37
- export const getThrow200ExceptionsPlugin = (config) => ({
38
- applyToStack: (clientStack) => {
56
+ export var getThrow200ExceptionsPlugin = function (config) { return ({
57
+ applyToStack: function (clientStack) {
39
58
  clientStack.addRelativeTo(throw200ExceptionsMiddleware(config), throw200ExceptionsMiddlewareOptions);
40
59
  },
41
- });
60
+ }); };
@@ -1,23 +1,30 @@
1
+ import { __assign, __awaiter, __generator } from "tslib";
1
2
  import { validate as validateArn } from "@aws-sdk/util-arn-parser";
2
3
  export function validateBucketNameMiddleware() {
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 });
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
+ }); };
11
18
  };
12
19
  }
13
- export const validateBucketNameMiddlewareOptions = {
20
+ export var validateBucketNameMiddlewareOptions = {
14
21
  step: "initialize",
15
22
  tags: ["VALIDATE_BUCKET_NAME"],
16
23
  name: "validateBucketNameMiddleware",
17
24
  override: true,
18
25
  };
19
- export const getValidateBucketNamePlugin = (unused) => ({
20
- applyToStack: (clientStack) => {
26
+ export var getValidateBucketNamePlugin = function (unused) { return ({
27
+ applyToStack: function (clientStack) {
21
28
  clientStack.add(validateBucketNameMiddleware(), validateBucketNameMiddlewareOptions);
22
29
  },
23
- });
30
+ }); };
@@ -1,38 +1,51 @@
1
+ import { __assign, __awaiter, __generator, __read } from "tslib";
1
2
  import { getSuffixForArnEndpoint } from "@aws-sdk/middleware-bucket-endpoint";
2
3
  import { HttpRequest } from "@aws-sdk/protocol-http";
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 });
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
+ };
26
39
  };
27
- export const writeGetObjectResponseEndpointMiddlewareOptions = {
40
+ export var writeGetObjectResponseEndpointMiddlewareOptions = {
28
41
  relation: "after",
29
42
  toMiddleware: "contentLengthMiddleware",
30
43
  tags: ["WRITE_GET_OBJECT_RESPONSE", "S3", "ENDPOINT"],
31
44
  name: "writeGetObjectResponseEndpointMiddleware",
32
45
  override: true,
33
46
  };
34
- export const getWriteGetObjectResponseEndpointPlugin = (config) => ({
35
- applyToStack: (clientStack) => {
47
+ export var getWriteGetObjectResponseEndpointPlugin = function (config) { return ({
48
+ applyToStack: function (clientStack) {
36
49
  clientStack.addRelativeTo(writeGetObjectResponseEndpointMiddleware(config), writeGetObjectResponseEndpointMiddlewareOptions);
37
50
  },
38
- });
51
+ }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-s3",
3
- "version": "3.183.0",
3
+ "version": "3.186.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.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",
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",
27
27
  "tslib": "^2.3.1"
28
28
  },
29
29
  "devDependencies": {