@aws-sdk/checksums 3.1000.8 → 3.1000.9

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
@@ -2,7 +2,9 @@ const { setFeature } = require("@aws-sdk/core/client");
2
2
  const { HttpRequest } = require("@smithy/core/protocols");
3
3
  const { isArrayBuffer, toUint8Array, createBufferedReadable, createChecksumStream } = require("@smithy/core/serde");
4
4
  const { AwsCrc32c } = require("@aws-crypto/crc32c");
5
- const { getCrc32ChecksumAlgorithmFunction } = require("./flexible-checksums/getCrc32ChecksumAlgorithmFunction");
5
+ const { AwsCrc32 } = require("@aws-crypto/crc32");
6
+ const { numToUint8 } = require("@aws-crypto/util");
7
+ const zlib = require("node:zlib");
6
8
  const { normalizeProvider } = require("@smithy/core/client");
7
9
 
8
10
  const generateCRC64NVMETable = () => {
@@ -196,6 +198,25 @@ const hasHeaderWithPrefix = (headerPrefix, headers) => {
196
198
 
197
199
  const isStreaming = (body) => body !== undefined && typeof body !== "string" && !ArrayBuffer.isView(body) && !isArrayBuffer(body);
198
200
 
201
+ class NodeCrc32 {
202
+ checksum = 0;
203
+ update(data) {
204
+ this.checksum = zlib.crc32(data, this.checksum);
205
+ }
206
+ async digest() {
207
+ return numToUint8(this.checksum);
208
+ }
209
+ reset() {
210
+ this.checksum = 0;
211
+ }
212
+ }
213
+ const getCrc32ChecksumAlgorithmFunction = () => {
214
+ if (typeof zlib.crc32 === "undefined") {
215
+ return AwsCrc32;
216
+ }
217
+ return NodeCrc32;
218
+ };
219
+
199
220
  const CLIENT_SUPPORTED_ALGORITHMS = [
200
221
  ChecksumAlgorithm.CRC32,
201
222
  ChecksumAlgorithm.CRC32C,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/checksums",
3
- "version": "3.1000.8",
3
+ "version": "3.1000.9",
4
4
  "description": "Checksum algorithms and flexible checksums middleware for the AWS SDK",
5
5
  "scripts": {
6
6
  "build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
@@ -31,10 +31,10 @@
31
31
  "@aws-crypto/crc32": "5.2.0",
32
32
  "@aws-crypto/crc32c": "5.2.0",
33
33
  "@aws-crypto/util": "5.2.0",
34
- "@aws-sdk/core": "^3.974.23",
35
- "@aws-sdk/types": "^3.973.13",
36
- "@smithy/core": "^3.24.6",
37
- "@smithy/types": "^4.14.3",
34
+ "@aws-sdk/core": "^3.974.24",
35
+ "@aws-sdk/types": "^3.973.14",
36
+ "@smithy/core": "^3.27.0",
37
+ "@smithy/types": "^4.15.0",
38
38
  "tslib": "^2.6.2"
39
39
  },
40
40
  "devDependencies": {
@@ -61,8 +61,7 @@
61
61
  "./dist-es/flexible-checksums/getCrc32ChecksumAlgorithmFunction": "./dist-es/flexible-checksums/getCrc32ChecksumAlgorithmFunction.browser"
62
62
  },
63
63
  "react-native": {
64
- "./dist-es/flexible-checksums/getCrc32ChecksumAlgorithmFunction": "./dist-es/flexible-checksums/getCrc32ChecksumAlgorithmFunction.browser",
65
- "./dist-cjs/flexible-checksums/getCrc32ChecksumAlgorithmFunction": "./dist-cjs/flexible-checksums/getCrc32ChecksumAlgorithmFunction.browser"
64
+ "./dist-es/flexible-checksums/getCrc32ChecksumAlgorithmFunction": "./dist-es/flexible-checksums/getCrc32ChecksumAlgorithmFunction.browser"
66
65
  },
67
66
  "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages-internal/checksums",
68
67
  "repository": {
@@ -1,2 +0,0 @@
1
- const { AwsCrc32 } = require("@aws-crypto/crc32");
2
- exports.getCrc32ChecksumAlgorithmFunction = () => AwsCrc32;
@@ -1,21 +0,0 @@
1
- const { AwsCrc32 } = require("@aws-crypto/crc32");
2
- const { numToUint8 } = require("@aws-crypto/util");
3
- const zlib = require("node:zlib");
4
- class NodeCrc32 {
5
- checksum = 0;
6
- update(data) {
7
- this.checksum = zlib.crc32(data, this.checksum);
8
- }
9
- async digest() {
10
- return numToUint8(this.checksum);
11
- }
12
- reset() {
13
- this.checksum = 0;
14
- }
15
- }
16
- exports.getCrc32ChecksumAlgorithmFunction = () => {
17
- if (typeof zlib.crc32 === "undefined") {
18
- return AwsCrc32;
19
- }
20
- return NodeCrc32;
21
- };