@aws-sdk/body-checksum-node 3.972.18 → 3.972.19

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 +13 -15
  2. package/package.json +7 -7
package/dist-cjs/index.js CHANGED
@@ -1,32 +1,30 @@
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 serde = require('@smithy/core/serde');
6
- var node_fs = require('node:fs');
1
+ const { streamReader } = require("@aws-sdk/chunked-stream-reader-node");
2
+ const { TreeHash } = require("@aws-sdk/sha256-tree-hash");
3
+ const { isArrayBuffer, toUint8Array, toHex } = require("@smithy/core/serde");
4
+ const { createReadStream } = require("node:fs");
7
5
 
8
6
  async function bodyChecksumGenerator(request, options) {
9
7
  const contentHash = new options.sha256();
10
- const treeHash = new sha256TreeHash.TreeHash(options.sha256, options.utf8Decoder);
8
+ const treeHash = new TreeHash(options.sha256, options.utf8Decoder);
11
9
  const { body } = request;
12
- if (typeof body === "string" || ArrayBuffer.isView(body) || serde.isArrayBuffer(body)) {
13
- contentHash?.update(serde.toUint8Array(body));
14
- treeHash?.update(serde.toUint8Array(body));
10
+ if (typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer(body)) {
11
+ contentHash?.update(toUint8Array(body));
12
+ treeHash?.update(toUint8Array(body));
15
13
  }
16
14
  else {
17
15
  if (typeof body.path !== "string") {
18
16
  throw new Error("Unable to calculate checksums for non-file streams.");
19
17
  }
20
- const bodyTee = node_fs.createReadStream(body.path, {
18
+ const bodyTee = createReadStream(body.path, {
21
19
  start: body.start,
22
20
  end: body.end,
23
21
  });
24
- await chunkedStreamReaderNode.streamReader(bodyTee, (chunk) => {
25
- contentHash?.update(serde.toUint8Array(chunk));
26
- treeHash?.update(serde.toUint8Array(chunk));
22
+ await streamReader(bodyTee, (chunk) => {
23
+ contentHash?.update(toUint8Array(chunk));
24
+ treeHash?.update(toUint8Array(chunk));
27
25
  });
28
26
  }
29
- return [serde.toHex(await contentHash.digest()), serde.toHex(await treeHash.digest())];
27
+ return [toHex(await contentHash.digest()), toHex(await treeHash.digest())];
30
28
  }
31
29
 
32
30
  exports.bodyChecksumGenerator = bodyChecksumGenerator;
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@aws-sdk/body-checksum-node",
3
- "version": "3.972.18",
3
+ "version": "3.972.19",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
6
6
  "build:cjs": "node ../../scripts/compilation/inline",
7
- "build:es": "tsc -p tsconfig.es.json",
7
+ "build:es": "premove dist-es && tsc -p tsconfig.es.json",
8
8
  "build:include:deps": "yarn g:turbo run build -F=\"$npm_package_name\"",
9
- "build:types": "tsc -p tsconfig.types.json",
9
+ "build:types": "premove dist-types && tsc -p tsconfig.types.json",
10
10
  "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
11
- "clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
11
+ "clean": "premove dist-cjs dist-es dist-types",
12
12
  "test": "yarn g:vitest run",
13
13
  "test:watch": "yarn g:vitest watch"
14
14
  },
@@ -22,9 +22,9 @@
22
22
  },
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@aws-sdk/chunked-stream-reader-node": "^3.972.7",
26
- "@aws-sdk/sha256-tree-hash": "^3.972.16",
27
- "@aws-sdk/types": "^3.973.12",
25
+ "@aws-sdk/chunked-stream-reader-node": "^3.972.8",
26
+ "@aws-sdk/sha256-tree-hash": "^3.972.17",
27
+ "@aws-sdk/types": "^3.973.13",
28
28
  "@smithy/core": "^3.24.6",
29
29
  "@smithy/types": "^4.14.3",
30
30
  "tslib": "^2.6.2"