@loaders.gl/crypto 3.1.0-beta.5 → 3.1.1

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.
@@ -1,22 +1,48 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.SHA256Hash = void 0;
7
9
 
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
+
16
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
+
18
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
+
8
20
  var _cryptoHash = require("./crypto-hash");
9
21
 
10
- class SHA256Hash extends _cryptoHash.CryptoHash {
11
- constructor(options) {
12
- super({ ...options,
13
- crypto: { ...options.crypto,
22
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
23
+
24
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
25
+
26
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
27
+
28
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
+
30
+ var SHA256Hash = function (_CryptoHash) {
31
+ (0, _inherits2.default)(SHA256Hash, _CryptoHash);
32
+
33
+ var _super = _createSuper(SHA256Hash);
34
+
35
+ function SHA256Hash(options) {
36
+ (0, _classCallCheck2.default)(this, SHA256Hash);
37
+ return _super.call(this, _objectSpread(_objectSpread({}, options), {}, {
38
+ crypto: _objectSpread(_objectSpread({}, options.crypto), {}, {
14
39
  algorithm: 'SHA256'
15
- }
16
- });
40
+ })
41
+ }));
17
42
  }
18
43
 
19
- }
44
+ return SHA256Hash;
45
+ }(_cryptoHash.CryptoHash);
20
46
 
21
47
  exports.SHA256Hash = SHA256Hash;
22
48
  //# sourceMappingURL=sha256-hash.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/sha256-hash.ts"],"names":["SHA256Hash","CryptoHash","constructor","options","crypto","algorithm"],"mappings":";;;;;;;AACA;;AAYO,MAAMA,UAAN,SAAyBC,sBAAzB,CAAoC;AACzCC,EAAAA,WAAW,CAACC,OAAD,EAA6B;AACtC,UAAM,EAAC,GAAGA,OAAJ;AAAaC,MAAAA,MAAM,EAAE,EAAC,GAAGD,OAAO,CAACC,MAAZ;AAAoBC,QAAAA,SAAS,EAAE;AAA/B;AAArB,KAAN;AACD;;AAHwC","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"],"file":"sha256-hash.js"}
1
+ {"version":3,"sources":["../../../src/lib/sha256-hash.ts"],"names":["SHA256Hash","options","crypto","algorithm","CryptoHash"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;;;;;;;;;IAYaA,U;;;;;AACX,sBAAYC,OAAZ,EAAwC;AAAA;AAAA,6DAC5BA,OAD4B;AACnBC,MAAAA,MAAM,kCAAMD,OAAO,CAACC,MAAd;AAAsBC,QAAAA,SAAS,EAAE;AAAjC;AADa;AAEvC;;;EAH6BC,sB","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"],"file":"sha256-hash.js"}
@@ -8,30 +8,30 @@ exports.toBase64 = toBase64;
8
8
  function toBase64(string) {
9
9
  string = "".concat(string);
10
10
 
11
- for (let i = 0; i < string.length; i++) {
11
+ for (var i = 0; i < string.length; i++) {
12
12
  if (string.charCodeAt(i) > 255) {
13
13
  return null;
14
14
  }
15
15
  }
16
16
 
17
- let out = '';
17
+ var out = '';
18
18
 
19
- for (let i = 0; i < string.length; i += 3) {
20
- const groupsOfSix = [undefined, undefined, undefined, undefined];
21
- groupsOfSix[0] = string.charCodeAt(i) >> 2;
22
- groupsOfSix[1] = (string.charCodeAt(i) & 0x03) << 4;
19
+ for (var _i = 0; _i < string.length; _i += 3) {
20
+ var groupsOfSix = [undefined, undefined, undefined, undefined];
21
+ groupsOfSix[0] = string.charCodeAt(_i) >> 2;
22
+ groupsOfSix[1] = (string.charCodeAt(_i) & 0x03) << 4;
23
23
 
24
- if (string.length > i + 1) {
25
- groupsOfSix[1] |= string.charCodeAt(i + 1) >> 4;
26
- groupsOfSix[2] = (string.charCodeAt(i + 1) & 0x0f) << 2;
24
+ if (string.length > _i + 1) {
25
+ groupsOfSix[1] |= string.charCodeAt(_i + 1) >> 4;
26
+ groupsOfSix[2] = (string.charCodeAt(_i + 1) & 0x0f) << 2;
27
27
  }
28
28
 
29
- if (string.length > i + 2) {
30
- groupsOfSix[2] |= string.charCodeAt(i + 2) >> 6;
31
- groupsOfSix[3] = string.charCodeAt(i + 2) & 0x3f;
29
+ if (string.length > _i + 2) {
30
+ groupsOfSix[2] |= string.charCodeAt(_i + 2) >> 6;
31
+ groupsOfSix[3] = string.charCodeAt(_i + 2) & 0x3f;
32
32
  }
33
33
 
34
- for (let j = 0; j < groupsOfSix.length; j++) {
34
+ for (var j = 0; j < groupsOfSix.length; j++) {
35
35
  if (typeof groupsOfSix[j] === 'undefined') {
36
36
  out += '=';
37
37
  } else {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/utils/base64-utils.ts"],"names":["toBase64","string","i","length","charCodeAt","out","groupsOfSix","undefined","j","btoaLookup","idx","String","fromCharCode"],"mappings":";;;;;;;AAIO,SAASA,QAAT,CAAkBC,MAAlB,EAAiD;AAEtDA,EAAAA,MAAM,aAAMA,MAAN,CAAN;;AAGA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,MAAM,CAACE,MAA3B,EAAmCD,CAAC,EAApC,EAAwC;AACtC,QAAID,MAAM,CAACG,UAAP,CAAkBF,CAAlB,IAAuB,GAA3B,EAAgC;AAC9B,aAAO,IAAP;AACD;AACF;;AACD,MAAIG,GAAG,GAAG,EAAV;;AACA,OAAK,IAAIH,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,MAAM,CAACE,MAA3B,EAAm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AOH,GAAP;AACD;;AAMD,SAASI,UAAT,CAAoBC,GAApB,EAAyB;AACvB,MAAIA,GAAG,GAAG,EAAV,EAAc;AACZ,WAAOC,MAAM,CAACC,YAAP,CAAoBF,GAAG,GAAG,IAAIN,UAAJ,CAAe,CAAf,CAA1B,CAAP;AACD;;AACD,MAAIM,GAAG,GAAG,EAAV,EAAc;AACZ,WAAOC,MAAM,CAACC,YAAP,CAAoBF,GAAG,GAAG,EAAN,GAAW,IAAIN,UAAJ,CAAe,CAAf,CAA/B,CAAP;AACD;;AACD,MAAIM,GAAG,GAAG,EAAV,EAAc;AACZ,WAAOC,MAAM,CAACC,YAAP,CAAoBF,GAAG,GAAG,EAAN,GAAW,IAAIN,UAAJ,CAAe,CAAf,CAA/B,CAAP;AACD;;AACD,MAAIM,GAAG,KAAK,EAAZ,EAAgB;AACd,WAAO,GAAP;AACD;;AACD,MAAIA,GAAG,KAAK,EAAZ,EAAgB;AACd,WAAO,GAAP;AACD;;AAED,SAAOH,SAAP;AACD","sourcesContent":["/**\n * `btoa()` polyfill as defined by the HTML and Infra specs, which mostly just references\n * RFC 4648.\n */\nexport function toBase64(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 * 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"],"file":"base64-utils.js"}
1
+ {"version":3,"sources":["../../../../src/lib/utils/base64-utils.ts"],"names":["toBase64","string","i","length","charCodeAt","out","groupsOfSix","undefined","j","btoaLookup","idx","String","fromCharCode"],"mappings":";;;;;;;AAIO,SAASA,QAAT,CAAkBC,MAAlB,EAAiD;AAEtDA,EAAAA,MAAM,aAAMA,MAAN,CAAN;;AAGA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,MAAM,CAACE,MAA3B,EAAmCD,CAAC,EAApC,EAAwC;AACtC,QAAID,MAAM,CAACG,UAAP,CAAkBF,CAAlB,IAAuB,GAA3B,EAAgC;AAC9B,aAAO,IAAP;AACD;AACF;;AACD,MAAIG,GAAG,GAAG,EAAV;;AACA,OAAK,IAAIH,EAAC,GAAG,CAAb,EAAgBA,EAAC,GAAGD,MAAM,CAACE,MAA3B,EAAmCD,EAAC,IAAI,CAAxC,EAA2C;AAEzC,QAAMI,WAAmC,GAAG,CAACC,SAAD,EAAYA,SAAZ,EAAuBA,SAAvB,EAAkCA,SAAlC,CAA5C;AACAD,IAAAA,WAAW,CAAC,CAAD,CAAX,GAAiBL,MAA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CAA1B,CAAP;AACD;;AACD,MAAIM,GAAG,GAAG,EAAV,EAAc;AACZ,WAAOC,MAAM,CAACC,YAAP,CAAoBF,GAAG,GAAG,EAAN,GAAW,IAAIN,UAAJ,CAAe,CAAf,CAA/B,CAAP;AACD;;AACD,MAAIM,GAAG,GAAG,EAAV,EAAc;AACZ,WAAOC,MAAM,CAACC,YAAP,CAAoBF,GAAG,GAAG,EAAN,GAAW,IAAIN,UAAJ,CAAe,CAAf,CAA/B,CAAP;AACD;;AACD,MAAIM,GAAG,KAAK,EAAZ,EAAgB;AACd,WAAO,GAAP;AACD;;AACD,MAAIA,GAAG,KAAK,EAAZ,EAAgB;AACd,WAAO,GAAP;AACD;;AAED,SAAOH,SAAP;AACD","sourcesContent":["/**\n * `btoa()` polyfill as defined by the HTML and Infra specs, which mostly just references\n * RFC 4648.\n */\nexport function toBase64(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 * 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"],"file":"base64-utils.js"}
@@ -9,7 +9,7 @@ exports.hexToBase64 = hexToBase64;
9
9
  var _base64Utils = require("./base64-utils");
10
10
 
11
11
  function toHex(cipher) {
12
- const hexString = cipher.toString(16);
12
+ var hexString = cipher.toString(16);
13
13
  return hexString === '0' ? "0".concat(hexString) : hexString;
14
14
  }
15
15
 
@@ -18,8 +18,10 @@ function hexToBase64(hexstring) {
18
18
  hexstring = "0".concat(hexstring);
19
19
  }
20
20
 
21
- const matches = hexstring.match(/\w{2}/g) || [];
22
- const string = matches.map(a => String.fromCharCode(parseInt(a, 16))).join('');
21
+ var matches = hexstring.match(/\w{2}/g) || [];
22
+ var string = matches.map(function (a) {
23
+ return String.fromCharCode(parseInt(a, 16));
24
+ }).join('');
23
25
  return (0, _base64Utils.toBase64)(string) || '';
24
26
  }
25
27
  //# sourceMappingURL=digest-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/utils/digest-utils.ts"],"names":["toHex","cipher","hexString","toString","hexToBase64","hexstring","length","matches","match","string","map","a","String","fromCharCode","parseInt","join"],"mappings":";;;;;;;;AAAA;;AAKO,SAASA,KAAT,CAAeC,MAAf,EAAuC;AAC5C,QAAMC,SAAS,GAAGD,MAAM,CAACE,QAAP,CAAgB,EAAhB,CAAlB;AACA,SAAOD,SAAS,KAAK,GAAd,cAAwBA,SAAxB,IAAsCA,SAA7C;AACD;;AAKM,SAASE,WAAT,CAAqBC,SAArB,EAAgD;AAGrD,MAAIA,SAAS,CAACC,MAAV,GAAmB,CAAnB,KAAyB,CAA7B,EAAgC;AAC9BD,IAAAA,SAAS,cAAOA,SAAP,CAAT;AACD;;AACD,QAAME,OAAO,GAAGF,SAAS,CAACG,KAAV,CAAgB,QAAhB,KAA6B,EAA7C;AACA,QAAMC,MAAM,GAAGF,OAAO,CAACG,GAAR,CAAaC,CAAD,IAAOC,MAAM,CAACC,YAAP,CAAoBC,QAAQ,CAACH,CAAD,EAAI,EAAJ,CAA5B,CAAnB,EAAyDI,IAAzD,CAA8D,EAA9D,CAAf;AAEA,SAAO,2BAASN,MAAT,KAAoB,EAA3B;AACD","sourcesContent":["import {toBase64} from './base64-utils';\n\n/**\n *\n */\nexport function toHex(cipher: number): string {\n const hexString = cipher.toString(16);\n return hexString === '0' ? `0${hexString}` : hexString;\n}\n\n/**\n * @see https://stackoverflow.com/questions/23190056/hex-to-base64-converter-for-javascript\n */\nexport function hexToBase64(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 toBase64(string) || '';\n}\n"],"file":"digest-utils.js"}
1
+ {"version":3,"sources":["../../../../src/lib/utils/digest-utils.ts"],"names":["toHex","cipher","hexString","toString","hexToBase64","hexstring","length","matches","match","string","map","a","String","fromCharCode","parseInt","join"],"mappings":";;;;;;;;AAAA;;AAKO,SAASA,KAAT,CAAeC,MAAf,EAAuC;AAC5C,MAAMC,SAAS,GAAGD,MAAM,CAACE,QAAP,CAAgB,EAAhB,CAAlB;AACA,SAAOD,SAAS,KAAK,GAAd,cAAwBA,SAAxB,IAAsCA,SAA7C;AACD;;AAKM,SAASE,WAAT,CAAqBC,SAArB,EAAgD;AAGrD,MAAIA,SAAS,CAACC,MAAV,GAAmB,CAAnB,KAAyB,CAA7B,EAAgC;AAC9BD,IAAAA,SAAS,cAAOA,SAAP,CAAT;AACD;;AACD,MAAME,OAAO,GAAGF,SAAS,CAACG,KAAV,CAAgB,QAAhB,KAA6B,EAA7C;AACA,MAAMC,MAAM,GAAGF,OAAO,CAACG,GAAR,CAAY,UAACC,CAAD;AAAA,WAAOC,MAAM,CAACC,YAAP,CAAoBC,QAAQ,CAACH,CAAD,EAAI,EAAJ,CAA5B,CAAP;AAAA,GAAZ,EAAyDI,IAAzD,CAA8D,EAA9D,CAAf;AAEA,SAAO,2BAASN,MAAT,KAAoB,EAA3B;AACD","sourcesContent":["import {toBase64} from './base64-utils';\n\n/**\n *\n */\nexport function toHex(cipher: number): string {\n const hexString = cipher.toString(16);\n return hexString === '0' ? `0${hexString}` : hexString;\n}\n\n/**\n * @see https://stackoverflow.com/questions/23190056/hex-to-base64-converter-for-javascript\n */\nexport function hexToBase64(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 toBase64(string) || '';\n}\n"],"file":"digest-utils.js"}
@@ -1,21 +1,27 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  Object.defineProperty(exports, "CRC32Hash", {
7
9
  enumerable: true,
8
- get: function () {
10
+ get: function get() {
9
11
  return _crc32Hash.CRC32Hash;
10
12
  }
11
13
  });
12
14
  Object.defineProperty(exports, "CRC32CHash", {
13
15
  enumerable: true,
14
- get: function () {
16
+ get: function get() {
15
17
  return _crc32cHash.CRC32CHash;
16
18
  }
17
19
  });
18
20
 
21
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
22
+
23
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
24
+
19
25
  var _workerUtils = require("@loaders.gl/worker-utils");
20
26
 
21
27
  var _crc32Hash = require("../lib/crc32-hash");
@@ -24,23 +30,55 @@ var _crc32cHash = require("../lib/crc32c-hash");
24
30
 
25
31
  var _md5Hash = require("../lib/md5-hash");
26
32
 
27
- (0, _workerUtils.createWorker)(async (data, options = {}) => {
28
- const {
29
- operation
30
- } = options;
33
+ (0, _workerUtils.createWorker)(function () {
34
+ var _ref = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data) {
35
+ var options,
36
+ operation,
37
+ _args = arguments;
38
+ return _regenerator.default.wrap(function _callee$(_context) {
39
+ while (1) {
40
+ switch (_context.prev = _context.next) {
41
+ case 0:
42
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
43
+ operation = options.operation;
44
+ _context.t0 = operation;
45
+ _context.next = _context.t0 === 'crc32' ? 5 : _context.t0 === 'crc32c' ? 8 : _context.t0 === 'md5' ? 11 : 14;
46
+ break;
31
47
 
32
- switch (operation) {
33
- case 'crc32':
34
- return await new _crc32Hash.CRC32Hash(options).hash(data);
48
+ case 5:
49
+ _context.next = 7;
50
+ return new _crc32Hash.CRC32Hash(options).hash(data);
35
51
 
36
- case 'crc32c':
37
- return await new _crc32cHash.CRC32CHash(options).hash(data);
52
+ case 7:
53
+ return _context.abrupt("return", _context.sent);
38
54
 
39
- case 'md5':
40
- return await new _md5Hash.MD5Hash(options).hash(data);
55
+ case 8:
56
+ _context.next = 10;
57
+ return new _crc32cHash.CRC32CHash(options).hash(data);
41
58
 
42
- default:
43
- throw new Error("invalid option: ".concat(operation));
44
- }
45
- });
59
+ case 10:
60
+ return _context.abrupt("return", _context.sent);
61
+
62
+ case 11:
63
+ _context.next = 13;
64
+ return new _md5Hash.MD5Hash(options).hash(data);
65
+
66
+ case 13:
67
+ return _context.abrupt("return", _context.sent);
68
+
69
+ case 14:
70
+ throw new Error("invalid option: ".concat(operation));
71
+
72
+ case 15:
73
+ case "end":
74
+ return _context.stop();
75
+ }
76
+ }
77
+ }, _callee);
78
+ }));
79
+
80
+ return function (_x) {
81
+ return _ref.apply(this, arguments);
82
+ };
83
+ }());
46
84
  //# sourceMappingURL=worker.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/workers/worker.ts"],"names":["data","options","operation","CRC32Hash","hash","CRC32CHash","MD5Hash","Error"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAKA,+BAAa,OAAOA,IAAP,EAAaC,OAAO,GAAG,EAAvB,KAA8B;AAEzC,QAAM;AAACC,IAAAA;AAAD,MAAcD,OAApB;;AAEA,UAAQC,SAAR;AACE,SAAK,OAAL;AACE,aAAO,MAAM,IAAIC,oBAAJ,CAAcF,OAAd,EAAuBG,IAAvB,CAA4BJ,IAA5B,CAAb;;AACF,SAAK,QAAL;AACE,aAAO,MAAM,IAAIK,sBAAJ,CAAeJ,OAAf,EAAwBG,IAAxB,CAA6BJ,IAA7B,CAAb;;AACF,SAAK,KAAL;AACE,aAAO,MAAM,IAAIM,gBAAJ,CAAYL,OAAZ,EAAqBG,IAArB,CAA0BJ,IAA1B,CAAb;;AACF;AACE,YAAM,IAAIO,KAAJ,2BAA6BL,SAA7B,EAAN;AARJ;AAUD,CAdD","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} = options;\n\n switch (operation) {\n case 'crc32':\n return await new CRC32Hash(options).hash(data);\n case 'crc32c':\n return await new CRC32CHash(options).hash(data);\n case 'md5':\n return await new MD5Hash(options).hash(data);\n default:\n throw new Error(`invalid option: ${operation}`);\n }\n});\n"],"file":"worker.js"}
1
+ {"version":3,"sources":["../../../src/workers/worker.ts"],"names":["data","options","operation","CRC32Hash","hash","CRC32CHash","MD5Hash","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAKA;AAAA,uEAAa,iBAAOA,IAAP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAaC,YAAAA,OAAb,2DAAuB,EAAvB;AAEJC,YAAAA,SAFI,GAESD,OAFT,CAEJC,SAFI;AAAA,0BAIHA,SAJG;AAAA,4CAKJ,OALI,uBAOJ,QAPI,uBASJ,KATI;AAAA;;AAAA;AAAA;AAAA,mBAMM,IAAIC,oBAAJ,CAAcF,OAAd,EAAuBG,IAAvB,CAA4BJ,IAA5B,CANN;;AAAA;AAAA;;AAAA;AAAA;AAAA,mBAQM,IAAIK,sBAAJ,CAAeJ,OAAf,EAAwBG,IAAxB,CAA6BJ,IAA7B,CARN;;AAAA;AAAA;;AAAA;AAAA;AAAA,mBAUM,IAAIM,gBAAJ,CAAYL,OAAZ,EAAqBG,IAArB,CAA0BJ,IAA1B,CAVN;;AAAA;AAAA;;AAAA;AAAA,kBAYD,IAAIO,KAAJ,2BAA6BL,SAA7B,EAZC;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAAb;;AAAA;AAAA;AAAA;AAAA","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} = options;\n\n switch (operation) {\n case 'crc32':\n return await new CRC32Hash(options).hash(data);\n case 'crc32c':\n return await new CRC32CHash(options).hash(data);\n case 'md5':\n return await new MD5Hash(options).hash(data);\n default:\n throw new Error(`invalid option: ${operation}`);\n }\n});\n"],"file":"worker.js"}
package/dist/esm/index.js CHANGED
@@ -5,7 +5,7 @@ export { SHA256Hash } from './lib/sha256-hash';
5
5
  export { CryptoHash } from './lib/crypto-hash';
6
6
  export { NodeHash } from './lib/node-hash';
7
7
  export { hexToBase64 as _hexToBase64, toHex as _toHex } from './lib/utils/digest-utils';
8
- const VERSION = typeof "3.1.0-beta.5" !== 'undefined' ? "3.1.0-beta.5" : 'latest';
8
+ const VERSION = typeof "3.1.1" !== 'undefined' ? "3.1.1" : 'latest';
9
9
  export const CryptoWorker = {
10
10
  id: 'crypto',
11
11
  name: 'CRC32, CRC32c and MD5 Hashes',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":["CRC32Hash","CRC32CHash","MD5Hash","SHA256Hash","CryptoHash","NodeHash","hexToBase64","_hexToBase64","toHex","_toHex","VERSION","CryptoWorker","id","name","module","version","options","crypto","CryptoJSWorker","cryptojs"],"mappings":"AAEA,SAAQA,SAAR,QAAwB,kBAAxB;AACA,SAAQC,UAAR,QAAyB,mBAAzB;AACA,SAAQC,OAAR,QAAsB,gBAAtB;AACA,SAAQC,UAAR,QAAyB,mBAAzB;AAEA,SAAQC,UAAR,QAAyB,mBAAzB;AACA,SAAQC,QAAR,QAAuB,iBAAvB;AAEA,SAAQC,WAAW,IAAIC,YAAvB,EAAqCC,KAAK,IAAIC,MAA9C,QAA2D,0BAA3D;AAIA,MAAMC,OAAO,GAAG,0BAAuB,WAAvB,oBAAmD,QAAnE;AAKA,OAAO,MAAMC,YAAY,GAAG;AAC1BC,EAAAA,EAAE,EAAE,QADsB;AAE1BC,EAAAA,IAAI,EAAE,8BAFoB;AAG1BC,EAAAA,MAAM,EAAE,QAHkB;AAI1BC,EAAAA,OAAO,EAAEL,OAJiB;AAK1BM,EAAAA,OAAO,EAAE;AACPC,IAAAA,MAAM,EAAE;AADD;AALiB,CAArB;AAcP,OAAO,MAAMC,cAAc,GAAG;AAC5BN,EAAAA,EAAE,EAAE,UADwB;AAE5BC,EAAAA,IAAI,EAAE,sBAFsB;AAG5BC,EAAAA,MAAM,EAAE,QAHoB;AAI5BC,EAAAA,OAAO,EAAEL,OAJmB;AAK5BM,EAAAA,OAAO,EAAE;AACPG,IAAAA,QAAQ,EAAE;AADH;AALmB,CAAvB","sourcesContent":["// import type {WorkerObject} from '@loaders.gl/worker-utils';\n\nexport {CRC32Hash} from './lib/crc32-hash';\nexport {CRC32CHash} from './lib/crc32c-hash';\nexport {MD5Hash} from './lib/md5-hash';\nexport {SHA256Hash} from './lib/sha256-hash';\n\nexport {CryptoHash} from './lib/crypto-hash';\nexport {NodeHash} from './lib/node-hash';\n\nexport {hexToBase64 as _hexToBase64, toHex as _toHex} from './lib/utils/digest-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * Small, fast worker for CRC32, CRC32c and MD5 Hashes\n */\nexport const CryptoWorker = {\n id: 'crypto',\n name: 'CRC32, CRC32c and MD5 Hashes',\n module: 'crypto',\n version: VERSION,\n options: {\n crypto: {}\n }\n};\n\n/**\n * Large worker for full complement of Cryptographic Hashes\n * bundles the full crypto.js library\n */\nexport const CryptoJSWorker = {\n id: 'cryptojs',\n name: 'Cryptographic Hashes',\n module: 'crypto',\n version: VERSION,\n options: {\n cryptojs: {}\n }\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":["CRC32Hash","CRC32CHash","MD5Hash","SHA256Hash","CryptoHash","NodeHash","hexToBase64","_hexToBase64","toHex","_toHex","VERSION","CryptoWorker","id","name","module","version","options","crypto","CryptoJSWorker","cryptojs"],"mappings":"AAEA,SAAQA,SAAR,QAAwB,kBAAxB;AACA,SAAQC,UAAR,QAAyB,mBAAzB;AACA,SAAQC,OAAR,QAAsB,gBAAtB;AACA,SAAQC,UAAR,QAAyB,mBAAzB;AAEA,SAAQC,UAAR,QAAyB,mBAAzB;AACA,SAAQC,QAAR,QAAuB,iBAAvB;AAEA,SAAQC,WAAW,IAAIC,YAAvB,EAAqCC,KAAK,IAAIC,MAA9C,QAA2D,0BAA3D;AAIA,MAAMC,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAKA,OAAO,MAAMC,YAAY,GAAG;AAC1BC,EAAAA,EAAE,EAAE,QADsB;AAE1BC,EAAAA,IAAI,EAAE,8BAFoB;AAG1BC,EAAAA,MAAM,EAAE,QAHkB;AAI1BC,EAAAA,OAAO,EAAEL,OAJiB;AAK1BM,EAAAA,OAAO,EAAE;AACPC,IAAAA,MAAM,EAAE;AADD;AALiB,CAArB;AAcP,OAAO,MAAMC,cAAc,GAAG;AAC5BN,EAAAA,EAAE,EAAE,UADwB;AAE5BC,EAAAA,IAAI,EAAE,sBAFsB;AAG5BC,EAAAA,MAAM,EAAE,QAHoB;AAI5BC,EAAAA,OAAO,EAAEL,OAJmB;AAK5BM,EAAAA,OAAO,EAAE;AACPG,IAAAA,QAAQ,EAAE;AADH;AALmB,CAAvB","sourcesContent":["// import type {WorkerObject} from '@loaders.gl/worker-utils';\n\nexport {CRC32Hash} from './lib/crc32-hash';\nexport {CRC32CHash} from './lib/crc32c-hash';\nexport {MD5Hash} from './lib/md5-hash';\nexport {SHA256Hash} from './lib/sha256-hash';\n\nexport {CryptoHash} from './lib/crypto-hash';\nexport {NodeHash} from './lib/node-hash';\n\nexport {hexToBase64 as _hexToBase64, toHex as _toHex} from './lib/utils/digest-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * Small, fast worker for CRC32, CRC32c and MD5 Hashes\n */\nexport const CryptoWorker = {\n id: 'crypto',\n name: 'CRC32, CRC32c and MD5 Hashes',\n module: 'crypto',\n version: VERSION,\n options: {\n crypto: {}\n }\n};\n\n/**\n * Large worker for full complement of Cryptographic Hashes\n * bundles the full crypto.js library\n */\nexport const CryptoJSWorker = {\n id: 'cryptojs',\n name: 'Cryptographic Hashes',\n module: 'crypto',\n version: VERSION,\n options: {\n cryptojs: {}\n }\n};\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/crypto",
3
- "version": "3.1.0-beta.5",
3
+ "version": "3.1.1",
4
4
  "description": "Cryptographic/hashing plugins for loaders.gl",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@babel/runtime": "^7.3.1",
36
- "@loaders.gl/loader-utils": "3.1.0-beta.5",
37
- "@loaders.gl/worker-utils": "3.1.0-beta.5",
36
+ "@loaders.gl/loader-utils": "3.1.1",
37
+ "@loaders.gl/worker-utils": "3.1.1",
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": "5d66468457cc878d2dbff3d7807d737ceb181c9a"
47
+ "gitHead": "ed3c238bcb68ab5a2d4ddc64319f6f4c02a20df7"
48
48
  }