@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 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
- 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
+ });
@@ -0,0 +1,6 @@
1
+ export const resolveS3Config = (input) => ({
2
+ ...input,
3
+ forcePathStyle: input.forcePathStyle ?? false,
4
+ useAccelerateEndpoint: input.useAccelerateEndpoint ?? false,
5
+ disableMultiregionAccessPoints: input.disableMultiregionAccessPoints ?? false,
6
+ });
package/dist-es/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./check-content-length-header";
2
+ export * from "./configuration";
2
3
  export * from "./throw-200-exceptions";
3
4
  export * from "./validate-bucket-name";
4
5
  export * from "./write-get-object-response-endpoint";
@@ -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
+ });
@@ -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;
@@ -1,4 +1,5 @@
1
1
  export * from "./check-content-length-header";
2
+ export * from "./configuration";
2
3
  export * from "./throw-200-exceptions";
3
4
  export * from "./validate-bucket-name";
4
5
  export * from "./write-get-object-response-endpoint";
@@ -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,4 +1,5 @@
1
1
  export * from "./check-content-length-header";
2
+ export * from "./configuration";
2
3
  export * from "./throw-200-exceptions";
3
4
  export * from "./validate-bucket-name";
4
5
  export * from "./write-get-object-response-endpoint";
@@ -6,7 +6,7 @@ import {
6
6
  } from "@aws-sdk/types";
7
7
  declare type PreviouslyResolved = {
8
8
  region: Provider<string>;
9
- isCustomEndpoint: boolean;
9
+ isCustomEndpoint?: boolean;
10
10
  disableHostPrefix: boolean;
11
11
  runtime: string;
12
12
  };
@@ -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: boolean;
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.171.0",
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.171.0",
24
- "@aws-sdk/protocol-http": "3.171.0",
25
- "@aws-sdk/types": "3.171.0",
26
- "@aws-sdk/util-arn-parser": "3.170.0",
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": {