@aws-sdk/middleware-sdk-rds 3.485.0 → 3.495.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.
@@ -1,26 +1 @@
1
- "use strict";
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,129 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCrossRegionPresignedUrlPlugin = exports.crossRegionPresignedUrlMiddlewareOptions = exports.crossRegionPresignedUrlMiddleware = void 0;
4
- const util_format_url_1 = require("@aws-sdk/util-format-url");
5
- const middleware_endpoint_1 = require("@smithy/middleware-endpoint");
6
- const protocol_http_1 = require("@smithy/protocol-http");
7
- const signature_v4_1 = require("@smithy/signature-v4");
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",
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
- const version = "2014-10-31";
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
- 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 = (0, middleware_endpoint_1.toEndpointV1)(context.endpointV2);
33
- }
34
- resolvedEndpoint.hostname = `rds.${sourceRegion}.amazonaws.com`;
35
- const request = new protocol_http_1.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 signature_v4_1.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: (0, util_format_url_1.formatUrl)(presignedRequest),
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
- return next(args);
68
- };
91
+ };
92
+ }
93
+ return next(args);
94
+ };
69
95
  }
70
- exports.crossRegionPresignedUrlMiddleware = crossRegionPresignedUrlMiddleware;
71
- exports.crossRegionPresignedUrlMiddlewareOptions = {
72
- step: "serialize",
73
- tags: ["CROSS_REGION_PRESIGNED_URL"],
74
- name: "crossRegionPresignedUrlMiddleware",
75
- override: true,
76
- relation: "after",
77
- toMiddleware: "endpointV2Middleware",
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
- const getCrossRegionPresignedUrlPlugin = (config) => ({
80
- applyToStack: (clientStack) => {
81
- clientStack.addRelativeTo(crossRegionPresignedUrlMiddleware(config), exports.crossRegionPresignedUrlMiddlewareOptions);
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
- if (!id)
87
- return false;
88
- return regARN.test(id);
111
+ if (!id)
112
+ return false;
113
+ return regARN.test(id);
89
114
  }
115
+ __name(isARN, "isARN");
90
116
  function getEndpointFromARN(arn) {
91
- const arnArr = arn.split(":");
92
- if (arnArr.length < 4) {
93
- throw new Error(`Cannot infer endpoint from '${arn}'`);
94
- }
95
- return arnArr[3];
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
+ 0 && (module.exports = {
126
+ crossRegionPresignedUrlMiddleware,
127
+ crossRegionPresignedUrlMiddlewareOptions,
128
+ getCrossRegionPresignedUrlPlugin
129
+ });
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-rds",
3
- "version": "3.485.0",
3
+ "version": "3.495.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
- "build:cjs": "tsc -p tsconfig.cjs.json",
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.485.0",
25
- "@aws-sdk/util-format-url": "3.485.0",
26
- "@smithy/middleware-endpoint": "^2.3.0",
27
- "@smithy/protocol-http": "^3.0.12",
28
- "@smithy/signature-v4": "^2.0.0",
29
- "@smithy/types": "^2.8.0",
24
+ "@aws-sdk/types": "3.495.0",
25
+ "@aws-sdk/util-format-url": "3.495.0",
26
+ "@smithy/middleware-endpoint": "^2.4.0",
27
+ "@smithy/protocol-http": "^3.1.0",
28
+ "@smithy/signature-v4": "^2.1.0",
29
+ "@smithy/types": "^2.9.0",
30
30
  "tslib": "^2.5.0"
31
31
  },
32
32
  "engines": {