@aws-sdk/body-checksum-node 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.
Files changed (2) hide show
  1. package/dist-cjs/index.js +29 -56
  2. package/package.json +5 -5
package/dist-cjs/index.js CHANGED
@@ -1,61 +1,34 @@
1
- "use strict";
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';
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
- const contentHash = new options.sha256();
35
- const treeHash = new import_sha256_tree_hash.TreeHash(options.sha256, options.utf8Decoder);
36
- const { body } = request;
37
- if (typeof body === "string" || ArrayBuffer.isView(body) || (0, import_is_array_buffer.isArrayBuffer)(body)) {
38
- contentHash?.update((0, import_util_utf8.toUint8Array)(body));
39
- treeHash?.update((0, import_util_utf8.toUint8Array)(body));
40
- } else {
41
- if (typeof body.path !== "string") {
42
- throw new Error("Unable to calculate checksums for non-file streams.");
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
- const bodyTee = (0, import_fs.createReadStream)(body.path, {
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.901.0",
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-node",
@@ -23,11 +23,11 @@
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.901.0",
27
- "@aws-sdk/types": "3.901.0",
26
+ "@aws-sdk/sha256-tree-hash": "3.914.0",
27
+ "@aws-sdk/types": "3.914.0",
28
28
  "@smithy/is-array-buffer": "^4.2.0",
29
- "@smithy/protocol-http": "^5.3.0",
30
- "@smithy/types": "^4.6.0",
29
+ "@smithy/protocol-http": "^5.3.3",
30
+ "@smithy/types": "^4.8.0",
31
31
  "@smithy/util-hex-encoding": "^4.2.0",
32
32
  "@smithy/util-utf8": "^4.2.0",
33
33
  "tslib": "^2.6.2"