@aws-sdk/body-checksum-browser 3.171.0 → 3.183.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 +16 -0
- package/dist-es/index.js +21 -36
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-sdk/body-checksum-browser
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @aws-sdk/body-checksum-browser
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [3.171.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.170.0...v3.171.0) (2022-09-14)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @aws-sdk/body-checksum-browser
|
package/dist-es/index.js
CHANGED
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
1
|
import { blobReader } from "@aws-sdk/chunked-blob-reader";
|
|
3
2
|
import { TreeHash } from "@aws-sdk/sha256-tree-hash";
|
|
4
3
|
import { toHex } from "@aws-sdk/util-hex-encoding";
|
|
5
|
-
|
|
6
|
-
export function bodyChecksumGenerator(request, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
_d.sent();
|
|
27
|
-
return [3, 4];
|
|
28
|
-
case 3: throw new Error("Unable to calculate checksums for non-blob streams.");
|
|
29
|
-
case 4:
|
|
30
|
-
_a = toHex;
|
|
31
|
-
return [4, contentHash.digest()];
|
|
32
|
-
case 5:
|
|
33
|
-
_b = [_a.apply(void 0, [_d.sent()])];
|
|
34
|
-
_c = toHex;
|
|
35
|
-
return [4, treeHash.digest()];
|
|
36
|
-
case 6: return [2, _b.concat([_c.apply(void 0, [_d.sent()])])];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
4
|
+
const MiB = 1024 * 1024;
|
|
5
|
+
export async function bodyChecksumGenerator(request, options) {
|
|
6
|
+
const contentHash = new options.sha256();
|
|
7
|
+
const treeHash = new TreeHash(options.sha256, options.utf8Decoder);
|
|
8
|
+
const { body } = request;
|
|
9
|
+
if (typeof body === "string") {
|
|
10
|
+
contentHash.update(body);
|
|
11
|
+
treeHash.update(body);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
if (Boolean(body) && Object.prototype.toString.call(body) === "[object Blob]") {
|
|
15
|
+
await blobReader(body, (chunk) => {
|
|
16
|
+
treeHash?.update(chunk);
|
|
17
|
+
contentHash?.update(chunk);
|
|
18
|
+
}, MiB);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
throw new Error("Unable to calculate checksums for non-blob streams.");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return [toHex(await contentHash.digest()), toHex(await treeHash.digest())];
|
|
40
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/body-checksum-browser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.183.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,16 +20,16 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/chunked-blob-reader": "3.
|
|
24
|
-
"@aws-sdk/protocol-http": "3.
|
|
25
|
-
"@aws-sdk/sha256-tree-hash": "3.
|
|
26
|
-
"@aws-sdk/types": "3.
|
|
27
|
-
"@aws-sdk/util-hex-encoding": "3.
|
|
23
|
+
"@aws-sdk/chunked-blob-reader": "3.183.0",
|
|
24
|
+
"@aws-sdk/protocol-http": "3.183.0",
|
|
25
|
+
"@aws-sdk/sha256-tree-hash": "3.183.0",
|
|
26
|
+
"@aws-sdk/types": "3.183.0",
|
|
27
|
+
"@aws-sdk/util-hex-encoding": "3.183.0",
|
|
28
28
|
"tslib": "^2.3.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@aws-crypto/sha256-js": "2.0.0",
|
|
32
|
-
"@aws-sdk/util-utf8-browser": "3.
|
|
32
|
+
"@aws-sdk/util-utf8-browser": "3.183.0",
|
|
33
33
|
"@tsconfig/recommended": "1.0.1",
|
|
34
34
|
"concurrently": "7.0.0",
|
|
35
35
|
"downlevel-dts": "0.10.1",
|