@aws-sdk/body-checksum-browser 3.972.18 → 3.972.20
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/dist-cjs/index.js +7 -9
- package/package.json +8 -8
package/dist-cjs/index.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var checksum = require('@smithy/core/checksum');
|
|
5
|
-
var serde = require('@smithy/core/serde');
|
|
1
|
+
const { TreeHash } = require("@aws-sdk/sha256-tree-hash");
|
|
2
|
+
const { blobReader } = require("@smithy/core/checksum");
|
|
3
|
+
const { toUint8Array, toHex } = require("@smithy/core/serde");
|
|
6
4
|
|
|
7
5
|
const MiB = 1024 * 1024;
|
|
8
6
|
async function bodyChecksumGenerator(request, options) {
|
|
9
7
|
const contentHash = new options.sha256();
|
|
10
|
-
const treeHash = new
|
|
8
|
+
const treeHash = new TreeHash(options.sha256, options.utf8Decoder);
|
|
11
9
|
const { body } = request;
|
|
12
10
|
if (typeof body === "string") {
|
|
13
|
-
contentHash.update(
|
|
11
|
+
contentHash.update(toUint8Array(body));
|
|
14
12
|
treeHash.update(body);
|
|
15
13
|
}
|
|
16
14
|
else {
|
|
17
15
|
if (Boolean(body) &&
|
|
18
16
|
(Object.prototype.toString.call(body) === "[object Blob]" || body.constructor?.name === "Blob")) {
|
|
19
|
-
await
|
|
17
|
+
await blobReader(body, (chunk) => {
|
|
20
18
|
treeHash?.update(chunk);
|
|
21
19
|
contentHash?.update(chunk);
|
|
22
20
|
}, MiB);
|
|
@@ -25,7 +23,7 @@ async function bodyChecksumGenerator(request, options) {
|
|
|
25
23
|
throw new Error(`Unable to calculate checksums for non-blob streams, received: ${body.constructor.name + ":" + Object.prototype.toString.call(body)}.`);
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
|
-
return [
|
|
26
|
+
return [toHex(await contentHash.digest()), toHex(await treeHash.digest())];
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
exports.bodyChecksumGenerator = bodyChecksumGenerator;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/body-checksum-browser",
|
|
3
|
-
"version": "3.972.
|
|
3
|
+
"version": "3.972.20",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
|
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline",
|
|
7
|
-
"build:es": "tsc -p tsconfig.es.json",
|
|
7
|
+
"build:es": "premove dist-es && tsc -p tsconfig.es.json",
|
|
8
8
|
"build:include:deps": "yarn g:turbo run build -F=\"$npm_package_name\"",
|
|
9
|
-
"build:types": "tsc -p tsconfig.types.json",
|
|
9
|
+
"build:types": "premove dist-types && tsc -p tsconfig.types.json",
|
|
10
10
|
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
|
|
11
|
-
"clean": "premove dist-cjs dist-es dist-types
|
|
11
|
+
"clean": "premove dist-cjs dist-es dist-types",
|
|
12
12
|
"test": "yarn g:vitest run",
|
|
13
13
|
"test:watch": "yarn g:vitest watch"
|
|
14
14
|
},
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@aws-sdk/sha256-tree-hash": "^3.972.
|
|
26
|
-
"@aws-sdk/types": "^3.973.
|
|
27
|
-
"@smithy/core": "^3.
|
|
28
|
-
"@smithy/types": "^4.
|
|
25
|
+
"@aws-sdk/sha256-tree-hash": "^3.972.18",
|
|
26
|
+
"@aws-sdk/types": "^3.973.14",
|
|
27
|
+
"@smithy/core": "^3.27.0",
|
|
28
|
+
"@smithy/types": "^4.15.0",
|
|
29
29
|
"tslib": "^2.6.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|