@aws-sdk/middleware-sdk-ec2 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,19 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.credentials = 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
- }
11
- exports.MockSha256 = MockSha256;
12
- const region = () => Promise.resolve("mock-region");
13
- exports.region = region;
14
- const credentials = () => Promise.resolve({
15
- accessKeyId: "akid",
16
- secretAccessKey: "secret",
17
- sessionToken: "session",
18
- });
19
- exports.credentials = credentials;
1
+ module.exports = require("./index.js");
package/dist-cjs/index.js CHANGED
@@ -1,91 +1,129 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCopySnapshotPresignedUrlPlugin = exports.copySnapshotPresignedUrlMiddlewareOptions = exports.copySnapshotPresignedUrlMiddleware = 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 smithy_client_1 = require("@smithy/smithy-client");
9
- const version = "2016-11-15";
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 });
9
+ };
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
+ copySnapshotPresignedUrlMiddleware: () => copySnapshotPresignedUrlMiddleware,
24
+ copySnapshotPresignedUrlMiddlewareOptions: () => copySnapshotPresignedUrlMiddlewareOptions,
25
+ getCopySnapshotPresignedUrlPlugin: () => getCopySnapshotPresignedUrlPlugin
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 import_smithy_client = require("@smithy/smithy-client");
33
+ var version = "2016-11-15";
10
34
  function copySnapshotPresignedUrlMiddleware(options) {
11
- return (next, context) => async (args) => {
12
- var _a, _b;
13
- const { input } = args;
14
- if (!input.PresignedUrl) {
15
- const destinationRegion = await options.region();
16
- const endpoint = await (0, middleware_endpoint_1.getEndpointFromInstructions)(input, {
17
- getEndpointParameterInstructions() {
18
- return {
19
- UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
20
- Endpoint: { type: "builtInParams", name: "endpoint" },
21
- Region: { type: "builtInParams", name: "region" },
22
- UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
23
- };
24
- },
25
- }, {
26
- ...options,
27
- region: input.SourceRegion,
28
- });
29
- const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : (0, middleware_endpoint_1.toEndpointV1)(endpoint);
30
- const requestToSign = new protocol_http_1.HttpRequest({
31
- ...resolvedEndpoint,
32
- protocol: "https",
33
- headers: {
34
- host: resolvedEndpoint.hostname,
35
- },
36
- query: {
37
- ...Object.entries(input).reduce((acc, [k, v]) => {
38
- acc[k] = String(v !== null && v !== void 0 ? v : "");
39
- return acc;
40
- }, {}),
41
- Action: "CopySnapshot",
42
- Version: version,
43
- DestinationRegion: destinationRegion,
44
- },
45
- });
46
- const signer = new signature_v4_1.SignatureV4({
47
- credentials: options.credentials,
48
- region: input.SourceRegion,
49
- service: "ec2",
50
- sha256: options.sha256,
51
- uriEscapePath: options.signingEscapePath,
52
- });
53
- const presignedRequest = await signer.presign(requestToSign, {
54
- expiresIn: 3600,
55
- });
56
- args = {
57
- ...args,
58
- input: {
59
- ...args.input,
60
- DestinationRegion: destinationRegion,
61
- PresignedUrl: (0, util_format_url_1.formatUrl)(presignedRequest),
62
- },
35
+ return (next, context) => async (args) => {
36
+ const { input } = args;
37
+ if (!input.PresignedUrl) {
38
+ const destinationRegion = await options.region();
39
+ const endpoint = await (0, import_middleware_endpoint.getEndpointFromInstructions)(
40
+ input,
41
+ {
42
+ /**
43
+ * Replication of {@link CopySnapshotCommand} in EC2.
44
+ * Not imported due to circular dependency.
45
+ */
46
+ getEndpointParameterInstructions() {
47
+ return {
48
+ UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
49
+ Endpoint: { type: "builtInParams", name: "endpoint" },
50
+ Region: { type: "builtInParams", name: "region" },
51
+ UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
63
52
  };
64
- if (protocol_http_1.HttpRequest.isInstance(args.request)) {
65
- const { request } = args;
66
- if (!((_a = request.body) !== null && _a !== void 0 ? _a : "").includes("DestinationRegion=")) {
67
- request.body += `&DestinationRegion=${destinationRegion}`;
68
- }
69
- if (!((_b = request.body) !== null && _b !== void 0 ? _b : "").includes("PresignedUrl=")) {
70
- request.body += `&PresignedUrl=${(0, smithy_client_1.extendedEncodeURIComponent)(args.input.PresignedUrl)}`;
71
- }
72
- }
53
+ }
54
+ },
55
+ {
56
+ ...options,
57
+ region: input.SourceRegion
58
+ }
59
+ );
60
+ const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : (0, import_middleware_endpoint.toEndpointV1)(endpoint);
61
+ const requestToSign = new import_protocol_http.HttpRequest({
62
+ ...resolvedEndpoint,
63
+ protocol: "https",
64
+ headers: {
65
+ host: resolvedEndpoint.hostname
66
+ },
67
+ query: {
68
+ // Values must be string instead of e.g. boolean
69
+ // because we need to sign the serialized form.
70
+ ...Object.entries(input).reduce((acc, [k, v]) => {
71
+ acc[k] = String(v ?? "");
72
+ return acc;
73
+ }, {}),
74
+ Action: "CopySnapshot",
75
+ Version: version,
76
+ DestinationRegion: destinationRegion
77
+ }
78
+ });
79
+ const signer = new import_signature_v4.SignatureV4({
80
+ credentials: options.credentials,
81
+ region: input.SourceRegion,
82
+ service: "ec2",
83
+ sha256: options.sha256,
84
+ uriEscapePath: options.signingEscapePath
85
+ });
86
+ const presignedRequest = await signer.presign(requestToSign, {
87
+ expiresIn: 3600
88
+ });
89
+ args = {
90
+ ...args,
91
+ input: {
92
+ ...args.input,
93
+ DestinationRegion: destinationRegion,
94
+ PresignedUrl: (0, import_util_format_url.formatUrl)(presignedRequest)
95
+ }
96
+ };
97
+ if (import_protocol_http.HttpRequest.isInstance(args.request)) {
98
+ const { request } = args;
99
+ if (!(request.body ?? "").includes("DestinationRegion=")) {
100
+ request.body += `&DestinationRegion=${destinationRegion}`;
101
+ }
102
+ if (!(request.body ?? "").includes("PresignedUrl=")) {
103
+ request.body += `&PresignedUrl=${(0, import_smithy_client.extendedEncodeURIComponent)(args.input.PresignedUrl)}`;
73
104
  }
74
- return next(args);
75
- };
105
+ }
106
+ }
107
+ return next(args);
108
+ };
76
109
  }
77
- exports.copySnapshotPresignedUrlMiddleware = copySnapshotPresignedUrlMiddleware;
78
- exports.copySnapshotPresignedUrlMiddlewareOptions = {
79
- step: "serialize",
80
- tags: ["CROSS_REGION_PRESIGNED_URL"],
81
- name: "crossRegionPresignedUrlMiddleware",
82
- override: true,
83
- relation: "after",
84
- toMiddleware: "endpointV2Middleware",
110
+ __name(copySnapshotPresignedUrlMiddleware, "copySnapshotPresignedUrlMiddleware");
111
+ var copySnapshotPresignedUrlMiddlewareOptions = {
112
+ step: "serialize",
113
+ tags: ["CROSS_REGION_PRESIGNED_URL"],
114
+ name: "crossRegionPresignedUrlMiddleware",
115
+ override: true,
116
+ relation: "after",
117
+ toMiddleware: "endpointV2Middleware"
85
118
  };
86
- const getCopySnapshotPresignedUrlPlugin = (config) => ({
87
- applyToStack: (clientStack) => {
88
- clientStack.add(copySnapshotPresignedUrlMiddleware(config), exports.copySnapshotPresignedUrlMiddlewareOptions);
89
- },
119
+ var getCopySnapshotPresignedUrlPlugin = /* @__PURE__ */ __name((config) => ({
120
+ applyToStack: (clientStack) => {
121
+ clientStack.add(copySnapshotPresignedUrlMiddleware(config), copySnapshotPresignedUrlMiddlewareOptions);
122
+ }
123
+ }), "getCopySnapshotPresignedUrlPlugin");
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ copySnapshotPresignedUrlMiddleware,
127
+ copySnapshotPresignedUrlMiddlewareOptions,
128
+ getCopySnapshotPresignedUrlPlugin
90
129
  });
91
- exports.getCopySnapshotPresignedUrlPlugin = getCopySnapshotPresignedUrlPlugin;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-ec2",
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-ec2",
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,13 +21,13 @@
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/smithy-client": "^2.2.1",
30
- "@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/smithy-client": "^2.3.0",
30
+ "@smithy/types": "^2.9.0",
31
31
  "tslib": "^2.5.0"
32
32
  },
33
33
  "engines": {