@aws-sdk/middleware-sdk-s3-control 3.183.0 → 3.186.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.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)
7
+
8
+ **Note:** Version bump only for package @aws-sdk/middleware-sdk-s3-control
9
+
10
+
11
+
12
+
13
+
6
14
  # [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
7
15
 
8
16
  **Note:** Version bump only for package @aws-sdk/middleware-sdk-s3-control
@@ -1,8 +1,6 @@
1
+ import { __assign } from "tslib";
1
2
  export { NODE_USE_ARN_REGION_CONFIG_OPTIONS } from "@aws-sdk/middleware-bucket-endpoint";
2
3
  export function resolveS3ControlConfig(input) {
3
- const { useArnRegion = false } = input;
4
- return {
5
- ...input,
6
- useArnRegion: typeof useArnRegion === "function" ? useArnRegion : () => Promise.resolve(useArnRegion),
7
- };
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); } });
8
6
  }
@@ -1,5 +1,5 @@
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
+ 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,14 +1,16 @@
1
- const REGEX_S3CONTROL_HOSTNAME = /^(.+\.)?s3-control(-fips)?[.-]([a-z0-9-]+)\./;
2
- export const getOutpostEndpoint = (hostname, { isCustomEndpoint, regionOverride, useFipsEndpoint }) => {
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;
3
5
  if (isCustomEndpoint) {
4
6
  return hostname;
5
7
  }
6
- const [matched, prefix, fips, region] = hostname.match(REGEX_S3CONTROL_HOSTNAME);
8
+ var _b = __read(hostname.match(REGEX_S3CONTROL_HOSTNAME), 4), matched = _b[0], prefix = _b[1], fips = _b[2], region = _b[3];
7
9
  return [
8
- `s3-outposts${useFipsEndpoint ? "-fips" : ""}`,
10
+ "s3-outposts".concat(useFipsEndpoint ? "-fips" : ""),
9
11
  regionOverride || region,
10
- hostname.replace(new RegExp(`^${matched}`), ""),
12
+ hostname.replace(new RegExp("^".concat(matched)), ""),
11
13
  ]
12
- .filter((part) => part !== undefined)
14
+ .filter(function (part) { return part !== undefined; })
13
15
  .join(".");
14
16
  };
@@ -1,95 +1,116 @@
1
+ import { __awaiter, __generator, __read } from "tslib";
1
2
  import { getArnResources as getS3AccesspointArnResources, validateAccountId, validateNoDualstack, validateOutpostService, validatePartition, validateRegion, } from "@aws-sdk/middleware-bucket-endpoint";
2
3
  import { parse as parseArn, validate as validateArn } from "@aws-sdk/util-arn-parser";
3
4
  import { CONTEXT_ARN_REGION, CONTEXT_OUTPOST_ID, CONTEXT_SIGNING_REGION, CONTEXT_SIGNING_SERVICE } from "../constants";
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,
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
+ }); };
25
71
  };
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);
52
72
  };
53
- export const parseOutpostArnablesMiddleawareOptions = {
73
+ export var parseOutpostArnablesMiddleawareOptions = {
54
74
  step: "initialize",
55
75
  tags: ["CONVERT_ARN", "OUTPOST_BUCKET_ARN", "OUTPOST_ACCESS_POINT_ARN", "OUTPOST"],
56
76
  name: "parseOutpostArnablesMiddleaware",
57
77
  };
58
- const validateOutpostsArn = (arn, { clientRegion, signingRegion, clientPartition, useArnRegion, useFipsEndpoint, useDualstackEndpoint, }) => {
59
- const { service, partition, accountId, region } = arn;
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;
60
81
  validateOutpostService(service);
61
- validatePartition(partition, { clientPartition });
82
+ validatePartition(partition, { clientPartition: clientPartition });
62
83
  validateAccountId(accountId);
63
84
  validateRegion(region, {
64
- useArnRegion,
65
- clientRegion,
85
+ useArnRegion: useArnRegion,
86
+ clientRegion: clientRegion,
66
87
  clientSigningRegion: signingRegion,
67
- useFipsEndpoint,
88
+ useFipsEndpoint: useFipsEndpoint,
68
89
  allowFipsRegion: true,
69
90
  });
70
91
  validateNoDualstack(useDualstackEndpoint);
71
92
  };
72
- const parseOutpostsAccessPointArnResource = (resource) => {
73
- const { outpostId, accesspointName } = getS3AccesspointArnResources(resource);
93
+ var parseOutpostsAccessPointArnResource = function (resource) {
94
+ var _a = getS3AccesspointArnResources(resource), outpostId = _a.outpostId, accesspointName = _a.accesspointName;
74
95
  if (!outpostId) {
75
96
  throw new Error("ARN resource should begin with 'outpost'");
76
97
  }
77
98
  return {
78
- outpostId,
79
- accesspointName,
99
+ outpostId: outpostId,
100
+ accesspointName: accesspointName,
80
101
  };
81
102
  };
82
- const parseOutpostBucketArnResource = (resource) => {
83
- const delimiter = resource.includes(":") ? ":" : "/";
84
- const [resourceType, ...rest] = resource.split(delimiter);
103
+ var parseOutpostBucketArnResource = function (resource) {
104
+ var delimiter = resource.includes(":") ? ":" : "/";
105
+ var _a = __read(resource.split(delimiter)), resourceType = _a[0], rest = _a.slice(1);
85
106
  if (resourceType === "outpost") {
86
107
  if (!rest[0] || rest[1] !== "bucket" || !rest[2] || rest.length !== 3) {
87
- throw new Error(`Outpost Bucket ARN should have resource outpost${delimiter}{outpostId}${delimiter}bucket${delimiter}{bucketName}`);
108
+ throw new Error("Outpost Bucket ARN should have resource outpost".concat(delimiter, "{outpostId}").concat(delimiter, "bucket").concat(delimiter, "{bucketName}"));
88
109
  }
89
- const [outpostId, _, bucketName] = rest;
90
- return { outpostId, bucketName };
110
+ var _b = __read(rest, 3), outpostId = _b[0], _1 = _b[1], bucketName = _b[2];
111
+ return { outpostId: outpostId, bucketName: bucketName };
91
112
  }
92
113
  else {
93
- throw new Error(`ARN resource should begin with 'outpost${delimiter}'`);
114
+ throw new Error("ARN resource should begin with 'outpost".concat(delimiter, "'"));
94
115
  }
95
116
  };
@@ -1,8 +1,8 @@
1
1
  import { parseOutpostArnablesMiddleaware, parseOutpostArnablesMiddleawareOptions } from "./parse-outpost-arnables";
2
2
  import { updateArnablesRequestMiddleware, updateArnablesRequestMiddlewareOptions } from "./update-arnables-request";
3
- export const getProcessArnablesPlugin = (options) => ({
4
- applyToStack: (clientStack) => {
3
+ export var getProcessArnablesPlugin = function (options) { return ({
4
+ applyToStack: function (clientStack) {
5
5
  clientStack.add(parseOutpostArnablesMiddleaware(options), parseOutpostArnablesMiddleawareOptions);
6
6
  clientStack.add(updateArnablesRequestMiddleware(options), updateArnablesRequestMiddlewareOptions);
7
7
  },
8
- });
8
+ }); };
@@ -1,27 +1,40 @@
1
+ import { __awaiter, __generator } from "tslib";
1
2
  import { HttpRequest } from "@aws-sdk/protocol-http";
2
3
  import { CONTEXT_ACCOUNT_ID, CONTEXT_ARN_REGION, CONTEXT_OUTPOST_ID } from "../constants";
3
4
  import { getOutpostEndpoint } from "./getOutpostEndpoint";
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);
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
+ };
23
36
  };
24
- export const updateArnablesRequestMiddlewareOptions = {
37
+ export var updateArnablesRequestMiddlewareOptions = {
25
38
  step: "build",
26
39
  name: "updateArnablesRequestMiddleware",
27
40
  tags: ["ACCOUNT_ID", "OUTPOST_ID", "OUTPOST"],
@@ -1,26 +1,39 @@
1
+ import { __awaiter, __generator } from "tslib";
1
2
  import { HttpRequest } from "@aws-sdk/protocol-http";
2
3
  import { CONTEXT_SIGNING_SERVICE } from "./constants";
3
4
  import { getOutpostEndpoint } from "./process-arnables-plugin";
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);
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
+ };
15
28
  };
16
- export const redirectFromPostIdMiddlewareOptions = {
29
+ export var redirectFromPostIdMiddlewareOptions = {
17
30
  step: "build",
18
31
  name: "redirectFromPostIdMiddleware",
19
32
  tags: ["OUTPOST"],
20
33
  override: true,
21
34
  };
22
- export const getRedirectFromPostIdPlugin = (options) => ({
23
- applyToStack: (clientStack) => {
35
+ export var getRedirectFromPostIdPlugin = function (options) { return ({
36
+ applyToStack: function (clientStack) {
24
37
  clientStack.add(redirectFromPostIdMiddleware(options), redirectFromPostIdMiddlewareOptions);
25
38
  },
26
- });
39
+ }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-s3-control",
3
- "version": "3.183.0",
3
+ "version": "3.186.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.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",
23
+ "@aws-sdk/middleware-bucket-endpoint": "3.186.0",
24
+ "@aws-sdk/protocol-http": "3.186.0",
25
+ "@aws-sdk/types": "3.186.0",
26
+ "@aws-sdk/util-arn-parser": "3.186.0",
27
27
  "tslib": "^2.3.1"
28
28
  },
29
29
  "devDependencies": {
30
- "@aws-sdk/middleware-stack": "3.183.0",
30
+ "@aws-sdk/middleware-stack": "3.186.0",
31
31
  "@tsconfig/recommended": "1.0.1",
32
32
  "concurrently": "7.0.0",
33
33
  "downlevel-dts": "0.10.1",