@loaders.gl/crypto 4.0.0-beta.7 → 4.0.0-beta.8

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 (58) hide show
  1. package/LICENSE +7 -7
  2. package/dist/crypto-worker-node.js.map +2 -2
  3. package/dist/crypto-worker.js.map +2 -2
  4. package/dist/dist.dev.js +16 -0
  5. package/dist/index.cjs +20 -0
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/lib/algorithms/crc32.d.ts.map +1 -1
  11. package/dist/lib/algorithms/crc32.js.map +1 -1
  12. package/dist/lib/algorithms/crc32c.d.ts.map +1 -1
  13. package/dist/lib/algorithms/crc32c.js.map +1 -1
  14. package/dist/lib/algorithms/md5-wasm.d.ts.map +1 -1
  15. package/dist/lib/algorithms/md5-wasm.js.map +1 -1
  16. package/dist/lib/crc32-hash.d.ts.map +1 -1
  17. package/dist/lib/crc32-hash.js.map +1 -1
  18. package/dist/lib/crc32c-hash.d.ts.map +1 -1
  19. package/dist/lib/crc32c-hash.js.map +1 -1
  20. package/dist/lib/crypto-hash.d.ts +1 -1
  21. package/dist/lib/crypto-hash.d.ts.map +1 -1
  22. package/dist/lib/crypto-hash.js.map +1 -1
  23. package/dist/lib/hash.d.ts.map +1 -1
  24. package/dist/lib/hash.js.map +1 -1
  25. package/dist/lib/md5-hash.d.ts.map +1 -1
  26. package/dist/lib/md5-hash.js.map +1 -1
  27. package/dist/lib/node-hash.d.ts +25 -0
  28. package/dist/lib/node-hash.d.ts.map +1 -0
  29. package/dist/lib/node-hash.js +17 -0
  30. package/dist/lib/node-hash.js.map +1 -0
  31. package/dist/lib/sha256-hash.d.ts.map +1 -1
  32. package/dist/lib/sha256-hash.js.map +1 -1
  33. package/dist/lib/utils/base64-utils.d.ts.map +1 -1
  34. package/dist/lib/utils/base64-utils.js.map +1 -1
  35. package/dist/lib/utils/digest-utils.d.ts.map +1 -1
  36. package/dist/lib/utils/digest-utils.js.map +1 -1
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/types.js.map +1 -1
  39. package/dist/workers/cryptojs-worker.ts.disabled +3 -0
  40. package/dist/workers/worker.d.ts.map +1 -1
  41. package/dist/workers/worker.js.map +1 -1
  42. package/package.json +4 -4
  43. package/src/index.ts +2 -2
  44. package/src/lib/algorithms/crc32.ts +3 -0
  45. package/src/lib/algorithms/crc32c.ts +3 -0
  46. package/src/lib/algorithms/md5-wasm.ts +3 -0
  47. package/src/lib/crc32-hash.ts +3 -1
  48. package/src/lib/crc32c-hash.ts +3 -1
  49. package/src/lib/crypto-hash.ts +1 -1
  50. package/src/lib/hash.ts +3 -1
  51. package/src/lib/md5-hash.ts +3 -0
  52. package/src/lib/node-hash.ts +37 -0
  53. package/src/lib/sha256-hash.ts +3 -1
  54. package/src/lib/utils/base64-utils.ts +3 -0
  55. package/src/lib/utils/digest-utils.ts +1 -0
  56. package/src/types.ts +3 -0
  57. package/src/workers/cryptojs-worker.ts.disabled +3 -0
  58. package/src/workers/worker.ts +3 -0
@@ -1 +1 @@
1
- {"version":3,"file":"sha256-hash.js","names":["CryptoHash","SHA256Hash","constructor","options","crypto","algorithm"],"sources":["../../src/lib/sha256-hash.ts"],"sourcesContent":["//\nimport {CryptoHash} from './crypto-hash';\n\ntype CryptoHashOptions = {\n modules: {[moduleName: string]: any};\n crypto?: {\n onEnd?: (result: {hash: string}) => any;\n };\n};\n\n/**\n * A transform that calculates Cryptographic Hash\n */\nexport class SHA256Hash extends CryptoHash {\n constructor(options: CryptoHashOptions) {\n super({...options, crypto: {...options.crypto, algorithm: 'SHA256'}});\n }\n}\n"],"mappings":"SACQA,UAAU;AAYlB,OAAO,MAAMC,UAAU,SAASD,UAAU,CAAC;EACzCE,WAAWA,CAACC,OAA0B,EAAE;IACtC,KAAK,CAAC;MAAC,GAAGA,OAAO;MAAEC,MAAM,EAAE;QAAC,GAAGD,OAAO,CAACC,MAAM;QAAEC,SAAS,EAAE;MAAQ;IAAC,CAAC,CAAC;EACvE;AACF"}
1
+ {"version":3,"file":"sha256-hash.js","names":["CryptoHash","SHA256Hash","constructor","options","crypto","algorithm"],"sources":["../../src/lib/sha256-hash.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {CryptoHash} from './crypto-hash';\n\ntype CryptoHashOptions = {\n modules: {[moduleName: string]: any};\n crypto?: {\n onEnd?: (result: {hash: string}) => any;\n };\n};\n\n/**\n * A transform that calculates Cryptographic Hash\n */\nexport class SHA256Hash extends CryptoHash {\n constructor(options: CryptoHashOptions) {\n super({...options, crypto: {...options.crypto, algorithm: 'SHA256'}});\n }\n}\n"],"mappings":"SAGQA,UAAU;AAYlB,OAAO,MAAMC,UAAU,SAASD,UAAU,CAAC;EACzCE,WAAWA,CAACC,OAA0B,EAAE;IACtC,KAAK,CAAC;MAAC,GAAGA,OAAO;MAAEC,MAAM,EAAE;QAAC,GAAGD,OAAO,CAACC,MAAM;QAAEC,SAAS,EAAE;MAAQ;IAAC,CAAC,CAAC;EACvE;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"base64-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/base64-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkC3D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA4ElD"}
1
+ {"version":3,"file":"base64-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/base64-utils.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkC3D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA4ElD"}
@@ -1 +1 @@
1
- {"version":3,"file":"base64-utils.js","names":["asciiToBase64","string","i","length","charCodeAt","out","groupsOfSix","undefined","j","btoaLookup","base64ToAscii","data","replace","test","output","buffer","accumulatedBits","atobLookup","String","fromCharCode","keystr","chr","index","indexOf","idx"],"sources":["../../../src/lib/utils/base64-utils.ts"],"sourcesContent":["/**\n * `btoa()` polyfill as defined by the HTML and Infra specs, which mostly just references\n * RFC 4648.\n */\nexport function asciiToBase64(string: string): string | null {\n // String conversion as required by Web IDL.\n string = `${string}`;\n // \"The btoa() method must throw an \"InvalidCharacterError\" DOMException if\n // data contains any character whose code point is greater than U+00FF.\"\n for (let i = 0; i < string.length; i++) {\n if (string.charCodeAt(i) > 255) {\n return null;\n }\n }\n let out = '';\n for (let i = 0; i < string.length; i += 3) {\n /** @type {Array[4]} */\n const groupsOfSix: (number | undefined)[] = [undefined, undefined, undefined, undefined];\n groupsOfSix[0] = string.charCodeAt(i) >> 2;\n groupsOfSix[1] = (string.charCodeAt(i) & 0x03) << 4;\n if (string.length > i + 1) {\n groupsOfSix[1] |= string.charCodeAt(i + 1) >> 4;\n groupsOfSix[2] = (string.charCodeAt(i + 1) & 0x0f) << 2;\n }\n if (string.length > i + 2) {\n // @ts-expect-error\n groupsOfSix[2] |= string.charCodeAt(i + 2) >> 6;\n groupsOfSix[3] = string.charCodeAt(i + 2) & 0x3f;\n }\n for (let j = 0; j < groupsOfSix.length; j++) {\n if (typeof groupsOfSix[j] === 'undefined') {\n out += '=';\n } else {\n out += btoaLookup(groupsOfSix[j]);\n }\n }\n }\n return out;\n}\n\n/**\n * Implementation of atob() according to the HTML and Infra specs, except that\n * instead of throwing INVALID_CHARACTER_ERR we return null.\n *\n * @note Forked from https://github.com/jsdom/abab under BSD 3 clause license\n */\nexport function base64ToAscii(data: string): string {\n // Web IDL requires DOMStrings to just be converted using ECMAScript\n // ToString, which in our case amounts to using a template literal.\n data = `${data}`;\n // \"Remove all ASCII whitespace from data.\"\n data = data.replace(/[ \\t\\n\\f\\r]/g, '');\n // \"If data's code point length divides by 4 leaving no remainder, then: if data ends\n // with one or two U+003D (=) code points, then remove them from data.\"\n if (data.length % 4 === 0) {\n data = data.replace(/[=]=?$/, '');\n }\n // \"If data's code point length divides by 4 leaving a remainder of 1, then return\n // failure.\"\n //\n // \"If data contains a code point that is not one of\n //\n // U+002B (+)\n // U+002F (/)\n // ASCII alphanumeric\n //\n // then return failure.\"\n if (data.length % 4 === 1 || /[^+/0-9A-Za-z]/.test(data)) {\n return '';\n }\n // \"Let output be an empty byte sequence.\"\n let output = '';\n // \"Let buffer be an empty buffer that can have bits appended to it.\"\n //\n // We append bits via left-shift and or. accumulatedBits is used to track\n // when we've gotten to 24 bits.\n let buffer = 0;\n let accumulatedBits = 0;\n // \"Let position be a position variable for data, initially pointing at the\n // start of data.\"\n //\n // \"While position does not point past the end of data:\"\n for (let i = 0; i < data.length; i++) {\n // \"Find the code point pointed to by position in the second column of\n // Table 1: The Base 64 Alphabet of RFC 4648. Let n be the number given in\n // the first cell of the same row.\n //\n // \"Append to buffer the six bits corresponding to n, most significant bit\n // first.\"\n //\n // atobLookup() implements the table from RFC 4648.\n buffer <<= 6;\n // @ts-expect-error\n buffer |= atobLookup(data[i]);\n accumulatedBits += 6;\n // \"If buffer has accumulated 24 bits, interpret them as three 8-bit\n // big-endian numbers. Append three bytes with values equal to those\n // numbers to output, in the same order, and then empty buffer.\"\n if (accumulatedBits === 24) {\n output += String.fromCharCode((buffer & 0xff0000) >> 16);\n output += String.fromCharCode((buffer & 0xff00) >> 8);\n output += String.fromCharCode(buffer & 0xff);\n buffer = accumulatedBits = 0;\n }\n // \"Advance position by 1.\"\n }\n // \"If buffer is not empty, it contains either 12 or 18 bits. If it contains\n // 12 bits, then discard the last four and interpret the remaining eight as\n // an 8-bit big-endian number. If it contains 18 bits, then discard the last\n // two and interpret the remaining 16 as two 8-bit big-endian numbers. Append\n // the one or two bytes with values equal to those one or two numbers to\n // output, in the same order.\"\n if (accumulatedBits === 12) {\n buffer >>= 4;\n output += String.fromCharCode(buffer);\n } else if (accumulatedBits === 18) {\n buffer >>= 2;\n output += String.fromCharCode((buffer & 0xff00) >> 8);\n output += String.fromCharCode(buffer & 0xff);\n }\n // \"Return output.\"\n return output;\n}\n/**\n * A lookup table for atob(), which converts an ASCII character to the\n * corresponding six-bit number.\n */\n\nconst keystr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\nfunction atobLookup(chr: string): number | undefined {\n const index = keystr.indexOf(chr);\n // Throw exception if character is not in the lookup string; should not be hit in tests\n return index < 0 ? undefined : index;\n}\n\n/**\n * Lookup table for btoa(), which converts a six-bit number into the\n * corresponding ASCII character.\n */\nfunction btoaLookup(idx) {\n if (idx < 26) {\n return String.fromCharCode(idx + 'A'.charCodeAt(0));\n }\n if (idx < 52) {\n return String.fromCharCode(idx - 26 + 'a'.charCodeAt(0));\n }\n if (idx < 62) {\n return String.fromCharCode(idx - 52 + '0'.charCodeAt(0));\n }\n if (idx === 62) {\n return '+';\n }\n if (idx === 63) {\n return '/';\n }\n // Throw INVALID_CHARACTER_ERR exception here -- won't be hit in the teststring.\n return undefined;\n}\n"],"mappings":"AAIA,OAAO,SAASA,aAAaA,CAACC,MAAc,EAAiB;EAE3DA,MAAM,GAAI,GAAEA,MAAO,EAAC;EAGpB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,MAAM,CAACE,MAAM,EAAED,CAAC,EAAE,EAAE;IACtC,IAAID,MAAM,CAACG,UAAU,CAACF,CAAC,CAAC,GAAG,GAAG,EAAE;MAC9B,OAAO,IAAI;IACb;EACF;EACA,IAAIG,GAAG,GAAG,EAAE;EACZ,KAAK,IAAIH,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,MAAM,CAACE,MAAM,EAAED,CAAC,IAAI,CAAC,EAAE;IAEzC,MAAMI,WAAmC,GAAG,CAACC,SAAS,EAAEA,SAAS,EAAEA,SAA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,IAAI,CAAC;EAC9C;EAEA,OAAOD,MAAM;AACf;AAMA,MAAMM,MAAM,GAAG,kEAAkE;AAEjF,SAASH,UAAUA,CAACI,GAAW,EAAsB;EACnD,MAAMC,KAAK,GAAGF,MAAM,CAACG,OAAO,CAACF,GAAG,CAAC;EAEjC,OAAOC,KAAK,GAAG,CAAC,GAAGf,SAAS,GAAGe,KAAK;AACtC;AAMA,SAASb,UAAUA,CAACe,GAAG,EAAE;EACvB,IAAIA,GAAG,GAAG,EAAE,EAAE;IACZ,OAAON,MAAM,CAACC,YAAY,CAACK,GAAG,GAAG,GAAG,CAACpB,UAAU,CAAC,CAAC,CAAC,CAAC;EACrD;EACA,IAAIoB,GAAG,GAAG,EAAE,EAAE;IACZ,OAAON,MAAM,CAACC,YAAY,CAACK,GAAG,GAAG,EAAE,GAAG,GAAG,CAACpB,UAAU,CAAC,CAAC,CAAC,CAAC;EAC1D;EACA,IAAIoB,GAAG,GAAG,EAAE,EAAE;IACZ,OAAON,MAAM,CAACC,YAAY,CAACK,GAAG,GAAG,EAAE,GAAG,GAAG,CAACpB,UAAU,CAAC,CAAC,CAAC,CAAC;EAC1D;EACA,IAAIoB,GAAG,KAAK,EAAE,EAAE;IACd,OAAO,GAAG;EACZ;EACA,IAAIA,GAAG,KAAK,EAAE,EAAE;IACd,OAAO,GAAG;EACZ;EAEA,OAAOjB,SAAS;AAClB"}
1
+ {"version":3,"file":"base64-utils.js","names":["asciiToBase64","string","i","length","charCodeAt","out","groupsOfSix","undefined","j","btoaLookup","base64ToAscii","data","replace","test","output","buffer","accumulatedBits","atobLookup","String","fromCharCode","keystr","chr","index","indexOf","idx"],"sources":["../../../src/lib/utils/base64-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n/**\n * `btoa()` polyfill as defined by the HTML and Infra specs, which mostly just references\n * RFC 4648.\n */\nexport function asciiToBase64(string: string): string | null {\n // String conversion as required by Web IDL.\n string = `${string}`;\n // \"The btoa() method must throw an \"InvalidCharacterError\" DOMException if\n // data contains any character whose code point is greater than U+00FF.\"\n for (let i = 0; i < string.length; i++) {\n if (string.charCodeAt(i) > 255) {\n return null;\n }\n }\n let out = '';\n for (let i = 0; i < string.length; i += 3) {\n /** @type {Array[4]} */\n const groupsOfSix: (number | undefined)[] = [undefined, undefined, undefined, undefined];\n groupsOfSix[0] = string.charCodeAt(i) >> 2;\n groupsOfSix[1] = (string.charCodeAt(i) & 0x03) << 4;\n if (string.length > i + 1) {\n groupsOfSix[1] |= string.charCodeAt(i + 1) >> 4;\n groupsOfSix[2] = (string.charCodeAt(i + 1) & 0x0f) << 2;\n }\n if (string.length > i + 2) {\n // @ts-expect-error\n groupsOfSix[2] |= string.charCodeAt(i + 2) >> 6;\n groupsOfSix[3] = string.charCodeAt(i + 2) & 0x3f;\n }\n for (let j = 0; j < groupsOfSix.length; j++) {\n if (typeof groupsOfSix[j] === 'undefined') {\n out += '=';\n } else {\n out += btoaLookup(groupsOfSix[j]);\n }\n }\n }\n return out;\n}\n\n/**\n * Implementation of atob() according to the HTML and Infra specs, except that\n * instead of throwing INVALID_CHARACTER_ERR we return null.\n *\n * @note Forked from https://github.com/jsdom/abab under BSD 3 clause license\n */\nexport function base64ToAscii(data: string): string {\n // Web IDL requires DOMStrings to just be converted using ECMAScript\n // ToString, which in our case amounts to using a template literal.\n data = `${data}`;\n // \"Remove all ASCII whitespace from data.\"\n data = data.replace(/[ \\t\\n\\f\\r]/g, '');\n // \"If data's code point length divides by 4 leaving no remainder, then: if data ends\n // with one or two U+003D (=) code points, then remove them from data.\"\n if (data.length % 4 === 0) {\n data = data.replace(/[=]=?$/, '');\n }\n // \"If data's code point length divides by 4 leaving a remainder of 1, then return\n // failure.\"\n //\n // \"If data contains a code point that is not one of\n //\n // U+002B (+)\n // U+002F (/)\n // ASCII alphanumeric\n //\n // then return failure.\"\n if (data.length % 4 === 1 || /[^+/0-9A-Za-z]/.test(data)) {\n return '';\n }\n // \"Let output be an empty byte sequence.\"\n let output = '';\n // \"Let buffer be an empty buffer that can have bits appended to it.\"\n //\n // We append bits via left-shift and or. accumulatedBits is used to track\n // when we've gotten to 24 bits.\n let buffer = 0;\n let accumulatedBits = 0;\n // \"Let position be a position variable for data, initially pointing at the\n // start of data.\"\n //\n // \"While position does not point past the end of data:\"\n for (let i = 0; i < data.length; i++) {\n // \"Find the code point pointed to by position in the second column of\n // Table 1: The Base 64 Alphabet of RFC 4648. Let n be the number given in\n // the first cell of the same row.\n //\n // \"Append to buffer the six bits corresponding to n, most significant bit\n // first.\"\n //\n // atobLookup() implements the table from RFC 4648.\n buffer <<= 6;\n // @ts-expect-error\n buffer |= atobLookup(data[i]);\n accumulatedBits += 6;\n // \"If buffer has accumulated 24 bits, interpret them as three 8-bit\n // big-endian numbers. Append three bytes with values equal to those\n // numbers to output, in the same order, and then empty buffer.\"\n if (accumulatedBits === 24) {\n output += String.fromCharCode((buffer & 0xff0000) >> 16);\n output += String.fromCharCode((buffer & 0xff00) >> 8);\n output += String.fromCharCode(buffer & 0xff);\n buffer = accumulatedBits = 0;\n }\n // \"Advance position by 1.\"\n }\n // \"If buffer is not empty, it contains either 12 or 18 bits. If it contains\n // 12 bits, then discard the last four and interpret the remaining eight as\n // an 8-bit big-endian number. If it contains 18 bits, then discard the last\n // two and interpret the remaining 16 as two 8-bit big-endian numbers. Append\n // the one or two bytes with values equal to those one or two numbers to\n // output, in the same order.\"\n if (accumulatedBits === 12) {\n buffer >>= 4;\n output += String.fromCharCode(buffer);\n } else if (accumulatedBits === 18) {\n buffer >>= 2;\n output += String.fromCharCode((buffer & 0xff00) >> 8);\n output += String.fromCharCode(buffer & 0xff);\n }\n // \"Return output.\"\n return output;\n}\n/**\n * A lookup table for atob(), which converts an ASCII character to the\n * corresponding six-bit number.\n */\n\nconst keystr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\nfunction atobLookup(chr: string): number | undefined {\n const index = keystr.indexOf(chr);\n // Throw exception if character is not in the lookup string; should not be hit in tests\n return index < 0 ? undefined : index;\n}\n\n/**\n * Lookup table for btoa(), which converts a six-bit number into the\n * corresponding ASCII character.\n */\nfunction btoaLookup(idx) {\n if (idx < 26) {\n return String.fromCharCode(idx + 'A'.charCodeAt(0));\n }\n if (idx < 52) {\n return String.fromCharCode(idx - 26 + 'a'.charCodeAt(0));\n }\n if (idx < 62) {\n return String.fromCharCode(idx - 52 + '0'.charCodeAt(0));\n }\n if (idx === 62) {\n return '+';\n }\n if (idx === 63) {\n return '/';\n }\n // Throw INVALID_CHARACTER_ERR exception here -- won't be hit in the teststring.\n return undefined;\n}\n"],"mappings":"AAOA,OAAO,SAASA,aAAaA,CAACC,MAAc,EAAiB;EAE3DA,MAAM,GAAI,GAAEA,MAAO,EAAC;EAGpB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,MAAM,CAACE,MAAM,EAAED,CAAC,EAAE,EAAE;IACtC,IAAID,MAAM,CAACG,UAAU,CAACF,CAAC,CAAC,GAAG,GAAG,EAAE;MAC9B,OAAO,IAAI;IACb;EACF;EACA,IAAIG,GAAG,GAAG,EAAE;EACZ,KAAK,IAAIH,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,MAAM,CAACE,MAAM,EAAED,CAAC,IAAI,CAAC,EAAE;IAEzC,MAAMI,WAAmC,GAAG,CAACC,SAAS,EAAEA,SAAS,EAAEA,SAAS,EAAEA,SAAS,CAAC;IACxFD,WAAW,CAAC,CAAC,CAAC,GAAGL,MAAM,CAACG,UAAU,CAACF,CAAC,CAAC,IAAI,CAAC;IAC1CI,WAAW,CAAC,CAAC,CAAC,GAAG,CAACL,MAAM,CAACG,UAAU,CAACF,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC;IACnD,IAAID,MAAM,CAACE,MAAM,GAAGD,CAAC,GAAG,CAAC,EAAE;MACzBI,WAAW,CAAC,CAAC,CAAC,IAAIL,MAAM,CAACG,UAAU,CAACF,CAAC,G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YAAY,CAACK,GAAG,GAAG,GAAG,CAACpB,UAAU,CAAC,CAAC,CAAC,CAAC;EACrD;EACA,IAAIoB,GAAG,GAAG,EAAE,EAAE;IACZ,OAAON,MAAM,CAACC,YAAY,CAACK,GAAG,GAAG,EAAE,GAAG,GAAG,CAACpB,UAAU,CAAC,CAAC,CAAC,CAAC;EAC1D;EACA,IAAIoB,GAAG,GAAG,EAAE,EAAE;IACZ,OAAON,MAAM,CAACC,YAAY,CAACK,GAAG,GAAG,EAAE,GAAG,GAAG,CAACpB,UAAU,CAAC,CAAC,CAAC,CAAC;EAC1D;EACA,IAAIoB,GAAG,KAAK,EAAE,EAAE;IACd,OAAO,GAAG;EACZ;EACA,IAAIA,GAAG,KAAK,EAAE,EAAE;IACd,OAAO,GAAG;EACZ;EAEA,OAAOjB,SAAS;AAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"digest-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/digest-utils.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAS/E;AAED,qEAAqE;AACrE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CASzE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAS/E"}
1
+ {"version":3,"file":"digest-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/digest-utils.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAS/E;AAED,qEAAqE;AACrE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CASzE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAS/E"}
@@ -1 +1 @@
1
- {"version":3,"file":"digest-utils.js","names":["asciiToBase64","base64ToAscii","encodeNumber","number","encoding","convertNumberToHex","convertHexToBase64","Error","encodeHex","hex","encodeBase64","base64","convertBase64ToHex","hexstring","length","matches","match","string","map","a","String","fromCharCode","parseInt","join","base64String","c","charCodeAt","toString","padStart","cipher","hexString"],"sources":["../../../src/lib/utils/digest-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {asciiToBase64, base64ToAscii} from './base64-utils';\n\n/**\n * Encode a number (usually a digest from a hash function / cipher) as either hex or base64\n * Suitable for hashes like CRC32 where the number of required bits fit withing a JavaScript number.\n */\nexport function encodeNumber(number: number, encoding: 'hex' | 'base64'): string {\n switch (encoding) {\n case 'hex':\n return convertNumberToHex(number);\n case 'base64':\n return convertHexToBase64(convertNumberToHex(number));\n default:\n throw new Error(encoding);\n }\n}\n\n/** Encode a hex string, aeither return hex or re-encode as base64 */\nexport function encodeHex(hex: string, encoding: 'hex' | 'base64'): string {\n switch (encoding) {\n case 'hex':\n return hex;\n case 'base64':\n return convertHexToBase64(hex);\n default:\n throw new Error(encoding);\n }\n}\n\nexport function encodeBase64(base64: string, encoding: 'hex' | 'base64'): string {\n switch (encoding) {\n case 'hex':\n return convertBase64ToHex(base64);\n case 'base64':\n return base64;\n default:\n throw new Error(encoding);\n }\n}\n\n/**\n * Convert a hexadecimal string to base64 encoded string representation\n */\nfunction convertHexToBase64(hexstring: string): string {\n // Add leading zero to keep even count of digits\n // eg. f85d741 => 0f85d741\n if (hexstring.length % 2 !== 0) {\n hexstring = `0${hexstring}`;\n }\n const matches = hexstring.match(/\\w{2}/g) || [];\n const string = matches.map((a) => String.fromCharCode(parseInt(a, 16))).join('');\n // TODO - define how to handle failures\n return asciiToBase64(string) || '';\n}\n\n/**\n * Convert a base64 encoded string to hexadecimal encoded string representation\n */\nfunction convertBase64ToHex(base64String: string): string {\n return [...base64ToAscii(base64String)]\n .map((c) => c.charCodeAt(0).toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * Converts a number to hex\n */\nfunction convertNumberToHex(cipher: number): string {\n const hexString = cipher.toString(16);\n return hexString === '0' ? `0${hexString}` : hexString;\n}\n"],"mappings":"SAEQA,aAAa,EAAEC,aAAa;AAMpC,OAAO,SAASC,YAAYA,CAACC,MAAc,EAAEC,QAA0B,EAAU;EAC/E,QAAQA,QAAQ;IACd,KAAK,KAAK;MACR,OAAOC,kBAAkB,CAACF,MAAM,CAAC;IACnC,KAAK,QAAQ;MACX,OAAOG,kBAAkB,CAACD,kBAAkB,CAACF,MAAM,CAAC,CAAC;IACvD;MACE,MAAM,IAAII,KAAK,CAACH,QAAQ,CAAC;EAC7B;AACF;AAGA,OAAO,SAASI,SAASA,CAACC,GAAW,EAAEL,QAA0B,EAAU;EACzE,QAAQA,QAAQ;IACd,KAAK,KAAK;MACR,OAAOK,GAAG;IACZ,KAAK,QAAQ;MACX,OAAOH,kBAAkB,CAACG,GAAG,CAAC;IAChC;MACE,MAAM,IAAIF,KAAK,CAACH,QAAQ,CAAC;EAC7B;AACF;AAEA,OAAO,SAASM,YAAYA,CAACC,MAAc,EAAEP,QAA0B,EAAU;EAC/E,QAAQA,QAAQ;IACd,KAAK,KAAK;MACR,OAAOQ,kBAAkB,CAACD,MAAM,CAAC;IACnC,KAAK,QAAQ;MACX,OAAOA,MAAM;IACf;MACE,MAAM,IAAIJ,KAAK,CAACH,QAAQ,CAAC;EAC7B;AACF;AAKA,SAASE,kBAAkBA,CAACO,SAAiB,EAAU;EAGrD,IAAIA,SAAS,CAACC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;IAC9BD,SAAS,GAAI,IAAGA,SAAU,EAAC;EAC7B;EACA,MAAME,OAAO,GAAGF,SAAS,CAACG,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE;EAC/C,MAAMC,MAAM,GAAGF,OAAO,CAACG,GAAG,CAAEC,CAAC,IAAKC,MAAM,CAACC,YAAY,CAACC,QAAQ,CAACH,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAACI,IAAI,CAAC,EAAE,CAAC;EAEhF,OAAOvB,aAAa,CAACiB,MAAM,CAAC,IAAI,EAAE;AACpC;AAKA,SAASL,kBAAkBA,CAACY,YAAoB,EAAU;EACxD,OAAO,CAAC,GAAGvB,aAAa,CAACuB,YAAY,CAAC,CAAC,CACpCN,GAAG,CAAEO,CAAC,IAAKA,CAAC,CAACC,UAAU,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CACzDL,IAAI,CAAC,EAAE,CAAC;AACb;AAKA,SAASlB,kBAAkBA,CAACwB,MAAc,EAAU;EAClD,MAAMC,SAAS,GAAGD,MAAM,CAACF,QAAQ,CAAC,EAAE,CAAC;EACrC,OAAOG,SAAS,KAAK,GAAG,GAAI,IAAGA,SAAU,EAAC,GAAGA,SAAS;AACxD"}
1
+ {"version":3,"file":"digest-utils.js","names":["asciiToBase64","base64ToAscii","encodeNumber","number","encoding","convertNumberToHex","convertHexToBase64","Error","encodeHex","hex","encodeBase64","base64","convertBase64ToHex","hexstring","length","matches","match","string","map","a","String","fromCharCode","parseInt","join","base64String","c","charCodeAt","toString","padStart","cipher","hexString"],"sources":["../../../src/lib/utils/digest-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {asciiToBase64, base64ToAscii} from './base64-utils';\n\n/**\n * Encode a number (usually a digest from a hash function / cipher) as either hex or base64\n * Suitable for hashes like CRC32 where the number of required bits fit withing a JavaScript number.\n */\nexport function encodeNumber(number: number, encoding: 'hex' | 'base64'): string {\n switch (encoding) {\n case 'hex':\n return convertNumberToHex(number);\n case 'base64':\n return convertHexToBase64(convertNumberToHex(number));\n default:\n throw new Error(encoding);\n }\n}\n\n/** Encode a hex string, aeither return hex or re-encode as base64 */\nexport function encodeHex(hex: string, encoding: 'hex' | 'base64'): string {\n switch (encoding) {\n case 'hex':\n return hex;\n case 'base64':\n return convertHexToBase64(hex);\n default:\n throw new Error(encoding);\n }\n}\n\nexport function encodeBase64(base64: string, encoding: 'hex' | 'base64'): string {\n switch (encoding) {\n case 'hex':\n return convertBase64ToHex(base64);\n case 'base64':\n return base64;\n default:\n throw new Error(encoding);\n }\n}\n\n/**\n * Convert a hexadecimal string to base64 encoded string representation\n */\nfunction convertHexToBase64(hexstring: string): string {\n // Add leading zero to keep even count of digits\n // eg. f85d741 => 0f85d741\n if (hexstring.length % 2 !== 0) {\n hexstring = `0${hexstring}`;\n }\n const matches = hexstring.match(/\\w{2}/g) || [];\n const string = matches.map((a) => String.fromCharCode(parseInt(a, 16))).join('');\n // TODO - define how to handle failures\n return asciiToBase64(string) || '';\n}\n\n/**\n * Convert a base64 encoded string to hexadecimal encoded string representation\n */\nfunction convertBase64ToHex(base64String: string): string {\n return [...base64ToAscii(base64String)]\n .map((c) => c.charCodeAt(0).toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * Converts a number to hex\n */\nfunction convertNumberToHex(cipher: number): string {\n const hexString = cipher.toString(16);\n return hexString === '0' ? `0${hexString}` : hexString;\n}\n"],"mappings":"SAGQA,aAAa,EAAEC,aAAa;AAMpC,OAAO,SAASC,YAAYA,CAACC,MAAc,EAAEC,QAA0B,EAAU;EAC/E,QAAQA,QAAQ;IACd,KAAK,KAAK;MACR,OAAOC,kBAAkB,CAACF,MAAM,CAAC;IACnC,KAAK,QAAQ;MACX,OAAOG,kBAAkB,CAACD,kBAAkB,CAACF,MAAM,CAAC,CAAC;IACvD;MACE,MAAM,IAAII,KAAK,CAACH,QAAQ,CAAC;EAC7B;AACF;AAGA,OAAO,SAASI,SAASA,CAACC,GAAW,EAAEL,QAA0B,EAAU;EACzE,QAAQA,Q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CAAC;EACrC,OAAOG,SAAS,KAAK,GAAG,GAAI,IAAGA,SAAU,EAAC,GAAGA,SAAS;AACxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;IACtC,MAAM,CAAC,EAAE;QACP,SAAS,MAAC;QACV,KAAK,CAAC,MAAC;KACR,CAAC;CACH,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;IACtC,MAAM,CAAC,EAAE;QACP,SAAS,MAAC;QACV,KAAK,CAAC,MAAC;KACR,CAAC;CACH,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["export type CryptoHashOptions = {\n modules?: {[moduleName: string]: any};\n crypto?: {\n algorithm;\n onEnd?;\n };\n};\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nexport type CryptoHashOptions = {\n modules?: {[moduleName: string]: any};\n crypto?: {\n algorithm;\n onEnd?;\n };\n};\n"],"mappings":""}
@@ -1,3 +1,6 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
1
4
  import type {CryptoHashOptions} from '../lib/crypto-hash';
2
5
  import {createWorker} from '@loaders.gl/worker-utils';
3
6
  import {CryptoHash} from '../lib/crypto-hash';
@@ -1 +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"}
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/workers/worker.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAI9C,OAAO,EAAC,SAAS,EAAE,UAAU,EAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","names":["createWorker","CRC32Hash","CRC32CHash","MD5Hash","data","options","arguments","length","undefined","operation","encoding","hash","Error"],"sources":["../../src/workers/worker.ts"],"sourcesContent":["import {createWorker} from '@loaders.gl/worker-utils';\nimport {CRC32Hash} from '../lib/crc32-hash';\nimport {CRC32CHash} from '../lib/crc32c-hash';\nimport {MD5Hash} from '../lib/md5-hash';\n\n// Assuming we can bundle as module\nexport {CRC32Hash, CRC32CHash};\n\ncreateWorker(async (data, options = {}) => {\n // @ts-ignore\n const {operation, encoding = 'base64'} = options;\n\n switch (operation) {\n case 'crc32':\n return await new CRC32Hash(options).hash(data, encoding);\n case 'crc32c':\n return await new CRC32CHash(options).hash(data, encoding);\n case 'md5':\n return await new MD5Hash(options).hash(data, encoding);\n default:\n throw new Error(`invalid option: ${operation}`);\n }\n});\n"],"mappings":"AAAA,SAAQA,YAAY,QAAO,0BAA0B;AAAC,SAC9CC,SAAS;AAAA,SACTC,UAAU;AAAA,SACVC,OAAO;AAGf,SAAQF,SAAS,EAAEC,UAAU;AAE7BF,YAAY,CAAC,gBAAOI,IAAI,EAAmB;EAAA,IAAjBC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEpC,MAAM;IAACG,SAAS;IAAEC,QAAQ,GAAG;EAAQ,CAAC,GAAGL,OAAO;EAEhD,QAAQI,SAAS;IACf,KAAK,OAAO;MACV,OAAO,MAAM,IAAIR,SAAS,CAACI,OAAO,CAAC,CAACM,IAAI,CAACP,IAAI,EAAEM,QAAQ,CAAC;IAC1D,KAAK,QAAQ;MACX,OAAO,MAAM,IAAIR,UAAU,CAACG,OAAO,CAAC,CAACM,IAAI,CAACP,IAAI,EAAEM,QAAQ,CAAC;IAC3D,KAAK,KAAK;MACR,OAAO,MAAM,IAAIP,OAAO,CAACE,OAAO,CAAC,CAACM,IAAI,CAACP,IAAI,EAAEM,QAAQ,CAAC;IACxD;MACE,MAAM,IAAIE,KAAK,CAAE,mBAAkBH,SAAU,EAAC,CAAC;EACnD;AACF,CAAC,CAAC"}
1
+ {"version":3,"file":"worker.js","names":["createWorker","CRC32Hash","CRC32CHash","MD5Hash","data","options","arguments","length","undefined","operation","encoding","hash","Error"],"sources":["../../src/workers/worker.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {createWorker} from '@loaders.gl/worker-utils';\nimport {CRC32Hash} from '../lib/crc32-hash';\nimport {CRC32CHash} from '../lib/crc32c-hash';\nimport {MD5Hash} from '../lib/md5-hash';\n\n// Assuming we can bundle as module\nexport {CRC32Hash, CRC32CHash};\n\ncreateWorker(async (data, options = {}) => {\n // @ts-ignore\n const {operation, encoding = 'base64'} = options;\n\n switch (operation) {\n case 'crc32':\n return await new CRC32Hash(options).hash(data, encoding);\n case 'crc32c':\n return await new CRC32CHash(options).hash(data, encoding);\n case 'md5':\n return await new MD5Hash(options).hash(data, encoding);\n default:\n throw new Error(`invalid option: ${operation}`);\n }\n});\n"],"mappings":"AAGA,SAAQA,YAAY,QAAO,0BAA0B;AAAC,SAC9CC,SAAS;AAAA,SACTC,UAAU;AAAA,SACVC,OAAO;AAGf,SAAQF,SAAS,EAAEC,UAAU;AAE7BF,YAAY,CAAC,gBAAOI,IAAI,EAAmB;EAAA,IAAjBC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEpC,MAAM;IAACG,SAAS;IAAEC,QAAQ,GAAG;EAAQ,CAAC,GAAGL,OAAO;EAEhD,QAAQI,SAAS;IACf,KAAK,OAAO;MACV,OAAO,MAAM,IAAIR,SAAS,CAACI,OAAO,CAAC,CAACM,IAAI,CAACP,IAAI,EAAEM,QAAQ,CAAC;IAC1D,KAAK,QAAQ;MACX,OAAO,MAAM,IAAIR,UAAU,CAACG,OAAO,CAAC,CAACM,IAAI,CAACP,IAAI,EAAEM,QAAQ,CAAC;IAC3D,KAAK,KAAK;MACR,OAAO,MAAM,IAAIP,OAAO,CAACE,OAAO,CAAC,CAACM,IAAI,CAACP,IAAI,EAAEM,QAAQ,CAAC;IACxD;MACE,MAAM,IAAIE,KAAK,CAAE,mBAAkBH,SAAU,EAAC,CAAC;EACnD;AACF,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/crypto",
3
- "version": "4.0.0-beta.7",
3
+ "version": "4.0.0-beta.8",
4
4
  "description": "Cryptographic/hashing plugins for loaders.gl",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -42,8 +42,8 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@babel/runtime": "^7.3.1",
45
- "@loaders.gl/loader-utils": "4.0.0-beta.7",
46
- "@loaders.gl/worker-utils": "4.0.0-beta.7",
45
+ "@loaders.gl/loader-utils": "4.0.0-beta.8",
46
+ "@loaders.gl/worker-utils": "4.0.0-beta.8",
47
47
  "@types/crypto-js": "^4.0.2"
48
48
  },
49
49
  "devDependencies": {
@@ -53,5 +53,5 @@
53
53
  "crypto": false,
54
54
  "sse4_crc32": false
55
55
  },
56
- "gitHead": "5b6cab0ab5d73212cfa37fa5da6e25ad7ef83fe5"
56
+ "gitHead": "ec3d1747b4c01c52a235455d6462680e711b4e19"
57
57
  }
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
2
3
 
3
4
  // __VERSION__ is injected by babel-plugin-version-inline
4
5
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
@@ -12,8 +13,7 @@ export {MD5Hash} from './lib/md5-hash';
12
13
  export {SHA256Hash} from './lib/sha256-hash';
13
14
 
14
15
  export {CryptoHash} from './lib/crypto-hash';
15
- // TODO - moved to polyfills
16
- // export {NodeHash} from './lib/node-hash';
16
+ export {NodeHash} from './lib/node-hash';
17
17
 
18
18
  /**
19
19
  * Small, fast worker for CRC32, CRC32c and MD5 Hashes
@@ -1,3 +1,6 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
1
4
  // Inspired by https://gist.github.com/wqli78/1330293/6d85cc967f32cccfcbad94ae7d088a3dcfc14bd9
2
5
 
3
6
  /**
@@ -1,3 +1,6 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
1
4
  // From: https://gist.github.com/wqli78/1330293/6d85cc967f32cccfcbad94ae7d088a3dcfc14bd9
2
5
  // CRC32 doesn't appear to be supported natively by crypto-js
3
6
 
@@ -1,3 +1,6 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
1
4
  /* eslint-disable */
2
5
  // @ts-nocheck
3
6
  /* !
@@ -1,4 +1,6 @@
1
- // CRC32
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
2
4
  import {Hash} from './hash';
3
5
  import CRC32 from './algorithms/crc32';
4
6
  import {encodeNumber} from './utils/digest-utils';
@@ -1,4 +1,6 @@
1
- // CRC32c
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
2
4
  import {Hash} from './hash';
3
5
  import CRC32C from './algorithms/crc32c';
4
6
  import {encodeNumber} from './utils/digest-utils';
@@ -1,7 +1,7 @@
1
1
  import {Hash} from './hash';
2
2
 
3
3
  type CryptoHashOptions = {
4
- modules: {[moduleName: string]: any};
4
+ modules?: {[moduleName: string]: any};
5
5
  crypto: {
6
6
  algorithm: string;
7
7
  onEnd?: (result: {hash: string}) => any;
package/src/lib/hash.ts CHANGED
@@ -1,4 +1,6 @@
1
- // Hash
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
2
4
  import {concatenateArrayBuffersAsync} from '@loaders.gl/loader-utils';
3
5
 
4
6
  type HashOptions = {
@@ -1,3 +1,6 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
1
4
  // Fork of https://github.com/briantbutton/md5-wasm under MIT license
2
5
  import {Hash} from './hash';
3
6
  import md5WASM from './algorithms/md5-wasm';
@@ -0,0 +1,37 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
4
+ import {Hash} from './hash';
5
+
6
+ type NodeHashOptions = {
7
+ crypto: {
8
+ algorithm: string;
9
+ onEnd?: (result: {hash: string}) => any;
10
+ };
11
+ };
12
+
13
+ /**
14
+ * A transform that calculates Cryptographic Hash using Node's Crypto library
15
+ * @deprecated Only available in Node.js
16
+ */
17
+ export class NodeHash extends Hash {
18
+ readonly name;
19
+ readonly options: NodeHashOptions;
20
+
21
+ constructor(options: NodeHashOptions) {
22
+ super();
23
+ this.options = options;
24
+ if (!globalThis.loaders.NodeHash) {
25
+ throw new Error('install @loaders.gl/crypto on Node.js to use NodeHash');
26
+ }
27
+ return new globalThis.loaders.NodeHash(options);
28
+ }
29
+
30
+ /**
31
+ * Atomic hash calculation
32
+ * @returns base64 encoded hash
33
+ */
34
+ async hash(input: ArrayBuffer, encoding: 'hex' | 'base64'): Promise<string> {
35
+ throw new Error('Not implemented');
36
+ }
37
+ }
@@ -1,4 +1,6 @@
1
- //
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
2
4
  import {CryptoHash} from './crypto-hash';
3
5
 
4
6
  type CryptoHashOptions = {
@@ -1,3 +1,6 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
1
4
  /**
2
5
  * `btoa()` polyfill as defined by the HTML and Infra specs, which mostly just references
3
6
  * RFC 4648.
@@ -1,4 +1,5 @@
1
1
  // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
2
3
 
3
4
  import {asciiToBase64, base64ToAscii} from './base64-utils';
4
5
 
package/src/types.ts CHANGED
@@ -1,3 +1,6 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
1
4
  export type CryptoHashOptions = {
2
5
  modules?: {[moduleName: string]: any};
3
6
  crypto?: {
@@ -1,3 +1,6 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
1
4
  import type {CryptoHashOptions} from '../lib/crypto-hash';
2
5
  import {createWorker} from '@loaders.gl/worker-utils';
3
6
  import {CryptoHash} from '../lib/crypto-hash';
@@ -1,3 +1,6 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
1
4
  import {createWorker} from '@loaders.gl/worker-utils';
2
5
  import {CRC32Hash} from '../lib/crc32-hash';
3
6
  import {CRC32CHash} from '../lib/crc32c-hash';