@aws-sdk/middleware-bucket-endpoint 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 +8 -0
- package/dist-es/NodeDisableMultiregionAccessPointConfigOptions.js +9 -5
- package/dist-es/NodeUseArnRegionConfigOptions.js +7 -5
- package/dist-es/bucketEndpointMiddleware.js +101 -68
- package/dist-es/bucketHostname.js +59 -53
- package/dist-es/bucketHostnameUtils.js +56 -48
- package/dist-es/configurations.js +4 -10
- package/package.json +7 -7
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-bucket-endpoint
|
|
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-bucket-endpoint
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { booleanSelector, SelectorType } from "@aws-sdk/util-config-provider";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
environmentVariableSelector: (env)
|
|
6
|
-
|
|
2
|
+
export var NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME = "AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS";
|
|
3
|
+
export var NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME = "s3_disable_multiregion_access_points";
|
|
4
|
+
export var NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS = {
|
|
5
|
+
environmentVariableSelector: function (env) {
|
|
6
|
+
return booleanSelector(env, NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME, SelectorType.ENV);
|
|
7
|
+
},
|
|
8
|
+
configFileSelector: function (profile) {
|
|
9
|
+
return booleanSelector(profile, NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME, SelectorType.CONFIG);
|
|
10
|
+
},
|
|
7
11
|
default: false,
|
|
8
12
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { booleanSelector, SelectorType } from "@aws-sdk/util-config-provider";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
environmentVariableSelector: (env)
|
|
6
|
-
|
|
2
|
+
export var NODE_USE_ARN_REGION_ENV_NAME = "AWS_S3_USE_ARN_REGION";
|
|
3
|
+
export var NODE_USE_ARN_REGION_INI_NAME = "s3_use_arn_region";
|
|
4
|
+
export var NODE_USE_ARN_REGION_CONFIG_OPTIONS = {
|
|
5
|
+
environmentVariableSelector: function (env) {
|
|
6
|
+
return booleanSelector(env, NODE_USE_ARN_REGION_ENV_NAME, SelectorType.ENV);
|
|
7
|
+
},
|
|
8
|
+
configFileSelector: function (profile) { return booleanSelector(profile, NODE_USE_ARN_REGION_INI_NAME, SelectorType.CONFIG); },
|
|
7
9
|
default: false,
|
|
8
10
|
};
|
|
@@ -1,81 +1,114 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator } from "tslib";
|
|
1
2
|
import { HttpRequest } from "@aws-sdk/protocol-http";
|
|
2
3
|
import { parse as parseArn, validate as validateArn } from "@aws-sdk/util-arn-parser";
|
|
3
4
|
import { bucketHostname } from "./bucketHostname";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
5
|
+
export var bucketEndpointMiddleware = function (options) {
|
|
6
|
+
return function (next, context) {
|
|
7
|
+
return function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8
|
+
var bucketName, replaceBucketInPath, request, bucketArn, clientRegion, useDualstackEndpoint, useFipsEndpoint, _a, partition, _b, signingRegion, useArnRegion, _c, hostname, bucketEndpoint, modifiedSigningRegion, signingService, _d, clientRegion, dualstackEndpoint, fipsEndpoint, _e, hostname, bucketEndpoint;
|
|
9
|
+
var _f;
|
|
10
|
+
return __generator(this, function (_g) {
|
|
11
|
+
switch (_g.label) {
|
|
12
|
+
case 0:
|
|
13
|
+
bucketName = args.input.Bucket;
|
|
14
|
+
replaceBucketInPath = options.bucketEndpoint;
|
|
15
|
+
request = args.request;
|
|
16
|
+
if (!HttpRequest.isInstance(request)) return [3, 13];
|
|
17
|
+
if (!options.bucketEndpoint) return [3, 1];
|
|
18
|
+
request.hostname = bucketName;
|
|
19
|
+
return [3, 12];
|
|
20
|
+
case 1:
|
|
21
|
+
if (!validateArn(bucketName)) return [3, 8];
|
|
22
|
+
bucketArn = parseArn(bucketName);
|
|
23
|
+
return [4, options.region()];
|
|
24
|
+
case 2:
|
|
25
|
+
clientRegion = _g.sent();
|
|
26
|
+
return [4, options.useDualstackEndpoint()];
|
|
27
|
+
case 3:
|
|
28
|
+
useDualstackEndpoint = _g.sent();
|
|
29
|
+
return [4, options.useFipsEndpoint()];
|
|
30
|
+
case 4:
|
|
31
|
+
useFipsEndpoint = _g.sent();
|
|
32
|
+
return [4, options.regionInfoProvider(clientRegion, { useDualstackEndpoint: useDualstackEndpoint, useFipsEndpoint: useFipsEndpoint })];
|
|
33
|
+
case 5:
|
|
34
|
+
_a = (_g.sent()) || {}, partition = _a.partition, _b = _a.signingRegion, signingRegion = _b === void 0 ? clientRegion : _b;
|
|
35
|
+
return [4, options.useArnRegion()];
|
|
36
|
+
case 6:
|
|
37
|
+
useArnRegion = _g.sent();
|
|
38
|
+
_d = bucketHostname;
|
|
39
|
+
_f = {
|
|
40
|
+
bucketName: bucketArn,
|
|
41
|
+
baseHostname: request.hostname,
|
|
42
|
+
accelerateEndpoint: options.useAccelerateEndpoint,
|
|
43
|
+
dualstackEndpoint: useDualstackEndpoint,
|
|
44
|
+
fipsEndpoint: useFipsEndpoint,
|
|
45
|
+
pathStyleEndpoint: options.forcePathStyle,
|
|
46
|
+
tlsCompatible: request.protocol === "https:",
|
|
47
|
+
useArnRegion: useArnRegion,
|
|
48
|
+
clientPartition: partition,
|
|
49
|
+
clientSigningRegion: signingRegion,
|
|
50
|
+
clientRegion: clientRegion,
|
|
51
|
+
isCustomEndpoint: options.isCustomEndpoint
|
|
52
|
+
};
|
|
53
|
+
return [4, options.disableMultiregionAccessPoints()];
|
|
54
|
+
case 7:
|
|
55
|
+
_c = _d.apply(void 0, [(_f.disableMultiregionAccessPoints = _g.sent(),
|
|
56
|
+
_f)]), hostname = _c.hostname, bucketEndpoint = _c.bucketEndpoint, modifiedSigningRegion = _c.signingRegion, signingService = _c.signingService;
|
|
57
|
+
if (modifiedSigningRegion && modifiedSigningRegion !== signingRegion) {
|
|
58
|
+
context["signing_region"] = modifiedSigningRegion;
|
|
59
|
+
}
|
|
60
|
+
if (signingService && signingService !== "s3") {
|
|
61
|
+
context["signing_service"] = signingService;
|
|
62
|
+
}
|
|
63
|
+
request.hostname = hostname;
|
|
64
|
+
replaceBucketInPath = bucketEndpoint;
|
|
65
|
+
return [3, 12];
|
|
66
|
+
case 8: return [4, options.region()];
|
|
67
|
+
case 9:
|
|
68
|
+
clientRegion = _g.sent();
|
|
69
|
+
return [4, options.useDualstackEndpoint()];
|
|
70
|
+
case 10:
|
|
71
|
+
dualstackEndpoint = _g.sent();
|
|
72
|
+
return [4, options.useFipsEndpoint()];
|
|
73
|
+
case 11:
|
|
74
|
+
fipsEndpoint = _g.sent();
|
|
75
|
+
_e = bucketHostname({
|
|
76
|
+
bucketName: bucketName,
|
|
77
|
+
clientRegion: clientRegion,
|
|
78
|
+
baseHostname: request.hostname,
|
|
79
|
+
accelerateEndpoint: options.useAccelerateEndpoint,
|
|
80
|
+
dualstackEndpoint: dualstackEndpoint,
|
|
81
|
+
fipsEndpoint: fipsEndpoint,
|
|
82
|
+
pathStyleEndpoint: options.forcePathStyle,
|
|
83
|
+
tlsCompatible: request.protocol === "https:",
|
|
84
|
+
isCustomEndpoint: options.isCustomEndpoint,
|
|
85
|
+
}), hostname = _e.hostname, bucketEndpoint = _e.bucketEndpoint;
|
|
86
|
+
request.hostname = hostname;
|
|
87
|
+
replaceBucketInPath = bucketEndpoint;
|
|
88
|
+
_g.label = 12;
|
|
89
|
+
case 12:
|
|
90
|
+
if (replaceBucketInPath) {
|
|
91
|
+
request.path = request.path.replace(/^(\/)?[^\/]+/, "");
|
|
92
|
+
if (request.path === "") {
|
|
93
|
+
request.path = "/";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
_g.label = 13;
|
|
97
|
+
case 13: return [2, next(__assign(__assign({}, args), { request: request }))];
|
|
98
|
+
}
|
|
33
99
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
if (signingService && signingService !== "s3") {
|
|
38
|
-
context["signing_service"] = signingService;
|
|
39
|
-
}
|
|
40
|
-
request.hostname = hostname;
|
|
41
|
-
replaceBucketInPath = bucketEndpoint;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
const clientRegion = await options.region();
|
|
45
|
-
const dualstackEndpoint = await options.useDualstackEndpoint();
|
|
46
|
-
const fipsEndpoint = await options.useFipsEndpoint();
|
|
47
|
-
const { hostname, bucketEndpoint } = bucketHostname({
|
|
48
|
-
bucketName,
|
|
49
|
-
clientRegion,
|
|
50
|
-
baseHostname: request.hostname,
|
|
51
|
-
accelerateEndpoint: options.useAccelerateEndpoint,
|
|
52
|
-
dualstackEndpoint,
|
|
53
|
-
fipsEndpoint,
|
|
54
|
-
pathStyleEndpoint: options.forcePathStyle,
|
|
55
|
-
tlsCompatible: request.protocol === "https:",
|
|
56
|
-
isCustomEndpoint: options.isCustomEndpoint,
|
|
57
|
-
});
|
|
58
|
-
request.hostname = hostname;
|
|
59
|
-
replaceBucketInPath = bucketEndpoint;
|
|
60
|
-
}
|
|
61
|
-
if (replaceBucketInPath) {
|
|
62
|
-
request.path = request.path.replace(/^(\/)?[^\/]+/, "");
|
|
63
|
-
if (request.path === "") {
|
|
64
|
-
request.path = "/";
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return next({ ...args, request });
|
|
100
|
+
}); };
|
|
101
|
+
};
|
|
69
102
|
};
|
|
70
|
-
export
|
|
103
|
+
export var bucketEndpointMiddlewareOptions = {
|
|
71
104
|
tags: ["BUCKET_ENDPOINT"],
|
|
72
105
|
name: "bucketEndpointMiddleware",
|
|
73
106
|
relation: "before",
|
|
74
107
|
toMiddleware: "hostHeaderMiddleware",
|
|
75
108
|
override: true,
|
|
76
109
|
};
|
|
77
|
-
export
|
|
78
|
-
applyToStack: (clientStack)
|
|
110
|
+
export var getBucketEndpointPlugin = function (options) { return ({
|
|
111
|
+
applyToStack: function (clientStack) {
|
|
79
112
|
clientStack.addRelativeTo(bucketEndpointMiddleware(options), bucketEndpointMiddlewareOptions);
|
|
80
113
|
},
|
|
81
|
-
});
|
|
114
|
+
}); };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { __assign, __read } from "tslib";
|
|
1
2
|
import { DOT_PATTERN, getArnResources, getSuffix, getSuffixForArnEndpoint, isBucketNameOptions, isDnsCompatibleBucketName, validateAccountId, validateArnEndpointOptions, validateCustomEndpoint, validateDNSHostLabel, validateMrapAlias, validateNoDualstack, validateNoFIPS, validateOutpostService, validatePartition, validateRegion, validateRegionalClient, validateS3Service, validateService, } from "./bucketHostnameUtils";
|
|
2
|
-
export
|
|
3
|
+
export var bucketHostname = function (options) {
|
|
3
4
|
validateCustomEndpoint(options);
|
|
4
5
|
return isBucketNameOptions(options)
|
|
5
6
|
?
|
|
@@ -7,69 +8,72 @@ export const bucketHostname = (options) => {
|
|
|
7
8
|
:
|
|
8
9
|
getEndpointFromArn(options);
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
var getEndpointFromBucketName = function (_a) {
|
|
12
|
+
var _b = _a.accelerateEndpoint, accelerateEndpoint = _b === void 0 ? false : _b, region = _a.clientRegion, baseHostname = _a.baseHostname, bucketName = _a.bucketName, _c = _a.dualstackEndpoint, dualstackEndpoint = _c === void 0 ? false : _c, _d = _a.fipsEndpoint, fipsEndpoint = _d === void 0 ? false : _d, _e = _a.pathStyleEndpoint, pathStyleEndpoint = _e === void 0 ? false : _e, _f = _a.tlsCompatible, tlsCompatible = _f === void 0 ? true : _f, _g = _a.isCustomEndpoint, isCustomEndpoint = _g === void 0 ? false : _g;
|
|
13
|
+
var _h = __read(isCustomEndpoint ? [region, baseHostname] : getSuffix(baseHostname), 2), clientRegion = _h[0], hostnameSuffix = _h[1];
|
|
12
14
|
if (pathStyleEndpoint || !isDnsCompatibleBucketName(bucketName) || (tlsCompatible && DOT_PATTERN.test(bucketName))) {
|
|
13
15
|
return {
|
|
14
16
|
bucketEndpoint: false,
|
|
15
|
-
hostname: dualstackEndpoint ?
|
|
17
|
+
hostname: dualstackEndpoint ? "s3.dualstack.".concat(clientRegion, ".").concat(hostnameSuffix) : baseHostname,
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
if (accelerateEndpoint) {
|
|
19
|
-
baseHostname =
|
|
21
|
+
baseHostname = "s3-accelerate".concat(dualstackEndpoint ? ".dualstack" : "", ".").concat(hostnameSuffix);
|
|
20
22
|
}
|
|
21
23
|
else if (dualstackEndpoint) {
|
|
22
|
-
baseHostname =
|
|
24
|
+
baseHostname = "s3.dualstack.".concat(clientRegion, ".").concat(hostnameSuffix);
|
|
23
25
|
}
|
|
24
26
|
return {
|
|
25
27
|
bucketEndpoint: true,
|
|
26
|
-
hostname:
|
|
28
|
+
hostname: "".concat(bucketName, ".").concat(baseHostname),
|
|
27
29
|
};
|
|
28
30
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
validateArnEndpointOptions({ pathStyleEndpoint, accelerateEndpoint, tlsCompatible });
|
|
34
|
-
|
|
31
|
+
var getEndpointFromArn = function (options) {
|
|
32
|
+
var isCustomEndpoint = options.isCustomEndpoint, baseHostname = options.baseHostname, clientRegion = options.clientRegion;
|
|
33
|
+
var hostnameSuffix = isCustomEndpoint ? baseHostname : getSuffixForArnEndpoint(baseHostname)[1];
|
|
34
|
+
var pathStyleEndpoint = options.pathStyleEndpoint, _a = options.accelerateEndpoint, accelerateEndpoint = _a === void 0 ? false : _a, _b = options.fipsEndpoint, fipsEndpoint = _b === void 0 ? false : _b, _c = options.tlsCompatible, tlsCompatible = _c === void 0 ? true : _c, bucketName = options.bucketName, _d = options.clientPartition, clientPartition = _d === void 0 ? "aws" : _d;
|
|
35
|
+
validateArnEndpointOptions({ pathStyleEndpoint: pathStyleEndpoint, accelerateEndpoint: accelerateEndpoint, tlsCompatible: tlsCompatible });
|
|
36
|
+
var service = bucketName.service, partition = bucketName.partition, accountId = bucketName.accountId, region = bucketName.region, resource = bucketName.resource;
|
|
35
37
|
validateService(service);
|
|
36
|
-
validatePartition(partition, { clientPartition });
|
|
38
|
+
validatePartition(partition, { clientPartition: clientPartition });
|
|
37
39
|
validateAccountId(accountId);
|
|
38
|
-
|
|
40
|
+
var _e = getArnResources(resource), accesspointName = _e.accesspointName, outpostId = _e.outpostId;
|
|
39
41
|
if (service === "s3-object-lambda") {
|
|
40
|
-
return getEndpointFromObjectLambdaArn({
|
|
42
|
+
return getEndpointFromObjectLambdaArn(__assign(__assign({}, options), { tlsCompatible: tlsCompatible, bucketName: bucketName, accesspointName: accesspointName, hostnameSuffix: hostnameSuffix }));
|
|
41
43
|
}
|
|
42
44
|
if (region === "") {
|
|
43
|
-
return getEndpointFromMRAPArn({
|
|
45
|
+
return getEndpointFromMRAPArn(__assign(__assign({}, options), { clientRegion: clientRegion, mrapAlias: accesspointName, hostnameSuffix: hostnameSuffix }));
|
|
44
46
|
}
|
|
45
47
|
if (outpostId) {
|
|
46
|
-
return getEndpointFromOutpostArn({
|
|
48
|
+
return getEndpointFromOutpostArn(__assign(__assign({}, options), { clientRegion: clientRegion, outpostId: outpostId, accesspointName: accesspointName, hostnameSuffix: hostnameSuffix }));
|
|
47
49
|
}
|
|
48
|
-
return getEndpointFromAccessPointArn({
|
|
50
|
+
return getEndpointFromAccessPointArn(__assign(__assign({}, options), { clientRegion: clientRegion, accesspointName: accesspointName, hostnameSuffix: hostnameSuffix }));
|
|
49
51
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
var getEndpointFromObjectLambdaArn = function (_a) {
|
|
53
|
+
var _b = _a.dualstackEndpoint, dualstackEndpoint = _b === void 0 ? false : _b, _c = _a.fipsEndpoint, fipsEndpoint = _c === void 0 ? false : _c, _d = _a.tlsCompatible, tlsCompatible = _d === void 0 ? true : _d, useArnRegion = _a.useArnRegion, clientRegion = _a.clientRegion, _e = _a.clientSigningRegion, clientSigningRegion = _e === void 0 ? clientRegion : _e, accesspointName = _a.accesspointName, bucketName = _a.bucketName, hostnameSuffix = _a.hostnameSuffix;
|
|
54
|
+
var accountId = bucketName.accountId, region = bucketName.region, service = bucketName.service;
|
|
52
55
|
validateRegionalClient(clientRegion);
|
|
53
56
|
validateRegion(region, {
|
|
54
|
-
useArnRegion,
|
|
55
|
-
clientRegion,
|
|
56
|
-
clientSigningRegion,
|
|
57
|
+
useArnRegion: useArnRegion,
|
|
58
|
+
clientRegion: clientRegion,
|
|
59
|
+
clientSigningRegion: clientSigningRegion,
|
|
57
60
|
allowFipsRegion: true,
|
|
58
61
|
useFipsEndpoint: fipsEndpoint,
|
|
59
62
|
});
|
|
60
63
|
validateNoDualstack(dualstackEndpoint);
|
|
61
|
-
|
|
62
|
-
validateDNSHostLabel(DNSHostLabel, { tlsCompatible });
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
var DNSHostLabel = "".concat(accesspointName, "-").concat(accountId);
|
|
65
|
+
validateDNSHostLabel(DNSHostLabel, { tlsCompatible: tlsCompatible });
|
|
66
|
+
var endpointRegion = useArnRegion ? region : clientRegion;
|
|
67
|
+
var signingRegion = useArnRegion ? region : clientSigningRegion;
|
|
65
68
|
return {
|
|
66
69
|
bucketEndpoint: true,
|
|
67
|
-
hostname:
|
|
68
|
-
signingRegion,
|
|
70
|
+
hostname: "".concat(DNSHostLabel, ".").concat(service).concat(fipsEndpoint ? "-fips" : "", ".").concat(endpointRegion, ".").concat(hostnameSuffix),
|
|
71
|
+
signingRegion: signingRegion,
|
|
69
72
|
signingService: service,
|
|
70
73
|
};
|
|
71
74
|
};
|
|
72
|
-
|
|
75
|
+
var getEndpointFromMRAPArn = function (_a) {
|
|
76
|
+
var disableMultiregionAccessPoints = _a.disableMultiregionAccessPoints, _b = _a.dualstackEndpoint, dualstackEndpoint = _b === void 0 ? false : _b, isCustomEndpoint = _a.isCustomEndpoint, mrapAlias = _a.mrapAlias, hostnameSuffix = _a.hostnameSuffix;
|
|
73
77
|
if (disableMultiregionAccessPoints === true) {
|
|
74
78
|
throw new Error("SDK is attempting to use a MRAP ARN. Please enable to feature.");
|
|
75
79
|
}
|
|
@@ -77,48 +81,50 @@ const getEndpointFromMRAPArn = ({ disableMultiregionAccessPoints, dualstackEndpo
|
|
|
77
81
|
validateNoDualstack(dualstackEndpoint);
|
|
78
82
|
return {
|
|
79
83
|
bucketEndpoint: true,
|
|
80
|
-
hostname:
|
|
84
|
+
hostname: "".concat(mrapAlias).concat(isCustomEndpoint ? "" : ".accesspoint.s3-global", ".").concat(hostnameSuffix),
|
|
81
85
|
signingRegion: "*",
|
|
82
86
|
};
|
|
83
87
|
};
|
|
84
|
-
|
|
88
|
+
var getEndpointFromOutpostArn = function (_a) {
|
|
89
|
+
var useArnRegion = _a.useArnRegion, clientRegion = _a.clientRegion, _b = _a.clientSigningRegion, clientSigningRegion = _b === void 0 ? clientRegion : _b, bucketName = _a.bucketName, outpostId = _a.outpostId, _c = _a.dualstackEndpoint, dualstackEndpoint = _c === void 0 ? false : _c, _d = _a.fipsEndpoint, fipsEndpoint = _d === void 0 ? false : _d, _e = _a.tlsCompatible, tlsCompatible = _e === void 0 ? true : _e, accesspointName = _a.accesspointName, isCustomEndpoint = _a.isCustomEndpoint, hostnameSuffix = _a.hostnameSuffix;
|
|
85
90
|
validateRegionalClient(clientRegion);
|
|
86
|
-
validateRegion(bucketName.region, { useArnRegion, clientRegion, clientSigningRegion, useFipsEndpoint: fipsEndpoint });
|
|
87
|
-
|
|
88
|
-
validateDNSHostLabel(DNSHostLabel, { tlsCompatible });
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
validateRegion(bucketName.region, { useArnRegion: useArnRegion, clientRegion: clientRegion, clientSigningRegion: clientSigningRegion, useFipsEndpoint: fipsEndpoint });
|
|
92
|
+
var DNSHostLabel = "".concat(accesspointName, "-").concat(bucketName.accountId);
|
|
93
|
+
validateDNSHostLabel(DNSHostLabel, { tlsCompatible: tlsCompatible });
|
|
94
|
+
var endpointRegion = useArnRegion ? bucketName.region : clientRegion;
|
|
95
|
+
var signingRegion = useArnRegion ? bucketName.region : clientSigningRegion;
|
|
91
96
|
validateOutpostService(bucketName.service);
|
|
92
|
-
validateDNSHostLabel(outpostId, { tlsCompatible });
|
|
97
|
+
validateDNSHostLabel(outpostId, { tlsCompatible: tlsCompatible });
|
|
93
98
|
validateNoDualstack(dualstackEndpoint);
|
|
94
99
|
validateNoFIPS(fipsEndpoint);
|
|
95
|
-
|
|
100
|
+
var hostnamePrefix = "".concat(DNSHostLabel, ".").concat(outpostId);
|
|
96
101
|
return {
|
|
97
102
|
bucketEndpoint: true,
|
|
98
|
-
hostname:
|
|
99
|
-
signingRegion,
|
|
103
|
+
hostname: "".concat(hostnamePrefix).concat(isCustomEndpoint ? "" : ".s3-outposts.".concat(endpointRegion), ".").concat(hostnameSuffix),
|
|
104
|
+
signingRegion: signingRegion,
|
|
100
105
|
signingService: "s3-outposts",
|
|
101
106
|
};
|
|
102
107
|
};
|
|
103
|
-
|
|
108
|
+
var getEndpointFromAccessPointArn = function (_a) {
|
|
109
|
+
var useArnRegion = _a.useArnRegion, clientRegion = _a.clientRegion, _b = _a.clientSigningRegion, clientSigningRegion = _b === void 0 ? clientRegion : _b, bucketName = _a.bucketName, _c = _a.dualstackEndpoint, dualstackEndpoint = _c === void 0 ? false : _c, _d = _a.fipsEndpoint, fipsEndpoint = _d === void 0 ? false : _d, _e = _a.tlsCompatible, tlsCompatible = _e === void 0 ? true : _e, accesspointName = _a.accesspointName, isCustomEndpoint = _a.isCustomEndpoint, hostnameSuffix = _a.hostnameSuffix;
|
|
104
110
|
validateRegionalClient(clientRegion);
|
|
105
111
|
validateRegion(bucketName.region, {
|
|
106
|
-
useArnRegion,
|
|
107
|
-
clientRegion,
|
|
108
|
-
clientSigningRegion,
|
|
112
|
+
useArnRegion: useArnRegion,
|
|
113
|
+
clientRegion: clientRegion,
|
|
114
|
+
clientSigningRegion: clientSigningRegion,
|
|
109
115
|
allowFipsRegion: true,
|
|
110
116
|
useFipsEndpoint: fipsEndpoint,
|
|
111
117
|
});
|
|
112
|
-
|
|
113
|
-
validateDNSHostLabel(hostnamePrefix, { tlsCompatible });
|
|
114
|
-
|
|
115
|
-
|
|
118
|
+
var hostnamePrefix = "".concat(accesspointName, "-").concat(bucketName.accountId);
|
|
119
|
+
validateDNSHostLabel(hostnamePrefix, { tlsCompatible: tlsCompatible });
|
|
120
|
+
var endpointRegion = useArnRegion ? bucketName.region : clientRegion;
|
|
121
|
+
var signingRegion = useArnRegion ? bucketName.region : clientSigningRegion;
|
|
116
122
|
validateS3Service(bucketName.service);
|
|
117
123
|
return {
|
|
118
124
|
bucketEndpoint: true,
|
|
119
|
-
hostname:
|
|
125
|
+
hostname: "".concat(hostnamePrefix).concat(isCustomEndpoint
|
|
120
126
|
? ""
|
|
121
|
-
:
|
|
122
|
-
signingRegion,
|
|
127
|
+
: ".s3-accesspoint".concat(fipsEndpoint ? "-fips" : "").concat(dualstackEndpoint ? ".dualstack" : "", ".").concat(endpointRegion), ".").concat(hostnameSuffix),
|
|
128
|
+
signingRegion: signingRegion,
|
|
123
129
|
};
|
|
124
130
|
};
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { __read } from "tslib";
|
|
2
|
+
var DOMAIN_PATTERN = /^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/;
|
|
3
|
+
var IP_ADDRESS_PATTERN = /(\d+\.){3}\d+/;
|
|
4
|
+
var DOTS_PATTERN = /\.\./;
|
|
5
|
+
export var DOT_PATTERN = /\./;
|
|
6
|
+
export var S3_HOSTNAME_PATTERN = /^(.+\.)?s3(-fips)?(\.dualstack)?[.-]([a-z0-9-]+)\./;
|
|
7
|
+
var S3_US_EAST_1_ALTNAME_PATTERN = /^s3(-external-1)?\.amazonaws\.com$/;
|
|
8
|
+
var AWS_PARTITION_SUFFIX = "amazonaws.com";
|
|
9
|
+
export var isBucketNameOptions = function (options) { return typeof options.bucketName === "string"; };
|
|
10
|
+
export var isDnsCompatibleBucketName = function (bucketName) {
|
|
11
|
+
return DOMAIN_PATTERN.test(bucketName) && !IP_ADDRESS_PATTERN.test(bucketName) && !DOTS_PATTERN.test(bucketName);
|
|
12
|
+
};
|
|
13
|
+
var getRegionalSuffix = function (hostname) {
|
|
14
|
+
var parts = hostname.match(S3_HOSTNAME_PATTERN);
|
|
15
|
+
return [parts[4], hostname.replace(new RegExp("^".concat(parts[0])), "")];
|
|
16
|
+
};
|
|
17
|
+
export var getSuffix = function (hostname) {
|
|
18
|
+
return S3_US_EAST_1_ALTNAME_PATTERN.test(hostname) ? ["us-east-1", AWS_PARTITION_SUFFIX] : getRegionalSuffix(hostname);
|
|
19
|
+
};
|
|
20
|
+
export var getSuffixForArnEndpoint = function (hostname) {
|
|
21
|
+
return S3_US_EAST_1_ALTNAME_PATTERN.test(hostname)
|
|
22
|
+
? [hostname.replace(".".concat(AWS_PARTITION_SUFFIX), ""), AWS_PARTITION_SUFFIX]
|
|
23
|
+
: getRegionalSuffix(hostname);
|
|
24
|
+
};
|
|
25
|
+
export var validateArnEndpointOptions = function (options) {
|
|
19
26
|
if (options.pathStyleEndpoint) {
|
|
20
27
|
throw new Error("Path-style S3 endpoint is not supported when bucket is an ARN");
|
|
21
28
|
}
|
|
@@ -26,27 +33,27 @@ export const validateArnEndpointOptions = (options) => {
|
|
|
26
33
|
throw new Error("HTTPS is required when bucket is an ARN");
|
|
27
34
|
}
|
|
28
35
|
};
|
|
29
|
-
export
|
|
36
|
+
export var validateService = function (service) {
|
|
30
37
|
if (service !== "s3" && service !== "s3-outposts" && service !== "s3-object-lambda") {
|
|
31
38
|
throw new Error("Expect 's3' or 's3-outposts' or 's3-object-lambda' in ARN service component");
|
|
32
39
|
}
|
|
33
40
|
};
|
|
34
|
-
export
|
|
41
|
+
export var validateS3Service = function (service) {
|
|
35
42
|
if (service !== "s3") {
|
|
36
43
|
throw new Error("Expect 's3' in Accesspoint ARN service component");
|
|
37
44
|
}
|
|
38
45
|
};
|
|
39
|
-
export
|
|
46
|
+
export var validateOutpostService = function (service) {
|
|
40
47
|
if (service !== "s3-outposts") {
|
|
41
48
|
throw new Error("Expect 's3-posts' in Outpost ARN service component");
|
|
42
49
|
}
|
|
43
50
|
};
|
|
44
|
-
export
|
|
51
|
+
export var validatePartition = function (partition, options) {
|
|
45
52
|
if (partition !== options.clientPartition) {
|
|
46
|
-
throw new Error(
|
|
53
|
+
throw new Error("Partition in ARN is incompatible, got \"".concat(partition, "\" but expected \"").concat(options.clientPartition, "\""));
|
|
47
54
|
}
|
|
48
55
|
};
|
|
49
|
-
export
|
|
56
|
+
export var validateRegion = function (region, options) {
|
|
50
57
|
if (region === "") {
|
|
51
58
|
throw new Error("ARN region is empty");
|
|
52
59
|
}
|
|
@@ -55,36 +62,37 @@ export const validateRegion = (region, options) => {
|
|
|
55
62
|
throw new Error("FIPS region is not supported");
|
|
56
63
|
}
|
|
57
64
|
else if (!isEqualRegions(region, options.clientRegion)) {
|
|
58
|
-
throw new Error(
|
|
65
|
+
throw new Error("Client FIPS region ".concat(options.clientRegion, " doesn't match region ").concat(region, " in ARN"));
|
|
59
66
|
}
|
|
60
67
|
}
|
|
61
68
|
if (!options.useArnRegion &&
|
|
62
69
|
!isEqualRegions(region, options.clientRegion || "") &&
|
|
63
70
|
!isEqualRegions(region, options.clientSigningRegion || "")) {
|
|
64
|
-
throw new Error(
|
|
71
|
+
throw new Error("Region in ARN is incompatible, got ".concat(region, " but expected ").concat(options.clientRegion));
|
|
65
72
|
}
|
|
66
73
|
};
|
|
67
|
-
export
|
|
74
|
+
export var validateRegionalClient = function (region) {
|
|
68
75
|
if (["s3-external-1", "aws-global"].includes(region)) {
|
|
69
|
-
throw new Error(
|
|
76
|
+
throw new Error("Client region ".concat(region, " is not regional"));
|
|
70
77
|
}
|
|
71
78
|
};
|
|
72
|
-
|
|
73
|
-
export
|
|
79
|
+
var isEqualRegions = function (regionA, regionB) { return regionA === regionB; };
|
|
80
|
+
export var validateAccountId = function (accountId) {
|
|
74
81
|
if (!/[0-9]{12}/.exec(accountId)) {
|
|
75
82
|
throw new Error("Access point ARN accountID does not match regex '[0-9]{12}'");
|
|
76
83
|
}
|
|
77
84
|
};
|
|
78
|
-
export
|
|
85
|
+
export var validateDNSHostLabel = function (label, options) {
|
|
86
|
+
if (options === void 0) { options = { tlsCompatible: true }; }
|
|
79
87
|
if (label.length >= 64 ||
|
|
80
88
|
!/^[a-z0-9][a-z0-9.-]*[a-z0-9]$/.test(label) ||
|
|
81
89
|
/(\d+\.){3}\d+/.test(label) ||
|
|
82
90
|
/[.-]{2}/.test(label) ||
|
|
83
|
-
(options
|
|
84
|
-
throw new Error(
|
|
91
|
+
((options === null || options === void 0 ? void 0 : options.tlsCompatible) && DOT_PATTERN.test(label))) {
|
|
92
|
+
throw new Error("Invalid DNS label ".concat(label));
|
|
85
93
|
}
|
|
86
94
|
};
|
|
87
|
-
export
|
|
95
|
+
export var validateCustomEndpoint = function (options) {
|
|
88
96
|
if (options.isCustomEndpoint) {
|
|
89
97
|
if (options.dualstackEndpoint)
|
|
90
98
|
throw new Error("Dualstack endpoint is not supported with custom endpoint");
|
|
@@ -92,41 +100,41 @@ export const validateCustomEndpoint = (options) => {
|
|
|
92
100
|
throw new Error("Accelerate endpoint is not supported with custom endpoint");
|
|
93
101
|
}
|
|
94
102
|
};
|
|
95
|
-
export
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
export var getArnResources = function (resource) {
|
|
104
|
+
var delimiter = resource.includes(":") ? ":" : "/";
|
|
105
|
+
var _a = __read(resource.split(delimiter)), resourceType = _a[0], rest = _a.slice(1);
|
|
98
106
|
if (resourceType === "accesspoint") {
|
|
99
107
|
if (rest.length !== 1 || rest[0] === "") {
|
|
100
|
-
throw new Error(
|
|
108
|
+
throw new Error("Access Point ARN should have one resource accesspoint".concat(delimiter, "{accesspointname}"));
|
|
101
109
|
}
|
|
102
110
|
return { accesspointName: rest[0] };
|
|
103
111
|
}
|
|
104
112
|
else if (resourceType === "outpost") {
|
|
105
113
|
if (!rest[0] || rest[1] !== "accesspoint" || !rest[2] || rest.length !== 3) {
|
|
106
|
-
throw new Error(
|
|
114
|
+
throw new Error("Outpost ARN should have resource outpost".concat(delimiter, "{outpostId}").concat(delimiter, "accesspoint").concat(delimiter, "{accesspointName}"));
|
|
107
115
|
}
|
|
108
|
-
|
|
109
|
-
return { outpostId, accesspointName };
|
|
116
|
+
var _b = __read(rest, 3), outpostId = _b[0], _1 = _b[1], accesspointName = _b[2];
|
|
117
|
+
return { outpostId: outpostId, accesspointName: accesspointName };
|
|
110
118
|
}
|
|
111
119
|
else {
|
|
112
|
-
throw new Error(
|
|
120
|
+
throw new Error("ARN resource should begin with 'accesspoint".concat(delimiter, "' or 'outpost").concat(delimiter, "'"));
|
|
113
121
|
}
|
|
114
122
|
};
|
|
115
|
-
export
|
|
123
|
+
export var validateNoDualstack = function (dualstackEndpoint) {
|
|
116
124
|
if (dualstackEndpoint)
|
|
117
125
|
throw new Error("Dualstack endpoint is not supported with Outpost or Multi-region Access Point ARN.");
|
|
118
126
|
};
|
|
119
|
-
export
|
|
127
|
+
export var validateNoFIPS = function (useFipsEndpoint) {
|
|
120
128
|
if (useFipsEndpoint)
|
|
121
|
-
throw new Error(
|
|
129
|
+
throw new Error("FIPS region is not supported with Outpost.");
|
|
122
130
|
};
|
|
123
|
-
export
|
|
131
|
+
export var validateMrapAlias = function (name) {
|
|
124
132
|
try {
|
|
125
|
-
name.split(".").forEach((label)
|
|
133
|
+
name.split(".").forEach(function (label) {
|
|
126
134
|
validateDNSHostLabel(label);
|
|
127
135
|
});
|
|
128
136
|
}
|
|
129
137
|
catch (e) {
|
|
130
|
-
throw new Error(
|
|
138
|
+
throw new Error("\"".concat(name, "\" is not a DNS compatible name."));
|
|
131
139
|
}
|
|
132
140
|
};
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
export function resolveBucketEndpointConfig(input) {
|
|
2
|
-
|
|
3
|
-
return {
|
|
4
|
-
...input,
|
|
5
|
-
bucketEndpoint,
|
|
6
|
-
forcePathStyle,
|
|
7
|
-
useAccelerateEndpoint,
|
|
8
|
-
useArnRegion: typeof useArnRegion === "function" ? useArnRegion : () => Promise.resolve(useArnRegion),
|
|
9
|
-
disableMultiregionAccessPoints: typeof disableMultiregionAccessPoints === "function"
|
|
3
|
+
var _a = input.bucketEndpoint, bucketEndpoint = _a === void 0 ? false : _a, _b = input.forcePathStyle, forcePathStyle = _b === void 0 ? false : _b, _c = input.useAccelerateEndpoint, useAccelerateEndpoint = _c === void 0 ? false : _c, _d = input.useArnRegion, useArnRegion = _d === void 0 ? false : _d, _e = input.disableMultiregionAccessPoints, disableMultiregionAccessPoints = _e === void 0 ? false : _e;
|
|
4
|
+
return __assign(__assign({}, input), { bucketEndpoint: bucketEndpoint, forcePathStyle: forcePathStyle, useAccelerateEndpoint: useAccelerateEndpoint, useArnRegion: typeof useArnRegion === "function" ? useArnRegion : function () { return Promise.resolve(useArnRegion); }, disableMultiregionAccessPoints: typeof disableMultiregionAccessPoints === "function"
|
|
10
5
|
? disableMultiregionAccessPoints
|
|
11
|
-
: ()
|
|
12
|
-
};
|
|
6
|
+
: function () { return Promise.resolve(disableMultiregionAccessPoints); } });
|
|
13
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-bucket-endpoint",
|
|
3
|
-
"version": "3.
|
|
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,15 +20,15 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/protocol-http": "3.
|
|
24
|
-
"@aws-sdk/types": "3.
|
|
25
|
-
"@aws-sdk/util-arn-parser": "3.
|
|
26
|
-
"@aws-sdk/util-config-provider": "3.
|
|
23
|
+
"@aws-sdk/protocol-http": "3.186.0",
|
|
24
|
+
"@aws-sdk/types": "3.186.0",
|
|
25
|
+
"@aws-sdk/util-arn-parser": "3.186.0",
|
|
26
|
+
"@aws-sdk/util-config-provider": "3.186.0",
|
|
27
27
|
"tslib": "^2.3.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@aws-sdk/middleware-stack": "3.
|
|
31
|
-
"@aws-sdk/node-config-provider": "3.
|
|
30
|
+
"@aws-sdk/middleware-stack": "3.186.0",
|
|
31
|
+
"@aws-sdk/node-config-provider": "3.186.0",
|
|
32
32
|
"@tsconfig/recommended": "1.0.1",
|
|
33
33
|
"concurrently": "7.0.0",
|
|
34
34
|
"downlevel-dts": "0.10.1",
|