@aws-sdk/middleware-flexible-checksums 3.687.0 → 3.688.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.
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCrc32ChecksumAlgorithmFunction = void 0;
4
+ const crc32_1 = require("@aws-crypto/crc32");
5
+ const getCrc32ChecksumAlgorithmFunction = () => crc32_1.AwsCrc32;
6
+ exports.getCrc32ChecksumAlgorithmFunction = getCrc32ChecksumAlgorithmFunction;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCrc32ChecksumAlgorithmFunction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const crc32_1 = require("@aws-crypto/crc32");
6
+ const util_1 = require("@aws-crypto/util");
7
+ const zlib = tslib_1.__importStar(require("zlib"));
8
+ const getCrc32ChecksumAlgorithmFunction = () => {
9
+ if (typeof zlib.crc32 === "undefined") {
10
+ return crc32_1.AwsCrc32;
11
+ }
12
+ return class NodeCrc32 {
13
+ constructor() {
14
+ this.checksum = 0;
15
+ }
16
+ update(data) {
17
+ this.checksum = zlib.crc32(data, this.checksum);
18
+ }
19
+ async digest() {
20
+ return (0, util_1.numToUint8)(this.checksum);
21
+ }
22
+ reset() {
23
+ this.checksum = 0;
24
+ }
25
+ };
26
+ };
27
+ exports.getCrc32ChecksumAlgorithmFunction = getCrc32ChecksumAlgorithmFunction;
package/dist-cjs/index.js CHANGED
@@ -174,11 +174,11 @@ var import_is_array_buffer = require("@smithy/is-array-buffer");
174
174
  var isStreaming = /* @__PURE__ */ __name((body) => body !== void 0 && typeof body !== "string" && !ArrayBuffer.isView(body) && !(0, import_is_array_buffer.isArrayBuffer)(body), "isStreaming");
175
175
 
176
176
  // src/selectChecksumAlgorithmFunction.ts
177
- var import_crc32 = require("@aws-crypto/crc32");
178
177
  var import_crc32c = require("@aws-crypto/crc32c");
178
+ var import_getCrc32ChecksumAlgorithmFunction = require("././getCrc32ChecksumAlgorithmFunction");
179
179
  var selectChecksumAlgorithmFunction = /* @__PURE__ */ __name((checksumAlgorithm, config) => ({
180
180
  ["MD5" /* MD5 */]: config.md5,
181
- ["CRC32" /* CRC32 */]: import_crc32.AwsCrc32,
181
+ ["CRC32" /* CRC32 */]: (0, import_getCrc32ChecksumAlgorithmFunction.getCrc32ChecksumAlgorithmFunction)(),
182
182
  ["CRC32C" /* CRC32C */]: import_crc32c.AwsCrc32c,
183
183
  ["SHA1" /* SHA1 */]: config.sha1,
184
184
  ["SHA256" /* SHA256 */]: config.sha256
@@ -0,0 +1,2 @@
1
+ import { AwsCrc32 } from "@aws-crypto/crc32";
2
+ export const getCrc32ChecksumAlgorithmFunction = () => AwsCrc32;
@@ -0,0 +1,22 @@
1
+ import { AwsCrc32 } from "@aws-crypto/crc32";
2
+ import { numToUint8 } from "@aws-crypto/util";
3
+ import * as zlib from "zlib";
4
+ export const getCrc32ChecksumAlgorithmFunction = () => {
5
+ if (typeof zlib.crc32 === "undefined") {
6
+ return AwsCrc32;
7
+ }
8
+ return class NodeCrc32 {
9
+ constructor() {
10
+ this.checksum = 0;
11
+ }
12
+ update(data) {
13
+ this.checksum = zlib.crc32(data, this.checksum);
14
+ }
15
+ async digest() {
16
+ return numToUint8(this.checksum);
17
+ }
18
+ reset() {
19
+ this.checksum = 0;
20
+ }
21
+ };
22
+ };
@@ -1,9 +1,9 @@
1
- import { AwsCrc32 } from "@aws-crypto/crc32";
2
1
  import { AwsCrc32c } from "@aws-crypto/crc32c";
3
2
  import { ChecksumAlgorithm } from "./constants";
3
+ import { getCrc32ChecksumAlgorithmFunction } from "./getCrc32ChecksumAlgorithmFunction";
4
4
  export const selectChecksumAlgorithmFunction = (checksumAlgorithm, config) => ({
5
5
  [ChecksumAlgorithm.MD5]: config.md5,
6
- [ChecksumAlgorithm.CRC32]: AwsCrc32,
6
+ [ChecksumAlgorithm.CRC32]: getCrc32ChecksumAlgorithmFunction(),
7
7
  [ChecksumAlgorithm.CRC32C]: AwsCrc32c,
8
8
  [ChecksumAlgorithm.SHA1]: config.sha1,
9
9
  [ChecksumAlgorithm.SHA256]: config.sha256,
@@ -0,0 +1,2 @@
1
+ import { AwsCrc32 } from "@aws-crypto/crc32";
2
+ export declare const getCrc32ChecksumAlgorithmFunction: () => typeof AwsCrc32;
@@ -0,0 +1,9 @@
1
+ import { AwsCrc32 } from "@aws-crypto/crc32";
2
+ export declare const getCrc32ChecksumAlgorithmFunction: () => typeof AwsCrc32 | {
3
+ new (): {
4
+ checksum: number;
5
+ update(data: Uint8Array): void;
6
+ digest(): Promise<Uint8Array>;
7
+ reset(): void;
8
+ };
9
+ };
@@ -0,0 +1,2 @@
1
+ import { AwsCrc32 } from "@aws-crypto/crc32";
2
+ export declare const getCrc32ChecksumAlgorithmFunction: () => typeof AwsCrc32;
@@ -0,0 +1,11 @@
1
+ import { AwsCrc32 } from "@aws-crypto/crc32";
2
+ export declare const getCrc32ChecksumAlgorithmFunction: () =>
3
+ | typeof AwsCrc32
4
+ | {
5
+ new (): {
6
+ checksum: number;
7
+ update(data: Uint8Array): void;
8
+ digest(): Promise<Uint8Array>;
9
+ reset(): void;
10
+ };
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-flexible-checksums",
3
- "version": "3.687.0",
3
+ "version": "3.688.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 middleware-flexible-checksums",
@@ -17,10 +17,13 @@
17
17
  "main": "./dist-cjs/index.js",
18
18
  "module": "./dist-es/index.js",
19
19
  "browser": {
20
+ "./dist-es/getCrc32ChecksumAlgorithmFunction": "./dist-es/getCrc32ChecksumAlgorithmFunction.browser",
20
21
  "./dist-es/streams/create-read-stream-on-buffer": "./dist-es/streams/create-read-stream-on-buffer.browser"
21
22
  },
22
23
  "react-native": {
24
+ "./dist-es/getCrc32ChecksumAlgorithmFunction": "./dist-es/getCrc32ChecksumAlgorithmFunction.browser",
23
25
  "./dist-es/streams/create-read-stream-on-buffer": "./dist-es/streams/create-read-stream-on-buffer.browser",
26
+ "./dist-cjs/getCrc32ChecksumAlgorithmFunction": "./dist-cjs/getCrc32ChecksumAlgorithmFunction.browser",
24
27
  "./dist-cjs/streams/create-read-stream-on-buffer": "./dist-cjs/streams/create-read-stream-on-buffer.browser"
25
28
  },
26
29
  "types": "./dist-types/index.d.ts",
@@ -32,6 +35,7 @@
32
35
  "dependencies": {
33
36
  "@aws-crypto/crc32": "5.2.0",
34
37
  "@aws-crypto/crc32c": "5.2.0",
38
+ "@aws-crypto/util": "5.2.0",
35
39
  "@aws-sdk/core": "3.686.0",
36
40
  "@aws-sdk/types": "3.686.0",
37
41
  "@smithy/is-array-buffer": "^3.0.0",