@loaders.gl/crypto 4.0.0-alpha.5 → 4.0.0-alpha.7
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.js +2 -2
- package/dist/crypto-worker-node.js +2 -0
- package/dist/crypto-worker-node.js.map +7 -0
- package/dist/crypto-worker.js +2 -0
- package/dist/crypto-worker.js.map +7 -0
- package/dist/dist.min.js +1 -1
- package/dist/dist.min.js.map +2 -2
- 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.js +45 -25
- package/dist/lib/algorithms/crc32.js +25 -26
- package/dist/lib/algorithms/crc32c.js +33 -29
- package/dist/lib/algorithms/md5-wasm.js +414 -449
- package/dist/lib/crc32-hash.js +45 -54
- package/dist/lib/crc32c-hash.js +49 -53
- package/dist/lib/crypto-hash.d.ts +1 -1
- package/dist/lib/crypto-hash.d.ts.map +1 -1
- package/dist/lib/crypto-hash.js +55 -70
- package/dist/lib/hash.d.ts +1 -1
- package/dist/lib/hash.d.ts.map +1 -1
- package/dist/lib/hash.js +27 -36
- package/dist/lib/md5-hash.js +31 -22
- package/dist/lib/node-hash.d.ts +1 -1
- package/dist/lib/node-hash.d.ts.map +1 -1
- package/dist/lib/node-hash.js +39 -49
- package/dist/lib/sha256-hash.d.ts +1 -1
- package/dist/lib/sha256-hash.d.ts.map +1 -1
- package/dist/lib/sha256-hash.js +13 -11
- package/dist/lib/utils/base64-utils.js +62 -57
- package/dist/lib/utils/digest-utils.js +25 -13
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/workers/worker.js +22 -24
- package/package.json +10 -9
- package/src/lib/hash.ts +1 -1
- 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 -2
- package/dist/worker.js.map +0 -7
- package/dist/workers/worker.js.map +0 -1
- /package/dist/{workers → es5/workers}/cryptojs-worker.ts.disabled +0 -0
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;
|
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;
|
|
@@ -1 +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,
|
|
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;
|
package/dist/lib/hash.d.ts
CHANGED
package/dist/lib/hash.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/lib/hash.ts"],"names":[],"mappings":"AAGA,
|
|
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;
|
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;
|
package/dist/lib/node-hash.d.ts
CHANGED
|
@@ -1 +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,
|
|
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"}
|
package/dist/lib/node-hash.js
CHANGED
|
@@ -1,52 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (!((_this$options = this.options) !== null && _this$options !== void 0 && (_this$options$crypto = _this$options.crypto) !== null && _this$options$crypto !== void 0 && _this$options$crypto.algorithm)) {
|
|
21
|
-
throw new Error(this.name);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeHash = void 0;
|
|
4
|
+
// This dependency is too big, application must provide it
|
|
5
|
+
const hash_1 = require("./hash");
|
|
6
|
+
const crypto_1 = require("crypto"); // Node.js builtin
|
|
7
|
+
/**
|
|
8
|
+
* Calculates Cryptographic Hash using Node.js crypto library
|
|
9
|
+
* @deprecated Warning, experimental class
|
|
10
|
+
*/
|
|
11
|
+
class NodeHash extends hash_1.Hash {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super();
|
|
14
|
+
this.name = 'crypto-node';
|
|
15
|
+
this.options = options;
|
|
16
|
+
if (!this.options?.crypto?.algorithm) {
|
|
17
|
+
throw new Error(this.name);
|
|
18
|
+
}
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
yield chunk;
|
|
20
|
+
/**
|
|
21
|
+
* Atomic hash calculation
|
|
22
|
+
* @returns base64 encoded hash
|
|
23
|
+
*/
|
|
24
|
+
async hash(input) {
|
|
25
|
+
await this.preload();
|
|
26
|
+
const hash = (0, crypto_1.createHash)(this.options?.crypto?.algorithm?.toLowerCase());
|
|
27
|
+
const inputArray = new Uint8Array(input);
|
|
28
|
+
return hash.update(inputArray).digest('base64');
|
|
29
|
+
}
|
|
30
|
+
async *hashBatches(asyncIterator) {
|
|
31
|
+
await this.preload();
|
|
32
|
+
const hash = (0, crypto_1.createHash)(this.options?.crypto?.algorithm?.toLowerCase());
|
|
33
|
+
for await (const chunk of asyncIterator) {
|
|
34
|
+
// https://stackoverflow.com/questions/25567468/how-to-decrypt-an-arraybuffer
|
|
35
|
+
const inputArray = new Uint8Array(chunk);
|
|
36
|
+
hash.update(inputArray);
|
|
37
|
+
yield chunk;
|
|
38
|
+
}
|
|
39
|
+
this.options?.crypto?.onEnd?.({ hash: hash.digest('base64') });
|
|
44
40
|
}
|
|
45
|
-
|
|
46
|
-
(_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : (_this$options4$crypto = _this$options4.crypto) === null || _this$options4$crypto === void 0 ? void 0 : (_this$options4$crypto2 = _this$options4$crypto.onEnd) === null || _this$options4$crypto2 === void 0 ? void 0 : _this$options4$crypto2.call(_this$options4$crypto, {
|
|
47
|
-
hash: hash.digest('base64')
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
41
|
}
|
|
52
|
-
|
|
42
|
+
exports.NodeHash = NodeHash;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sha256-hash.d.ts","sourceRoot":"","sources":["../../src/lib/sha256-hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC,
|
|
1
|
+
{"version":3,"file":"sha256-hash.d.ts","sourceRoot":"","sources":["../../src/lib/sha256-hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;IACrC,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE;YAAC,IAAI,EAAE,MAAM,CAAA;SAAC,KAAK,GAAG,CAAC;KACzC,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,qBAAa,UAAW,SAAQ,UAAU;gBAC5B,OAAO,EAAE,iBAAiB;CAGvC"}
|
package/dist/lib/sha256-hash.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SHA256Hash = void 0;
|
|
4
|
+
//
|
|
5
|
+
const crypto_hash_1 = require("./crypto-hash");
|
|
6
|
+
/**
|
|
7
|
+
* A transform that calculates Cryptographic Hash
|
|
8
|
+
*/
|
|
9
|
+
class SHA256Hash extends crypto_hash_1.CryptoHash {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
super({ ...options, crypto: { ...options.crypto, algorithm: 'SHA256' } });
|
|
12
|
+
}
|
|
11
13
|
}
|
|
12
|
-
|
|
14
|
+
exports.SHA256Hash = SHA256Hash;
|