@aws-sdk/body-checksum-node
Advanced tools
Comparing version 3.183.0 to 3.186.0
@@ -6,2 +6,10 @@ # Change Log | ||
# [3.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06) | ||
**Note:** Version bump only for package @aws-sdk/body-checksum-node | ||
# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03) | ||
@@ -8,0 +16,0 @@ |
@@ -0,1 +1,2 @@ | ||
import { __awaiter, __generator } from "tslib"; | ||
import { streamReader } from "@aws-sdk/chunked-stream-reader-node"; | ||
@@ -6,24 +7,41 @@ import { isArrayBuffer } from "@aws-sdk/is-array-buffer"; | ||
import { createReadStream } from "fs"; | ||
export async function bodyChecksumGenerator(request, options) { | ||
const contentHash = new options.sha256(); | ||
const treeHash = new TreeHash(options.sha256, options.utf8Decoder); | ||
const { body } = request; | ||
if (typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer(body)) { | ||
contentHash?.update(body); | ||
treeHash?.update(body); | ||
} | ||
else { | ||
if (typeof body.path !== "string") { | ||
throw new Error("Unable to calculate checksums for non-file streams."); | ||
} | ||
const bodyTee = createReadStream(body.path, { | ||
start: body.start, | ||
end: body.end, | ||
export function bodyChecksumGenerator(request, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var contentHash, treeHash, body, bodyTee, _a, _b, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
contentHash = new options.sha256(); | ||
treeHash = new TreeHash(options.sha256, options.utf8Decoder); | ||
body = request.body; | ||
if (!(typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer(body))) return [3, 1]; | ||
contentHash === null || contentHash === void 0 ? void 0 : contentHash.update(body); | ||
treeHash === null || treeHash === void 0 ? void 0 : treeHash.update(body); | ||
return [3, 3]; | ||
case 1: | ||
if (typeof body.path !== "string") { | ||
throw new Error("Unable to calculate checksums for non-file streams."); | ||
} | ||
bodyTee = createReadStream(body.path, { | ||
start: body.start, | ||
end: body.end, | ||
}); | ||
return [4, streamReader(bodyTee, function (chunk) { | ||
contentHash === null || contentHash === void 0 ? void 0 : contentHash.update(chunk); | ||
treeHash === null || treeHash === void 0 ? void 0 : treeHash.update(chunk); | ||
})]; | ||
case 2: | ||
_d.sent(); | ||
_d.label = 3; | ||
case 3: | ||
_a = toHex; | ||
return [4, contentHash.digest()]; | ||
case 4: | ||
_b = [_a.apply(void 0, [_d.sent()])]; | ||
_c = toHex; | ||
return [4, treeHash.digest()]; | ||
case 5: return [2, _b.concat([_c.apply(void 0, [_d.sent()])])]; | ||
} | ||
}); | ||
await streamReader(bodyTee, (chunk) => { | ||
contentHash?.update(chunk); | ||
treeHash?.update(chunk); | ||
}); | ||
} | ||
return [toHex(await contentHash.digest()), toHex(await treeHash.digest())]; | ||
}); | ||
} |
{ | ||
"name": "@aws-sdk/body-checksum-node", | ||
"version": "3.183.0", | ||
"version": "3.186.0", | ||
"scripts": { | ||
@@ -23,8 +23,8 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", | ||
"dependencies": { | ||
"@aws-sdk/chunked-stream-reader-node": "3.183.0", | ||
"@aws-sdk/is-array-buffer": "3.183.0", | ||
"@aws-sdk/protocol-http": "3.183.0", | ||
"@aws-sdk/sha256-tree-hash": "3.183.0", | ||
"@aws-sdk/types": "3.183.0", | ||
"@aws-sdk/util-hex-encoding": "3.183.0", | ||
"@aws-sdk/chunked-stream-reader-node": "3.186.0", | ||
"@aws-sdk/is-array-buffer": "3.186.0", | ||
"@aws-sdk/protocol-http": "3.186.0", | ||
"@aws-sdk/sha256-tree-hash": "3.186.0", | ||
"@aws-sdk/types": "3.186.0", | ||
"@aws-sdk/util-hex-encoding": "3.186.0", | ||
"tslib": "^2.3.1" | ||
@@ -34,3 +34,3 @@ }, | ||
"@aws-crypto/sha256-js": "2.0.0", | ||
"@aws-sdk/util-utf8-node": "3.183.0", | ||
"@aws-sdk/util-utf8-node": "3.186.0", | ||
"@tsconfig/recommended": "1.0.1", | ||
@@ -37,0 +37,0 @@ "concurrently": "7.0.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
40262
91
+ Added@aws-sdk/chunked-stream-reader-node@3.186.0(transitive)
+ Added@aws-sdk/is-array-buffer@3.186.0(transitive)
+ Added@aws-sdk/protocol-http@3.186.0(transitive)
+ Added@aws-sdk/sha256-tree-hash@3.186.0(transitive)
+ Added@aws-sdk/types@3.186.0(transitive)
+ Added@aws-sdk/util-hex-encoding@3.186.0(transitive)
- Removed@aws-sdk/chunked-stream-reader-node@3.183.0(transitive)
- Removed@aws-sdk/is-array-buffer@3.183.0(transitive)
- Removed@aws-sdk/protocol-http@3.183.0(transitive)
- Removed@aws-sdk/sha256-tree-hash@3.183.0(transitive)
- Removed@aws-sdk/types@3.183.0(transitive)
- Removed@aws-sdk/util-hex-encoding@3.183.0(transitive)
Updated@aws-sdk/types@3.186.0