@aws-sdk/middleware-flexible-checksums 3.687.0 → 3.689.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/getCrc32ChecksumAlgorithmFunction.browser.js +6 -0
- package/dist-cjs/getCrc32ChecksumAlgorithmFunction.js +28 -0
- package/dist-cjs/index.js +2 -2
- package/dist-es/getCrc32ChecksumAlgorithmFunction.browser.js +2 -0
- package/dist-es/getCrc32ChecksumAlgorithmFunction.js +23 -0
- package/dist-es/selectChecksumAlgorithmFunction.js +2 -2
- package/dist-types/getCrc32ChecksumAlgorithmFunction.browser.d.ts +2 -0
- package/dist-types/getCrc32ChecksumAlgorithmFunction.d.ts +10 -0
- package/dist-types/ts3.4/getCrc32ChecksumAlgorithmFunction.browser.d.ts +2 -0
- package/dist-types/ts3.4/getCrc32ChecksumAlgorithmFunction.d.ts +12 -0
- package/package.json +5 -1
|
@@ -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,28 @@
|
|
|
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
|
+
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 (0, util_1.numToUint8)(this.checksum);
|
|
17
|
+
}
|
|
18
|
+
reset() {
|
|
19
|
+
this.checksum = 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const getCrc32ChecksumAlgorithmFunction = () => {
|
|
23
|
+
if (typeof zlib.crc32 === "undefined") {
|
|
24
|
+
return crc32_1.AwsCrc32;
|
|
25
|
+
}
|
|
26
|
+
return NodeCrc32;
|
|
27
|
+
};
|
|
28
|
+
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 */]:
|
|
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,23 @@
|
|
|
1
|
+
import { AwsCrc32 } from "@aws-crypto/crc32";
|
|
2
|
+
import { numToUint8 } from "@aws-crypto/util";
|
|
3
|
+
import * as zlib from "zlib";
|
|
4
|
+
class NodeCrc32 {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.checksum = 0;
|
|
7
|
+
}
|
|
8
|
+
update(data) {
|
|
9
|
+
this.checksum = zlib.crc32(data, this.checksum);
|
|
10
|
+
}
|
|
11
|
+
async digest() {
|
|
12
|
+
return numToUint8(this.checksum);
|
|
13
|
+
}
|
|
14
|
+
reset() {
|
|
15
|
+
this.checksum = 0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export const getCrc32ChecksumAlgorithmFunction = () => {
|
|
19
|
+
if (typeof zlib.crc32 === "undefined") {
|
|
20
|
+
return AwsCrc32;
|
|
21
|
+
}
|
|
22
|
+
return NodeCrc32;
|
|
23
|
+
};
|
|
@@ -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]:
|
|
6
|
+
[ChecksumAlgorithm.CRC32]: getCrc32ChecksumAlgorithmFunction(),
|
|
7
7
|
[ChecksumAlgorithm.CRC32C]: AwsCrc32c,
|
|
8
8
|
[ChecksumAlgorithm.SHA1]: config.sha1,
|
|
9
9
|
[ChecksumAlgorithm.SHA256]: config.sha256,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AwsCrc32 } from "@aws-crypto/crc32";
|
|
2
|
+
import { Checksum } from "@smithy/types";
|
|
3
|
+
declare class NodeCrc32 implements Checksum {
|
|
4
|
+
private checksum;
|
|
5
|
+
update(data: Uint8Array): void;
|
|
6
|
+
digest(): Promise<Uint8Array>;
|
|
7
|
+
reset(): void;
|
|
8
|
+
}
|
|
9
|
+
export declare const getCrc32ChecksumAlgorithmFunction: () => typeof NodeCrc32 | typeof AwsCrc32;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AwsCrc32 } from "@aws-crypto/crc32";
|
|
2
|
+
import { Checksum } from "@smithy/types";
|
|
3
|
+
declare class NodeCrc32 implements Checksum {
|
|
4
|
+
private checksum;
|
|
5
|
+
update(data: Uint8Array): void;
|
|
6
|
+
digest(): Promise<Uint8Array>;
|
|
7
|
+
reset(): void;
|
|
8
|
+
}
|
|
9
|
+
export declare const getCrc32ChecksumAlgorithmFunction: () =>
|
|
10
|
+
| typeof NodeCrc32
|
|
11
|
+
| typeof AwsCrc32;
|
|
12
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-flexible-checksums",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.689.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",
|