@aws-sdk/middleware-sdk-s3 3.78.0 → 3.109.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,36 @@
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.109.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.108.1...v3.109.0) (2022-06-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **s3:** update endpoints for writeGetObjectResponse for object lambda ([#3662](https://github.com/aws/aws-sdk-js-v3/issues/3662)) ([bb9f18e](https://github.com/aws/aws-sdk-js-v3/commit/bb9f18edb6226b65b146d81be3b91cb3581bc3b3))
12
+
13
+
14
+
15
+
16
+
17
+ # [3.105.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.104.0...v3.105.0) (2022-06-06)
18
+
19
+ **Note:** Version bump only for package @aws-sdk/middleware-sdk-s3
20
+
21
+
22
+
23
+
24
+
25
+ # [3.86.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.85.0...v3.86.0) (2022-05-06)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **middleware-sdk-s3:** improve error message on stream upload ([#3571](https://github.com/aws/aws-sdk-js-v3/issues/3571)) ([c0ed833](https://github.com/aws/aws-sdk-js-v3/commit/c0ed83347f571b3f5d1e41dc91c172abafb44b7b))
31
+
32
+
33
+
34
+
35
+
6
36
  # [3.78.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.77.0...v3.78.0) (2022-04-26)
7
37
 
8
38
  **Note:** Version bump only for package @aws-sdk/middleware-sdk-s3
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCheckContentLengthHeaderPlugin = exports.checkContentLengthHeaderMiddlewareOptions = exports.checkContentLengthHeader = void 0;
4
+ const protocol_http_1 = require("@aws-sdk/protocol-http");
5
+ const CONTENT_LENGTH_HEADER = "content-length";
6
+ function checkContentLengthHeader() {
7
+ return (next, context) => async (args) => {
8
+ var _a;
9
+ const { request } = args;
10
+ if (protocol_http_1.HttpRequest.isInstance(request)) {
11
+ if (!request.headers[CONTENT_LENGTH_HEADER]) {
12
+ 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.`;
13
+ if (typeof ((_a = context === null || context === void 0 ? void 0 : context.logger) === null || _a === void 0 ? void 0 : _a.warn) === "function") {
14
+ context.logger.warn(message);
15
+ }
16
+ else {
17
+ console.warn(message);
18
+ }
19
+ }
20
+ }
21
+ return next({ ...args });
22
+ };
23
+ }
24
+ exports.checkContentLengthHeader = checkContentLengthHeader;
25
+ exports.checkContentLengthHeaderMiddlewareOptions = {
26
+ step: "finalizeRequest",
27
+ tags: ["CHECK_CONTENT_LENGTH_HEADER"],
28
+ name: "getCheckContentLengthHeaderPlugin",
29
+ override: true,
30
+ };
31
+ const getCheckContentLengthHeaderPlugin = (unused) => ({
32
+ applyToStack: (clientStack) => {
33
+ clientStack.add(checkContentLengthHeader(), exports.checkContentLengthHeaderMiddlewareOptions);
34
+ },
35
+ });
36
+ exports.getCheckContentLengthHeaderPlugin = getCheckContentLengthHeaderPlugin;
package/dist-cjs/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./check-content-length-header"), exports);
4
5
  tslib_1.__exportStar(require("./throw-200-exceptions"), exports);
5
- tslib_1.__exportStar(require("./use-regional-endpoint"), exports);
6
6
  tslib_1.__exportStar(require("./validate-bucket-name"), exports);
7
+ tslib_1.__exportStar(require("./write-get-object-response-endpoint"), exports);
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWriteGetObjectResponseEndpointPlugin = exports.writeGetObjectResponseEndpointMiddlewareOptions = exports.writeGetObjectResponseEndpointMiddleware = void 0;
4
+ const middleware_bucket_endpoint_1 = require("@aws-sdk/middleware-bucket-endpoint");
5
+ const protocol_http_1 = require("@aws-sdk/protocol-http");
6
+ const writeGetObjectResponseEndpointMiddleware = (config) => (next, context) => async (args) => {
7
+ const { region: regionProvider, isCustomEndpoint, disableHostPrefix } = config;
8
+ const region = await regionProvider();
9
+ const { request, input } = args;
10
+ if (!protocol_http_1.HttpRequest.isInstance(request))
11
+ return next({ ...args });
12
+ let hostname = request.hostname;
13
+ if (hostname.endsWith("s3.amazonaws.com") || hostname.endsWith("s3-external-1.amazonaws.com")) {
14
+ return next({ ...args });
15
+ }
16
+ if (!isCustomEndpoint) {
17
+ const [, suffix] = (0, middleware_bucket_endpoint_1.getSuffixForArnEndpoint)(request.hostname);
18
+ hostname = `s3-object-lambda.${region}.${suffix}`;
19
+ }
20
+ if (!disableHostPrefix && input.RequestRoute) {
21
+ hostname = `${input.RequestRoute}.${hostname}`;
22
+ }
23
+ request.hostname = hostname;
24
+ context["signing_service"] = "s3-object-lambda";
25
+ if (config.runtime === "node" && !request.headers["content-length"]) {
26
+ request.headers["transfer-encoding"] = "chunked";
27
+ }
28
+ return next({ ...args });
29
+ };
30
+ exports.writeGetObjectResponseEndpointMiddleware = writeGetObjectResponseEndpointMiddleware;
31
+ exports.writeGetObjectResponseEndpointMiddlewareOptions = {
32
+ relation: "after",
33
+ toMiddleware: "contentLengthMiddleware",
34
+ tags: ["WRITE_GET_OBJECT_RESPONSE", "S3", "ENDPOINT"],
35
+ name: "writeGetObjectResponseEndpointMiddleware",
36
+ override: true,
37
+ };
38
+ const getWriteGetObjectResponseEndpointPlugin = (config) => ({
39
+ applyToStack: (clientStack) => {
40
+ clientStack.addRelativeTo((0, exports.writeGetObjectResponseEndpointMiddleware)(config), exports.writeGetObjectResponseEndpointMiddlewareOptions);
41
+ },
42
+ });
43
+ exports.getWriteGetObjectResponseEndpointPlugin = getWriteGetObjectResponseEndpointPlugin;
@@ -0,0 +1,38 @@
1
+ import { __assign, __awaiter, __generator } from "tslib";
2
+ import { HttpRequest } from "@aws-sdk/protocol-http";
3
+ var CONTENT_LENGTH_HEADER = "content-length";
4
+ 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
+ }
22
+ }
23
+ return [2, next(__assign({}, args))];
24
+ });
25
+ }); };
26
+ };
27
+ }
28
+ export var checkContentLengthHeaderMiddlewareOptions = {
29
+ step: "finalizeRequest",
30
+ tags: ["CHECK_CONTENT_LENGTH_HEADER"],
31
+ name: "getCheckContentLengthHeaderPlugin",
32
+ override: true,
33
+ };
34
+ export var getCheckContentLengthHeaderPlugin = function (unused) { return ({
35
+ applyToStack: function (clientStack) {
36
+ clientStack.add(checkContentLengthHeader(), checkContentLengthHeaderMiddlewareOptions);
37
+ },
38
+ }); };
package/dist-es/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./check-content-length-header";
1
2
  export * from "./throw-200-exceptions";
2
- export * from "./use-regional-endpoint";
3
3
  export * from "./validate-bucket-name";
4
+ export * from "./write-get-object-response-endpoint";
@@ -0,0 +1,51 @@
1
+ import { __assign, __awaiter, __generator, __read } from "tslib";
2
+ import { getSuffixForArnEndpoint } from "@aws-sdk/middleware-bucket-endpoint";
3
+ 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
+ };
39
+ };
40
+ export var writeGetObjectResponseEndpointMiddlewareOptions = {
41
+ relation: "after",
42
+ toMiddleware: "contentLengthMiddleware",
43
+ tags: ["WRITE_GET_OBJECT_RESPONSE", "S3", "ENDPOINT"],
44
+ name: "writeGetObjectResponseEndpointMiddleware",
45
+ override: true,
46
+ };
47
+ export var getWriteGetObjectResponseEndpointPlugin = function (config) { return ({
48
+ applyToStack: function (clientStack) {
49
+ clientStack.addRelativeTo(writeGetObjectResponseEndpointMiddleware(config), writeGetObjectResponseEndpointMiddlewareOptions);
50
+ },
51
+ }); };
@@ -0,0 +1,16 @@
1
+ import { FinalizeRequestHandlerOptions, FinalizeRequestMiddleware, Pluggable } from "@aws-sdk/types";
2
+ /**
3
+ * @internal
4
+ *
5
+ * Log a warning if the input to PutObject is detected to be a Stream of unknown ContentLength and
6
+ * recommend the usage of the @aws-sdk/lib-storage Upload class.
7
+ */
8
+ export declare function checkContentLengthHeader(): FinalizeRequestMiddleware<any, any>;
9
+ /**
10
+ * @internal
11
+ */
12
+ export declare const checkContentLengthHeaderMiddlewareOptions: FinalizeRequestHandlerOptions;
13
+ /**
14
+ * @internal
15
+ */
16
+ export declare const getCheckContentLengthHeaderPlugin: (unused: any) => Pluggable<any, any>;
@@ -1,3 +1,4 @@
1
+ export * from "./check-content-length-header";
1
2
  export * from "./throw-200-exceptions";
2
- export * from "./use-regional-endpoint";
3
3
  export * from "./validate-bucket-name";
4
+ export * from "./write-get-object-response-endpoint";
@@ -0,0 +1,7 @@
1
+ import { FinalizeRequestHandlerOptions, FinalizeRequestMiddleware, Pluggable } from "@aws-sdk/types";
2
+
3
+ export declare function checkContentLengthHeader(): FinalizeRequestMiddleware<any, any>;
4
+
5
+ export declare const checkContentLengthHeaderMiddlewareOptions: FinalizeRequestHandlerOptions;
6
+
7
+ export declare const getCheckContentLengthHeaderPlugin: (unused: any) => Pluggable<any, any>;
@@ -1,3 +1,4 @@
1
+ export * from "./check-content-length-header";
1
2
  export * from "./throw-200-exceptions";
2
- export * from "./use-regional-endpoint";
3
3
  export * from "./validate-bucket-name";
4
+ export * from "./write-get-object-response-endpoint";
@@ -0,0 +1,14 @@
1
+ import { BuildMiddleware, Pluggable, Provider, RelativeMiddlewareOptions } from "@aws-sdk/types";
2
+ declare type PreviouslyResolved = {
3
+ region: Provider<string>;
4
+ isCustomEndpoint: boolean;
5
+ disableHostPrefix: boolean;
6
+ runtime: string;
7
+ };
8
+
9
+ export declare const writeGetObjectResponseEndpointMiddleware: (config: PreviouslyResolved) => BuildMiddleware<any, any>;
10
+
11
+ export declare const writeGetObjectResponseEndpointMiddlewareOptions: RelativeMiddlewareOptions;
12
+
13
+ export declare const getWriteGetObjectResponseEndpointPlugin: (config: PreviouslyResolved) => Pluggable<any, any>;
14
+ export {};
@@ -0,0 +1,20 @@
1
+ import { BuildMiddleware, Pluggable, Provider, RelativeMiddlewareOptions } from "@aws-sdk/types";
2
+ declare type PreviouslyResolved = {
3
+ region: Provider<string>;
4
+ isCustomEndpoint: boolean;
5
+ disableHostPrefix: boolean;
6
+ runtime: string;
7
+ };
8
+ /**
9
+ * @internal
10
+ */
11
+ export declare const writeGetObjectResponseEndpointMiddleware: (config: PreviouslyResolved) => BuildMiddleware<any, any>;
12
+ /**
13
+ * @internal
14
+ */
15
+ export declare const writeGetObjectResponseEndpointMiddlewareOptions: RelativeMiddlewareOptions;
16
+ /**
17
+ * @internal
18
+ */
19
+ export declare const getWriteGetObjectResponseEndpointPlugin: (config: PreviouslyResolved) => Pluggable<any, any>;
20
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-s3",
3
- "version": "3.78.0",
3
+ "version": "3.109.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",
@@ -19,8 +19,9 @@
19
19
  },
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@aws-sdk/protocol-http": "3.78.0",
23
- "@aws-sdk/types": "3.78.0",
22
+ "@aws-sdk/middleware-bucket-endpoint": "3.109.0",
23
+ "@aws-sdk/protocol-http": "3.109.0",
24
+ "@aws-sdk/types": "3.109.0",
24
25
  "@aws-sdk/util-arn-parser": "3.55.0",
25
26
  "tslib": "^2.3.1"
26
27
  },
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUseRegionalEndpointPlugin = exports.useRegionalEndpointMiddlewareOptions = exports.useRegionalEndpointMiddleware = void 0;
4
- const protocol_http_1 = require("@aws-sdk/protocol-http");
5
- const useRegionalEndpointMiddleware = (config) => (next) => async (args) => {
6
- const { request } = args;
7
- if (!protocol_http_1.HttpRequest.isInstance(request) || config.isCustomEndpoint)
8
- return next({ ...args });
9
- if (request.hostname === "s3.amazonaws.com") {
10
- request.hostname = "s3.us-east-1.amazonaws.com";
11
- }
12
- else if ("aws-global" === (await config.region())) {
13
- request.hostname = "s3.amazonaws.com";
14
- }
15
- return next({ ...args });
16
- };
17
- exports.useRegionalEndpointMiddleware = useRegionalEndpointMiddleware;
18
- exports.useRegionalEndpointMiddlewareOptions = {
19
- step: "build",
20
- tags: ["USE_REGIONAL_ENDPOINT", "S3"],
21
- name: "useRegionalEndpointMiddleware",
22
- override: true,
23
- };
24
- const getUseRegionalEndpointPlugin = (config) => ({
25
- applyToStack: (clientStack) => {
26
- clientStack.add((0, exports.useRegionalEndpointMiddleware)(config), exports.useRegionalEndpointMiddlewareOptions);
27
- },
28
- });
29
- exports.getUseRegionalEndpointPlugin = getUseRegionalEndpointPlugin;
@@ -1,40 +0,0 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
2
- import { HttpRequest } from "@aws-sdk/protocol-http";
3
- export var useRegionalEndpointMiddleware = function (config) {
4
- return function (next) {
5
- return function (args) { return __awaiter(void 0, void 0, void 0, function () {
6
- var request, _a;
7
- return __generator(this, function (_b) {
8
- switch (_b.label) {
9
- case 0:
10
- request = args.request;
11
- if (!HttpRequest.isInstance(request) || config.isCustomEndpoint)
12
- return [2, next(__assign({}, args))];
13
- if (!(request.hostname === "s3.amazonaws.com")) return [3, 1];
14
- request.hostname = "s3.us-east-1.amazonaws.com";
15
- return [3, 3];
16
- case 1:
17
- _a = "aws-global";
18
- return [4, config.region()];
19
- case 2:
20
- if (_a === (_b.sent())) {
21
- request.hostname = "s3.amazonaws.com";
22
- }
23
- _b.label = 3;
24
- case 3: return [2, next(__assign({}, args))];
25
- }
26
- });
27
- }); };
28
- };
29
- };
30
- export var useRegionalEndpointMiddlewareOptions = {
31
- step: "build",
32
- tags: ["USE_REGIONAL_ENDPOINT", "S3"],
33
- name: "useRegionalEndpointMiddleware",
34
- override: true,
35
- };
36
- export var getUseRegionalEndpointPlugin = function (config) { return ({
37
- applyToStack: function (clientStack) {
38
- clientStack.add(useRegionalEndpointMiddleware(config), useRegionalEndpointMiddlewareOptions);
39
- },
40
- }); };
@@ -1,12 +0,0 @@
1
- import { BuildHandlerOptions, BuildMiddleware, Pluggable, Provider } from "@aws-sdk/types";
2
- declare type PreviouslyResolved = {
3
- region: Provider<string>;
4
- isCustomEndpoint: boolean;
5
- };
6
-
7
- export declare const useRegionalEndpointMiddleware: (config: PreviouslyResolved) => BuildMiddleware<any, any>;
8
-
9
- export declare const useRegionalEndpointMiddlewareOptions: BuildHandlerOptions;
10
-
11
- export declare const getUseRegionalEndpointPlugin: (config: PreviouslyResolved) => Pluggable<any, any>;
12
- export {};
@@ -1,18 +0,0 @@
1
- import { BuildHandlerOptions, BuildMiddleware, Pluggable, Provider } from "@aws-sdk/types";
2
- declare type PreviouslyResolved = {
3
- region: Provider<string>;
4
- isCustomEndpoint: boolean;
5
- };
6
- /**
7
- * @internal
8
- */
9
- export declare const useRegionalEndpointMiddleware: (config: PreviouslyResolved) => BuildMiddleware<any, any>;
10
- /**
11
- * @internal
12
- */
13
- export declare const useRegionalEndpointMiddlewareOptions: BuildHandlerOptions;
14
- /**
15
- * @internal
16
- */
17
- export declare const getUseRegionalEndpointPlugin: (config: PreviouslyResolved) => Pluggable<any, any>;
18
- export {};