@aws-sdk/body-checksum-browser 3.667.0 → 3.679.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/dist-cjs/index.js +5 -2
- package/dist-es/index.js +3 -2
- package/package.json +6 -4
package/dist-cjs/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var import_util_hex_encoding = require("@smithy/util-hex-encoding");
|
|
|
30
30
|
var import_util_utf8 = require("@smithy/util-utf8");
|
|
31
31
|
var MiB = 1024 * 1024;
|
|
32
32
|
async function bodyChecksumGenerator(request, options) {
|
|
33
|
+
var _a;
|
|
33
34
|
const contentHash = new options.sha256();
|
|
34
35
|
const treeHash = new import_sha256_tree_hash.TreeHash(options.sha256, options.utf8Decoder);
|
|
35
36
|
const { body } = request;
|
|
@@ -37,7 +38,7 @@ async function bodyChecksumGenerator(request, options) {
|
|
|
37
38
|
contentHash.update((0, import_util_utf8.toUint8Array)(body));
|
|
38
39
|
treeHash.update(body);
|
|
39
40
|
} else {
|
|
40
|
-
if (Boolean(body) && Object.prototype.toString.call(body) === "[object Blob]") {
|
|
41
|
+
if (Boolean(body) && (Object.prototype.toString.call(body) === "[object Blob]" || ((_a = body.constructor) == null ? void 0 : _a.name) === "Blob")) {
|
|
41
42
|
await (0, import_chunked_blob_reader.blobReader)(
|
|
42
43
|
body,
|
|
43
44
|
(chunk) => {
|
|
@@ -47,7 +48,9 @@ async function bodyChecksumGenerator(request, options) {
|
|
|
47
48
|
MiB
|
|
48
49
|
);
|
|
49
50
|
} else {
|
|
50
|
-
throw new Error(
|
|
51
|
+
throw new Error(
|
|
52
|
+
`Unable to calculate checksums for non-blob streams, received: ${body.constructor.name + ":" + Object.prototype.toString.call(body)}.`
|
|
53
|
+
);
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
return [(0, import_util_hex_encoding.toHex)(await contentHash.digest()), (0, import_util_hex_encoding.toHex)(await treeHash.digest())];
|
package/dist-es/index.js
CHANGED
|
@@ -12,14 +12,15 @@ export async function bodyChecksumGenerator(request, options) {
|
|
|
12
12
|
treeHash.update(body);
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
|
-
if (Boolean(body) &&
|
|
15
|
+
if (Boolean(body) &&
|
|
16
|
+
(Object.prototype.toString.call(body) === "[object Blob]" || body.constructor?.name === "Blob")) {
|
|
16
17
|
await blobReader(body, (chunk) => {
|
|
17
18
|
treeHash?.update(chunk);
|
|
18
19
|
contentHash?.update(chunk);
|
|
19
20
|
}, MiB);
|
|
20
21
|
}
|
|
21
22
|
else {
|
|
22
|
-
throw new Error(
|
|
23
|
+
throw new Error(`Unable to calculate checksums for non-blob streams, received: ${body.constructor.name + ":" + Object.prototype.toString.call(body)}.`);
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
return [toHex(await contentHash.digest()), toHex(await treeHash.digest())];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/body-checksum-browser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.679.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline body-checksum-browser",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"build:types": "tsc -p tsconfig.types.json",
|
|
10
10
|
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
|
|
11
11
|
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
|
|
12
|
-
"test": "
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test:watch": "vitest watch"
|
|
13
14
|
},
|
|
14
15
|
"main": "./dist-cjs/index.js",
|
|
15
16
|
"module": "./dist-es/index.js",
|
|
@@ -20,8 +21,8 @@
|
|
|
20
21
|
},
|
|
21
22
|
"license": "Apache-2.0",
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/sha256-tree-hash": "3.
|
|
24
|
-
"@aws-sdk/types": "3.
|
|
24
|
+
"@aws-sdk/sha256-tree-hash": "3.679.0",
|
|
25
|
+
"@aws-sdk/types": "3.679.0",
|
|
25
26
|
"@smithy/chunked-blob-reader": "^3.0.0",
|
|
26
27
|
"@smithy/protocol-http": "^4.1.4",
|
|
27
28
|
"@smithy/types": "^3.5.0",
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"@tsconfig/recommended": "1.0.1",
|
|
35
36
|
"concurrently": "7.0.0",
|
|
36
37
|
"downlevel-dts": "0.10.1",
|
|
38
|
+
"happy-dom": "^15.7.4",
|
|
37
39
|
"rimraf": "3.0.2",
|
|
38
40
|
"typescript": "~4.9.5"
|
|
39
41
|
},
|