@aws-sdk/middleware-bucket-endpoint 3.485.0 → 3.495.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/NodeDisableMultiregionAccessPointConfigOptions.js +1 -11
- package/dist-cjs/NodeUseArnRegionConfigOptions.js +1 -11
- package/dist-cjs/bucketEndpointMiddleware.js +1 -86
- package/dist-cjs/bucketHostname.js +1 -128
- package/dist-cjs/bucketHostnameUtils.js +1 -153
- package/dist-cjs/configurations.js +1 -17
- package/dist-cjs/index.js +498 -19
- package/package.json +8 -8
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS = exports.NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME = exports.NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME = void 0;
|
|
4
|
-
const util_config_provider_1 = require("@smithy/util-config-provider");
|
|
5
|
-
exports.NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME = "AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS";
|
|
6
|
-
exports.NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME = "s3_disable_multiregion_access_points";
|
|
7
|
-
exports.NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS = {
|
|
8
|
-
environmentVariableSelector: (env) => (0, util_config_provider_1.booleanSelector)(env, exports.NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME, util_config_provider_1.SelectorType.ENV),
|
|
9
|
-
configFileSelector: (profile) => (0, util_config_provider_1.booleanSelector)(profile, exports.NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME, util_config_provider_1.SelectorType.CONFIG),
|
|
10
|
-
default: false,
|
|
11
|
-
};
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NODE_USE_ARN_REGION_CONFIG_OPTIONS = exports.NODE_USE_ARN_REGION_INI_NAME = exports.NODE_USE_ARN_REGION_ENV_NAME = void 0;
|
|
4
|
-
const util_config_provider_1 = require("@smithy/util-config-provider");
|
|
5
|
-
exports.NODE_USE_ARN_REGION_ENV_NAME = "AWS_S3_USE_ARN_REGION";
|
|
6
|
-
exports.NODE_USE_ARN_REGION_INI_NAME = "s3_use_arn_region";
|
|
7
|
-
exports.NODE_USE_ARN_REGION_CONFIG_OPTIONS = {
|
|
8
|
-
environmentVariableSelector: (env) => (0, util_config_provider_1.booleanSelector)(env, exports.NODE_USE_ARN_REGION_ENV_NAME, util_config_provider_1.SelectorType.ENV),
|
|
9
|
-
configFileSelector: (profile) => (0, util_config_provider_1.booleanSelector)(profile, exports.NODE_USE_ARN_REGION_INI_NAME, util_config_provider_1.SelectorType.CONFIG),
|
|
10
|
-
default: false,
|
|
11
|
-
};
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,86 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBucketEndpointPlugin = exports.bucketEndpointMiddlewareOptions = exports.bucketEndpointMiddleware = void 0;
|
|
4
|
-
const util_arn_parser_1 = require("@aws-sdk/util-arn-parser");
|
|
5
|
-
const protocol_http_1 = require("@smithy/protocol-http");
|
|
6
|
-
const bucketHostname_1 = require("./bucketHostname");
|
|
7
|
-
const bucketEndpointMiddleware = (options) => (next, context) => async (args) => {
|
|
8
|
-
const { Bucket: bucketName } = args.input;
|
|
9
|
-
let replaceBucketInPath = options.bucketEndpoint;
|
|
10
|
-
const request = args.request;
|
|
11
|
-
if (protocol_http_1.HttpRequest.isInstance(request)) {
|
|
12
|
-
if (options.bucketEndpoint) {
|
|
13
|
-
request.hostname = bucketName;
|
|
14
|
-
}
|
|
15
|
-
else if ((0, util_arn_parser_1.validate)(bucketName)) {
|
|
16
|
-
const bucketArn = (0, util_arn_parser_1.parse)(bucketName);
|
|
17
|
-
const clientRegion = await options.region();
|
|
18
|
-
const useDualstackEndpoint = await options.useDualstackEndpoint();
|
|
19
|
-
const useFipsEndpoint = await options.useFipsEndpoint();
|
|
20
|
-
const { partition, signingRegion = clientRegion } = (await options.regionInfoProvider(clientRegion, { useDualstackEndpoint, useFipsEndpoint })) || {};
|
|
21
|
-
const useArnRegion = await options.useArnRegion();
|
|
22
|
-
const { hostname, bucketEndpoint, signingRegion: modifiedSigningRegion, signingService, } = (0, bucketHostname_1.bucketHostname)({
|
|
23
|
-
bucketName: bucketArn,
|
|
24
|
-
baseHostname: request.hostname,
|
|
25
|
-
accelerateEndpoint: options.useAccelerateEndpoint,
|
|
26
|
-
dualstackEndpoint: useDualstackEndpoint,
|
|
27
|
-
fipsEndpoint: useFipsEndpoint,
|
|
28
|
-
pathStyleEndpoint: options.forcePathStyle,
|
|
29
|
-
tlsCompatible: request.protocol === "https:",
|
|
30
|
-
useArnRegion,
|
|
31
|
-
clientPartition: partition,
|
|
32
|
-
clientSigningRegion: signingRegion,
|
|
33
|
-
clientRegion: clientRegion,
|
|
34
|
-
isCustomEndpoint: options.isCustomEndpoint,
|
|
35
|
-
disableMultiregionAccessPoints: await options.disableMultiregionAccessPoints(),
|
|
36
|
-
});
|
|
37
|
-
if (modifiedSigningRegion && modifiedSigningRegion !== signingRegion) {
|
|
38
|
-
context["signing_region"] = modifiedSigningRegion;
|
|
39
|
-
}
|
|
40
|
-
if (signingService && signingService !== "s3") {
|
|
41
|
-
context["signing_service"] = signingService;
|
|
42
|
-
}
|
|
43
|
-
request.hostname = hostname;
|
|
44
|
-
replaceBucketInPath = bucketEndpoint;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
const clientRegion = await options.region();
|
|
48
|
-
const dualstackEndpoint = await options.useDualstackEndpoint();
|
|
49
|
-
const fipsEndpoint = await options.useFipsEndpoint();
|
|
50
|
-
const { hostname, bucketEndpoint } = (0, bucketHostname_1.bucketHostname)({
|
|
51
|
-
bucketName,
|
|
52
|
-
clientRegion,
|
|
53
|
-
baseHostname: request.hostname,
|
|
54
|
-
accelerateEndpoint: options.useAccelerateEndpoint,
|
|
55
|
-
dualstackEndpoint,
|
|
56
|
-
fipsEndpoint,
|
|
57
|
-
pathStyleEndpoint: options.forcePathStyle,
|
|
58
|
-
tlsCompatible: request.protocol === "https:",
|
|
59
|
-
isCustomEndpoint: options.isCustomEndpoint,
|
|
60
|
-
});
|
|
61
|
-
request.hostname = hostname;
|
|
62
|
-
replaceBucketInPath = bucketEndpoint;
|
|
63
|
-
}
|
|
64
|
-
if (replaceBucketInPath) {
|
|
65
|
-
request.path = request.path.replace(/^(\/)?[^\/]+/, "");
|
|
66
|
-
if (request.path === "") {
|
|
67
|
-
request.path = "/";
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return next({ ...args, request });
|
|
72
|
-
};
|
|
73
|
-
exports.bucketEndpointMiddleware = bucketEndpointMiddleware;
|
|
74
|
-
exports.bucketEndpointMiddlewareOptions = {
|
|
75
|
-
tags: ["BUCKET_ENDPOINT"],
|
|
76
|
-
name: "bucketEndpointMiddleware",
|
|
77
|
-
relation: "before",
|
|
78
|
-
toMiddleware: "hostHeaderMiddleware",
|
|
79
|
-
override: true,
|
|
80
|
-
};
|
|
81
|
-
const getBucketEndpointPlugin = (options) => ({
|
|
82
|
-
applyToStack: (clientStack) => {
|
|
83
|
-
clientStack.addRelativeTo((0, exports.bucketEndpointMiddleware)(options), exports.bucketEndpointMiddlewareOptions);
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
exports.getBucketEndpointPlugin = getBucketEndpointPlugin;
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,128 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bucketHostname = void 0;
|
|
4
|
-
const bucketHostnameUtils_1 = require("./bucketHostnameUtils");
|
|
5
|
-
const bucketHostname = (options) => {
|
|
6
|
-
(0, bucketHostnameUtils_1.validateCustomEndpoint)(options);
|
|
7
|
-
return (0, bucketHostnameUtils_1.isBucketNameOptions)(options)
|
|
8
|
-
?
|
|
9
|
-
getEndpointFromBucketName(options)
|
|
10
|
-
:
|
|
11
|
-
getEndpointFromArn(options);
|
|
12
|
-
};
|
|
13
|
-
exports.bucketHostname = bucketHostname;
|
|
14
|
-
const getEndpointFromBucketName = ({ accelerateEndpoint = false, clientRegion: region, baseHostname, bucketName, dualstackEndpoint = false, fipsEndpoint = false, pathStyleEndpoint = false, tlsCompatible = true, isCustomEndpoint = false, }) => {
|
|
15
|
-
const [clientRegion, hostnameSuffix] = isCustomEndpoint ? [region, baseHostname] : (0, bucketHostnameUtils_1.getSuffix)(baseHostname);
|
|
16
|
-
if (pathStyleEndpoint || !(0, bucketHostnameUtils_1.isDnsCompatibleBucketName)(bucketName) || (tlsCompatible && bucketHostnameUtils_1.DOT_PATTERN.test(bucketName))) {
|
|
17
|
-
return {
|
|
18
|
-
bucketEndpoint: false,
|
|
19
|
-
hostname: dualstackEndpoint ? `s3.dualstack.${clientRegion}.${hostnameSuffix}` : baseHostname,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
if (accelerateEndpoint) {
|
|
23
|
-
baseHostname = `s3-accelerate${dualstackEndpoint ? ".dualstack" : ""}.${hostnameSuffix}`;
|
|
24
|
-
}
|
|
25
|
-
else if (dualstackEndpoint) {
|
|
26
|
-
baseHostname = `s3.dualstack.${clientRegion}.${hostnameSuffix}`;
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
bucketEndpoint: true,
|
|
30
|
-
hostname: `${bucketName}.${baseHostname}`,
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
const getEndpointFromArn = (options) => {
|
|
34
|
-
const { isCustomEndpoint, baseHostname, clientRegion } = options;
|
|
35
|
-
const hostnameSuffix = isCustomEndpoint ? baseHostname : (0, bucketHostnameUtils_1.getSuffixForArnEndpoint)(baseHostname)[1];
|
|
36
|
-
const { pathStyleEndpoint, accelerateEndpoint = false, fipsEndpoint = false, tlsCompatible = true, bucketName, clientPartition = "aws", } = options;
|
|
37
|
-
(0, bucketHostnameUtils_1.validateArnEndpointOptions)({ pathStyleEndpoint, accelerateEndpoint, tlsCompatible });
|
|
38
|
-
const { service, partition, accountId, region, resource } = bucketName;
|
|
39
|
-
(0, bucketHostnameUtils_1.validateService)(service);
|
|
40
|
-
(0, bucketHostnameUtils_1.validatePartition)(partition, { clientPartition });
|
|
41
|
-
(0, bucketHostnameUtils_1.validateAccountId)(accountId);
|
|
42
|
-
const { accesspointName, outpostId } = (0, bucketHostnameUtils_1.getArnResources)(resource);
|
|
43
|
-
if (service === "s3-object-lambda") {
|
|
44
|
-
return getEndpointFromObjectLambdaArn({ ...options, tlsCompatible, bucketName, accesspointName, hostnameSuffix });
|
|
45
|
-
}
|
|
46
|
-
if (region === "") {
|
|
47
|
-
return getEndpointFromMRAPArn({ ...options, clientRegion, mrapAlias: accesspointName, hostnameSuffix });
|
|
48
|
-
}
|
|
49
|
-
if (outpostId) {
|
|
50
|
-
return getEndpointFromOutpostArn({ ...options, clientRegion, outpostId, accesspointName, hostnameSuffix });
|
|
51
|
-
}
|
|
52
|
-
return getEndpointFromAccessPointArn({ ...options, clientRegion, accesspointName, hostnameSuffix });
|
|
53
|
-
};
|
|
54
|
-
const getEndpointFromObjectLambdaArn = ({ dualstackEndpoint = false, fipsEndpoint = false, tlsCompatible = true, useArnRegion, clientRegion, clientSigningRegion = clientRegion, accesspointName, bucketName, hostnameSuffix, }) => {
|
|
55
|
-
const { accountId, region, service } = bucketName;
|
|
56
|
-
(0, bucketHostnameUtils_1.validateRegionalClient)(clientRegion);
|
|
57
|
-
(0, bucketHostnameUtils_1.validateRegion)(region, {
|
|
58
|
-
useArnRegion,
|
|
59
|
-
clientRegion,
|
|
60
|
-
clientSigningRegion,
|
|
61
|
-
allowFipsRegion: true,
|
|
62
|
-
useFipsEndpoint: fipsEndpoint,
|
|
63
|
-
});
|
|
64
|
-
(0, bucketHostnameUtils_1.validateNoDualstack)(dualstackEndpoint);
|
|
65
|
-
const DNSHostLabel = `${accesspointName}-${accountId}`;
|
|
66
|
-
(0, bucketHostnameUtils_1.validateDNSHostLabel)(DNSHostLabel, { tlsCompatible });
|
|
67
|
-
const endpointRegion = useArnRegion ? region : clientRegion;
|
|
68
|
-
const signingRegion = useArnRegion ? region : clientSigningRegion;
|
|
69
|
-
return {
|
|
70
|
-
bucketEndpoint: true,
|
|
71
|
-
hostname: `${DNSHostLabel}.${service}${fipsEndpoint ? "-fips" : ""}.${endpointRegion}.${hostnameSuffix}`,
|
|
72
|
-
signingRegion,
|
|
73
|
-
signingService: service,
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
const getEndpointFromMRAPArn = ({ disableMultiregionAccessPoints, dualstackEndpoint = false, isCustomEndpoint, mrapAlias, hostnameSuffix, }) => {
|
|
77
|
-
if (disableMultiregionAccessPoints === true) {
|
|
78
|
-
throw new Error("SDK is attempting to use a MRAP ARN. Please enable to feature.");
|
|
79
|
-
}
|
|
80
|
-
(0, bucketHostnameUtils_1.validateMrapAlias)(mrapAlias);
|
|
81
|
-
(0, bucketHostnameUtils_1.validateNoDualstack)(dualstackEndpoint);
|
|
82
|
-
return {
|
|
83
|
-
bucketEndpoint: true,
|
|
84
|
-
hostname: `${mrapAlias}${isCustomEndpoint ? "" : `.accesspoint.s3-global`}.${hostnameSuffix}`,
|
|
85
|
-
signingRegion: "*",
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
const getEndpointFromOutpostArn = ({ useArnRegion, clientRegion, clientSigningRegion = clientRegion, bucketName, outpostId, dualstackEndpoint = false, fipsEndpoint = false, tlsCompatible = true, accesspointName, isCustomEndpoint, hostnameSuffix, }) => {
|
|
89
|
-
(0, bucketHostnameUtils_1.validateRegionalClient)(clientRegion);
|
|
90
|
-
(0, bucketHostnameUtils_1.validateRegion)(bucketName.region, { useArnRegion, clientRegion, clientSigningRegion, useFipsEndpoint: fipsEndpoint });
|
|
91
|
-
const DNSHostLabel = `${accesspointName}-${bucketName.accountId}`;
|
|
92
|
-
(0, bucketHostnameUtils_1.validateDNSHostLabel)(DNSHostLabel, { tlsCompatible });
|
|
93
|
-
const endpointRegion = useArnRegion ? bucketName.region : clientRegion;
|
|
94
|
-
const signingRegion = useArnRegion ? bucketName.region : clientSigningRegion;
|
|
95
|
-
(0, bucketHostnameUtils_1.validateOutpostService)(bucketName.service);
|
|
96
|
-
(0, bucketHostnameUtils_1.validateDNSHostLabel)(outpostId, { tlsCompatible });
|
|
97
|
-
(0, bucketHostnameUtils_1.validateNoDualstack)(dualstackEndpoint);
|
|
98
|
-
(0, bucketHostnameUtils_1.validateNoFIPS)(fipsEndpoint);
|
|
99
|
-
const hostnamePrefix = `${DNSHostLabel}.${outpostId}`;
|
|
100
|
-
return {
|
|
101
|
-
bucketEndpoint: true,
|
|
102
|
-
hostname: `${hostnamePrefix}${isCustomEndpoint ? "" : `.s3-outposts.${endpointRegion}`}.${hostnameSuffix}`,
|
|
103
|
-
signingRegion,
|
|
104
|
-
signingService: "s3-outposts",
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
const getEndpointFromAccessPointArn = ({ useArnRegion, clientRegion, clientSigningRegion = clientRegion, bucketName, dualstackEndpoint = false, fipsEndpoint = false, tlsCompatible = true, accesspointName, isCustomEndpoint, hostnameSuffix, }) => {
|
|
108
|
-
(0, bucketHostnameUtils_1.validateRegionalClient)(clientRegion);
|
|
109
|
-
(0, bucketHostnameUtils_1.validateRegion)(bucketName.region, {
|
|
110
|
-
useArnRegion,
|
|
111
|
-
clientRegion,
|
|
112
|
-
clientSigningRegion,
|
|
113
|
-
allowFipsRegion: true,
|
|
114
|
-
useFipsEndpoint: fipsEndpoint,
|
|
115
|
-
});
|
|
116
|
-
const hostnamePrefix = `${accesspointName}-${bucketName.accountId}`;
|
|
117
|
-
(0, bucketHostnameUtils_1.validateDNSHostLabel)(hostnamePrefix, { tlsCompatible });
|
|
118
|
-
const endpointRegion = useArnRegion ? bucketName.region : clientRegion;
|
|
119
|
-
const signingRegion = useArnRegion ? bucketName.region : clientSigningRegion;
|
|
120
|
-
(0, bucketHostnameUtils_1.validateS3Service)(bucketName.service);
|
|
121
|
-
return {
|
|
122
|
-
bucketEndpoint: true,
|
|
123
|
-
hostname: `${hostnamePrefix}${isCustomEndpoint
|
|
124
|
-
? ""
|
|
125
|
-
: `.s3-accesspoint${fipsEndpoint ? "-fips" : ""}${dualstackEndpoint ? ".dualstack" : ""}.${endpointRegion}`}.${hostnameSuffix}`,
|
|
126
|
-
signingRegion,
|
|
127
|
-
};
|
|
128
|
-
};
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,153 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateMrapAlias = exports.validateNoFIPS = exports.validateNoDualstack = exports.getArnResources = exports.validateCustomEndpoint = exports.validateDNSHostLabel = exports.validateAccountId = exports.validateRegionalClient = exports.validateRegion = exports.validatePartition = exports.validateOutpostService = exports.validateS3Service = exports.validateService = exports.validateArnEndpointOptions = exports.getSuffixForArnEndpoint = exports.getSuffix = exports.isDnsCompatibleBucketName = exports.isBucketNameOptions = exports.S3_HOSTNAME_PATTERN = exports.DOT_PATTERN = void 0;
|
|
4
|
-
const DOMAIN_PATTERN = /^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/;
|
|
5
|
-
const IP_ADDRESS_PATTERN = /(\d+\.){3}\d+/;
|
|
6
|
-
const DOTS_PATTERN = /\.\./;
|
|
7
|
-
exports.DOT_PATTERN = /\./;
|
|
8
|
-
exports.S3_HOSTNAME_PATTERN = /^(.+\.)?s3(-fips)?(\.dualstack)?[.-]([a-z0-9-]+)\./;
|
|
9
|
-
const S3_US_EAST_1_ALTNAME_PATTERN = /^s3(-external-1)?\.amazonaws\.com$/;
|
|
10
|
-
const AWS_PARTITION_SUFFIX = "amazonaws.com";
|
|
11
|
-
const isBucketNameOptions = (options) => typeof options.bucketName === "string";
|
|
12
|
-
exports.isBucketNameOptions = isBucketNameOptions;
|
|
13
|
-
const isDnsCompatibleBucketName = (bucketName) => DOMAIN_PATTERN.test(bucketName) && !IP_ADDRESS_PATTERN.test(bucketName) && !DOTS_PATTERN.test(bucketName);
|
|
14
|
-
exports.isDnsCompatibleBucketName = isDnsCompatibleBucketName;
|
|
15
|
-
const getRegionalSuffix = (hostname) => {
|
|
16
|
-
const parts = hostname.match(exports.S3_HOSTNAME_PATTERN);
|
|
17
|
-
return [parts[4], hostname.replace(new RegExp(`^${parts[0]}`), "")];
|
|
18
|
-
};
|
|
19
|
-
const getSuffix = (hostname) => S3_US_EAST_1_ALTNAME_PATTERN.test(hostname) ? ["us-east-1", AWS_PARTITION_SUFFIX] : getRegionalSuffix(hostname);
|
|
20
|
-
exports.getSuffix = getSuffix;
|
|
21
|
-
const getSuffixForArnEndpoint = (hostname) => S3_US_EAST_1_ALTNAME_PATTERN.test(hostname)
|
|
22
|
-
? [hostname.replace(`.${AWS_PARTITION_SUFFIX}`, ""), AWS_PARTITION_SUFFIX]
|
|
23
|
-
: getRegionalSuffix(hostname);
|
|
24
|
-
exports.getSuffixForArnEndpoint = getSuffixForArnEndpoint;
|
|
25
|
-
const validateArnEndpointOptions = (options) => {
|
|
26
|
-
if (options.pathStyleEndpoint) {
|
|
27
|
-
throw new Error("Path-style S3 endpoint is not supported when bucket is an ARN");
|
|
28
|
-
}
|
|
29
|
-
if (options.accelerateEndpoint) {
|
|
30
|
-
throw new Error("Accelerate endpoint is not supported when bucket is an ARN");
|
|
31
|
-
}
|
|
32
|
-
if (!options.tlsCompatible) {
|
|
33
|
-
throw new Error("HTTPS is required when bucket is an ARN");
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
exports.validateArnEndpointOptions = validateArnEndpointOptions;
|
|
37
|
-
const validateService = (service) => {
|
|
38
|
-
if (service !== "s3" && service !== "s3-outposts" && service !== "s3-object-lambda") {
|
|
39
|
-
throw new Error("Expect 's3' or 's3-outposts' or 's3-object-lambda' in ARN service component");
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
exports.validateService = validateService;
|
|
43
|
-
const validateS3Service = (service) => {
|
|
44
|
-
if (service !== "s3") {
|
|
45
|
-
throw new Error("Expect 's3' in Accesspoint ARN service component");
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
exports.validateS3Service = validateS3Service;
|
|
49
|
-
const validateOutpostService = (service) => {
|
|
50
|
-
if (service !== "s3-outposts") {
|
|
51
|
-
throw new Error("Expect 's3-posts' in Outpost ARN service component");
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
exports.validateOutpostService = validateOutpostService;
|
|
55
|
-
const validatePartition = (partition, options) => {
|
|
56
|
-
if (partition !== options.clientPartition) {
|
|
57
|
-
throw new Error(`Partition in ARN is incompatible, got "${partition}" but expected "${options.clientPartition}"`);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
exports.validatePartition = validatePartition;
|
|
61
|
-
const validateRegion = (region, options) => {
|
|
62
|
-
if (region === "") {
|
|
63
|
-
throw new Error("ARN region is empty");
|
|
64
|
-
}
|
|
65
|
-
if (options.useFipsEndpoint) {
|
|
66
|
-
if (!options.allowFipsRegion) {
|
|
67
|
-
throw new Error("FIPS region is not supported");
|
|
68
|
-
}
|
|
69
|
-
else if (!isEqualRegions(region, options.clientRegion)) {
|
|
70
|
-
throw new Error(`Client FIPS region ${options.clientRegion} doesn't match region ${region} in ARN`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (!options.useArnRegion &&
|
|
74
|
-
!isEqualRegions(region, options.clientRegion || "") &&
|
|
75
|
-
!isEqualRegions(region, options.clientSigningRegion || "")) {
|
|
76
|
-
throw new Error(`Region in ARN is incompatible, got ${region} but expected ${options.clientRegion}`);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
exports.validateRegion = validateRegion;
|
|
80
|
-
const validateRegionalClient = (region) => {
|
|
81
|
-
if (["s3-external-1", "aws-global"].includes(region)) {
|
|
82
|
-
throw new Error(`Client region ${region} is not regional`);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
exports.validateRegionalClient = validateRegionalClient;
|
|
86
|
-
const isEqualRegions = (regionA, regionB) => regionA === regionB;
|
|
87
|
-
const validateAccountId = (accountId) => {
|
|
88
|
-
if (!/[0-9]{12}/.exec(accountId)) {
|
|
89
|
-
throw new Error("Access point ARN accountID does not match regex '[0-9]{12}'");
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
exports.validateAccountId = validateAccountId;
|
|
93
|
-
const validateDNSHostLabel = (label, options = { tlsCompatible: true }) => {
|
|
94
|
-
if (label.length >= 64 ||
|
|
95
|
-
!/^[a-z0-9][a-z0-9.-]*[a-z0-9]$/.test(label) ||
|
|
96
|
-
/(\d+\.){3}\d+/.test(label) ||
|
|
97
|
-
/[.-]{2}/.test(label) ||
|
|
98
|
-
((options === null || options === void 0 ? void 0 : options.tlsCompatible) && exports.DOT_PATTERN.test(label))) {
|
|
99
|
-
throw new Error(`Invalid DNS label ${label}`);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
exports.validateDNSHostLabel = validateDNSHostLabel;
|
|
103
|
-
const validateCustomEndpoint = (options) => {
|
|
104
|
-
if (options.isCustomEndpoint) {
|
|
105
|
-
if (options.dualstackEndpoint)
|
|
106
|
-
throw new Error("Dualstack endpoint is not supported with custom endpoint");
|
|
107
|
-
if (options.accelerateEndpoint)
|
|
108
|
-
throw new Error("Accelerate endpoint is not supported with custom endpoint");
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
exports.validateCustomEndpoint = validateCustomEndpoint;
|
|
112
|
-
const getArnResources = (resource) => {
|
|
113
|
-
const delimiter = resource.includes(":") ? ":" : "/";
|
|
114
|
-
const [resourceType, ...rest] = resource.split(delimiter);
|
|
115
|
-
if (resourceType === "accesspoint") {
|
|
116
|
-
if (rest.length !== 1 || rest[0] === "") {
|
|
117
|
-
throw new Error(`Access Point ARN should have one resource accesspoint${delimiter}{accesspointname}`);
|
|
118
|
-
}
|
|
119
|
-
return { accesspointName: rest[0] };
|
|
120
|
-
}
|
|
121
|
-
else if (resourceType === "outpost") {
|
|
122
|
-
if (!rest[0] || rest[1] !== "accesspoint" || !rest[2] || rest.length !== 3) {
|
|
123
|
-
throw new Error(`Outpost ARN should have resource outpost${delimiter}{outpostId}${delimiter}accesspoint${delimiter}{accesspointName}`);
|
|
124
|
-
}
|
|
125
|
-
const [outpostId, _, accesspointName] = rest;
|
|
126
|
-
return { outpostId, accesspointName };
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
throw new Error(`ARN resource should begin with 'accesspoint${delimiter}' or 'outpost${delimiter}'`);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
exports.getArnResources = getArnResources;
|
|
133
|
-
const validateNoDualstack = (dualstackEndpoint) => {
|
|
134
|
-
if (dualstackEndpoint)
|
|
135
|
-
throw new Error("Dualstack endpoint is not supported with Outpost or Multi-region Access Point ARN.");
|
|
136
|
-
};
|
|
137
|
-
exports.validateNoDualstack = validateNoDualstack;
|
|
138
|
-
const validateNoFIPS = (useFipsEndpoint) => {
|
|
139
|
-
if (useFipsEndpoint)
|
|
140
|
-
throw new Error(`FIPS region is not supported with Outpost.`);
|
|
141
|
-
};
|
|
142
|
-
exports.validateNoFIPS = validateNoFIPS;
|
|
143
|
-
const validateMrapAlias = (name) => {
|
|
144
|
-
try {
|
|
145
|
-
name.split(".").forEach((label) => {
|
|
146
|
-
(0, exports.validateDNSHostLabel)(label);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
catch (e) {
|
|
150
|
-
throw new Error(`"${name}" is not a DNS compatible name.`);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
exports.validateMrapAlias = validateMrapAlias;
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveBucketEndpointConfig = void 0;
|
|
4
|
-
function resolveBucketEndpointConfig(input) {
|
|
5
|
-
const { bucketEndpoint = false, forcePathStyle = false, useAccelerateEndpoint = false, useArnRegion = false, disableMultiregionAccessPoints = false, } = input;
|
|
6
|
-
return {
|
|
7
|
-
...input,
|
|
8
|
-
bucketEndpoint,
|
|
9
|
-
forcePathStyle,
|
|
10
|
-
useAccelerateEndpoint,
|
|
11
|
-
useArnRegion: typeof useArnRegion === "function" ? useArnRegion : () => Promise.resolve(useArnRegion),
|
|
12
|
-
disableMultiregionAccessPoints: typeof disableMultiregionAccessPoints === "function"
|
|
13
|
-
? disableMultiregionAccessPoints
|
|
14
|
-
: () => Promise.resolve(disableMultiregionAccessPoints),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
exports.resolveBucketEndpointConfig = resolveBucketEndpointConfig;
|
|
1
|
+
module.exports = require("./index.js");
|
package/dist-cjs/index.js
CHANGED
|
@@ -1,19 +1,498 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS: () => NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS,
|
|
24
|
+
NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME: () => NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME,
|
|
25
|
+
NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME: () => NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME,
|
|
26
|
+
NODE_USE_ARN_REGION_CONFIG_OPTIONS: () => NODE_USE_ARN_REGION_CONFIG_OPTIONS,
|
|
27
|
+
NODE_USE_ARN_REGION_ENV_NAME: () => NODE_USE_ARN_REGION_ENV_NAME,
|
|
28
|
+
NODE_USE_ARN_REGION_INI_NAME: () => NODE_USE_ARN_REGION_INI_NAME,
|
|
29
|
+
bucketEndpointMiddleware: () => bucketEndpointMiddleware,
|
|
30
|
+
bucketEndpointMiddlewareOptions: () => bucketEndpointMiddlewareOptions,
|
|
31
|
+
bucketHostname: () => bucketHostname,
|
|
32
|
+
getArnResources: () => getArnResources,
|
|
33
|
+
getBucketEndpointPlugin: () => getBucketEndpointPlugin,
|
|
34
|
+
getSuffixForArnEndpoint: () => getSuffixForArnEndpoint,
|
|
35
|
+
resolveBucketEndpointConfig: () => resolveBucketEndpointConfig,
|
|
36
|
+
validateAccountId: () => validateAccountId,
|
|
37
|
+
validateDNSHostLabel: () => validateDNSHostLabel,
|
|
38
|
+
validateNoDualstack: () => validateNoDualstack,
|
|
39
|
+
validateNoFIPS: () => validateNoFIPS,
|
|
40
|
+
validateOutpostService: () => validateOutpostService,
|
|
41
|
+
validatePartition: () => validatePartition,
|
|
42
|
+
validateRegion: () => validateRegion
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(src_exports);
|
|
45
|
+
|
|
46
|
+
// src/NodeDisableMultiregionAccessPointConfigOptions.ts
|
|
47
|
+
var import_util_config_provider = require("@smithy/util-config-provider");
|
|
48
|
+
var NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME = "AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS";
|
|
49
|
+
var NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME = "s3_disable_multiregion_access_points";
|
|
50
|
+
var NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS = {
|
|
51
|
+
environmentVariableSelector: (env) => (0, import_util_config_provider.booleanSelector)(env, NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME, import_util_config_provider.SelectorType.ENV),
|
|
52
|
+
configFileSelector: (profile) => (0, import_util_config_provider.booleanSelector)(profile, NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME, import_util_config_provider.SelectorType.CONFIG),
|
|
53
|
+
default: false
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/NodeUseArnRegionConfigOptions.ts
|
|
57
|
+
|
|
58
|
+
var NODE_USE_ARN_REGION_ENV_NAME = "AWS_S3_USE_ARN_REGION";
|
|
59
|
+
var NODE_USE_ARN_REGION_INI_NAME = "s3_use_arn_region";
|
|
60
|
+
var NODE_USE_ARN_REGION_CONFIG_OPTIONS = {
|
|
61
|
+
environmentVariableSelector: (env) => (0, import_util_config_provider.booleanSelector)(env, NODE_USE_ARN_REGION_ENV_NAME, import_util_config_provider.SelectorType.ENV),
|
|
62
|
+
configFileSelector: (profile) => (0, import_util_config_provider.booleanSelector)(profile, NODE_USE_ARN_REGION_INI_NAME, import_util_config_provider.SelectorType.CONFIG),
|
|
63
|
+
default: false
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// src/bucketEndpointMiddleware.ts
|
|
67
|
+
var import_util_arn_parser = require("@aws-sdk/util-arn-parser");
|
|
68
|
+
var import_protocol_http = require("@smithy/protocol-http");
|
|
69
|
+
|
|
70
|
+
// src/bucketHostnameUtils.ts
|
|
71
|
+
var DOMAIN_PATTERN = /^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/;
|
|
72
|
+
var IP_ADDRESS_PATTERN = /(\d+\.){3}\d+/;
|
|
73
|
+
var DOTS_PATTERN = /\.\./;
|
|
74
|
+
var DOT_PATTERN = /\./;
|
|
75
|
+
var S3_HOSTNAME_PATTERN = /^(.+\.)?s3(-fips)?(\.dualstack)?[.-]([a-z0-9-]+)\./;
|
|
76
|
+
var S3_US_EAST_1_ALTNAME_PATTERN = /^s3(-external-1)?\.amazonaws\.com$/;
|
|
77
|
+
var AWS_PARTITION_SUFFIX = "amazonaws.com";
|
|
78
|
+
var isBucketNameOptions = /* @__PURE__ */ __name((options) => typeof options.bucketName === "string", "isBucketNameOptions");
|
|
79
|
+
var isDnsCompatibleBucketName = /* @__PURE__ */ __name((bucketName) => DOMAIN_PATTERN.test(bucketName) && !IP_ADDRESS_PATTERN.test(bucketName) && !DOTS_PATTERN.test(bucketName), "isDnsCompatibleBucketName");
|
|
80
|
+
var getRegionalSuffix = /* @__PURE__ */ __name((hostname) => {
|
|
81
|
+
const parts = hostname.match(S3_HOSTNAME_PATTERN);
|
|
82
|
+
return [parts[4], hostname.replace(new RegExp(`^${parts[0]}`), "")];
|
|
83
|
+
}, "getRegionalSuffix");
|
|
84
|
+
var getSuffix = /* @__PURE__ */ __name((hostname) => S3_US_EAST_1_ALTNAME_PATTERN.test(hostname) ? ["us-east-1", AWS_PARTITION_SUFFIX] : getRegionalSuffix(hostname), "getSuffix");
|
|
85
|
+
var getSuffixForArnEndpoint = /* @__PURE__ */ __name((hostname) => S3_US_EAST_1_ALTNAME_PATTERN.test(hostname) ? [hostname.replace(`.${AWS_PARTITION_SUFFIX}`, ""), AWS_PARTITION_SUFFIX] : getRegionalSuffix(hostname), "getSuffixForArnEndpoint");
|
|
86
|
+
var validateArnEndpointOptions = /* @__PURE__ */ __name((options) => {
|
|
87
|
+
if (options.pathStyleEndpoint) {
|
|
88
|
+
throw new Error("Path-style S3 endpoint is not supported when bucket is an ARN");
|
|
89
|
+
}
|
|
90
|
+
if (options.accelerateEndpoint) {
|
|
91
|
+
throw new Error("Accelerate endpoint is not supported when bucket is an ARN");
|
|
92
|
+
}
|
|
93
|
+
if (!options.tlsCompatible) {
|
|
94
|
+
throw new Error("HTTPS is required when bucket is an ARN");
|
|
95
|
+
}
|
|
96
|
+
}, "validateArnEndpointOptions");
|
|
97
|
+
var validateService = /* @__PURE__ */ __name((service) => {
|
|
98
|
+
if (service !== "s3" && service !== "s3-outposts" && service !== "s3-object-lambda") {
|
|
99
|
+
throw new Error("Expect 's3' or 's3-outposts' or 's3-object-lambda' in ARN service component");
|
|
100
|
+
}
|
|
101
|
+
}, "validateService");
|
|
102
|
+
var validateS3Service = /* @__PURE__ */ __name((service) => {
|
|
103
|
+
if (service !== "s3") {
|
|
104
|
+
throw new Error("Expect 's3' in Accesspoint ARN service component");
|
|
105
|
+
}
|
|
106
|
+
}, "validateS3Service");
|
|
107
|
+
var validateOutpostService = /* @__PURE__ */ __name((service) => {
|
|
108
|
+
if (service !== "s3-outposts") {
|
|
109
|
+
throw new Error("Expect 's3-posts' in Outpost ARN service component");
|
|
110
|
+
}
|
|
111
|
+
}, "validateOutpostService");
|
|
112
|
+
var validatePartition = /* @__PURE__ */ __name((partition, options) => {
|
|
113
|
+
if (partition !== options.clientPartition) {
|
|
114
|
+
throw new Error(`Partition in ARN is incompatible, got "${partition}" but expected "${options.clientPartition}"`);
|
|
115
|
+
}
|
|
116
|
+
}, "validatePartition");
|
|
117
|
+
var validateRegion = /* @__PURE__ */ __name((region, options) => {
|
|
118
|
+
if (region === "") {
|
|
119
|
+
throw new Error("ARN region is empty");
|
|
120
|
+
}
|
|
121
|
+
if (options.useFipsEndpoint) {
|
|
122
|
+
if (!options.allowFipsRegion) {
|
|
123
|
+
throw new Error("FIPS region is not supported");
|
|
124
|
+
} else if (!isEqualRegions(region, options.clientRegion)) {
|
|
125
|
+
throw new Error(`Client FIPS region ${options.clientRegion} doesn't match region ${region} in ARN`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (!options.useArnRegion && !isEqualRegions(region, options.clientRegion || "") && !isEqualRegions(region, options.clientSigningRegion || "")) {
|
|
129
|
+
throw new Error(`Region in ARN is incompatible, got ${region} but expected ${options.clientRegion}`);
|
|
130
|
+
}
|
|
131
|
+
}, "validateRegion");
|
|
132
|
+
var validateRegionalClient = /* @__PURE__ */ __name((region) => {
|
|
133
|
+
if (["s3-external-1", "aws-global"].includes(region)) {
|
|
134
|
+
throw new Error(`Client region ${region} is not regional`);
|
|
135
|
+
}
|
|
136
|
+
}, "validateRegionalClient");
|
|
137
|
+
var isEqualRegions = /* @__PURE__ */ __name((regionA, regionB) => regionA === regionB, "isEqualRegions");
|
|
138
|
+
var validateAccountId = /* @__PURE__ */ __name((accountId) => {
|
|
139
|
+
if (!/[0-9]{12}/.exec(accountId)) {
|
|
140
|
+
throw new Error("Access point ARN accountID does not match regex '[0-9]{12}'");
|
|
141
|
+
}
|
|
142
|
+
}, "validateAccountId");
|
|
143
|
+
var validateDNSHostLabel = /* @__PURE__ */ __name((label, options = { tlsCompatible: true }) => {
|
|
144
|
+
if (label.length >= 64 || !/^[a-z0-9][a-z0-9.-]*[a-z0-9]$/.test(label) || /(\d+\.){3}\d+/.test(label) || /[.-]{2}/.test(label) || (options == null ? void 0 : options.tlsCompatible) && DOT_PATTERN.test(label)) {
|
|
145
|
+
throw new Error(`Invalid DNS label ${label}`);
|
|
146
|
+
}
|
|
147
|
+
}, "validateDNSHostLabel");
|
|
148
|
+
var validateCustomEndpoint = /* @__PURE__ */ __name((options) => {
|
|
149
|
+
if (options.isCustomEndpoint) {
|
|
150
|
+
if (options.dualstackEndpoint)
|
|
151
|
+
throw new Error("Dualstack endpoint is not supported with custom endpoint");
|
|
152
|
+
if (options.accelerateEndpoint)
|
|
153
|
+
throw new Error("Accelerate endpoint is not supported with custom endpoint");
|
|
154
|
+
}
|
|
155
|
+
}, "validateCustomEndpoint");
|
|
156
|
+
var getArnResources = /* @__PURE__ */ __name((resource) => {
|
|
157
|
+
const delimiter = resource.includes(":") ? ":" : "/";
|
|
158
|
+
const [resourceType, ...rest] = resource.split(delimiter);
|
|
159
|
+
if (resourceType === "accesspoint") {
|
|
160
|
+
if (rest.length !== 1 || rest[0] === "") {
|
|
161
|
+
throw new Error(`Access Point ARN should have one resource accesspoint${delimiter}{accesspointname}`);
|
|
162
|
+
}
|
|
163
|
+
return { accesspointName: rest[0] };
|
|
164
|
+
} else if (resourceType === "outpost") {
|
|
165
|
+
if (!rest[0] || rest[1] !== "accesspoint" || !rest[2] || rest.length !== 3) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
`Outpost ARN should have resource outpost${delimiter}{outpostId}${delimiter}accesspoint${delimiter}{accesspointName}`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
const [outpostId, _, accesspointName] = rest;
|
|
171
|
+
return { outpostId, accesspointName };
|
|
172
|
+
} else {
|
|
173
|
+
throw new Error(`ARN resource should begin with 'accesspoint${delimiter}' or 'outpost${delimiter}'`);
|
|
174
|
+
}
|
|
175
|
+
}, "getArnResources");
|
|
176
|
+
var validateNoDualstack = /* @__PURE__ */ __name((dualstackEndpoint) => {
|
|
177
|
+
if (dualstackEndpoint)
|
|
178
|
+
throw new Error("Dualstack endpoint is not supported with Outpost or Multi-region Access Point ARN.");
|
|
179
|
+
}, "validateNoDualstack");
|
|
180
|
+
var validateNoFIPS = /* @__PURE__ */ __name((useFipsEndpoint) => {
|
|
181
|
+
if (useFipsEndpoint)
|
|
182
|
+
throw new Error(`FIPS region is not supported with Outpost.`);
|
|
183
|
+
}, "validateNoFIPS");
|
|
184
|
+
var validateMrapAlias = /* @__PURE__ */ __name((name) => {
|
|
185
|
+
try {
|
|
186
|
+
name.split(".").forEach((label) => {
|
|
187
|
+
validateDNSHostLabel(label);
|
|
188
|
+
});
|
|
189
|
+
} catch (e) {
|
|
190
|
+
throw new Error(`"${name}" is not a DNS compatible name.`);
|
|
191
|
+
}
|
|
192
|
+
}, "validateMrapAlias");
|
|
193
|
+
|
|
194
|
+
// src/bucketHostname.ts
|
|
195
|
+
var bucketHostname = /* @__PURE__ */ __name((options) => {
|
|
196
|
+
validateCustomEndpoint(options);
|
|
197
|
+
return isBucketNameOptions(options) ? (
|
|
198
|
+
// Construct endpoint when bucketName is a string referring to a bucket name
|
|
199
|
+
getEndpointFromBucketName(options)
|
|
200
|
+
) : (
|
|
201
|
+
// Construct endpoint when bucketName is an ARN referring to an S3 resource like Access Point
|
|
202
|
+
getEndpointFromArn(options)
|
|
203
|
+
);
|
|
204
|
+
}, "bucketHostname");
|
|
205
|
+
var getEndpointFromBucketName = /* @__PURE__ */ __name(({
|
|
206
|
+
accelerateEndpoint = false,
|
|
207
|
+
clientRegion: region,
|
|
208
|
+
baseHostname,
|
|
209
|
+
bucketName,
|
|
210
|
+
dualstackEndpoint = false,
|
|
211
|
+
fipsEndpoint = false,
|
|
212
|
+
pathStyleEndpoint = false,
|
|
213
|
+
tlsCompatible = true,
|
|
214
|
+
isCustomEndpoint = false
|
|
215
|
+
}) => {
|
|
216
|
+
const [clientRegion, hostnameSuffix] = isCustomEndpoint ? [region, baseHostname] : getSuffix(baseHostname);
|
|
217
|
+
if (pathStyleEndpoint || !isDnsCompatibleBucketName(bucketName) || tlsCompatible && DOT_PATTERN.test(bucketName)) {
|
|
218
|
+
return {
|
|
219
|
+
bucketEndpoint: false,
|
|
220
|
+
hostname: dualstackEndpoint ? `s3.dualstack.${clientRegion}.${hostnameSuffix}` : baseHostname
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
if (accelerateEndpoint) {
|
|
224
|
+
baseHostname = `s3-accelerate${dualstackEndpoint ? ".dualstack" : ""}.${hostnameSuffix}`;
|
|
225
|
+
} else if (dualstackEndpoint) {
|
|
226
|
+
baseHostname = `s3.dualstack.${clientRegion}.${hostnameSuffix}`;
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
bucketEndpoint: true,
|
|
230
|
+
hostname: `${bucketName}.${baseHostname}`
|
|
231
|
+
};
|
|
232
|
+
}, "getEndpointFromBucketName");
|
|
233
|
+
var getEndpointFromArn = /* @__PURE__ */ __name((options) => {
|
|
234
|
+
const { isCustomEndpoint, baseHostname, clientRegion } = options;
|
|
235
|
+
const hostnameSuffix = isCustomEndpoint ? baseHostname : getSuffixForArnEndpoint(baseHostname)[1];
|
|
236
|
+
const {
|
|
237
|
+
pathStyleEndpoint,
|
|
238
|
+
accelerateEndpoint = false,
|
|
239
|
+
fipsEndpoint = false,
|
|
240
|
+
tlsCompatible = true,
|
|
241
|
+
bucketName,
|
|
242
|
+
clientPartition = "aws"
|
|
243
|
+
} = options;
|
|
244
|
+
validateArnEndpointOptions({ pathStyleEndpoint, accelerateEndpoint, tlsCompatible });
|
|
245
|
+
const { service, partition, accountId, region, resource } = bucketName;
|
|
246
|
+
validateService(service);
|
|
247
|
+
validatePartition(partition, { clientPartition });
|
|
248
|
+
validateAccountId(accountId);
|
|
249
|
+
const { accesspointName, outpostId } = getArnResources(resource);
|
|
250
|
+
if (service === "s3-object-lambda") {
|
|
251
|
+
return getEndpointFromObjectLambdaArn({ ...options, tlsCompatible, bucketName, accesspointName, hostnameSuffix });
|
|
252
|
+
}
|
|
253
|
+
if (region === "") {
|
|
254
|
+
return getEndpointFromMRAPArn({ ...options, clientRegion, mrapAlias: accesspointName, hostnameSuffix });
|
|
255
|
+
}
|
|
256
|
+
if (outpostId) {
|
|
257
|
+
return getEndpointFromOutpostArn({ ...options, clientRegion, outpostId, accesspointName, hostnameSuffix });
|
|
258
|
+
}
|
|
259
|
+
return getEndpointFromAccessPointArn({ ...options, clientRegion, accesspointName, hostnameSuffix });
|
|
260
|
+
}, "getEndpointFromArn");
|
|
261
|
+
var getEndpointFromObjectLambdaArn = /* @__PURE__ */ __name(({
|
|
262
|
+
dualstackEndpoint = false,
|
|
263
|
+
fipsEndpoint = false,
|
|
264
|
+
tlsCompatible = true,
|
|
265
|
+
useArnRegion,
|
|
266
|
+
clientRegion,
|
|
267
|
+
clientSigningRegion = clientRegion,
|
|
268
|
+
accesspointName,
|
|
269
|
+
bucketName,
|
|
270
|
+
hostnameSuffix
|
|
271
|
+
}) => {
|
|
272
|
+
const { accountId, region, service } = bucketName;
|
|
273
|
+
validateRegionalClient(clientRegion);
|
|
274
|
+
validateRegion(region, {
|
|
275
|
+
useArnRegion,
|
|
276
|
+
clientRegion,
|
|
277
|
+
clientSigningRegion,
|
|
278
|
+
allowFipsRegion: true,
|
|
279
|
+
useFipsEndpoint: fipsEndpoint
|
|
280
|
+
});
|
|
281
|
+
validateNoDualstack(dualstackEndpoint);
|
|
282
|
+
const DNSHostLabel = `${accesspointName}-${accountId}`;
|
|
283
|
+
validateDNSHostLabel(DNSHostLabel, { tlsCompatible });
|
|
284
|
+
const endpointRegion = useArnRegion ? region : clientRegion;
|
|
285
|
+
const signingRegion = useArnRegion ? region : clientSigningRegion;
|
|
286
|
+
return {
|
|
287
|
+
bucketEndpoint: true,
|
|
288
|
+
hostname: `${DNSHostLabel}.${service}${fipsEndpoint ? "-fips" : ""}.${endpointRegion}.${hostnameSuffix}`,
|
|
289
|
+
signingRegion,
|
|
290
|
+
signingService: service
|
|
291
|
+
};
|
|
292
|
+
}, "getEndpointFromObjectLambdaArn");
|
|
293
|
+
var getEndpointFromMRAPArn = /* @__PURE__ */ __name(({
|
|
294
|
+
disableMultiregionAccessPoints,
|
|
295
|
+
dualstackEndpoint = false,
|
|
296
|
+
isCustomEndpoint,
|
|
297
|
+
mrapAlias,
|
|
298
|
+
hostnameSuffix
|
|
299
|
+
}) => {
|
|
300
|
+
if (disableMultiregionAccessPoints === true) {
|
|
301
|
+
throw new Error("SDK is attempting to use a MRAP ARN. Please enable to feature.");
|
|
302
|
+
}
|
|
303
|
+
validateMrapAlias(mrapAlias);
|
|
304
|
+
validateNoDualstack(dualstackEndpoint);
|
|
305
|
+
return {
|
|
306
|
+
bucketEndpoint: true,
|
|
307
|
+
hostname: `${mrapAlias}${isCustomEndpoint ? "" : `.accesspoint.s3-global`}.${hostnameSuffix}`,
|
|
308
|
+
signingRegion: "*"
|
|
309
|
+
};
|
|
310
|
+
}, "getEndpointFromMRAPArn");
|
|
311
|
+
var getEndpointFromOutpostArn = /* @__PURE__ */ __name(({
|
|
312
|
+
useArnRegion,
|
|
313
|
+
clientRegion,
|
|
314
|
+
clientSigningRegion = clientRegion,
|
|
315
|
+
bucketName,
|
|
316
|
+
outpostId,
|
|
317
|
+
dualstackEndpoint = false,
|
|
318
|
+
fipsEndpoint = false,
|
|
319
|
+
tlsCompatible = true,
|
|
320
|
+
accesspointName,
|
|
321
|
+
isCustomEndpoint,
|
|
322
|
+
hostnameSuffix
|
|
323
|
+
}) => {
|
|
324
|
+
validateRegionalClient(clientRegion);
|
|
325
|
+
validateRegion(bucketName.region, { useArnRegion, clientRegion, clientSigningRegion, useFipsEndpoint: fipsEndpoint });
|
|
326
|
+
const DNSHostLabel = `${accesspointName}-${bucketName.accountId}`;
|
|
327
|
+
validateDNSHostLabel(DNSHostLabel, { tlsCompatible });
|
|
328
|
+
const endpointRegion = useArnRegion ? bucketName.region : clientRegion;
|
|
329
|
+
const signingRegion = useArnRegion ? bucketName.region : clientSigningRegion;
|
|
330
|
+
validateOutpostService(bucketName.service);
|
|
331
|
+
validateDNSHostLabel(outpostId, { tlsCompatible });
|
|
332
|
+
validateNoDualstack(dualstackEndpoint);
|
|
333
|
+
validateNoFIPS(fipsEndpoint);
|
|
334
|
+
const hostnamePrefix = `${DNSHostLabel}.${outpostId}`;
|
|
335
|
+
return {
|
|
336
|
+
bucketEndpoint: true,
|
|
337
|
+
hostname: `${hostnamePrefix}${isCustomEndpoint ? "" : `.s3-outposts.${endpointRegion}`}.${hostnameSuffix}`,
|
|
338
|
+
signingRegion,
|
|
339
|
+
signingService: "s3-outposts"
|
|
340
|
+
};
|
|
341
|
+
}, "getEndpointFromOutpostArn");
|
|
342
|
+
var getEndpointFromAccessPointArn = /* @__PURE__ */ __name(({
|
|
343
|
+
useArnRegion,
|
|
344
|
+
clientRegion,
|
|
345
|
+
clientSigningRegion = clientRegion,
|
|
346
|
+
bucketName,
|
|
347
|
+
dualstackEndpoint = false,
|
|
348
|
+
fipsEndpoint = false,
|
|
349
|
+
tlsCompatible = true,
|
|
350
|
+
accesspointName,
|
|
351
|
+
isCustomEndpoint,
|
|
352
|
+
hostnameSuffix
|
|
353
|
+
}) => {
|
|
354
|
+
validateRegionalClient(clientRegion);
|
|
355
|
+
validateRegion(bucketName.region, {
|
|
356
|
+
useArnRegion,
|
|
357
|
+
clientRegion,
|
|
358
|
+
clientSigningRegion,
|
|
359
|
+
allowFipsRegion: true,
|
|
360
|
+
useFipsEndpoint: fipsEndpoint
|
|
361
|
+
});
|
|
362
|
+
const hostnamePrefix = `${accesspointName}-${bucketName.accountId}`;
|
|
363
|
+
validateDNSHostLabel(hostnamePrefix, { tlsCompatible });
|
|
364
|
+
const endpointRegion = useArnRegion ? bucketName.region : clientRegion;
|
|
365
|
+
const signingRegion = useArnRegion ? bucketName.region : clientSigningRegion;
|
|
366
|
+
validateS3Service(bucketName.service);
|
|
367
|
+
return {
|
|
368
|
+
bucketEndpoint: true,
|
|
369
|
+
hostname: `${hostnamePrefix}${isCustomEndpoint ? "" : `.s3-accesspoint${fipsEndpoint ? "-fips" : ""}${dualstackEndpoint ? ".dualstack" : ""}.${endpointRegion}`}.${hostnameSuffix}`,
|
|
370
|
+
signingRegion
|
|
371
|
+
};
|
|
372
|
+
}, "getEndpointFromAccessPointArn");
|
|
373
|
+
|
|
374
|
+
// src/bucketEndpointMiddleware.ts
|
|
375
|
+
var bucketEndpointMiddleware = /* @__PURE__ */ __name((options) => (next, context) => async (args) => {
|
|
376
|
+
const { Bucket: bucketName } = args.input;
|
|
377
|
+
let replaceBucketInPath = options.bucketEndpoint;
|
|
378
|
+
const request = args.request;
|
|
379
|
+
if (import_protocol_http.HttpRequest.isInstance(request)) {
|
|
380
|
+
if (options.bucketEndpoint) {
|
|
381
|
+
request.hostname = bucketName;
|
|
382
|
+
} else if ((0, import_util_arn_parser.validate)(bucketName)) {
|
|
383
|
+
const bucketArn = (0, import_util_arn_parser.parse)(bucketName);
|
|
384
|
+
const clientRegion = await options.region();
|
|
385
|
+
const useDualstackEndpoint = await options.useDualstackEndpoint();
|
|
386
|
+
const useFipsEndpoint = await options.useFipsEndpoint();
|
|
387
|
+
const { partition, signingRegion = clientRegion } = await options.regionInfoProvider(clientRegion, { useDualstackEndpoint, useFipsEndpoint }) || {};
|
|
388
|
+
const useArnRegion = await options.useArnRegion();
|
|
389
|
+
const {
|
|
390
|
+
hostname,
|
|
391
|
+
bucketEndpoint,
|
|
392
|
+
signingRegion: modifiedSigningRegion,
|
|
393
|
+
signingService
|
|
394
|
+
} = bucketHostname({
|
|
395
|
+
bucketName: bucketArn,
|
|
396
|
+
baseHostname: request.hostname,
|
|
397
|
+
accelerateEndpoint: options.useAccelerateEndpoint,
|
|
398
|
+
dualstackEndpoint: useDualstackEndpoint,
|
|
399
|
+
fipsEndpoint: useFipsEndpoint,
|
|
400
|
+
pathStyleEndpoint: options.forcePathStyle,
|
|
401
|
+
tlsCompatible: request.protocol === "https:",
|
|
402
|
+
useArnRegion,
|
|
403
|
+
clientPartition: partition,
|
|
404
|
+
clientSigningRegion: signingRegion,
|
|
405
|
+
clientRegion,
|
|
406
|
+
isCustomEndpoint: options.isCustomEndpoint,
|
|
407
|
+
disableMultiregionAccessPoints: await options.disableMultiregionAccessPoints()
|
|
408
|
+
});
|
|
409
|
+
if (modifiedSigningRegion && modifiedSigningRegion !== signingRegion) {
|
|
410
|
+
context["signing_region"] = modifiedSigningRegion;
|
|
411
|
+
}
|
|
412
|
+
if (signingService && signingService !== "s3") {
|
|
413
|
+
context["signing_service"] = signingService;
|
|
414
|
+
}
|
|
415
|
+
request.hostname = hostname;
|
|
416
|
+
replaceBucketInPath = bucketEndpoint;
|
|
417
|
+
} else {
|
|
418
|
+
const clientRegion = await options.region();
|
|
419
|
+
const dualstackEndpoint = await options.useDualstackEndpoint();
|
|
420
|
+
const fipsEndpoint = await options.useFipsEndpoint();
|
|
421
|
+
const { hostname, bucketEndpoint } = bucketHostname({
|
|
422
|
+
bucketName,
|
|
423
|
+
clientRegion,
|
|
424
|
+
baseHostname: request.hostname,
|
|
425
|
+
accelerateEndpoint: options.useAccelerateEndpoint,
|
|
426
|
+
dualstackEndpoint,
|
|
427
|
+
fipsEndpoint,
|
|
428
|
+
pathStyleEndpoint: options.forcePathStyle,
|
|
429
|
+
tlsCompatible: request.protocol === "https:",
|
|
430
|
+
isCustomEndpoint: options.isCustomEndpoint
|
|
431
|
+
});
|
|
432
|
+
request.hostname = hostname;
|
|
433
|
+
replaceBucketInPath = bucketEndpoint;
|
|
434
|
+
}
|
|
435
|
+
if (replaceBucketInPath) {
|
|
436
|
+
request.path = request.path.replace(/^(\/)?[^\/]+/, "");
|
|
437
|
+
if (request.path === "") {
|
|
438
|
+
request.path = "/";
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return next({ ...args, request });
|
|
443
|
+
}, "bucketEndpointMiddleware");
|
|
444
|
+
var bucketEndpointMiddlewareOptions = {
|
|
445
|
+
tags: ["BUCKET_ENDPOINT"],
|
|
446
|
+
name: "bucketEndpointMiddleware",
|
|
447
|
+
relation: "before",
|
|
448
|
+
toMiddleware: "hostHeaderMiddleware",
|
|
449
|
+
override: true
|
|
450
|
+
};
|
|
451
|
+
var getBucketEndpointPlugin = /* @__PURE__ */ __name((options) => ({
|
|
452
|
+
applyToStack: (clientStack) => {
|
|
453
|
+
clientStack.addRelativeTo(bucketEndpointMiddleware(options), bucketEndpointMiddlewareOptions);
|
|
454
|
+
}
|
|
455
|
+
}), "getBucketEndpointPlugin");
|
|
456
|
+
|
|
457
|
+
// src/configurations.ts
|
|
458
|
+
function resolveBucketEndpointConfig(input) {
|
|
459
|
+
const {
|
|
460
|
+
bucketEndpoint = false,
|
|
461
|
+
forcePathStyle = false,
|
|
462
|
+
useAccelerateEndpoint = false,
|
|
463
|
+
useArnRegion = false,
|
|
464
|
+
disableMultiregionAccessPoints = false
|
|
465
|
+
} = input;
|
|
466
|
+
return {
|
|
467
|
+
...input,
|
|
468
|
+
bucketEndpoint,
|
|
469
|
+
forcePathStyle,
|
|
470
|
+
useAccelerateEndpoint,
|
|
471
|
+
useArnRegion: typeof useArnRegion === "function" ? useArnRegion : () => Promise.resolve(useArnRegion),
|
|
472
|
+
disableMultiregionAccessPoints: typeof disableMultiregionAccessPoints === "function" ? disableMultiregionAccessPoints : () => Promise.resolve(disableMultiregionAccessPoints)
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
__name(resolveBucketEndpointConfig, "resolveBucketEndpointConfig");
|
|
476
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
477
|
+
0 && (module.exports = {
|
|
478
|
+
NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS,
|
|
479
|
+
NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME,
|
|
480
|
+
NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME,
|
|
481
|
+
NODE_USE_ARN_REGION_CONFIG_OPTIONS,
|
|
482
|
+
NODE_USE_ARN_REGION_ENV_NAME,
|
|
483
|
+
NODE_USE_ARN_REGION_INI_NAME,
|
|
484
|
+
bucketEndpointMiddleware,
|
|
485
|
+
bucketEndpointMiddlewareOptions,
|
|
486
|
+
bucketHostname,
|
|
487
|
+
getArnResources,
|
|
488
|
+
getBucketEndpointPlugin,
|
|
489
|
+
getSuffixForArnEndpoint,
|
|
490
|
+
resolveBucketEndpointConfig,
|
|
491
|
+
validateAccountId,
|
|
492
|
+
validateDNSHostLabel,
|
|
493
|
+
validateNoDualstack,
|
|
494
|
+
validateNoFIPS,
|
|
495
|
+
validateOutpostService,
|
|
496
|
+
validatePartition,
|
|
497
|
+
validateRegion
|
|
498
|
+
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-bucket-endpoint",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.495.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
6
|
-
"build:cjs": "
|
|
6
|
+
"build:cjs": "node ../../scripts/compilation/inline middleware-bucket-endpoint",
|
|
7
7
|
"build:es": "tsc -p tsconfig.es.json",
|
|
8
8
|
"build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build",
|
|
9
9
|
"build:types": "tsc -p tsconfig.types.json",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@aws-sdk/types": "3.
|
|
25
|
-
"@aws-sdk/util-arn-parser": "3.
|
|
26
|
-
"@smithy/node-config-provider": "^2.
|
|
27
|
-
"@smithy/protocol-http": "^3.0
|
|
28
|
-
"@smithy/types": "^2.
|
|
29
|
-
"@smithy/util-config-provider": "^2.
|
|
24
|
+
"@aws-sdk/types": "3.495.0",
|
|
25
|
+
"@aws-sdk/util-arn-parser": "3.495.0",
|
|
26
|
+
"@smithy/node-config-provider": "^2.2.0",
|
|
27
|
+
"@smithy/protocol-http": "^3.1.0",
|
|
28
|
+
"@smithy/types": "^2.9.0",
|
|
29
|
+
"@smithy/util-config-provider": "^2.2.0",
|
|
30
30
|
"tslib": "^2.5.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|