@aws-sdk/middleware-sdk-rds 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 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-rds
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-rds
@@ -1,25 +1,18 @@
1
- var MockSha256 = (function () {
2
- function MockSha256(secret) {
3
- }
4
- MockSha256.prototype.update = function (data) { };
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
- return MockSha256;
9
- }());
10
- export { MockSha256 };
11
- export var region = function () { return Promise.resolve("mock-region"); };
12
- export var endpoint = function () {
13
- return Promise.resolve({
14
- protocol: "https:",
15
- path: "/",
16
- hostname: "ec2.mock-region.amazonaws.com",
17
- });
18
- };
19
- export var credentials = function () {
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
- var regARN = /arn:[\w+=/,.@-]+:[\w+=/,.@-]+:([\w+=/,.@-]*)?:[0-9]+:[\w+=/,.@-]+(:[\w+=/,.@-]+)?(:[\w+=/,.@-]+)?/;
6
- var sourceIdToCommandKeyMap = {
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
- var version = "2014-10-31";
12
+ const version = "2014-10-31";
14
13
  export function crossRegionPresignedUrlMiddleware(options) {
15
- var _this = this;
16
- return function (next) {
17
- return function (args) { return __awaiter(_this, void 0, void 0, function () {
18
- var input, region, sourceIdKey, command, sourceRegion, resolvedEndpoint, request, signer, presignedRequest;
19
- var _a;
20
- return __generator(this, function (_b) {
21
- switch (_b.label) {
22
- case 0:
23
- input = args.input;
24
- return [4, options.region()];
25
- case 1:
26
- region = _b.sent();
27
- sourceIdKey = Object.keys(sourceIdToCommandKeyMap).filter(function (sourceKeyId) {
28
- return input.hasOwnProperty(sourceKeyId);
29
- })[0];
30
- if (!sourceIdKey)
31
- return [2, next(args)];
32
- command = sourceIdToCommandKeyMap[sourceIdKey];
33
- if (!(!input.PreSignedUrl && isARN(input[sourceIdKey]) && region !== getEndpointFromARN(input[sourceIdKey]))) return [3, 4];
34
- sourceRegion = getEndpointFromARN(input[sourceIdKey]);
35
- return [4, options.endpoint()];
36
- case 2:
37
- resolvedEndpoint = _b.sent();
38
- resolvedEndpoint.hostname = "rds.".concat(sourceRegion, ".amazonaws.com");
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 var crossRegionPresignedUrlMiddlewareOptions = {
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 var getCrossRegionPresignedUrlPlugin = function (config) { return ({
76
- applyToStack: function (clientStack) {
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
- var arnArr = arn.split(":");
77
+ const arnArr = arn.split(":");
87
78
  if (arnArr.length < 4) {
88
- throw new Error("Cannot infer endpoint from '".concat(arn, "'"));
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.178.0",
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.178.0",
24
- "@aws-sdk/signature-v4": "3.178.0",
25
- "@aws-sdk/types": "3.178.0",
26
- "@aws-sdk/util-format-url": "3.178.0",
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": {