@aws-sdk/body-checksum-node 3.893.0 → 3.910.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 +29 -56
- package/package.json +8 -8
package/dist-cjs/index.js
CHANGED
|
@@ -1,61 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
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';
|
|
2
|
+
|
|
3
|
+
var chunkedStreamReaderNode = require('@aws-sdk/chunked-stream-reader-node');
|
|
4
|
+
var sha256TreeHash = require('@aws-sdk/sha256-tree-hash');
|
|
5
|
+
var isArrayBuffer = require('@smithy/is-array-buffer');
|
|
6
|
+
var utilHexEncoding = require('@smithy/util-hex-encoding');
|
|
7
|
+
var utilUtf8 = require('@smithy/util-utf8');
|
|
8
|
+
var fs = require('fs');
|
|
20
9
|
|
|
21
|
-
// src/index.ts
|
|
22
|
-
var index_exports = {};
|
|
23
|
-
__export(index_exports, {
|
|
24
|
-
bodyChecksumGenerator: () => bodyChecksumGenerator
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
var import_chunked_stream_reader_node = require("@aws-sdk/chunked-stream-reader-node");
|
|
28
|
-
var import_sha256_tree_hash = require("@aws-sdk/sha256-tree-hash");
|
|
29
|
-
var import_is_array_buffer = require("@smithy/is-array-buffer");
|
|
30
|
-
var import_util_hex_encoding = require("@smithy/util-hex-encoding");
|
|
31
|
-
var import_util_utf8 = require("@smithy/util-utf8");
|
|
32
|
-
var import_fs = require("fs");
|
|
33
10
|
async function bodyChecksumGenerator(request, options) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
11
|
+
const contentHash = new options.sha256();
|
|
12
|
+
const treeHash = new sha256TreeHash.TreeHash(options.sha256, options.utf8Decoder);
|
|
13
|
+
const { body } = request;
|
|
14
|
+
if (typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer.isArrayBuffer(body)) {
|
|
15
|
+
contentHash?.update(utilUtf8.toUint8Array(body));
|
|
16
|
+
treeHash?.update(utilUtf8.toUint8Array(body));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
if (typeof body.path !== "string") {
|
|
20
|
+
throw new Error("Unable to calculate checksums for non-file streams.");
|
|
21
|
+
}
|
|
22
|
+
const bodyTee = fs.createReadStream(body.path, {
|
|
23
|
+
start: body.start,
|
|
24
|
+
end: body.end,
|
|
25
|
+
});
|
|
26
|
+
await chunkedStreamReaderNode.streamReader(bodyTee, (chunk) => {
|
|
27
|
+
contentHash?.update(utilUtf8.toUint8Array(chunk));
|
|
28
|
+
treeHash?.update(utilUtf8.toUint8Array(chunk));
|
|
29
|
+
});
|
|
43
30
|
}
|
|
44
|
-
|
|
45
|
-
start: body.start,
|
|
46
|
-
end: body.end
|
|
47
|
-
});
|
|
48
|
-
await (0, import_chunked_stream_reader_node.streamReader)(bodyTee, (chunk) => {
|
|
49
|
-
contentHash?.update((0, import_util_utf8.toUint8Array)(chunk));
|
|
50
|
-
treeHash?.update((0, import_util_utf8.toUint8Array)(chunk));
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return [(0, import_util_hex_encoding.toHex)(await contentHash.digest()), (0, import_util_hex_encoding.toHex)(await treeHash.digest())];
|
|
31
|
+
return [utilHexEncoding.toHex(await contentHash.digest()), utilHexEncoding.toHex(await treeHash.digest())];
|
|
54
32
|
}
|
|
55
|
-
__name(bodyChecksumGenerator, "bodyChecksumGenerator");
|
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
-
|
|
58
|
-
0 && (module.exports = {
|
|
59
|
-
bodyChecksumGenerator
|
|
60
|
-
});
|
|
61
33
|
|
|
34
|
+
exports.bodyChecksumGenerator = bodyChecksumGenerator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/body-checksum-node",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.910.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-node",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@aws-sdk/chunked-stream-reader-node": "3.893.0",
|
|
26
|
-
"@aws-sdk/sha256-tree-hash": "3.
|
|
27
|
-
"@aws-sdk/types": "3.
|
|
28
|
-
"@smithy/is-array-buffer": "^4.
|
|
29
|
-
"@smithy/protocol-http": "^5.2
|
|
30
|
-
"@smithy/types": "^4.
|
|
31
|
-
"@smithy/util-hex-encoding": "^4.
|
|
32
|
-
"@smithy/util-utf8": "^4.
|
|
26
|
+
"@aws-sdk/sha256-tree-hash": "3.910.0",
|
|
27
|
+
"@aws-sdk/types": "3.910.0",
|
|
28
|
+
"@smithy/is-array-buffer": "^4.2.0",
|
|
29
|
+
"@smithy/protocol-http": "^5.3.2",
|
|
30
|
+
"@smithy/types": "^4.7.1",
|
|
31
|
+
"@smithy/util-hex-encoding": "^4.2.0",
|
|
32
|
+
"@smithy/util-utf8": "^4.2.0",
|
|
33
33
|
"tslib": "^2.6.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|