@aws-sdk/middleware-sdk-s3-control 3.178.0 → 3.183.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
7
+
8
+ **Note:** Version bump only for package @aws-sdk/middleware-sdk-s3-control
9
+
10
+
11
+
12
+
13
+
6
14
  # [3.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23)
7
15
 
8
16
  **Note:** Version bump only for package @aws-sdk/middleware-sdk-s3-control
@@ -1,6 +1,8 @@
1
- import { __assign } from "tslib";
2
1
  export { NODE_USE_ARN_REGION_CONFIG_OPTIONS } from "@aws-sdk/middleware-bucket-endpoint";
3
2
  export function resolveS3ControlConfig(input) {
4
- var _a = input.useArnRegion, useArnRegion = _a === void 0 ? false : _a;
5
- return __assign(__assign({}, input), { useArnRegion: typeof useArnRegion === "function" ? useArnRegion : function () { return Promise.resolve(useArnRegion); } });
3
+ const { useArnRegion = false } = input;
4
+ return {
5
+ ...input,
6
+ useArnRegion: typeof useArnRegion === "function" ? useArnRegion : () => Promise.resolve(useArnRegion),
7
+ };
6
8
  }
@@ -1,5 +1,5 @@
1
- export var CONTEXT_OUTPOST_ID = "outpost_id";
2
- export var CONTEXT_ACCOUNT_ID = "account_id";
3
- export var CONTEXT_ARN_REGION = "outpost_arn_region";
4
- export var CONTEXT_SIGNING_SERVICE = "signing_service";
5
- export var CONTEXT_SIGNING_REGION = "signing_region";
1
+ export const CONTEXT_OUTPOST_ID = "outpost_id";
2
+ export const CONTEXT_ACCOUNT_ID = "account_id";
3
+ export const CONTEXT_ARN_REGION = "outpost_arn_region";
4
+ export const CONTEXT_SIGNING_SERVICE = "signing_service";
5
+ export const CONTEXT_SIGNING_REGION = "signing_region";
@@ -1,16 +1,14 @@
1
- import { __read } from "tslib";
2
- var REGEX_S3CONTROL_HOSTNAME = /^(.+\.)?s3-control(-fips)?[.-]([a-z0-9-]+)\./;
3
- export var getOutpostEndpoint = function (hostname, _a) {
4
- var isCustomEndpoint = _a.isCustomEndpoint, regionOverride = _a.regionOverride, useFipsEndpoint = _a.useFipsEndpoint;
1
+ const REGEX_S3CONTROL_HOSTNAME = /^(.+\.)?s3-control(-fips)?[.-]([a-z0-9-]+)\./;
2
+ export const getOutpostEndpoint = (hostname, { isCustomEndpoint, regionOverride, useFipsEndpoint }) => {
5
3
  if (isCustomEndpoint) {
6
4
  return hostname;
7
5
  }
8
- var _b = __read(hostname.match(REGEX_S3CONTROL_HOSTNAME), 4), matched = _b[0], prefix = _b[1], fips = _b[2], region = _b[3];
6
+ const [matched, prefix, fips, region] = hostname.match(REGEX_S3CONTROL_HOSTNAME);
9
7
  return [
10
- "s3-outposts".concat(useFipsEndpoint ? "-fips" : ""),
8
+ `s3-outposts${useFipsEndpoint ? "-fips" : ""}`,
11
9
  regionOverride || region,
12
- hostname.replace(new RegExp("^".concat(matched)), ""),
10
+ hostname.replace(new RegExp(`^${matched}`), ""),
13
11
  ]
14
- .filter(function (part) { return part !== undefined; })
12
+ .filter((part) => part !== undefined)
15
13
  .join(".");
16
14
  };
@@ -1,116 +1,95 @@
1
- import { __awaiter, __generator, __read } from "tslib";
2
1
  import { getArnResources as getS3AccesspointArnResources, validateAccountId, validateNoDualstack, validateOutpostService, validatePartition, validateRegion, } from "@aws-sdk/middleware-bucket-endpoint";
3
2
  import { parse as parseArn, validate as validateArn } from "@aws-sdk/util-arn-parser";
4
3
  import { CONTEXT_ARN_REGION, CONTEXT_OUTPOST_ID, CONTEXT_SIGNING_REGION, CONTEXT_SIGNING_SERVICE } from "../constants";
5
- export var parseOutpostArnablesMiddleaware = function (options) {
6
- return function (next, context) {
7
- return function (args) { return __awaiter(void 0, void 0, void 0, function () {
8
- var input, parameter, clientRegion, useArnRegion, useFipsEndpoint, useDualstackEndpoint, baseRegion, _a, clientPartition, _b, signingRegion, validatorOptions, arn, _c, outpostId, accesspointName, _d, outpostId, bucketName;
9
- return __generator(this, function (_e) {
10
- switch (_e.label) {
11
- case 0:
12
- input = args.input;
13
- parameter = input.Name && validateArn(input.Name) ? "Name" : input.Bucket && validateArn(input.Bucket) ? "Bucket" : undefined;
14
- if (!parameter)
15
- return [2, next(args)];
16
- return [4, options.region()];
17
- case 1:
18
- clientRegion = _e.sent();
19
- return [4, options.useArnRegion()];
20
- case 2:
21
- useArnRegion = _e.sent();
22
- return [4, options.useFipsEndpoint()];
23
- case 3:
24
- useFipsEndpoint = _e.sent();
25
- return [4, options.useDualstackEndpoint()];
26
- case 4:
27
- useDualstackEndpoint = _e.sent();
28
- baseRegion = clientRegion;
29
- return [4, options.regionInfoProvider(baseRegion, {
30
- useFipsEndpoint: useFipsEndpoint,
31
- useDualstackEndpoint: useDualstackEndpoint,
32
- })];
33
- case 5:
34
- _a = (_e.sent()), clientPartition = _a.partition, _b = _a.signingRegion, signingRegion = _b === void 0 ? baseRegion : _b;
35
- validatorOptions = {
36
- useFipsEndpoint: useFipsEndpoint,
37
- useDualstackEndpoint: useDualstackEndpoint,
38
- clientRegion: clientRegion,
39
- clientPartition: clientPartition,
40
- signingRegion: signingRegion,
41
- useArnRegion: useArnRegion,
42
- };
43
- if (parameter === "Name") {
44
- arn = parseArn(input.Name);
45
- validateOutpostsArn(arn, validatorOptions);
46
- _c = parseOutpostsAccessPointArnResource(arn.resource), outpostId = _c.outpostId, accesspointName = _c.accesspointName;
47
- input.Name = accesspointName;
48
- context[CONTEXT_OUTPOST_ID] = outpostId;
49
- }
50
- else {
51
- arn = parseArn(input.Bucket);
52
- validateOutpostsArn(arn, validatorOptions);
53
- _d = parseOutpostBucketArnResource(arn.resource), outpostId = _d.outpostId, bucketName = _d.bucketName;
54
- input.Bucket = bucketName;
55
- context[CONTEXT_OUTPOST_ID] = outpostId;
56
- }
57
- context[CONTEXT_SIGNING_SERVICE] = arn.service;
58
- context[CONTEXT_SIGNING_REGION] = useArnRegion ? arn.region : signingRegion;
59
- if (!input.AccountId) {
60
- input.AccountId = arn.accountId;
61
- }
62
- else if (input.AccountId !== arn.accountId) {
63
- throw new Error("AccountId is incompatible with account id inferred from ".concat(parameter));
64
- }
65
- if (useArnRegion)
66
- context[CONTEXT_ARN_REGION] = arn.region;
67
- return [2, next(args)];
68
- }
69
- });
70
- }); };
4
+ export const parseOutpostArnablesMiddleaware = (options) => (next, context) => async (args) => {
5
+ const { input } = args;
6
+ const parameter = input.Name && validateArn(input.Name) ? "Name" : input.Bucket && validateArn(input.Bucket) ? "Bucket" : undefined;
7
+ if (!parameter)
8
+ return next(args);
9
+ const clientRegion = await options.region();
10
+ const useArnRegion = await options.useArnRegion();
11
+ const useFipsEndpoint = await options.useFipsEndpoint();
12
+ const useDualstackEndpoint = await options.useDualstackEndpoint();
13
+ const baseRegion = clientRegion;
14
+ const { partition: clientPartition, signingRegion = baseRegion } = (await options.regionInfoProvider(baseRegion, {
15
+ useFipsEndpoint,
16
+ useDualstackEndpoint,
17
+ }));
18
+ const validatorOptions = {
19
+ useFipsEndpoint,
20
+ useDualstackEndpoint,
21
+ clientRegion,
22
+ clientPartition,
23
+ signingRegion,
24
+ useArnRegion,
71
25
  };
26
+ let arn;
27
+ if (parameter === "Name") {
28
+ arn = parseArn(input.Name);
29
+ validateOutpostsArn(arn, validatorOptions);
30
+ const { outpostId, accesspointName } = parseOutpostsAccessPointArnResource(arn.resource);
31
+ input.Name = accesspointName;
32
+ context[CONTEXT_OUTPOST_ID] = outpostId;
33
+ }
34
+ else {
35
+ arn = parseArn(input.Bucket);
36
+ validateOutpostsArn(arn, validatorOptions);
37
+ const { outpostId, bucketName } = parseOutpostBucketArnResource(arn.resource);
38
+ input.Bucket = bucketName;
39
+ context[CONTEXT_OUTPOST_ID] = outpostId;
40
+ }
41
+ context[CONTEXT_SIGNING_SERVICE] = arn.service;
42
+ context[CONTEXT_SIGNING_REGION] = useArnRegion ? arn.region : signingRegion;
43
+ if (!input.AccountId) {
44
+ input.AccountId = arn.accountId;
45
+ }
46
+ else if (input.AccountId !== arn.accountId) {
47
+ throw new Error(`AccountId is incompatible with account id inferred from ${parameter}`);
48
+ }
49
+ if (useArnRegion)
50
+ context[CONTEXT_ARN_REGION] = arn.region;
51
+ return next(args);
72
52
  };
73
- export var parseOutpostArnablesMiddleawareOptions = {
53
+ export const parseOutpostArnablesMiddleawareOptions = {
74
54
  step: "initialize",
75
55
  tags: ["CONVERT_ARN", "OUTPOST_BUCKET_ARN", "OUTPOST_ACCESS_POINT_ARN", "OUTPOST"],
76
56
  name: "parseOutpostArnablesMiddleaware",
77
57
  };
78
- var validateOutpostsArn = function (arn, _a) {
79
- var clientRegion = _a.clientRegion, signingRegion = _a.signingRegion, clientPartition = _a.clientPartition, useArnRegion = _a.useArnRegion, useFipsEndpoint = _a.useFipsEndpoint, useDualstackEndpoint = _a.useDualstackEndpoint;
80
- var service = arn.service, partition = arn.partition, accountId = arn.accountId, region = arn.region;
58
+ const validateOutpostsArn = (arn, { clientRegion, signingRegion, clientPartition, useArnRegion, useFipsEndpoint, useDualstackEndpoint, }) => {
59
+ const { service, partition, accountId, region } = arn;
81
60
  validateOutpostService(service);
82
- validatePartition(partition, { clientPartition: clientPartition });
61
+ validatePartition(partition, { clientPartition });
83
62
  validateAccountId(accountId);
84
63
  validateRegion(region, {
85
- useArnRegion: useArnRegion,
86
- clientRegion: clientRegion,
64
+ useArnRegion,
65
+ clientRegion,
87
66
  clientSigningRegion: signingRegion,
88
- useFipsEndpoint: useFipsEndpoint,
67
+ useFipsEndpoint,
89
68
  allowFipsRegion: true,
90
69
  });
91
70
  validateNoDualstack(useDualstackEndpoint);
92
71
  };
93
- var parseOutpostsAccessPointArnResource = function (resource) {
94
- var _a = getS3AccesspointArnResources(resource), outpostId = _a.outpostId, accesspointName = _a.accesspointName;
72
+ const parseOutpostsAccessPointArnResource = (resource) => {
73
+ const { outpostId, accesspointName } = getS3AccesspointArnResources(resource);
95
74
  if (!outpostId) {
96
75
  throw new Error("ARN resource should begin with 'outpost'");
97
76
  }
98
77
  return {
99
- outpostId: outpostId,
100
- accesspointName: accesspointName,
78
+ outpostId,
79
+ accesspointName,
101
80
  };
102
81
  };
103
- var parseOutpostBucketArnResource = function (resource) {
104
- var delimiter = resource.includes(":") ? ":" : "/";
105
- var _a = __read(resource.split(delimiter)), resourceType = _a[0], rest = _a.slice(1);
82
+ const parseOutpostBucketArnResource = (resource) => {
83
+ const delimiter = resource.includes(":") ? ":" : "/";
84
+ const [resourceType, ...rest] = resource.split(delimiter);
106
85
  if (resourceType === "outpost") {
107
86
  if (!rest[0] || rest[1] !== "bucket" || !rest[2] || rest.length !== 3) {
108
- throw new Error("Outpost Bucket ARN should have resource outpost".concat(delimiter, "{outpostId}").concat(delimiter, "bucket").concat(delimiter, "{bucketName}"));
87
+ throw new Error(`Outpost Bucket ARN should have resource outpost${delimiter}{outpostId}${delimiter}bucket${delimiter}{bucketName}`);
109
88
  }
110
- var _b = __read(rest, 3), outpostId = _b[0], _1 = _b[1], bucketName = _b[2];
111
- return { outpostId: outpostId, bucketName: bucketName };
89
+ const [outpostId, _, bucketName] = rest;
90
+ return { outpostId, bucketName };
112
91
  }
113
92
  else {
114
- throw new Error("ARN resource should begin with 'outpost".concat(delimiter, "'"));
93
+ throw new Error(`ARN resource should begin with 'outpost${delimiter}'`);
115
94
  }
116
95
  };
@@ -1,8 +1,8 @@
1
1
  import { parseOutpostArnablesMiddleaware, parseOutpostArnablesMiddleawareOptions } from "./parse-outpost-arnables";
2
2
  import { updateArnablesRequestMiddleware, updateArnablesRequestMiddlewareOptions } from "./update-arnables-request";
3
- export var getProcessArnablesPlugin = function (options) { return ({
4
- applyToStack: function (clientStack) {
3
+ export const getProcessArnablesPlugin = (options) => ({
4
+ applyToStack: (clientStack) => {
5
5
  clientStack.add(parseOutpostArnablesMiddleaware(options), parseOutpostArnablesMiddleawareOptions);
6
6
  clientStack.add(updateArnablesRequestMiddleware(options), updateArnablesRequestMiddlewareOptions);
7
7
  },
8
- }); };
8
+ });
@@ -1,40 +1,27 @@
1
- import { __awaiter, __generator } from "tslib";
2
1
  import { HttpRequest } from "@aws-sdk/protocol-http";
3
2
  import { CONTEXT_ACCOUNT_ID, CONTEXT_ARN_REGION, CONTEXT_OUTPOST_ID } from "../constants";
4
3
  import { getOutpostEndpoint } from "./getOutpostEndpoint";
5
- var ACCOUNT_ID_HEADER = "x-amz-account-id";
6
- var OUTPOST_ID_HEADER = "x-amz-outpost-id";
7
- export var updateArnablesRequestMiddleware = function (config) {
8
- return function (next, context) {
9
- return function (args) { return __awaiter(void 0, void 0, void 0, function () {
10
- var request, isCustomEndpoint, useFipsEndpoint;
11
- return __generator(this, function (_a) {
12
- switch (_a.label) {
13
- case 0:
14
- request = args.request;
15
- if (!HttpRequest.isInstance(request))
16
- return [2, next(args)];
17
- if (context[CONTEXT_ACCOUNT_ID])
18
- request.headers[ACCOUNT_ID_HEADER] = context[CONTEXT_ACCOUNT_ID];
19
- if (!context[CONTEXT_OUTPOST_ID]) return [3, 2];
20
- isCustomEndpoint = config.isCustomEndpoint;
21
- return [4, config.useFipsEndpoint()];
22
- case 1:
23
- useFipsEndpoint = _a.sent();
24
- request.headers[OUTPOST_ID_HEADER] = context[CONTEXT_OUTPOST_ID];
25
- request.hostname = getOutpostEndpoint(request.hostname, {
26
- isCustomEndpoint: isCustomEndpoint,
27
- regionOverride: context[CONTEXT_ARN_REGION],
28
- useFipsEndpoint: useFipsEndpoint,
29
- });
30
- _a.label = 2;
31
- case 2: return [2, next(args)];
32
- }
33
- });
34
- }); };
35
- };
4
+ const ACCOUNT_ID_HEADER = "x-amz-account-id";
5
+ const OUTPOST_ID_HEADER = "x-amz-outpost-id";
6
+ export const updateArnablesRequestMiddleware = (config) => (next, context) => async (args) => {
7
+ const { request } = args;
8
+ if (!HttpRequest.isInstance(request))
9
+ return next(args);
10
+ if (context[CONTEXT_ACCOUNT_ID])
11
+ request.headers[ACCOUNT_ID_HEADER] = context[CONTEXT_ACCOUNT_ID];
12
+ if (context[CONTEXT_OUTPOST_ID]) {
13
+ const { isCustomEndpoint } = config;
14
+ const useFipsEndpoint = await config.useFipsEndpoint();
15
+ request.headers[OUTPOST_ID_HEADER] = context[CONTEXT_OUTPOST_ID];
16
+ request.hostname = getOutpostEndpoint(request.hostname, {
17
+ isCustomEndpoint,
18
+ regionOverride: context[CONTEXT_ARN_REGION],
19
+ useFipsEndpoint,
20
+ });
21
+ }
22
+ return next(args);
36
23
  };
37
- export var updateArnablesRequestMiddlewareOptions = {
24
+ export const updateArnablesRequestMiddlewareOptions = {
38
25
  step: "build",
39
26
  name: "updateArnablesRequestMiddleware",
40
27
  tags: ["ACCOUNT_ID", "OUTPOST_ID", "OUTPOST"],
@@ -1,39 +1,26 @@
1
- import { __awaiter, __generator } from "tslib";
2
1
  import { HttpRequest } from "@aws-sdk/protocol-http";
3
2
  import { CONTEXT_SIGNING_SERVICE } from "./constants";
4
3
  import { getOutpostEndpoint } from "./process-arnables-plugin";
5
- export var redirectFromPostIdMiddleware = function (config) {
6
- return function (next, context) {
7
- return function (args) { return __awaiter(void 0, void 0, void 0, function () {
8
- var input, request, isCustomEndpoint, useFipsEndpoint;
9
- return __generator(this, function (_a) {
10
- switch (_a.label) {
11
- case 0:
12
- input = args.input, request = args.request;
13
- if (!HttpRequest.isInstance(request))
14
- return [2, next(args)];
15
- if (!input.OutpostId) return [3, 2];
16
- isCustomEndpoint = config.isCustomEndpoint;
17
- return [4, config.useFipsEndpoint()];
18
- case 1:
19
- useFipsEndpoint = _a.sent();
20
- request.hostname = getOutpostEndpoint(request.hostname, { isCustomEndpoint: isCustomEndpoint, useFipsEndpoint: useFipsEndpoint });
21
- context[CONTEXT_SIGNING_SERVICE] = "s3-outposts";
22
- _a.label = 2;
23
- case 2: return [2, next(args)];
24
- }
25
- });
26
- }); };
27
- };
4
+ export const redirectFromPostIdMiddleware = (config) => (next, context) => async (args) => {
5
+ const { input, request } = args;
6
+ if (!HttpRequest.isInstance(request))
7
+ return next(args);
8
+ if (input.OutpostId) {
9
+ const { isCustomEndpoint } = config;
10
+ const useFipsEndpoint = await config.useFipsEndpoint();
11
+ request.hostname = getOutpostEndpoint(request.hostname, { isCustomEndpoint, useFipsEndpoint });
12
+ context[CONTEXT_SIGNING_SERVICE] = "s3-outposts";
13
+ }
14
+ return next(args);
28
15
  };
29
- export var redirectFromPostIdMiddlewareOptions = {
16
+ export const redirectFromPostIdMiddlewareOptions = {
30
17
  step: "build",
31
18
  name: "redirectFromPostIdMiddleware",
32
19
  tags: ["OUTPOST"],
33
20
  override: true,
34
21
  };
35
- export var getRedirectFromPostIdPlugin = function (options) { return ({
36
- applyToStack: function (clientStack) {
22
+ export const getRedirectFromPostIdPlugin = (options) => ({
23
+ applyToStack: (clientStack) => {
37
24
  clientStack.add(redirectFromPostIdMiddleware(options), redirectFromPostIdMiddlewareOptions);
38
25
  },
39
- }); };
26
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-s3-control",
3
- "version": "3.178.0",
3
+ "version": "3.183.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",
@@ -20,14 +20,14 @@
20
20
  },
21
21
  "license": "Apache-2.0",
22
22
  "dependencies": {
23
- "@aws-sdk/middleware-bucket-endpoint": "3.178.0",
24
- "@aws-sdk/protocol-http": "3.178.0",
25
- "@aws-sdk/types": "3.178.0",
26
- "@aws-sdk/util-arn-parser": "3.170.0",
23
+ "@aws-sdk/middleware-bucket-endpoint": "3.183.0",
24
+ "@aws-sdk/protocol-http": "3.183.0",
25
+ "@aws-sdk/types": "3.183.0",
26
+ "@aws-sdk/util-arn-parser": "3.183.0",
27
27
  "tslib": "^2.3.1"
28
28
  },
29
29
  "devDependencies": {
30
- "@aws-sdk/middleware-stack": "3.178.0",
30
+ "@aws-sdk/middleware-stack": "3.183.0",
31
31
  "@tsconfig/recommended": "1.0.1",
32
32
  "concurrently": "7.0.0",
33
33
  "downlevel-dts": "0.10.1",