@aws-sdk/middleware-sdk-ec2 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-ec2
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-ec2
@@ -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,71 +1,64 @@
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 version = "2016-11-15";
4
+ const version = "2016-11-15";
6
5
  export function copySnapshotPresignedUrlMiddleware(options) {
7
- var _this = this;
8
- return function (next) {
9
- return function (args) { return __awaiter(_this, void 0, void 0, function () {
10
- var input, region, resolvedEndpoint, regionInfo, request, signer, presignedRequest;
11
- return __generator(this, function (_a) {
12
- switch (_a.label) {
13
- case 0:
14
- input = args.input;
15
- if (!!input.PresignedUrl) return [3, 7];
16
- return [4, options.region()];
17
- case 1:
18
- region = _a.sent();
19
- return [4, options.endpoint()];
20
- case 2:
21
- resolvedEndpoint = _a.sent();
22
- if (!(typeof options.regionInfoProvider === "function")) return [3, 4];
23
- return [4, options.regionInfoProvider(input.SourceRegion)];
24
- case 3:
25
- regionInfo = _a.sent();
26
- resolvedEndpoint.hostname = (regionInfo === null || regionInfo === void 0 ? void 0 : regionInfo.hostname) || "ec2.".concat(input.SourceRegion, ".amazonaws.com");
27
- return [3, 5];
28
- case 4:
29
- resolvedEndpoint.hostname = "ec2.".concat(input.SourceRegion, ".amazonaws.com");
30
- _a.label = 5;
31
- case 5:
32
- request = new HttpRequest(__assign(__assign({}, resolvedEndpoint), { protocol: "https", headers: {
33
- host: resolvedEndpoint.hostname,
34
- }, query: {
35
- Action: "CopySnapshot",
36
- Version: version,
37
- SourceRegion: input.SourceRegion,
38
- SourceSnapshotId: input.SourceSnapshotId,
39
- DestinationRegion: region,
40
- } }));
41
- signer = new SignatureV4({
42
- credentials: options.credentials,
43
- region: input.SourceRegion,
44
- service: "ec2",
45
- sha256: options.sha256,
46
- uriEscapePath: options.signingEscapePath,
47
- });
48
- return [4, signer.presign(request, {
49
- expiresIn: 3600,
50
- })];
51
- case 6:
52
- presignedRequest = _a.sent();
53
- args = __assign(__assign({}, args), { input: __assign(__assign({}, args.input), { DestinationRegion: region, PresignedUrl: formatUrl(presignedRequest) }) });
54
- _a.label = 7;
55
- case 7: return [2, next(args)];
56
- }
6
+ return (next) => async (args) => {
7
+ const { input } = args;
8
+ if (!input.PresignedUrl) {
9
+ const region = await options.region();
10
+ const resolvedEndpoint = await options.endpoint();
11
+ if (typeof options.regionInfoProvider === "function") {
12
+ const regionInfo = await options.regionInfoProvider(input.SourceRegion);
13
+ resolvedEndpoint.hostname = regionInfo?.hostname || `ec2.${input.SourceRegion}.amazonaws.com`;
14
+ }
15
+ else {
16
+ resolvedEndpoint.hostname = `ec2.${input.SourceRegion}.amazonaws.com`;
17
+ }
18
+ const request = new HttpRequest({
19
+ ...resolvedEndpoint,
20
+ protocol: "https",
21
+ headers: {
22
+ host: resolvedEndpoint.hostname,
23
+ },
24
+ query: {
25
+ Action: "CopySnapshot",
26
+ Version: version,
27
+ SourceRegion: input.SourceRegion,
28
+ SourceSnapshotId: input.SourceSnapshotId,
29
+ DestinationRegion: region,
30
+ },
57
31
  });
58
- }); };
32
+ const signer = new SignatureV4({
33
+ credentials: options.credentials,
34
+ region: input.SourceRegion,
35
+ service: "ec2",
36
+ sha256: options.sha256,
37
+ uriEscapePath: options.signingEscapePath,
38
+ });
39
+ const presignedRequest = await signer.presign(request, {
40
+ expiresIn: 3600,
41
+ });
42
+ args = {
43
+ ...args,
44
+ input: {
45
+ ...args.input,
46
+ DestinationRegion: region,
47
+ PresignedUrl: formatUrl(presignedRequest),
48
+ },
49
+ };
50
+ }
51
+ return next(args);
59
52
  };
60
53
  }
61
- export var copySnapshotPresignedUrlMiddlewareOptions = {
54
+ export const copySnapshotPresignedUrlMiddlewareOptions = {
62
55
  step: "initialize",
63
56
  tags: ["CROSS_REGION_PRESIGNED_URL"],
64
57
  name: "crossRegionPresignedUrlMiddleware",
65
58
  override: true,
66
59
  };
67
- export var getCopySnapshotPresignedUrlPlugin = function (config) { return ({
68
- applyToStack: function (clientStack) {
60
+ export const getCopySnapshotPresignedUrlPlugin = (config) => ({
61
+ applyToStack: (clientStack) => {
69
62
  clientStack.add(copySnapshotPresignedUrlMiddleware(config), copySnapshotPresignedUrlMiddlewareOptions);
70
63
  },
71
- }); };
64
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-ec2",
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": {