@aws-sdk/body-checksum-browser 3.485.0 → 3.495.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 +55 -27
- package/package.json +9 -9
package/dist-cjs/index.js
CHANGED
|
@@ -1,30 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
bodyChecksumGenerator: () => bodyChecksumGenerator
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
var import_sha256_tree_hash = require("@aws-sdk/sha256-tree-hash");
|
|
27
|
+
var import_chunked_blob_reader = require("@smithy/chunked-blob-reader");
|
|
28
|
+
var import_util_hex_encoding = require("@smithy/util-hex-encoding");
|
|
29
|
+
var import_util_utf8 = require("@smithy/util-utf8");
|
|
30
|
+
var MiB = 1024 * 1024;
|
|
9
31
|
async function bodyChecksumGenerator(request, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
const contentHash = new options.sha256();
|
|
33
|
+
const treeHash = new import_sha256_tree_hash.TreeHash(options.sha256, options.utf8Decoder);
|
|
34
|
+
const { body } = request;
|
|
35
|
+
if (typeof body === "string") {
|
|
36
|
+
contentHash.update((0, import_util_utf8.toUint8Array)(body));
|
|
37
|
+
treeHash.update(body);
|
|
38
|
+
} else {
|
|
39
|
+
if (Boolean(body) && Object.prototype.toString.call(body) === "[object Blob]") {
|
|
40
|
+
await (0, import_chunked_blob_reader.blobReader)(
|
|
41
|
+
body,
|
|
42
|
+
(chunk) => {
|
|
43
|
+
treeHash == null ? void 0 : treeHash.update(chunk);
|
|
44
|
+
contentHash == null ? void 0 : contentHash.update(chunk);
|
|
45
|
+
},
|
|
46
|
+
MiB
|
|
47
|
+
);
|
|
48
|
+
} else {
|
|
49
|
+
throw new Error("Unable to calculate checksums for non-blob streams.");
|
|
16
50
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
await (0, chunked_blob_reader_1.blobReader)(body, (chunk) => {
|
|
20
|
-
treeHash === null || treeHash === void 0 ? void 0 : treeHash.update(chunk);
|
|
21
|
-
contentHash === null || contentHash === void 0 ? void 0 : contentHash.update(chunk);
|
|
22
|
-
}, MiB);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
throw new Error("Unable to calculate checksums for non-blob streams.");
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return [(0, util_hex_encoding_1.toHex)(await contentHash.digest()), (0, util_hex_encoding_1.toHex)(await treeHash.digest())];
|
|
51
|
+
}
|
|
52
|
+
return [(0, import_util_hex_encoding.toHex)(await contentHash.digest()), (0, import_util_hex_encoding.toHex)(await treeHash.digest())];
|
|
29
53
|
}
|
|
30
|
-
|
|
54
|
+
__name(bodyChecksumGenerator, "bodyChecksumGenerator");
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
bodyChecksumGenerator
|
|
58
|
+
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/body-checksum-browser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.495.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
6
|
-
"build:cjs": "
|
|
6
|
+
"build:cjs": "node ../../scripts/compilation/inline body-checksum-browser",
|
|
7
7
|
"build:es": "tsc -p tsconfig.es.json",
|
|
8
8
|
"build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build",
|
|
9
9
|
"build:types": "tsc -p tsconfig.types.json",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/sha256-tree-hash": "3.
|
|
24
|
-
"@aws-sdk/types": "3.
|
|
25
|
-
"@smithy/chunked-blob-reader": "^2.
|
|
26
|
-
"@smithy/protocol-http": "^3.0
|
|
27
|
-
"@smithy/types": "^2.
|
|
28
|
-
"@smithy/util-hex-encoding": "^2.
|
|
29
|
-
"@smithy/util-utf8": "^2.0
|
|
23
|
+
"@aws-sdk/sha256-tree-hash": "3.495.0",
|
|
24
|
+
"@aws-sdk/types": "3.495.0",
|
|
25
|
+
"@smithy/chunked-blob-reader": "^2.1.0",
|
|
26
|
+
"@smithy/protocol-http": "^3.1.0",
|
|
27
|
+
"@smithy/types": "^2.9.0",
|
|
28
|
+
"@smithy/util-hex-encoding": "^2.1.0",
|
|
29
|
+
"@smithy/util-utf8": "^2.1.0",
|
|
30
30
|
"tslib": "^2.5.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|