@aws-sdk/middleware-bucket-endpoint 3.34.0 → 3.38.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist-cjs/bucketEndpointMiddleware.js +81 -0
  3. package/dist-cjs/bucketHostname.js +116 -0
  4. package/dist-cjs/bucketHostnameUtils.js +157 -0
  5. package/dist-cjs/configurations.js +64 -0
  6. package/{dist/cjs → dist-cjs}/index.js +0 -1
  7. package/dist-es/bucketEndpointMiddleware.js +100 -0
  8. package/dist-es/bucketHostname.js +118 -0
  9. package/dist-es/bucketHostnameUtils.js +144 -0
  10. package/dist-es/configurations.js +53 -0
  11. package/{dist/types/index.d.ts → dist-es/index.js} +0 -0
  12. package/{dist/types → dist-types}/bucketEndpointMiddleware.d.ts +0 -0
  13. package/{dist/types → dist-types}/bucketHostname.d.ts +0 -0
  14. package/{dist/types → dist-types}/bucketHostnameUtils.d.ts +0 -0
  15. package/{dist/types → dist-types}/configurations.d.ts +0 -0
  16. package/dist-types/index.d.ts +4 -0
  17. package/{dist/types → dist-types}/ts3.4/bucketEndpointMiddleware.d.ts +0 -0
  18. package/{dist/types → dist-types}/ts3.4/bucketHostname.d.ts +0 -0
  19. package/{dist/types → dist-types}/ts3.4/bucketHostnameUtils.d.ts +13 -62
  20. package/dist-types/ts3.4/configurations.d.ts +49 -0
  21. package/{dist/types → dist-types}/ts3.4/index.d.ts +0 -0
  22. package/package.json +15 -12
  23. package/dist/cjs/bucketEndpointMiddleware.js +0 -82
  24. package/dist/cjs/bucketHostname.js +0 -117
  25. package/dist/cjs/bucketHostnameUtils.js +0 -158
  26. package/dist/cjs/configurations.js +0 -65
  27. package/dist/es/bucketEndpointMiddleware.js +0 -103
  28. package/dist/es/bucketHostname.js +0 -123
  29. package/dist/es/bucketHostnameUtils.js +0 -210
  30. package/dist/es/configurations.js +0 -59
  31. package/dist/es/index.js +0 -5
  32. package/dist/types/ts3.4/configurations.d.ts +0 -87
  33. package/src/bucketEndpointMiddleware.ts +0 -101
  34. package/src/bucketHostname.ts +0 -223
  35. package/src/bucketHostnameUtils.ts +0 -272
  36. package/src/configurations.ts +0 -154
  37. package/src/index.ts +0 -15
  38. package/tsconfig.cjs.json +0 -9
  39. package/tsconfig.es.json +0 -10
  40. package/tsconfig.types.json +0 -9
@@ -0,0 +1,118 @@
1
+ import { __assign, __read } from "tslib";
2
+ import { DOT_PATTERN, getArnResources, getPseudoRegion, getSuffix, getSuffixForArnEndpoint, isBucketNameOptions, isDnsCompatibleBucketName, isFipsRegion, validateAccountId, validateArnEndpointOptions, validateCustomEndpoint, validateDNSHostLabel, validateMrapAlias, validateNoDualstack, validateNoFIPS, validateOutpostService, validatePartition, validateRegion, validateRegionalClient, validateS3Service, validateService, } from "./bucketHostnameUtils";
3
+ export var bucketHostname = function (options) {
4
+ validateCustomEndpoint(options);
5
+ return isBucketNameOptions(options)
6
+ ?
7
+ getEndpointFromBucketName(options)
8
+ :
9
+ getEndpointFromArn(options);
10
+ };
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.pathStyleEndpoint, pathStyleEndpoint = _d === void 0 ? false : _d, _e = _a.tlsCompatible, tlsCompatible = _e === void 0 ? true : _e, _f = _a.isCustomEndpoint, isCustomEndpoint = _f === void 0 ? false : _f;
13
+ var _g = __read(isCustomEndpoint ? [region, baseHostname] : getSuffix(baseHostname), 2), clientRegion = _g[0], hostnameSuffix = _g[1];
14
+ if (pathStyleEndpoint || !isDnsCompatibleBucketName(bucketName) || (tlsCompatible && DOT_PATTERN.test(bucketName))) {
15
+ return {
16
+ bucketEndpoint: false,
17
+ hostname: dualstackEndpoint ? "s3.dualstack." + clientRegion + "." + hostnameSuffix : baseHostname,
18
+ };
19
+ }
20
+ if (accelerateEndpoint) {
21
+ baseHostname = "s3-accelerate" + (dualstackEndpoint ? ".dualstack" : "") + "." + hostnameSuffix;
22
+ }
23
+ else if (dualstackEndpoint) {
24
+ baseHostname = "s3.dualstack." + clientRegion + "." + hostnameSuffix;
25
+ }
26
+ return {
27
+ bucketEndpoint: true,
28
+ hostname: bucketName + "." + baseHostname,
29
+ };
30
+ };
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.tlsCompatible, tlsCompatible = _b === void 0 ? true : _b, bucketName = options.bucketName, _c = options.clientPartition, clientPartition = _c === void 0 ? "aws" : _c;
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;
37
+ validateService(service);
38
+ validatePartition(partition, { clientPartition: clientPartition });
39
+ validateAccountId(accountId);
40
+ var _d = getArnResources(resource), accesspointName = _d.accesspointName, outpostId = _d.outpostId;
41
+ if (service === "s3-object-lambda") {
42
+ return getEndpointFromObjectLambdaArn(__assign(__assign({}, options), { tlsCompatible: tlsCompatible, bucketName: bucketName, accesspointName: accesspointName, hostnameSuffix: hostnameSuffix }));
43
+ }
44
+ if (region === "") {
45
+ return getEndpointFromMRAPArn(__assign(__assign({}, options), { clientRegion: clientRegion, mrapAlias: accesspointName, hostnameSuffix: hostnameSuffix }));
46
+ }
47
+ if (outpostId) {
48
+ return getEndpointFromOutpostArn(__assign(__assign({}, options), { clientRegion: clientRegion, outpostId: outpostId, accesspointName: accesspointName, hostnameSuffix: hostnameSuffix }));
49
+ }
50
+ return getEndpointFromAccessPointArn(__assign(__assign({}, options), { clientRegion: clientRegion, accesspointName: accesspointName, hostnameSuffix: hostnameSuffix }));
51
+ };
52
+ var getEndpointFromObjectLambdaArn = function (_a) {
53
+ var _b = _a.dualstackEndpoint, dualstackEndpoint = _b === void 0 ? false : _b, _c = _a.tlsCompatible, tlsCompatible = _c === void 0 ? true : _c, useArnRegion = _a.useArnRegion, clientRegion = _a.clientRegion, _d = _a.clientSigningRegion, clientSigningRegion = _d === void 0 ? clientRegion : _d, accesspointName = _a.accesspointName, bucketName = _a.bucketName, hostnameSuffix = _a.hostnameSuffix;
54
+ var accountId = bucketName.accountId, region = bucketName.region, service = bucketName.service;
55
+ validateRegionalClient(clientRegion);
56
+ validateRegion(region, { useArnRegion: useArnRegion, clientRegion: clientRegion, clientSigningRegion: clientSigningRegion, allowFipsRegion: true });
57
+ validateNoDualstack(dualstackEndpoint);
58
+ var DNSHostLabel = accesspointName + "-" + accountId;
59
+ validateDNSHostLabel(DNSHostLabel, { tlsCompatible: tlsCompatible });
60
+ var endpointRegion = useArnRegion ? region : clientRegion;
61
+ var signingRegion = useArnRegion ? region : clientSigningRegion;
62
+ return {
63
+ bucketEndpoint: true,
64
+ hostname: DNSHostLabel + "." + service + (isFipsRegion(clientRegion) ? "-fips" : "") + "." + getPseudoRegion(endpointRegion) + "." + hostnameSuffix,
65
+ signingRegion: signingRegion,
66
+ signingService: service,
67
+ };
68
+ };
69
+ var getEndpointFromMRAPArn = function (_a) {
70
+ var disableMultiregionAccessPoints = _a.disableMultiregionAccessPoints, _b = _a.dualstackEndpoint, dualstackEndpoint = _b === void 0 ? false : _b, isCustomEndpoint = _a.isCustomEndpoint, mrapAlias = _a.mrapAlias, hostnameSuffix = _a.hostnameSuffix;
71
+ if (disableMultiregionAccessPoints === true) {
72
+ throw new Error("SDK is attempting to use a MRAP ARN. Please enable to feature.");
73
+ }
74
+ validateMrapAlias(mrapAlias);
75
+ validateNoDualstack(dualstackEndpoint);
76
+ return {
77
+ bucketEndpoint: true,
78
+ hostname: "" + mrapAlias + (isCustomEndpoint ? "" : ".accesspoint.s3-global") + "." + hostnameSuffix,
79
+ signingRegion: "*",
80
+ };
81
+ };
82
+ var getEndpointFromOutpostArn = function (_a) {
83
+ 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.tlsCompatible, tlsCompatible = _d === void 0 ? true : _d, accesspointName = _a.accesspointName, isCustomEndpoint = _a.isCustomEndpoint, hostnameSuffix = _a.hostnameSuffix;
84
+ validateRegionalClient(clientRegion);
85
+ validateRegion(bucketName.region, { useArnRegion: useArnRegion, clientRegion: clientRegion, clientSigningRegion: clientSigningRegion });
86
+ var DNSHostLabel = accesspointName + "-" + bucketName.accountId;
87
+ validateDNSHostLabel(DNSHostLabel, { tlsCompatible: tlsCompatible });
88
+ var endpointRegion = useArnRegion ? bucketName.region : clientRegion;
89
+ var signingRegion = useArnRegion ? bucketName.region : clientSigningRegion;
90
+ validateOutpostService(bucketName.service);
91
+ validateDNSHostLabel(outpostId, { tlsCompatible: tlsCompatible });
92
+ validateNoDualstack(dualstackEndpoint);
93
+ validateNoFIPS(endpointRegion);
94
+ var hostnamePrefix = DNSHostLabel + "." + outpostId;
95
+ return {
96
+ bucketEndpoint: true,
97
+ hostname: "" + hostnamePrefix + (isCustomEndpoint ? "" : ".s3-outposts." + endpointRegion) + "." + hostnameSuffix,
98
+ signingRegion: signingRegion,
99
+ signingService: "s3-outposts",
100
+ };
101
+ };
102
+ var getEndpointFromAccessPointArn = function (_a) {
103
+ 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.tlsCompatible, tlsCompatible = _d === void 0 ? true : _d, accesspointName = _a.accesspointName, isCustomEndpoint = _a.isCustomEndpoint, hostnameSuffix = _a.hostnameSuffix;
104
+ validateRegionalClient(clientRegion);
105
+ validateRegion(bucketName.region, { useArnRegion: useArnRegion, clientRegion: clientRegion, clientSigningRegion: clientSigningRegion, allowFipsRegion: true });
106
+ var hostnamePrefix = accesspointName + "-" + bucketName.accountId;
107
+ validateDNSHostLabel(hostnamePrefix, { tlsCompatible: tlsCompatible });
108
+ var endpointRegion = useArnRegion ? bucketName.region : clientRegion;
109
+ var signingRegion = useArnRegion ? bucketName.region : clientSigningRegion;
110
+ validateS3Service(bucketName.service);
111
+ return {
112
+ bucketEndpoint: true,
113
+ hostname: "" + hostnamePrefix + (isCustomEndpoint
114
+ ? ""
115
+ : ".s3-accesspoint" + (isFipsRegion(clientRegion) ? "-fips" : "") + (dualstackEndpoint ? ".dualstack" : "") + "." + getPseudoRegion(endpointRegion)) + "." + hostnameSuffix,
116
+ signingRegion: signingRegion,
117
+ };
118
+ };
@@ -0,0 +1,144 @@
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[.-]([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 getPseudoRegion = function (region) { return (isFipsRegion(region) ? region.replace(/fips-|-fips/, "") : region); };
11
+ export var isDnsCompatibleBucketName = function (bucketName) {
12
+ return DOMAIN_PATTERN.test(bucketName) && !IP_ADDRESS_PATTERN.test(bucketName) && !DOTS_PATTERN.test(bucketName);
13
+ };
14
+ var getRegionalSuffix = function (hostname) {
15
+ var parts = hostname.match(S3_HOSTNAME_PATTERN);
16
+ return [parts[2], hostname.replace(new RegExp("^" + parts[0]), "")];
17
+ };
18
+ export var getSuffix = function (hostname) {
19
+ return S3_US_EAST_1_ALTNAME_PATTERN.test(hostname) ? ["us-east-1", AWS_PARTITION_SUFFIX] : getRegionalSuffix(hostname);
20
+ };
21
+ export var getSuffixForArnEndpoint = function (hostname) {
22
+ return S3_US_EAST_1_ALTNAME_PATTERN.test(hostname)
23
+ ? [hostname.replace("." + AWS_PARTITION_SUFFIX, ""), AWS_PARTITION_SUFFIX]
24
+ : getRegionalSuffix(hostname);
25
+ };
26
+ export var validateArnEndpointOptions = function (options) {
27
+ if (options.pathStyleEndpoint) {
28
+ throw new Error("Path-style S3 endpoint is not supported when bucket is an ARN");
29
+ }
30
+ if (options.accelerateEndpoint) {
31
+ throw new Error("Accelerate endpoint is not supported when bucket is an ARN");
32
+ }
33
+ if (!options.tlsCompatible) {
34
+ throw new Error("HTTPS is required when bucket is an ARN");
35
+ }
36
+ };
37
+ export var validateService = function (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
+ export var validateS3Service = function (service) {
43
+ if (service !== "s3") {
44
+ throw new Error("Expect 's3' in Accesspoint ARN service component");
45
+ }
46
+ };
47
+ export var validateOutpostService = function (service) {
48
+ if (service !== "s3-outposts") {
49
+ throw new Error("Expect 's3-posts' in Outpost ARN service component");
50
+ }
51
+ };
52
+ export var validatePartition = function (partition, options) {
53
+ if (partition !== options.clientPartition) {
54
+ throw new Error("Partition in ARN is incompatible, got \"" + partition + "\" but expected \"" + options.clientPartition + "\"");
55
+ }
56
+ };
57
+ export var validateRegion = function (region, options) {
58
+ if (region === "") {
59
+ throw new Error("ARN region is empty");
60
+ }
61
+ if (isFipsRegion(options.clientRegion)) {
62
+ if (!options.allowFipsRegion) {
63
+ throw new Error("FIPS region is not supported");
64
+ }
65
+ else if (!isEqualRegions(region, options.clientRegion)) {
66
+ throw new Error("Client FIPS region " + options.clientRegion + " doesn't match region " + region + " in ARN");
67
+ }
68
+ }
69
+ if (!options.useArnRegion &&
70
+ !isEqualRegions(region, options.clientRegion || "") &&
71
+ !isEqualRegions(region, options.clientSigningRegion || "")) {
72
+ throw new Error("Region in ARN is incompatible, got " + region + " but expected " + options.clientRegion);
73
+ }
74
+ };
75
+ export var validateRegionalClient = function (region) {
76
+ if (["s3-external-1", "aws-global"].includes(getPseudoRegion(region))) {
77
+ throw new Error("Client region " + region + " is not regional");
78
+ }
79
+ };
80
+ export var isFipsRegion = function (region) { return region.startsWith("fips-") || region.endsWith("-fips"); };
81
+ var isEqualRegions = function (regionA, regionB) {
82
+ return regionA === regionB || getPseudoRegion(regionA) === regionB || regionA === getPseudoRegion(regionB);
83
+ };
84
+ export var validateAccountId = function (accountId) {
85
+ if (!/[0-9]{12}/.exec(accountId)) {
86
+ throw new Error("Access point ARN accountID does not match regex '[0-9]{12}'");
87
+ }
88
+ };
89
+ export var validateDNSHostLabel = function (label, options) {
90
+ if (options === void 0) { options = { tlsCompatible: true }; }
91
+ if (label.length >= 64 ||
92
+ !/^[a-z0-9][a-z0-9.-]*[a-z0-9]$/.test(label) ||
93
+ /(\d+\.){3}\d+/.test(label) ||
94
+ /[.-]{2}/.test(label) ||
95
+ ((options === null || options === void 0 ? void 0 : options.tlsCompatible) && DOT_PATTERN.test(label))) {
96
+ throw new Error("Invalid DNS label " + label);
97
+ }
98
+ };
99
+ export var validateCustomEndpoint = function (options) {
100
+ if (options.isCustomEndpoint) {
101
+ if (options.dualstackEndpoint)
102
+ throw new Error("Dualstack endpoint is not supported with custom endpoint");
103
+ if (options.accelerateEndpoint)
104
+ throw new Error("Accelerate endpoint is not supported with custom endpoint");
105
+ }
106
+ };
107
+ export var getArnResources = function (resource) {
108
+ var delimiter = resource.includes(":") ? ":" : "/";
109
+ var _a = __read(resource.split(delimiter)), resourceType = _a[0], rest = _a.slice(1);
110
+ if (resourceType === "accesspoint") {
111
+ if (rest.length !== 1 || rest[0] === "") {
112
+ throw new Error("Access Point ARN should have one resource accesspoint" + delimiter + "{accesspointname}");
113
+ }
114
+ return { accesspointName: rest[0] };
115
+ }
116
+ else if (resourceType === "outpost") {
117
+ if (!rest[0] || rest[1] !== "accesspoint" || !rest[2] || rest.length !== 3) {
118
+ throw new Error("Outpost ARN should have resource outpost" + delimiter + "{outpostId}" + delimiter + "accesspoint" + delimiter + "{accesspointName}");
119
+ }
120
+ var _b = __read(rest, 3), outpostId = _b[0], _1 = _b[1], accesspointName = _b[2];
121
+ return { outpostId: outpostId, accesspointName: accesspointName };
122
+ }
123
+ else {
124
+ throw new Error("ARN resource should begin with 'accesspoint" + delimiter + "' or 'outpost" + delimiter + "'");
125
+ }
126
+ };
127
+ export var validateNoDualstack = function (dualstackEndpoint) {
128
+ if (dualstackEndpoint)
129
+ throw new Error("Dualstack endpoint is not supported with Outpost or Multi-region Access Point ARN.");
130
+ };
131
+ export var validateNoFIPS = function (region) {
132
+ if (isFipsRegion(region !== null && region !== void 0 ? region : ""))
133
+ throw new Error("FIPS region is not supported with Outpost, got " + region);
134
+ };
135
+ export var validateMrapAlias = function (name) {
136
+ try {
137
+ name.split(".").forEach(function (label) {
138
+ validateDNSHostLabel(label);
139
+ });
140
+ }
141
+ catch (e) {
142
+ throw new Error("\"" + name + "\" is not a DNS compatible name.");
143
+ }
144
+ };
@@ -0,0 +1,53 @@
1
+ import { __assign } from "tslib";
2
+ export function resolveBucketEndpointConfig(input) {
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.useDualstackEndpoint, useDualstackEndpoint = _d === void 0 ? false : _d, _e = input.useArnRegion, useArnRegion = _e === void 0 ? false : _e, _f = input.disableMultiregionAccessPoints, disableMultiregionAccessPoints = _f === void 0 ? false : _f;
4
+ return __assign(__assign({}, input), { bucketEndpoint: bucketEndpoint, forcePathStyle: forcePathStyle, useAccelerateEndpoint: useAccelerateEndpoint, useDualstackEndpoint: useDualstackEndpoint, useArnRegion: typeof useArnRegion === "function" ? useArnRegion : function () { return Promise.resolve(useArnRegion); }, disableMultiregionAccessPoints: typeof disableMultiregionAccessPoints === "function"
5
+ ? disableMultiregionAccessPoints
6
+ : function () { return Promise.resolve(disableMultiregionAccessPoints); } });
7
+ }
8
+ export var NODE_USE_ARN_REGION_ENV_NAME = "AWS_S3_USE_ARN_REGION";
9
+ export var NODE_USE_ARN_REGION_INI_NAME = "s3_use_arn_region";
10
+ export var NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME = "AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS";
11
+ export var NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME = "s3_disable_multiregion_access_points";
12
+ export var NODE_USE_ARN_REGION_CONFIG_OPTIONS = {
13
+ environmentVariableSelector: function (env) {
14
+ if (!Object.prototype.hasOwnProperty.call(env, NODE_USE_ARN_REGION_ENV_NAME))
15
+ return undefined;
16
+ if (env[NODE_USE_ARN_REGION_ENV_NAME] === "true")
17
+ return true;
18
+ if (env[NODE_USE_ARN_REGION_ENV_NAME] === "false")
19
+ return false;
20
+ throw new Error("Cannot load env " + NODE_USE_ARN_REGION_ENV_NAME + ". Expected \"true\" or \"false\", got " + env[NODE_USE_ARN_REGION_ENV_NAME] + ".");
21
+ },
22
+ configFileSelector: function (profile) {
23
+ if (!Object.prototype.hasOwnProperty.call(profile, NODE_USE_ARN_REGION_INI_NAME))
24
+ return undefined;
25
+ if (profile[NODE_USE_ARN_REGION_INI_NAME] === "true")
26
+ return true;
27
+ if (profile[NODE_USE_ARN_REGION_INI_NAME] === "false")
28
+ return false;
29
+ throw new Error("Cannot load shared config entry " + NODE_USE_ARN_REGION_INI_NAME + ". Expected \"true\" or \"false\", got " + profile[NODE_USE_ARN_REGION_INI_NAME] + ".");
30
+ },
31
+ default: false,
32
+ };
33
+ export var NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS = {
34
+ environmentVariableSelector: function (env) {
35
+ if (!Object.prototype.hasOwnProperty.call(env, NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME))
36
+ return undefined;
37
+ if (env[NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME] === "true")
38
+ return true;
39
+ if (env[NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME] === "false")
40
+ return false;
41
+ throw new Error("Cannot load env " + NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME + ". Expected \"true\" or \"false\", got " + env[NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME] + ".");
42
+ },
43
+ configFileSelector: function (profile) {
44
+ if (!Object.prototype.hasOwnProperty.call(profile, NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME))
45
+ return undefined;
46
+ if (profile[NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME] === "true")
47
+ return true;
48
+ if (profile[NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME] === "false")
49
+ return false;
50
+ throw new Error("Cannot load shared config entry " + NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME + ". Expected \"true\" or \"false\", got " + profile[NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME] + ".");
51
+ },
52
+ default: false,
53
+ };
File without changes
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ export * from "./bucketEndpointMiddleware";
2
+ export * from "./bucketHostname";
3
+ export * from "./configurations";
4
+ export { getArnResources, getPseudoRegion, getSuffixForArnEndpoint, validateOutpostService, validatePartition, validateAccountId, validateRegion, validateDNSHostLabel, validateNoDualstack, validateNoFIPS, } from "./bucketHostnameUtils";
@@ -22,30 +22,15 @@ export interface ArnHostnameParams extends Pick<BucketHostnameParams, Exclude<ke
22
22
  disableMultiregionAccessPoints?: boolean;
23
23
  }
24
24
  export declare const isBucketNameOptions: (options: BucketHostnameParams | ArnHostnameParams) => options is BucketHostnameParams;
25
- /**
26
- * Get pseudo region from supplied region. For example, if supplied with `fips-us-west-2`, it returns `us-west-2`.
27
- * @internal
28
- */
25
+
29
26
  export declare const getPseudoRegion: (region: string) => string;
30
- /**
31
- * Determines whether a given string is DNS compliant per the rules outlined by
32
- * S3. Length, capitaization, and leading dot restrictions are enforced by the
33
- * DOMAIN_PATTERN regular expression.
34
- * @internal
35
- *
36
- * @see https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
37
- */
27
+
38
28
  export declare const isDnsCompatibleBucketName: (bucketName: string) => boolean;
39
29
  export declare const getSuffix: (hostname: string) => [
40
30
  string,
41
31
  string
42
32
  ];
43
- /**
44
- * Infer region and hostname suffix from a complete hostname
45
- * @internal
46
- * @param hostname - Hostname
47
- * @returns [Region, Hostname suffix]
48
- */
33
+
49
34
  export declare const getSuffixForArnEndpoint: (hostname: string) => [
50
35
  string,
51
36
  string
@@ -58,43 +43,24 @@ export declare const validateArnEndpointOptions: (options: {
58
43
  export declare const validateService: (service: string) => void;
59
44
  export declare const validateS3Service: (service: string) => void;
60
45
  export declare const validateOutpostService: (service: string) => void;
61
- /**
62
- * Validate partition inferred from ARN is the same to `options.clientPartition`.
63
- * @internal
64
- */
46
+
65
47
  export declare const validatePartition: (partition: string, options: {
66
48
  clientPartition: string;
67
49
  }) => void;
68
- /**
69
- * validate region value inferred from ARN. If `options.useArnRegion` is set, it validates the region is not a FIPS
70
- * region. If `options.useArnRegion` is unset, it validates the region is equal to `options.clientRegion` or
71
- * `options.clientSigningRegion`.
72
- * @internal
73
- */
50
+
74
51
  export declare const validateRegion: (region: string, options: {
75
52
  useArnRegion?: boolean;
76
53
  allowFipsRegion?: boolean;
77
54
  clientRegion: string;
78
55
  clientSigningRegion: string;
79
56
  }) => void;
80
- /**
81
- *
82
- * @param region
83
- */
57
+
84
58
  export declare const validateRegionalClient: (region: string) => void;
85
- /**
86
- * @internal
87
- */
59
+
88
60
  export declare const isFipsRegion: (region: string) => boolean;
89
- /**
90
- * Validate an account ID
91
- * @internal
92
- */
61
+
93
62
  export declare const validateAccountId: (accountId: string) => void;
94
- /**
95
- * Validate a host label according to https://tools.ietf.org/html/rfc3986#section-3.2.2
96
- * @internal
97
- */
63
+
98
64
  export declare const validateDNSHostLabel: (label: string, options?: {
99
65
  tlsCompatible?: boolean;
100
66
  }) => void;
@@ -103,29 +69,14 @@ export declare const validateCustomEndpoint: (options: {
103
69
  dualstackEndpoint?: boolean;
104
70
  accelerateEndpoint?: boolean;
105
71
  }) => void;
106
- /**
107
- * Validate and parse an Access Point ARN or Outposts ARN
108
- * @internal
109
- *
110
- * @param resource - The resource section of an ARN
111
- * @returns Access Point Name and optional Outpost ID.
112
- */
72
+
113
73
  export declare const getArnResources: (resource: string) => {
114
74
  accesspointName: string;
115
75
  outpostId?: string;
116
76
  };
117
- /**
118
- * Throw if dual stack configuration is set to true.
119
- * @internal
120
- */
77
+
121
78
  export declare const validateNoDualstack: (dualstackEndpoint?: boolean | undefined) => void;
122
- /**
123
- * Validate region is not appended or prepended with a `fips-`
124
- * @internal
125
- */
79
+
126
80
  export declare const validateNoFIPS: (region?: string | undefined) => void;
127
- /**
128
- * Validate the multi-region access point alias.
129
- * @private
130
- */
81
+
131
82
  export declare const validateMrapAlias: (name: string) => void;
@@ -0,0 +1,49 @@
1
+ import { LoadedConfigSelectors } from "@aws-sdk/node-config-provider";
2
+ import { Provider, RegionInfoProvider } from "@aws-sdk/types";
3
+ export interface BucketEndpointInputConfig {
4
+
5
+ bucketEndpoint?: boolean;
6
+
7
+ forcePathStyle?: boolean;
8
+
9
+ useAccelerateEndpoint?: boolean;
10
+
11
+ useDualstackEndpoint?: boolean;
12
+
13
+ useArnRegion?: boolean | Provider<boolean>;
14
+
15
+ disableMultiregionAccessPoints?: boolean | Provider<boolean>;
16
+ }
17
+ interface PreviouslyResolved {
18
+ isCustomEndpoint: boolean;
19
+ region: Provider<string>;
20
+ regionInfoProvider: RegionInfoProvider;
21
+ }
22
+ export interface BucketEndpointResolvedConfig {
23
+
24
+ isCustomEndpoint: boolean;
25
+
26
+ bucketEndpoint: boolean;
27
+
28
+ forcePathStyle: boolean;
29
+
30
+ useAccelerateEndpoint: boolean;
31
+
32
+ useDualstackEndpoint: boolean;
33
+
34
+ useArnRegion: Provider<boolean>;
35
+
36
+ region: Provider<string>;
37
+
38
+ regionInfoProvider: RegionInfoProvider;
39
+ disableMultiregionAccessPoints: Provider<boolean>;
40
+ }
41
+ export declare function resolveBucketEndpointConfig<T>(input: T & PreviouslyResolved & BucketEndpointInputConfig): T & BucketEndpointResolvedConfig;
42
+ export declare const NODE_USE_ARN_REGION_ENV_NAME = "AWS_S3_USE_ARN_REGION";
43
+ export declare const NODE_USE_ARN_REGION_INI_NAME = "s3_use_arn_region";
44
+ export declare const NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME = "AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS";
45
+ export declare const NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME = "s3_disable_multiregion_access_points";
46
+
47
+ export declare const NODE_USE_ARN_REGION_CONFIG_OPTIONS: LoadedConfigSelectors<boolean>;
48
+ export declare const NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS: LoadedConfigSelectors<boolean>;
49
+ export {};
File without changes
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-bucket-endpoint",
3
- "version": "3.34.0",
3
+ "version": "3.38.0",
4
4
  "scripts": {
5
5
  "build": "yarn build:cjs && yarn build:es && yarn build:types",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",
7
7
  "build:es": "tsc -p tsconfig.es.json",
8
8
  "build:types": "tsc -p tsconfig.types.json",
9
- "downlevel-dts": "downlevel-dts dist/types dist/types/ts3.4",
9
+ "downlevel-dts": "downlevel-dts dist-types dist-types/ts3.4",
10
10
  "test": "jest"
11
11
  },
12
- "main": "./dist/cjs/index.js",
13
- "module": "./dist/es/index.js",
14
- "types": "./dist/types/index.d.ts",
12
+ "main": "./dist-cjs/index.js",
13
+ "module": "./dist-es/index.js",
14
+ "types": "./dist-types/index.d.ts",
15
15
  "author": {
16
16
  "name": "AWS SDK for JavaScript Team",
17
17
  "url": "https://aws.amazon.com/javascript/"
18
18
  },
19
19
  "license": "Apache-2.0",
20
20
  "dependencies": {
21
- "@aws-sdk/protocol-http": "3.34.0",
22
- "@aws-sdk/types": "3.34.0",
23
- "@aws-sdk/util-arn-parser": "3.34.0",
21
+ "@aws-sdk/protocol-http": "3.38.0",
22
+ "@aws-sdk/types": "3.38.0",
23
+ "@aws-sdk/util-arn-parser": "3.37.0",
24
24
  "tslib": "^2.3.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@aws-sdk/middleware-stack": "3.34.0",
28
- "@aws-sdk/node-config-provider": "3.34.0",
27
+ "@aws-sdk/middleware-stack": "3.38.0",
28
+ "@aws-sdk/node-config-provider": "3.38.0",
29
29
  "@types/jest": "^26.0.4",
30
30
  "jest": "^26.1.0",
31
31
  "typescript": "~4.3.5"
@@ -35,11 +35,14 @@
35
35
  },
36
36
  "typesVersions": {
37
37
  "<4.0": {
38
- "dist/types/*": [
39
- "dist/types/ts3.4/*"
38
+ "dist-types/*": [
39
+ "dist-types/ts3.4/*"
40
40
  ]
41
41
  }
42
42
  },
43
+ "files": [
44
+ "dist-*"
45
+ ],
43
46
  "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages/middleware-bucket-endpoint",
44
47
  "repository": {
45
48
  "type": "git",