@loaders.gl/crypto 4.0.0-beta.2 → 4.0.0-beta.4
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/crypto-worker-node.js +1 -1
- package/dist/crypto-worker-node.js.map +2 -2
- package/dist/crypto-worker.js +1 -1
- package/dist/crypto-worker.js.map +2 -2
- package/dist/dist.dev.js +846 -0
- package/dist/index.cjs +1341 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/{esm/lib → lib}/algorithms/crc32.js +1 -2
- package/dist/lib/algorithms/crc32.js.map +1 -0
- package/dist/{esm/lib → lib}/algorithms/crc32c.js +2 -3
- package/dist/lib/algorithms/crc32c.js.map +1 -0
- package/dist/lib/algorithms/md5-wasm.js.map +1 -0
- package/dist/{esm/lib → lib}/crc32-hash.js +6 -7
- package/dist/lib/crc32-hash.js.map +1 -0
- package/dist/{esm/lib → lib}/crc32c-hash.js +6 -7
- package/dist/lib/crc32c-hash.js.map +1 -0
- package/dist/lib/crypto-hash.d.ts.map +1 -1
- package/dist/{esm/lib → lib}/crypto-hash.js +8 -9
- package/dist/lib/crypto-hash.js.map +1 -0
- package/dist/{esm/lib → lib}/hash.js +2 -3
- package/dist/lib/hash.js.map +1 -0
- package/dist/{esm/lib → lib}/md5-hash.js +5 -6
- package/dist/lib/md5-hash.js.map +1 -0
- package/dist/{esm/lib → lib}/sha256-hash.js +1 -1
- package/dist/lib/sha256-hash.js.map +1 -0
- package/dist/{esm/lib → lib}/utils/base64-utils.js +2 -2
- package/dist/lib/utils/base64-utils.js.map +1 -0
- package/dist/{esm/lib → lib}/utils/digest-utils.js +3 -3
- package/dist/lib/utils/digest-utils.js.map +1 -0
- package/dist/types.js.map +1 -0
- package/dist/{esm/workers → workers}/worker.js +4 -4
- package/dist/workers/worker.js.map +1 -0
- package/package.json +16 -8
- package/src/index.ts +4 -1
- package/src/lib/crypto-hash.ts +4 -8
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/dist.min.js +0 -2
- package/dist/dist.min.js.map +0 -7
- package/dist/es5/bundle.js +0 -6
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/index.js +0 -102
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/algorithms/crc32.js +0 -41
- package/dist/es5/lib/algorithms/crc32.js.map +0 -1
- package/dist/es5/lib/algorithms/crc32c.js +0 -44
- package/dist/es5/lib/algorithms/crc32c.js.map +0 -1
- package/dist/es5/lib/algorithms/md5-wasm.js +0 -436
- package/dist/es5/lib/algorithms/md5-wasm.js.map +0 -1
- package/dist/es5/lib/crc32-hash.js +0 -148
- package/dist/es5/lib/crc32-hash.js.map +0 -1
- package/dist/es5/lib/crc32c-hash.js +0 -147
- package/dist/es5/lib/crc32c-hash.js.map +0 -1
- package/dist/es5/lib/crypto-hash.js +0 -189
- package/dist/es5/lib/crypto-hash.js.map +0 -1
- package/dist/es5/lib/hash.js +0 -150
- package/dist/es5/lib/hash.js.map +0 -1
- package/dist/es5/lib/md5-hash.js +0 -66
- package/dist/es5/lib/md5-hash.js.map +0 -1
- package/dist/es5/lib/node-hash.js +0 -155
- package/dist/es5/lib/node-hash.js.map +0 -1
- package/dist/es5/lib/sha256-hash.js +0 -33
- package/dist/es5/lib/sha256-hash.js.map +0 -1
- package/dist/es5/lib/utils/base64-utils.js +0 -94
- package/dist/es5/lib/utils/base64-utils.js.map +0 -1
- package/dist/es5/lib/utils/digest-utils.js +0 -61
- package/dist/es5/lib/utils/digest-utils.js.map +0 -1
- package/dist/es5/types.js +0 -2
- package/dist/es5/types.js.map +0 -1
- package/dist/es5/workers/worker.js +0 -67
- package/dist/es5/workers/worker.js.map +0 -1
- package/dist/esm/bundle.js +0 -4
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/index.js +0 -28
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/algorithms/crc32.js.map +0 -1
- package/dist/esm/lib/algorithms/crc32c.js.map +0 -1
- package/dist/esm/lib/algorithms/md5-wasm.js.map +0 -1
- package/dist/esm/lib/crc32-hash.js.map +0 -1
- package/dist/esm/lib/crc32c-hash.js.map +0 -1
- package/dist/esm/lib/crypto-hash.js.map +0 -1
- package/dist/esm/lib/hash.js.map +0 -1
- package/dist/esm/lib/md5-hash.js.map +0 -1
- package/dist/esm/lib/node-hash.js +0 -52
- package/dist/esm/lib/node-hash.js.map +0 -1
- package/dist/esm/lib/sha256-hash.js.map +0 -1
- package/dist/esm/lib/utils/base64-utils.js.map +0 -1
- package/dist/esm/lib/utils/digest-utils.js.map +0 -1
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/workers/cryptojs-worker.ts.disabled +0 -26
- package/dist/esm/workers/worker.js.map +0 -1
- package/dist/lib/node-hash.d.ts +0 -28
- package/dist/lib/node-hash.d.ts.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/lib/node-hash.ts +0 -65
- /package/dist/{esm/lib → lib}/algorithms/md5-wasm.js +0 -0
- /package/dist/{esm/types.js → types.js} +0 -0
- /package/dist/{es5/workers → workers}/cryptojs-worker.ts.disabled +0 -0
package/dist/lib/node-hash.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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, encoding: 'hex' | 'base64'): Promise<string>;
|
|
25
|
-
hashBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, encoding?: 'hex' | 'base64'): AsyncIterable<ArrayBuffer>;
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=node-hash.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,EAAE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAYpE,WAAW,CAChB,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EACjE,QAAQ,GAAE,KAAK,GAAG,QAAmB,GACpC,aAAa,CAAC,WAAW,CAAC;CAa9B"}
|
package/src/bundle.ts
DELETED
package/src/lib/node-hash.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// This dependency is too big, application must provide it
|
|
2
|
-
import {Hash} from './hash';
|
|
3
|
-
import {createHash} from 'crypto'; // Node.js builtin
|
|
4
|
-
|
|
5
|
-
type CryptoHashOptions = {
|
|
6
|
-
crypto: {
|
|
7
|
-
algorithm: string;
|
|
8
|
-
onEnd?: (result: {hash: string}) => any;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Calculates Cryptographic Hash using Node.js crypto library
|
|
14
|
-
* @deprecated Warning, experimental class
|
|
15
|
-
*/
|
|
16
|
-
export class NodeHash extends Hash {
|
|
17
|
-
readonly name = 'crypto-node';
|
|
18
|
-
|
|
19
|
-
options: CryptoHashOptions;
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
private _algorithm;
|
|
22
|
-
// @ts-ignore
|
|
23
|
-
private _hash;
|
|
24
|
-
|
|
25
|
-
constructor(options: CryptoHashOptions) {
|
|
26
|
-
super();
|
|
27
|
-
this.options = options;
|
|
28
|
-
if (!this.options?.crypto?.algorithm) {
|
|
29
|
-
throw new Error(this.name);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Atomic hash calculation
|
|
35
|
-
* @returns base64 encoded hash
|
|
36
|
-
*/
|
|
37
|
-
async hash(input: ArrayBuffer, encoding: 'hex' | 'base64'): Promise<string> {
|
|
38
|
-
await this.preload();
|
|
39
|
-
const algorithm = this.options?.crypto?.algorithm?.toLowerCase();
|
|
40
|
-
try {
|
|
41
|
-
const hash = createHash(algorithm);
|
|
42
|
-
const inputArray = new Uint8Array(input);
|
|
43
|
-
return hash.update(inputArray).digest('base64');
|
|
44
|
-
} catch (error) {
|
|
45
|
-
throw Error(`${algorithm} hash not available. ${error}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async *hashBatches(
|
|
50
|
-
asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,
|
|
51
|
-
encoding: 'hex' | 'base64' = 'base64'
|
|
52
|
-
): AsyncIterable<ArrayBuffer> {
|
|
53
|
-
await this.preload();
|
|
54
|
-
const hash = createHash(this.options?.crypto?.algorithm?.toLowerCase());
|
|
55
|
-
for await (const chunk of asyncIterator) {
|
|
56
|
-
// https://stackoverflow.com/questions/25567468/how-to-decrypt-an-arraybuffer
|
|
57
|
-
const inputArray = new Uint8Array(chunk);
|
|
58
|
-
hash.update(inputArray);
|
|
59
|
-
yield chunk;
|
|
60
|
-
}
|
|
61
|
-
// We can pass our encoding constant directly to Node.js digest as it already supports `hex` and `base64`
|
|
62
|
-
const digest = hash.digest(encoding);
|
|
63
|
-
this.options?.crypto?.onEnd?.({hash: digest});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|