@loaders.gl/crypto 4.0.0-alpha.4 → 4.0.0-alpha.5
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/dist.min.js +2 -2
- package/dist/dist.min.js.map +7 -1
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- 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 +3 -0
- package/dist/lib/algorithms/crc32.js.map +1 -1
- 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 +5 -0
- package/dist/lib/algorithms/crc32c.js.map +1 -1
- 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.map +1 -1
- package/dist/lib/crc32-hash.d.ts +18 -0
- package/dist/lib/crc32-hash.d.ts.map +1 -0
- package/dist/lib/crc32c-hash.d.ts +22 -0
- package/dist/lib/crc32c-hash.d.ts.map +1 -0
- package/dist/lib/crypto-hash.d.ts +32 -0
- package/dist/lib/crypto-hash.d.ts.map +1 -0
- package/dist/lib/hash.d.ts +22 -0
- package/dist/lib/hash.d.ts.map +1 -0
- 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.map +1 -1
- package/dist/lib/node-hash.d.ts +28 -0
- package/dist/lib/node-hash.d.ts.map +1 -0
- package/dist/lib/sha256-hash.d.ts +19 -0
- package/dist/lib/sha256-hash.d.ts.map +1 -0
- 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.map +1 -1
- 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 +3 -2
- package/dist/lib/utils/digest-utils.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/worker.js +2 -5072
- package/dist/worker.js.map +7 -1
- package/dist/workers/worker.d.ts +4 -0
- package/dist/workers/worker.d.ts.map +1 -0
- package/package.json +7 -7
- package/src/lib/algorithms/{crc32.js → crc32.ts} +2 -0
- package/src/lib/algorithms/{crc32c.js → crc32c.ts} +3 -0
- package/src/lib/algorithms/{md5-wasm.js → md5-wasm.ts} +2 -2
- 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/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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/workers/worker.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAI9C,OAAO,EAAC,SAAS,EAAE,UAAU,EAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/crypto",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.5",
|
|
4
4
|
"description": "Cryptographic/hashing plugins for loaders.gl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"mesh",
|
|
18
18
|
"point cloud"
|
|
19
19
|
],
|
|
20
|
-
"types": "
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
21
|
"main": "dist/index.js",
|
|
22
22
|
"module": "dist/index.js",
|
|
23
23
|
"sideEffects": false,
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
30
|
"pre-build": "npm run build-worker && npm run build-bundle",
|
|
31
|
-
"build-bundle": "
|
|
32
|
-
"build-worker": "
|
|
31
|
+
"build-bundle": "esbuild src/bundle.ts --outfile=dist/dist.min.js --bundle --minify --sourcemap",
|
|
32
|
+
"build-worker": "esbuild src/workers/worker.ts --outfile=dist/worker.js --bundle --minify --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/runtime": "^7.3.1",
|
|
36
|
-
"@loaders.gl/loader-utils": "4.0.0-alpha.
|
|
37
|
-
"@loaders.gl/worker-utils": "4.0.0-alpha.
|
|
36
|
+
"@loaders.gl/loader-utils": "4.0.0-alpha.5",
|
|
37
|
+
"@loaders.gl/worker-utils": "4.0.0-alpha.5",
|
|
38
38
|
"@types/crypto-js": "^4.0.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"crypto": false,
|
|
45
45
|
"sse4_crc32": false
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "7a71a54bdf1ddf985cc3af3db90b82e7fa97d025"
|
|
48
48
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
1
3
|
/* !
|
|
2
4
|
* MD5 WebAssembly
|
|
3
5
|
* https://github.com/briantbutton/md5-wasm
|
|
4
6
|
* (c) 2020 Brian Todd Button
|
|
5
7
|
* Released under the MIT license
|
|
6
8
|
*/
|
|
7
|
-
/* eslint-disable */
|
|
8
|
-
// @ts-nocheck
|
|
9
9
|
|
|
10
10
|
// *-*=* *=*-* *-*=* *=*-* *-*=* *=*-* *-*=* *=*-* *-*=* *=*-* *-*=* *=*-*
|
|
11
11
|
// This contains two functions designed to achieve the same thing
|
package/src/lib/md5-hash.ts
CHANGED
|
@@ -21,6 +21,7 @@ export class MD5Hash extends Hash {
|
|
|
21
21
|
*/
|
|
22
22
|
async hash(input: ArrayBuffer): Promise<string> {
|
|
23
23
|
const md5Promise = new Promise<string>((resolve, reject) =>
|
|
24
|
+
// @ts-expect-error
|
|
24
25
|
md5WASM(input).then(resolve).catch(reject)
|
|
25
26
|
);
|
|
26
27
|
const hex = await md5Promise;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `btoa()` polyfill as defined by the HTML and Infra specs, which mostly just references
|
|
3
3
|
* RFC 4648.
|
|
4
4
|
*/
|
|
5
|
-
export function toBase64(string) {
|
|
5
|
+
export function toBase64(string: string): string | null {
|
|
6
6
|
// String conversion as required by Web IDL.
|
|
7
7
|
string = `${string}`;
|
|
8
8
|
// "The btoa() method must throw an "InvalidCharacterError" DOMException if
|
|
@@ -15,7 +15,7 @@ export function toBase64(string) {
|
|
|
15
15
|
let out = '';
|
|
16
16
|
for (let i = 0; i < string.length; i += 3) {
|
|
17
17
|
/** @type {Array[4]} */
|
|
18
|
-
const groupsOfSix = [undefined, undefined, undefined, undefined];
|
|
18
|
+
const groupsOfSix: (number | undefined)[] = [undefined, undefined, undefined, undefined];
|
|
19
19
|
groupsOfSix[0] = string.charCodeAt(i) >> 2;
|
|
20
20
|
groupsOfSix[1] = (string.charCodeAt(i) & 0x03) << 4;
|
|
21
21
|
if (string.length > i + 1) {
|
|
@@ -23,6 +23,7 @@ export function toBase64(string) {
|
|
|
23
23
|
groupsOfSix[2] = (string.charCodeAt(i + 1) & 0x0f) << 2;
|
|
24
24
|
}
|
|
25
25
|
if (string.length > i + 2) {
|
|
26
|
+
// @ts-expect-error
|
|
26
27
|
groupsOfSix[2] |= string.charCodeAt(i + 2) >> 6;
|
|
27
28
|
groupsOfSix[3] = string.charCodeAt(i + 2) & 0x3f;
|
|
28
29
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {toBase64} from './base64-utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export function toHex(cipher: number): string {
|
|
7
|
+
const hexString = cipher.toString(16);
|
|
8
|
+
return hexString === '0' ? `0${hexString}` : hexString;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @see https://stackoverflow.com/questions/23190056/hex-to-base64-converter-for-javascript
|
|
13
|
+
*/
|
|
14
|
+
export function hexToBase64(hexstring: string): string {
|
|
15
|
+
// Add leading zero to keep even count of digits
|
|
16
|
+
// eg. f85d741 => 0f85d741
|
|
17
|
+
if (hexstring.length % 2 !== 0) {
|
|
18
|
+
hexstring = `0${hexstring}`;
|
|
19
|
+
}
|
|
20
|
+
const matches = hexstring.match(/\w{2}/g) || [];
|
|
21
|
+
const string = matches.map((a) => String.fromCharCode(parseInt(a, 16))).join('');
|
|
22
|
+
// TODO - define how to handle failures
|
|
23
|
+
return toBase64(string) || '';
|
|
24
|
+
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {toBase64} from './base64-utils';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
export function toHex(cipher) {
|
|
7
|
-
const hexString = cipher.toString(16);
|
|
8
|
-
return hexString === '0' ? `0${hexString}` : hexString;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export function hexToBase64(hexstring) {
|
|
15
|
-
// Add leading zero to keep even count of digits
|
|
16
|
-
// eg. f85d741 => 0f85d741
|
|
17
|
-
if (hexstring.length % 2 !== 0) {
|
|
18
|
-
hexstring = `0${hexstring}`;
|
|
19
|
-
}
|
|
20
|
-
const string = hexstring
|
|
21
|
-
.match(/\w{2}/g)
|
|
22
|
-
.map((a) => String.fromCharCode(parseInt(a, 16)))
|
|
23
|
-
.join('');
|
|
24
|
-
return toBase64(string);
|
|
25
|
-
}
|