@aws-sdk/middleware-sdk-ec2 3.899.0 → 3.908.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.
Files changed (2) hide show
  1. package/dist-cjs/index.js +84 -124
  2. package/package.json +8 -8
package/dist-cjs/index.js CHANGED
@@ -1,132 +1,92 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
20
2
 
21
- // src/index.ts
22
- var index_exports = {};
23
- __export(index_exports, {
24
- copySnapshotPresignedUrlMiddleware: () => copySnapshotPresignedUrlMiddleware,
25
- copySnapshotPresignedUrlMiddlewareOptions: () => copySnapshotPresignedUrlMiddlewareOptions,
26
- getCopySnapshotPresignedUrlPlugin: () => getCopySnapshotPresignedUrlPlugin
27
- });
28
- module.exports = __toCommonJS(index_exports);
29
- var import_util_format_url = require("@aws-sdk/util-format-url");
30
- var import_middleware_endpoint = require("@smithy/middleware-endpoint");
31
- var import_protocol_http = require("@smithy/protocol-http");
32
- var import_signature_v4 = require("@smithy/signature-v4");
33
- var import_smithy_client = require("@smithy/smithy-client");
34
- var version = "2016-11-15";
3
+ var utilFormatUrl = require('@aws-sdk/util-format-url');
4
+ var middlewareEndpoint = require('@smithy/middleware-endpoint');
5
+ var protocolHttp = require('@smithy/protocol-http');
6
+ var signatureV4 = require('@smithy/signature-v4');
7
+ var smithyClient = require('@smithy/smithy-client');
8
+
9
+ const version = "2016-11-15";
35
10
  function copySnapshotPresignedUrlMiddleware(options) {
36
- return (next, context) => async (args) => {
37
- const { input } = args;
38
- if (!input.PresignedUrl) {
39
- const destinationRegion = await options.region();
40
- const endpoint = await (0, import_middleware_endpoint.getEndpointFromInstructions)(
41
- input,
42
- {
43
- /**
44
- * Replication of {@link CopySnapshotCommand} in EC2.
45
- * Not imported due to circular dependency.
46
- */
47
- getEndpointParameterInstructions() {
48
- return {
49
- UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
50
- Endpoint: { type: "builtInParams", name: "endpoint" },
51
- Region: { type: "builtInParams", name: "region" },
52
- UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
11
+ return (next, context) => async (args) => {
12
+ const { input } = args;
13
+ if (!input.PresignedUrl) {
14
+ const destinationRegion = await options.region();
15
+ const endpoint = await middlewareEndpoint.getEndpointFromInstructions(input, {
16
+ getEndpointParameterInstructions() {
17
+ return {
18
+ UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
19
+ Endpoint: { type: "builtInParams", name: "endpoint" },
20
+ Region: { type: "builtInParams", name: "region" },
21
+ UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
22
+ };
23
+ },
24
+ }, {
25
+ ...options,
26
+ region: input.SourceRegion,
27
+ });
28
+ const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : middlewareEndpoint.toEndpointV1(endpoint);
29
+ const requestToSign = new protocolHttp.HttpRequest({
30
+ ...resolvedEndpoint,
31
+ protocol: "https",
32
+ headers: {
33
+ host: resolvedEndpoint.hostname,
34
+ },
35
+ query: {
36
+ ...Object.entries(input).reduce((acc, [k, v]) => {
37
+ acc[k] = String(v ?? "");
38
+ return acc;
39
+ }, {}),
40
+ Action: "CopySnapshot",
41
+ Version: version,
42
+ DestinationRegion: destinationRegion,
43
+ },
44
+ });
45
+ const signer = new signatureV4.SignatureV4({
46
+ credentials: options.credentials,
47
+ region: input.SourceRegion,
48
+ service: "ec2",
49
+ sha256: options.sha256,
50
+ uriEscapePath: options.signingEscapePath,
51
+ });
52
+ const presignedRequest = await signer.presign(requestToSign, {
53
+ expiresIn: 3600,
54
+ });
55
+ args = {
56
+ ...args,
57
+ input: {
58
+ ...args.input,
59
+ DestinationRegion: destinationRegion,
60
+ PresignedUrl: utilFormatUrl.formatUrl(presignedRequest),
61
+ },
53
62
  };
54
- }
55
- },
56
- {
57
- ...options,
58
- region: input.SourceRegion
59
- }
60
- );
61
- const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : (0, import_middleware_endpoint.toEndpointV1)(endpoint);
62
- const requestToSign = new import_protocol_http.HttpRequest({
63
- ...resolvedEndpoint,
64
- protocol: "https",
65
- headers: {
66
- host: resolvedEndpoint.hostname
67
- },
68
- query: {
69
- // Values must be string instead of e.g. boolean
70
- // because we need to sign the serialized form.
71
- ...Object.entries(input).reduce((acc, [k, v]) => {
72
- acc[k] = String(v ?? "");
73
- return acc;
74
- }, {}),
75
- Action: "CopySnapshot",
76
- Version: version,
77
- DestinationRegion: destinationRegion
63
+ if (protocolHttp.HttpRequest.isInstance(args.request)) {
64
+ const { request } = args;
65
+ if (!(request.body ?? "").includes("DestinationRegion=")) {
66
+ request.body += `&DestinationRegion=${destinationRegion}`;
67
+ }
68
+ if (!(request.body ?? "").includes("PresignedUrl=")) {
69
+ request.body += `&PresignedUrl=${smithyClient.extendedEncodeURIComponent(args.input.PresignedUrl)}`;
70
+ }
71
+ }
78
72
  }
79
- });
80
- const signer = new import_signature_v4.SignatureV4({
81
- credentials: options.credentials,
82
- region: input.SourceRegion,
83
- service: "ec2",
84
- sha256: options.sha256,
85
- uriEscapePath: options.signingEscapePath
86
- });
87
- const presignedRequest = await signer.presign(requestToSign, {
88
- expiresIn: 3600
89
- });
90
- args = {
91
- ...args,
92
- input: {
93
- ...args.input,
94
- DestinationRegion: destinationRegion,
95
- PresignedUrl: (0, import_util_format_url.formatUrl)(presignedRequest)
96
- }
97
- };
98
- if (import_protocol_http.HttpRequest.isInstance(args.request)) {
99
- const { request } = args;
100
- if (!(request.body ?? "").includes("DestinationRegion=")) {
101
- request.body += `&DestinationRegion=${destinationRegion}`;
102
- }
103
- if (!(request.body ?? "").includes("PresignedUrl=")) {
104
- request.body += `&PresignedUrl=${(0, import_smithy_client.extendedEncodeURIComponent)(args.input.PresignedUrl)}`;
105
- }
106
- }
107
- }
108
- return next(args);
109
- };
73
+ return next(args);
74
+ };
110
75
  }
111
- __name(copySnapshotPresignedUrlMiddleware, "copySnapshotPresignedUrlMiddleware");
112
- var copySnapshotPresignedUrlMiddlewareOptions = {
113
- step: "serialize",
114
- tags: ["CROSS_REGION_PRESIGNED_URL"],
115
- name: "crossRegionPresignedUrlMiddleware",
116
- override: true,
117
- relation: "after",
118
- toMiddleware: "endpointV2Middleware"
76
+ const copySnapshotPresignedUrlMiddlewareOptions = {
77
+ step: "serialize",
78
+ tags: ["CROSS_REGION_PRESIGNED_URL"],
79
+ name: "crossRegionPresignedUrlMiddleware",
80
+ override: true,
81
+ relation: "after",
82
+ toMiddleware: "endpointV2Middleware",
119
83
  };
120
- var getCopySnapshotPresignedUrlPlugin = /* @__PURE__ */ __name((config) => ({
121
- applyToStack: /* @__PURE__ */ __name((clientStack) => {
122
- clientStack.add(copySnapshotPresignedUrlMiddleware(config), copySnapshotPresignedUrlMiddlewareOptions);
123
- }, "applyToStack")
124
- }), "getCopySnapshotPresignedUrlPlugin");
125
- // Annotate the CommonJS export names for ESM import in node:
126
-
127
- 0 && (module.exports = {
128
- copySnapshotPresignedUrlMiddlewareOptions,
129
- getCopySnapshotPresignedUrlPlugin,
130
- copySnapshotPresignedUrlMiddleware
84
+ const getCopySnapshotPresignedUrlPlugin = (config) => ({
85
+ applyToStack: (clientStack) => {
86
+ clientStack.add(copySnapshotPresignedUrlMiddleware(config), copySnapshotPresignedUrlMiddlewareOptions);
87
+ },
131
88
  });
132
89
 
90
+ exports.copySnapshotPresignedUrlMiddleware = copySnapshotPresignedUrlMiddleware;
91
+ exports.copySnapshotPresignedUrlMiddlewareOptions = copySnapshotPresignedUrlMiddlewareOptions;
92
+ exports.getCopySnapshotPresignedUrlPlugin = getCopySnapshotPresignedUrlPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-ec2",
3
- "version": "3.899.0",
3
+ "version": "3.908.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "node ../../scripts/compilation/inline middleware-sdk-ec2",
@@ -26,13 +26,13 @@
26
26
  },
27
27
  "license": "Apache-2.0",
28
28
  "dependencies": {
29
- "@aws-sdk/types": "3.893.0",
30
- "@aws-sdk/util-format-url": "3.893.0",
31
- "@smithy/middleware-endpoint": "^4.2.5",
32
- "@smithy/protocol-http": "^5.2.1",
33
- "@smithy/signature-v4": "^5.2.1",
34
- "@smithy/smithy-client": "^4.6.5",
35
- "@smithy/types": "^4.5.0",
29
+ "@aws-sdk/types": "3.901.0",
30
+ "@aws-sdk/util-format-url": "3.901.0",
31
+ "@smithy/middleware-endpoint": "^4.3.1",
32
+ "@smithy/protocol-http": "^5.3.0",
33
+ "@smithy/signature-v4": "^5.3.0",
34
+ "@smithy/smithy-client": "^4.7.1",
35
+ "@smithy/types": "^4.6.0",
36
36
  "tslib": "^2.6.2"
37
37
  },
38
38
  "engines": {