@aws-sdk/body-checksum-browser 3.901.0 → 3.914.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 +27 -58
- package/package.json +5 -5
package/dist-cjs/index.js
CHANGED
|
@@ -1,63 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
20
2
|
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var import_sha256_tree_hash = require("@aws-sdk/sha256-tree-hash");
|
|
28
|
-
var import_chunked_blob_reader = require("@smithy/chunked-blob-reader");
|
|
29
|
-
var import_util_hex_encoding = require("@smithy/util-hex-encoding");
|
|
30
|
-
var import_util_utf8 = require("@smithy/util-utf8");
|
|
31
|
-
var MiB = 1024 * 1024;
|
|
3
|
+
var sha256TreeHash = require('@aws-sdk/sha256-tree-hash');
|
|
4
|
+
var chunkedBlobReader = require('@smithy/chunked-blob-reader');
|
|
5
|
+
var utilHexEncoding = require('@smithy/util-hex-encoding');
|
|
6
|
+
var utilUtf8 = require('@smithy/util-utf8');
|
|
7
|
+
|
|
8
|
+
const MiB = 1024 * 1024;
|
|
32
9
|
async function bodyChecksumGenerator(request, options) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
`Unable to calculate checksums for non-blob streams, received: ${body.constructor.name + ":" + Object.prototype.toString.call(body)}.`
|
|
52
|
-
);
|
|
10
|
+
const contentHash = new options.sha256();
|
|
11
|
+
const treeHash = new sha256TreeHash.TreeHash(options.sha256, options.utf8Decoder);
|
|
12
|
+
const { body } = request;
|
|
13
|
+
if (typeof body === "string") {
|
|
14
|
+
contentHash.update(utilUtf8.toUint8Array(body));
|
|
15
|
+
treeHash.update(body);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
if (Boolean(body) &&
|
|
19
|
+
(Object.prototype.toString.call(body) === "[object Blob]" || body.constructor?.name === "Blob")) {
|
|
20
|
+
await chunkedBlobReader.blobReader(body, (chunk) => {
|
|
21
|
+
treeHash?.update(chunk);
|
|
22
|
+
contentHash?.update(chunk);
|
|
23
|
+
}, MiB);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw new Error(`Unable to calculate checksums for non-blob streams, received: ${body.constructor.name + ":" + Object.prototype.toString.call(body)}.`);
|
|
27
|
+
}
|
|
53
28
|
}
|
|
54
|
-
|
|
55
|
-
return [(0, import_util_hex_encoding.toHex)(await contentHash.digest()), (0, import_util_hex_encoding.toHex)(await treeHash.digest())];
|
|
29
|
+
return [utilHexEncoding.toHex(await contentHash.digest()), utilHexEncoding.toHex(await treeHash.digest())];
|
|
56
30
|
}
|
|
57
|
-
__name(bodyChecksumGenerator, "bodyChecksumGenerator");
|
|
58
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
-
|
|
60
|
-
0 && (module.exports = {
|
|
61
|
-
bodyChecksumGenerator
|
|
62
|
-
});
|
|
63
31
|
|
|
32
|
+
exports.bodyChecksumGenerator = bodyChecksumGenerator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/body-checksum-browser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.914.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",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@aws-sdk/sha256-tree-hash": "3.
|
|
26
|
-
"@aws-sdk/types": "3.
|
|
25
|
+
"@aws-sdk/sha256-tree-hash": "3.914.0",
|
|
26
|
+
"@aws-sdk/types": "3.914.0",
|
|
27
27
|
"@smithy/chunked-blob-reader": "^5.2.0",
|
|
28
|
-
"@smithy/protocol-http": "^5.3.
|
|
29
|
-
"@smithy/types": "^4.
|
|
28
|
+
"@smithy/protocol-http": "^5.3.3",
|
|
29
|
+
"@smithy/types": "^4.8.0",
|
|
30
30
|
"@smithy/util-hex-encoding": "^4.2.0",
|
|
31
31
|
"@smithy/util-utf8": "^4.2.0",
|
|
32
32
|
"tslib": "^2.6.2"
|