@aws-sdk/body-checksum-browser 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.
Files changed (2) hide show
  1. package/dist-cjs/index.js +27 -58
  2. package/package.json +8 -8
package/dist-cjs/index.js CHANGED
@@ -1,63 +1,32 @@
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';
20
2
 
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_sha256_tree_hash = require("@aws-sdk/sha256-tree-hash");
28
- var import_chunked_blob_reader = require("@smithy/chunked-blob-reader");
29
- var import_util_hex_encoding = require("@smithy/util-hex-encoding");
30
- var import_util_utf8 = require("@smithy/util-utf8");
31
- var MiB = 1024 * 1024;
3
+ var sha256TreeHash = require('@aws-sdk/sha256-tree-hash');
4
+ var chunkedBlobReader = require('@smithy/chunked-blob-reader');
5
+ var utilHexEncoding = require('@smithy/util-hex-encoding');
6
+ var utilUtf8 = require('@smithy/util-utf8');
7
+
8
+ const MiB = 1024 * 1024;
32
9
  async function bodyChecksumGenerator(request, options) {
33
- const contentHash = new options.sha256();
34
- const treeHash = new import_sha256_tree_hash.TreeHash(options.sha256, options.utf8Decoder);
35
- const { body } = request;
36
- if (typeof body === "string") {
37
- contentHash.update((0, import_util_utf8.toUint8Array)(body));
38
- treeHash.update(body);
39
- } else {
40
- if (Boolean(body) && (Object.prototype.toString.call(body) === "[object Blob]" || body.constructor?.name === "Blob")) {
41
- await (0, import_chunked_blob_reader.blobReader)(
42
- body,
43
- (chunk) => {
44
- treeHash?.update(chunk);
45
- contentHash?.update(chunk);
46
- },
47
- MiB
48
- );
49
- } else {
50
- throw new Error(
51
- `Unable to calculate checksums for non-blob streams, received: ${body.constructor.name + ":" + Object.prototype.toString.call(body)}.`
52
- );
10
+ const contentHash = new options.sha256();
11
+ const treeHash = new sha256TreeHash.TreeHash(options.sha256, options.utf8Decoder);
12
+ const { body } = request;
13
+ if (typeof body === "string") {
14
+ contentHash.update(utilUtf8.toUint8Array(body));
15
+ treeHash.update(body);
16
+ }
17
+ else {
18
+ if (Boolean(body) &&
19
+ (Object.prototype.toString.call(body) === "[object Blob]" || body.constructor?.name === "Blob")) {
20
+ await chunkedBlobReader.blobReader(body, (chunk) => {
21
+ treeHash?.update(chunk);
22
+ contentHash?.update(chunk);
23
+ }, MiB);
24
+ }
25
+ else {
26
+ throw new Error(`Unable to calculate checksums for non-blob streams, received: ${body.constructor.name + ":" + Object.prototype.toString.call(body)}.`);
27
+ }
53
28
  }
54
- }
55
- return [(0, import_util_hex_encoding.toHex)(await contentHash.digest()), (0, import_util_hex_encoding.toHex)(await treeHash.digest())];
29
+ return [utilHexEncoding.toHex(await contentHash.digest()), utilHexEncoding.toHex(await treeHash.digest())];
56
30
  }
57
- __name(bodyChecksumGenerator, "bodyChecksumGenerator");
58
- // Annotate the CommonJS export names for ESM import in node:
59
-
60
- 0 && (module.exports = {
61
- bodyChecksumGenerator
62
- });
63
31
 
32
+ exports.bodyChecksumGenerator = bodyChecksumGenerator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/body-checksum-browser",
3
- "version": "3.893.0",
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-browser",
@@ -22,13 +22,13 @@
22
22
  },
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@aws-sdk/sha256-tree-hash": "3.893.0",
26
- "@aws-sdk/types": "3.893.0",
27
- "@smithy/chunked-blob-reader": "^5.1.0",
28
- "@smithy/protocol-http": "^5.2.1",
29
- "@smithy/types": "^4.5.0",
30
- "@smithy/util-hex-encoding": "^4.1.0",
31
- "@smithy/util-utf8": "^4.1.0",
25
+ "@aws-sdk/sha256-tree-hash": "3.910.0",
26
+ "@aws-sdk/types": "3.910.0",
27
+ "@smithy/chunked-blob-reader": "^5.2.0",
28
+ "@smithy/protocol-http": "^5.3.2",
29
+ "@smithy/types": "^4.7.1",
30
+ "@smithy/util-hex-encoding": "^4.2.0",
31
+ "@smithy/util-utf8": "^4.2.0",
32
32
  "tslib": "^2.6.2"
33
33
  },
34
34
  "devDependencies": {