@aws-sdk/middleware-sdk-ec2
Advanced tools
Comparing version 3.178.0 to 3.183.0
@@ -6,2 +6,10 @@ # Change Log | ||
# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03) | ||
**Note:** Version bump only for package @aws-sdk/middleware-sdk-ec2 | ||
# [3.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23) | ||
@@ -8,0 +16,0 @@ |
@@ -1,25 +0,18 @@ | ||
var MockSha256 = (function () { | ||
function MockSha256(secret) { | ||
export class MockSha256 { | ||
constructor(secret) { } | ||
update(data) { } | ||
digest() { | ||
return Promise.resolve(new Uint8Array(5)); | ||
} | ||
MockSha256.prototype.update = function (data) { }; | ||
MockSha256.prototype.digest = function () { | ||
return Promise.resolve(new Uint8Array(5)); | ||
}; | ||
return MockSha256; | ||
}()); | ||
export { MockSha256 }; | ||
export var region = function () { return Promise.resolve("mock-region"); }; | ||
export var endpoint = function () { | ||
return Promise.resolve({ | ||
protocol: "https:", | ||
path: "/", | ||
hostname: "ec2.mock-region.amazonaws.com", | ||
}); | ||
}; | ||
export var credentials = function () { | ||
return Promise.resolve({ | ||
accessKeyId: "akid", | ||
secretAccessKey: "secret", | ||
sessionToken: "session", | ||
}); | ||
}; | ||
} | ||
export const region = () => Promise.resolve("mock-region"); | ||
export const endpoint = () => Promise.resolve({ | ||
protocol: "https:", | ||
path: "/", | ||
hostname: "ec2.mock-region.amazonaws.com", | ||
}); | ||
export const credentials = () => Promise.resolve({ | ||
accessKeyId: "akid", | ||
secretAccessKey: "secret", | ||
sessionToken: "session", | ||
}); |
@@ -1,62 +0,55 @@ | ||
import { __assign, __awaiter, __generator } from "tslib"; | ||
import { HttpRequest } from "@aws-sdk/protocol-http"; | ||
import { SignatureV4 } from "@aws-sdk/signature-v4"; | ||
import { formatUrl } from "@aws-sdk/util-format-url"; | ||
var version = "2016-11-15"; | ||
const version = "2016-11-15"; | ||
export function copySnapshotPresignedUrlMiddleware(options) { | ||
var _this = this; | ||
return function (next) { | ||
return function (args) { return __awaiter(_this, void 0, void 0, function () { | ||
var input, region, resolvedEndpoint, regionInfo, request, signer, presignedRequest; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = args.input; | ||
if (!!input.PresignedUrl) return [3, 7]; | ||
return [4, options.region()]; | ||
case 1: | ||
region = _a.sent(); | ||
return [4, options.endpoint()]; | ||
case 2: | ||
resolvedEndpoint = _a.sent(); | ||
if (!(typeof options.regionInfoProvider === "function")) return [3, 4]; | ||
return [4, options.regionInfoProvider(input.SourceRegion)]; | ||
case 3: | ||
regionInfo = _a.sent(); | ||
resolvedEndpoint.hostname = (regionInfo === null || regionInfo === void 0 ? void 0 : regionInfo.hostname) || "ec2.".concat(input.SourceRegion, ".amazonaws.com"); | ||
return [3, 5]; | ||
case 4: | ||
resolvedEndpoint.hostname = "ec2.".concat(input.SourceRegion, ".amazonaws.com"); | ||
_a.label = 5; | ||
case 5: | ||
request = new HttpRequest(__assign(__assign({}, resolvedEndpoint), { protocol: "https", headers: { | ||
host: resolvedEndpoint.hostname, | ||
}, query: { | ||
Action: "CopySnapshot", | ||
Version: version, | ||
SourceRegion: input.SourceRegion, | ||
SourceSnapshotId: input.SourceSnapshotId, | ||
DestinationRegion: region, | ||
} })); | ||
signer = new SignatureV4({ | ||
credentials: options.credentials, | ||
region: input.SourceRegion, | ||
service: "ec2", | ||
sha256: options.sha256, | ||
uriEscapePath: options.signingEscapePath, | ||
}); | ||
return [4, signer.presign(request, { | ||
expiresIn: 3600, | ||
})]; | ||
case 6: | ||
presignedRequest = _a.sent(); | ||
args = __assign(__assign({}, args), { input: __assign(__assign({}, args.input), { DestinationRegion: region, PresignedUrl: formatUrl(presignedRequest) }) }); | ||
_a.label = 7; | ||
case 7: return [2, next(args)]; | ||
} | ||
return (next) => async (args) => { | ||
const { input } = args; | ||
if (!input.PresignedUrl) { | ||
const region = await options.region(); | ||
const resolvedEndpoint = await options.endpoint(); | ||
if (typeof options.regionInfoProvider === "function") { | ||
const regionInfo = await options.regionInfoProvider(input.SourceRegion); | ||
resolvedEndpoint.hostname = regionInfo?.hostname || `ec2.${input.SourceRegion}.amazonaws.com`; | ||
} | ||
else { | ||
resolvedEndpoint.hostname = `ec2.${input.SourceRegion}.amazonaws.com`; | ||
} | ||
const request = new HttpRequest({ | ||
...resolvedEndpoint, | ||
protocol: "https", | ||
headers: { | ||
host: resolvedEndpoint.hostname, | ||
}, | ||
query: { | ||
Action: "CopySnapshot", | ||
Version: version, | ||
SourceRegion: input.SourceRegion, | ||
SourceSnapshotId: input.SourceSnapshotId, | ||
DestinationRegion: region, | ||
}, | ||
}); | ||
}); }; | ||
const signer = new SignatureV4({ | ||
credentials: options.credentials, | ||
region: input.SourceRegion, | ||
service: "ec2", | ||
sha256: options.sha256, | ||
uriEscapePath: options.signingEscapePath, | ||
}); | ||
const presignedRequest = await signer.presign(request, { | ||
expiresIn: 3600, | ||
}); | ||
args = { | ||
...args, | ||
input: { | ||
...args.input, | ||
DestinationRegion: region, | ||
PresignedUrl: formatUrl(presignedRequest), | ||
}, | ||
}; | ||
} | ||
return next(args); | ||
}; | ||
} | ||
export var copySnapshotPresignedUrlMiddlewareOptions = { | ||
export const copySnapshotPresignedUrlMiddlewareOptions = { | ||
step: "initialize", | ||
@@ -67,6 +60,6 @@ tags: ["CROSS_REGION_PRESIGNED_URL"], | ||
}; | ||
export var getCopySnapshotPresignedUrlPlugin = function (config) { return ({ | ||
applyToStack: function (clientStack) { | ||
export const getCopySnapshotPresignedUrlPlugin = (config) => ({ | ||
applyToStack: (clientStack) => { | ||
clientStack.add(copySnapshotPresignedUrlMiddleware(config), copySnapshotPresignedUrlMiddlewareOptions); | ||
}, | ||
}); }; | ||
}); |
{ | ||
"name": "@aws-sdk/middleware-sdk-ec2", | ||
"version": "3.178.0", | ||
"version": "3.183.0", | ||
"scripts": { | ||
@@ -23,6 +23,6 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", | ||
"dependencies": { | ||
"@aws-sdk/protocol-http": "3.178.0", | ||
"@aws-sdk/signature-v4": "3.178.0", | ||
"@aws-sdk/types": "3.178.0", | ||
"@aws-sdk/util-format-url": "3.178.0", | ||
"@aws-sdk/protocol-http": "3.183.0", | ||
"@aws-sdk/signature-v4": "3.183.0", | ||
"@aws-sdk/types": "3.183.0", | ||
"@aws-sdk/util-format-url": "3.183.0", | ||
"tslib": "^2.3.1" | ||
@@ -29,0 +29,0 @@ }, |
52622
250
+ Added@aws-sdk/is-array-buffer@3.183.0(transitive)
+ Added@aws-sdk/protocol-http@3.183.0(transitive)
+ Added@aws-sdk/querystring-builder@3.183.0(transitive)
+ Added@aws-sdk/signature-v4@3.183.0(transitive)
+ Added@aws-sdk/types@3.183.0(transitive)
+ Added@aws-sdk/util-format-url@3.183.0(transitive)
+ Added@aws-sdk/util-hex-encoding@3.183.0(transitive)
+ Added@aws-sdk/util-middleware@3.183.0(transitive)
+ Added@aws-sdk/util-uri-escape@3.183.0(transitive)
- Removed@aws-sdk/is-array-buffer@3.170.0(transitive)
- Removed@aws-sdk/protocol-http@3.178.0(transitive)
- Removed@aws-sdk/querystring-builder@3.178.0(transitive)
- Removed@aws-sdk/signature-v4@3.178.0(transitive)
- Removed@aws-sdk/types@3.178.0(transitive)
- Removed@aws-sdk/util-format-url@3.178.0(transitive)
- Removed@aws-sdk/util-hex-encoding@3.170.0(transitive)
- Removed@aws-sdk/util-middleware@3.178.0(transitive)
- Removed@aws-sdk/util-uri-escape@3.170.0(transitive)
Updated@aws-sdk/types@3.183.0