@aws-sdk/middleware-apply-body-checksum
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-apply-body-checksum | ||
# [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,42 +0,32 @@ | ||
import { __assign, __awaiter, __generator, __values } from "tslib"; | ||
import { isArrayBuffer } from "@aws-sdk/is-array-buffer"; | ||
import { HttpRequest } from "@aws-sdk/protocol-http"; | ||
export var applyMd5BodyChecksumMiddleware = function (options) { | ||
return function (next) { | ||
return function (args) { return __awaiter(void 0, void 0, void 0, function () { | ||
var request, body, headers, digest, hash, _a, _b, _c, _d, _e; | ||
var _f, _g; | ||
return __generator(this, function (_h) { | ||
switch (_h.label) { | ||
case 0: | ||
request = args.request; | ||
if (!HttpRequest.isInstance(request)) return [3, 2]; | ||
body = request.body, headers = request.headers; | ||
if (!!hasHeader("content-md5", headers)) return [3, 2]; | ||
digest = void 0; | ||
if (body === undefined || typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer(body)) { | ||
hash = new options.md5(); | ||
hash.update(body || ""); | ||
digest = hash.digest(); | ||
} | ||
else { | ||
digest = options.streamHasher(options.md5, body); | ||
} | ||
_a = [__assign({}, request)]; | ||
_f = {}; | ||
_b = [__assign({}, headers)]; | ||
_g = {}; | ||
_c = "content-md5"; | ||
_e = (_d = options).base64Encoder; | ||
return [4, digest]; | ||
case 1: | ||
request = __assign.apply(void 0, _a.concat([(_f.headers = __assign.apply(void 0, _b.concat([(_g[_c] = _e.apply(_d, [_h.sent()]), _g)])), _f)])); | ||
_h.label = 2; | ||
case 2: return [2, next(__assign(__assign({}, args), { request: request }))]; | ||
} | ||
}); | ||
}); }; | ||
}; | ||
export const applyMd5BodyChecksumMiddleware = (options) => (next) => async (args) => { | ||
let { request } = args; | ||
if (HttpRequest.isInstance(request)) { | ||
const { body, headers } = request; | ||
if (!hasHeader("content-md5", headers)) { | ||
let digest; | ||
if (body === undefined || typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer(body)) { | ||
const hash = new options.md5(); | ||
hash.update(body || ""); | ||
digest = hash.digest(); | ||
} | ||
else { | ||
digest = options.streamHasher(options.md5, body); | ||
} | ||
request = { | ||
...request, | ||
headers: { | ||
...headers, | ||
"content-md5": options.base64Encoder(await digest), | ||
}, | ||
}; | ||
} | ||
} | ||
return next({ | ||
...args, | ||
request, | ||
}); | ||
}; | ||
export var applyMd5BodyChecksumMiddlewareOptions = { | ||
export const applyMd5BodyChecksumMiddlewareOptions = { | ||
name: "applyMd5BodyChecksumMiddleware", | ||
@@ -47,26 +37,15 @@ step: "build", | ||
}; | ||
export var getApplyMd5BodyChecksumPlugin = function (config) { return ({ | ||
applyToStack: function (clientStack) { | ||
export const getApplyMd5BodyChecksumPlugin = (config) => ({ | ||
applyToStack: (clientStack) => { | ||
clientStack.add(applyMd5BodyChecksumMiddleware(config), applyMd5BodyChecksumMiddlewareOptions); | ||
}, | ||
}); }; | ||
var hasHeader = function (soughtHeader, headers) { | ||
var e_1, _a; | ||
}); | ||
const hasHeader = (soughtHeader, headers) => { | ||
soughtHeader = soughtHeader.toLowerCase(); | ||
try { | ||
for (var _b = __values(Object.keys(headers)), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var headerName = _c.value; | ||
if (soughtHeader === headerName.toLowerCase()) { | ||
return true; | ||
} | ||
for (const headerName of Object.keys(headers)) { | ||
if (soughtHeader === headerName.toLowerCase()) { | ||
return true; | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return false; | ||
}; |
@@ -1,1 +0,1 @@ | ||
export var resolveMd5BodyChecksumConfig = function (input) { return input; }; | ||
export const resolveMd5BodyChecksumConfig = (input) => input; |
{ | ||
"name": "@aws-sdk/middleware-apply-body-checksum", | ||
"version": "3.178.0", | ||
"version": "3.183.0", | ||
"scripts": { | ||
@@ -23,5 +23,5 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", | ||
"dependencies": { | ||
"@aws-sdk/is-array-buffer": "3.170.0", | ||
"@aws-sdk/protocol-http": "3.178.0", | ||
"@aws-sdk/types": "3.178.0", | ||
"@aws-sdk/is-array-buffer": "3.183.0", | ||
"@aws-sdk/protocol-http": "3.183.0", | ||
"@aws-sdk/types": "3.183.0", | ||
"tslib": "^2.3.1" | ||
@@ -28,0 +28,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51642
183
+ Added@aws-sdk/is-array-buffer@3.183.0(transitive)
+ Added@aws-sdk/protocol-http@3.183.0(transitive)
+ Added@aws-sdk/types@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/types@3.178.0(transitive)
Updated@aws-sdk/types@3.183.0