@aws-sdk/middleware-sdk-s3 3.523.0 → 3.533.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.
@@ -0,0 +1 @@
1
+ module.exports = require("./index.js");
package/dist-cjs/index.js CHANGED
@@ -433,7 +433,8 @@ var resolveS3Config = /* @__PURE__ */ __name((input, {
433
433
  SessionMode: "ReadWrite"
434
434
  })
435
435
  )
436
- )
436
+ ),
437
+ bucketEndpoint: input.bucketEndpoint ?? false
437
438
  };
438
439
  }, "resolveS3Config");
439
440
 
@@ -482,12 +483,49 @@ var getThrow200ExceptionsPlugin = /* @__PURE__ */ __name((config) => ({
482
483
 
483
484
  // src/validate-bucket-name.ts
484
485
  var import_util_arn_parser = require("@aws-sdk/util-arn-parser");
485
- function validateBucketNameMiddleware() {
486
+
487
+ // src/bucket-endpoint-middleware.ts
488
+ function bucketEndpointMiddleware(options) {
489
+ return (next, context) => async (args) => {
490
+ var _a, _b, _c, _d;
491
+ if (options.bucketEndpoint) {
492
+ const endpoint = context.endpointV2;
493
+ if (endpoint) {
494
+ const bucket = args.input.Bucket;
495
+ if (typeof bucket === "string") {
496
+ try {
497
+ const bucketEndpointUrl = new URL(bucket);
498
+ endpoint.url = bucketEndpointUrl;
499
+ } catch (e) {
500
+ const warning = `@aws-sdk/middleware-sdk-s3: bucketEndpoint=true was set but Bucket=${bucket} could not be parsed as URL.`;
501
+ if (((_b = (_a = context.logger) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name) === "NoOpLogger") {
502
+ console.warn(warning);
503
+ } else {
504
+ (_d = (_c = context.logger) == null ? void 0 : _c.warn) == null ? void 0 : _d.call(_c, warning);
505
+ }
506
+ throw e;
507
+ }
508
+ }
509
+ }
510
+ }
511
+ return next(args);
512
+ };
513
+ }
514
+ __name(bucketEndpointMiddleware, "bucketEndpointMiddleware");
515
+ var bucketEndpointMiddlewareOptions = {
516
+ name: "bucketEndpointMiddleware",
517
+ override: true,
518
+ relation: "after",
519
+ toMiddleware: "endpointV2Middleware"
520
+ };
521
+
522
+ // src/validate-bucket-name.ts
523
+ function validateBucketNameMiddleware({ bucketEndpoint }) {
486
524
  return (next) => async (args) => {
487
525
  const {
488
526
  input: { Bucket }
489
527
  } = args;
490
- if (typeof Bucket === "string" && !(0, import_util_arn_parser.validate)(Bucket) && Bucket.indexOf("/") >= 0) {
528
+ if (!bucketEndpoint && typeof Bucket === "string" && !(0, import_util_arn_parser.validate)(Bucket) && Bucket.indexOf("/") >= 0) {
491
529
  const err = new Error(`Bucket name shouldn't contain '/', received '${Bucket}'`);
492
530
  err.name = "InvalidBucketName";
493
531
  throw err;
@@ -502,9 +540,10 @@ var validateBucketNameMiddlewareOptions = {
502
540
  name: "validateBucketNameMiddleware",
503
541
  override: true
504
542
  };
505
- var getValidateBucketNamePlugin = /* @__PURE__ */ __name((unused) => ({
543
+ var getValidateBucketNamePlugin = /* @__PURE__ */ __name((options) => ({
506
544
  applyToStack: (clientStack) => {
507
- clientStack.add(validateBucketNameMiddleware(), validateBucketNameMiddlewareOptions);
545
+ clientStack.add(validateBucketNameMiddleware(options), validateBucketNameMiddlewareOptions);
546
+ clientStack.addRelativeTo(bucketEndpointMiddleware(options), bucketEndpointMiddlewareOptions);
508
547
  }
509
548
  }), "getValidateBucketNamePlugin");
510
549
  // Annotate the CommonJS export names for ESM import in node:
@@ -0,0 +1,33 @@
1
+ export function bucketEndpointMiddleware(options) {
2
+ return (next, context) => async (args) => {
3
+ if (options.bucketEndpoint) {
4
+ const endpoint = context.endpointV2;
5
+ if (endpoint) {
6
+ const bucket = args.input.Bucket;
7
+ if (typeof bucket === "string") {
8
+ try {
9
+ const bucketEndpointUrl = new URL(bucket);
10
+ endpoint.url = bucketEndpointUrl;
11
+ }
12
+ catch (e) {
13
+ const warning = `@aws-sdk/middleware-sdk-s3: bucketEndpoint=true was set but Bucket=${bucket} could not be parsed as URL.`;
14
+ if (context.logger?.constructor?.name === "NoOpLogger") {
15
+ console.warn(warning);
16
+ }
17
+ else {
18
+ context.logger?.warn?.(warning);
19
+ }
20
+ throw e;
21
+ }
22
+ }
23
+ }
24
+ }
25
+ return next(args);
26
+ };
27
+ }
28
+ export const bucketEndpointMiddlewareOptions = {
29
+ name: "bucketEndpointMiddleware",
30
+ override: true,
31
+ relation: "after",
32
+ toMiddleware: "endpointV2Middleware",
33
+ };
@@ -12,5 +12,6 @@ export const resolveS3Config = (input, { session, }) => {
12
12
  Bucket: key,
13
13
  SessionMode: "ReadWrite",
14
14
  }))),
15
+ bucketEndpoint: input.bucketEndpoint ?? false,
15
16
  };
16
17
  };
@@ -1,8 +1,9 @@
1
1
  import { validate as validateArn } from "@aws-sdk/util-arn-parser";
2
- export function validateBucketNameMiddleware() {
2
+ import { bucketEndpointMiddleware, bucketEndpointMiddlewareOptions } from "./bucket-endpoint-middleware";
3
+ export function validateBucketNameMiddleware({ bucketEndpoint }) {
3
4
  return (next) => async (args) => {
4
5
  const { input: { Bucket }, } = args;
5
- if (typeof Bucket === "string" && !validateArn(Bucket) && Bucket.indexOf("/") >= 0) {
6
+ if (!bucketEndpoint && typeof Bucket === "string" && !validateArn(Bucket) && Bucket.indexOf("/") >= 0) {
6
7
  const err = new Error(`Bucket name shouldn't contain '/', received '${Bucket}'`);
7
8
  err.name = "InvalidBucketName";
8
9
  throw err;
@@ -16,8 +17,9 @@ export const validateBucketNameMiddlewareOptions = {
16
17
  name: "validateBucketNameMiddleware",
17
18
  override: true,
18
19
  };
19
- export const getValidateBucketNamePlugin = (unused) => ({
20
+ export const getValidateBucketNamePlugin = (options) => ({
20
21
  applyToStack: (clientStack) => {
21
- clientStack.add(validateBucketNameMiddleware(), validateBucketNameMiddlewareOptions);
22
+ clientStack.add(validateBucketNameMiddleware(options), validateBucketNameMiddlewareOptions);
23
+ clientStack.addRelativeTo(bucketEndpointMiddleware(options), bucketEndpointMiddlewareOptions);
22
24
  },
23
25
  });
@@ -0,0 +1,13 @@
1
+ import { RelativeMiddlewareOptions, SerializeMiddleware } from "@smithy/types";
2
+ interface PreviouslyResolved {
3
+ bucketEndpoint?: boolean;
4
+ }
5
+ /**
6
+ * @internal
7
+ */
8
+ export declare function bucketEndpointMiddleware(options: PreviouslyResolved): SerializeMiddleware<any, any>;
9
+ /**
10
+ * @internal
11
+ */
12
+ export declare const bucketEndpointMiddlewareOptions: RelativeMiddlewareOptions;
13
+ export {};
@@ -27,6 +27,10 @@ export interface S3InputConfig {
27
27
  */
28
28
  followRegionRedirects?: boolean;
29
29
  s3ExpressIdentityProvider?: S3ExpressIdentityProvider;
30
+ /**
31
+ * Whether to use the bucket name as the endpoint for this client.
32
+ */
33
+ bucketEndpoint?: boolean;
30
34
  }
31
35
  /**
32
36
  * @internal
@@ -48,6 +52,7 @@ export interface S3ResolvedConfig {
48
52
  disableMultiregionAccessPoints: boolean;
49
53
  followRegionRedirects: boolean;
50
54
  s3ExpressIdentityProvider: S3ExpressIdentityProvider;
55
+ bucketEndpoint: boolean;
51
56
  }
52
57
  export declare const resolveS3Config: <T>(input: T & S3InputConfig, { session, }: {
53
58
  session: [() => PlaceholderS3Client, PlaceholderCreateSessionCommandCtor];
@@ -0,0 +1,9 @@
1
+ import { RelativeMiddlewareOptions, SerializeMiddleware } from "@smithy/types";
2
+ interface PreviouslyResolved {
3
+ bucketEndpoint?: boolean;
4
+ }
5
+ export declare function bucketEndpointMiddleware(
6
+ options: PreviouslyResolved
7
+ ): SerializeMiddleware<any, any>;
8
+ export declare const bucketEndpointMiddlewareOptions: RelativeMiddlewareOptions;
9
+ export {};
@@ -6,6 +6,7 @@ export interface S3InputConfig {
6
6
  disableMultiregionAccessPoints?: boolean;
7
7
  followRegionRedirects?: boolean;
8
8
  s3ExpressIdentityProvider?: S3ExpressIdentityProvider;
9
+ bucketEndpoint?: boolean;
9
10
  }
10
11
  type PlaceholderS3Client = Client<any, any, any> & any;
11
12
  type PlaceholderCreateSessionCommandCtor = {
@@ -17,6 +18,7 @@ export interface S3ResolvedConfig {
17
18
  disableMultiregionAccessPoints: boolean;
18
19
  followRegionRedirects: boolean;
19
20
  s3ExpressIdentityProvider: S3ExpressIdentityProvider;
21
+ bucketEndpoint: boolean;
20
22
  }
21
23
  export declare const resolveS3Config: <T>(
22
24
  input: T & S3InputConfig,
@@ -3,11 +3,11 @@ import {
3
3
  InitializeMiddleware,
4
4
  Pluggable,
5
5
  } from "@smithy/types";
6
- export declare function validateBucketNameMiddleware(): InitializeMiddleware<
7
- any,
8
- any
9
- >;
6
+ import { S3ResolvedConfig } from "./s3Configuration";
7
+ export declare function validateBucketNameMiddleware({
8
+ bucketEndpoint,
9
+ }: S3ResolvedConfig): InitializeMiddleware<any, any>;
10
10
  export declare const validateBucketNameMiddlewareOptions: InitializeHandlerOptions;
11
11
  export declare const getValidateBucketNamePlugin: (
12
- unused: any
12
+ options: S3ResolvedConfig
13
13
  ) => Pluggable<any, any>;
@@ -1,8 +1,9 @@
1
1
  import { InitializeHandlerOptions, InitializeMiddleware, Pluggable } from "@smithy/types";
2
+ import { S3ResolvedConfig } from "./s3Configuration";
2
3
  /**
3
4
  * @internal
4
5
  */
5
- export declare function validateBucketNameMiddleware(): InitializeMiddleware<any, any>;
6
+ export declare function validateBucketNameMiddleware({ bucketEndpoint }: S3ResolvedConfig): InitializeMiddleware<any, any>;
6
7
  /**
7
8
  * @internal
8
9
  */
@@ -10,4 +11,4 @@ export declare const validateBucketNameMiddlewareOptions: InitializeHandlerOptio
10
11
  /**
11
12
  * @internal
12
13
  */
13
- export declare const getValidateBucketNamePlugin: (unused: any) => Pluggable<any, any>;
14
+ export declare const getValidateBucketNamePlugin: (options: S3ResolvedConfig) => Pluggable<any, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-s3",
3
- "version": "3.523.0",
3
+ "version": "3.533.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "node ../../scripts/compilation/inline middleware-sdk-s3",
@@ -23,13 +23,13 @@
23
23
  },
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
- "@aws-sdk/types": "3.523.0",
26
+ "@aws-sdk/types": "3.533.0",
27
27
  "@aws-sdk/util-arn-parser": "3.495.0",
28
- "@smithy/node-config-provider": "^2.2.3",
29
- "@smithy/protocol-http": "^3.2.1",
30
- "@smithy/signature-v4": "^2.1.3",
31
- "@smithy/smithy-client": "^2.4.1",
32
- "@smithy/types": "^2.10.1",
28
+ "@smithy/node-config-provider": "^2.2.5",
29
+ "@smithy/protocol-http": "^3.2.2",
30
+ "@smithy/signature-v4": "^2.1.4",
31
+ "@smithy/smithy-client": "^2.4.5",
32
+ "@smithy/types": "^2.11.0",
33
33
  "@smithy/util-config-provider": "^2.2.1",
34
34
  "tslib": "^2.5.0"
35
35
  },