fix: 修复配额说明重复和undefined问题

- 在editStorageForm中初始化oss_storage_quota_value和oss_quota_unit
- 删除重复的旧配额说明块,保留新的当前配额设置显示

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-22 19:39:53 +08:00
commit 4350113979
7649 changed files with 897277 additions and 0 deletions

View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,4 @@
# @aws-sdk/middleware-bucket-endpoint
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/middleware-bucket-endpoint/latest.svg)](https://www.npmjs.com/package/@aws-sdk/middleware-bucket-endpoint)
[![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/middleware-bucket-endpoint.svg)](https://www.npmjs.com/package/@aws-sdk/middleware-bucket-endpoint)

View File

@@ -0,0 +1,352 @@
'use strict';
var utilConfigProvider = require('@smithy/util-config-provider');
var utilArnParser = require('@aws-sdk/util-arn-parser');
var protocolHttp = require('@smithy/protocol-http');
const NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME = "AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS";
const NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME = "s3_disable_multiregion_access_points";
const NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS = {
environmentVariableSelector: (env) => utilConfigProvider.booleanSelector(env, NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME, utilConfigProvider.SelectorType.ENV),
configFileSelector: (profile) => utilConfigProvider.booleanSelector(profile, NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME, utilConfigProvider.SelectorType.CONFIG),
default: false,
};
const NODE_USE_ARN_REGION_ENV_NAME = "AWS_S3_USE_ARN_REGION";
const NODE_USE_ARN_REGION_INI_NAME = "s3_use_arn_region";
const NODE_USE_ARN_REGION_CONFIG_OPTIONS = {
environmentVariableSelector: (env) => utilConfigProvider.booleanSelector(env, NODE_USE_ARN_REGION_ENV_NAME, utilConfigProvider.SelectorType.ENV),
configFileSelector: (profile) => utilConfigProvider.booleanSelector(profile, NODE_USE_ARN_REGION_INI_NAME, utilConfigProvider.SelectorType.CONFIG),
default: undefined,
};
const DOMAIN_PATTERN = /^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/;
const IP_ADDRESS_PATTERN = /(\d+\.){3}\d+/;
const DOTS_PATTERN = /\.\./;
const DOT_PATTERN = /\./;
const S3_HOSTNAME_PATTERN = /^(.+\.)?s3(-fips)?(\.dualstack)?[.-]([a-z0-9-]+)\./;
const S3_US_EAST_1_ALTNAME_PATTERN = /^s3(-external-1)?\.amazonaws\.com$/;
const AWS_PARTITION_SUFFIX = "amazonaws.com";
const isBucketNameOptions = (options) => typeof options.bucketName === "string";
const isDnsCompatibleBucketName = (bucketName) => DOMAIN_PATTERN.test(bucketName) && !IP_ADDRESS_PATTERN.test(bucketName) && !DOTS_PATTERN.test(bucketName);
const getRegionalSuffix = (hostname) => {
const parts = hostname.match(S3_HOSTNAME_PATTERN);
return [parts[4], hostname.replace(new RegExp(`^${parts[0]}`), "")];
};
const getSuffix = (hostname) => S3_US_EAST_1_ALTNAME_PATTERN.test(hostname) ? ["us-east-1", AWS_PARTITION_SUFFIX] : getRegionalSuffix(hostname);
const getSuffixForArnEndpoint = (hostname) => S3_US_EAST_1_ALTNAME_PATTERN.test(hostname)
? [hostname.replace(`.${AWS_PARTITION_SUFFIX}`, ""), AWS_PARTITION_SUFFIX]
: getRegionalSuffix(hostname);
const validateArnEndpointOptions = (options) => {
if (options.pathStyleEndpoint) {
throw new Error("Path-style S3 endpoint is not supported when bucket is an ARN");
}
if (options.accelerateEndpoint) {
throw new Error("Accelerate endpoint is not supported when bucket is an ARN");
}
if (!options.tlsCompatible) {
throw new Error("HTTPS is required when bucket is an ARN");
}
};
const validateService = (service) => {
if (service !== "s3" && service !== "s3-outposts" && service !== "s3-object-lambda") {
throw new Error("Expect 's3' or 's3-outposts' or 's3-object-lambda' in ARN service component");
}
};
const validateS3Service = (service) => {
if (service !== "s3") {
throw new Error("Expect 's3' in Accesspoint ARN service component");
}
};
const validateOutpostService = (service) => {
if (service !== "s3-outposts") {
throw new Error("Expect 's3-posts' in Outpost ARN service component");
}
};
const validatePartition = (partition, options) => {
if (partition !== options.clientPartition) {
throw new Error(`Partition in ARN is incompatible, got "${partition}" but expected "${options.clientPartition}"`);
}
};
const validateRegion = (region, options) => { };
const validateRegionalClient = (region) => {
if (["s3-external-1", "aws-global"].includes(region)) {
throw new Error(`Client region ${region} is not regional`);
}
};
const validateAccountId = (accountId) => {
if (!/[0-9]{12}/.exec(accountId)) {
throw new Error("Access point ARN accountID does not match regex '[0-9]{12}'");
}
};
const validateDNSHostLabel = (label, options = { tlsCompatible: true }) => {
if (label.length >= 64 ||
!/^[a-z0-9][a-z0-9.-]*[a-z0-9]$/.test(label) ||
/(\d+\.){3}\d+/.test(label) ||
/[.-]{2}/.test(label) ||
(options?.tlsCompatible && DOT_PATTERN.test(label))) {
throw new Error(`Invalid DNS label ${label}`);
}
};
const validateCustomEndpoint = (options) => {
if (options.isCustomEndpoint) {
if (options.dualstackEndpoint)
throw new Error("Dualstack endpoint is not supported with custom endpoint");
if (options.accelerateEndpoint)
throw new Error("Accelerate endpoint is not supported with custom endpoint");
}
};
const getArnResources = (resource) => {
const delimiter = resource.includes(":") ? ":" : "/";
const [resourceType, ...rest] = resource.split(delimiter);
if (resourceType === "accesspoint") {
if (rest.length !== 1 || rest[0] === "") {
throw new Error(`Access Point ARN should have one resource accesspoint${delimiter}{accesspointname}`);
}
return { accesspointName: rest[0] };
}
else if (resourceType === "outpost") {
if (!rest[0] || rest[1] !== "accesspoint" || !rest[2] || rest.length !== 3) {
throw new Error(`Outpost ARN should have resource outpost${delimiter}{outpostId}${delimiter}accesspoint${delimiter}{accesspointName}`);
}
const [outpostId, _, accesspointName] = rest;
return { outpostId, accesspointName };
}
else {
throw new Error(`ARN resource should begin with 'accesspoint${delimiter}' or 'outpost${delimiter}'`);
}
};
const validateNoDualstack = (dualstackEndpoint) => { };
const validateNoFIPS = (useFipsEndpoint) => {
if (useFipsEndpoint)
throw new Error(`FIPS region is not supported with Outpost.`);
};
const validateMrapAlias = (name) => {
try {
name.split(".").forEach((label) => {
validateDNSHostLabel(label);
});
}
catch (e) {
throw new Error(`"${name}" is not a DNS compatible name.`);
}
};
const bucketHostname = (options) => {
validateCustomEndpoint(options);
return isBucketNameOptions(options)
?
getEndpointFromBucketName(options)
:
getEndpointFromArn(options);
};
const getEndpointFromBucketName = ({ accelerateEndpoint = false, clientRegion: region, baseHostname, bucketName, dualstackEndpoint = false, fipsEndpoint = false, pathStyleEndpoint = false, tlsCompatible = true, isCustomEndpoint = false, }) => {
const [clientRegion, hostnameSuffix] = isCustomEndpoint ? [region, baseHostname] : getSuffix(baseHostname);
if (pathStyleEndpoint || !isDnsCompatibleBucketName(bucketName) || (tlsCompatible && DOT_PATTERN.test(bucketName))) {
return {
bucketEndpoint: false,
hostname: dualstackEndpoint ? `s3.dualstack.${clientRegion}.${hostnameSuffix}` : baseHostname,
};
}
if (accelerateEndpoint) {
baseHostname = `s3-accelerate${dualstackEndpoint ? ".dualstack" : ""}.${hostnameSuffix}`;
}
else if (dualstackEndpoint) {
baseHostname = `s3.dualstack.${clientRegion}.${hostnameSuffix}`;
}
return {
bucketEndpoint: true,
hostname: `${bucketName}.${baseHostname}`,
};
};
const getEndpointFromArn = (options) => {
const { isCustomEndpoint, baseHostname, clientRegion } = options;
const hostnameSuffix = isCustomEndpoint ? baseHostname : getSuffixForArnEndpoint(baseHostname)[1];
const { pathStyleEndpoint, accelerateEndpoint = false, fipsEndpoint = false, tlsCompatible = true, bucketName, clientPartition = "aws", } = options;
validateArnEndpointOptions({ pathStyleEndpoint, accelerateEndpoint, tlsCompatible });
const { service, partition, accountId, region, resource } = bucketName;
validateService(service);
validatePartition(partition, { clientPartition });
validateAccountId(accountId);
const { accesspointName, outpostId } = getArnResources(resource);
if (service === "s3-object-lambda") {
return getEndpointFromObjectLambdaArn({ ...options, tlsCompatible, bucketName, accesspointName, hostnameSuffix });
}
if (region === "") {
return getEndpointFromMRAPArn({ ...options, mrapAlias: accesspointName, hostnameSuffix });
}
if (outpostId) {
return getEndpointFromOutpostArn({ ...options, clientRegion, outpostId, accesspointName, hostnameSuffix });
}
return getEndpointFromAccessPointArn({ ...options, clientRegion, accesspointName, hostnameSuffix });
};
const getEndpointFromObjectLambdaArn = ({ dualstackEndpoint = false, fipsEndpoint = false, tlsCompatible = true, useArnRegion, clientRegion, clientSigningRegion = clientRegion, accesspointName, bucketName, hostnameSuffix, }) => {
const { accountId, region, service } = bucketName;
validateRegionalClient(clientRegion);
const DNSHostLabel = `${accesspointName}-${accountId}`;
validateDNSHostLabel(DNSHostLabel, { tlsCompatible });
const endpointRegion = useArnRegion ? region : clientRegion;
const signingRegion = useArnRegion ? region : clientSigningRegion;
return {
bucketEndpoint: true,
hostname: `${DNSHostLabel}.${service}${fipsEndpoint ? "-fips" : ""}.${endpointRegion}.${hostnameSuffix}`,
signingRegion,
signingService: service,
};
};
const getEndpointFromMRAPArn = ({ disableMultiregionAccessPoints, dualstackEndpoint = false, isCustomEndpoint, mrapAlias, hostnameSuffix, }) => {
if (disableMultiregionAccessPoints === true) {
throw new Error("SDK is attempting to use a MRAP ARN. Please enable to feature.");
}
validateMrapAlias(mrapAlias);
return {
bucketEndpoint: true,
hostname: `${mrapAlias}${isCustomEndpoint ? "" : `.accesspoint.s3-global`}.${hostnameSuffix}`,
signingRegion: "*",
};
};
const getEndpointFromOutpostArn = ({ useArnRegion, clientRegion, clientSigningRegion = clientRegion, bucketName, outpostId, dualstackEndpoint = false, fipsEndpoint = false, tlsCompatible = true, accesspointName, isCustomEndpoint, hostnameSuffix, }) => {
validateRegionalClient(clientRegion);
const DNSHostLabel = `${accesspointName}-${bucketName.accountId}`;
validateDNSHostLabel(DNSHostLabel, { tlsCompatible });
const endpointRegion = useArnRegion ? bucketName.region : clientRegion;
const signingRegion = useArnRegion ? bucketName.region : clientSigningRegion;
validateOutpostService(bucketName.service);
validateDNSHostLabel(outpostId, { tlsCompatible });
validateNoFIPS(fipsEndpoint);
const hostnamePrefix = `${DNSHostLabel}.${outpostId}`;
return {
bucketEndpoint: true,
hostname: `${hostnamePrefix}${isCustomEndpoint ? "" : `.s3-outposts.${endpointRegion}`}.${hostnameSuffix}`,
signingRegion,
signingService: "s3-outposts",
};
};
const getEndpointFromAccessPointArn = ({ useArnRegion, clientRegion, clientSigningRegion = clientRegion, bucketName, dualstackEndpoint = false, fipsEndpoint = false, tlsCompatible = true, accesspointName, isCustomEndpoint, hostnameSuffix, }) => {
validateRegionalClient(clientRegion);
const hostnamePrefix = `${accesspointName}-${bucketName.accountId}`;
validateDNSHostLabel(hostnamePrefix, { tlsCompatible });
const endpointRegion = useArnRegion ? bucketName.region : clientRegion;
const signingRegion = useArnRegion ? bucketName.region : clientSigningRegion;
validateS3Service(bucketName.service);
return {
bucketEndpoint: true,
hostname: `${hostnamePrefix}${isCustomEndpoint
? ""
: `.s3-accesspoint${fipsEndpoint ? "-fips" : ""}${dualstackEndpoint ? ".dualstack" : ""}.${endpointRegion}`}.${hostnameSuffix}`,
signingRegion,
};
};
const bucketEndpointMiddleware = (options) => (next, context) => async (args) => {
const { Bucket: bucketName } = args.input;
let replaceBucketInPath = options.bucketEndpoint;
const request = args.request;
if (protocolHttp.HttpRequest.isInstance(request)) {
if (options.bucketEndpoint) {
request.hostname = bucketName;
}
else if (utilArnParser.validate(bucketName)) {
const bucketArn = utilArnParser.parse(bucketName);
const clientRegion = await options.region();
const useDualstackEndpoint = await options.useDualstackEndpoint();
const useFipsEndpoint = await options.useFipsEndpoint();
const { partition, signingRegion = clientRegion } = (await options.regionInfoProvider(clientRegion, { useDualstackEndpoint, useFipsEndpoint })) || {};
const useArnRegion = await options.useArnRegion();
const { hostname, bucketEndpoint, signingRegion: modifiedSigningRegion, signingService, } = bucketHostname({
bucketName: bucketArn,
baseHostname: request.hostname,
accelerateEndpoint: options.useAccelerateEndpoint,
dualstackEndpoint: useDualstackEndpoint,
fipsEndpoint: useFipsEndpoint,
pathStyleEndpoint: options.forcePathStyle,
tlsCompatible: request.protocol === "https:",
useArnRegion,
clientPartition: partition,
clientSigningRegion: signingRegion,
clientRegion: clientRegion,
isCustomEndpoint: options.isCustomEndpoint,
disableMultiregionAccessPoints: await options.disableMultiregionAccessPoints(),
});
if (modifiedSigningRegion && modifiedSigningRegion !== signingRegion) {
context["signing_region"] = modifiedSigningRegion;
}
if (signingService && signingService !== "s3") {
context["signing_service"] = signingService;
}
request.hostname = hostname;
replaceBucketInPath = bucketEndpoint;
}
else {
const clientRegion = await options.region();
const dualstackEndpoint = await options.useDualstackEndpoint();
const fipsEndpoint = await options.useFipsEndpoint();
const { hostname, bucketEndpoint } = bucketHostname({
bucketName,
clientRegion,
baseHostname: request.hostname,
accelerateEndpoint: options.useAccelerateEndpoint,
dualstackEndpoint,
fipsEndpoint,
pathStyleEndpoint: options.forcePathStyle,
tlsCompatible: request.protocol === "https:",
isCustomEndpoint: options.isCustomEndpoint,
});
request.hostname = hostname;
replaceBucketInPath = bucketEndpoint;
}
if (replaceBucketInPath) {
request.path = request.path.replace(/^(\/)?[^\/]+/, "");
if (request.path === "") {
request.path = "/";
}
}
}
return next({ ...args, request });
};
const bucketEndpointMiddlewareOptions = {
tags: ["BUCKET_ENDPOINT"],
name: "bucketEndpointMiddleware",
relation: "before",
toMiddleware: "hostHeaderMiddleware",
override: true,
};
const getBucketEndpointPlugin = (options) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(bucketEndpointMiddleware(options), bucketEndpointMiddlewareOptions);
},
});
function resolveBucketEndpointConfig(input) {
const { bucketEndpoint = false, forcePathStyle = false, useAccelerateEndpoint = false, useArnRegion, disableMultiregionAccessPoints = false, } = input;
return Object.assign(input, {
bucketEndpoint,
forcePathStyle,
useAccelerateEndpoint,
useArnRegion: typeof useArnRegion === "function" ? useArnRegion : () => Promise.resolve(useArnRegion),
disableMultiregionAccessPoints: typeof disableMultiregionAccessPoints === "function"
? disableMultiregionAccessPoints
: () => Promise.resolve(disableMultiregionAccessPoints),
});
}
exports.NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS = NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS;
exports.NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME = NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME;
exports.NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME = NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME;
exports.NODE_USE_ARN_REGION_CONFIG_OPTIONS = NODE_USE_ARN_REGION_CONFIG_OPTIONS;
exports.NODE_USE_ARN_REGION_ENV_NAME = NODE_USE_ARN_REGION_ENV_NAME;
exports.NODE_USE_ARN_REGION_INI_NAME = NODE_USE_ARN_REGION_INI_NAME;
exports.bucketEndpointMiddleware = bucketEndpointMiddleware;
exports.bucketEndpointMiddlewareOptions = bucketEndpointMiddlewareOptions;
exports.bucketHostname = bucketHostname;
exports.getArnResources = getArnResources;
exports.getBucketEndpointPlugin = getBucketEndpointPlugin;
exports.getSuffixForArnEndpoint = getSuffixForArnEndpoint;
exports.resolveBucketEndpointConfig = resolveBucketEndpointConfig;
exports.validateAccountId = validateAccountId;
exports.validateDNSHostLabel = validateDNSHostLabel;
exports.validateNoDualstack = validateNoDualstack;
exports.validateNoFIPS = validateNoFIPS;
exports.validateOutpostService = validateOutpostService;
exports.validatePartition = validatePartition;
exports.validateRegion = validateRegion;

View File

@@ -0,0 +1,8 @@
import { booleanSelector, SelectorType } from "@smithy/util-config-provider";
export const NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME = "AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS";
export const NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME = "s3_disable_multiregion_access_points";
export const NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS = {
environmentVariableSelector: (env) => booleanSelector(env, NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME, SelectorType.ENV),
configFileSelector: (profile) => booleanSelector(profile, NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME, SelectorType.CONFIG),
default: false,
};

View File

@@ -0,0 +1,8 @@
import { booleanSelector, SelectorType } from "@smithy/util-config-provider";
export const NODE_USE_ARN_REGION_ENV_NAME = "AWS_S3_USE_ARN_REGION";
export const NODE_USE_ARN_REGION_INI_NAME = "s3_use_arn_region";
export const NODE_USE_ARN_REGION_CONFIG_OPTIONS = {
environmentVariableSelector: (env) => booleanSelector(env, NODE_USE_ARN_REGION_ENV_NAME, SelectorType.ENV),
configFileSelector: (profile) => booleanSelector(profile, NODE_USE_ARN_REGION_INI_NAME, SelectorType.CONFIG),
default: undefined,
};

View File

@@ -0,0 +1,81 @@
import { parse as parseArn, validate as validateArn } from "@aws-sdk/util-arn-parser";
import { HttpRequest } from "@smithy/protocol-http";
import { bucketHostname } from "./bucketHostname";
export const bucketEndpointMiddleware = (options) => (next, context) => async (args) => {
const { Bucket: bucketName } = args.input;
let replaceBucketInPath = options.bucketEndpoint;
const request = args.request;
if (HttpRequest.isInstance(request)) {
if (options.bucketEndpoint) {
request.hostname = bucketName;
}
else if (validateArn(bucketName)) {
const bucketArn = parseArn(bucketName);
const clientRegion = await options.region();
const useDualstackEndpoint = await options.useDualstackEndpoint();
const useFipsEndpoint = await options.useFipsEndpoint();
const { partition, signingRegion = clientRegion } = (await options.regionInfoProvider(clientRegion, { useDualstackEndpoint, useFipsEndpoint })) || {};
const useArnRegion = await options.useArnRegion();
const { hostname, bucketEndpoint, signingRegion: modifiedSigningRegion, signingService, } = bucketHostname({
bucketName: bucketArn,
baseHostname: request.hostname,
accelerateEndpoint: options.useAccelerateEndpoint,
dualstackEndpoint: useDualstackEndpoint,
fipsEndpoint: useFipsEndpoint,
pathStyleEndpoint: options.forcePathStyle,
tlsCompatible: request.protocol === "https:",
useArnRegion,
clientPartition: partition,
clientSigningRegion: signingRegion,
clientRegion: clientRegion,
isCustomEndpoint: options.isCustomEndpoint,
disableMultiregionAccessPoints: await options.disableMultiregionAccessPoints(),
});
if (modifiedSigningRegion && modifiedSigningRegion !== signingRegion) {
context["signing_region"] = modifiedSigningRegion;
}
if (signingService && signingService !== "s3") {
context["signing_service"] = signingService;
}
request.hostname = hostname;
replaceBucketInPath = bucketEndpoint;
}
else {
const clientRegion = await options.region();
const dualstackEndpoint = await options.useDualstackEndpoint();
const fipsEndpoint = await options.useFipsEndpoint();
const { hostname, bucketEndpoint } = bucketHostname({
bucketName,
clientRegion,
baseHostname: request.hostname,
accelerateEndpoint: options.useAccelerateEndpoint,
dualstackEndpoint,
fipsEndpoint,
pathStyleEndpoint: options.forcePathStyle,
tlsCompatible: request.protocol === "https:",
isCustomEndpoint: options.isCustomEndpoint,
});
request.hostname = hostname;
replaceBucketInPath = bucketEndpoint;
}
if (replaceBucketInPath) {
request.path = request.path.replace(/^(\/)?[^\/]+/, "");
if (request.path === "") {
request.path = "/";
}
}
}
return next({ ...args, request });
};
export const bucketEndpointMiddlewareOptions = {
tags: ["BUCKET_ENDPOINT"],
name: "bucketEndpointMiddleware",
relation: "before",
toMiddleware: "hostHeaderMiddleware",
override: true,
};
export const getBucketEndpointPlugin = (options) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(bucketEndpointMiddleware(options), bucketEndpointMiddlewareOptions);
},
});

View File

@@ -0,0 +1,106 @@
import { DOT_PATTERN, getArnResources, getSuffix, getSuffixForArnEndpoint, isBucketNameOptions, isDnsCompatibleBucketName, validateAccountId, validateArnEndpointOptions, validateCustomEndpoint, validateDNSHostLabel, validateMrapAlias, validateNoFIPS, validateOutpostService, validatePartition, validateRegionalClient, validateS3Service, validateService, } from "./bucketHostnameUtils";
export const bucketHostname = (options) => {
validateCustomEndpoint(options);
return isBucketNameOptions(options)
?
getEndpointFromBucketName(options)
:
getEndpointFromArn(options);
};
const getEndpointFromBucketName = ({ accelerateEndpoint = false, clientRegion: region, baseHostname, bucketName, dualstackEndpoint = false, fipsEndpoint = false, pathStyleEndpoint = false, tlsCompatible = true, isCustomEndpoint = false, }) => {
const [clientRegion, hostnameSuffix] = isCustomEndpoint ? [region, baseHostname] : getSuffix(baseHostname);
if (pathStyleEndpoint || !isDnsCompatibleBucketName(bucketName) || (tlsCompatible && DOT_PATTERN.test(bucketName))) {
return {
bucketEndpoint: false,
hostname: dualstackEndpoint ? `s3.dualstack.${clientRegion}.${hostnameSuffix}` : baseHostname,
};
}
if (accelerateEndpoint) {
baseHostname = `s3-accelerate${dualstackEndpoint ? ".dualstack" : ""}.${hostnameSuffix}`;
}
else if (dualstackEndpoint) {
baseHostname = `s3.dualstack.${clientRegion}.${hostnameSuffix}`;
}
return {
bucketEndpoint: true,
hostname: `${bucketName}.${baseHostname}`,
};
};
const getEndpointFromArn = (options) => {
const { isCustomEndpoint, baseHostname, clientRegion } = options;
const hostnameSuffix = isCustomEndpoint ? baseHostname : getSuffixForArnEndpoint(baseHostname)[1];
const { pathStyleEndpoint, accelerateEndpoint = false, fipsEndpoint = false, tlsCompatible = true, bucketName, clientPartition = "aws", } = options;
validateArnEndpointOptions({ pathStyleEndpoint, accelerateEndpoint, tlsCompatible });
const { service, partition, accountId, region, resource } = bucketName;
validateService(service);
validatePartition(partition, { clientPartition });
validateAccountId(accountId);
const { accesspointName, outpostId } = getArnResources(resource);
if (service === "s3-object-lambda") {
return getEndpointFromObjectLambdaArn({ ...options, tlsCompatible, bucketName, accesspointName, hostnameSuffix });
}
if (region === "") {
return getEndpointFromMRAPArn({ ...options, clientRegion, mrapAlias: accesspointName, hostnameSuffix });
}
if (outpostId) {
return getEndpointFromOutpostArn({ ...options, clientRegion, outpostId, accesspointName, hostnameSuffix });
}
return getEndpointFromAccessPointArn({ ...options, clientRegion, accesspointName, hostnameSuffix });
};
const getEndpointFromObjectLambdaArn = ({ dualstackEndpoint = false, fipsEndpoint = false, tlsCompatible = true, useArnRegion, clientRegion, clientSigningRegion = clientRegion, accesspointName, bucketName, hostnameSuffix, }) => {
const { accountId, region, service } = bucketName;
validateRegionalClient(clientRegion);
const DNSHostLabel = `${accesspointName}-${accountId}`;
validateDNSHostLabel(DNSHostLabel, { tlsCompatible });
const endpointRegion = useArnRegion ? region : clientRegion;
const signingRegion = useArnRegion ? region : clientSigningRegion;
return {
bucketEndpoint: true,
hostname: `${DNSHostLabel}.${service}${fipsEndpoint ? "-fips" : ""}.${endpointRegion}.${hostnameSuffix}`,
signingRegion,
signingService: service,
};
};
const getEndpointFromMRAPArn = ({ disableMultiregionAccessPoints, dualstackEndpoint = false, isCustomEndpoint, mrapAlias, hostnameSuffix, }) => {
if (disableMultiregionAccessPoints === true) {
throw new Error("SDK is attempting to use a MRAP ARN. Please enable to feature.");
}
validateMrapAlias(mrapAlias);
return {
bucketEndpoint: true,
hostname: `${mrapAlias}${isCustomEndpoint ? "" : `.accesspoint.s3-global`}.${hostnameSuffix}`,
signingRegion: "*",
};
};
const getEndpointFromOutpostArn = ({ useArnRegion, clientRegion, clientSigningRegion = clientRegion, bucketName, outpostId, dualstackEndpoint = false, fipsEndpoint = false, tlsCompatible = true, accesspointName, isCustomEndpoint, hostnameSuffix, }) => {
validateRegionalClient(clientRegion);
const DNSHostLabel = `${accesspointName}-${bucketName.accountId}`;
validateDNSHostLabel(DNSHostLabel, { tlsCompatible });
const endpointRegion = useArnRegion ? bucketName.region : clientRegion;
const signingRegion = useArnRegion ? bucketName.region : clientSigningRegion;
validateOutpostService(bucketName.service);
validateDNSHostLabel(outpostId, { tlsCompatible });
validateNoFIPS(fipsEndpoint);
const hostnamePrefix = `${DNSHostLabel}.${outpostId}`;
return {
bucketEndpoint: true,
hostname: `${hostnamePrefix}${isCustomEndpoint ? "" : `.s3-outposts.${endpointRegion}`}.${hostnameSuffix}`,
signingRegion,
signingService: "s3-outposts",
};
};
const getEndpointFromAccessPointArn = ({ useArnRegion, clientRegion, clientSigningRegion = clientRegion, bucketName, dualstackEndpoint = false, fipsEndpoint = false, tlsCompatible = true, accesspointName, isCustomEndpoint, hostnameSuffix, }) => {
validateRegionalClient(clientRegion);
const hostnamePrefix = `${accesspointName}-${bucketName.accountId}`;
validateDNSHostLabel(hostnamePrefix, { tlsCompatible });
const endpointRegion = useArnRegion ? bucketName.region : clientRegion;
const signingRegion = useArnRegion ? bucketName.region : clientSigningRegion;
validateS3Service(bucketName.service);
return {
bucketEndpoint: true,
hostname: `${hostnamePrefix}${isCustomEndpoint
? ""
: `.s3-accesspoint${fipsEndpoint ? "-fips" : ""}${dualstackEndpoint ? ".dualstack" : ""}.${endpointRegion}`}.${hostnameSuffix}`,
signingRegion,
};
};

View File

@@ -0,0 +1,111 @@
const DOMAIN_PATTERN = /^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/;
const IP_ADDRESS_PATTERN = /(\d+\.){3}\d+/;
const DOTS_PATTERN = /\.\./;
export const DOT_PATTERN = /\./;
export const S3_HOSTNAME_PATTERN = /^(.+\.)?s3(-fips)?(\.dualstack)?[.-]([a-z0-9-]+)\./;
const S3_US_EAST_1_ALTNAME_PATTERN = /^s3(-external-1)?\.amazonaws\.com$/;
const AWS_PARTITION_SUFFIX = "amazonaws.com";
export const isBucketNameOptions = (options) => typeof options.bucketName === "string";
export const isDnsCompatibleBucketName = (bucketName) => DOMAIN_PATTERN.test(bucketName) && !IP_ADDRESS_PATTERN.test(bucketName) && !DOTS_PATTERN.test(bucketName);
const getRegionalSuffix = (hostname) => {
const parts = hostname.match(S3_HOSTNAME_PATTERN);
return [parts[4], hostname.replace(new RegExp(`^${parts[0]}`), "")];
};
export const getSuffix = (hostname) => S3_US_EAST_1_ALTNAME_PATTERN.test(hostname) ? ["us-east-1", AWS_PARTITION_SUFFIX] : getRegionalSuffix(hostname);
export const getSuffixForArnEndpoint = (hostname) => S3_US_EAST_1_ALTNAME_PATTERN.test(hostname)
? [hostname.replace(`.${AWS_PARTITION_SUFFIX}`, ""), AWS_PARTITION_SUFFIX]
: getRegionalSuffix(hostname);
export const validateArnEndpointOptions = (options) => {
if (options.pathStyleEndpoint) {
throw new Error("Path-style S3 endpoint is not supported when bucket is an ARN");
}
if (options.accelerateEndpoint) {
throw new Error("Accelerate endpoint is not supported when bucket is an ARN");
}
if (!options.tlsCompatible) {
throw new Error("HTTPS is required when bucket is an ARN");
}
};
export const validateService = (service) => {
if (service !== "s3" && service !== "s3-outposts" && service !== "s3-object-lambda") {
throw new Error("Expect 's3' or 's3-outposts' or 's3-object-lambda' in ARN service component");
}
};
export const validateS3Service = (service) => {
if (service !== "s3") {
throw new Error("Expect 's3' in Accesspoint ARN service component");
}
};
export const validateOutpostService = (service) => {
if (service !== "s3-outposts") {
throw new Error("Expect 's3-posts' in Outpost ARN service component");
}
};
export const validatePartition = (partition, options) => {
if (partition !== options.clientPartition) {
throw new Error(`Partition in ARN is incompatible, got "${partition}" but expected "${options.clientPartition}"`);
}
};
export const validateRegion = (region, options) => { };
export const validateRegionalClient = (region) => {
if (["s3-external-1", "aws-global"].includes(region)) {
throw new Error(`Client region ${region} is not regional`);
}
};
export const validateAccountId = (accountId) => {
if (!/[0-9]{12}/.exec(accountId)) {
throw new Error("Access point ARN accountID does not match regex '[0-9]{12}'");
}
};
export const validateDNSHostLabel = (label, options = { tlsCompatible: true }) => {
if (label.length >= 64 ||
!/^[a-z0-9][a-z0-9.-]*[a-z0-9]$/.test(label) ||
/(\d+\.){3}\d+/.test(label) ||
/[.-]{2}/.test(label) ||
(options?.tlsCompatible && DOT_PATTERN.test(label))) {
throw new Error(`Invalid DNS label ${label}`);
}
};
export const validateCustomEndpoint = (options) => {
if (options.isCustomEndpoint) {
if (options.dualstackEndpoint)
throw new Error("Dualstack endpoint is not supported with custom endpoint");
if (options.accelerateEndpoint)
throw new Error("Accelerate endpoint is not supported with custom endpoint");
}
};
export const getArnResources = (resource) => {
const delimiter = resource.includes(":") ? ":" : "/";
const [resourceType, ...rest] = resource.split(delimiter);
if (resourceType === "accesspoint") {
if (rest.length !== 1 || rest[0] === "") {
throw new Error(`Access Point ARN should have one resource accesspoint${delimiter}{accesspointname}`);
}
return { accesspointName: rest[0] };
}
else if (resourceType === "outpost") {
if (!rest[0] || rest[1] !== "accesspoint" || !rest[2] || rest.length !== 3) {
throw new Error(`Outpost ARN should have resource outpost${delimiter}{outpostId}${delimiter}accesspoint${delimiter}{accesspointName}`);
}
const [outpostId, _, accesspointName] = rest;
return { outpostId, accesspointName };
}
else {
throw new Error(`ARN resource should begin with 'accesspoint${delimiter}' or 'outpost${delimiter}'`);
}
};
export const validateNoDualstack = (dualstackEndpoint) => { };
export const validateNoFIPS = (useFipsEndpoint) => {
if (useFipsEndpoint)
throw new Error(`FIPS region is not supported with Outpost.`);
};
export const validateMrapAlias = (name) => {
try {
name.split(".").forEach((label) => {
validateDNSHostLabel(label);
});
}
catch (e) {
throw new Error(`"${name}" is not a DNS compatible name.`);
}
};

View File

@@ -0,0 +1,12 @@
export function resolveBucketEndpointConfig(input) {
const { bucketEndpoint = false, forcePathStyle = false, useAccelerateEndpoint = false, useArnRegion, disableMultiregionAccessPoints = false, } = input;
return Object.assign(input, {
bucketEndpoint,
forcePathStyle,
useAccelerateEndpoint,
useArnRegion: typeof useArnRegion === "function" ? useArnRegion : () => Promise.resolve(useArnRegion),
disableMultiregionAccessPoints: typeof disableMultiregionAccessPoints === "function"
? disableMultiregionAccessPoints
: () => Promise.resolve(disableMultiregionAccessPoints),
});
}

View File

@@ -0,0 +1,6 @@
export * from "./NodeDisableMultiregionAccessPointConfigOptions";
export * from "./NodeUseArnRegionConfigOptions";
export * from "./bucketEndpointMiddleware";
export * from "./bucketHostname";
export * from "./configurations";
export { getArnResources, getSuffixForArnEndpoint, validateOutpostService, validatePartition, validateAccountId, validateRegion, validateDNSHostLabel, validateNoDualstack, validateNoFIPS, } from "./bucketHostnameUtils";

View File

@@ -0,0 +1,4 @@
import { LoadedConfigSelectors } from "@smithy/node-config-provider";
export declare const NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME = "AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS";
export declare const NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME = "s3_disable_multiregion_access_points";
export declare const NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS: LoadedConfigSelectors<boolean>;

View File

@@ -0,0 +1,9 @@
import { LoadedConfigSelectors } from "@smithy/node-config-provider";
export declare const NODE_USE_ARN_REGION_ENV_NAME = "AWS_S3_USE_ARN_REGION";
export declare const NODE_USE_ARN_REGION_INI_NAME = "s3_use_arn_region";
/**
* Config to load useArnRegion from environment variables and shared INI files
*
* @internal
*/
export declare const NODE_USE_ARN_REGION_CONFIG_OPTIONS: LoadedConfigSelectors<boolean | undefined>;

View File

@@ -0,0 +1,17 @@
import { BuildMiddleware, Pluggable, RelativeMiddlewareOptions } from "@smithy/types";
import { BucketEndpointResolvedConfig } from "./configurations";
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export declare const bucketEndpointMiddleware: (options: BucketEndpointResolvedConfig) => BuildMiddleware<any, any>;
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export declare const bucketEndpointMiddlewareOptions: RelativeMiddlewareOptions;
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export declare const getBucketEndpointPlugin: (options: BucketEndpointResolvedConfig) => Pluggable<any, any>;

View File

@@ -0,0 +1,16 @@
import { ArnHostnameParams, BucketHostnameParams } from "./bucketHostnameUtils";
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export interface BucketHostname {
hostname: string;
bucketEndpoint: boolean;
signingRegion?: string;
signingService?: string;
}
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export declare const bucketHostname: (options: BucketHostnameParams | ArnHostnameParams) => BucketHostname;

View File

@@ -0,0 +1,174 @@
import { ARN } from "@aws-sdk/util-arn-parser";
/**
* @deprecated unused as of EndpointsV2.
*/
export declare const DOT_PATTERN: RegExp;
/**
* @deprecated unused as of EndpointsV2.
*/
export declare const S3_HOSTNAME_PATTERN: RegExp;
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export interface AccessPointArn extends ARN {
accessPointName: string;
}
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export interface BucketHostnameParams {
isCustomEndpoint?: boolean;
baseHostname: string;
bucketName: string;
clientRegion: string;
accelerateEndpoint?: boolean;
dualstackEndpoint?: boolean;
fipsEndpoint?: boolean;
pathStyleEndpoint?: boolean;
tlsCompatible?: boolean;
}
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export interface ArnHostnameParams extends Omit<BucketHostnameParams, "bucketName"> {
bucketName: ARN;
clientSigningRegion?: string;
clientPartition?: string;
useArnRegion?: boolean;
disableMultiregionAccessPoints?: boolean;
}
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export declare const isBucketNameOptions: (options: BucketHostnameParams | ArnHostnameParams) => options is BucketHostnameParams;
/**
* Determines whether a given string is DNS compliant per the rules outlined by
* S3. Length, capitaization, and leading dot restrictions are enforced by the
* DOMAIN_PATTERN regular expression.
* @internal
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
*
* @deprecated unused as of EndpointsV2.
*/
export declare const isDnsCompatibleBucketName: (bucketName: string) => boolean;
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export declare const getSuffix: (hostname: string) => [string, string];
/**
* Infer region and hostname suffix from a complete hostname
* @internal
* @param hostname - Hostname
* @returns [Region, Hostname suffix]
*
* @deprecated unused as of EndpointsV2.
*/
export declare const getSuffixForArnEndpoint: (hostname: string) => [string, string];
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export declare const validateArnEndpointOptions: (options: {
accelerateEndpoint?: boolean;
tlsCompatible?: boolean;
pathStyleEndpoint?: boolean;
}) => void;
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export declare const validateService: (service: string) => void;
/**
* @deprecated unused as of EndpointsV2.
* @internal
*/
export declare const validateS3Service: (service: string) => void;
/**
* @internal
*/
export declare const validateOutpostService: (service: string) => void;
/**
* Validate partition inferred from ARN is the same to `options.clientPartition`.
* @internal
*/
export declare const validatePartition: (partition: string, options: {
clientPartition: string;
}) => void;
/**
* (Previous to deprecation)
* validate region value inferred from ARN. If `options.useArnRegion` is set, it validates the region is not a FIPS
* region. If `options.useArnRegion` is unset, it validates the region is equal to `options.clientRegion` or
* `options.clientSigningRegion`.
*
* @internal
*
* @deprecated validation is deferred to the endpoint ruleset.
*/
export declare const validateRegion: (region: string, options: {
useArnRegion?: boolean;
allowFipsRegion?: boolean;
clientRegion: string;
clientSigningRegion: string;
useFipsEndpoint: boolean;
}) => void;
/**
* @deprecated unused as of EndpointsV2.
*/
export declare const validateRegionalClient: (region: string) => void;
/**
* Validate an account ID
* @internal
*/
export declare const validateAccountId: (accountId: string) => void;
/**
* Validate a host label according to https://tools.ietf.org/html/rfc3986#section-3.2.2
* @internal
* @deprecated unused as of EndpointsV2.
*/
export declare const validateDNSHostLabel: (label: string, options?: {
tlsCompatible?: boolean;
}) => void;
/**
* @deprecated unused as of EndpointsV2.
*/
export declare const validateCustomEndpoint: (options: {
isCustomEndpoint?: boolean;
dualstackEndpoint?: boolean;
accelerateEndpoint?: boolean;
}) => void;
/**
* Validate and parse an Access Point ARN or Outposts ARN
* @internal
*
* @param resource - The resource section of an ARN
* @returns Access Point Name and optional Outpost ID.
*/
export declare const getArnResources: (resource: string) => {
accesspointName: string;
outpostId?: string;
};
/**
* (Prior to deprecation) Throw if dual stack configuration is set to true.
* @internal
*
* @deprecated validation deferred to endpoints ruleset.
*/
export declare const validateNoDualstack: (dualstackEndpoint?: boolean) => void;
/**
* Validate fips endpoint is not set up.
* @internal
* @deprecated unused as of EndpointsV2.
*/
export declare const validateNoFIPS: (useFipsEndpoint?: boolean) => void;
/**
* Validate the multi-region access point alias.
* @internal
* @deprecated unused as of EndpointsV2.
*/
export declare const validateMrapAlias: (name: string) => void;

View File

@@ -0,0 +1,95 @@
import { Provider, RegionInfoProvider } from "@smithy/types";
/**
* @deprecated unused as of EndpointsV2.
*/
export interface BucketEndpointInputConfig {
/**
* Whether to use the bucket name as the endpoint for this request. The bucket
* name must be a domain name with a CNAME record alias to an appropriate virtual
* hosted-style S3 hostname, e.g. a bucket of `images.johnsmith.net` and a DNS
* record of:
*
* ```
* images.johnsmith.net CNAME images.johnsmith.net.s3.amazonaws.com.
* ```
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#VirtualHostingCustomURLs
*/
bucketEndpoint?: boolean;
/**
* Whether to force path style URLs for S3 objects (e.g., https://s3.amazonaws.com/<bucketName>/<key> instead of https://<bucketName>.s3.amazonaws.com/<key>
*/
forcePathStyle?: boolean;
/**
* Whether to use the S3 Transfer Acceleration endpoint by default
*/
useAccelerateEndpoint?: boolean;
/**
* Whether to override the request region with the region inferred from requested resource's ARN. Defaults to false
*/
useArnRegion?: boolean | Provider<boolean>;
/**
* Whether to prevent SDK from making cross-region request when supplied bucket is a multi-region access point ARN.
* Defaults to false
*/
disableMultiregionAccessPoints?: boolean | Provider<boolean>;
}
/**
* @deprecated unused as of EndpointsV2.
*/
interface PreviouslyResolved {
isCustomEndpoint?: boolean;
region: Provider<string>;
regionInfoProvider: RegionInfoProvider;
useFipsEndpoint: Provider<boolean>;
useDualstackEndpoint: Provider<boolean>;
}
/**
* @deprecated unused as of EndpointsV2.
*/
export interface BucketEndpointResolvedConfig {
/**
* Whether the endpoint is specified by caller.
* @internal
*/
isCustomEndpoint?: boolean;
/**
* Resolved value for input config {@link BucketEndpointInputConfig.bucketEndpoint}
*/
bucketEndpoint: boolean;
/**
* Resolved value for input config {@link BucketEndpointInputConfig.forcePathStyle}
*/
forcePathStyle: boolean;
/**
* Resolved value for input config {@link BucketEndpointInputConfig.useAccelerateEndpoint}
*/
useAccelerateEndpoint: boolean;
/**
* Enables FIPS compatible endpoints.
*/
useFipsEndpoint: Provider<boolean>;
/**
* Enables IPv6/IPv4 dualstack endpoint.
*/
useDualstackEndpoint: Provider<boolean>;
/**
* Resolved value for input config {@link BucketEndpointInputConfig.useArnRegion}
*/
useArnRegion: Provider<boolean | undefined>;
/**
* Resolved value for input config {@link RegionInputConfig.region}
*/
region: Provider<string>;
/**
* Fetch related hostname, signing name or signing region with given region.
* @internal
*/
regionInfoProvider: RegionInfoProvider;
disableMultiregionAccessPoints: Provider<boolean>;
}
/**
* @deprecated unused as of EndpointsV2.
*/
export declare function resolveBucketEndpointConfig<T>(input: T & PreviouslyResolved & BucketEndpointInputConfig): T & BucketEndpointResolvedConfig;
export {};

View File

@@ -0,0 +1,6 @@
export * from "./NodeDisableMultiregionAccessPointConfigOptions";
export * from "./NodeUseArnRegionConfigOptions";
export * from "./bucketEndpointMiddleware";
export * from "./bucketHostname";
export * from "./configurations";
export { getArnResources, getSuffixForArnEndpoint, validateOutpostService, validatePartition, validateAccountId, validateRegion, validateDNSHostLabel, validateNoDualstack, validateNoFIPS, } from "./bucketHostnameUtils";

View File

@@ -0,0 +1,6 @@
import { LoadedConfigSelectors } from "@smithy/node-config-provider";
export declare const NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME =
"AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS";
export declare const NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME =
"s3_disable_multiregion_access_points";
export declare const NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS: LoadedConfigSelectors<boolean>;

View File

@@ -0,0 +1,6 @@
import { LoadedConfigSelectors } from "@smithy/node-config-provider";
export declare const NODE_USE_ARN_REGION_ENV_NAME = "AWS_S3_USE_ARN_REGION";
export declare const NODE_USE_ARN_REGION_INI_NAME = "s3_use_arn_region";
export declare const NODE_USE_ARN_REGION_CONFIG_OPTIONS: LoadedConfigSelectors<
boolean | undefined
>;

View File

@@ -0,0 +1,13 @@
import {
BuildMiddleware,
Pluggable,
RelativeMiddlewareOptions,
} from "@smithy/types";
import { BucketEndpointResolvedConfig } from "./configurations";
export declare const bucketEndpointMiddleware: (
options: BucketEndpointResolvedConfig
) => BuildMiddleware<any, any>;
export declare const bucketEndpointMiddlewareOptions: RelativeMiddlewareOptions;
export declare const getBucketEndpointPlugin: (
options: BucketEndpointResolvedConfig
) => Pluggable<any, any>;

View File

@@ -0,0 +1,10 @@
import { ArnHostnameParams, BucketHostnameParams } from "./bucketHostnameUtils";
export interface BucketHostname {
hostname: string;
bucketEndpoint: boolean;
signingRegion?: string;
signingService?: string;
}
export declare const bucketHostname: (
options: BucketHostnameParams | ArnHostnameParams
) => BucketHostname;

View File

@@ -0,0 +1,80 @@
import { ARN } from "@aws-sdk/util-arn-parser";
export declare const DOT_PATTERN: RegExp;
export declare const S3_HOSTNAME_PATTERN: RegExp;
export interface AccessPointArn extends ARN {
accessPointName: string;
}
export interface BucketHostnameParams {
isCustomEndpoint?: boolean;
baseHostname: string;
bucketName: string;
clientRegion: string;
accelerateEndpoint?: boolean;
dualstackEndpoint?: boolean;
fipsEndpoint?: boolean;
pathStyleEndpoint?: boolean;
tlsCompatible?: boolean;
}
export interface ArnHostnameParams
extends Pick<
BucketHostnameParams,
Exclude<keyof BucketHostnameParams, "bucketName">
> {
bucketName: ARN;
clientSigningRegion?: string;
clientPartition?: string;
useArnRegion?: boolean;
disableMultiregionAccessPoints?: boolean;
}
export declare const isBucketNameOptions: (
options: BucketHostnameParams | ArnHostnameParams
) => options is BucketHostnameParams;
export declare const isDnsCompatibleBucketName: (bucketName: string) => boolean;
export declare const getSuffix: (hostname: string) => [string, string];
export declare const getSuffixForArnEndpoint: (
hostname: string
) => [string, string];
export declare const validateArnEndpointOptions: (options: {
accelerateEndpoint?: boolean;
tlsCompatible?: boolean;
pathStyleEndpoint?: boolean;
}) => void;
export declare const validateService: (service: string) => void;
export declare const validateS3Service: (service: string) => void;
export declare const validateOutpostService: (service: string) => void;
export declare const validatePartition: (
partition: string,
options: {
clientPartition: string;
}
) => void;
export declare const validateRegion: (
region: string,
options: {
useArnRegion?: boolean;
allowFipsRegion?: boolean;
clientRegion: string;
clientSigningRegion: string;
useFipsEndpoint: boolean;
}
) => void;
export declare const validateRegionalClient: (region: string) => void;
export declare const validateAccountId: (accountId: string) => void;
export declare const validateDNSHostLabel: (
label: string,
options?: {
tlsCompatible?: boolean;
}
) => void;
export declare const validateCustomEndpoint: (options: {
isCustomEndpoint?: boolean;
dualstackEndpoint?: boolean;
accelerateEndpoint?: boolean;
}) => void;
export declare const getArnResources: (resource: string) => {
accesspointName: string;
outpostId?: string;
};
export declare const validateNoDualstack: (dualstackEndpoint?: boolean) => void;
export declare const validateNoFIPS: (useFipsEndpoint?: boolean) => void;
export declare const validateMrapAlias: (name: string) => void;

View File

@@ -0,0 +1,31 @@
import { Provider, RegionInfoProvider } from "@smithy/types";
export interface BucketEndpointInputConfig {
bucketEndpoint?: boolean;
forcePathStyle?: boolean;
useAccelerateEndpoint?: boolean;
useArnRegion?: boolean | Provider<boolean>;
disableMultiregionAccessPoints?: boolean | Provider<boolean>;
}
interface PreviouslyResolved {
isCustomEndpoint?: boolean;
region: Provider<string>;
regionInfoProvider: RegionInfoProvider;
useFipsEndpoint: Provider<boolean>;
useDualstackEndpoint: Provider<boolean>;
}
export interface BucketEndpointResolvedConfig {
isCustomEndpoint?: boolean;
bucketEndpoint: boolean;
forcePathStyle: boolean;
useAccelerateEndpoint: boolean;
useFipsEndpoint: Provider<boolean>;
useDualstackEndpoint: Provider<boolean>;
useArnRegion: Provider<boolean | undefined>;
region: Provider<string>;
regionInfoProvider: RegionInfoProvider;
disableMultiregionAccessPoints: Provider<boolean>;
}
export declare function resolveBucketEndpointConfig<T>(
input: T & PreviouslyResolved & BucketEndpointInputConfig
): T & BucketEndpointResolvedConfig;
export {};

View File

@@ -0,0 +1,16 @@
export * from "./NodeDisableMultiregionAccessPointConfigOptions";
export * from "./NodeUseArnRegionConfigOptions";
export * from "./bucketEndpointMiddleware";
export * from "./bucketHostname";
export * from "./configurations";
export {
getArnResources,
getSuffixForArnEndpoint,
validateOutpostService,
validatePartition,
validateAccountId,
validateRegion,
validateDNSHostLabel,
validateNoDualstack,
validateNoFIPS,
} from "./bucketHostnameUtils";

View File

@@ -0,0 +1,60 @@
{
"name": "@aws-sdk/middleware-bucket-endpoint",
"version": "3.969.0",
"scripts": {
"build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
"build:cjs": "node ../../scripts/compilation/inline middleware-bucket-endpoint",
"build:es": "tsc -p tsconfig.es.json",
"build:include:deps": "yarn g:turbo run build -F=\"$npm_package_name\"",
"build:types": "tsc -p tsconfig.types.json",
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"extract:docs": "api-extractor run --local",
"test": "yarn g:vitest run",
"test:watch": "yarn g:vitest watch"
},
"main": "./dist-cjs/index.js",
"module": "./dist-es/index.js",
"types": "./dist-types/index.d.ts",
"sideEffects": false,
"author": {
"name": "AWS SDK for JavaScript Team",
"url": "https://aws.amazon.com/javascript/"
},
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/types": "3.969.0",
"@aws-sdk/util-arn-parser": "3.968.0",
"@smithy/node-config-provider": "^4.3.8",
"@smithy/protocol-http": "^5.3.8",
"@smithy/types": "^4.12.0",
"@smithy/util-config-provider": "^4.2.0",
"tslib": "^2.6.2"
},
"devDependencies": {
"@tsconfig/recommended": "1.0.1",
"concurrently": "7.0.0",
"downlevel-dts": "0.10.1",
"rimraf": "5.0.10",
"typescript": "~5.8.3"
},
"engines": {
"node": ">=20.0.0"
},
"typesVersions": {
"<4.0": {
"dist-types/*": [
"dist-types/ts3.4/*"
]
}
},
"files": [
"dist-*/**"
],
"homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages/middleware-bucket-endpoint",
"repository": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-js-v3.git",
"directory": "packages/middleware-bucket-endpoint"
}
}