@aws-sdk/middleware-sdk-s3 3.425.0 → 3.428.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/dist-cjs/index.js +2 -0
- package/dist-cjs/region-redirect-endpoint-middleware.js +31 -0
- package/dist-cjs/region-redirect-middleware.js +44 -0
- package/dist-cjs/s3Configuration.js +2 -1
- package/dist-es/index.js +2 -0
- package/dist-es/region-redirect-endpoint-middleware.js +27 -0
- package/dist-es/region-redirect-middleware.js +38 -0
- package/dist-es/s3Configuration.js +1 -0
- package/dist-types/index.d.ts +2 -0
- package/dist-types/region-redirect-endpoint-middleware.d.ts +10 -0
- package/dist-types/region-redirect-middleware.d.ts +20 -0
- package/dist-types/s3Configuration.d.ts +8 -0
- package/dist-types/ts3.4/index.d.ts +2 -0
- package/dist-types/ts3.4/region-redirect-endpoint-middleware.d.ts +6 -0
- package/dist-types/ts3.4/region-redirect-middleware.d.ts +17 -0
- package/dist-types/ts3.4/s3Configuration.d.ts +2 -0
- package/package.json +6 -5
package/dist-cjs/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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("./region-redirect-endpoint-middleware"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./region-redirect-middleware"), exports);
|
|
5
7
|
tslib_1.__exportStar(require("./s3Configuration"), exports);
|
|
6
8
|
tslib_1.__exportStar(require("./throw-200-exceptions"), exports);
|
|
7
9
|
tslib_1.__exportStar(require("./validate-bucket-name"), exports);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.regionRedirectEndpointMiddlewareOptions = exports.regionRedirectEndpointMiddleware = void 0;
|
|
4
|
+
const regionRedirectEndpointMiddleware = (config) => {
|
|
5
|
+
return (next, context) => async (args) => {
|
|
6
|
+
const originalRegion = await config.region();
|
|
7
|
+
const regionProviderRef = config.region;
|
|
8
|
+
if (context.__s3RegionRedirect) {
|
|
9
|
+
config.region = async () => {
|
|
10
|
+
config.region = regionProviderRef;
|
|
11
|
+
return context.__s3RegionRedirect;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const result = await next(args);
|
|
15
|
+
if (context.__s3RegionRedirect) {
|
|
16
|
+
const region = await config.region();
|
|
17
|
+
if (originalRegion !== region) {
|
|
18
|
+
throw new Error("Region was not restored following S3 region redirect.");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.regionRedirectEndpointMiddleware = regionRedirectEndpointMiddleware;
|
|
25
|
+
exports.regionRedirectEndpointMiddlewareOptions = {
|
|
26
|
+
tags: ["REGION_REDIRECT", "S3"],
|
|
27
|
+
name: "regionRedirectEndpointMiddleware",
|
|
28
|
+
override: true,
|
|
29
|
+
relation: "before",
|
|
30
|
+
toMiddleware: "endpointV2Middleware",
|
|
31
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRegionRedirectMiddlewarePlugin = exports.regionRedirectMiddlewareOptions = exports.regionRedirectMiddleware = void 0;
|
|
4
|
+
const region_redirect_endpoint_middleware_1 = require("./region-redirect-endpoint-middleware");
|
|
5
|
+
function regionRedirectMiddleware(clientConfig) {
|
|
6
|
+
return (next, context) => async (args) => {
|
|
7
|
+
var _a;
|
|
8
|
+
try {
|
|
9
|
+
return await next(args);
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
if (clientConfig.followRegionRedirects &&
|
|
13
|
+
err.name === "PermanentRedirect" &&
|
|
14
|
+
err.$metadata.httpStatusCode === 301) {
|
|
15
|
+
try {
|
|
16
|
+
const actualRegion = err.$response.headers["x-amz-bucket-region"];
|
|
17
|
+
(_a = context.logger) === null || _a === void 0 ? void 0 : _a.debug(`Redirecting from ${await clientConfig.region()} to ${actualRegion}`);
|
|
18
|
+
context.__s3RegionRedirect = actualRegion;
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
throw new Error("Region redirect failed: " + e);
|
|
22
|
+
}
|
|
23
|
+
return next(args);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.regionRedirectMiddleware = regionRedirectMiddleware;
|
|
32
|
+
exports.regionRedirectMiddlewareOptions = {
|
|
33
|
+
step: "initialize",
|
|
34
|
+
tags: ["REGION_REDIRECT", "S3"],
|
|
35
|
+
name: "regionRedirectMiddleware",
|
|
36
|
+
override: true,
|
|
37
|
+
};
|
|
38
|
+
const getRegionRedirectMiddlewarePlugin = (clientConfig) => ({
|
|
39
|
+
applyToStack: (clientStack) => {
|
|
40
|
+
clientStack.add(regionRedirectMiddleware(clientConfig), exports.regionRedirectMiddlewareOptions);
|
|
41
|
+
clientStack.addRelativeTo((0, region_redirect_endpoint_middleware_1.regionRedirectEndpointMiddleware)(clientConfig), region_redirect_endpoint_middleware_1.regionRedirectEndpointMiddlewareOptions);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
exports.getRegionRedirectMiddlewarePlugin = getRegionRedirectMiddlewarePlugin;
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveS3Config = void 0;
|
|
4
4
|
const resolveS3Config = (input) => {
|
|
5
|
-
var _a, _b, _c;
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
6
|
return ({
|
|
7
7
|
...input,
|
|
8
8
|
forcePathStyle: (_a = input.forcePathStyle) !== null && _a !== void 0 ? _a : false,
|
|
9
9
|
useAccelerateEndpoint: (_b = input.useAccelerateEndpoint) !== null && _b !== void 0 ? _b : false,
|
|
10
10
|
disableMultiregionAccessPoints: (_c = input.disableMultiregionAccessPoints) !== null && _c !== void 0 ? _c : false,
|
|
11
|
+
followRegionRedirects: (_d = input.followRegionRedirects) !== null && _d !== void 0 ? _d : false,
|
|
11
12
|
});
|
|
12
13
|
};
|
|
13
14
|
exports.resolveS3Config = resolveS3Config;
|
package/dist-es/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./check-content-length-header";
|
|
2
|
+
export * from "./region-redirect-endpoint-middleware";
|
|
3
|
+
export * from "./region-redirect-middleware";
|
|
2
4
|
export * from "./s3Configuration";
|
|
3
5
|
export * from "./throw-200-exceptions";
|
|
4
6
|
export * from "./validate-bucket-name";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const regionRedirectEndpointMiddleware = (config) => {
|
|
2
|
+
return (next, context) => async (args) => {
|
|
3
|
+
const originalRegion = await config.region();
|
|
4
|
+
const regionProviderRef = config.region;
|
|
5
|
+
if (context.__s3RegionRedirect) {
|
|
6
|
+
config.region = async () => {
|
|
7
|
+
config.region = regionProviderRef;
|
|
8
|
+
return context.__s3RegionRedirect;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const result = await next(args);
|
|
12
|
+
if (context.__s3RegionRedirect) {
|
|
13
|
+
const region = await config.region();
|
|
14
|
+
if (originalRegion !== region) {
|
|
15
|
+
throw new Error("Region was not restored following S3 region redirect.");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export const regionRedirectEndpointMiddlewareOptions = {
|
|
22
|
+
tags: ["REGION_REDIRECT", "S3"],
|
|
23
|
+
name: "regionRedirectEndpointMiddleware",
|
|
24
|
+
override: true,
|
|
25
|
+
relation: "before",
|
|
26
|
+
toMiddleware: "endpointV2Middleware",
|
|
27
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { regionRedirectEndpointMiddleware, regionRedirectEndpointMiddlewareOptions, } from "./region-redirect-endpoint-middleware";
|
|
2
|
+
export function regionRedirectMiddleware(clientConfig) {
|
|
3
|
+
return (next, context) => async (args) => {
|
|
4
|
+
try {
|
|
5
|
+
return await next(args);
|
|
6
|
+
}
|
|
7
|
+
catch (err) {
|
|
8
|
+
if (clientConfig.followRegionRedirects &&
|
|
9
|
+
err.name === "PermanentRedirect" &&
|
|
10
|
+
err.$metadata.httpStatusCode === 301) {
|
|
11
|
+
try {
|
|
12
|
+
const actualRegion = err.$response.headers["x-amz-bucket-region"];
|
|
13
|
+
context.logger?.debug(`Redirecting from ${await clientConfig.region()} to ${actualRegion}`);
|
|
14
|
+
context.__s3RegionRedirect = actualRegion;
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
throw new Error("Region redirect failed: " + e);
|
|
18
|
+
}
|
|
19
|
+
return next(args);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export const regionRedirectMiddlewareOptions = {
|
|
28
|
+
step: "initialize",
|
|
29
|
+
tags: ["REGION_REDIRECT", "S3"],
|
|
30
|
+
name: "regionRedirectMiddleware",
|
|
31
|
+
override: true,
|
|
32
|
+
};
|
|
33
|
+
export const getRegionRedirectMiddlewarePlugin = (clientConfig) => ({
|
|
34
|
+
applyToStack: (clientStack) => {
|
|
35
|
+
clientStack.add(regionRedirectMiddleware(clientConfig), regionRedirectMiddlewareOptions);
|
|
36
|
+
clientStack.addRelativeTo(regionRedirectEndpointMiddleware(clientConfig), regionRedirectEndpointMiddlewareOptions);
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -3,4 +3,5 @@ export const resolveS3Config = (input) => ({
|
|
|
3
3
|
forcePathStyle: input.forcePathStyle ?? false,
|
|
4
4
|
useAccelerateEndpoint: input.useAccelerateEndpoint ?? false,
|
|
5
5
|
disableMultiregionAccessPoints: input.disableMultiregionAccessPoints ?? false,
|
|
6
|
+
followRegionRedirects: input.followRegionRedirects ?? false,
|
|
6
7
|
});
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./check-content-length-header";
|
|
2
|
+
export * from "./region-redirect-endpoint-middleware";
|
|
3
|
+
export * from "./region-redirect-middleware";
|
|
2
4
|
export * from "./s3Configuration";
|
|
3
5
|
export * from "./throw-200-exceptions";
|
|
4
6
|
export * from "./validate-bucket-name";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RelativeMiddlewareOptions, SerializeMiddleware } from "@smithy/types";
|
|
2
|
+
import { PreviouslyResolved } from "./region-redirect-middleware";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare const regionRedirectEndpointMiddleware: (config: PreviouslyResolved) => SerializeMiddleware<any, any>;
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const regionRedirectEndpointMiddlewareOptions: RelativeMiddlewareOptions;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InitializeHandlerOptions, InitializeMiddleware, Pluggable, Provider } from "@smithy/types";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export interface PreviouslyResolved {
|
|
6
|
+
region: Provider<string>;
|
|
7
|
+
followRegionRedirects: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function regionRedirectMiddleware(clientConfig: PreviouslyResolved): InitializeMiddleware<any, any>;
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare const regionRedirectMiddlewareOptions: InitializeHandlerOptions;
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare const getRegionRedirectMiddlewarePlugin: (clientConfig: PreviouslyResolved) => Pluggable<any, any>;
|
|
@@ -17,10 +17,18 @@ export interface S3InputConfig {
|
|
|
17
17
|
* Whether multi-region access points (MRAP) should be disabled.
|
|
18
18
|
*/
|
|
19
19
|
disableMultiregionAccessPoints?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* This feature was previously called the S3 Global Client.
|
|
22
|
+
* This can result in additional latency as failed requests are retried
|
|
23
|
+
* with a corrected region when receiving a permanent redirect error with status 301.
|
|
24
|
+
* This feature should only be used as a last resort if you do not know the region of your bucket(s) ahead of time.
|
|
25
|
+
*/
|
|
26
|
+
followRegionRedirects?: boolean;
|
|
20
27
|
}
|
|
21
28
|
export interface S3ResolvedConfig {
|
|
22
29
|
forcePathStyle: boolean;
|
|
23
30
|
useAccelerateEndpoint: boolean;
|
|
24
31
|
disableMultiregionAccessPoints: boolean;
|
|
32
|
+
followRegionRedirects: boolean;
|
|
25
33
|
}
|
|
26
34
|
export declare const resolveS3Config: <T>(input: T & S3InputConfig) => T & S3ResolvedConfig;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./check-content-length-header";
|
|
2
|
+
export * from "./region-redirect-endpoint-middleware";
|
|
3
|
+
export * from "./region-redirect-middleware";
|
|
2
4
|
export * from "./s3Configuration";
|
|
3
5
|
export * from "./throw-200-exceptions";
|
|
4
6
|
export * from "./validate-bucket-name";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RelativeMiddlewareOptions, SerializeMiddleware } from "@smithy/types";
|
|
2
|
+
import { PreviouslyResolved } from "./region-redirect-middleware";
|
|
3
|
+
export declare const regionRedirectEndpointMiddleware: (
|
|
4
|
+
config: PreviouslyResolved
|
|
5
|
+
) => SerializeMiddleware<any, any>;
|
|
6
|
+
export declare const regionRedirectEndpointMiddlewareOptions: RelativeMiddlewareOptions;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InitializeHandlerOptions,
|
|
3
|
+
InitializeMiddleware,
|
|
4
|
+
Pluggable,
|
|
5
|
+
Provider,
|
|
6
|
+
} from "@smithy/types";
|
|
7
|
+
export interface PreviouslyResolved {
|
|
8
|
+
region: Provider<string>;
|
|
9
|
+
followRegionRedirects: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function regionRedirectMiddleware(
|
|
12
|
+
clientConfig: PreviouslyResolved
|
|
13
|
+
): InitializeMiddleware<any, any>;
|
|
14
|
+
export declare const regionRedirectMiddlewareOptions: InitializeHandlerOptions;
|
|
15
|
+
export declare const getRegionRedirectMiddlewarePlugin: (
|
|
16
|
+
clientConfig: PreviouslyResolved
|
|
17
|
+
) => Pluggable<any, any>;
|
|
@@ -2,11 +2,13 @@ export interface S3InputConfig {
|
|
|
2
2
|
forcePathStyle?: boolean;
|
|
3
3
|
useAccelerateEndpoint?: boolean;
|
|
4
4
|
disableMultiregionAccessPoints?: boolean;
|
|
5
|
+
followRegionRedirects?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export interface S3ResolvedConfig {
|
|
7
8
|
forcePathStyle: boolean;
|
|
8
9
|
useAccelerateEndpoint: boolean;
|
|
9
10
|
disableMultiregionAccessPoints: boolean;
|
|
11
|
+
followRegionRedirects: boolean;
|
|
10
12
|
}
|
|
11
13
|
export declare const resolveS3Config: <T>(
|
|
12
14
|
input: T & S3InputConfig
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-sdk-s3",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.428.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",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
|
|
12
12
|
"test": "jest",
|
|
13
13
|
"test:integration": "jest -c jest.config.integ.js",
|
|
14
|
+
"test:e2e": "jest -c jest.config.e2e.js",
|
|
14
15
|
"extract:docs": "api-extractor run --local"
|
|
15
16
|
},
|
|
16
17
|
"main": "./dist-cjs/index.js",
|
|
@@ -22,11 +23,11 @@
|
|
|
22
23
|
},
|
|
23
24
|
"license": "Apache-2.0",
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@aws-sdk/types": "3.
|
|
26
|
+
"@aws-sdk/types": "3.428.0",
|
|
26
27
|
"@aws-sdk/util-arn-parser": "3.310.0",
|
|
27
|
-
"@smithy/protocol-http": "^3.0.
|
|
28
|
-
"@smithy/smithy-client": "^2.1.
|
|
29
|
-
"@smithy/types": "^2.3.
|
|
28
|
+
"@smithy/protocol-http": "^3.0.7",
|
|
29
|
+
"@smithy/smithy-client": "^2.1.11",
|
|
30
|
+
"@smithy/types": "^2.3.5",
|
|
30
31
|
"tslib": "^2.5.0"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|