@aws-sdk/body-checksum-node 3.226.0 → 3.254.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 CHANGED
@@ -5,14 +5,15 @@ const chunked_stream_reader_node_1 = require("@aws-sdk/chunked-stream-reader-nod
5
5
  const is_array_buffer_1 = require("@aws-sdk/is-array-buffer");
6
6
  const sha256_tree_hash_1 = require("@aws-sdk/sha256-tree-hash");
7
7
  const util_hex_encoding_1 = require("@aws-sdk/util-hex-encoding");
8
+ const util_utf8_1 = require("@aws-sdk/util-utf8");
8
9
  const fs_1 = require("fs");
9
10
  async function bodyChecksumGenerator(request, options) {
10
11
  const contentHash = new options.sha256();
11
12
  const treeHash = new sha256_tree_hash_1.TreeHash(options.sha256, options.utf8Decoder);
12
13
  const { body } = request;
13
14
  if (typeof body === "string" || ArrayBuffer.isView(body) || (0, is_array_buffer_1.isArrayBuffer)(body)) {
14
- contentHash === null || contentHash === void 0 ? void 0 : contentHash.update(body);
15
- treeHash === null || treeHash === void 0 ? void 0 : treeHash.update(body);
15
+ contentHash === null || contentHash === void 0 ? void 0 : contentHash.update((0, util_utf8_1.toUint8Array)(body));
16
+ treeHash === null || treeHash === void 0 ? void 0 : treeHash.update((0, util_utf8_1.toUint8Array)(body));
16
17
  }
17
18
  else {
18
19
  if (typeof body.path !== "string") {
@@ -23,8 +24,8 @@ async function bodyChecksumGenerator(request, options) {
23
24
  end: body.end,
24
25
  });
25
26
  await (0, chunked_stream_reader_node_1.streamReader)(bodyTee, (chunk) => {
26
- contentHash === null || contentHash === void 0 ? void 0 : contentHash.update(chunk);
27
- treeHash === null || treeHash === void 0 ? void 0 : treeHash.update(chunk);
27
+ contentHash === null || contentHash === void 0 ? void 0 : contentHash.update((0, util_utf8_1.toUint8Array)(chunk));
28
+ treeHash === null || treeHash === void 0 ? void 0 : treeHash.update((0, util_utf8_1.toUint8Array)(chunk));
28
29
  });
29
30
  }
30
31
  return [(0, util_hex_encoding_1.toHex)(await contentHash.digest()), (0, util_hex_encoding_1.toHex)(await treeHash.digest())];
package/dist-es/index.js CHANGED
@@ -2,14 +2,15 @@ import { streamReader } from "@aws-sdk/chunked-stream-reader-node";
2
2
  import { isArrayBuffer } from "@aws-sdk/is-array-buffer";
3
3
  import { TreeHash } from "@aws-sdk/sha256-tree-hash";
4
4
  import { toHex } from "@aws-sdk/util-hex-encoding";
5
+ import { toUint8Array } from "@aws-sdk/util-utf8";
5
6
  import { createReadStream } from "fs";
6
7
  export async function bodyChecksumGenerator(request, options) {
7
8
  const contentHash = new options.sha256();
8
9
  const treeHash = new TreeHash(options.sha256, options.utf8Decoder);
9
10
  const { body } = request;
10
11
  if (typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer(body)) {
11
- contentHash?.update(body);
12
- treeHash?.update(body);
12
+ contentHash?.update(toUint8Array(body));
13
+ treeHash?.update(toUint8Array(body));
13
14
  }
14
15
  else {
15
16
  if (typeof body.path !== "string") {
@@ -20,8 +21,8 @@ export async function bodyChecksumGenerator(request, options) {
20
21
  end: body.end,
21
22
  });
22
23
  await streamReader(bodyTee, (chunk) => {
23
- contentHash?.update(chunk);
24
- treeHash?.update(chunk);
24
+ contentHash?.update(toUint8Array(chunk));
25
+ treeHash?.update(toUint8Array(chunk));
25
26
  });
26
27
  }
27
28
  return [toHex(await contentHash.digest()), toHex(await treeHash.digest())];
@@ -1,5 +1,5 @@
1
- import { Decoder, HashConstructor, HttpRequest } from "@aws-sdk/types";
1
+ import { ChecksumConstructor, Decoder, HashConstructor, HttpRequest } from "@aws-sdk/types";
2
2
  export declare function bodyChecksumGenerator(request: HttpRequest, options: {
3
- sha256: HashConstructor;
3
+ sha256: ChecksumConstructor | HashConstructor;
4
4
  utf8Decoder: Decoder;
5
5
  }): Promise<[string, string]>;
@@ -1,8 +1,13 @@
1
- import { Decoder, HashConstructor, HttpRequest } from "@aws-sdk/types";
1
+ import {
2
+ ChecksumConstructor,
3
+ Decoder,
4
+ HashConstructor,
5
+ HttpRequest,
6
+ } from "@aws-sdk/types";
2
7
  export declare function bodyChecksumGenerator(
3
8
  request: HttpRequest,
4
9
  options: {
5
- sha256: HashConstructor;
10
+ sha256: ChecksumConstructor | HashConstructor;
6
11
  utf8Decoder: Decoder;
7
12
  }
8
13
  ): Promise<[string, string]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/body-checksum-node",
3
- "version": "3.226.0",
3
+ "version": "3.254.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",
@@ -22,14 +22,15 @@
22
22
  "dependencies": {
23
23
  "@aws-sdk/chunked-stream-reader-node": "3.208.0",
24
24
  "@aws-sdk/is-array-buffer": "3.201.0",
25
- "@aws-sdk/protocol-http": "3.226.0",
26
- "@aws-sdk/sha256-tree-hash": "3.226.0",
27
- "@aws-sdk/types": "3.226.0",
25
+ "@aws-sdk/protocol-http": "3.254.0",
26
+ "@aws-sdk/sha256-tree-hash": "3.254.0",
27
+ "@aws-sdk/types": "3.254.0",
28
28
  "@aws-sdk/util-hex-encoding": "3.201.0",
29
+ "@aws-sdk/util-utf8": "3.254.0",
29
30
  "tslib": "^2.3.1"
30
31
  },
31
32
  "devDependencies": {
32
- "@aws-crypto/sha256-js": "2.0.0",
33
+ "@aws-crypto/sha256-js": "3.0.0",
33
34
  "@aws-sdk/util-utf8-node": "3.208.0",
34
35
  "@tsconfig/recommended": "1.0.1",
35
36
  "concurrently": "7.0.0",