@aws-sdk/middleware-sdk-rds 3.901.0 → 3.910.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/dist-cjs/index.js +87 -119
- package/package.json +7 -7
package/dist-cjs/index.js
CHANGED
|
@@ -1,130 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
20
2
|
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var regARN = /arn:[\w+=/,.@-]+:[\w+=/,.@-]+:([\w+=/,.@-]*)?:[0-9]+:[\w+=/,.@-]+(:[\w+=/,.@-]+)?(:[\w+=/,.@-]+)?/;
|
|
34
|
-
var sourceIdToCommandKeyMap = {
|
|
35
|
-
SourceDBSnapshotIdentifier: "CopyDBSnapshot",
|
|
36
|
-
SourceDBInstanceIdentifier: "CreateDBInstanceReadReplica",
|
|
37
|
-
ReplicationSourceIdentifier: "CreateDBCluster",
|
|
38
|
-
// This key is optional.
|
|
39
|
-
SourceDBClusterSnapshotIdentifier: "CopyDBClusterSnapshot",
|
|
40
|
-
SourceDBInstanceArn: "StartDBInstanceAutomatedBackupsReplication"
|
|
3
|
+
var utilFormatUrl = require('@aws-sdk/util-format-url');
|
|
4
|
+
var middlewareEndpoint = require('@smithy/middleware-endpoint');
|
|
5
|
+
var protocolHttp = require('@smithy/protocol-http');
|
|
6
|
+
var signatureV4 = require('@smithy/signature-v4');
|
|
7
|
+
|
|
8
|
+
const regARN = /arn:[\w+=/,.@-]+:[\w+=/,.@-]+:([\w+=/,.@-]*)?:[0-9]+:[\w+=/,.@-]+(:[\w+=/,.@-]+)?(:[\w+=/,.@-]+)?/;
|
|
9
|
+
const sourceIdToCommandKeyMap = {
|
|
10
|
+
SourceDBSnapshotIdentifier: "CopyDBSnapshot",
|
|
11
|
+
SourceDBInstanceIdentifier: "CreateDBInstanceReadReplica",
|
|
12
|
+
ReplicationSourceIdentifier: "CreateDBCluster",
|
|
13
|
+
SourceDBClusterSnapshotIdentifier: "CopyDBClusterSnapshot",
|
|
14
|
+
SourceDBInstanceArn: "StartDBInstanceAutomatedBackupsReplication",
|
|
41
15
|
};
|
|
42
|
-
|
|
16
|
+
const version = "2014-10-31";
|
|
43
17
|
function crossRegionPresignedUrlMiddleware(options) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
18
|
+
return (next, context) => async (args) => {
|
|
19
|
+
const { input } = args;
|
|
20
|
+
const region = await options.region();
|
|
21
|
+
const sourceIdKey = Object.keys(sourceIdToCommandKeyMap).filter((sourceKeyId) => input.hasOwnProperty(sourceKeyId))[0];
|
|
22
|
+
if (!sourceIdKey)
|
|
23
|
+
return next(args);
|
|
24
|
+
const command = sourceIdToCommandKeyMap[sourceIdKey];
|
|
25
|
+
if (!input.PreSignedUrl && isARN(input[sourceIdKey]) && region !== getEndpointFromARN(input[sourceIdKey])) {
|
|
26
|
+
const sourceRegion = getEndpointFromARN(input[sourceIdKey]);
|
|
27
|
+
let resolvedEndpoint;
|
|
28
|
+
if (typeof options.endpoint === "function") {
|
|
29
|
+
resolvedEndpoint = await options.endpoint();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
resolvedEndpoint = middlewareEndpoint.toEndpointV1(context.endpointV2);
|
|
33
|
+
}
|
|
34
|
+
resolvedEndpoint.hostname = `rds.${sourceRegion}.amazonaws.com`;
|
|
35
|
+
const request = new protocolHttp.HttpRequest({
|
|
36
|
+
...resolvedEndpoint,
|
|
37
|
+
protocol: "https",
|
|
38
|
+
headers: {
|
|
39
|
+
host: resolvedEndpoint.hostname,
|
|
40
|
+
},
|
|
41
|
+
query: {
|
|
42
|
+
Action: command,
|
|
43
|
+
Version: version,
|
|
44
|
+
KmsKeyId: input.KmsKeyId,
|
|
45
|
+
DestinationRegion: region,
|
|
46
|
+
[sourceIdKey]: input[sourceIdKey],
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
const signer = new signatureV4.SignatureV4({
|
|
50
|
+
credentials: options.credentials,
|
|
51
|
+
region: sourceRegion,
|
|
52
|
+
service: "rds",
|
|
53
|
+
sha256: options.sha256,
|
|
54
|
+
uriEscapePath: options.signingEscapePath,
|
|
55
|
+
});
|
|
56
|
+
const presignedRequest = await signer.presign(request, {
|
|
57
|
+
expiresIn: 3600,
|
|
58
|
+
});
|
|
59
|
+
args = {
|
|
60
|
+
...args,
|
|
61
|
+
input: {
|
|
62
|
+
...args.input,
|
|
63
|
+
PreSignedUrl: utilFormatUrl.formatUrl(presignedRequest),
|
|
64
|
+
},
|
|
65
|
+
};
|
|
90
66
|
}
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
return next(args);
|
|
94
|
-
};
|
|
67
|
+
return next(args);
|
|
68
|
+
};
|
|
95
69
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
toMiddleware: "endpointV2Middleware"
|
|
70
|
+
const crossRegionPresignedUrlMiddlewareOptions = {
|
|
71
|
+
step: "serialize",
|
|
72
|
+
tags: ["CROSS_REGION_PRESIGNED_URL"],
|
|
73
|
+
name: "crossRegionPresignedUrlMiddleware",
|
|
74
|
+
override: true,
|
|
75
|
+
relation: "after",
|
|
76
|
+
toMiddleware: "endpointV2Middleware",
|
|
104
77
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
})
|
|
78
|
+
const getCrossRegionPresignedUrlPlugin = (config) => ({
|
|
79
|
+
applyToStack: (clientStack) => {
|
|
80
|
+
clientStack.addRelativeTo(crossRegionPresignedUrlMiddleware(config), crossRegionPresignedUrlMiddlewareOptions);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
110
83
|
function isARN(id) {
|
|
111
|
-
|
|
112
|
-
|
|
84
|
+
if (!id)
|
|
85
|
+
return false;
|
|
86
|
+
return regARN.test(id);
|
|
113
87
|
}
|
|
114
|
-
__name(isARN, "isARN");
|
|
115
88
|
function getEndpointFromARN(arn) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
89
|
+
const arnArr = arn.split(":");
|
|
90
|
+
if (arnArr.length < 4) {
|
|
91
|
+
throw new Error(`Cannot infer endpoint from '${arn}'`);
|
|
92
|
+
}
|
|
93
|
+
return arnArr[3];
|
|
121
94
|
}
|
|
122
|
-
__name(getEndpointFromARN, "getEndpointFromARN");
|
|
123
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
-
|
|
125
|
-
0 && (module.exports = {
|
|
126
|
-
crossRegionPresignedUrlMiddlewareOptions,
|
|
127
|
-
getCrossRegionPresignedUrlPlugin,
|
|
128
|
-
crossRegionPresignedUrlMiddleware
|
|
129
|
-
});
|
|
130
95
|
|
|
96
|
+
exports.crossRegionPresignedUrlMiddleware = crossRegionPresignedUrlMiddleware;
|
|
97
|
+
exports.crossRegionPresignedUrlMiddlewareOptions = crossRegionPresignedUrlMiddlewareOptions;
|
|
98
|
+
exports.getCrossRegionPresignedUrlPlugin = getCrossRegionPresignedUrlPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-sdk-rds",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.910.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-rds",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@aws-sdk/types": "3.
|
|
28
|
-
"@aws-sdk/util-format-url": "3.
|
|
29
|
-
"@smithy/middleware-endpoint": "^4.3.
|
|
30
|
-
"@smithy/protocol-http": "^5.3.
|
|
31
|
-
"@smithy/signature-v4": "^5.3.
|
|
32
|
-
"@smithy/types": "^4.
|
|
27
|
+
"@aws-sdk/types": "3.910.0",
|
|
28
|
+
"@aws-sdk/util-format-url": "3.910.0",
|
|
29
|
+
"@smithy/middleware-endpoint": "^4.3.3",
|
|
30
|
+
"@smithy/protocol-http": "^5.3.2",
|
|
31
|
+
"@smithy/signature-v4": "^5.3.2",
|
|
32
|
+
"@smithy/types": "^4.7.1",
|
|
33
33
|
"tslib": "^2.6.2"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|