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