Initial
This commit is contained in:
25
resources/app/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/validate-bucket-name.js
generated
vendored
Normal file
25
resources/app/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/validate-bucket-name.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { validate as validateArn } from "@aws-sdk/util-arn-parser";
|
||||
import { bucketEndpointMiddleware, bucketEndpointMiddlewareOptions } from "./bucket-endpoint-middleware";
|
||||
export function validateBucketNameMiddleware({ bucketEndpoint }) {
|
||||
return (next) => async (args) => {
|
||||
const { input: { Bucket }, } = args;
|
||||
if (!bucketEndpoint && typeof Bucket === "string" && !validateArn(Bucket) && Bucket.indexOf("/") >= 0) {
|
||||
const err = new Error(`Bucket name shouldn't contain '/', received '${Bucket}'`);
|
||||
err.name = "InvalidBucketName";
|
||||
throw err;
|
||||
}
|
||||
return next({ ...args });
|
||||
};
|
||||
}
|
||||
export const validateBucketNameMiddlewareOptions = {
|
||||
step: "initialize",
|
||||
tags: ["VALIDATE_BUCKET_NAME"],
|
||||
name: "validateBucketNameMiddleware",
|
||||
override: true,
|
||||
};
|
||||
export const getValidateBucketNamePlugin = (options) => ({
|
||||
applyToStack: (clientStack) => {
|
||||
clientStack.add(validateBucketNameMiddleware(options), validateBucketNameMiddlewareOptions);
|
||||
clientStack.addRelativeTo(bucketEndpointMiddleware(options), bucketEndpointMiddlewareOptions);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user