@aws-sdk/middleware-sdk-ec2
Advanced tools
Comparing version 3.489.0 to 3.495.0
@@ -1,19 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.credentials = exports.region = exports.MockSha256 = void 0; | ||
class MockSha256 { | ||
constructor(secret) { } | ||
update(data) { } | ||
digest() { | ||
return Promise.resolve(new Uint8Array(5)); | ||
} | ||
} | ||
exports.MockSha256 = MockSha256; | ||
const region = () => Promise.resolve("mock-region"); | ||
exports.region = region; | ||
const credentials = () => Promise.resolve({ | ||
accessKeyId: "akid", | ||
secretAccessKey: "secret", | ||
sessionToken: "session", | ||
}); | ||
exports.credentials = credentials; | ||
module.exports = require("./index.js"); |
@@ -1,91 +0,129 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getCopySnapshotPresignedUrlPlugin = exports.copySnapshotPresignedUrlMiddlewareOptions = exports.copySnapshotPresignedUrlMiddleware = void 0; | ||
const util_format_url_1 = require("@aws-sdk/util-format-url"); | ||
const middleware_endpoint_1 = require("@smithy/middleware-endpoint"); | ||
const protocol_http_1 = require("@smithy/protocol-http"); | ||
const signature_v4_1 = require("@smithy/signature-v4"); | ||
const smithy_client_1 = require("@smithy/smithy-client"); | ||
const version = "2016-11-15"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
copySnapshotPresignedUrlMiddleware: () => copySnapshotPresignedUrlMiddleware, | ||
copySnapshotPresignedUrlMiddlewareOptions: () => copySnapshotPresignedUrlMiddlewareOptions, | ||
getCopySnapshotPresignedUrlPlugin: () => getCopySnapshotPresignedUrlPlugin | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
var import_util_format_url = require("@aws-sdk/util-format-url"); | ||
var import_middleware_endpoint = require("@smithy/middleware-endpoint"); | ||
var import_protocol_http = require("@smithy/protocol-http"); | ||
var import_signature_v4 = require("@smithy/signature-v4"); | ||
var import_smithy_client = require("@smithy/smithy-client"); | ||
var version = "2016-11-15"; | ||
function copySnapshotPresignedUrlMiddleware(options) { | ||
return (next, context) => async (args) => { | ||
var _a, _b; | ||
const { input } = args; | ||
if (!input.PresignedUrl) { | ||
const destinationRegion = await options.region(); | ||
const endpoint = await (0, middleware_endpoint_1.getEndpointFromInstructions)(input, { | ||
getEndpointParameterInstructions() { | ||
return { | ||
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, | ||
Endpoint: { type: "builtInParams", name: "endpoint" }, | ||
Region: { type: "builtInParams", name: "region" }, | ||
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, | ||
}; | ||
}, | ||
}, { | ||
...options, | ||
region: input.SourceRegion, | ||
}); | ||
const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : (0, middleware_endpoint_1.toEndpointV1)(endpoint); | ||
const requestToSign = new protocol_http_1.HttpRequest({ | ||
...resolvedEndpoint, | ||
protocol: "https", | ||
headers: { | ||
host: resolvedEndpoint.hostname, | ||
}, | ||
query: { | ||
...Object.entries(input).reduce((acc, [k, v]) => { | ||
acc[k] = String(v !== null && v !== void 0 ? v : ""); | ||
return acc; | ||
}, {}), | ||
Action: "CopySnapshot", | ||
Version: version, | ||
DestinationRegion: destinationRegion, | ||
}, | ||
}); | ||
const signer = new signature_v4_1.SignatureV4({ | ||
credentials: options.credentials, | ||
region: input.SourceRegion, | ||
service: "ec2", | ||
sha256: options.sha256, | ||
uriEscapePath: options.signingEscapePath, | ||
}); | ||
const presignedRequest = await signer.presign(requestToSign, { | ||
expiresIn: 3600, | ||
}); | ||
args = { | ||
...args, | ||
input: { | ||
...args.input, | ||
DestinationRegion: destinationRegion, | ||
PresignedUrl: (0, util_format_url_1.formatUrl)(presignedRequest), | ||
}, | ||
return (next, context) => async (args) => { | ||
const { input } = args; | ||
if (!input.PresignedUrl) { | ||
const destinationRegion = await options.region(); | ||
const endpoint = await (0, import_middleware_endpoint.getEndpointFromInstructions)( | ||
input, | ||
{ | ||
/** | ||
* Replication of {@link CopySnapshotCommand} in EC2. | ||
* Not imported due to circular dependency. | ||
*/ | ||
getEndpointParameterInstructions() { | ||
return { | ||
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, | ||
Endpoint: { type: "builtInParams", name: "endpoint" }, | ||
Region: { type: "builtInParams", name: "region" }, | ||
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" } | ||
}; | ||
if (protocol_http_1.HttpRequest.isInstance(args.request)) { | ||
const { request } = args; | ||
if (!((_a = request.body) !== null && _a !== void 0 ? _a : "").includes("DestinationRegion=")) { | ||
request.body += `&DestinationRegion=${destinationRegion}`; | ||
} | ||
if (!((_b = request.body) !== null && _b !== void 0 ? _b : "").includes("PresignedUrl=")) { | ||
request.body += `&PresignedUrl=${(0, smithy_client_1.extendedEncodeURIComponent)(args.input.PresignedUrl)}`; | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
...options, | ||
region: input.SourceRegion | ||
} | ||
return next(args); | ||
}; | ||
); | ||
const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : (0, import_middleware_endpoint.toEndpointV1)(endpoint); | ||
const requestToSign = new import_protocol_http.HttpRequest({ | ||
...resolvedEndpoint, | ||
protocol: "https", | ||
headers: { | ||
host: resolvedEndpoint.hostname | ||
}, | ||
query: { | ||
// Values must be string instead of e.g. boolean | ||
// because we need to sign the serialized form. | ||
...Object.entries(input).reduce((acc, [k, v]) => { | ||
acc[k] = String(v ?? ""); | ||
return acc; | ||
}, {}), | ||
Action: "CopySnapshot", | ||
Version: version, | ||
DestinationRegion: destinationRegion | ||
} | ||
}); | ||
const signer = new import_signature_v4.SignatureV4({ | ||
credentials: options.credentials, | ||
region: input.SourceRegion, | ||
service: "ec2", | ||
sha256: options.sha256, | ||
uriEscapePath: options.signingEscapePath | ||
}); | ||
const presignedRequest = await signer.presign(requestToSign, { | ||
expiresIn: 3600 | ||
}); | ||
args = { | ||
...args, | ||
input: { | ||
...args.input, | ||
DestinationRegion: destinationRegion, | ||
PresignedUrl: (0, import_util_format_url.formatUrl)(presignedRequest) | ||
} | ||
}; | ||
if (import_protocol_http.HttpRequest.isInstance(args.request)) { | ||
const { request } = args; | ||
if (!(request.body ?? "").includes("DestinationRegion=")) { | ||
request.body += `&DestinationRegion=${destinationRegion}`; | ||
} | ||
if (!(request.body ?? "").includes("PresignedUrl=")) { | ||
request.body += `&PresignedUrl=${(0, import_smithy_client.extendedEncodeURIComponent)(args.input.PresignedUrl)}`; | ||
} | ||
} | ||
} | ||
return next(args); | ||
}; | ||
} | ||
exports.copySnapshotPresignedUrlMiddleware = copySnapshotPresignedUrlMiddleware; | ||
exports.copySnapshotPresignedUrlMiddlewareOptions = { | ||
step: "serialize", | ||
tags: ["CROSS_REGION_PRESIGNED_URL"], | ||
name: "crossRegionPresignedUrlMiddleware", | ||
override: true, | ||
relation: "after", | ||
toMiddleware: "endpointV2Middleware", | ||
__name(copySnapshotPresignedUrlMiddleware, "copySnapshotPresignedUrlMiddleware"); | ||
var copySnapshotPresignedUrlMiddlewareOptions = { | ||
step: "serialize", | ||
tags: ["CROSS_REGION_PRESIGNED_URL"], | ||
name: "crossRegionPresignedUrlMiddleware", | ||
override: true, | ||
relation: "after", | ||
toMiddleware: "endpointV2Middleware" | ||
}; | ||
const getCopySnapshotPresignedUrlPlugin = (config) => ({ | ||
applyToStack: (clientStack) => { | ||
clientStack.add(copySnapshotPresignedUrlMiddleware(config), exports.copySnapshotPresignedUrlMiddlewareOptions); | ||
}, | ||
var getCopySnapshotPresignedUrlPlugin = /* @__PURE__ */ __name((config) => ({ | ||
applyToStack: (clientStack) => { | ||
clientStack.add(copySnapshotPresignedUrlMiddleware(config), copySnapshotPresignedUrlMiddlewareOptions); | ||
} | ||
}), "getCopySnapshotPresignedUrlPlugin"); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
copySnapshotPresignedUrlMiddleware, | ||
copySnapshotPresignedUrlMiddlewareOptions, | ||
getCopySnapshotPresignedUrlPlugin | ||
}); | ||
exports.getCopySnapshotPresignedUrlPlugin = getCopySnapshotPresignedUrlPlugin; |
{ | ||
"name": "@aws-sdk/middleware-sdk-ec2", | ||
"version": "3.489.0", | ||
"version": "3.495.0", | ||
"scripts": { | ||
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", | ||
"build:cjs": "tsc -p tsconfig.cjs.json", | ||
"build:cjs": "node ../../scripts/compilation/inline middleware-sdk-ec2", | ||
"build:es": "tsc -p tsconfig.es.json", | ||
@@ -24,9 +24,9 @@ "build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build", | ||
"dependencies": { | ||
"@aws-sdk/types": "3.489.0", | ||
"@aws-sdk/util-format-url": "3.489.0", | ||
"@smithy/middleware-endpoint": "^2.3.0", | ||
"@smithy/protocol-http": "^3.0.12", | ||
"@smithy/signature-v4": "^2.0.0", | ||
"@smithy/smithy-client": "^2.2.1", | ||
"@smithy/types": "^2.8.0", | ||
"@aws-sdk/types": "3.495.0", | ||
"@aws-sdk/util-format-url": "3.495.0", | ||
"@smithy/middleware-endpoint": "^2.4.0", | ||
"@smithy/protocol-http": "^3.1.0", | ||
"@smithy/signature-v4": "^2.1.0", | ||
"@smithy/smithy-client": "^2.3.0", | ||
"@smithy/types": "^2.9.0", | ||
"tslib": "^2.5.0" | ||
@@ -33,0 +33,0 @@ }, |
25233
293
+ Added@aws-sdk/types@3.495.0(transitive)
+ Added@aws-sdk/util-format-url@3.495.0(transitive)
- Removed@aws-sdk/types@3.489.0(transitive)
- Removed@aws-sdk/util-format-url@3.489.0(transitive)
Updated@aws-sdk/types@3.495.0
Updated@smithy/protocol-http@^3.1.0
Updated@smithy/signature-v4@^2.1.0
Updated@smithy/smithy-client@^2.3.0
Updated@smithy/types@^2.9.0