@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.
Files changed (56) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/dist.min.js +2 -2
  4. package/dist/dist.min.js.map +7 -1
  5. package/dist/index.d.ts +33 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +1 -1
  8. package/dist/lib/algorithms/crc32.d.ts +10 -0
  9. package/dist/lib/algorithms/crc32.d.ts.map +1 -0
  10. package/dist/lib/algorithms/crc32.js +3 -0
  11. package/dist/lib/algorithms/crc32.js.map +1 -1
  12. package/dist/lib/algorithms/crc32c.d.ts +11 -0
  13. package/dist/lib/algorithms/crc32c.d.ts.map +1 -0
  14. package/dist/lib/algorithms/crc32c.js +5 -0
  15. package/dist/lib/algorithms/crc32c.js.map +1 -1
  16. package/dist/lib/algorithms/md5-wasm.d.ts +2 -0
  17. package/dist/lib/algorithms/md5-wasm.d.ts.map +1 -0
  18. package/dist/lib/algorithms/md5-wasm.js.map +1 -1
  19. package/dist/lib/crc32-hash.d.ts +18 -0
  20. package/dist/lib/crc32-hash.d.ts.map +1 -0
  21. package/dist/lib/crc32c-hash.d.ts +22 -0
  22. package/dist/lib/crc32c-hash.d.ts.map +1 -0
  23. package/dist/lib/crypto-hash.d.ts +32 -0
  24. package/dist/lib/crypto-hash.d.ts.map +1 -0
  25. package/dist/lib/hash.d.ts +22 -0
  26. package/dist/lib/hash.d.ts.map +1 -0
  27. package/dist/lib/md5-hash.d.ts +15 -0
  28. package/dist/lib/md5-hash.d.ts.map +1 -0
  29. package/dist/lib/md5-hash.js.map +1 -1
  30. package/dist/lib/node-hash.d.ts +28 -0
  31. package/dist/lib/node-hash.d.ts.map +1 -0
  32. package/dist/lib/sha256-hash.d.ts +19 -0
  33. package/dist/lib/sha256-hash.d.ts.map +1 -0
  34. package/dist/lib/utils/base64-utils.d.ts +3 -2
  35. package/dist/lib/utils/base64-utils.d.ts.map +1 -0
  36. package/dist/lib/utils/base64-utils.js.map +1 -1
  37. package/dist/lib/utils/digest-utils.d.ts +6 -3
  38. package/dist/lib/utils/digest-utils.d.ts.map +1 -0
  39. package/dist/lib/utils/digest-utils.js +3 -2
  40. package/dist/lib/utils/digest-utils.js.map +1 -1
  41. package/dist/types.d.ts +10 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/worker.js +2 -5072
  44. package/dist/worker.js.map +7 -1
  45. package/dist/workers/worker.d.ts +4 -0
  46. package/dist/workers/worker.d.ts.map +1 -0
  47. package/package.json +7 -7
  48. package/src/lib/algorithms/{crc32.js → crc32.ts} +2 -0
  49. package/src/lib/algorithms/{crc32c.js → crc32c.ts} +3 -0
  50. package/src/lib/algorithms/{md5-wasm.js → md5-wasm.ts} +2 -2
  51. package/src/lib/md5-hash.ts +1 -0
  52. package/src/lib/utils/{base64-utils.js → base64-utils.ts} +3 -2
  53. package/src/lib/utils/digest-utils.ts +24 -0
  54. package/src/lib/utils/base64-utils.d.ts +0 -5
  55. package/src/lib/utils/digest-utils.d.ts +0 -6
  56. package/src/lib/utils/digest-utils.js +0 -25
@@ -0,0 +1,4 @@
1
+ import { CRC32Hash } from '../lib/crc32-hash';
2
+ import { CRC32CHash } from '../lib/crc32c-hash';
3
+ export { CRC32Hash, CRC32CHash };
4
+ //# sourceMappingURL=worker.d.ts.map
@@ -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.4",
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": "src/index.ts",
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": "webpack --display=minimal --config ../../scripts/webpack/bundle.js",
32
- "build-worker": "webpack --entry ./src/workers/worker.ts --output ./dist/worker.js --env.dev --config ../../scripts/webpack/worker.js"
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.4",
37
- "@loaders.gl/worker-utils": "4.0.0-alpha.4",
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": "53026061b3c8871f7e96d3a5826125cc6613bddc"
47
+ "gitHead": "7a71a54bdf1ddf985cc3af3db90b82e7fa97d025"
48
48
  }
@@ -4,6 +4,8 @@
4
4
  * Calculates the CRC32 checksum of a string.
5
5
  */
6
6
  export default class CRC32 {
7
+ crc: number;
8
+
7
9
  constructor() {
8
10
  this.crc = ~0;
9
11
  }
@@ -8,6 +8,9 @@
8
8
  * Calculates the CRC32C checksum of a string.
9
9
  */
10
10
  export default class CRC32C {
11
+ options;
12
+ crc: number;
13
+
11
14
  constructor(options = {}) {
12
15
  this.options = options;
13
16
  this.crc = ~0;
@@ -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
@@ -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,5 +0,0 @@
1
- /**
2
- * btoa() polyfill as defined by the HTML and Infra specs, which mostly just references
3
- * RFC 4648.
4
- */
5
- export function toBase64(string: string): string;
@@ -1,6 +0,0 @@
1
- export function toHex(cipher: number): string;
2
-
3
- /**
4
- * @see https://stackoverflow.com/questions/23190056/hex-to-base64-converter-for-javascript
5
- */
6
- export function hexToBase64(hexstring: string): string;
@@ -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
- }