@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 +8 -0
- package/dist-es/configurations.js +5 -3
- package/dist-es/constants.js +5 -5
- package/dist-es/process-arnables-plugin/getOutpostEndpoint.js +6 -8
- package/dist-es/process-arnables-plugin/parse-outpost-arnables.js +65 -86
- package/dist-es/process-arnables-plugin/plugin.js +3 -3
- package/dist-es/process-arnables-plugin/update-arnables-request.js +20 -33
- package/dist-es/redirect-from-postid.js +15 -28
- package/package.json +6 -6
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
|
-
|
|
5
|
-
return
|
|
3
|
+
const { useArnRegion = false } = input;
|
|
4
|
+
return {
|
|
5
|
+
...input,
|
|
6
|
+
useArnRegion: typeof useArnRegion === "function" ? useArnRegion : () => Promise.resolve(useArnRegion),
|
|
7
|
+
};
|
|
6
8
|
}
|
package/dist-es/constants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
6
|
+
const [matched, prefix, fips, region] = hostname.match(REGEX_S3CONTROL_HOSTNAME);
|
|
9
7
|
return [
|
|
10
|
-
|
|
8
|
+
`s3-outposts${useFipsEndpoint ? "-fips" : ""}`,
|
|
11
9
|
regionOverride || region,
|
|
12
|
-
hostname.replace(new RegExp(
|
|
10
|
+
hostname.replace(new RegExp(`^${matched}`), ""),
|
|
13
11
|
]
|
|
14
|
-
.filter(
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
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
|
-
|
|
79
|
-
|
|
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
|
|
61
|
+
validatePartition(partition, { clientPartition });
|
|
83
62
|
validateAccountId(accountId);
|
|
84
63
|
validateRegion(region, {
|
|
85
|
-
useArnRegion
|
|
86
|
-
clientRegion
|
|
64
|
+
useArnRegion,
|
|
65
|
+
clientRegion,
|
|
87
66
|
clientSigningRegion: signingRegion,
|
|
88
|
-
useFipsEndpoint
|
|
67
|
+
useFipsEndpoint,
|
|
89
68
|
allowFipsRegion: true,
|
|
90
69
|
});
|
|
91
70
|
validateNoDualstack(useDualstackEndpoint);
|
|
92
71
|
};
|
|
93
|
-
|
|
94
|
-
|
|
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
|
|
100
|
-
accesspointName
|
|
78
|
+
outpostId,
|
|
79
|
+
accesspointName,
|
|
101
80
|
};
|
|
102
81
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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(
|
|
87
|
+
throw new Error(`Outpost Bucket ARN should have resource outpost${delimiter}{outpostId}${delimiter}bucket${delimiter}{bucketName}`);
|
|
109
88
|
}
|
|
110
|
-
|
|
111
|
-
return { outpostId
|
|
89
|
+
const [outpostId, _, bucketName] = rest;
|
|
90
|
+
return { outpostId, bucketName };
|
|
112
91
|
}
|
|
113
92
|
else {
|
|
114
|
-
throw new Error(
|
|
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
|
|
4
|
-
applyToStack:
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
16
|
+
export const redirectFromPostIdMiddlewareOptions = {
|
|
30
17
|
step: "build",
|
|
31
18
|
name: "redirectFromPostIdMiddleware",
|
|
32
19
|
tags: ["OUTPOST"],
|
|
33
20
|
override: true,
|
|
34
21
|
};
|
|
35
|
-
export
|
|
36
|
-
applyToStack:
|
|
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.
|
|
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.
|
|
24
|
-
"@aws-sdk/protocol-http": "3.
|
|
25
|
-
"@aws-sdk/types": "3.
|
|
26
|
-
"@aws-sdk/util-arn-parser": "3.
|
|
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.
|
|
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",
|