@aws-sdk/middleware-sdk-ec2 3.306.0 → 3.310.1

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 CHANGED
@@ -4,10 +4,12 @@ exports.getCopySnapshotPresignedUrlPlugin = exports.copySnapshotPresignedUrlMidd
4
4
  const middleware_endpoint_1 = require("@aws-sdk/middleware-endpoint");
5
5
  const protocol_http_1 = require("@aws-sdk/protocol-http");
6
6
  const signature_v4_1 = require("@aws-sdk/signature-v4");
7
+ const smithy_client_1 = require("@aws-sdk/smithy-client");
7
8
  const util_format_url_1 = require("@aws-sdk/util-format-url");
8
9
  const version = "2016-11-15";
9
10
  function copySnapshotPresignedUrlMiddleware(options) {
10
11
  return (next, context) => async (args) => {
12
+ var _a, _b;
11
13
  const { input } = args;
12
14
  if (!input.PresignedUrl) {
13
15
  const destinationRegion = await options.region();
@@ -25,17 +27,16 @@ function copySnapshotPresignedUrlMiddleware(options) {
25
27
  region: input.SourceRegion,
26
28
  });
27
29
  const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : (0, middleware_endpoint_1.toEndpointV1)(endpoint);
28
- const request = new protocol_http_1.HttpRequest({
30
+ const requestToSign = new protocol_http_1.HttpRequest({
29
31
  ...resolvedEndpoint,
30
32
  protocol: "https",
31
33
  headers: {
32
34
  host: resolvedEndpoint.hostname,
33
35
  },
34
36
  query: {
37
+ ...input,
35
38
  Action: "CopySnapshot",
36
39
  Version: version,
37
- SourceRegion: input.SourceRegion,
38
- SourceSnapshotId: input.SourceSnapshotId,
39
40
  DestinationRegion: destinationRegion,
40
41
  },
41
42
  });
@@ -46,7 +47,7 @@ function copySnapshotPresignedUrlMiddleware(options) {
46
47
  sha256: options.sha256,
47
48
  uriEscapePath: options.signingEscapePath,
48
49
  });
49
- const presignedRequest = await signer.presign(request, {
50
+ const presignedRequest = await signer.presign(requestToSign, {
50
51
  expiresIn: 3600,
51
52
  });
52
53
  args = {
@@ -57,6 +58,15 @@ function copySnapshotPresignedUrlMiddleware(options) {
57
58
  PresignedUrl: (0, util_format_url_1.formatUrl)(presignedRequest),
58
59
  },
59
60
  };
61
+ if (protocol_http_1.HttpRequest.isInstance(args.request)) {
62
+ const { request } = args;
63
+ if (!((_a = request.body) !== null && _a !== void 0 ? _a : "").includes("DestinationRegion=")) {
64
+ request.body += `&DestinationRegion=${destinationRegion}`;
65
+ }
66
+ if (!((_b = request.body) !== null && _b !== void 0 ? _b : "").includes("PresignedUrl=")) {
67
+ request.body += `&PresignedUrl=${(0, smithy_client_1.extendedEncodeURIComponent)(args.input.PresignedUrl)}`;
68
+ }
69
+ }
60
70
  }
61
71
  return next(args);
62
72
  };
package/dist-es/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { getEndpointFromInstructions, toEndpointV1 } from "@aws-sdk/middleware-endpoint";
2
2
  import { HttpRequest } from "@aws-sdk/protocol-http";
3
3
  import { SignatureV4 } from "@aws-sdk/signature-v4";
4
+ import { extendedEncodeURIComponent } from "@aws-sdk/smithy-client";
4
5
  import { formatUrl } from "@aws-sdk/util-format-url";
5
6
  const version = "2016-11-15";
6
7
  export function copySnapshotPresignedUrlMiddleware(options) {
@@ -22,17 +23,16 @@ export function copySnapshotPresignedUrlMiddleware(options) {
22
23
  region: input.SourceRegion,
23
24
  });
24
25
  const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : toEndpointV1(endpoint);
25
- const request = new HttpRequest({
26
+ const requestToSign = new HttpRequest({
26
27
  ...resolvedEndpoint,
27
28
  protocol: "https",
28
29
  headers: {
29
30
  host: resolvedEndpoint.hostname,
30
31
  },
31
32
  query: {
33
+ ...input,
32
34
  Action: "CopySnapshot",
33
35
  Version: version,
34
- SourceRegion: input.SourceRegion,
35
- SourceSnapshotId: input.SourceSnapshotId,
36
36
  DestinationRegion: destinationRegion,
37
37
  },
38
38
  });
@@ -43,7 +43,7 @@ export function copySnapshotPresignedUrlMiddleware(options) {
43
43
  sha256: options.sha256,
44
44
  uriEscapePath: options.signingEscapePath,
45
45
  });
46
- const presignedRequest = await signer.presign(request, {
46
+ const presignedRequest = await signer.presign(requestToSign, {
47
47
  expiresIn: 3600,
48
48
  });
49
49
  args = {
@@ -54,6 +54,15 @@ export function copySnapshotPresignedUrlMiddleware(options) {
54
54
  PresignedUrl: formatUrl(presignedRequest),
55
55
  },
56
56
  };
57
+ if (HttpRequest.isInstance(args.request)) {
58
+ const { request } = args;
59
+ if (!(request.body ?? "").includes("DestinationRegion=")) {
60
+ request.body += `&DestinationRegion=${destinationRegion}`;
61
+ }
62
+ if (!(request.body ?? "").includes("PresignedUrl=")) {
63
+ request.body += `&PresignedUrl=${extendedEncodeURIComponent(args.input.PresignedUrl)}`;
64
+ }
65
+ }
57
66
  }
58
67
  return next(args);
59
68
  };
@@ -1,4 +1,4 @@
1
- import { AwsCredentialIdentity, ChecksumConstructor, Endpoint, HashConstructor, InitializeMiddleware, MemoizedProvider, Pluggable, Provider, RegionInfoProvider, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@aws-sdk/types";
1
+ import { AwsCredentialIdentity, ChecksumConstructor, Endpoint, HashConstructor, MemoizedProvider, Pluggable, Provider, RegionInfoProvider, RelativeMiddlewareOptions, SerializeHandlerOptions, SerializeMiddleware } from "@aws-sdk/types";
2
2
  interface PreviouslyResolved {
3
3
  credentials: MemoizedProvider<AwsCredentialIdentity>;
4
4
  endpoint?: Provider<Endpoint>;
@@ -7,7 +7,7 @@ interface PreviouslyResolved {
7
7
  signingEscapePath: boolean;
8
8
  regionInfoProvider?: RegionInfoProvider;
9
9
  }
10
- export declare function copySnapshotPresignedUrlMiddleware(options: PreviouslyResolved): InitializeMiddleware<any, any>;
10
+ export declare function copySnapshotPresignedUrlMiddleware(options: PreviouslyResolved): SerializeMiddleware<any, any>;
11
11
  export declare const copySnapshotPresignedUrlMiddlewareOptions: SerializeHandlerOptions & RelativeMiddlewareOptions;
12
12
  export declare const getCopySnapshotPresignedUrlPlugin: (config: PreviouslyResolved) => Pluggable<any, any>;
13
13
  export {};
@@ -1,12 +1,12 @@
1
- import { SourceData } from "@aws-sdk/types";
2
- export declare class MockSha256 {
3
- constructor(secret?: string | ArrayBuffer | ArrayBufferView);
4
- update(data?: SourceData): void;
5
- digest(): Promise<Uint8Array>;
6
- }
7
- export declare const region: () => Promise<string>;
8
- export declare const credentials: () => Promise<{
9
- accessKeyId: string;
10
- secretAccessKey: string;
11
- sessionToken: string;
12
- }>;
1
+ import { SourceData } from "@aws-sdk/types";
2
+ export declare class MockSha256 {
3
+ constructor(secret?: string | ArrayBuffer | ArrayBufferView);
4
+ update(data?: SourceData): void;
5
+ digest(): Promise<Uint8Array>;
6
+ }
7
+ export declare const region: () => Promise<string>;
8
+ export declare const credentials: () => Promise<{
9
+ accessKeyId: string;
10
+ secretAccessKey: string;
11
+ sessionToken: string;
12
+ }>;
@@ -1,30 +1,13 @@
1
- import {
2
- AwsCredentialIdentity,
3
- ChecksumConstructor,
4
- Endpoint,
5
- HashConstructor,
6
- InitializeMiddleware,
7
- MemoizedProvider,
8
- Pluggable,
9
- Provider,
10
- RegionInfoProvider,
11
- RelativeMiddlewareOptions,
12
- SerializeHandlerOptions,
13
- } from "@aws-sdk/types";
14
- interface PreviouslyResolved {
15
- credentials: MemoizedProvider<AwsCredentialIdentity>;
16
- endpoint?: Provider<Endpoint>;
17
- region: Provider<string>;
18
- sha256: ChecksumConstructor | HashConstructor;
19
- signingEscapePath: boolean;
20
- regionInfoProvider?: RegionInfoProvider;
21
- }
22
- export declare function copySnapshotPresignedUrlMiddleware(
23
- options: PreviouslyResolved
24
- ): InitializeMiddleware<any, any>;
25
- export declare const copySnapshotPresignedUrlMiddlewareOptions: SerializeHandlerOptions &
26
- RelativeMiddlewareOptions;
27
- export declare const getCopySnapshotPresignedUrlPlugin: (
28
- config: PreviouslyResolved
29
- ) => Pluggable<any, any>;
30
- export {};
1
+ import { AwsCredentialIdentity, ChecksumConstructor, Endpoint, HashConstructor, MemoizedProvider, Pluggable, Provider, RegionInfoProvider, RelativeMiddlewareOptions, SerializeHandlerOptions, SerializeMiddleware } from "@aws-sdk/types";
2
+ interface PreviouslyResolved {
3
+ credentials: MemoizedProvider<AwsCredentialIdentity>;
4
+ endpoint?: Provider<Endpoint>;
5
+ region: Provider<string>;
6
+ sha256: ChecksumConstructor | HashConstructor;
7
+ signingEscapePath: boolean;
8
+ regionInfoProvider?: RegionInfoProvider;
9
+ }
10
+ export declare function copySnapshotPresignedUrlMiddleware(options: PreviouslyResolved): SerializeMiddleware<any, any>;
11
+ export declare const copySnapshotPresignedUrlMiddlewareOptions: SerializeHandlerOptions & RelativeMiddlewareOptions;
12
+ export declare const getCopySnapshotPresignedUrlPlugin: (config: PreviouslyResolved) => Pluggable<any, any>;
13
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-ec2",
3
- "version": "3.306.0",
3
+ "version": "3.310.1",
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,11 +20,12 @@
20
20
  },
21
21
  "license": "Apache-2.0",
22
22
  "dependencies": {
23
- "@aws-sdk/middleware-endpoint": "3.306.0",
24
- "@aws-sdk/protocol-http": "3.306.0",
25
- "@aws-sdk/signature-v4": "3.306.0",
26
- "@aws-sdk/types": "3.306.0",
27
- "@aws-sdk/util-format-url": "3.306.0",
23
+ "@aws-sdk/middleware-endpoint": "3.310.0",
24
+ "@aws-sdk/protocol-http": "3.310.0",
25
+ "@aws-sdk/signature-v4": "3.310.0",
26
+ "@aws-sdk/smithy-client": "3.310.0",
27
+ "@aws-sdk/types": "3.310.0",
28
+ "@aws-sdk/util-format-url": "3.310.0",
28
29
  "tslib": "^2.5.0"
29
30
  },
30
31
  "engines": {
@@ -38,7 +39,7 @@
38
39
  }
39
40
  },
40
41
  "files": [
41
- "dist-*"
42
+ "dist-*/**"
42
43
  ],
43
44
  "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages/middleware-sdk-ec2",
44
45
  "repository": {