@aws-sdk/middleware-sdk-rds 3.171.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 +16 -0
- package/dist-es/fixture.js +17 -24
- package/dist-es/index.js +52 -61
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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-rds
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @aws-sdk/middleware-sdk-rds
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [3.171.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.170.0...v3.171.0) (2022-09-14)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @aws-sdk/middleware-sdk-rds
|
package/dist-es/fixture.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
MockSha256.prototype.digest = function () {
|
|
1
|
+
export class MockSha256 {
|
|
2
|
+
constructor(secret) { }
|
|
3
|
+
update(data) { }
|
|
4
|
+
digest() {
|
|
6
5
|
return Promise.resolve(new Uint8Array(5));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return Promise.resolve({
|
|
21
|
-
accessKeyId: "akid",
|
|
22
|
-
secretAccessKey: "secret",
|
|
23
|
-
sessionToken: "session",
|
|
24
|
-
});
|
|
25
|
-
};
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export const region = () => Promise.resolve("mock-region");
|
|
9
|
+
export const endpoint = () => Promise.resolve({
|
|
10
|
+
protocol: "https:",
|
|
11
|
+
path: "/",
|
|
12
|
+
hostname: "ec2.mock-region.amazonaws.com",
|
|
13
|
+
});
|
|
14
|
+
export const credentials = () => Promise.resolve({
|
|
15
|
+
accessKeyId: "akid",
|
|
16
|
+
secretAccessKey: "secret",
|
|
17
|
+
sessionToken: "session",
|
|
18
|
+
});
|
package/dist-es/index.js
CHANGED
|
@@ -1,91 +1,82 @@
|
|
|
1
|
-
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
1
|
import { HttpRequest } from "@aws-sdk/protocol-http";
|
|
3
2
|
import { SignatureV4 } from "@aws-sdk/signature-v4";
|
|
4
3
|
import { formatUrl } from "@aws-sdk/util-format-url";
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const regARN = /arn:[\w+=/,.@-]+:[\w+=/,.@-]+:([\w+=/,.@-]*)?:[0-9]+:[\w+=/,.@-]+(:[\w+=/,.@-]+)?(:[\w+=/,.@-]+)?/;
|
|
5
|
+
const sourceIdToCommandKeyMap = {
|
|
7
6
|
SourceDBSnapshotIdentifier: "CopyDBSnapshot",
|
|
8
7
|
SourceDBInstanceIdentifier: "CreateDBInstanceReadReplica",
|
|
9
8
|
ReplicationSourceIdentifier: "CreateDBCluster",
|
|
10
9
|
SourceDBClusterSnapshotIdentifier: "CopyDBClusterSnapshot",
|
|
11
10
|
SourceDBInstanceArn: "StartDBInstanceAutomatedBackupsReplication",
|
|
12
11
|
};
|
|
13
|
-
|
|
12
|
+
const version = "2014-10-31";
|
|
14
13
|
export function crossRegionPresignedUrlMiddleware(options) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
request = new HttpRequest(__assign(__assign({}, resolvedEndpoint), { protocol: "https", headers: {
|
|
40
|
-
host: resolvedEndpoint.hostname,
|
|
41
|
-
}, query: (_a = {
|
|
42
|
-
Action: command,
|
|
43
|
-
Version: version,
|
|
44
|
-
KmsKeyId: input.KmsKeyId,
|
|
45
|
-
DestinationRegion: region
|
|
46
|
-
},
|
|
47
|
-
_a[sourceIdKey] = input[sourceIdKey],
|
|
48
|
-
_a) }));
|
|
49
|
-
signer = new SignatureV4({
|
|
50
|
-
credentials: options.credentials,
|
|
51
|
-
region: sourceRegion,
|
|
52
|
-
service: "rds",
|
|
53
|
-
sha256: options.sha256,
|
|
54
|
-
uriEscapePath: options.signingEscapePath,
|
|
55
|
-
});
|
|
56
|
-
return [4, signer.presign(request, {
|
|
57
|
-
expiresIn: 3600,
|
|
58
|
-
})];
|
|
59
|
-
case 3:
|
|
60
|
-
presignedRequest = _b.sent();
|
|
61
|
-
args = __assign(__assign({}, args), { input: __assign(__assign({}, args.input), { PreSignedUrl: formatUrl(presignedRequest) }) });
|
|
62
|
-
_b.label = 4;
|
|
63
|
-
case 4: return [2, next(args)];
|
|
64
|
-
}
|
|
14
|
+
return (next) => async (args) => {
|
|
15
|
+
const { input } = args;
|
|
16
|
+
const region = await options.region();
|
|
17
|
+
const sourceIdKey = Object.keys(sourceIdToCommandKeyMap).filter((sourceKeyId) => input.hasOwnProperty(sourceKeyId))[0];
|
|
18
|
+
if (!sourceIdKey)
|
|
19
|
+
return next(args);
|
|
20
|
+
const command = sourceIdToCommandKeyMap[sourceIdKey];
|
|
21
|
+
if (!input.PreSignedUrl && isARN(input[sourceIdKey]) && region !== getEndpointFromARN(input[sourceIdKey])) {
|
|
22
|
+
const sourceRegion = getEndpointFromARN(input[sourceIdKey]);
|
|
23
|
+
const resolvedEndpoint = await options.endpoint();
|
|
24
|
+
resolvedEndpoint.hostname = `rds.${sourceRegion}.amazonaws.com`;
|
|
25
|
+
const request = new HttpRequest({
|
|
26
|
+
...resolvedEndpoint,
|
|
27
|
+
protocol: "https",
|
|
28
|
+
headers: {
|
|
29
|
+
host: resolvedEndpoint.hostname,
|
|
30
|
+
},
|
|
31
|
+
query: {
|
|
32
|
+
Action: command,
|
|
33
|
+
Version: version,
|
|
34
|
+
KmsKeyId: input.KmsKeyId,
|
|
35
|
+
DestinationRegion: region,
|
|
36
|
+
[sourceIdKey]: input[sourceIdKey],
|
|
37
|
+
},
|
|
65
38
|
});
|
|
66
|
-
|
|
39
|
+
const signer = new SignatureV4({
|
|
40
|
+
credentials: options.credentials,
|
|
41
|
+
region: sourceRegion,
|
|
42
|
+
service: "rds",
|
|
43
|
+
sha256: options.sha256,
|
|
44
|
+
uriEscapePath: options.signingEscapePath,
|
|
45
|
+
});
|
|
46
|
+
const presignedRequest = await signer.presign(request, {
|
|
47
|
+
expiresIn: 3600,
|
|
48
|
+
});
|
|
49
|
+
args = {
|
|
50
|
+
...args,
|
|
51
|
+
input: {
|
|
52
|
+
...args.input,
|
|
53
|
+
PreSignedUrl: formatUrl(presignedRequest),
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return next(args);
|
|
67
58
|
};
|
|
68
59
|
}
|
|
69
|
-
export
|
|
60
|
+
export const crossRegionPresignedUrlMiddlewareOptions = {
|
|
70
61
|
step: "initialize",
|
|
71
62
|
tags: ["CROSS_REGION_PRESIGNED_URL"],
|
|
72
63
|
name: "crossRegionPresignedUrlMiddleware",
|
|
73
64
|
override: true,
|
|
74
65
|
};
|
|
75
|
-
export
|
|
76
|
-
applyToStack:
|
|
66
|
+
export const getCrossRegionPresignedUrlPlugin = (config) => ({
|
|
67
|
+
applyToStack: (clientStack) => {
|
|
77
68
|
clientStack.add(crossRegionPresignedUrlMiddleware(config), crossRegionPresignedUrlMiddlewareOptions);
|
|
78
69
|
},
|
|
79
|
-
});
|
|
70
|
+
});
|
|
80
71
|
function isARN(id) {
|
|
81
72
|
if (!id)
|
|
82
73
|
return false;
|
|
83
74
|
return regARN.test(id);
|
|
84
75
|
}
|
|
85
76
|
function getEndpointFromARN(arn) {
|
|
86
|
-
|
|
77
|
+
const arnArr = arn.split(":");
|
|
87
78
|
if (arnArr.length < 4) {
|
|
88
|
-
throw new Error(
|
|
79
|
+
throw new Error(`Cannot infer endpoint from '${arn}'`);
|
|
89
80
|
}
|
|
90
81
|
return arnArr[3];
|
|
91
82
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-sdk-rds",
|
|
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,10 +20,10 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/protocol-http": "3.
|
|
24
|
-
"@aws-sdk/signature-v4": "3.
|
|
25
|
-
"@aws-sdk/types": "3.
|
|
26
|
-
"@aws-sdk/util-format-url": "3.
|
|
23
|
+
"@aws-sdk/protocol-http": "3.183.0",
|
|
24
|
+
"@aws-sdk/signature-v4": "3.183.0",
|
|
25
|
+
"@aws-sdk/types": "3.183.0",
|
|
26
|
+
"@aws-sdk/util-format-url": "3.183.0",
|
|
27
27
|
"tslib": "^2.3.1"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|