@loaders.gl/crypto 4.0.0-alpha.4 → 4.0.0-alpha.6
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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2 -2
- package/dist/crypto-worker.js +2 -0
- package/dist/crypto-worker.js.map +7 -0
- package/dist/dist.min.js +2 -2
- package/dist/dist.min.js.map +7 -1
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/index.js +83 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/algorithms/crc32.js +41 -0
- package/dist/es5/lib/algorithms/crc32.js.map +1 -0
- package/dist/es5/lib/algorithms/crc32c.js +44 -0
- package/dist/es5/lib/algorithms/crc32c.js.map +1 -0
- package/dist/es5/lib/algorithms/md5-wasm.js +436 -0
- package/dist/es5/lib/algorithms/md5-wasm.js.map +1 -0
- package/dist/es5/lib/crc32-hash.js +150 -0
- package/dist/es5/lib/crc32-hash.js.map +1 -0
- package/dist/es5/lib/crc32c-hash.js +149 -0
- package/dist/es5/lib/crc32c-hash.js.map +1 -0
- package/dist/es5/lib/crypto-hash.js +186 -0
- package/dist/es5/lib/crypto-hash.js.map +1 -0
- package/dist/es5/lib/hash.js +149 -0
- package/dist/es5/lib/hash.js.map +1 -0
- package/dist/es5/lib/md5-hash.js +66 -0
- package/dist/es5/lib/md5-hash.js.map +1 -0
- package/dist/es5/lib/node-hash.js +147 -0
- package/dist/es5/lib/node-hash.js.map +1 -0
- package/dist/es5/lib/sha256-hash.js +33 -0
- package/dist/es5/lib/sha256-hash.js.map +1 -0
- package/dist/es5/lib/utils/base64-utils.js +55 -0
- package/dist/es5/lib/utils/base64-utils.js.map +1 -0
- package/dist/es5/lib/utils/digest-utils.js +23 -0
- package/dist/es5/lib/utils/digest-utils.js.map +1 -0
- package/dist/es5/types.js +2 -0
- package/dist/es5/types.js.map +1 -0
- package/dist/es5/workers/worker.js +65 -0
- package/dist/es5/workers/worker.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/index.js +27 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/algorithms/crc32.js +24 -0
- package/dist/esm/lib/algorithms/crc32.js.map +1 -0
- package/dist/esm/lib/algorithms/crc32c.js +27 -0
- package/dist/esm/lib/algorithms/crc32c.js.map +1 -0
- package/dist/esm/lib/algorithms/md5-wasm.js +428 -0
- package/dist/esm/lib/algorithms/md5-wasm.js.map +1 -0
- package/dist/esm/lib/crc32-hash.js +43 -0
- package/dist/esm/lib/crc32-hash.js.map +1 -0
- package/dist/esm/lib/crc32c-hash.js +42 -0
- package/dist/esm/lib/crc32c-hash.js.map +1 -0
- package/dist/esm/lib/crypto-hash.js +54 -0
- package/dist/esm/lib/crypto-hash.js.map +1 -0
- package/dist/esm/lib/hash.js +30 -0
- package/dist/esm/lib/hash.js.map +1 -0
- package/dist/esm/lib/md5-hash.js +19 -0
- package/dist/esm/lib/md5-hash.js.map +1 -0
- package/dist/esm/lib/node-hash.js +38 -0
- package/dist/esm/lib/node-hash.js.map +1 -0
- package/dist/esm/lib/sha256-hash.js +13 -0
- package/dist/esm/lib/sha256-hash.js.map +1 -0
- package/dist/esm/lib/utils/base64-utils.js +49 -0
- package/dist/esm/lib/utils/base64-utils.js.map +1 -0
- package/dist/esm/lib/utils/digest-utils.js +14 -0
- package/dist/esm/lib/utils/digest-utils.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/workers/cryptojs-worker.ts.disabled +26 -0
- package/dist/esm/workers/worker.js +22 -0
- package/dist/esm/workers/worker.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -25
- package/dist/lib/algorithms/crc32.d.ts +10 -0
- package/dist/lib/algorithms/crc32.d.ts.map +1 -0
- package/dist/lib/algorithms/crc32.js +25 -23
- package/dist/lib/algorithms/crc32c.d.ts +11 -0
- package/dist/lib/algorithms/crc32c.d.ts.map +1 -0
- package/dist/lib/algorithms/crc32c.js +33 -24
- package/dist/lib/algorithms/md5-wasm.d.ts +2 -0
- package/dist/lib/algorithms/md5-wasm.d.ts.map +1 -0
- package/dist/lib/algorithms/md5-wasm.js +414 -449
- package/dist/lib/crc32-hash.d.ts +18 -0
- package/dist/lib/crc32-hash.d.ts.map +1 -0
- package/dist/lib/crc32-hash.js +45 -54
- package/dist/lib/crc32c-hash.d.ts +22 -0
- package/dist/lib/crc32c-hash.d.ts.map +1 -0
- package/dist/lib/crc32c-hash.js +49 -53
- package/dist/lib/crypto-hash.d.ts +32 -0
- package/dist/lib/crypto-hash.d.ts.map +1 -0
- package/dist/lib/crypto-hash.js +55 -70
- package/dist/lib/hash.d.ts +22 -0
- package/dist/lib/hash.d.ts.map +1 -0
- package/dist/lib/hash.js +27 -36
- package/dist/lib/md5-hash.d.ts +15 -0
- package/dist/lib/md5-hash.d.ts.map +1 -0
- package/dist/lib/md5-hash.js +31 -22
- package/dist/lib/node-hash.d.ts +28 -0
- package/dist/lib/node-hash.d.ts.map +1 -0
- package/dist/lib/node-hash.js +39 -49
- package/dist/lib/sha256-hash.d.ts +19 -0
- package/dist/lib/sha256-hash.d.ts.map +1 -0
- package/dist/lib/sha256-hash.js +13 -11
- package/dist/lib/utils/base64-utils.d.ts +3 -2
- package/dist/lib/utils/base64-utils.d.ts.map +1 -0
- package/dist/lib/utils/base64-utils.js +62 -57
- package/dist/lib/utils/digest-utils.d.ts +6 -3
- package/dist/lib/utils/digest-utils.d.ts.map +1 -0
- package/dist/lib/utils/digest-utils.js +25 -12
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -2
- package/dist/workers/worker.d.ts +4 -0
- package/dist/workers/worker.d.ts.map +1 -0
- package/dist/workers/worker.js +22 -24
- package/package.json +10 -10
- package/src/lib/algorithms/{crc32.js → crc32.ts} +2 -0
- package/src/lib/algorithms/{crc32c.js → crc32c.ts} +3 -0
- package/src/lib/hash.ts +1 -1
- package/src/lib/md5-hash.ts +1 -0
- package/src/lib/utils/{base64-utils.js → base64-utils.ts} +3 -2
- package/src/lib/utils/digest-utils.ts +24 -0
- package/dist/bundle.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/algorithms/crc32.js.map +0 -1
- package/dist/lib/algorithms/crc32c.js.map +0 -1
- package/dist/lib/algorithms/md5-wasm.js.map +0 -1
- package/dist/lib/crc32-hash.js.map +0 -1
- package/dist/lib/crc32c-hash.js.map +0 -1
- package/dist/lib/crypto-hash.js.map +0 -1
- package/dist/lib/hash.js.map +0 -1
- package/dist/lib/md5-hash.js.map +0 -1
- package/dist/lib/node-hash.js.map +0 -1
- package/dist/lib/sha256-hash.js.map +0 -1
- package/dist/lib/utils/base64-utils.js.map +0 -1
- package/dist/lib/utils/digest-utils.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/worker.js +0 -5072
- package/dist/worker.js.map +0 -1
- package/dist/workers/worker.js.map +0 -1
- package/src/lib/utils/base64-utils.d.ts +0 -5
- package/src/lib/utils/digest-utils.d.ts +0 -6
- package/src/lib/utils/digest-utils.js +0 -25
- package/dist/{workers → es5/workers}/cryptojs-worker.ts.disabled +0 -0
- package/src/lib/algorithms/{md5-wasm.js → md5-wasm.ts} +2 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Hash } from './hash';
|
|
2
|
+
/**
|
|
3
|
+
* Calculates CRC32 Cryptographic Hash
|
|
4
|
+
*/
|
|
5
|
+
export declare class CRC32Hash extends Hash {
|
|
6
|
+
readonly name = "crc32";
|
|
7
|
+
options: any;
|
|
8
|
+
private _hash;
|
|
9
|
+
constructor(options?: {});
|
|
10
|
+
/**
|
|
11
|
+
* Atomic hash calculation
|
|
12
|
+
* @returns base64 encoded hash
|
|
13
|
+
*/
|
|
14
|
+
hash(input: ArrayBuffer): Promise<string>;
|
|
15
|
+
hashSync(input: ArrayBuffer): string;
|
|
16
|
+
hashBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=crc32-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crc32-hash.d.ts","sourceRoot":"","sources":["../../src/lib/crc32-hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAI5B;;GAEG;AACH,qBAAa,SAAU,SAAQ,IAAI;IACjC,QAAQ,CAAC,IAAI,WAAW;IAExB,OAAO,MAAC;IACR,OAAO,CAAC,KAAK,CAAQ;gBAET,OAAO,KAAK;IAOxB;;;OAGG;IACG,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAI/C,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM;IAQ7B,WAAW,CAChB,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAChE,aAAa,CAAC,WAAW,CAAC;CAU9B"}
|
package/dist/lib/crc32-hash.js
CHANGED
|
@@ -1,56 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CRC32Hash = void 0;
|
|
7
|
+
// CRC32
|
|
8
|
+
const hash_1 = require("./hash");
|
|
9
|
+
const crc32_1 = __importDefault(require("./algorithms/crc32"));
|
|
10
|
+
const digest_utils_1 = require("./utils/digest-utils");
|
|
11
|
+
/**
|
|
12
|
+
* Calculates CRC32 Cryptographic Hash
|
|
13
|
+
*/
|
|
14
|
+
class CRC32Hash extends hash_1.Hash {
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
super();
|
|
17
|
+
this.name = 'crc32';
|
|
18
|
+
this.options = { crypto: {}, ...options };
|
|
19
|
+
this._hash = new crc32_1.default();
|
|
20
|
+
this.hashBatches = this.hashBatches.bind(this);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Atomic hash calculation
|
|
24
|
+
* @returns base64 encoded hash
|
|
25
|
+
*/
|
|
26
|
+
async hash(input) {
|
|
27
|
+
return this.hashSync(input);
|
|
28
|
+
}
|
|
29
|
+
hashSync(input) {
|
|
30
|
+
this._hash.update(input);
|
|
31
|
+
const hashValue = this._hash.finalize();
|
|
32
|
+
const hex = (0, digest_utils_1.toHex)(hashValue);
|
|
33
|
+
const hash = (0, digest_utils_1.hexToBase64)(hex);
|
|
34
|
+
return hash;
|
|
35
|
+
}
|
|
36
|
+
async *hashBatches(asyncIterator) {
|
|
37
|
+
for await (const chunk of asyncIterator) {
|
|
38
|
+
this._hash.update(chunk);
|
|
39
|
+
yield chunk;
|
|
40
|
+
}
|
|
41
|
+
const hashValue = this._hash.finalize();
|
|
42
|
+
const hex = (0, digest_utils_1.toHex)(hashValue);
|
|
43
|
+
const hash = (0, digest_utils_1.hexToBase64)(hex);
|
|
44
|
+
this.options.crypto?.onEnd?.({ hash });
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
-
const hashValue = this._hash.finalize();
|
|
47
|
-
|
|
48
|
-
const hex = toHex(hashValue);
|
|
49
|
-
const hash = hexToBase64(hex);
|
|
50
|
-
(_this$options$crypto = this.options.crypto) === null || _this$options$crypto === void 0 ? void 0 : (_this$options$crypto$ = _this$options$crypto.onEnd) === null || _this$options$crypto$ === void 0 ? void 0 : _this$options$crypto$.call(_this$options$crypto, {
|
|
51
|
-
hash
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
46
|
}
|
|
56
|
-
|
|
47
|
+
exports.CRC32Hash = CRC32Hash;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Hash } from './hash';
|
|
2
|
+
/**
|
|
3
|
+
* A transform that calculates CRC32c Hash
|
|
4
|
+
*/
|
|
5
|
+
export declare class CRC32CHash extends Hash {
|
|
6
|
+
readonly name = "crc32c";
|
|
7
|
+
options: any;
|
|
8
|
+
private _hash;
|
|
9
|
+
/**
|
|
10
|
+
* Atomic hash calculation
|
|
11
|
+
* @returns base64 encoded hash
|
|
12
|
+
*/
|
|
13
|
+
constructor(options?: {});
|
|
14
|
+
/**
|
|
15
|
+
* Atomic hash calculation
|
|
16
|
+
* @returns base64 encoded hash
|
|
17
|
+
*/
|
|
18
|
+
hash(input: ArrayBuffer): Promise<string>;
|
|
19
|
+
hashSync(input: ArrayBuffer): string;
|
|
20
|
+
hashBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=crc32c-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crc32c-hash.d.ts","sourceRoot":"","sources":["../../src/lib/crc32c-hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAI5B;;GAEG;AACH,qBAAa,UAAW,SAAQ,IAAI;IAClC,QAAQ,CAAC,IAAI,YAAY;IAEzB,OAAO,MAAC;IACR,OAAO,CAAC,KAAK,CAAS;IAEtB;;;OAGG;gBACS,OAAO,KAAK;IAMxB;;;OAGG;IACG,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAI/C,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM;IAU7B,WAAW,CAChB,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAChE,aAAa,CAAC,WAAW,CAAC;CAU9B"}
|
package/dist/lib/crc32c-hash.js
CHANGED
|
@@ -1,55 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CRC32CHash = void 0;
|
|
7
|
+
// CRC32c
|
|
8
|
+
const hash_1 = require("./hash");
|
|
9
|
+
const crc32c_1 = __importDefault(require("./algorithms/crc32c"));
|
|
10
|
+
const digest_utils_1 = require("./utils/digest-utils");
|
|
11
|
+
/**
|
|
12
|
+
* A transform that calculates CRC32c Hash
|
|
13
|
+
*/
|
|
14
|
+
class CRC32CHash extends hash_1.Hash {
|
|
15
|
+
/**
|
|
16
|
+
* Atomic hash calculation
|
|
17
|
+
* @returns base64 encoded hash
|
|
18
|
+
*/
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
super();
|
|
21
|
+
this.name = 'crc32c';
|
|
22
|
+
this.options = { crypto: {}, ...options };
|
|
23
|
+
this._hash = new crc32c_1.default(options);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Atomic hash calculation
|
|
27
|
+
* @returns base64 encoded hash
|
|
28
|
+
*/
|
|
29
|
+
async hash(input) {
|
|
30
|
+
return this.hashSync(input);
|
|
31
|
+
}
|
|
32
|
+
hashSync(input) {
|
|
33
|
+
this._hash.update(input);
|
|
34
|
+
const hashValue = this._hash.finalize();
|
|
35
|
+
const hex = (0, digest_utils_1.toHex)(hashValue);
|
|
36
|
+
const hash = (0, digest_utils_1.hexToBase64)(hex);
|
|
37
|
+
return hash;
|
|
38
|
+
}
|
|
39
|
+
// runInBatches inherited
|
|
40
|
+
async *hashBatches(asyncIterator) {
|
|
41
|
+
for await (const chunk of asyncIterator) {
|
|
42
|
+
this._hash.update(chunk);
|
|
43
|
+
yield chunk;
|
|
44
|
+
}
|
|
45
|
+
const hashValue = this._hash.finalize();
|
|
46
|
+
const hex = (0, digest_utils_1.toHex)(hashValue);
|
|
47
|
+
const hash = (0, digest_utils_1.hexToBase64)(hex);
|
|
48
|
+
this.options.crypto?.onEnd?.({ hash });
|
|
43
49
|
}
|
|
44
|
-
|
|
45
|
-
const hashValue = this._hash.finalize();
|
|
46
|
-
|
|
47
|
-
const hex = toHex(hashValue);
|
|
48
|
-
const hash = hexToBase64(hex);
|
|
49
|
-
(_this$options$crypto = this.options.crypto) === null || _this$options$crypto === void 0 ? void 0 : (_this$options$crypto$ = _this$options$crypto.onEnd) === null || _this$options$crypto$ === void 0 ? void 0 : _this$options$crypto$.call(_this$options$crypto, {
|
|
50
|
-
hash
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
50
|
}
|
|
55
|
-
|
|
51
|
+
exports.CRC32CHash = CRC32CHash;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Hash } from './hash';
|
|
2
|
+
type CryptoHashOptions = {
|
|
3
|
+
modules: {
|
|
4
|
+
[moduleName: string]: any;
|
|
5
|
+
};
|
|
6
|
+
crypto: {
|
|
7
|
+
algorithm: string;
|
|
8
|
+
onEnd?: (result: {
|
|
9
|
+
hash: string;
|
|
10
|
+
}) => any;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A transform that calculates Cryptographic Hash using Crypto JS library
|
|
15
|
+
* @deprecated Warning, experimental class
|
|
16
|
+
*/
|
|
17
|
+
export declare class CryptoHash extends Hash {
|
|
18
|
+
readonly name: any;
|
|
19
|
+
options: CryptoHashOptions;
|
|
20
|
+
private _algorithm;
|
|
21
|
+
private _hash;
|
|
22
|
+
constructor(options: CryptoHashOptions);
|
|
23
|
+
preload(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Atomic hash calculation
|
|
26
|
+
* @returns base64 encoded hash
|
|
27
|
+
*/
|
|
28
|
+
hash(input: ArrayBuffer): Promise<string>;
|
|
29
|
+
hashBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=crypto-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto-hash.d.ts","sourceRoot":"","sources":["../../src/lib/crypto-hash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAE5B,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;IACrC,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE;YAAC,IAAI,EAAE,MAAM,CAAA;SAAC,KAAK,GAAG,CAAC;KACzC,CAAC;CACH,CAAC;AAIF;;;GAGG;AACH,qBAAa,UAAW,SAAQ,IAAI;IAClC,QAAQ,CAAC,IAAI,MAAC;IAEd,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,CAAC,UAAU,CAAC;IACnB,OAAO,CAAC,KAAK,CAAC;gBAEF,OAAO,EAAE,iBAAiB;IAUhC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB9B;;;OAGG;IACG,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IASxC,WAAW,CAChB,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAChE,aAAa,CAAC,WAAW,CAAC;CAa9B"}
|
package/dist/lib/crypto-hash.js
CHANGED
|
@@ -1,76 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CryptoHash = void 0;
|
|
4
|
+
const hash_1 = require("./hash");
|
|
3
5
|
let CryptoJS;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.options = options;
|
|
19
|
-
this._algorithm = (_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$crypto = _this$options.crypto) === null || _this$options$crypto === void 0 ? void 0 : _this$options$crypto.algorithm;
|
|
20
|
-
|
|
21
|
-
if (!this._algorithm) {
|
|
22
|
-
throw new Error(this.name);
|
|
6
|
+
/**
|
|
7
|
+
* A transform that calculates Cryptographic Hash using Crypto JS library
|
|
8
|
+
* @deprecated Warning, experimental class
|
|
9
|
+
*/
|
|
10
|
+
class CryptoHash extends hash_1.Hash {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super();
|
|
13
|
+
this.options = options;
|
|
14
|
+
this._algorithm = this.options?.crypto?.algorithm;
|
|
15
|
+
if (!this._algorithm) {
|
|
16
|
+
throw new Error(this.name);
|
|
17
|
+
}
|
|
18
|
+
this.name = this._algorithm.toLowerCase();
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
20
|
+
async preload() {
|
|
21
|
+
if (!CryptoJS) {
|
|
22
|
+
CryptoJS = this.options?.modules?.CryptoJS;
|
|
23
|
+
if (!CryptoJS) {
|
|
24
|
+
throw new Error(this.name);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!this._hash) {
|
|
28
|
+
const algo = CryptoJS.algo[this._algorithm];
|
|
29
|
+
this._hash = algo.create();
|
|
30
|
+
}
|
|
31
|
+
if (!this._hash) {
|
|
32
|
+
throw new Error(this.name);
|
|
33
|
+
}
|
|
37
34
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Atomic hash calculation
|
|
37
|
+
* @returns base64 encoded hash
|
|
38
|
+
*/
|
|
39
|
+
async hash(input) {
|
|
40
|
+
await this.preload();
|
|
41
|
+
// arrayBuffer is accepted, even though types and docs say no
|
|
42
|
+
// https://stackoverflow.com/questions/25567468/how-to-decrypt-an-arraybuffer
|
|
43
|
+
// @ts-expect-error
|
|
44
|
+
const typedWordArray = CryptoJS.lib.WordArray.create(input);
|
|
45
|
+
return this._hash.update(typedWordArray).finalize().toString(CryptoJS.enc.Base64);
|
|
42
46
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
async *hashBatches(asyncIterator) {
|
|
48
|
+
await this.preload();
|
|
49
|
+
for await (const chunk of asyncIterator) {
|
|
50
|
+
// arrayBuffer is accepted, even though types and docs say no
|
|
51
|
+
// https://stackoverflow.com/questions/25567468/how-to-decrypt-an-arraybuffer
|
|
52
|
+
// @ts-expect-error
|
|
53
|
+
const typedWordArray = CryptoJS.lib.WordArray.create(chunk);
|
|
54
|
+
this._hash.update(typedWordArray);
|
|
55
|
+
yield chunk;
|
|
56
|
+
}
|
|
57
|
+
const hash = this._hash.finalize().toString(CryptoJS.enc.Base64);
|
|
58
|
+
this.options?.crypto?.onEnd?.({ hash });
|
|
46
59
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async hash(input) {
|
|
50
|
-
await this.preload();
|
|
51
|
-
const typedWordArray = CryptoJS.lib.WordArray.create(input);
|
|
52
|
-
return this._hash.update(typedWordArray).finalize().toString(CryptoJS.enc.Base64);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async *hashBatches(asyncIterator) {
|
|
56
|
-
var _this$options3, _this$options3$crypto, _this$options3$crypto2;
|
|
57
|
-
|
|
58
|
-
await this.preload();
|
|
59
|
-
|
|
60
|
-
for await (const chunk of asyncIterator) {
|
|
61
|
-
const typedWordArray = CryptoJS.lib.WordArray.create(chunk);
|
|
62
|
-
|
|
63
|
-
this._hash.update(typedWordArray);
|
|
64
|
-
|
|
65
|
-
yield chunk;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const hash = this._hash.finalize().toString(CryptoJS.enc.Base64);
|
|
69
|
-
|
|
70
|
-
(_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : (_this$options3$crypto = _this$options3.crypto) === null || _this$options3$crypto === void 0 ? void 0 : (_this$options3$crypto2 = _this$options3$crypto.onEnd) === null || _this$options3$crypto2 === void 0 ? void 0 : _this$options3$crypto2.call(_this$options3$crypto, {
|
|
71
|
-
hash
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
60
|
}
|
|
76
|
-
|
|
61
|
+
exports.CryptoHash = CryptoHash;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type HashOptions = {
|
|
2
|
+
modules?: {
|
|
3
|
+
[moduleName: string]: any;
|
|
4
|
+
};
|
|
5
|
+
crypto?: {
|
|
6
|
+
onEnd?: (result: {
|
|
7
|
+
hash: string;
|
|
8
|
+
}) => any;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
/** Abstract hash base class */
|
|
12
|
+
export declare abstract class Hash {
|
|
13
|
+
abstract readonly name: string;
|
|
14
|
+
abstract readonly options: HashOptions;
|
|
15
|
+
constructor(options?: HashOptions);
|
|
16
|
+
preload(): Promise<void>;
|
|
17
|
+
abstract hash(arrayBuffer: ArrayBuffer): Promise<string>;
|
|
18
|
+
hashBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
19
|
+
protected concatenate(asyncIterator: any): Promise<ArrayBuffer>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/lib/hash.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;IACtC,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE;YAAC,IAAI,EAAE,MAAM,CAAA;SAAC,KAAK,GAAG,CAAC;KACzC,CAAC;CACH,CAAC;AAEF,+BAA+B;AAC/B,8BAAsB,IAAI;IACxB,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;gBAE3B,OAAO,GAAE,WAAgB;IAI/B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAEjD,WAAW,CAChB,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAChE,aAAa,CAAC,WAAW,CAAC;cAab,WAAW,CAAC,aAAa,KAAA,GAAG,OAAO,CAAC,WAAW,CAAC;CAGjE"}
|
package/dist/lib/hash.js
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Hash = void 0;
|
|
4
|
+
// Hash
|
|
5
|
+
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
6
|
+
/** Abstract hash base class */
|
|
7
|
+
class Hash {
|
|
8
|
+
constructor(options = {}) {
|
|
9
|
+
this.hashBatches = this.hashBatches.bind(this);
|
|
10
|
+
}
|
|
11
|
+
async preload() {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
async *hashBatches(asyncIterator) {
|
|
15
|
+
const arrayBuffers = [];
|
|
16
|
+
for await (const arrayBuffer of asyncIterator) {
|
|
17
|
+
arrayBuffers.push(arrayBuffer);
|
|
18
|
+
yield arrayBuffer;
|
|
19
|
+
}
|
|
20
|
+
const output = await this.concatenate(arrayBuffers);
|
|
21
|
+
const hash = await this.hash(output);
|
|
22
|
+
this.options.crypto?.onEnd?.({ hash });
|
|
23
|
+
}
|
|
24
|
+
// HELPERS
|
|
25
|
+
async concatenate(asyncIterator) {
|
|
26
|
+
return await (0, loader_utils_1.concatenateArrayBuffersAsync)(asyncIterator);
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
const output = await this.concatenate(arrayBuffers);
|
|
27
|
-
const hash = await this.hash(output);
|
|
28
|
-
(_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$crypto = _this$options.crypto) === null || _this$options$crypto === void 0 ? void 0 : (_this$options$crypto$ = _this$options$crypto.onEnd) === null || _this$options$crypto$ === void 0 ? void 0 : _this$options$crypto$.call(_this$options$crypto, {
|
|
29
|
-
hash
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async concatenate(asyncIterator) {
|
|
34
|
-
return await concatenateArrayBuffersAsync(asyncIterator);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
28
|
}
|
|
38
|
-
|
|
29
|
+
exports.Hash = Hash;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Hash } from './hash';
|
|
2
|
+
/**
|
|
3
|
+
* A transform that calculates MD5 hashes, passing data through
|
|
4
|
+
*/
|
|
5
|
+
export declare class MD5Hash extends Hash {
|
|
6
|
+
readonly name = "md5";
|
|
7
|
+
readonly options: any;
|
|
8
|
+
constructor(options?: {});
|
|
9
|
+
/**
|
|
10
|
+
* Atomic hash calculation
|
|
11
|
+
* @returns base64 encoded hash
|
|
12
|
+
*/
|
|
13
|
+
hash(input: ArrayBuffer): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=md5-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md5-hash.d.ts","sourceRoot":"","sources":["../../src/lib/md5-hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAI5B;;GAEG;AACH,qBAAa,OAAQ,SAAQ,IAAI;IAC/B,QAAQ,CAAC,IAAI,SAAS;IACtB,QAAQ,CAAC,OAAO,MAAC;gBAEL,OAAO,KAAK;IAKxB;;;OAGG;IACG,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;CAQhD"}
|
package/dist/lib/md5-hash.js
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MD5Hash = void 0;
|
|
7
|
+
// Fork of https://github.com/briantbutton/md5-wasm under MIT license
|
|
8
|
+
const hash_1 = require("./hash");
|
|
9
|
+
const md5_wasm_1 = __importDefault(require("./algorithms/md5-wasm"));
|
|
10
|
+
const digest_utils_1 = require("./utils/digest-utils");
|
|
11
|
+
/**
|
|
12
|
+
* A transform that calculates MD5 hashes, passing data through
|
|
13
|
+
*/
|
|
14
|
+
class MD5Hash extends hash_1.Hash {
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
super();
|
|
17
|
+
this.name = 'md5';
|
|
18
|
+
this.options = options;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Atomic hash calculation
|
|
22
|
+
* @returns base64 encoded hash
|
|
23
|
+
*/
|
|
24
|
+
async hash(input) {
|
|
25
|
+
const md5Promise = new Promise((resolve, reject) =>
|
|
26
|
+
// @ts-expect-error
|
|
27
|
+
(0, md5_wasm_1.default)(input).then(resolve).catch(reject));
|
|
28
|
+
const hex = await md5Promise;
|
|
29
|
+
return (0, digest_utils_1.hexToBase64)(hex);
|
|
30
|
+
}
|
|
22
31
|
}
|
|
23
|
-
|
|
32
|
+
exports.MD5Hash = MD5Hash;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Hash } from './hash';
|
|
2
|
+
type CryptoHashOptions = {
|
|
3
|
+
crypto: {
|
|
4
|
+
algorithm: string;
|
|
5
|
+
onEnd?: (result: {
|
|
6
|
+
hash: string;
|
|
7
|
+
}) => any;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Calculates Cryptographic Hash using Node.js crypto library
|
|
12
|
+
* @deprecated Warning, experimental class
|
|
13
|
+
*/
|
|
14
|
+
export declare class NodeHash extends Hash {
|
|
15
|
+
readonly name = "crypto-node";
|
|
16
|
+
options: CryptoHashOptions;
|
|
17
|
+
private _algorithm;
|
|
18
|
+
private _hash;
|
|
19
|
+
constructor(options: CryptoHashOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Atomic hash calculation
|
|
22
|
+
* @returns base64 encoded hash
|
|
23
|
+
*/
|
|
24
|
+
hash(input: ArrayBuffer): Promise<string>;
|
|
25
|
+
hashBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=node-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-hash.d.ts","sourceRoot":"","sources":["../../src/lib/node-hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAG5B,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE;YAAC,IAAI,EAAE,MAAM,CAAA;SAAC,KAAK,GAAG,CAAC;KACzC,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,qBAAa,QAAS,SAAQ,IAAI;IAChC,QAAQ,CAAC,IAAI,iBAAiB;IAE9B,OAAO,EAAE,iBAAiB,CAAC;IAE3B,OAAO,CAAC,UAAU,CAAC;IAEnB,OAAO,CAAC,KAAK,CAAC;gBAEF,OAAO,EAAE,iBAAiB;IAQtC;;;OAGG;IACG,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAOxC,WAAW,CAChB,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAChE,aAAa,CAAC,WAAW,CAAC;CAW9B"}
|