@aws-sdk/body-checksum-node 3.186.0 → 3.188.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.
- package/CHANGELOG.md +8 -0
- package/dist-es/index.js +21 -39
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.188.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.187.0...v3.188.0) (2022-10-13)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-sdk/body-checksum-node
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [3.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @aws-sdk/body-checksum-node
|
package/dist-es/index.js
CHANGED
|
@@ -1,46 +1,28 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
1
|
import { streamReader } from "@aws-sdk/chunked-stream-reader-node";
|
|
3
2
|
import { isArrayBuffer } from "@aws-sdk/is-array-buffer";
|
|
4
3
|
import { TreeHash } from "@aws-sdk/sha256-tree-hash";
|
|
5
4
|
import { toHex } from "@aws-sdk/util-hex-encoding";
|
|
6
5
|
import { createReadStream } from "fs";
|
|
7
|
-
export function bodyChecksumGenerator(request, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
throw new Error("Unable to calculate checksums for non-file streams.");
|
|
23
|
-
}
|
|
24
|
-
bodyTee = createReadStream(body.path, {
|
|
25
|
-
start: body.start,
|
|
26
|
-
end: body.end,
|
|
27
|
-
});
|
|
28
|
-
return [4, streamReader(bodyTee, function (chunk) {
|
|
29
|
-
contentHash === null || contentHash === void 0 ? void 0 : contentHash.update(chunk);
|
|
30
|
-
treeHash === null || treeHash === void 0 ? void 0 : treeHash.update(chunk);
|
|
31
|
-
})];
|
|
32
|
-
case 2:
|
|
33
|
-
_d.sent();
|
|
34
|
-
_d.label = 3;
|
|
35
|
-
case 3:
|
|
36
|
-
_a = toHex;
|
|
37
|
-
return [4, contentHash.digest()];
|
|
38
|
-
case 4:
|
|
39
|
-
_b = [_a.apply(void 0, [_d.sent()])];
|
|
40
|
-
_c = toHex;
|
|
41
|
-
return [4, treeHash.digest()];
|
|
42
|
-
case 5: return [2, _b.concat([_c.apply(void 0, [_d.sent()])])];
|
|
43
|
-
}
|
|
6
|
+
export async function bodyChecksumGenerator(request, options) {
|
|
7
|
+
const contentHash = new options.sha256();
|
|
8
|
+
const treeHash = new TreeHash(options.sha256, options.utf8Decoder);
|
|
9
|
+
const { body } = request;
|
|
10
|
+
if (typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer(body)) {
|
|
11
|
+
contentHash?.update(body);
|
|
12
|
+
treeHash?.update(body);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
if (typeof body.path !== "string") {
|
|
16
|
+
throw new Error("Unable to calculate checksums for non-file streams.");
|
|
17
|
+
}
|
|
18
|
+
const bodyTee = createReadStream(body.path, {
|
|
19
|
+
start: body.start,
|
|
20
|
+
end: body.end,
|
|
44
21
|
});
|
|
45
|
-
|
|
22
|
+
await streamReader(bodyTee, (chunk) => {
|
|
23
|
+
contentHash?.update(chunk);
|
|
24
|
+
treeHash?.update(chunk);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return [toHex(await contentHash.digest()), toHex(await treeHash.digest())];
|
|
46
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/body-checksum-node",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.188.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
6
6
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/chunked-stream-reader-node": "3.
|
|
24
|
-
"@aws-sdk/is-array-buffer": "3.
|
|
25
|
-
"@aws-sdk/protocol-http": "3.
|
|
26
|
-
"@aws-sdk/sha256-tree-hash": "3.
|
|
27
|
-
"@aws-sdk/types": "3.
|
|
28
|
-
"@aws-sdk/util-hex-encoding": "3.
|
|
23
|
+
"@aws-sdk/chunked-stream-reader-node": "3.188.0",
|
|
24
|
+
"@aws-sdk/is-array-buffer": "3.188.0",
|
|
25
|
+
"@aws-sdk/protocol-http": "3.188.0",
|
|
26
|
+
"@aws-sdk/sha256-tree-hash": "3.188.0",
|
|
27
|
+
"@aws-sdk/types": "3.188.0",
|
|
28
|
+
"@aws-sdk/util-hex-encoding": "3.188.0",
|
|
29
29
|
"tslib": "^2.3.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@aws-crypto/sha256-js": "2.0.0",
|
|
33
|
-
"@aws-sdk/util-utf8-node": "3.
|
|
33
|
+
"@aws-sdk/util-utf8-node": "3.188.0",
|
|
34
34
|
"@tsconfig/recommended": "1.0.1",
|
|
35
35
|
"concurrently": "7.0.0",
|
|
36
36
|
"downlevel-dts": "0.10.1",
|