jscrambler 6.2.6 → 6.3.0

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/index.js CHANGED
@@ -1,122 +1,82 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  require("regenerator-runtime");
11
-
12
9
  require("core-js");
13
-
14
10
  var _path = _interopRequireDefault(require("path"));
15
-
16
11
  var _axios = _interopRequireDefault(require("axios"));
17
-
18
12
  var _lodash = _interopRequireDefault(require("lodash.defaults"));
19
-
20
13
  var _fs = _interopRequireDefault(require("fs"));
21
-
22
14
  var _config2 = _interopRequireDefault(require("./config"));
23
-
24
15
  var _generateSignedParams = _interopRequireDefault(require("./generate-signed-params"));
25
-
26
16
  var _client = _interopRequireDefault(require("./client"));
27
-
28
17
  var mutations = _interopRequireWildcard(require("./mutations"));
29
-
30
18
  var queries = _interopRequireWildcard(require("./queries"));
31
-
32
19
  var _constants = require("./constants");
33
-
34
20
  var _zip = require("./zip");
35
-
36
21
  var introspection = _interopRequireWildcard(require("./introspection"));
37
-
38
22
  var _utils = require("./utils");
39
-
40
23
  var _getProtectionDefaultFragments = _interopRequireDefault(require("./get-protection-default-fragments"));
41
-
42
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
43
-
44
25
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
45
-
46
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
47
-
48
27
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
49
-
50
28
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
51
-
52
29
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
53
-
54
30
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
55
-
56
31
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
57
-
58
32
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
59
-
60
33
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
61
-
62
34
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
63
-
64
35
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
65
-
66
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
67
-
36
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
68
37
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
69
-
70
38
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
71
-
72
39
  var intoObjectType = introspection.intoObjectType;
73
40
  var debug = !!process.env.DEBUG;
74
41
  var APP_URL = 'https://app.jscrambler.com';
75
42
  var POLLING_MIN_INTERVAL = 1000;
76
43
  var POLLING_MAX_INTERVAL = 10000;
77
44
  var INCREASE_POLL_INTERVAL_EVERY = 30000;
45
+
78
46
  /**
79
47
  * Calculate polling interval for protection and instrumentation.
80
48
  * Upper limit of {POLLING_MAX_INTERVAL}.
81
49
  * @param start
82
50
  * @returns {number|number}
83
51
  */
84
-
85
52
  function getPollingInterval(start) {
86
53
  var pollingInterval = POLLING_MIN_INTERVAL * Math.ceil((Date.now() - start) / INCREASE_POLL_INTERVAL_EVERY);
87
54
  return pollingInterval >= POLLING_MAX_INTERVAL ? POLLING_MAX_INTERVAL : pollingInterval;
88
55
  }
89
-
90
56
  function errorHandler(res) {
91
57
  if (res.errors && res.errors.length) {
92
58
  res.errors.forEach(function (error) {
93
59
  throw new Error("Error: ".concat(error.message));
94
60
  });
95
61
  }
96
-
97
62
  if (res.data && res.data.errors) {
98
63
  res.data.errors.forEach(function (e) {
99
64
  return console.error(e.message);
100
65
  });
101
66
  throw new Error('GraphQL Query Error');
102
67
  }
103
-
104
68
  if (res.message) {
105
69
  throw new Error("Error: ".concat(res.message));
106
70
  }
107
-
108
71
  return res;
109
72
  }
110
-
111
73
  function printSourcesErrors(errors) {
112
74
  console.error('Application sources errors:');
113
75
  console.error(JSON.stringify(errors, null, 2));
114
76
  console.error('');
115
77
  }
116
-
117
78
  function normalizeParameters(parameters) {
118
79
  var result;
119
-
120
80
  if (!Array.isArray(parameters)) {
121
81
  result = [];
122
82
  Object.keys(parameters).forEach(function (name) {
@@ -128,21 +88,16 @@ function normalizeParameters(parameters) {
128
88
  } else {
129
89
  result = parameters;
130
90
  }
131
-
132
91
  return result;
133
92
  }
134
-
135
93
  function buildFinalConfig(configPathOrObject) {
136
94
  var _config = typeof configPathOrObject === 'string' ? require(configPathOrObject) : configPathOrObject;
137
-
138
95
  return (0, _lodash.default)(_config, _config2.default);
139
96
  }
140
-
141
97
  var _default = {
142
98
  Client: _client.default,
143
99
  config: _config2.default,
144
100
  generateSignedParams: _generateSignedParams.default,
145
-
146
101
  /**
147
102
  * Remove and Add application sources
148
103
  * @param {object} client
@@ -157,44 +112,34 @@ var _default = {
157
112
  */
158
113
  updateApplicationSources: function updateApplicationSources(client, applicationId, _ref) {
159
114
  var _this = this;
160
-
161
115
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
162
116
  var sources, filesSrc, cwd, appProfiling, removeSourceRes, zipped, source, _filesSrc, i, l, content;
163
-
164
117
  return _regeneratorRuntime().wrap(function _callee$(_context) {
165
118
  while (1) {
166
119
  switch (_context.prev = _context.next) {
167
120
  case 0:
168
121
  sources = _ref.sources, filesSrc = _ref.filesSrc, cwd = _ref.cwd, appProfiling = _ref.appProfiling;
169
-
170
122
  if (!(sources || filesSrc && filesSrc.length)) {
171
123
  _context.next = 8;
172
124
  break;
173
125
  }
174
-
175
126
  if (!(appProfiling && appProfiling.data && appProfiling.data.state === 'READY')) {
176
127
  _context.next = 4;
177
128
  break;
178
129
  }
179
-
180
130
  throw new Error('You have a finished Profiling for this application so you are NOT ALLOWED to update sources. To override this behavior use *--remove-profiling-data* or *--skip-sources*.');
181
-
182
131
  case 4:
183
132
  _context.next = 6;
184
133
  return _this.removeSourceFromApplication(client, '', applicationId);
185
-
186
134
  case 6:
187
135
  removeSourceRes = _context.sent;
188
136
  errorHandler(removeSourceRes);
189
-
190
137
  case 8:
191
138
  if (!(filesSrc && filesSrc.length)) {
192
139
  _context.next = 17;
193
140
  break;
194
141
  }
195
-
196
142
  _filesSrc = [];
197
-
198
143
  for (i = 0, l = filesSrc.length; i < l; i += 1) {
199
144
  if (typeof filesSrc[i] === 'string') {
200
145
  _filesSrc = _filesSrc.concat((0, _utils.getMatchedFiles)(filesSrc[i]));
@@ -202,41 +147,32 @@ var _default = {
202
147
  _filesSrc.push(filesSrc[i]);
203
148
  }
204
149
  }
205
-
206
150
  if (debug) {
207
151
  console.log('Creating zip from source files');
208
152
  }
209
-
210
153
  _context.next = 14;
211
154
  return (0, _zip.zip)(_filesSrc, cwd);
212
-
213
155
  case 14:
214
156
  zipped = _context.sent;
215
157
  _context.next = 22;
216
158
  break;
217
-
218
159
  case 17:
219
160
  if (!sources) {
220
161
  _context.next = 22;
221
162
  break;
222
163
  }
223
-
224
164
  if (debug) {
225
165
  console.log('Creating zip from sources');
226
166
  }
227
-
228
167
  _context.next = 21;
229
168
  return (0, _zip.zipSources)(sources);
230
-
231
169
  case 21:
232
170
  zipped = _context.sent;
233
-
234
171
  case 22:
235
172
  if (!zipped) {
236
173
  _context.next = 33;
237
174
  break;
238
175
  }
239
-
240
176
  _context.next = 25;
241
177
  return zipped.generateAsync({
242
178
  type: 'base64',
@@ -246,14 +182,11 @@ var _default = {
246
182
  level: 5
247
183
  }
248
184
  });
249
-
250
185
  case 25:
251
186
  content = _context.sent;
252
-
253
187
  if (debug) {
254
188
  console.log('Adding sources to application');
255
189
  }
256
-
257
190
  source = {
258
191
  content: content,
259
192
  filename: 'application.zip',
@@ -262,14 +195,11 @@ var _default = {
262
195
  _context.t0 = errorHandler;
263
196
  _context.next = 31;
264
197
  return _this.addApplicationSource(client, applicationId, source);
265
-
266
198
  case 31:
267
199
  _context.t1 = _context.sent;
268
200
  (0, _context.t0)(_context.t1);
269
-
270
201
  case 33:
271
202
  return _context.abrupt("return", source);
272
-
273
203
  case 34:
274
204
  case "end":
275
205
  return _context.stop();
@@ -323,10 +253,8 @@ var _default = {
323
253
  //
324
254
  protectAndDownload: function protectAndDownload(configPathOrObject, destCallback) {
325
255
  var _this2 = this;
326
-
327
256
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
328
257
  var start, finalConfig, applicationId, host, port, basePath, protocol, cafile, keys, sources, _finalConfig$stream, stream, cwd, params, applicationTypes, languageSpecifications, sourceMaps, randomizationSeed, areSubscribersOrdered, useRecommendedOrder, _finalConfig$bail, bail, jscramblerVersion, debugMode, proxy, utc, clientId, tolerateMinification, codeHardeningThreshold, useProfilingData, browsers, useAppClassification, profilingDataMode, removeProfilingData, skipSources, inputSymbolTable, entryPoint, excludeList, numberOfProtections, ensureCodeAnnotation, forceAppEnvironment, accessKey, secretKey, client, filesSrc, filesDest, source, appProfiling, updateData, dataToValidate, prop, value, applicationUpdate, updateApplicationRes, protectionOptions, inputSymbolTableContents, createApplicationProtectionRes, protectionIds, onExitCancelProtection, processedProtections, handleProtection, i, protection;
329
-
330
258
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
331
259
  while (1) {
332
260
  switch (_context4.prev = _context4.next) {
@@ -350,36 +278,28 @@ var _default = {
350
278
  });
351
279
  filesSrc = finalConfig.filesSrc;
352
280
  filesDest = finalConfig.filesDest;
353
-
354
281
  if (sources) {
355
282
  filesSrc = undefined;
356
283
  }
357
-
358
284
  if (destCallback) {
359
285
  filesDest = undefined;
360
286
  }
361
-
362
287
  if (applicationId) {
363
288
  _context4.next = 11;
364
289
  break;
365
290
  }
366
-
367
291
  throw new Error('Required *applicationId* not provided');
368
-
369
292
  case 11:
370
293
  if (!(!filesDest && !destCallback)) {
371
294
  _context4.next = 13;
372
295
  break;
373
296
  }
374
-
375
297
  throw new Error('Required *filesDest* not provided');
376
-
377
298
  case 13:
378
299
  if (skipSources) {
379
300
  _context4.next = 26;
380
301
  break;
381
302
  }
382
-
383
303
  _context4.next = 16;
384
304
  return _this2.getApplicationProfiling(client, applicationId).catch(function (e) {
385
305
  if (![_constants.HTTP_STATUS_CODES.NOT_FOUND, _constants.HTTP_STATUS_CODES.FORBIDDEN, _constants.HTTP_STATUS_CODES.SERVICE_UNAVAILABLE].includes(e.statusCode)) throw e;else if (_constants.HTTP_STATUS_CODES.NOT_FOUND === e.statusCode) {
@@ -390,21 +310,16 @@ var _default = {
390
310
  }
391
311
  }
392
312
  });
393
-
394
313
  case 16:
395
314
  appProfiling = _context4.sent;
396
-
397
315
  if (!(appProfiling && removeProfilingData)) {
398
316
  _context4.next = 21;
399
317
  break;
400
318
  }
401
-
402
319
  _context4.next = 20;
403
320
  return _this2.deleteProfiling(client, appProfiling.data.id);
404
-
405
321
  case 20:
406
322
  appProfiling.data.state = 'DELETED';
407
-
408
323
  case 21:
409
324
  _context4.next = 23;
410
325
  return _this2.updateApplicationSources(client, applicationId, {
@@ -413,15 +328,12 @@ var _default = {
413
328
  cwd: cwd,
414
329
  appProfiling: appProfiling
415
330
  });
416
-
417
331
  case 23:
418
332
  source = _context4.sent;
419
333
  _context4.next = 27;
420
334
  break;
421
-
422
335
  case 26:
423
336
  console.log('Update source files SKIPPED');
424
-
425
337
  case 27:
426
338
  updateData = {
427
339
  _id: applicationId,
@@ -429,12 +341,10 @@ var _default = {
429
341
  tolerateMinification: tolerateMinification,
430
342
  codeHardeningThreshold: codeHardeningThreshold
431
343
  };
432
-
433
344
  if (params && Object.keys(params).length) {
434
345
  updateData.parameters = normalizeParameters(params);
435
346
  updateData.areSubscribersOrdered = Array.isArray(params);
436
347
  }
437
-
438
348
  dataToValidate = {
439
349
  applicationTypes: applicationTypes,
440
350
  areSubscribersOrdered: areSubscribersOrdered,
@@ -447,47 +357,36 @@ var _default = {
447
357
  useProfilingData: useProfilingData,
448
358
  useRecommendedOrder: useRecommendedOrder
449
359
  };
450
-
451
360
  for (prop in dataToValidate) {
452
361
  value = dataToValidate[prop];
453
-
454
362
  if (typeof value !== 'undefined') {
455
363
  updateData[prop] = value;
456
364
  }
457
365
  }
458
-
459
366
  if (!(updateData.parameters || updateData.applicationTypes || updateData.languageSpecifications || updateData.browsers || typeof updateData.areSubscribersOrdered !== 'undefined')) {
460
367
  _context4.next = 41;
461
368
  break;
462
369
  }
463
-
464
370
  if (debug) {
465
371
  console.log('Updating parameters of protection');
466
372
  }
467
-
468
373
  _context4.next = 35;
469
374
  return intoObjectType(client, updateData, 'Application');
470
-
471
375
  case 35:
472
376
  applicationUpdate = _context4.sent;
473
377
  _context4.next = 38;
474
378
  return _this2.updateApplication(client, applicationUpdate);
475
-
476
379
  case 38:
477
380
  updateApplicationRes = _context4.sent;
478
-
479
381
  if (debug) {
480
382
  console.log('Finished updating parameters of protection');
481
383
  console.error(updateApplicationRes);
482
384
  }
483
-
484
385
  errorHandler(updateApplicationRes);
485
-
486
386
  case 41:
487
387
  if (debug) {
488
388
  console.log('Creating Application Protection');
489
389
  }
490
-
491
390
  delete updateData._id;
492
391
  protectionOptions = _objectSpread(_objectSpread({}, updateData), {}, {
493
392
  bail: bail,
@@ -500,7 +399,6 @@ var _default = {
500
399
  numberOfProtections: numberOfProtections,
501
400
  forceAppEnvironment: forceAppEnvironment
502
401
  });
503
-
504
402
  if (finalConfig.inputSymbolTable) {
505
403
  // Note: we can not use the fs.promises API because some users may not have node 10.
506
404
  // Once node 10 is old enough to be safe to assume that all users will have it, this
@@ -508,10 +406,8 @@ var _default = {
508
406
  inputSymbolTableContents = _fs.default.readFileSync(finalConfig.inputSymbolTable, 'utf-8');
509
407
  protectionOptions.inputSymbolTable = inputSymbolTableContents;
510
408
  }
511
-
512
409
  _context4.next = 47;
513
410
  return _this2.createApplicationProtections(client, applicationId, protectionOptions);
514
-
515
411
  case 47:
516
412
  createApplicationProtectionRes = _context4.sent;
517
413
  errorHandler(createApplicationProtectionRes);
@@ -519,7 +415,6 @@ var _default = {
519
415
  var _id = _ref2._id;
520
416
  return _id;
521
417
  });
522
-
523
418
  onExitCancelProtection = /*#__PURE__*/function () {
524
419
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
525
420
  var i, protectionId;
@@ -528,39 +423,31 @@ var _default = {
528
423
  switch (_context2.prev = _context2.next) {
529
424
  case 0:
530
425
  i = 0;
531
-
532
426
  case 1:
533
427
  if (!(i < protectionIds.length)) {
534
428
  _context2.next = 15;
535
429
  break;
536
430
  }
537
-
538
431
  protectionId = protectionIds[i];
539
432
  _context2.prev = 3;
540
433
  _context2.next = 6;
541
434
  return _this2.cancelProtection(client, protectionId, applicationId);
542
-
543
435
  case 6:
544
436
  console.log('** Protection %s WAS CANCELLED **', protectionId);
545
437
  _context2.next = 12;
546
438
  break;
547
-
548
439
  case 9:
549
440
  _context2.prev = 9;
550
441
  _context2.t0 = _context2["catch"](3);
551
-
552
442
  if (debug) {
553
443
  console.error(_context2.t0);
554
444
  }
555
-
556
445
  case 12:
557
446
  i++;
558
447
  _context2.next = 1;
559
448
  break;
560
-
561
449
  case 15:
562
450
  process.exit(1);
563
-
564
451
  case 16:
565
452
  case "end":
566
453
  return _context2.stop();
@@ -568,12 +455,10 @@ var _default = {
568
455
  }
569
456
  }, _callee2, null, [[3, 9]]);
570
457
  }));
571
-
572
458
  return function onExitCancelProtection() {
573
459
  return _ref3.apply(this, arguments);
574
460
  };
575
461
  }();
576
-
577
462
  process.once('SIGINT', onExitCancelProtection).once('SIGTERM', onExitCancelProtection);
578
463
  _context4.t0 = _this2;
579
464
  _context4.t1 = client;
@@ -581,41 +466,34 @@ var _default = {
581
466
  _context4.t3 = protectionIds;
582
467
  _context4.next = 58;
583
468
  return (0, _getProtectionDefaultFragments.default)(client);
584
-
585
469
  case 58:
586
470
  _context4.t4 = _context4.sent;
587
471
  _context4.next = 61;
588
472
  return _context4.t0.pollProtections.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3, _context4.t4);
589
-
590
473
  case 61:
591
474
  processedProtections = _context4.sent;
592
475
  process.removeListener('SIGINT', onExitCancelProtection).removeListener('SIGTERM', onExitCancelProtection);
593
-
594
476
  handleProtection = /*#__PURE__*/function () {
595
477
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(protection) {
596
478
  var _ref5,
597
- _ref5$outPrefix,
598
- outPrefix,
599
- _ref5$printProtection,
600
- printProtectionId,
601
- sourcesErrors,
602
- download,
603
- _args3 = arguments;
604
-
479
+ _ref5$outPrefix,
480
+ outPrefix,
481
+ _ref5$printProtection,
482
+ printProtectionId,
483
+ sourcesErrors,
484
+ download,
485
+ _args3 = arguments;
605
486
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
606
487
  while (1) {
607
488
  switch (_context3.prev = _context3.next) {
608
489
  case 0:
609
490
  _ref5 = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {}, _ref5$outPrefix = _ref5.outPrefix, outPrefix = _ref5$outPrefix === void 0 ? '' : _ref5$outPrefix, _ref5$printProtection = _ref5.printProtectionId, printProtectionId = _ref5$printProtection === void 0 ? true : _ref5$printProtection;
610
-
611
491
  if (protection.growthWarning) {
612
492
  console.warn("Warning: Your protected application has surpassed a reasonable file growth.\nFor more information on what might have caused this, please see the Protection Report.\nLink: ".concat(APP_URL, "."));
613
493
  }
614
-
615
494
  if (debug) {
616
495
  console.log('Finished protecting');
617
496
  }
618
-
619
497
  if (protection.deprecations) {
620
498
  protection.deprecations.forEach(function (deprecation) {
621
499
  if (deprecation.type === 'Transformation') {
@@ -625,7 +503,6 @@ var _default = {
625
503
  }
626
504
  });
627
505
  }
628
-
629
506
  sourcesErrors = [];
630
507
  protection.sources.forEach(function (s) {
631
508
  if (s.errorMessages && s.errorMessages.length > 0) {
@@ -636,71 +513,54 @@ var _default = {
636
513
  })));
637
514
  }
638
515
  });
639
-
640
516
  if (!(protection.state === 'errored')) {
641
517
  _context3.next = 14;
642
518
  break;
643
519
  }
644
-
645
520
  console.error('Global protection errors:');
646
521
  console.error("- ".concat(protection.errorMessage));
647
522
  console.error('');
648
-
649
523
  if (sourcesErrors.length > 0) {
650
524
  printSourcesErrors(sourcesErrors);
651
525
  }
652
-
653
526
  throw new Error("Protection failed. For more information visit: ".concat(APP_URL, "."));
654
-
655
527
  case 14:
656
528
  if (!(sourcesErrors.length > 0)) {
657
529
  _context3.next = 21;
658
530
  break;
659
531
  }
660
-
661
532
  if (!protection.bail) {
662
533
  _context3.next = 20;
663
534
  break;
664
535
  }
665
-
666
536
  printSourcesErrors(sourcesErrors);
667
537
  throw new Error('Your protection has failed.');
668
-
669
538
  case 20:
670
539
  sourcesErrors.forEach(function (e) {
671
540
  return console.warn("Non-fatal error: \"".concat(e.message, "\" in ").concat(e.filename));
672
541
  });
673
-
674
542
  case 21:
675
543
  if (debug) {
676
544
  console.log('Downloading protection result');
677
545
  }
678
-
679
546
  _context3.next = 24;
680
547
  return _this2.downloadApplicationProtection(client, protection._id);
681
-
682
548
  case 24:
683
549
  download = _context3.sent;
684
550
  errorHandler(download);
685
-
686
551
  if (debug) {
687
552
  console.log('Unzipping files');
688
553
  }
689
-
690
554
  _context3.next = 29;
691
555
  return (0, _zip.unzip)(download, (filesDest ? "".concat(filesDest).concat(outPrefix) : filesDest) || destCallback, stream);
692
-
693
556
  case 29:
694
557
  if (debug) {
695
558
  console.log('Finished unzipping files');
696
559
  }
697
-
698
560
  if (printProtectionId) {
699
561
  console.log(protection._id);
700
562
  }
701
-
702
563
  return _context3.abrupt("return", protection._id);
703
-
704
564
  case 32:
705
565
  case "end":
706
566
  return _context3.stop();
@@ -708,29 +568,23 @@ var _default = {
708
568
  }
709
569
  }, _callee3);
710
570
  }));
711
-
712
571
  return function handleProtection(_x) {
713
572
  return _ref4.apply(this, arguments);
714
573
  };
715
574
  }();
716
-
717
575
  if (!(processedProtections.length === 1)) {
718
576
  _context4.next = 66;
719
577
  break;
720
578
  }
721
-
722
579
  return _context4.abrupt("return", handleProtection(processedProtections[0]));
723
-
724
580
  case 66:
725
581
  console.log("Protections stored in ".concat(filesDest, "/[protection-id]"));
726
582
  i = 0;
727
-
728
583
  case 68:
729
584
  if (!(i < processedProtections.length)) {
730
585
  _context4.next = 81;
731
586
  break;
732
587
  }
733
-
734
588
  protection = processedProtections[i];
735
589
  _context4.prev = 70;
736
590
  _context4.next = 73;
@@ -738,25 +592,20 @@ var _default = {
738
592
  outPrefix: "/".concat(protection._id, "/"),
739
593
  printProtectionId: false
740
594
  });
741
-
742
595
  case 73:
743
596
  _context4.next = 78;
744
597
  break;
745
-
746
598
  case 75:
747
599
  _context4.prev = 75;
748
600
  _context4.t5 = _context4["catch"](70);
749
601
  console.error(_context4.t5);
750
-
751
602
  case 78:
752
603
  i++;
753
604
  _context4.next = 68;
754
605
  break;
755
-
756
606
  case 81:
757
607
  console.log("Runtime: ".concat(processedProtections.length, " protections in ").concat(Math.round((Date.now() - start) / 1000), "s"));
758
608
  return _context4.abrupt("return", protectionIds);
759
-
760
609
  case 83:
761
610
  case "end":
762
611
  return _context4.stop();
@@ -765,7 +614,6 @@ var _default = {
765
614
  }, _callee4, null, [[70, 75]]);
766
615
  }))();
767
616
  },
768
-
769
617
  /**
770
618
  * Instrument and download application sources for profiling purposes
771
619
  * @param {object} configPathOrObject
@@ -774,10 +622,8 @@ var _default = {
774
622
  */
775
623
  instrumentAndDownload: function instrumentAndDownload(configPathOrObject, destCallback) {
776
624
  var _this3 = this;
777
-
778
625
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
779
626
  var finalConfig, applicationId, host, port, basePath, protocol, cafile, keys, sources, _finalConfig$stream2, stream, cwd, jscramblerVersion, proxy, utc, skipSources, clientId, accessKey, secretKey, client, filesSrc, filesDest, instrumentation, onExitCancelInstrumentation, download;
780
-
781
627
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
782
628
  while (1) {
783
629
  switch (_context5.prev = _context5.next) {
@@ -799,58 +645,45 @@ var _default = {
799
645
  clientId: clientId
800
646
  });
801
647
  filesSrc = finalConfig.filesSrc, filesDest = finalConfig.filesDest;
802
-
803
648
  if (sources) {
804
649
  filesSrc = undefined;
805
650
  }
806
-
807
651
  if (destCallback) {
808
652
  filesDest = undefined;
809
653
  }
810
-
811
654
  if (applicationId) {
812
655
  _context5.next = 9;
813
656
  break;
814
657
  }
815
-
816
658
  throw new Error('Required *applicationId* not provided');
817
-
818
659
  case 9:
819
660
  if (!(!filesDest && !destCallback)) {
820
661
  _context5.next = 11;
821
662
  break;
822
663
  }
823
-
824
664
  throw new Error('Required *filesDest* not provided');
825
-
826
665
  case 11:
827
666
  if (skipSources) {
828
667
  _context5.next = 16;
829
668
  break;
830
669
  }
831
-
832
670
  _context5.next = 14;
833
671
  return _this3.updateApplicationSources(client, applicationId, {
834
672
  sources: sources,
835
673
  filesSrc: filesSrc,
836
674
  cwd: cwd
837
675
  });
838
-
839
676
  case 14:
840
677
  _context5.next = 17;
841
678
  break;
842
-
843
679
  case 16:
844
680
  console.log('Update source files SKIPPED');
845
-
846
681
  case 17:
847
682
  _context5.next = 19;
848
683
  return _this3.startInstrumentation(client, applicationId);
849
-
850
684
  case 19:
851
685
  instrumentation = _context5.sent;
852
686
  errorHandler(instrumentation);
853
-
854
687
  onExitCancelInstrumentation = function onExitCancelInstrumentation() {
855
688
  _this3.deleteProfiling(client, instrumentation.data.id).then(function () {
856
689
  return console.log('\n** Instrumentation %s WAS CANCELLED **', instrumentation.data.id);
@@ -860,42 +693,32 @@ var _default = {
860
693
  return process.exit(1);
861
694
  });
862
695
  };
863
-
864
696
  process.once('SIGINT', onExitCancelInstrumentation).once('SIGTERM', onExitCancelInstrumentation);
865
697
  _context5.next = 25;
866
698
  return _this3.pollInstrumentation(client, instrumentation.data.id);
867
-
868
699
  case 25:
869
700
  instrumentation = _context5.sent;
870
701
  process.removeListener('SIGINT', onExitCancelInstrumentation).removeListener('SIGTERM', onExitCancelInstrumentation);
871
-
872
702
  if (debug) {
873
703
  console.log("Finished instrumention with id ".concat(instrumentation.data.id, ". Downloading..."));
874
704
  }
875
-
876
705
  _context5.next = 30;
877
706
  return _this3.downloadApplicationInstrumented(client, instrumentation.data.id);
878
-
879
707
  case 30:
880
708
  download = _context5.sent;
881
709
  errorHandler(download);
882
-
883
710
  if (debug) {
884
711
  console.log('Unzipping files');
885
712
  }
886
-
887
713
  _context5.next = 35;
888
714
  return (0, _zip.unzip)(download, filesDest || destCallback, stream);
889
-
890
715
  case 35:
891
716
  if (debug) {
892
717
  console.log('Finished unzipping files');
893
718
  }
894
-
895
719
  console.warn("\n WARNING: DO NOT SEND THIS CODE TO PRODUCTION AS IT IS NOT PROTECTED\n ");
896
720
  console.log("Application ".concat(applicationId, " was instrumented. Bootstrap your instrumented application and run *--start-profiling* command."));
897
721
  return _context5.abrupt("return", instrumentation.data.id);
898
-
899
722
  case 39:
900
723
  case "end":
901
724
  return _context5.stop();
@@ -904,7 +727,6 @@ var _default = {
904
727
  }, _callee5);
905
728
  }))();
906
729
  },
907
-
908
730
  /**
909
731
  * Change the profiling run stat.
910
732
  * @param configPathOrObject
@@ -915,7 +737,6 @@ var _default = {
915
737
  */
916
738
  setProfilingState: function setProfilingState(configPathOrObject, state, label, nextStepMessage) {
917
739
  var _this4 = this;
918
-
919
740
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
920
741
  var finalConfig, keys, host, port, basePath, protocol, cafile, applicationId, proxy, utc, jscramblerVersion, clientId, accessKey, secretKey, client, instrumentation, previousState;
921
742
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
@@ -944,37 +765,28 @@ var _default = {
944
765
  }).catch(function (e) {
945
766
  if (e.statusCode !== 404) throw e;
946
767
  });
947
-
948
768
  case 6:
949
769
  instrumentation = _context6.sent;
950
-
951
770
  if (instrumentation) {
952
771
  _context6.next = 9;
953
772
  break;
954
773
  }
955
-
956
774
  throw new Error('There is no active profiling run. Instrument your application first.');
957
-
958
775
  case 9:
959
776
  previousState = instrumentation.data.state;
960
-
961
777
  if (!(previousState === state)) {
962
778
  _context6.next = 13;
963
779
  break;
964
780
  }
965
-
966
781
  console.log("Profiling was already ".concat(label, " for application ").concat(applicationId, ". ").concat(nextStepMessage));
967
782
  return _context6.abrupt("return");
968
-
969
783
  case 13:
970
784
  _context6.next = 15;
971
785
  return client.patch("/profiling-run/".concat(instrumentation.data.id), {
972
786
  state: state
973
787
  });
974
-
975
788
  case 15:
976
789
  console.log("Profiling was ".concat(label, " for application ").concat(applicationId, ". ").concat(nextStepMessage));
977
-
978
790
  case 16:
979
791
  case "end":
980
792
  return _context6.stop();
@@ -985,10 +797,8 @@ var _default = {
985
797
  },
986
798
  downloadSourceMaps: function downloadSourceMaps(configs, destCallback) {
987
799
  var _this5 = this;
988
-
989
800
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
990
801
  var keys, host, port, basePath, protocol, cafile, _configs$stream, stream, filesDest, filesSrc, protectionId, jscramblerVersion, utc, proxy, accessKey, secretKey, client, download;
991
-
992
802
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
993
803
  while (1) {
994
804
  switch (_context7.prev = _context7.next) {
@@ -1007,45 +817,35 @@ var _default = {
1007
817
  utc: utc,
1008
818
  proxy: proxy
1009
819
  });
1010
-
1011
820
  if (!(!filesDest && !destCallback)) {
1012
821
  _context7.next = 5;
1013
822
  break;
1014
823
  }
1015
-
1016
824
  throw new Error('Required *filesDest* not provided');
1017
-
1018
825
  case 5:
1019
826
  if (protectionId) {
1020
827
  _context7.next = 7;
1021
828
  break;
1022
829
  }
1023
-
1024
830
  throw new Error('Required *protectionId* not provided');
1025
-
1026
831
  case 7:
1027
832
  if (filesSrc) {
1028
833
  console.warn('[Warning] Ignoring sources supplied. Downloading source maps of given protection');
1029
834
  }
1030
-
1031
835
  _context7.prev = 8;
1032
836
  _context7.next = 11;
1033
837
  return _this5.downloadSourceMapsRequest(client, protectionId);
1034
-
1035
838
  case 11:
1036
839
  download = _context7.sent;
1037
840
  _context7.next = 17;
1038
841
  break;
1039
-
1040
842
  case 14:
1041
843
  _context7.prev = 14;
1042
844
  _context7.t0 = _context7["catch"](8);
1043
845
  errorHandler(_context7.t0);
1044
-
1045
846
  case 17:
1046
847
  _context7.next = 19;
1047
848
  return (0, _zip.unzip)(download, filesDest || destCallback, stream);
1048
-
1049
849
  case 19:
1050
850
  case "end":
1051
851
  return _context7.stop();
@@ -1056,10 +856,8 @@ var _default = {
1056
856
  },
1057
857
  downloadSymbolTable: function downloadSymbolTable(configs, destCallback) {
1058
858
  var _this6 = this;
1059
-
1060
859
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1061
860
  var keys, host, port, basePath, protocol, cafile, _configs$stream2, stream, filesDest, filesSrc, protectionId, jscramblerVersion, utc, proxy, accessKey, secretKey, client, download;
1062
-
1063
861
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1064
862
  while (1) {
1065
863
  switch (_context8.prev = _context8.next) {
@@ -1078,48 +876,38 @@ var _default = {
1078
876
  utc: utc,
1079
877
  proxy: proxy
1080
878
  });
1081
-
1082
879
  if (!(!filesDest && !destCallback)) {
1083
880
  _context8.next = 5;
1084
881
  break;
1085
882
  }
1086
-
1087
883
  throw new Error('Required *filesDest* not provided');
1088
-
1089
884
  case 5:
1090
885
  if (protectionId) {
1091
886
  _context8.next = 7;
1092
887
  break;
1093
888
  }
1094
-
1095
889
  throw new Error('Required *protectionId* not provided');
1096
-
1097
890
  case 7:
1098
891
  if (filesSrc) {
1099
892
  console.warn('[Warning] Ignoring sources supplied. Downloading symbol table of given protection');
1100
893
  }
1101
-
1102
894
  _context8.prev = 8;
1103
895
  _context8.next = 11;
1104
896
  return _this6.downloadSymbolTableRequest(client, protectionId);
1105
-
1106
897
  case 11:
1107
898
  download = _context8.sent;
1108
899
  _context8.next = 17;
1109
900
  break;
1110
-
1111
901
  case 14:
1112
902
  _context8.prev = 14;
1113
903
  _context8.t0 = _context8["catch"](8);
1114
904
  errorHandler(_context8.t0);
1115
-
1116
905
  case 17:
1117
906
  if (typeof destCallback === 'function') {
1118
907
  destCallback(download, filesDest);
1119
908
  } else {
1120
909
  (0, _zip.outputFileSync)(_path.default.join(filesDest, "".concat(protectionId, "_symbolTable.json")), download);
1121
910
  }
1122
-
1123
911
  case 18:
1124
912
  case "end":
1125
913
  return _context8.stop();
@@ -1128,7 +916,6 @@ var _default = {
1128
916
  }, _callee8, null, [[8, 14]]);
1129
917
  }))();
1130
918
  },
1131
-
1132
919
  /**
1133
920
  * Polls a instrumentation every POLLING_INTERVALms until the state be equal to
1134
921
  * FINISHED_INSTRUMENTATION, FAILED_INSTRUMENTATION or DELETED
@@ -1139,7 +926,6 @@ var _default = {
1139
926
  */
1140
927
  pollInstrumentation: function pollInstrumentation(client, instrumentationId) {
1141
928
  var _this7 = this;
1142
-
1143
929
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1144
930
  var start, poll;
1145
931
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
@@ -1147,7 +933,6 @@ var _default = {
1147
933
  switch (_context10.prev = _context10.next) {
1148
934
  case 0:
1149
935
  start = Date.now();
1150
-
1151
936
  poll = /*#__PURE__*/function () {
1152
937
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1153
938
  var instrumentation;
@@ -1157,16 +942,13 @@ var _default = {
1157
942
  case 0:
1158
943
  _context9.next = 2;
1159
944
  return _this7.getInstrumentation(client, instrumentationId);
1160
-
1161
945
  case 2:
1162
946
  instrumentation = _context9.sent;
1163
947
  _context9.t0 = instrumentation.data.state;
1164
948
  _context9.next = _context9.t0 === 'DELETED' ? 6 : _context9.t0 === 'FAILED_INSTRUMENTATION' ? 7 : _context9.t0 === 'FINISHED_INSTRUMENTATION' ? 9 : 10;
1165
949
  break;
1166
-
1167
950
  case 6:
1168
951
  throw new Error('Protection canceled by user');
1169
-
1170
952
  case 7:
1171
953
  instrumentation.errors = instrumentation.errors.concat(instrumentation.data.instrumentationErrors.map(function (e) {
1172
954
  return {
@@ -1174,19 +956,15 @@ var _default = {
1174
956
  };
1175
957
  }));
1176
958
  return _context9.abrupt("return", errorHandler(instrumentation));
1177
-
1178
959
  case 9:
1179
960
  return _context9.abrupt("return", instrumentation);
1180
-
1181
961
  case 10:
1182
962
  _context9.next = 12;
1183
963
  return new Promise(function (resolve) {
1184
964
  return setTimeout(resolve, getPollingInterval(start));
1185
965
  });
1186
-
1187
966
  case 12:
1188
967
  return _context9.abrupt("return", poll());
1189
-
1190
968
  case 13:
1191
969
  case "end":
1192
970
  return _context9.stop();
@@ -1194,14 +972,11 @@ var _default = {
1194
972
  }
1195
973
  }, _callee9);
1196
974
  }));
1197
-
1198
975
  return function poll() {
1199
976
  return _ref6.apply(this, arguments);
1200
977
  };
1201
978
  }();
1202
-
1203
979
  return _context10.abrupt("return", poll());
1204
-
1205
980
  case 3:
1206
981
  case "end":
1207
982
  return _context10.stop();
@@ -1218,46 +993,35 @@ var _default = {
1218
993
  switch (_context11.prev = _context11.next) {
1219
994
  case 0:
1220
995
  retriesLeft = _config2.default.maxRetries;
1221
-
1222
996
  case 1:
1223
997
  _context11.prev = 1;
1224
998
  _context11.next = 4;
1225
999
  return action();
1226
-
1227
1000
  case 4:
1228
1001
  return _context11.abrupt("return", _context11.sent);
1229
-
1230
1002
  case 7:
1231
1003
  _context11.prev = 7;
1232
1004
  _context11.t0 = _context11["catch"](1);
1233
-
1234
1005
  if (!(retriesLeft <= 0)) {
1235
1006
  _context11.next = 11;
1236
1007
  break;
1237
1008
  }
1238
-
1239
1009
  throw _context11.t0;
1240
-
1241
1010
  case 11:
1242
1011
  if (!(_context11.t0.statusCode !== _constants.HTTP_STATUS_CODES.SERVICE_UNAVAILABLE && _context11.t0.statusCode !== _constants.HTTP_STATUS_CODES.GATEWAY_TIMEOUT)) {
1243
1012
  _context11.next = 13;
1244
1013
  break;
1245
1014
  }
1246
-
1247
1015
  throw _context11.t0;
1248
-
1249
1016
  case 13:
1250
1017
  // Retry
1251
1018
  if (debug) {
1252
1019
  console.log('Retrying request');
1253
1020
  }
1254
-
1255
1021
  retriesLeft--;
1256
-
1257
1022
  case 15:
1258
1023
  _context11.next = 1;
1259
1024
  break;
1260
-
1261
1025
  case 17:
1262
1026
  case "end":
1263
1027
  return _context11.stop();
@@ -1268,7 +1032,6 @@ var _default = {
1268
1032
  },
1269
1033
  pollProtection: function pollProtection(client, applicationId, protectionId, fragments) {
1270
1034
  var _this8 = this;
1271
-
1272
1035
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1273
1036
  var start, poll;
1274
1037
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
@@ -1276,7 +1039,6 @@ var _default = {
1276
1039
  switch (_context13.prev = _context13.next) {
1277
1040
  case 0:
1278
1041
  start = Date.now();
1279
-
1280
1042
  poll = /*#__PURE__*/function () {
1281
1043
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1282
1044
  var applicationProtection, state;
@@ -1288,45 +1050,34 @@ var _default = {
1288
1050
  return _this8.withRetries(function () {
1289
1051
  return _this8.getApplicationProtection(client, applicationId, protectionId, fragments);
1290
1052
  });
1291
-
1292
1053
  case 2:
1293
1054
  applicationProtection = _context12.sent;
1294
-
1295
1055
  if (!applicationProtection.errors) {
1296
1056
  _context12.next = 8;
1297
1057
  break;
1298
1058
  }
1299
-
1300
1059
  console.log('Error polling protection', applicationProtection.errors);
1301
1060
  throw new Error("Protection failed. For more information visit: ".concat(APP_URL, "."));
1302
-
1303
1061
  case 8:
1304
1062
  state = applicationProtection.data.applicationProtection.state;
1305
-
1306
1063
  if (!(state !== 'finished' && state !== 'errored' && state !== 'canceled')) {
1307
1064
  _context12.next = 15;
1308
1065
  break;
1309
1066
  }
1310
-
1311
1067
  _context12.next = 12;
1312
1068
  return new Promise(function (resolve) {
1313
1069
  return setTimeout(resolve, getPollingInterval(start));
1314
1070
  });
1315
-
1316
1071
  case 12:
1317
1072
  return _context12.abrupt("return", poll());
1318
-
1319
1073
  case 15:
1320
1074
  if (!(state === 'canceled')) {
1321
1075
  _context12.next = 19;
1322
1076
  break;
1323
1077
  }
1324
-
1325
1078
  throw new Error('Protection canceled by user');
1326
-
1327
1079
  case 19:
1328
1080
  return _context12.abrupt("return", applicationProtection.data.applicationProtection);
1329
-
1330
1081
  case 20:
1331
1082
  case "end":
1332
1083
  return _context12.stop();
@@ -1334,14 +1085,11 @@ var _default = {
1334
1085
  }
1335
1086
  }, _callee12);
1336
1087
  }));
1337
-
1338
1088
  return function poll() {
1339
1089
  return _ref7.apply(this, arguments);
1340
1090
  };
1341
1091
  }();
1342
-
1343
1092
  return _context13.abrupt("return", poll());
1344
-
1345
1093
  case 3:
1346
1094
  case "end":
1347
1095
  return _context13.stop();
@@ -1352,7 +1100,6 @@ var _default = {
1352
1100
  },
1353
1101
  pollProtections: function pollProtections(client, applicationId, protectionIds, fragments) {
1354
1102
  var _this9 = this;
1355
-
1356
1103
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1357
1104
  var start, seen, poll;
1358
1105
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
@@ -1363,18 +1110,14 @@ var _default = {
1363
1110
  _context15.next = 5;
1364
1111
  break;
1365
1112
  }
1366
-
1367
1113
  _context15.next = 3;
1368
1114
  return _this9.pollProtection(client, applicationId, protectionIds[0], fragments);
1369
-
1370
1115
  case 3:
1371
1116
  _context15.t0 = _context15.sent;
1372
1117
  return _context15.abrupt("return", [_context15.t0]);
1373
-
1374
1118
  case 5:
1375
1119
  start = Date.now();
1376
1120
  seen = {};
1377
-
1378
1121
  poll = /*#__PURE__*/function () {
1379
1122
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1380
1123
  var applicationProtections, ended;
@@ -1388,53 +1131,43 @@ var _default = {
1388
1131
  protectionIds: protectionIds
1389
1132
  }, fragments.applicationProtection, ["$protectionIds: [String]"]);
1390
1133
  });
1391
-
1392
1134
  case 2:
1393
1135
  applicationProtections = _context14.sent;
1394
-
1395
1136
  if (!applicationProtections.errors) {
1396
1137
  _context14.next = 8;
1397
1138
  break;
1398
1139
  }
1399
-
1400
1140
  console.log('Error polling protection', applicationProtections.errors);
1401
1141
  throw new Error("Protection failed. For more information visit: ".concat(APP_URL, "."));
1402
-
1403
1142
  case 8:
1404
1143
  ended = applicationProtections.data.applicationProtections.filter(function (_ref9) {
1405
1144
  var state = _ref9.state;
1406
1145
  return state === 'finished' || state === 'errored' || state === 'canceled';
1407
1146
  }); // print progress
1408
-
1409
1147
  ended.filter(function (_ref10) {
1410
1148
  var _id = _ref10._id,
1411
- state = _ref10.state;
1149
+ state = _ref10.state;
1412
1150
  return !seen[_id] && state !== 'canceled';
1413
1151
  }).forEach(function (_ref11) {
1414
1152
  var _id = _ref11._id,
1415
- startedAt = _ref11.startedAt,
1416
- finishedAt = _ref11.finishedAt,
1417
- state = _ref11.state;
1153
+ startedAt = _ref11.startedAt,
1154
+ finishedAt = _ref11.finishedAt,
1155
+ state = _ref11.state;
1418
1156
  seen[_id] = true;
1419
1157
  console.log("[".concat(Object.keys(seen).length, "/").concat(protectionIds.length, "] Protection=").concat(_id, ", state=").concat(state, ", build-time=").concat(Math.round((new Date(finishedAt) - new Date(startedAt)) / 1000), "s"));
1420
1158
  });
1421
-
1422
1159
  if (!(ended.length < protectionIds.length)) {
1423
1160
  _context14.next = 14;
1424
1161
  break;
1425
1162
  }
1426
-
1427
1163
  _context14.next = 13;
1428
1164
  return new Promise(function (resolve) {
1429
1165
  return setTimeout(resolve, getPollingInterval(start));
1430
1166
  });
1431
-
1432
1167
  case 13:
1433
1168
  return _context14.abrupt("return", poll());
1434
-
1435
1169
  case 14:
1436
1170
  return _context14.abrupt("return", applicationProtections.data.applicationProtections);
1437
-
1438
1171
  case 15:
1439
1172
  case "end":
1440
1173
  return _context14.stop();
@@ -1442,14 +1175,11 @@ var _default = {
1442
1175
  }
1443
1176
  }, _callee14);
1444
1177
  }));
1445
-
1446
1178
  return function poll() {
1447
1179
  return _ref8.apply(this, arguments);
1448
1180
  };
1449
1181
  }();
1450
-
1451
1182
  return _context15.abrupt("return", poll());
1452
-
1453
1183
  case 9:
1454
1184
  case "end":
1455
1185
  return _context15.stop();
@@ -1466,7 +1196,6 @@ var _default = {
1466
1196
  switch (_context16.prev = _context16.next) {
1467
1197
  case 0:
1468
1198
  return _context16.abrupt("return", client.post('/application', mutations.createApplication(data, fragments)));
1469
-
1470
1199
  case 1:
1471
1200
  case "end":
1472
1201
  return _context16.stop();
@@ -1483,7 +1212,6 @@ var _default = {
1483
1212
  switch (_context17.prev = _context17.next) {
1484
1213
  case 0:
1485
1214
  return _context17.abrupt("return", client.post('/application', mutations.duplicateApplication(data, fragments)));
1486
-
1487
1215
  case 1:
1488
1216
  case "end":
1489
1217
  return _context17.stop();
@@ -1500,7 +1228,6 @@ var _default = {
1500
1228
  switch (_context18.prev = _context18.next) {
1501
1229
  case 0:
1502
1230
  return _context18.abrupt("return", client.post('/application', mutations.removeApplication(id)));
1503
-
1504
1231
  case 1:
1505
1232
  case "end":
1506
1233
  return _context18.stop();
@@ -1517,7 +1244,6 @@ var _default = {
1517
1244
  switch (_context19.prev = _context19.next) {
1518
1245
  case 0:
1519
1246
  return _context19.abrupt("return", client.post('/application', mutations.removeProtection(id, appId, fragments)));
1520
-
1521
1247
  case 1:
1522
1248
  case "end":
1523
1249
  return _context19.stop();
@@ -1536,11 +1262,9 @@ var _default = {
1536
1262
  case 0:
1537
1263
  _context20.next = 2;
1538
1264
  return mutations.cancelProtection(id, appId, fragments);
1539
-
1540
1265
  case 2:
1541
1266
  mutation = _context20.sent;
1542
1267
  return _context20.abrupt("return", client.post('/application', mutation));
1543
-
1544
1268
  case 4:
1545
1269
  case "end":
1546
1270
  return _context20.stop();
@@ -1559,11 +1283,9 @@ var _default = {
1559
1283
  case 0:
1560
1284
  _context21.next = 2;
1561
1285
  return mutations.updateApplication(application, fragments);
1562
-
1563
1286
  case 2:
1564
1287
  mutation = _context21.sent;
1565
1288
  return _context21.abrupt("return", client.post('/application', mutation));
1566
-
1567
1289
  case 4:
1568
1290
  case "end":
1569
1291
  return _context21.stop();
@@ -1582,11 +1304,9 @@ var _default = {
1582
1304
  case 0:
1583
1305
  _context22.next = 2;
1584
1306
  return mutations.unlockApplication(application, fragments);
1585
-
1586
1307
  case 2:
1587
1308
  mutation = _context22.sent;
1588
1309
  return _context22.abrupt("return", client.post('/application', mutation));
1589
-
1590
1310
  case 4:
1591
1311
  case "end":
1592
1312
  return _context22.stop();
@@ -1605,11 +1325,9 @@ var _default = {
1605
1325
  case 0:
1606
1326
  _context23.next = 2;
1607
1327
  return queries.getApplication(applicationId, fragments, params);
1608
-
1609
1328
  case 2:
1610
1329
  query = _context23.sent;
1611
1330
  return _context23.abrupt("return", client.get('/application', query));
1612
-
1613
1331
  case 4:
1614
1332
  case "end":
1615
1333
  return _context23.stop();
@@ -1628,11 +1346,9 @@ var _default = {
1628
1346
  case 0:
1629
1347
  _context24.next = 2;
1630
1348
  return queries.getApplicationSource(sourceId, fragments, limits);
1631
-
1632
1349
  case 2:
1633
1350
  query = _context24.sent;
1634
1351
  return _context24.abrupt("return", client.get('/application', query));
1635
-
1636
1352
  case 4:
1637
1353
  case "end":
1638
1354
  return _context24.stop();
@@ -1651,7 +1367,6 @@ var _default = {
1651
1367
  case 0:
1652
1368
  query = queries.getApplicationProtections(applicationId, params, fragments, queryArgs);
1653
1369
  return _context25.abrupt("return", client.get('/application', query));
1654
-
1655
1370
  case 2:
1656
1371
  case "end":
1657
1372
  return _context25.stop();
@@ -1670,11 +1385,9 @@ var _default = {
1670
1385
  case 0:
1671
1386
  _context26.next = 2;
1672
1387
  return queries.getApplicationProtectionsCount(applicationId, fragments);
1673
-
1674
1388
  case 2:
1675
1389
  query = _context26.sent;
1676
1390
  return _context26.abrupt("return", client.get('/application', query));
1677
-
1678
1391
  case 4:
1679
1392
  case "end":
1680
1393
  return _context26.stop();
@@ -1693,11 +1406,9 @@ var _default = {
1693
1406
  case 0:
1694
1407
  _context27.next = 2;
1695
1408
  return mutations.createTemplate(template, fragments);
1696
-
1697
1409
  case 2:
1698
1410
  mutation = _context27.sent;
1699
1411
  return _context27.abrupt("return", client.post('/application', mutation));
1700
-
1701
1412
  case 4:
1702
1413
  case "end":
1703
1414
  return _context27.stop();
@@ -1716,11 +1427,9 @@ var _default = {
1716
1427
  case 0:
1717
1428
  _context28.next = 2;
1718
1429
  return mutations.removeTemplate(id);
1719
-
1720
1430
  case 2:
1721
1431
  mutation = _context28.sent;
1722
1432
  return _context28.abrupt("return", client.post('/application', mutation));
1723
-
1724
1433
  case 4:
1725
1434
  case "end":
1726
1435
  return _context28.stop();
@@ -1739,11 +1448,9 @@ var _default = {
1739
1448
  case 0:
1740
1449
  _context29.next = 2;
1741
1450
  return queries.getTemplates(fragments);
1742
-
1743
1451
  case 2:
1744
1452
  query = _context29.sent;
1745
1453
  return _context29.abrupt("return", client.get('/application', query));
1746
-
1747
1454
  case 4:
1748
1455
  case "end":
1749
1456
  return _context29.stop();
@@ -1762,11 +1469,9 @@ var _default = {
1762
1469
  case 0:
1763
1470
  _context30.next = 2;
1764
1471
  return queries.getApplications(fragments, params);
1765
-
1766
1472
  case 2:
1767
1473
  query = _context30.sent;
1768
1474
  return _context30.abrupt("return", client.get('/application', query));
1769
-
1770
1475
  case 4:
1771
1476
  case "end":
1772
1477
  return _context30.stop();
@@ -1778,7 +1483,6 @@ var _default = {
1778
1483
  //
1779
1484
  addApplicationSource: function addApplicationSource(client, applicationId, applicationSource, fragments) {
1780
1485
  var _this10 = this;
1781
-
1782
1486
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
1783
1487
  var mutation;
1784
1488
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
@@ -1787,13 +1491,11 @@ var _default = {
1787
1491
  case 0:
1788
1492
  _context31.next = 2;
1789
1493
  return mutations.addApplicationSource(applicationId, applicationSource, fragments);
1790
-
1791
1494
  case 2:
1792
1495
  mutation = _context31.sent;
1793
1496
  return _context31.abrupt("return", _this10.withRetries(function () {
1794
1497
  return client.post('/application', mutation);
1795
1498
  }));
1796
-
1797
1499
  case 4:
1798
1500
  case "end":
1799
1501
  return _context31.stop();
@@ -1812,16 +1514,13 @@ var _default = {
1812
1514
  case 0:
1813
1515
  _context32.next = 2;
1814
1516
  return getFileFromUrl(client, url);
1815
-
1816
1517
  case 2:
1817
1518
  file = _context32.sent;
1818
1519
  _context32.next = 5;
1819
1520
  return mutations.addApplicationSource(applicationId, file, fragments);
1820
-
1821
1521
  case 5:
1822
1522
  mutation = _context32.sent;
1823
1523
  return _context32.abrupt("return", client.post('/application', mutation));
1824
-
1825
1524
  case 7:
1826
1525
  case "end":
1827
1526
  return _context32.stop();
@@ -1840,11 +1539,9 @@ var _default = {
1840
1539
  case 0:
1841
1540
  _context33.next = 2;
1842
1541
  return mutations.updateApplicationSource(applicationSource, fragments);
1843
-
1844
1542
  case 2:
1845
1543
  mutation = _context33.sent;
1846
1544
  return _context33.abrupt("return", client.post('/application', mutation));
1847
-
1848
1545
  case 4:
1849
1546
  case "end":
1850
1547
  return _context33.stop();
@@ -1856,7 +1553,6 @@ var _default = {
1856
1553
  //
1857
1554
  removeSourceFromApplication: function removeSourceFromApplication(client, sourceId, applicationId, fragments) {
1858
1555
  var _this11 = this;
1859
-
1860
1556
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
1861
1557
  var mutation;
1862
1558
  return _regeneratorRuntime().wrap(function _callee34$(_context34) {
@@ -1865,13 +1561,11 @@ var _default = {
1865
1561
  case 0:
1866
1562
  _context34.next = 2;
1867
1563
  return mutations.removeSourceFromApplication(sourceId, applicationId, fragments);
1868
-
1869
1564
  case 2:
1870
1565
  mutation = _context34.sent;
1871
1566
  return _context34.abrupt("return", _this11.withRetries(function () {
1872
1567
  return client.post('/application', mutation);
1873
1568
  }));
1874
-
1875
1569
  case 4:
1876
1570
  case "end":
1877
1571
  return _context34.stop();
@@ -1890,11 +1584,9 @@ var _default = {
1890
1584
  case 0:
1891
1585
  _context35.next = 2;
1892
1586
  return mutations.applyTemplate(templateId, appId, fragments);
1893
-
1894
1587
  case 2:
1895
1588
  mutation = _context35.sent;
1896
1589
  return _context35.abrupt("return", client.post('/application', mutation));
1897
-
1898
1590
  case 4:
1899
1591
  case "end":
1900
1592
  return _context35.stop();
@@ -1913,11 +1605,9 @@ var _default = {
1913
1605
  case 0:
1914
1606
  _context36.next = 2;
1915
1607
  return mutations.updateTemplate(template, fragments);
1916
-
1917
1608
  case 2:
1918
1609
  mutation = _context36.sent;
1919
1610
  return _context36.abrupt("return", client.post('/application', mutation));
1920
-
1921
1611
  case 4:
1922
1612
  case "end":
1923
1613
  return _context36.stop();
@@ -1935,7 +1625,6 @@ var _default = {
1935
1625
  return _context37.abrupt("return", client.get('/profiling-run', {
1936
1626
  applicationId: applicationId
1937
1627
  }));
1938
-
1939
1628
  case 1:
1940
1629
  case "end":
1941
1630
  return _context37.stop();
@@ -1953,7 +1642,6 @@ var _default = {
1953
1642
  return _context38.abrupt("return", client.patch("/profiling-run/".concat(profilingId), {
1954
1643
  state: 'DELETED'
1955
1644
  }));
1956
-
1957
1645
  case 1:
1958
1646
  case "end":
1959
1647
  return _context38.stop();
@@ -1962,7 +1650,6 @@ var _default = {
1962
1650
  }, _callee38);
1963
1651
  }))();
1964
1652
  },
1965
-
1966
1653
  /**
1967
1654
  * Starts a new instrumentation process.
1968
1655
  * Previous instrumentation must be deleted, before starting a new one.
@@ -1972,7 +1659,6 @@ var _default = {
1972
1659
  */
1973
1660
  startInstrumentation: function startInstrumentation(client, applicationId) {
1974
1661
  var _this12 = this;
1975
-
1976
1662
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
1977
1663
  var instrumentation;
1978
1664
  return _regeneratorRuntime().wrap(function _callee39$(_context39) {
@@ -1983,23 +1669,18 @@ var _default = {
1983
1669
  return _this12.getApplicationProfiling(client, applicationId).catch(function (e) {
1984
1670
  if (e.statusCode !== 404) throw e;
1985
1671
  });
1986
-
1987
1672
  case 2:
1988
1673
  instrumentation = _context39.sent;
1989
-
1990
1674
  if (!instrumentation) {
1991
1675
  _context39.next = 6;
1992
1676
  break;
1993
1677
  }
1994
-
1995
1678
  _context39.next = 6;
1996
1679
  return _this12.deleteProfiling(client, instrumentation.data.id);
1997
-
1998
1680
  case 6:
1999
1681
  return _context39.abrupt("return", client.post('/profiling-run', {
2000
1682
  applicationId: applicationId
2001
1683
  }));
2002
-
2003
1684
  case 7:
2004
1685
  case "end":
2005
1686
  return _context39.stop();
@@ -2012,24 +1693,20 @@ var _default = {
2012
1693
  createApplicationProtection: function createApplicationProtection(client, applicationId, protectionOptions, fragments) {
2013
1694
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
2014
1695
  var _yield$introspection$, args, mutation;
2015
-
2016
1696
  return _regeneratorRuntime().wrap(function _callee40$(_context40) {
2017
1697
  while (1) {
2018
1698
  switch (_context40.prev = _context40.next) {
2019
1699
  case 0:
2020
1700
  _context40.next = 2;
2021
1701
  return introspection.mutation(client, 'createApplicationProtection');
2022
-
2023
1702
  case 2:
2024
1703
  _yield$introspection$ = _context40.sent;
2025
1704
  args = _yield$introspection$.args;
2026
1705
  _context40.next = 6;
2027
1706
  return mutations.createApplicationProtection(applicationId, fragments, protectionOptions, args);
2028
-
2029
1707
  case 6:
2030
1708
  mutation = _context40.sent;
2031
1709
  return _context40.abrupt("return", client.post('/application', mutation));
2032
-
2033
1710
  case 8:
2034
1711
  case "end":
2035
1712
  return _context40.stop();
@@ -2038,7 +1715,6 @@ var _default = {
2038
1715
  }, _callee40);
2039
1716
  }))();
2040
1717
  },
2041
-
2042
1718
  /**
2043
1719
  * Create one or more application protections at once
2044
1720
  * @param {JscramblerClient} client
@@ -2050,7 +1726,6 @@ var _default = {
2050
1726
  */
2051
1727
  createApplicationProtections: function createApplicationProtections(client, applicationId, protectionOptions, fragments) {
2052
1728
  var _this13 = this;
2053
-
2054
1729
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
2055
1730
  var result, mutationType, mutation;
2056
1731
  return _regeneratorRuntime().wrap(function _callee41$(_context41) {
@@ -2061,54 +1736,41 @@ var _default = {
2061
1736
  _context41.next = 7;
2062
1737
  break;
2063
1738
  }
2064
-
2065
1739
  _context41.next = 3;
2066
1740
  return _this13.createApplicationProtection(client, applicationId, _objectSpread(_objectSpread({}, protectionOptions), {}, {
2067
1741
  numberOfProtections: undefined
2068
1742
  }), fragments);
2069
-
2070
1743
  case 3:
2071
1744
  result = _context41.sent;
2072
-
2073
1745
  if (result.data && result.data.createApplicationProtection) {
2074
1746
  result.data.protections = [result.data.createApplicationProtection];
2075
1747
  delete result.data.createApplicationProtection;
2076
1748
  }
2077
-
2078
1749
  _context41.next = 18;
2079
1750
  break;
2080
-
2081
1751
  case 7:
2082
1752
  _context41.next = 9;
2083
1753
  return introspection.mutation(client, 'createApplicationProtections');
2084
-
2085
1754
  case 9:
2086
1755
  mutationType = _context41.sent;
2087
-
2088
1756
  if (!mutationType) {
2089
1757
  console.error("\"Create multiple protections at once\" it's only available on Jscrambler version 7.2 and above.");
2090
1758
  process.exit(1);
2091
1759
  }
2092
-
2093
1760
  _context41.next = 13;
2094
1761
  return mutations.createApplicationProtections(applicationId, fragments, protectionOptions, mutationType.args);
2095
-
2096
1762
  case 13:
2097
1763
  mutation = _context41.sent;
2098
1764
  _context41.next = 16;
2099
1765
  return client.post('/application', mutation);
2100
-
2101
1766
  case 16:
2102
1767
  result = _context41.sent;
2103
-
2104
1768
  if (result.data && result.data.createApplicationProtections) {
2105
1769
  result.data.protections = result.data.createApplicationProtections.protections;
2106
1770
  delete result.data.createApplicationProtections;
2107
1771
  }
2108
-
2109
1772
  case 18:
2110
1773
  return _context41.abrupt("return", result);
2111
-
2112
1774
  case 19:
2113
1775
  case "end":
2114
1776
  return _context41.stop();
@@ -2117,7 +1779,6 @@ var _default = {
2117
1779
  }, _callee41);
2118
1780
  }))();
2119
1781
  },
2120
-
2121
1782
  /**
2122
1783
  * @param {object} client
2123
1784
  * @param {string} instrumentationId
@@ -2130,7 +1791,6 @@ var _default = {
2130
1791
  switch (_context42.prev = _context42.next) {
2131
1792
  case 0:
2132
1793
  return _context42.abrupt("return", client.get("/profiling-run/".concat(instrumentationId)));
2133
-
2134
1794
  case 1:
2135
1795
  case "end":
2136
1796
  return _context42.stop();
@@ -2149,11 +1809,9 @@ var _default = {
2149
1809
  case 0:
2150
1810
  _context43.next = 2;
2151
1811
  return queries.getProtection(applicationId, protectionId, fragments);
2152
-
2153
1812
  case 2:
2154
1813
  query = _context43.sent;
2155
1814
  return _context43.abrupt("return", client.get('/application', query));
2156
-
2157
1815
  case 4:
2158
1816
  case "end":
2159
1817
  return _context43.stop();
@@ -2170,7 +1828,6 @@ var _default = {
2170
1828
  switch (_context44.prev = _context44.next) {
2171
1829
  case 0:
2172
1830
  return _context44.abrupt("return", client.get("/application/sourceMaps/".concat(protectionId), null, false));
2173
-
2174
1831
  case 1:
2175
1832
  case "end":
2176
1833
  return _context44.stop();
@@ -2186,7 +1843,6 @@ var _default = {
2186
1843
  switch (_context45.prev = _context45.next) {
2187
1844
  case 0:
2188
1845
  return _context45.abrupt("return", client.get("/application/symbolTable/".concat(protectionId), null, false));
2189
-
2190
1846
  case 1:
2191
1847
  case "end":
2192
1848
  return _context45.stop();
@@ -2203,7 +1859,6 @@ var _default = {
2203
1859
  switch (_context46.prev = _context46.next) {
2204
1860
  case 0:
2205
1861
  return _context46.abrupt("return", client.get("/application/download/".concat(protectionId), null, false));
2206
-
2207
1862
  case 1:
2208
1863
  case "end":
2209
1864
  return _context46.stop();
@@ -2212,7 +1867,6 @@ var _default = {
2212
1867
  }, _callee46);
2213
1868
  }))();
2214
1869
  },
2215
-
2216
1870
  /**
2217
1871
  * @param {object} client
2218
1872
  * @param {string} instrumentationId
@@ -2221,7 +1875,6 @@ var _default = {
2221
1875
  downloadApplicationInstrumented: function downloadApplicationInstrumented(client, instrumentationId) {
2222
1876
  return client.get("/profiling-run/".concat(instrumentationId, "/instrumented-bundle"), null, false);
2223
1877
  },
2224
-
2225
1878
  /**
2226
1879
  * Introspect method to check if a certain field is supported.
2227
1880
  * @param {Object} config jscrambler client config
@@ -2232,7 +1885,6 @@ var _default = {
2232
1885
  */
2233
1886
  introspectFieldOnMethod: function introspectFieldOnMethod(config, queryOrMutation, methodName, field) {
2234
1887
  var _this14 = this;
2235
-
2236
1888
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
2237
1889
  var instrospectionType, client, result, dataArg, isFieldSupported;
2238
1890
  return _regeneratorRuntime().wrap(function _callee47$(_context47) {
@@ -2243,18 +1895,14 @@ var _default = {
2243
1895
  client = new _this14.Client(_objectSpread({}, config));
2244
1896
  _context47.next = 4;
2245
1897
  return instrospectionType(client, methodName);
2246
-
2247
1898
  case 4:
2248
1899
  result = _context47.sent;
2249
-
2250
1900
  if (!(!result || !result.args)) {
2251
1901
  _context47.next = 8;
2252
1902
  break;
2253
1903
  }
2254
-
2255
1904
  debug && console.log("Method *".concat(methodName, "* not found."));
2256
1905
  return _context47.abrupt("return", false);
2257
-
2258
1906
  case 8:
2259
1907
  dataArg = result.args.find(function (arg) {
2260
1908
  return arg.name === 'data';
@@ -2263,7 +1911,6 @@ var _default = {
2263
1911
  return e.name === field;
2264
1912
  });
2265
1913
  return _context47.abrupt("return", isFieldSupported);
2266
-
2267
1914
  case 11:
2268
1915
  case "end":
2269
1916
  return _context47.stop();
@@ -2274,7 +1921,6 @@ var _default = {
2274
1921
  }
2275
1922
  };
2276
1923
  exports.default = _default;
2277
-
2278
1924
  function getFileFromUrl(client, url) {
2279
1925
  return _axios.default.get(url).then(function (res) {
2280
1926
  return {