jscrambler 6.4.19 → 6.4.21

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
@@ -29,13 +29,11 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread n
29
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); }
30
30
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
31
31
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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; }
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; }
33
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; }
34
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; }
35
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
36
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
37
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
38
- 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 methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), 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; }
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; }
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; }
39
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); } }
40
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); }); }; }
41
39
  var intoObjectType = introspection.intoObjectType;
@@ -44,6 +42,7 @@ var APP_URL = 'https://app.jscrambler.com';
44
42
  var POLLING_MIN_INTERVAL = 1000;
45
43
  var POLLING_MAX_INTERVAL = 10000;
46
44
  var INCREASE_POLL_INTERVAL_EVERY = 30000;
45
+ var MAX_PRINTED_ERRORS = 3;
47
46
 
48
47
  /**
49
48
  * Calculate polling interval for protection and instrumentation.
@@ -73,9 +72,20 @@ function errorHandler(res) {
73
72
  return res;
74
73
  }
75
74
  function printSourcesErrors(errors) {
76
- console.error('Application sources errors:');
77
- console.error(JSON.stringify(errors, null, 2));
78
- console.error('');
75
+ console.error('Source errors:');
76
+ for (var i = 0; i < Math.min(MAX_PRINTED_ERRORS, errors.length); i++) {
77
+ var sourceErrorsMessage = errors[i].line ? ':' + errors[i].line + ':' + errors[i].column + ': ' : ': ';
78
+ console.error('- ' + errors[i].filename + sourceErrorsMessage + errors[i].message);
79
+ }
80
+ var errorsLeft = errors.length - MAX_PRINTED_ERRORS;
81
+ if (errorsLeft > 0) {
82
+ if (errorsLeft === 1) {
83
+ console.error('There is 1 more error.');
84
+ } else {
85
+ console.error('There are ' + errorsLeft + ' more errors.');
86
+ }
87
+ }
88
+ console.error();
79
89
  }
80
90
  function normalizeParameters(parameters) {
81
91
  var result;
@@ -118,93 +128,95 @@ var _default = {
118
128
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
119
129
  var sources, filesSrc, cwd, appProfiling, removeSourceRes, zipped, source, _filesSrc, i, l, content;
120
130
  return _regeneratorRuntime().wrap(function _callee$(_context) {
121
- while (1) switch (_context.prev = _context.next) {
122
- case 0:
123
- sources = _ref.sources, filesSrc = _ref.filesSrc, cwd = _ref.cwd, appProfiling = _ref.appProfiling;
124
- if (!(sources || filesSrc && filesSrc.length)) {
125
- _context.next = 8;
126
- break;
127
- }
128
- if (!(appProfiling && appProfiling.data && appProfiling.data.state === 'READY')) {
129
- _context.next = 4;
130
- break;
131
- }
132
- 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*.');
133
- case 4:
134
- _context.next = 6;
135
- return _this.removeSourceFromApplication(client, '', applicationId);
136
- case 6:
137
- removeSourceRes = _context.sent;
138
- errorHandler(removeSourceRes);
139
- case 8:
140
- if (!(filesSrc && filesSrc.length)) {
141
- _context.next = 17;
142
- break;
143
- }
144
- _filesSrc = [];
145
- for (i = 0, l = filesSrc.length; i < l; i += 1) {
146
- if (typeof filesSrc[i] === 'string') {
147
- _filesSrc = _filesSrc.concat((0, _utils.getMatchedFiles)(filesSrc[i]));
148
- } else {
149
- _filesSrc.push(filesSrc[i]);
131
+ while (1) {
132
+ switch (_context.prev = _context.next) {
133
+ case 0:
134
+ sources = _ref.sources, filesSrc = _ref.filesSrc, cwd = _ref.cwd, appProfiling = _ref.appProfiling;
135
+ if (!(sources || filesSrc && filesSrc.length)) {
136
+ _context.next = 8;
137
+ break;
138
+ }
139
+ if (!(appProfiling && appProfiling.data && appProfiling.data.state === 'READY')) {
140
+ _context.next = 4;
141
+ break;
142
+ }
143
+ 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*.');
144
+ case 4:
145
+ _context.next = 6;
146
+ return _this.removeSourceFromApplication(client, '', applicationId);
147
+ case 6:
148
+ removeSourceRes = _context.sent;
149
+ errorHandler(removeSourceRes);
150
+ case 8:
151
+ if (!(filesSrc && filesSrc.length)) {
152
+ _context.next = 17;
153
+ break;
154
+ }
155
+ _filesSrc = [];
156
+ for (i = 0, l = filesSrc.length; i < l; i += 1) {
157
+ if (typeof filesSrc[i] === 'string') {
158
+ _filesSrc = _filesSrc.concat((0, _utils.getMatchedFiles)(filesSrc[i]));
159
+ } else {
160
+ _filesSrc.push(filesSrc[i]);
161
+ }
150
162
  }
151
- }
152
- if (debug) {
153
- console.log('Creating zip from source files');
154
- }
155
- _context.next = 14;
156
- return (0, _zip.zip)(_filesSrc, cwd);
157
- case 14:
158
- zipped = _context.sent;
159
- _context.next = 22;
160
- break;
161
- case 17:
162
- if (!sources) {
163
+ if (debug) {
164
+ console.log('Creating zip from source files');
165
+ }
166
+ _context.next = 14;
167
+ return (0, _zip.zip)(_filesSrc, cwd);
168
+ case 14:
169
+ zipped = _context.sent;
163
170
  _context.next = 22;
164
171
  break;
165
- }
166
- if (debug) {
167
- console.log('Creating zip from sources');
168
- }
169
- _context.next = 21;
170
- return (0, _zip.zipSources)(sources);
171
- case 21:
172
- zipped = _context.sent;
173
- case 22:
174
- if (!zipped) {
175
- _context.next = 33;
176
- break;
177
- }
178
- _context.next = 25;
179
- return zipped.generateAsync({
180
- type: 'base64',
181
- compression: 'DEFLATE',
182
- compressionOptions: {
183
- // 1 - 9 (max compression)
184
- level: 5
172
+ case 17:
173
+ if (!sources) {
174
+ _context.next = 22;
175
+ break;
176
+ }
177
+ if (debug) {
178
+ console.log('Creating zip from sources');
179
+ }
180
+ _context.next = 21;
181
+ return (0, _zip.zipSources)(sources);
182
+ case 21:
183
+ zipped = _context.sent;
184
+ case 22:
185
+ if (!zipped) {
186
+ _context.next = 33;
187
+ break;
188
+ }
189
+ _context.next = 25;
190
+ return zipped.generateAsync({
191
+ type: 'base64',
192
+ compression: 'DEFLATE',
193
+ compressionOptions: {
194
+ // 1 - 9 (max compression)
195
+ level: 5
196
+ }
197
+ });
198
+ case 25:
199
+ content = _context.sent;
200
+ if (debug) {
201
+ console.log('Adding sources to application');
185
202
  }
186
- });
187
- case 25:
188
- content = _context.sent;
189
- if (debug) {
190
- console.log('Adding sources to application');
191
- }
192
- source = {
193
- content: content,
194
- filename: 'application.zip',
195
- extension: 'zip'
196
- };
197
- _context.t0 = errorHandler;
198
- _context.next = 31;
199
- return _this.addApplicationSource(client, applicationId, source);
200
- case 31:
201
- _context.t1 = _context.sent;
202
- (0, _context.t0)(_context.t1);
203
- case 33:
204
- return _context.abrupt("return", source);
205
- case 34:
206
- case "end":
207
- return _context.stop();
203
+ source = {
204
+ content: content,
205
+ filename: 'application.zip',
206
+ extension: 'zip'
207
+ };
208
+ _context.t0 = errorHandler;
209
+ _context.next = 31;
210
+ return _this.addApplicationSource(client, applicationId, source);
211
+ case 31:
212
+ _context.t1 = _context.sent;
213
+ (0, _context.t0)(_context.t1);
214
+ case 33:
215
+ return _context.abrupt("return", source);
216
+ case 34:
217
+ case "end":
218
+ return _context.stop();
219
+ }
208
220
  }
209
221
  }, _callee);
210
222
  }))();
@@ -257,369 +269,373 @@ var _default = {
257
269
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
258
270
  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;
259
271
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
260
- while (1) switch (_context4.prev = _context4.next) {
261
- case 0:
262
- start = Date.now();
263
- finalConfig = buildFinalConfig(configPathOrObject);
264
- applicationId = finalConfig.applicationId, host = finalConfig.host, port = finalConfig.port, basePath = finalConfig.basePath, protocol = finalConfig.protocol, cafile = finalConfig.cafile, keys = finalConfig.keys, sources = finalConfig.sources, _finalConfig$stream = finalConfig.stream, stream = _finalConfig$stream === void 0 ? true : _finalConfig$stream, cwd = finalConfig.cwd, params = finalConfig.params, applicationTypes = finalConfig.applicationTypes, languageSpecifications = finalConfig.languageSpecifications, sourceMaps = finalConfig.sourceMaps, randomizationSeed = finalConfig.randomizationSeed, areSubscribersOrdered = finalConfig.areSubscribersOrdered, useRecommendedOrder = finalConfig.useRecommendedOrder, _finalConfig$bail = finalConfig.bail, bail = _finalConfig$bail === void 0 ? true : _finalConfig$bail, jscramblerVersion = finalConfig.jscramblerVersion, debugMode = finalConfig.debugMode, proxy = finalConfig.proxy, utc = finalConfig.utc, clientId = finalConfig.clientId, tolerateMinification = finalConfig.tolerateMinification, codeHardeningThreshold = finalConfig.codeHardeningThreshold, useProfilingData = finalConfig.useProfilingData, browsers = finalConfig.browsers, useAppClassification = finalConfig.useAppClassification, profilingDataMode = finalConfig.profilingDataMode, removeProfilingData = finalConfig.removeProfilingData, skipSources = finalConfig.skipSources, inputSymbolTable = finalConfig.inputSymbolTable, entryPoint = finalConfig.entryPoint, excludeList = finalConfig.excludeList, numberOfProtections = finalConfig.numberOfProtections, ensureCodeAnnotation = finalConfig.ensureCodeAnnotation, forceAppEnvironment = finalConfig.forceAppEnvironment;
265
- accessKey = keys.accessKey, secretKey = keys.secretKey;
266
- client = new _this2.Client({
267
- accessKey: accessKey,
268
- secretKey: secretKey,
269
- host: host,
270
- port: port,
271
- basePath: basePath,
272
- protocol: protocol,
273
- cafile: cafile,
274
- jscramblerVersion: jscramblerVersion,
275
- proxy: proxy,
276
- utc: utc,
277
- clientId: clientId
278
- });
279
- filesSrc = finalConfig.filesSrc;
280
- filesDest = finalConfig.filesDest;
281
- if (sources) {
282
- filesSrc = undefined;
283
- }
284
- if (destCallback) {
285
- filesDest = undefined;
286
- }
287
- if (applicationId) {
288
- _context4.next = 11;
289
- break;
290
- }
291
- throw new Error('Required *applicationId* not provided');
292
- case 11:
293
- if (!(!filesDest && !destCallback)) {
294
- _context4.next = 13;
295
- break;
296
- }
297
- throw new Error('Required *filesDest* not provided');
298
- case 13:
299
- if (skipSources) {
300
- _context4.next = 26;
301
- break;
302
- }
303
- _context4.next = 16;
304
- return _this2.getApplicationProfiling(client, applicationId).catch(function (e) {
305
- if (typeof profilingDataMode === 'string' && profilingDataMode !== 'off') {
306
- switch (e.statusCode) {
307
- case _constants.HTTP_STATUS_CODES.FORBIDDEN:
308
- throw new Error("No ".concat(profilingDataMode, " profiling feature in your plan. Please set profilingDataMode to \"off\" or contact the Jscrambler Support."));
309
- case _constants.HTTP_STATUS_CODES.NOT_FOUND:
310
- if (profilingDataMode === 'automatic') {
311
- throw new Error('You can not use the automatic mode without previous profiling having been done.');
312
- }
313
- break;
314
- case _constants.HTTP_STATUS_CODES.SERVICE_UNAVAILABLE:
315
- if (profilingDataMode === 'automatic') {
316
- throw e;
317
- }
318
- }
272
+ while (1) {
273
+ switch (_context4.prev = _context4.next) {
274
+ case 0:
275
+ start = Date.now();
276
+ finalConfig = buildFinalConfig(configPathOrObject);
277
+ applicationId = finalConfig.applicationId, host = finalConfig.host, port = finalConfig.port, basePath = finalConfig.basePath, protocol = finalConfig.protocol, cafile = finalConfig.cafile, keys = finalConfig.keys, sources = finalConfig.sources, _finalConfig$stream = finalConfig.stream, stream = _finalConfig$stream === void 0 ? true : _finalConfig$stream, cwd = finalConfig.cwd, params = finalConfig.params, applicationTypes = finalConfig.applicationTypes, languageSpecifications = finalConfig.languageSpecifications, sourceMaps = finalConfig.sourceMaps, randomizationSeed = finalConfig.randomizationSeed, areSubscribersOrdered = finalConfig.areSubscribersOrdered, useRecommendedOrder = finalConfig.useRecommendedOrder, _finalConfig$bail = finalConfig.bail, bail = _finalConfig$bail === void 0 ? true : _finalConfig$bail, jscramblerVersion = finalConfig.jscramblerVersion, debugMode = finalConfig.debugMode, proxy = finalConfig.proxy, utc = finalConfig.utc, clientId = finalConfig.clientId, tolerateMinification = finalConfig.tolerateMinification, codeHardeningThreshold = finalConfig.codeHardeningThreshold, useProfilingData = finalConfig.useProfilingData, browsers = finalConfig.browsers, useAppClassification = finalConfig.useAppClassification, profilingDataMode = finalConfig.profilingDataMode, removeProfilingData = finalConfig.removeProfilingData, skipSources = finalConfig.skipSources, inputSymbolTable = finalConfig.inputSymbolTable, entryPoint = finalConfig.entryPoint, excludeList = finalConfig.excludeList, numberOfProtections = finalConfig.numberOfProtections, ensureCodeAnnotation = finalConfig.ensureCodeAnnotation, forceAppEnvironment = finalConfig.forceAppEnvironment;
278
+ accessKey = keys.accessKey, secretKey = keys.secretKey;
279
+ client = new _this2.Client({
280
+ accessKey: accessKey,
281
+ secretKey: secretKey,
282
+ host: host,
283
+ port: port,
284
+ basePath: basePath,
285
+ protocol: protocol,
286
+ cafile: cafile,
287
+ jscramblerVersion: jscramblerVersion,
288
+ proxy: proxy,
289
+ utc: utc,
290
+ clientId: clientId
291
+ });
292
+ filesSrc = finalConfig.filesSrc;
293
+ filesDest = finalConfig.filesDest;
294
+ if (sources) {
295
+ filesSrc = undefined;
319
296
  }
320
- });
321
- case 16:
322
- appProfiling = _context4.sent;
323
- if (!(appProfiling && removeProfilingData)) {
324
- _context4.next = 21;
325
- break;
326
- }
327
- _context4.next = 20;
328
- return _this2.deleteProfiling(client, appProfiling.data.id);
329
- case 20:
330
- appProfiling.data.state = 'DELETED';
331
- case 21:
332
- _context4.next = 23;
333
- return _this2.updateApplicationSources(client, applicationId, {
334
- sources: sources,
335
- filesSrc: filesSrc,
336
- cwd: cwd,
337
- appProfiling: appProfiling
338
- });
339
- case 23:
340
- source = _context4.sent;
341
- _context4.next = 27;
342
- break;
343
- case 26:
344
- console.log('Update source files SKIPPED');
345
- case 27:
346
- updateData = {
347
- _id: applicationId,
348
- debugMode: !!debugMode,
349
- tolerateMinification: tolerateMinification,
350
- codeHardeningThreshold: codeHardeningThreshold
351
- };
352
- if (params && Object.keys(params).length) {
353
- updateData.parameters = normalizeParameters(params);
354
- updateData.areSubscribersOrdered = Array.isArray(params);
355
- }
356
- dataToValidate = {
357
- applicationTypes: applicationTypes,
358
- areSubscribersOrdered: areSubscribersOrdered,
359
- browsers: browsers,
360
- languageSpecifications: languageSpecifications,
361
- profilingDataMode: profilingDataMode,
362
- sourceMaps: sourceMaps,
363
- useAppClassification: useAppClassification,
364
- ensureCodeAnnotation: ensureCodeAnnotation,
365
- useProfilingData: useProfilingData,
366
- useRecommendedOrder: useRecommendedOrder
367
- };
368
- for (prop in dataToValidate) {
369
- value = dataToValidate[prop];
370
- if (typeof value !== 'undefined') {
371
- updateData[prop] = value;
297
+ if (destCallback) {
298
+ filesDest = undefined;
372
299
  }
373
- }
374
- if (!(updateData.parameters || updateData.applicationTypes || updateData.languageSpecifications || updateData.browsers || typeof updateData.areSubscribersOrdered !== 'undefined')) {
375
- _context4.next = 41;
376
- break;
377
- }
378
- if (debug) {
379
- console.log('Updating parameters of protection');
380
- }
381
- _context4.next = 35;
382
- return intoObjectType(client, updateData, 'Application');
383
- case 35:
384
- applicationUpdate = _context4.sent;
385
- _context4.next = 38;
386
- return _this2.updateApplication(client, applicationUpdate);
387
- case 38:
388
- updateApplicationRes = _context4.sent;
389
- if (debug) {
390
- console.log('Finished updating parameters of protection');
391
- console.error(updateApplicationRes);
392
- }
393
- errorHandler(updateApplicationRes);
394
- case 41:
395
- if (debug) {
396
- console.log('Creating Application Protection');
397
- }
398
- delete updateData._id;
399
- protectionOptions = _objectSpread(_objectSpread({}, updateData), {}, {
400
- bail: bail,
401
- entryPoint: entryPoint,
402
- excludeList: excludeList,
403
- inputSymbolTable: inputSymbolTable,
404
- randomizationSeed: randomizationSeed,
405
- source: source,
406
- tolerateMinification: tolerateMinification,
407
- numberOfProtections: numberOfProtections,
408
- forceAppEnvironment: forceAppEnvironment
409
- });
410
- if (finalConfig.inputSymbolTable) {
411
- // Note: we can not use the fs.promises API because some users may not have node 10.
412
- // Once node 10 is old enough to be safe to assume that all users will have it, this
413
- // should be safe to replace with `await fs.promises.readFile`.
414
- inputSymbolTableContents = _fs.default.readFileSync(finalConfig.inputSymbolTable, 'utf-8');
415
- protectionOptions.inputSymbolTable = inputSymbolTableContents;
416
- }
417
- _context4.next = 47;
418
- return _this2.createApplicationProtections(client, applicationId, protectionOptions);
419
- case 47:
420
- createApplicationProtectionRes = _context4.sent;
421
- errorHandler(createApplicationProtectionRes);
422
- protectionIds = createApplicationProtectionRes.data.protections.map(function (_ref2) {
423
- var _id = _ref2._id;
424
- return _id;
425
- });
426
- onExitCancelProtection = /*#__PURE__*/function () {
427
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
428
- var i, protectionId;
429
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
430
- while (1) switch (_context2.prev = _context2.next) {
431
- case 0:
432
- i = 0;
433
- case 1:
434
- if (!(i < protectionIds.length)) {
435
- _context2.next = 15;
436
- break;
300
+ if (applicationId) {
301
+ _context4.next = 11;
302
+ break;
303
+ }
304
+ throw new Error('Required *applicationId* not provided');
305
+ case 11:
306
+ if (!(!filesDest && !destCallback)) {
307
+ _context4.next = 13;
308
+ break;
309
+ }
310
+ throw new Error('Required *filesDest* not provided');
311
+ case 13:
312
+ if (skipSources) {
313
+ _context4.next = 26;
314
+ break;
315
+ }
316
+ _context4.next = 16;
317
+ return _this2.getApplicationProfiling(client, applicationId).catch(function (e) {
318
+ if (typeof profilingDataMode === 'string' && profilingDataMode !== 'off') {
319
+ switch (e.statusCode) {
320
+ case _constants.HTTP_STATUS_CODES.FORBIDDEN:
321
+ throw new Error("No ".concat(profilingDataMode, " profiling feature in your plan. Please set profilingDataMode to \"off\" or contact the Jscrambler Support."));
322
+ case _constants.HTTP_STATUS_CODES.NOT_FOUND:
323
+ if (profilingDataMode === 'automatic') {
324
+ throw new Error('You can not use the automatic mode without previous profiling having been done.');
437
325
  }
438
- protectionId = protectionIds[i];
439
- _context2.prev = 3;
440
- _context2.next = 6;
441
- return _this2.cancelProtection(client, protectionId, applicationId);
442
- case 6:
443
- console.log('** Protection %s WAS CANCELLED **', protectionId);
444
- _context2.next = 12;
445
326
  break;
446
- case 9:
447
- _context2.prev = 9;
448
- _context2.t0 = _context2["catch"](3);
449
- if (debug) {
450
- console.error(_context2.t0);
327
+ case _constants.HTTP_STATUS_CODES.SERVICE_UNAVAILABLE:
328
+ if (profilingDataMode === 'automatic') {
329
+ throw e;
451
330
  }
452
- case 12:
453
- i++;
454
- _context2.next = 1;
455
- break;
456
- case 15:
457
- process.exit(1);
458
- case 16:
459
- case "end":
460
- return _context2.stop();
461
331
  }
462
- }, _callee2, null, [[3, 9]]);
463
- }));
464
- return function onExitCancelProtection() {
465
- return _ref3.apply(this, arguments);
332
+ }
333
+ });
334
+ case 16:
335
+ appProfiling = _context4.sent;
336
+ if (!(appProfiling && removeProfilingData)) {
337
+ _context4.next = 21;
338
+ break;
339
+ }
340
+ _context4.next = 20;
341
+ return _this2.deleteProfiling(client, appProfiling.data.id);
342
+ case 20:
343
+ appProfiling.data.state = 'DELETED';
344
+ case 21:
345
+ _context4.next = 23;
346
+ return _this2.updateApplicationSources(client, applicationId, {
347
+ sources: sources,
348
+ filesSrc: filesSrc,
349
+ cwd: cwd,
350
+ appProfiling: appProfiling
351
+ });
352
+ case 23:
353
+ source = _context4.sent;
354
+ _context4.next = 27;
355
+ break;
356
+ case 26:
357
+ console.log('Update source files SKIPPED');
358
+ case 27:
359
+ updateData = {
360
+ debugMode: !!debugMode,
361
+ tolerateMinification: tolerateMinification,
362
+ codeHardeningThreshold: codeHardeningThreshold
466
363
  };
467
- }();
468
- process.once('SIGINT', onExitCancelProtection).once('SIGTERM', onExitCancelProtection);
469
- _context4.t0 = _this2;
470
- _context4.t1 = client;
471
- _context4.t2 = applicationId;
472
- _context4.t3 = protectionIds;
473
- _context4.next = 58;
474
- return (0, _getProtectionDefaultFragments.default)(client);
475
- case 58:
476
- _context4.t4 = _context4.sent;
477
- _context4.next = 61;
478
- return _context4.t0.pollProtections.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3, _context4.t4);
479
- case 61:
480
- processedProtections = _context4.sent;
481
- process.removeListener('SIGINT', onExitCancelProtection).removeListener('SIGTERM', onExitCancelProtection);
482
- handleProtection = /*#__PURE__*/function () {
483
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(protection) {
484
- var _ref5,
485
- _ref5$outPrefix,
486
- outPrefix,
487
- _ref5$printProtection,
488
- printProtectionId,
489
- sourcesErrors,
490
- download,
491
- _args3 = arguments;
492
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
493
- while (1) switch (_context3.prev = _context3.next) {
494
- case 0:
495
- _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;
496
- if (protection.growthWarning) {
497
- 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, "."));
498
- }
499
- if (protection.hasForcedDateLock) {
500
- console.warn("Warning: Since your plan is a Trial, your protected files will stop working on ".concat(protection.parameters.find(function (p) {
501
- return p.name === 'dateLock' && p.options.endDate;
502
- }).options.endDate));
503
- }
504
- if (debug) {
505
- console.log('Finished protecting');
506
- }
507
- if (protection.deprecations) {
508
- protection.deprecations.forEach(function (deprecation) {
509
- if (deprecation.type === 'Transformation') {
510
- console.warn("Warning: ".concat(deprecation.type, " ").concat(deprecation.entity, " is no longer maintained. Please consider removing it from your configuration."));
511
- } else if (deprecation.type && deprecation.entity) {
512
- console.warn("Warning: ".concat(deprecation.type, " ").concat(deprecation.entity, " is deprecated."));
364
+ if (params && Object.keys(params).length) {
365
+ updateData.parameters = normalizeParameters(params);
366
+ updateData.areSubscribersOrdered = Array.isArray(params);
367
+ }
368
+ dataToValidate = {
369
+ applicationTypes: applicationTypes,
370
+ areSubscribersOrdered: areSubscribersOrdered,
371
+ browsers: browsers,
372
+ languageSpecifications: languageSpecifications,
373
+ profilingDataMode: profilingDataMode,
374
+ sourceMaps: sourceMaps,
375
+ useAppClassification: useAppClassification,
376
+ ensureCodeAnnotation: ensureCodeAnnotation,
377
+ useProfilingData: useProfilingData,
378
+ useRecommendedOrder: useRecommendedOrder
379
+ };
380
+ for (prop in dataToValidate) {
381
+ value = dataToValidate[prop];
382
+ if (typeof value !== 'undefined') {
383
+ updateData[prop] = value;
384
+ }
385
+ }
386
+ if (!(updateData.parameters || updateData.applicationTypes || updateData.languageSpecifications || updateData.browsers || typeof updateData.areSubscribersOrdered !== 'undefined')) {
387
+ _context4.next = 41;
388
+ break;
389
+ }
390
+ if (debug) {
391
+ console.log('Updating parameters of protection');
392
+ }
393
+ _context4.next = 35;
394
+ return intoObjectType(client, updateData, 'ApplicationUpdate');
395
+ case 35:
396
+ applicationUpdate = _context4.sent;
397
+ _context4.next = 38;
398
+ return _this2.updateApplication(client, applicationUpdate, undefined, applicationId);
399
+ case 38:
400
+ updateApplicationRes = _context4.sent;
401
+ if (debug) {
402
+ console.log('Finished updating parameters of protection');
403
+ console.error(updateApplicationRes);
404
+ }
405
+ errorHandler(updateApplicationRes);
406
+ case 41:
407
+ if (debug) {
408
+ console.log('Creating Application Protection');
409
+ }
410
+ protectionOptions = _objectSpread(_objectSpread({}, updateData), {}, {
411
+ bail: bail,
412
+ entryPoint: entryPoint,
413
+ excludeList: excludeList,
414
+ inputSymbolTable: inputSymbolTable,
415
+ randomizationSeed: randomizationSeed,
416
+ source: source,
417
+ tolerateMinification: tolerateMinification,
418
+ numberOfProtections: numberOfProtections,
419
+ forceAppEnvironment: forceAppEnvironment
420
+ });
421
+ if (finalConfig.inputSymbolTable) {
422
+ // Note: we can not use the fs.promises API because some users may not have node 10.
423
+ // Once node 10 is old enough to be safe to assume that all users will have it, this
424
+ // should be safe to replace with `await fs.promises.readFile`.
425
+ inputSymbolTableContents = _fs.default.readFileSync(finalConfig.inputSymbolTable, 'utf-8');
426
+ protectionOptions.inputSymbolTable = inputSymbolTableContents;
427
+ }
428
+ _context4.next = 46;
429
+ return _this2.createApplicationProtections(client, applicationId, protectionOptions);
430
+ case 46:
431
+ createApplicationProtectionRes = _context4.sent;
432
+ errorHandler(createApplicationProtectionRes);
433
+ protectionIds = createApplicationProtectionRes.data.protections.map(function (_ref2) {
434
+ var _id = _ref2._id;
435
+ return _id;
436
+ });
437
+ onExitCancelProtection = /*#__PURE__*/function () {
438
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
439
+ var i, protectionId;
440
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
441
+ while (1) {
442
+ switch (_context2.prev = _context2.next) {
443
+ case 0:
444
+ i = 0;
445
+ case 1:
446
+ if (!(i < protectionIds.length)) {
447
+ _context2.next = 15;
448
+ break;
513
449
  }
514
- });
515
- }
516
- sourcesErrors = [];
517
- protection.sources.forEach(function (s) {
518
- if (s.isSource && s.errorMessages && s.errorMessages.length > 0) {
519
- sourcesErrors.push.apply(sourcesErrors, _toConsumableArray(s.errorMessages.map(function (e) {
520
- return _objectSpread({
521
- filename: s.filename
522
- }, e);
523
- })));
524
- }
525
- });
526
- if (!(protection.state === 'errored')) {
527
- _context3.next = 15;
528
- break;
529
- }
530
- console.error('Global protection errors:');
531
- console.error("- ".concat(protection.errorMessage));
532
- console.error('');
533
- if (sourcesErrors.length > 0) {
534
- printSourcesErrors(sourcesErrors);
535
- }
536
- throw new Error("Protection failed. For more information visit: ".concat(APP_URL, "."));
537
- case 15:
538
- if (!(sourcesErrors.length > 0)) {
539
- _context3.next = 22;
540
- break;
541
- }
542
- if (!protection.bail) {
543
- _context3.next = 21;
544
- break;
545
- }
546
- printSourcesErrors(sourcesErrors);
547
- throw new Error('Your protection has failed.');
548
- case 21:
549
- sourcesErrors.forEach(function (e) {
550
- return console.warn("Non-fatal error: \"".concat(e.message, "\" in ").concat(e.filename));
551
- });
552
- case 22:
553
- if (debug) {
554
- console.log('Downloading protection result');
555
- }
556
- _context3.next = 25;
557
- return _this2.downloadApplicationProtection(client, protection._id);
558
- case 25:
559
- download = _context3.sent;
560
- errorHandler(download);
561
- if (debug) {
562
- console.log('Unzipping files');
563
- }
564
- _context3.next = 30;
565
- return (0, _zip.unzip)(download, (filesDest ? "".concat(filesDest).concat(outPrefix) : filesDest) || destCallback, stream);
566
- case 30:
567
- if (debug) {
568
- console.log('Finished unzipping files');
450
+ protectionId = protectionIds[i];
451
+ _context2.prev = 3;
452
+ _context2.next = 6;
453
+ return _this2.cancelProtection(client, protectionId, applicationId);
454
+ case 6:
455
+ console.log('** Protection %s WAS CANCELLED **', protectionId);
456
+ _context2.next = 12;
457
+ break;
458
+ case 9:
459
+ _context2.prev = 9;
460
+ _context2.t0 = _context2["catch"](3);
461
+ if (debug) {
462
+ console.error(_context2.t0);
463
+ }
464
+ case 12:
465
+ i++;
466
+ _context2.next = 1;
467
+ break;
468
+ case 15:
469
+ process.exit(1);
470
+ case 16:
471
+ case "end":
472
+ return _context2.stop();
569
473
  }
570
- if (printProtectionId) {
571
- console.log(protection._id);
474
+ }
475
+ }, _callee2, null, [[3, 9]]);
476
+ }));
477
+ return function onExitCancelProtection() {
478
+ return _ref3.apply(this, arguments);
479
+ };
480
+ }();
481
+ process.once('SIGINT', onExitCancelProtection).once('SIGTERM', onExitCancelProtection);
482
+ _context4.t0 = _this2;
483
+ _context4.t1 = client;
484
+ _context4.t2 = applicationId;
485
+ _context4.t3 = protectionIds;
486
+ _context4.next = 57;
487
+ return (0, _getProtectionDefaultFragments.default)(client);
488
+ case 57:
489
+ _context4.t4 = _context4.sent;
490
+ _context4.next = 60;
491
+ return _context4.t0.pollProtections.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3, _context4.t4);
492
+ case 60:
493
+ processedProtections = _context4.sent;
494
+ process.removeListener('SIGINT', onExitCancelProtection).removeListener('SIGTERM', onExitCancelProtection);
495
+ handleProtection = /*#__PURE__*/function () {
496
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(protection) {
497
+ var _ref5,
498
+ _ref5$outPrefix,
499
+ outPrefix,
500
+ _ref5$printProtection,
501
+ printProtectionId,
502
+ sourcesErrors,
503
+ download,
504
+ _args3 = arguments;
505
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
506
+ while (1) {
507
+ switch (_context3.prev = _context3.next) {
508
+ case 0:
509
+ _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;
510
+ if (protection.growthWarning) {
511
+ 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, "."));
512
+ }
513
+ if (protection.hasForcedDateLock) {
514
+ console.warn("Warning: Since your plan is a Trial, your protected files will stop working on ".concat(protection.parameters.find(function (p) {
515
+ return p.name === 'dateLock' && p.options.endDate;
516
+ }).options.endDate));
517
+ }
518
+ if (debug) {
519
+ console.log('Finished protecting');
520
+ }
521
+ if (protection.deprecations) {
522
+ protection.deprecations.forEach(function (deprecation) {
523
+ if (deprecation.type === 'Transformation') {
524
+ console.warn("Warning: ".concat(deprecation.type, " ").concat(deprecation.entity, " is no longer maintained. Please consider removing it from your configuration."));
525
+ } else if (deprecation.type && deprecation.entity) {
526
+ console.warn("Warning: ".concat(deprecation.type, " ").concat(deprecation.entity, " is deprecated."));
527
+ }
528
+ });
529
+ }
530
+ sourcesErrors = [];
531
+ protection.sources.forEach(function (s) {
532
+ if (s.isSource && s.errorMessages && s.errorMessages.length > 0) {
533
+ sourcesErrors.push.apply(sourcesErrors, _toConsumableArray(s.errorMessages.map(function (e) {
534
+ return _objectSpread({
535
+ filename: s.filename
536
+ }, e);
537
+ })));
538
+ }
539
+ });
540
+ if (!(protection.state === 'errored')) {
541
+ _context3.next = 15;
542
+ break;
543
+ }
544
+ console.error('Global protection errors:');
545
+ console.error("- ".concat(protection.errorMessage));
546
+ console.error('');
547
+ if (sourcesErrors.length > 0) {
548
+ printSourcesErrors(sourcesErrors);
549
+ }
550
+ throw new Error("Protection failed. For more information visit: ".concat(APP_URL, "."));
551
+ case 15:
552
+ if (!(sourcesErrors.length > 0)) {
553
+ _context3.next = 22;
554
+ break;
555
+ }
556
+ if (!protection.bail) {
557
+ _context3.next = 21;
558
+ break;
559
+ }
560
+ printSourcesErrors(sourcesErrors);
561
+ throw new Error('Your protection has failed.');
562
+ case 21:
563
+ sourcesErrors.forEach(function (e) {
564
+ return console.warn("Non-fatal error: \"".concat(e.message, "\" in ").concat(e.filename));
565
+ });
566
+ case 22:
567
+ if (debug) {
568
+ console.log('Downloading protection result');
569
+ }
570
+ _context3.next = 25;
571
+ return _this2.downloadApplicationProtection(client, protection._id);
572
+ case 25:
573
+ download = _context3.sent;
574
+ errorHandler(download);
575
+ if (debug) {
576
+ console.log('Unzipping files');
577
+ }
578
+ _context3.next = 30;
579
+ return (0, _zip.unzip)(download, (filesDest ? "".concat(filesDest).concat(outPrefix) : filesDest) || destCallback, stream);
580
+ case 30:
581
+ if (debug) {
582
+ console.log('Finished unzipping files');
583
+ }
584
+ if (printProtectionId) {
585
+ console.log(protection._id);
586
+ }
587
+ return _context3.abrupt("return", protection._id);
588
+ case 33:
589
+ case "end":
590
+ return _context3.stop();
572
591
  }
573
- return _context3.abrupt("return", protection._id);
574
- case 33:
575
- case "end":
576
- return _context3.stop();
577
- }
578
- }, _callee3);
579
- }));
580
- return function handleProtection(_x) {
581
- return _ref4.apply(this, arguments);
582
- };
583
- }();
584
- if (!(processedProtections.length === 1)) {
585
- _context4.next = 66;
592
+ }
593
+ }, _callee3);
594
+ }));
595
+ return function handleProtection(_x) {
596
+ return _ref4.apply(this, arguments);
597
+ };
598
+ }();
599
+ if (!(processedProtections.length === 1)) {
600
+ _context4.next = 65;
601
+ break;
602
+ }
603
+ return _context4.abrupt("return", handleProtection(processedProtections[0]));
604
+ case 65:
605
+ console.log("Protections stored in ".concat(filesDest, "/[protection-id]"));
606
+ i = 0;
607
+ case 67:
608
+ if (!(i < processedProtections.length)) {
609
+ _context4.next = 80;
610
+ break;
611
+ }
612
+ protection = processedProtections[i];
613
+ _context4.prev = 69;
614
+ _context4.next = 72;
615
+ return handleProtection(protection, {
616
+ outPrefix: "/".concat(protection._id, "/"),
617
+ printProtectionId: false
618
+ });
619
+ case 72:
620
+ _context4.next = 77;
586
621
  break;
587
- }
588
- return _context4.abrupt("return", handleProtection(processedProtections[0]));
589
- case 66:
590
- console.log("Protections stored in ".concat(filesDest, "/[protection-id]"));
591
- i = 0;
592
- case 68:
593
- if (!(i < processedProtections.length)) {
594
- _context4.next = 81;
622
+ case 74:
623
+ _context4.prev = 74;
624
+ _context4.t5 = _context4["catch"](69);
625
+ console.error(_context4.t5);
626
+ case 77:
627
+ i++;
628
+ _context4.next = 67;
595
629
  break;
596
- }
597
- protection = processedProtections[i];
598
- _context4.prev = 70;
599
- _context4.next = 73;
600
- return handleProtection(protection, {
601
- outPrefix: "/".concat(protection._id, "/"),
602
- printProtectionId: false
603
- });
604
- case 73:
605
- _context4.next = 78;
606
- break;
607
- case 75:
608
- _context4.prev = 75;
609
- _context4.t5 = _context4["catch"](70);
610
- console.error(_context4.t5);
611
- case 78:
612
- i++;
613
- _context4.next = 68;
614
- break;
615
- case 81:
616
- console.log("Runtime: ".concat(processedProtections.length, " protections in ").concat(Math.round((Date.now() - start) / 1000), "s"));
617
- return _context4.abrupt("return", protectionIds);
618
- case 83:
619
- case "end":
620
- return _context4.stop();
630
+ case 80:
631
+ console.log("Runtime: ".concat(processedProtections.length, " protections in ").concat(Math.round((Date.now() - start) / 1000), "s"));
632
+ return _context4.abrupt("return", protectionIds);
633
+ case 82:
634
+ case "end":
635
+ return _context4.stop();
636
+ }
621
637
  }
622
- }, _callee4, null, [[70, 75]]);
638
+ }, _callee4, null, [[69, 74]]);
623
639
  }))();
624
640
  },
625
641
  /**
@@ -633,102 +649,104 @@ var _default = {
633
649
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
634
650
  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;
635
651
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
636
- while (1) switch (_context5.prev = _context5.next) {
637
- case 0:
638
- finalConfig = buildFinalConfig(configPathOrObject);
639
- applicationId = finalConfig.applicationId, host = finalConfig.host, port = finalConfig.port, basePath = finalConfig.basePath, protocol = finalConfig.protocol, cafile = finalConfig.cafile, keys = finalConfig.keys, sources = finalConfig.sources, _finalConfig$stream2 = finalConfig.stream, stream = _finalConfig$stream2 === void 0 ? true : _finalConfig$stream2, cwd = finalConfig.cwd, jscramblerVersion = finalConfig.jscramblerVersion, proxy = finalConfig.proxy, utc = finalConfig.utc, skipSources = finalConfig.skipSources, clientId = finalConfig.clientId;
640
- accessKey = keys.accessKey, secretKey = keys.secretKey;
641
- client = new _this3.Client({
642
- accessKey: accessKey,
643
- secretKey: secretKey,
644
- host: host,
645
- port: port,
646
- basePath: basePath,
647
- protocol: protocol,
648
- cafile: cafile,
649
- jscramblerVersion: jscramblerVersion,
650
- proxy: proxy,
651
- utc: utc,
652
- clientId: clientId
653
- });
654
- filesSrc = finalConfig.filesSrc, filesDest = finalConfig.filesDest;
655
- if (sources) {
656
- filesSrc = undefined;
657
- }
658
- if (destCallback) {
659
- filesDest = undefined;
660
- }
661
- if (applicationId) {
662
- _context5.next = 9;
663
- break;
664
- }
665
- throw new Error('Required *applicationId* not provided');
666
- case 9:
667
- if (!(!filesDest && !destCallback)) {
668
- _context5.next = 11;
669
- break;
670
- }
671
- throw new Error('Required *filesDest* not provided');
672
- case 11:
673
- if (skipSources) {
674
- _context5.next = 16;
675
- break;
676
- }
677
- _context5.next = 14;
678
- return _this3.updateApplicationSources(client, applicationId, {
679
- sources: sources,
680
- filesSrc: filesSrc,
681
- cwd: cwd
682
- });
683
- case 14:
684
- _context5.next = 17;
685
- break;
686
- case 16:
687
- console.log('Update source files SKIPPED');
688
- case 17:
689
- _context5.next = 19;
690
- return _this3.startInstrumentation(client, applicationId);
691
- case 19:
692
- instrumentation = _context5.sent;
693
- errorHandler(instrumentation);
694
- onExitCancelInstrumentation = function onExitCancelInstrumentation() {
695
- _this3.deleteProfiling(client, instrumentation.data.id).then(function () {
696
- return console.log('\n** Instrumentation %s WAS CANCELLED **', instrumentation.data.id);
697
- }).catch(function () {
698
- return debug && console.error(e);
699
- }).finally(function () {
700
- return process.exit(1);
652
+ while (1) {
653
+ switch (_context5.prev = _context5.next) {
654
+ case 0:
655
+ finalConfig = buildFinalConfig(configPathOrObject);
656
+ applicationId = finalConfig.applicationId, host = finalConfig.host, port = finalConfig.port, basePath = finalConfig.basePath, protocol = finalConfig.protocol, cafile = finalConfig.cafile, keys = finalConfig.keys, sources = finalConfig.sources, _finalConfig$stream2 = finalConfig.stream, stream = _finalConfig$stream2 === void 0 ? true : _finalConfig$stream2, cwd = finalConfig.cwd, jscramblerVersion = finalConfig.jscramblerVersion, proxy = finalConfig.proxy, utc = finalConfig.utc, skipSources = finalConfig.skipSources, clientId = finalConfig.clientId;
657
+ accessKey = keys.accessKey, secretKey = keys.secretKey;
658
+ client = new _this3.Client({
659
+ accessKey: accessKey,
660
+ secretKey: secretKey,
661
+ host: host,
662
+ port: port,
663
+ basePath: basePath,
664
+ protocol: protocol,
665
+ cafile: cafile,
666
+ jscramblerVersion: jscramblerVersion,
667
+ proxy: proxy,
668
+ utc: utc,
669
+ clientId: clientId
670
+ });
671
+ filesSrc = finalConfig.filesSrc, filesDest = finalConfig.filesDest;
672
+ if (sources) {
673
+ filesSrc = undefined;
674
+ }
675
+ if (destCallback) {
676
+ filesDest = undefined;
677
+ }
678
+ if (applicationId) {
679
+ _context5.next = 9;
680
+ break;
681
+ }
682
+ throw new Error('Required *applicationId* not provided');
683
+ case 9:
684
+ if (!(!filesDest && !destCallback)) {
685
+ _context5.next = 11;
686
+ break;
687
+ }
688
+ throw new Error('Required *filesDest* not provided');
689
+ case 11:
690
+ if (skipSources) {
691
+ _context5.next = 16;
692
+ break;
693
+ }
694
+ _context5.next = 14;
695
+ return _this3.updateApplicationSources(client, applicationId, {
696
+ sources: sources,
697
+ filesSrc: filesSrc,
698
+ cwd: cwd
701
699
  });
702
- };
703
- process.once('SIGINT', onExitCancelInstrumentation).once('SIGTERM', onExitCancelInstrumentation);
704
- _context5.next = 25;
705
- return _this3.pollInstrumentation(client, instrumentation.data.id);
706
- case 25:
707
- instrumentation = _context5.sent;
708
- process.removeListener('SIGINT', onExitCancelInstrumentation).removeListener('SIGTERM', onExitCancelInstrumentation);
709
- if (debug) {
710
- console.log("Finished instrumention with id ".concat(instrumentation.data.id, ". Downloading..."));
711
- }
712
- _context5.next = 30;
713
- return _this3.downloadApplicationInstrumented(client, instrumentation.data.id);
714
- case 30:
715
- download = _context5.sent;
716
- errorHandler(download);
717
- if (debug) {
718
- console.log('Unzipping files');
719
- }
720
- _context5.next = 35;
721
- return (0, _zip.unzip)(download, filesDest || destCallback, stream);
722
- case 35:
723
- if (debug) {
724
- console.log('Finished unzipping files');
725
- }
726
- console.warn("\n WARNING: DO NOT SEND THIS CODE TO PRODUCTION AS IT IS NOT PROTECTED\n ");
727
- console.log("Application ".concat(applicationId, " was instrumented. Bootstrap your instrumented application and run *--start-profiling* command."));
728
- return _context5.abrupt("return", instrumentation.data.id);
729
- case 39:
730
- case "end":
731
- return _context5.stop();
700
+ case 14:
701
+ _context5.next = 17;
702
+ break;
703
+ case 16:
704
+ console.log('Update source files SKIPPED');
705
+ case 17:
706
+ _context5.next = 19;
707
+ return _this3.startInstrumentation(client, applicationId);
708
+ case 19:
709
+ instrumentation = _context5.sent;
710
+ errorHandler(instrumentation);
711
+ onExitCancelInstrumentation = function onExitCancelInstrumentation() {
712
+ _this3.deleteProfiling(client, instrumentation.data.id).then(function () {
713
+ return console.log('\n** Instrumentation %s WAS CANCELLED **', instrumentation.data.id);
714
+ }).catch(function () {
715
+ return debug && console.error(e);
716
+ }).finally(function () {
717
+ return process.exit(1);
718
+ });
719
+ };
720
+ process.once('SIGINT', onExitCancelInstrumentation).once('SIGTERM', onExitCancelInstrumentation);
721
+ _context5.next = 25;
722
+ return _this3.pollInstrumentation(client, instrumentation.data.id);
723
+ case 25:
724
+ instrumentation = _context5.sent;
725
+ process.removeListener('SIGINT', onExitCancelInstrumentation).removeListener('SIGTERM', onExitCancelInstrumentation);
726
+ if (debug) {
727
+ console.log("Finished instrumention with id ".concat(instrumentation.data.id, ". Downloading..."));
728
+ }
729
+ _context5.next = 30;
730
+ return _this3.downloadApplicationInstrumented(client, instrumentation.data.id);
731
+ case 30:
732
+ download = _context5.sent;
733
+ errorHandler(download);
734
+ if (debug) {
735
+ console.log('Unzipping files');
736
+ }
737
+ _context5.next = 35;
738
+ return (0, _zip.unzip)(download, filesDest || destCallback, stream);
739
+ case 35:
740
+ if (debug) {
741
+ console.log('Finished unzipping files');
742
+ }
743
+ console.warn("\n WARNING: DO NOT SEND THIS CODE TO PRODUCTION AS IT IS NOT PROTECTED\n ");
744
+ console.log("Application ".concat(applicationId, " was instrumented. Bootstrap your instrumented application and run *--start-profiling* command."));
745
+ return _context5.abrupt("return", instrumentation.data.id);
746
+ case 39:
747
+ case "end":
748
+ return _context5.stop();
749
+ }
732
750
  }
733
751
  }, _callee5);
734
752
  }))();
@@ -746,55 +764,57 @@ var _default = {
746
764
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
747
765
  var finalConfig, keys, host, port, basePath, protocol, cafile, applicationId, proxy, utc, jscramblerVersion, clientId, accessKey, secretKey, client, instrumentation, previousState;
748
766
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
749
- while (1) switch (_context6.prev = _context6.next) {
750
- case 0:
751
- finalConfig = buildFinalConfig(configPathOrObject);
752
- keys = finalConfig.keys, host = finalConfig.host, port = finalConfig.port, basePath = finalConfig.basePath, protocol = finalConfig.protocol, cafile = finalConfig.cafile, applicationId = finalConfig.applicationId, proxy = finalConfig.proxy, utc = finalConfig.utc, jscramblerVersion = finalConfig.jscramblerVersion, clientId = finalConfig.clientId;
753
- accessKey = keys.accessKey, secretKey = keys.secretKey;
754
- client = new _this4.Client({
755
- accessKey: accessKey,
756
- secretKey: secretKey,
757
- host: host,
758
- port: port,
759
- basePath: basePath,
760
- protocol: protocol,
761
- cafile: cafile,
762
- proxy: proxy,
763
- utc: utc,
764
- jscramblerVersion: jscramblerVersion,
765
- clientId: clientId
766
- });
767
- _context6.next = 6;
768
- return client.get('/profiling-run', {
769
- applicationId: applicationId
770
- }).catch(function (e) {
771
- if (e.statusCode !== 404) throw e;
772
- });
773
- case 6:
774
- instrumentation = _context6.sent;
775
- if (instrumentation) {
776
- _context6.next = 9;
777
- break;
778
- }
779
- throw new Error('There is no active profiling run. Instrument your application first.');
780
- case 9:
781
- previousState = instrumentation.data.state;
782
- if (!(previousState === state)) {
783
- _context6.next = 13;
784
- break;
785
- }
786
- console.log("Profiling was already ".concat(label, " for application ").concat(applicationId, ". ").concat(nextStepMessage));
787
- return _context6.abrupt("return");
788
- case 13:
789
- _context6.next = 15;
790
- return client.patch("/profiling-run/".concat(instrumentation.data.id), {
791
- state: state
792
- });
793
- case 15:
794
- console.log("Profiling was ".concat(label, " for application ").concat(applicationId, ". ").concat(nextStepMessage));
795
- case 16:
796
- case "end":
797
- return _context6.stop();
767
+ while (1) {
768
+ switch (_context6.prev = _context6.next) {
769
+ case 0:
770
+ finalConfig = buildFinalConfig(configPathOrObject);
771
+ keys = finalConfig.keys, host = finalConfig.host, port = finalConfig.port, basePath = finalConfig.basePath, protocol = finalConfig.protocol, cafile = finalConfig.cafile, applicationId = finalConfig.applicationId, proxy = finalConfig.proxy, utc = finalConfig.utc, jscramblerVersion = finalConfig.jscramblerVersion, clientId = finalConfig.clientId;
772
+ accessKey = keys.accessKey, secretKey = keys.secretKey;
773
+ client = new _this4.Client({
774
+ accessKey: accessKey,
775
+ secretKey: secretKey,
776
+ host: host,
777
+ port: port,
778
+ basePath: basePath,
779
+ protocol: protocol,
780
+ cafile: cafile,
781
+ proxy: proxy,
782
+ utc: utc,
783
+ jscramblerVersion: jscramblerVersion,
784
+ clientId: clientId
785
+ });
786
+ _context6.next = 6;
787
+ return client.get('/profiling-run', {
788
+ applicationId: applicationId
789
+ }).catch(function (e) {
790
+ if (e.statusCode !== 404) throw e;
791
+ });
792
+ case 6:
793
+ instrumentation = _context6.sent;
794
+ if (instrumentation) {
795
+ _context6.next = 9;
796
+ break;
797
+ }
798
+ throw new Error('There is no active profiling run. Instrument your application first.');
799
+ case 9:
800
+ previousState = instrumentation.data.state;
801
+ if (!(previousState === state)) {
802
+ _context6.next = 13;
803
+ break;
804
+ }
805
+ console.log("Profiling was already ".concat(label, " for application ").concat(applicationId, ". ").concat(nextStepMessage));
806
+ return _context6.abrupt("return");
807
+ case 13:
808
+ _context6.next = 15;
809
+ return client.patch("/profiling-run/".concat(instrumentation.data.id), {
810
+ state: state
811
+ });
812
+ case 15:
813
+ console.log("Profiling was ".concat(label, " for application ").concat(applicationId, ". ").concat(nextStepMessage));
814
+ case 16:
815
+ case "end":
816
+ return _context6.stop();
817
+ }
798
818
  }
799
819
  }, _callee6);
800
820
  }))();
@@ -804,54 +824,56 @@ var _default = {
804
824
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
805
825
  var keys, host, port, basePath, protocol, cafile, _configs$stream, stream, filesDest, filesSrc, protectionId, jscramblerVersion, utc, proxy, accessKey, secretKey, client, download;
806
826
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
807
- while (1) switch (_context7.prev = _context7.next) {
808
- case 0:
809
- keys = configs.keys, host = configs.host, port = configs.port, basePath = configs.basePath, protocol = configs.protocol, cafile = configs.cafile, _configs$stream = configs.stream, stream = _configs$stream === void 0 ? true : _configs$stream, filesDest = configs.filesDest, filesSrc = configs.filesSrc, protectionId = configs.protectionId, jscramblerVersion = configs.jscramblerVersion, utc = configs.utc, proxy = configs.proxy;
810
- accessKey = keys.accessKey, secretKey = keys.secretKey;
811
- client = new _this5.Client({
812
- accessKey: accessKey,
813
- secretKey: secretKey,
814
- host: host,
815
- port: port,
816
- basePath: basePath,
817
- protocol: protocol,
818
- cafile: cafile,
819
- jscramblerVersion: jscramblerVersion,
820
- utc: utc,
821
- proxy: proxy
822
- });
823
- if (!(!filesDest && !destCallback)) {
824
- _context7.next = 5;
825
- break;
826
- }
827
- throw new Error('Required *filesDest* not provided');
828
- case 5:
829
- if (protectionId) {
830
- _context7.next = 7;
827
+ while (1) {
828
+ switch (_context7.prev = _context7.next) {
829
+ case 0:
830
+ keys = configs.keys, host = configs.host, port = configs.port, basePath = configs.basePath, protocol = configs.protocol, cafile = configs.cafile, _configs$stream = configs.stream, stream = _configs$stream === void 0 ? true : _configs$stream, filesDest = configs.filesDest, filesSrc = configs.filesSrc, protectionId = configs.protectionId, jscramblerVersion = configs.jscramblerVersion, utc = configs.utc, proxy = configs.proxy;
831
+ accessKey = keys.accessKey, secretKey = keys.secretKey;
832
+ client = new _this5.Client({
833
+ accessKey: accessKey,
834
+ secretKey: secretKey,
835
+ host: host,
836
+ port: port,
837
+ basePath: basePath,
838
+ protocol: protocol,
839
+ cafile: cafile,
840
+ jscramblerVersion: jscramblerVersion,
841
+ utc: utc,
842
+ proxy: proxy
843
+ });
844
+ if (!(!filesDest && !destCallback)) {
845
+ _context7.next = 5;
846
+ break;
847
+ }
848
+ throw new Error('Required *filesDest* not provided');
849
+ case 5:
850
+ if (protectionId) {
851
+ _context7.next = 7;
852
+ break;
853
+ }
854
+ throw new Error('Required *protectionId* not provided');
855
+ case 7:
856
+ if (filesSrc) {
857
+ console.warn('[Warning] Ignoring sources supplied. Downloading source maps of given protection');
858
+ }
859
+ _context7.prev = 8;
860
+ _context7.next = 11;
861
+ return _this5.downloadSourceMapsRequest(client, protectionId);
862
+ case 11:
863
+ download = _context7.sent;
864
+ _context7.next = 17;
831
865
  break;
832
- }
833
- throw new Error('Required *protectionId* not provided');
834
- case 7:
835
- if (filesSrc) {
836
- console.warn('[Warning] Ignoring sources supplied. Downloading source maps of given protection');
837
- }
838
- _context7.prev = 8;
839
- _context7.next = 11;
840
- return _this5.downloadSourceMapsRequest(client, protectionId);
841
- case 11:
842
- download = _context7.sent;
843
- _context7.next = 17;
844
- break;
845
- case 14:
846
- _context7.prev = 14;
847
- _context7.t0 = _context7["catch"](8);
848
- errorHandler(_context7.t0);
849
- case 17:
850
- _context7.next = 19;
851
- return (0, _zip.unzip)(download, filesDest || destCallback, stream);
852
- case 19:
853
- case "end":
854
- return _context7.stop();
866
+ case 14:
867
+ _context7.prev = 14;
868
+ _context7.t0 = _context7["catch"](8);
869
+ errorHandler(_context7.t0);
870
+ case 17:
871
+ _context7.next = 19;
872
+ return (0, _zip.unzip)(download, filesDest || destCallback, stream);
873
+ case 19:
874
+ case "end":
875
+ return _context7.stop();
876
+ }
855
877
  }
856
878
  }, _callee7, null, [[8, 14]]);
857
879
  }))();
@@ -861,57 +883,59 @@ var _default = {
861
883
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
862
884
  var keys, host, port, basePath, protocol, cafile, _configs$stream2, stream, filesDest, filesSrc, protectionId, jscramblerVersion, utc, proxy, accessKey, secretKey, client, download;
863
885
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
864
- while (1) switch (_context8.prev = _context8.next) {
865
- case 0:
866
- keys = configs.keys, host = configs.host, port = configs.port, basePath = configs.basePath, protocol = configs.protocol, cafile = configs.cafile, _configs$stream2 = configs.stream, stream = _configs$stream2 === void 0 ? true : _configs$stream2, filesDest = configs.filesDest, filesSrc = configs.filesSrc, protectionId = configs.protectionId, jscramblerVersion = configs.jscramblerVersion, utc = configs.utc, proxy = configs.proxy;
867
- accessKey = keys.accessKey, secretKey = keys.secretKey;
868
- client = new _this6.Client({
869
- accessKey: accessKey,
870
- secretKey: secretKey,
871
- host: host,
872
- port: port,
873
- basePath: basePath,
874
- protocol: protocol,
875
- cafile: cafile,
876
- jscramblerVersion: jscramblerVersion,
877
- utc: utc,
878
- proxy: proxy
879
- });
880
- if (!(!filesDest && !destCallback)) {
881
- _context8.next = 5;
882
- break;
883
- }
884
- throw new Error('Required *filesDest* not provided');
885
- case 5:
886
- if (protectionId) {
887
- _context8.next = 7;
886
+ while (1) {
887
+ switch (_context8.prev = _context8.next) {
888
+ case 0:
889
+ keys = configs.keys, host = configs.host, port = configs.port, basePath = configs.basePath, protocol = configs.protocol, cafile = configs.cafile, _configs$stream2 = configs.stream, stream = _configs$stream2 === void 0 ? true : _configs$stream2, filesDest = configs.filesDest, filesSrc = configs.filesSrc, protectionId = configs.protectionId, jscramblerVersion = configs.jscramblerVersion, utc = configs.utc, proxy = configs.proxy;
890
+ accessKey = keys.accessKey, secretKey = keys.secretKey;
891
+ client = new _this6.Client({
892
+ accessKey: accessKey,
893
+ secretKey: secretKey,
894
+ host: host,
895
+ port: port,
896
+ basePath: basePath,
897
+ protocol: protocol,
898
+ cafile: cafile,
899
+ jscramblerVersion: jscramblerVersion,
900
+ utc: utc,
901
+ proxy: proxy
902
+ });
903
+ if (!(!filesDest && !destCallback)) {
904
+ _context8.next = 5;
905
+ break;
906
+ }
907
+ throw new Error('Required *filesDest* not provided');
908
+ case 5:
909
+ if (protectionId) {
910
+ _context8.next = 7;
911
+ break;
912
+ }
913
+ throw new Error('Required *protectionId* not provided');
914
+ case 7:
915
+ if (filesSrc) {
916
+ console.warn('[Warning] Ignoring sources supplied. Downloading symbol table of given protection');
917
+ }
918
+ _context8.prev = 8;
919
+ _context8.next = 11;
920
+ return _this6.downloadSymbolTableRequest(client, protectionId);
921
+ case 11:
922
+ download = _context8.sent;
923
+ _context8.next = 17;
888
924
  break;
889
- }
890
- throw new Error('Required *protectionId* not provided');
891
- case 7:
892
- if (filesSrc) {
893
- console.warn('[Warning] Ignoring sources supplied. Downloading symbol table of given protection');
894
- }
895
- _context8.prev = 8;
896
- _context8.next = 11;
897
- return _this6.downloadSymbolTableRequest(client, protectionId);
898
- case 11:
899
- download = _context8.sent;
900
- _context8.next = 17;
901
- break;
902
- case 14:
903
- _context8.prev = 14;
904
- _context8.t0 = _context8["catch"](8);
905
- errorHandler(_context8.t0);
906
- case 17:
907
- if (typeof destCallback === 'function') {
908
- destCallback(download, filesDest);
909
- } else {
910
- (0, _zip.outputFileSync)(_path.default.join(filesDest, "".concat(protectionId, "_symbolTable.json")), download);
911
- }
912
- case 18:
913
- case "end":
914
- return _context8.stop();
925
+ case 14:
926
+ _context8.prev = 14;
927
+ _context8.t0 = _context8["catch"](8);
928
+ errorHandler(_context8.t0);
929
+ case 17:
930
+ if (typeof destCallback === 'function') {
931
+ destCallback(download, filesDest);
932
+ } else {
933
+ (0, _zip.outputFileSync)(_path.default.join(filesDest, "".concat(protectionId, "_symbolTable.json")), download);
934
+ }
935
+ case 18:
936
+ case "end":
937
+ return _context8.stop();
938
+ }
915
939
  }
916
940
  }, _callee8, null, [[8, 14]]);
917
941
  }))();
@@ -929,54 +953,58 @@ var _default = {
929
953
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
930
954
  var start, poll;
931
955
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
932
- while (1) switch (_context10.prev = _context10.next) {
933
- case 0:
934
- start = Date.now();
935
- poll = /*#__PURE__*/function () {
936
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
937
- var instrumentation;
938
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
939
- while (1) switch (_context9.prev = _context9.next) {
940
- case 0:
941
- _context9.next = 2;
942
- return _this7.getInstrumentation(client, instrumentationId);
943
- case 2:
944
- instrumentation = _context9.sent;
945
- _context9.t0 = instrumentation.data.state;
946
- _context9.next = _context9.t0 === 'DELETED' ? 6 : _context9.t0 === 'FAILED_INSTRUMENTATION' ? 7 : _context9.t0 === 'FINISHED_INSTRUMENTATION' ? 9 : 10;
947
- break;
948
- case 6:
949
- throw new Error('Protection canceled by user');
950
- case 7:
951
- instrumentation.errors = instrumentation.errors.concat(instrumentation.data.instrumentationErrors.map(function (e) {
952
- return {
953
- message: "".concat(e.message, " at ").concat(e.fileName, ":").concat(e.lineNumber)
954
- };
955
- }));
956
- return _context9.abrupt("return", errorHandler(instrumentation));
957
- case 9:
958
- return _context9.abrupt("return", instrumentation);
959
- case 10:
960
- _context9.next = 12;
961
- return new Promise(function (resolve) {
962
- return setTimeout(resolve, getPollingInterval(start));
963
- });
964
- case 12:
965
- return _context9.abrupt("return", poll());
966
- case 13:
967
- case "end":
968
- return _context9.stop();
969
- }
970
- }, _callee9);
971
- }));
972
- return function poll() {
973
- return _ref6.apply(this, arguments);
974
- };
975
- }();
976
- return _context10.abrupt("return", poll());
977
- case 3:
978
- case "end":
979
- return _context10.stop();
956
+ while (1) {
957
+ switch (_context10.prev = _context10.next) {
958
+ case 0:
959
+ start = Date.now();
960
+ poll = /*#__PURE__*/function () {
961
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
962
+ var instrumentation;
963
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
964
+ while (1) {
965
+ switch (_context9.prev = _context9.next) {
966
+ case 0:
967
+ _context9.next = 2;
968
+ return _this7.getInstrumentation(client, instrumentationId);
969
+ case 2:
970
+ instrumentation = _context9.sent;
971
+ _context9.t0 = instrumentation.data.state;
972
+ _context9.next = _context9.t0 === 'DELETED' ? 6 : _context9.t0 === 'FAILED_INSTRUMENTATION' ? 7 : _context9.t0 === 'FINISHED_INSTRUMENTATION' ? 9 : 10;
973
+ break;
974
+ case 6:
975
+ throw new Error('Protection canceled by user');
976
+ case 7:
977
+ instrumentation.errors = instrumentation.errors.concat(instrumentation.data.instrumentationErrors.map(function (e) {
978
+ return {
979
+ message: "".concat(e.message, " at ").concat(e.fileName, ":").concat(e.lineNumber)
980
+ };
981
+ }));
982
+ return _context9.abrupt("return", errorHandler(instrumentation));
983
+ case 9:
984
+ return _context9.abrupt("return", instrumentation);
985
+ case 10:
986
+ _context9.next = 12;
987
+ return new Promise(function (resolve) {
988
+ return setTimeout(resolve, getPollingInterval(start));
989
+ });
990
+ case 12:
991
+ return _context9.abrupt("return", poll());
992
+ case 13:
993
+ case "end":
994
+ return _context9.stop();
995
+ }
996
+ }
997
+ }, _callee9);
998
+ }));
999
+ return function poll() {
1000
+ return _ref6.apply(this, arguments);
1001
+ };
1002
+ }();
1003
+ return _context10.abrupt("return", poll());
1004
+ case 3:
1005
+ case "end":
1006
+ return _context10.stop();
1007
+ }
980
1008
  }
981
1009
  }, _callee10);
982
1010
  }))();
@@ -985,41 +1013,43 @@ var _default = {
985
1013
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
986
1014
  var retriesLeft;
987
1015
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
988
- while (1) switch (_context11.prev = _context11.next) {
989
- case 0:
990
- retriesLeft = _config2.default.maxRetries;
991
- case 1:
992
- _context11.prev = 1;
993
- _context11.next = 4;
994
- return action();
995
- case 4:
996
- return _context11.abrupt("return", _context11.sent);
997
- case 7:
998
- _context11.prev = 7;
999
- _context11.t0 = _context11["catch"](1);
1000
- if (!(retriesLeft <= 0)) {
1001
- _context11.next = 11;
1002
- break;
1003
- }
1004
- throw _context11.t0;
1005
- case 11:
1006
- if (!(_context11.t0.statusCode !== _constants.HTTP_STATUS_CODES.SERVICE_UNAVAILABLE && _context11.t0.statusCode !== _constants.HTTP_STATUS_CODES.GATEWAY_TIMEOUT)) {
1007
- _context11.next = 13;
1016
+ while (1) {
1017
+ switch (_context11.prev = _context11.next) {
1018
+ case 0:
1019
+ retriesLeft = _config2.default.maxRetries;
1020
+ case 1:
1021
+ _context11.prev = 1;
1022
+ _context11.next = 4;
1023
+ return action();
1024
+ case 4:
1025
+ return _context11.abrupt("return", _context11.sent);
1026
+ case 7:
1027
+ _context11.prev = 7;
1028
+ _context11.t0 = _context11["catch"](1);
1029
+ if (!(retriesLeft <= 0)) {
1030
+ _context11.next = 11;
1031
+ break;
1032
+ }
1033
+ throw _context11.t0;
1034
+ case 11:
1035
+ if (!(_context11.t0.statusCode !== _constants.HTTP_STATUS_CODES.SERVICE_UNAVAILABLE && _context11.t0.statusCode !== _constants.HTTP_STATUS_CODES.GATEWAY_TIMEOUT)) {
1036
+ _context11.next = 13;
1037
+ break;
1038
+ }
1039
+ throw _context11.t0;
1040
+ case 13:
1041
+ // Retry
1042
+ if (debug) {
1043
+ console.log('Retrying request');
1044
+ }
1045
+ retriesLeft--;
1046
+ case 15:
1047
+ _context11.next = 1;
1008
1048
  break;
1009
- }
1010
- throw _context11.t0;
1011
- case 13:
1012
- // Retry
1013
- if (debug) {
1014
- console.log('Retrying request');
1015
- }
1016
- retriesLeft--;
1017
- case 15:
1018
- _context11.next = 1;
1019
- break;
1020
- case 17:
1021
- case "end":
1022
- return _context11.stop();
1049
+ case 17:
1050
+ case "end":
1051
+ return _context11.stop();
1052
+ }
1023
1053
  }
1024
1054
  }, _callee11, null, [[1, 7]]);
1025
1055
  }))();
@@ -1029,61 +1059,65 @@ var _default = {
1029
1059
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1030
1060
  var start, poll;
1031
1061
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1032
- while (1) switch (_context13.prev = _context13.next) {
1033
- case 0:
1034
- start = Date.now();
1035
- poll = /*#__PURE__*/function () {
1036
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1037
- var applicationProtection, state;
1038
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1039
- while (1) switch (_context12.prev = _context12.next) {
1040
- case 0:
1041
- _context12.next = 2;
1042
- return _this8.withRetries(function () {
1043
- return _this8.getApplicationProtection(client, applicationId, protectionId, fragments);
1044
- });
1045
- case 2:
1046
- applicationProtection = _context12.sent;
1047
- if (!applicationProtection.errors) {
1048
- _context12.next = 8;
1049
- break;
1050
- }
1051
- console.log('Error polling protection', applicationProtection.errors);
1052
- throw new Error("Protection failed. For more information visit: ".concat(APP_URL, "."));
1053
- case 8:
1054
- state = applicationProtection.data.applicationProtection.state;
1055
- if (!(state !== 'finished' && state !== 'errored' && state !== 'canceled')) {
1056
- _context12.next = 15;
1057
- break;
1058
- }
1059
- _context12.next = 12;
1060
- return new Promise(function (resolve) {
1061
- return setTimeout(resolve, getPollingInterval(start));
1062
- });
1063
- case 12:
1064
- return _context12.abrupt("return", poll());
1065
- case 15:
1066
- if (!(state === 'canceled')) {
1067
- _context12.next = 19;
1068
- break;
1062
+ while (1) {
1063
+ switch (_context13.prev = _context13.next) {
1064
+ case 0:
1065
+ start = Date.now();
1066
+ poll = /*#__PURE__*/function () {
1067
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1068
+ var applicationProtection, state;
1069
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1070
+ while (1) {
1071
+ switch (_context12.prev = _context12.next) {
1072
+ case 0:
1073
+ _context12.next = 2;
1074
+ return _this8.withRetries(function () {
1075
+ return _this8.getApplicationProtection(client, applicationId, protectionId, fragments);
1076
+ });
1077
+ case 2:
1078
+ applicationProtection = _context12.sent;
1079
+ if (!applicationProtection.errors) {
1080
+ _context12.next = 8;
1081
+ break;
1082
+ }
1083
+ console.log('Error polling protection', applicationProtection.errors);
1084
+ throw new Error("Protection failed. For more information visit: ".concat(APP_URL, "."));
1085
+ case 8:
1086
+ state = applicationProtection.data.applicationProtection.state;
1087
+ if (!(state !== 'finished' && state !== 'errored' && state !== 'canceled')) {
1088
+ _context12.next = 15;
1089
+ break;
1090
+ }
1091
+ _context12.next = 12;
1092
+ return new Promise(function (resolve) {
1093
+ return setTimeout(resolve, getPollingInterval(start));
1094
+ });
1095
+ case 12:
1096
+ return _context12.abrupt("return", poll());
1097
+ case 15:
1098
+ if (!(state === 'canceled')) {
1099
+ _context12.next = 19;
1100
+ break;
1101
+ }
1102
+ throw new Error('Protection canceled by user');
1103
+ case 19:
1104
+ return _context12.abrupt("return", applicationProtection.data.applicationProtection);
1105
+ case 20:
1106
+ case "end":
1107
+ return _context12.stop();
1069
1108
  }
1070
- throw new Error('Protection canceled by user');
1071
- case 19:
1072
- return _context12.abrupt("return", applicationProtection.data.applicationProtection);
1073
- case 20:
1074
- case "end":
1075
- return _context12.stop();
1076
- }
1077
- }, _callee12);
1078
- }));
1079
- return function poll() {
1080
- return _ref7.apply(this, arguments);
1081
- };
1082
- }();
1083
- return _context13.abrupt("return", poll());
1084
- case 3:
1085
- case "end":
1086
- return _context13.stop();
1109
+ }
1110
+ }, _callee12);
1111
+ }));
1112
+ return function poll() {
1113
+ return _ref7.apply(this, arguments);
1114
+ };
1115
+ }();
1116
+ return _context13.abrupt("return", poll());
1117
+ case 3:
1118
+ case "end":
1119
+ return _context13.stop();
1120
+ }
1087
1121
  }
1088
1122
  }, _callee13);
1089
1123
  }))();
@@ -1093,83 +1127,87 @@ var _default = {
1093
1127
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1094
1128
  var start, seen, poll;
1095
1129
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1096
- while (1) switch (_context15.prev = _context15.next) {
1097
- case 0:
1098
- if (!(protectionIds.length === 1)) {
1099
- _context15.next = 5;
1100
- break;
1101
- }
1102
- _context15.next = 3;
1103
- return _this9.pollProtection(client, applicationId, protectionIds[0], fragments);
1104
- case 3:
1105
- _context15.t0 = _context15.sent;
1106
- return _context15.abrupt("return", [_context15.t0]);
1107
- case 5:
1108
- start = Date.now();
1109
- seen = {};
1110
- poll = /*#__PURE__*/function () {
1111
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1112
- var applicationProtections, ended;
1113
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1114
- while (1) switch (_context14.prev = _context14.next) {
1115
- case 0:
1116
- _context14.next = 2;
1117
- return _this9.withRetries(function () {
1118
- return _this9.getApplicationProtections(client, applicationId, {
1119
- protectionIds: protectionIds
1120
- }, fragments.applicationProtection, ["$protectionIds: [String]"]);
1121
- });
1122
- case 2:
1123
- applicationProtections = _context14.sent;
1124
- if (!applicationProtections.errors) {
1125
- _context14.next = 8;
1126
- break;
1127
- }
1128
- console.log('Error polling protection', applicationProtections.errors);
1129
- throw new Error("Protection failed. For more information visit: ".concat(APP_URL, "."));
1130
- case 8:
1131
- ended = applicationProtections.data.applicationProtections.filter(function (_ref9) {
1132
- var state = _ref9.state;
1133
- return state === 'finished' || state === 'errored' || state === 'canceled';
1134
- }); // print progress
1135
- ended.filter(function (_ref10) {
1136
- var _id = _ref10._id,
1137
- state = _ref10.state;
1138
- return !seen[_id] && state !== 'canceled';
1139
- }).forEach(function (_ref11) {
1140
- var _id = _ref11._id,
1141
- startedAt = _ref11.startedAt,
1142
- finishedAt = _ref11.finishedAt,
1143
- state = _ref11.state;
1144
- seen[_id] = true;
1145
- 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"));
1146
- });
1147
- if (!(ended.length < protectionIds.length)) {
1148
- _context14.next = 14;
1149
- break;
1130
+ while (1) {
1131
+ switch (_context15.prev = _context15.next) {
1132
+ case 0:
1133
+ if (!(protectionIds.length === 1)) {
1134
+ _context15.next = 5;
1135
+ break;
1136
+ }
1137
+ _context15.next = 3;
1138
+ return _this9.pollProtection(client, applicationId, protectionIds[0], fragments);
1139
+ case 3:
1140
+ _context15.t0 = _context15.sent;
1141
+ return _context15.abrupt("return", [_context15.t0]);
1142
+ case 5:
1143
+ start = Date.now();
1144
+ seen = {};
1145
+ poll = /*#__PURE__*/function () {
1146
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1147
+ var applicationProtections, ended;
1148
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1149
+ while (1) {
1150
+ switch (_context14.prev = _context14.next) {
1151
+ case 0:
1152
+ _context14.next = 2;
1153
+ return _this9.withRetries(function () {
1154
+ return _this9.getApplicationProtections(client, applicationId, {
1155
+ protectionIds: protectionIds
1156
+ }, fragments.applicationProtection, ["$protectionIds: [String]"]);
1157
+ });
1158
+ case 2:
1159
+ applicationProtections = _context14.sent;
1160
+ if (!applicationProtections.errors) {
1161
+ _context14.next = 8;
1162
+ break;
1163
+ }
1164
+ console.log('Error polling protection', applicationProtections.errors);
1165
+ throw new Error("Protection failed. For more information visit: ".concat(APP_URL, "."));
1166
+ case 8:
1167
+ ended = applicationProtections.data.applicationProtections.filter(function (_ref9) {
1168
+ var state = _ref9.state;
1169
+ return state === 'finished' || state === 'errored' || state === 'canceled';
1170
+ }); // print progress
1171
+ ended.filter(function (_ref10) {
1172
+ var _id = _ref10._id,
1173
+ state = _ref10.state;
1174
+ return !seen[_id] && state !== 'canceled';
1175
+ }).forEach(function (_ref11) {
1176
+ var _id = _ref11._id,
1177
+ startedAt = _ref11.startedAt,
1178
+ finishedAt = _ref11.finishedAt,
1179
+ state = _ref11.state;
1180
+ seen[_id] = true;
1181
+ 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"));
1182
+ });
1183
+ if (!(ended.length < protectionIds.length)) {
1184
+ _context14.next = 14;
1185
+ break;
1186
+ }
1187
+ _context14.next = 13;
1188
+ return new Promise(function (resolve) {
1189
+ return setTimeout(resolve, getPollingInterval(start));
1190
+ });
1191
+ case 13:
1192
+ return _context14.abrupt("return", poll());
1193
+ case 14:
1194
+ return _context14.abrupt("return", applicationProtections.data.applicationProtections);
1195
+ case 15:
1196
+ case "end":
1197
+ return _context14.stop();
1150
1198
  }
1151
- _context14.next = 13;
1152
- return new Promise(function (resolve) {
1153
- return setTimeout(resolve, getPollingInterval(start));
1154
- });
1155
- case 13:
1156
- return _context14.abrupt("return", poll());
1157
- case 14:
1158
- return _context14.abrupt("return", applicationProtections.data.applicationProtections);
1159
- case 15:
1160
- case "end":
1161
- return _context14.stop();
1162
- }
1163
- }, _callee14);
1164
- }));
1165
- return function poll() {
1166
- return _ref8.apply(this, arguments);
1167
- };
1168
- }();
1169
- return _context15.abrupt("return", poll());
1170
- case 9:
1171
- case "end":
1172
- return _context15.stop();
1199
+ }
1200
+ }, _callee14);
1201
+ }));
1202
+ return function poll() {
1203
+ return _ref8.apply(this, arguments);
1204
+ };
1205
+ }();
1206
+ return _context15.abrupt("return", poll());
1207
+ case 9:
1208
+ case "end":
1209
+ return _context15.stop();
1210
+ }
1173
1211
  }
1174
1212
  }, _callee15);
1175
1213
  }))();
@@ -1178,12 +1216,14 @@ var _default = {
1178
1216
  createApplication: function createApplication(client, data, fragments) {
1179
1217
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1180
1218
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1181
- while (1) switch (_context16.prev = _context16.next) {
1182
- case 0:
1183
- return _context16.abrupt("return", client.post('/application', mutations.createApplication(data, fragments)));
1184
- case 1:
1185
- case "end":
1186
- return _context16.stop();
1219
+ while (1) {
1220
+ switch (_context16.prev = _context16.next) {
1221
+ case 0:
1222
+ return _context16.abrupt("return", client.post('/application', mutations.createApplication(data, fragments)));
1223
+ case 1:
1224
+ case "end":
1225
+ return _context16.stop();
1226
+ }
1187
1227
  }
1188
1228
  }, _callee16);
1189
1229
  }))();
@@ -1192,12 +1232,14 @@ var _default = {
1192
1232
  duplicateApplication: function duplicateApplication(client, data, fragments) {
1193
1233
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1194
1234
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1195
- while (1) switch (_context17.prev = _context17.next) {
1196
- case 0:
1197
- return _context17.abrupt("return", client.post('/application', mutations.duplicateApplication(data, fragments)));
1198
- case 1:
1199
- case "end":
1200
- return _context17.stop();
1235
+ while (1) {
1236
+ switch (_context17.prev = _context17.next) {
1237
+ case 0:
1238
+ return _context17.abrupt("return", client.post('/application', mutations.duplicateApplication(data, fragments)));
1239
+ case 1:
1240
+ case "end":
1241
+ return _context17.stop();
1242
+ }
1201
1243
  }
1202
1244
  }, _callee17);
1203
1245
  }))();
@@ -1206,12 +1248,14 @@ var _default = {
1206
1248
  removeApplication: function removeApplication(client, id) {
1207
1249
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1208
1250
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1209
- while (1) switch (_context18.prev = _context18.next) {
1210
- case 0:
1211
- return _context18.abrupt("return", client.post('/application', mutations.removeApplication(id)));
1212
- case 1:
1213
- case "end":
1214
- return _context18.stop();
1251
+ while (1) {
1252
+ switch (_context18.prev = _context18.next) {
1253
+ case 0:
1254
+ return _context18.abrupt("return", client.post('/application', mutations.removeApplication(id)));
1255
+ case 1:
1256
+ case "end":
1257
+ return _context18.stop();
1258
+ }
1215
1259
  }
1216
1260
  }, _callee18);
1217
1261
  }))();
@@ -1220,12 +1264,14 @@ var _default = {
1220
1264
  removeProtection: function removeProtection(client, id, appId, fragments) {
1221
1265
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1222
1266
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1223
- while (1) switch (_context19.prev = _context19.next) {
1224
- case 0:
1225
- return _context19.abrupt("return", client.post('/application', mutations.removeProtection(id, appId, fragments)));
1226
- case 1:
1227
- case "end":
1228
- return _context19.stop();
1267
+ while (1) {
1268
+ switch (_context19.prev = _context19.next) {
1269
+ case 0:
1270
+ return _context19.abrupt("return", client.post('/application', mutations.removeProtection(id, appId, fragments)));
1271
+ case 1:
1272
+ case "end":
1273
+ return _context19.stop();
1274
+ }
1229
1275
  }
1230
1276
  }, _callee19);
1231
1277
  }))();
@@ -1235,35 +1281,39 @@ var _default = {
1235
1281
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1236
1282
  var mutation;
1237
1283
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1238
- while (1) switch (_context20.prev = _context20.next) {
1239
- case 0:
1240
- _context20.next = 2;
1241
- return mutations.cancelProtection(id, appId, fragments);
1242
- case 2:
1243
- mutation = _context20.sent;
1244
- return _context20.abrupt("return", client.post('/application', mutation));
1245
- case 4:
1246
- case "end":
1247
- return _context20.stop();
1284
+ while (1) {
1285
+ switch (_context20.prev = _context20.next) {
1286
+ case 0:
1287
+ _context20.next = 2;
1288
+ return mutations.cancelProtection(id, appId, fragments);
1289
+ case 2:
1290
+ mutation = _context20.sent;
1291
+ return _context20.abrupt("return", client.post('/application', mutation));
1292
+ case 4:
1293
+ case "end":
1294
+ return _context20.stop();
1295
+ }
1248
1296
  }
1249
1297
  }, _callee20);
1250
1298
  }))();
1251
1299
  },
1252
1300
  //
1253
- updateApplication: function updateApplication(client, application, fragments) {
1301
+ updateApplication: function updateApplication(client, applicationData, fragments, applicationId) {
1254
1302
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1255
1303
  var mutation;
1256
1304
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1257
- while (1) switch (_context21.prev = _context21.next) {
1258
- case 0:
1259
- _context21.next = 2;
1260
- return mutations.updateApplication(application, fragments);
1261
- case 2:
1262
- mutation = _context21.sent;
1263
- return _context21.abrupt("return", client.post('/application', mutation));
1264
- case 4:
1265
- case "end":
1266
- return _context21.stop();
1305
+ while (1) {
1306
+ switch (_context21.prev = _context21.next) {
1307
+ case 0:
1308
+ _context21.next = 2;
1309
+ return mutations.updateApplication(applicationData, fragments, applicationId);
1310
+ case 2:
1311
+ mutation = _context21.sent;
1312
+ return _context21.abrupt("return", client.post('/application', mutation));
1313
+ case 4:
1314
+ case "end":
1315
+ return _context21.stop();
1316
+ }
1267
1317
  }
1268
1318
  }, _callee21);
1269
1319
  }))();
@@ -1273,16 +1323,18 @@ var _default = {
1273
1323
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1274
1324
  var mutation;
1275
1325
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1276
- while (1) switch (_context22.prev = _context22.next) {
1277
- case 0:
1278
- _context22.next = 2;
1279
- return mutations.unlockApplication(application, fragments);
1280
- case 2:
1281
- mutation = _context22.sent;
1282
- return _context22.abrupt("return", client.post('/application', mutation));
1283
- case 4:
1284
- case "end":
1285
- return _context22.stop();
1326
+ while (1) {
1327
+ switch (_context22.prev = _context22.next) {
1328
+ case 0:
1329
+ _context22.next = 2;
1330
+ return mutations.unlockApplication(application, fragments);
1331
+ case 2:
1332
+ mutation = _context22.sent;
1333
+ return _context22.abrupt("return", client.post('/application', mutation));
1334
+ case 4:
1335
+ case "end":
1336
+ return _context22.stop();
1337
+ }
1286
1338
  }
1287
1339
  }, _callee22);
1288
1340
  }))();
@@ -1292,16 +1344,18 @@ var _default = {
1292
1344
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1293
1345
  var query;
1294
1346
  return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1295
- while (1) switch (_context23.prev = _context23.next) {
1296
- case 0:
1297
- _context23.next = 2;
1298
- return queries.getApplication(applicationId, fragments, params);
1299
- case 2:
1300
- query = _context23.sent;
1301
- return _context23.abrupt("return", client.get('/application', query));
1302
- case 4:
1303
- case "end":
1304
- return _context23.stop();
1347
+ while (1) {
1348
+ switch (_context23.prev = _context23.next) {
1349
+ case 0:
1350
+ _context23.next = 2;
1351
+ return queries.getApplication(applicationId, fragments, params);
1352
+ case 2:
1353
+ query = _context23.sent;
1354
+ return _context23.abrupt("return", client.get('/application', query));
1355
+ case 4:
1356
+ case "end":
1357
+ return _context23.stop();
1358
+ }
1305
1359
  }
1306
1360
  }, _callee23);
1307
1361
  }))();
@@ -1311,16 +1365,18 @@ var _default = {
1311
1365
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1312
1366
  var query;
1313
1367
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1314
- while (1) switch (_context24.prev = _context24.next) {
1315
- case 0:
1316
- _context24.next = 2;
1317
- return queries.getApplicationSource(sourceId, fragments, limits);
1318
- case 2:
1319
- query = _context24.sent;
1320
- return _context24.abrupt("return", client.get('/application', query));
1321
- case 4:
1322
- case "end":
1323
- return _context24.stop();
1368
+ while (1) {
1369
+ switch (_context24.prev = _context24.next) {
1370
+ case 0:
1371
+ _context24.next = 2;
1372
+ return queries.getApplicationSource(sourceId, fragments, limits);
1373
+ case 2:
1374
+ query = _context24.sent;
1375
+ return _context24.abrupt("return", client.get('/application', query));
1376
+ case 4:
1377
+ case "end":
1378
+ return _context24.stop();
1379
+ }
1324
1380
  }
1325
1381
  }, _callee24);
1326
1382
  }))();
@@ -1330,13 +1386,15 @@ var _default = {
1330
1386
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1331
1387
  var query;
1332
1388
  return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1333
- while (1) switch (_context25.prev = _context25.next) {
1334
- case 0:
1335
- query = queries.getApplicationProtections(applicationId, params, fragments, queryArgs);
1336
- return _context25.abrupt("return", client.get('/application', query));
1337
- case 2:
1338
- case "end":
1339
- return _context25.stop();
1389
+ while (1) {
1390
+ switch (_context25.prev = _context25.next) {
1391
+ case 0:
1392
+ query = queries.getApplicationProtections(applicationId, params, fragments, queryArgs);
1393
+ return _context25.abrupt("return", client.get('/application', query));
1394
+ case 2:
1395
+ case "end":
1396
+ return _context25.stop();
1397
+ }
1340
1398
  }
1341
1399
  }, _callee25);
1342
1400
  }))();
@@ -1346,16 +1404,18 @@ var _default = {
1346
1404
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1347
1405
  var query;
1348
1406
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1349
- while (1) switch (_context26.prev = _context26.next) {
1350
- case 0:
1351
- _context26.next = 2;
1352
- return queries.getApplicationProtectionsCount(applicationId, fragments);
1353
- case 2:
1354
- query = _context26.sent;
1355
- return _context26.abrupt("return", client.get('/application', query));
1356
- case 4:
1357
- case "end":
1358
- return _context26.stop();
1407
+ while (1) {
1408
+ switch (_context26.prev = _context26.next) {
1409
+ case 0:
1410
+ _context26.next = 2;
1411
+ return queries.getApplicationProtectionsCount(applicationId, fragments);
1412
+ case 2:
1413
+ query = _context26.sent;
1414
+ return _context26.abrupt("return", client.get('/application', query));
1415
+ case 4:
1416
+ case "end":
1417
+ return _context26.stop();
1418
+ }
1359
1419
  }
1360
1420
  }, _callee26);
1361
1421
  }))();
@@ -1365,16 +1425,18 @@ var _default = {
1365
1425
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
1366
1426
  var mutation;
1367
1427
  return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1368
- while (1) switch (_context27.prev = _context27.next) {
1369
- case 0:
1370
- _context27.next = 2;
1371
- return mutations.createTemplate(template, fragments);
1372
- case 2:
1373
- mutation = _context27.sent;
1374
- return _context27.abrupt("return", client.post('/application', mutation));
1375
- case 4:
1376
- case "end":
1377
- return _context27.stop();
1428
+ while (1) {
1429
+ switch (_context27.prev = _context27.next) {
1430
+ case 0:
1431
+ _context27.next = 2;
1432
+ return mutations.createTemplate(template, fragments);
1433
+ case 2:
1434
+ mutation = _context27.sent;
1435
+ return _context27.abrupt("return", client.post('/application', mutation));
1436
+ case 4:
1437
+ case "end":
1438
+ return _context27.stop();
1439
+ }
1378
1440
  }
1379
1441
  }, _callee27);
1380
1442
  }))();
@@ -1384,16 +1446,18 @@ var _default = {
1384
1446
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
1385
1447
  var mutation;
1386
1448
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1387
- while (1) switch (_context28.prev = _context28.next) {
1388
- case 0:
1389
- _context28.next = 2;
1390
- return mutations.removeTemplate(id);
1391
- case 2:
1392
- mutation = _context28.sent;
1393
- return _context28.abrupt("return", client.post('/application', mutation));
1394
- case 4:
1395
- case "end":
1396
- return _context28.stop();
1449
+ while (1) {
1450
+ switch (_context28.prev = _context28.next) {
1451
+ case 0:
1452
+ _context28.next = 2;
1453
+ return mutations.removeTemplate(id);
1454
+ case 2:
1455
+ mutation = _context28.sent;
1456
+ return _context28.abrupt("return", client.post('/application', mutation));
1457
+ case 4:
1458
+ case "end":
1459
+ return _context28.stop();
1460
+ }
1397
1461
  }
1398
1462
  }, _callee28);
1399
1463
  }))();
@@ -1403,16 +1467,18 @@ var _default = {
1403
1467
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
1404
1468
  var query;
1405
1469
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1406
- while (1) switch (_context29.prev = _context29.next) {
1407
- case 0:
1408
- _context29.next = 2;
1409
- return queries.getTemplates(fragments);
1410
- case 2:
1411
- query = _context29.sent;
1412
- return _context29.abrupt("return", client.get('/application', query));
1413
- case 4:
1414
- case "end":
1415
- return _context29.stop();
1470
+ while (1) {
1471
+ switch (_context29.prev = _context29.next) {
1472
+ case 0:
1473
+ _context29.next = 2;
1474
+ return queries.getTemplates(fragments);
1475
+ case 2:
1476
+ query = _context29.sent;
1477
+ return _context29.abrupt("return", client.get('/application', query));
1478
+ case 4:
1479
+ case "end":
1480
+ return _context29.stop();
1481
+ }
1416
1482
  }
1417
1483
  }, _callee29);
1418
1484
  }))();
@@ -1422,16 +1488,18 @@ var _default = {
1422
1488
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
1423
1489
  var query;
1424
1490
  return _regeneratorRuntime().wrap(function _callee30$(_context30) {
1425
- while (1) switch (_context30.prev = _context30.next) {
1426
- case 0:
1427
- _context30.next = 2;
1428
- return queries.getApplications(fragments, params);
1429
- case 2:
1430
- query = _context30.sent;
1431
- return _context30.abrupt("return", client.get('/application', query));
1432
- case 4:
1433
- case "end":
1434
- return _context30.stop();
1491
+ while (1) {
1492
+ switch (_context30.prev = _context30.next) {
1493
+ case 0:
1494
+ _context30.next = 2;
1495
+ return queries.getApplications(fragments, params);
1496
+ case 2:
1497
+ query = _context30.sent;
1498
+ return _context30.abrupt("return", client.get('/application', query));
1499
+ case 4:
1500
+ case "end":
1501
+ return _context30.stop();
1502
+ }
1435
1503
  }
1436
1504
  }, _callee30);
1437
1505
  }))();
@@ -1442,18 +1510,20 @@ var _default = {
1442
1510
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
1443
1511
  var mutation;
1444
1512
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
1445
- while (1) switch (_context31.prev = _context31.next) {
1446
- case 0:
1447
- _context31.next = 2;
1448
- return mutations.addApplicationSource(applicationId, applicationSource, fragments);
1449
- case 2:
1450
- mutation = _context31.sent;
1451
- return _context31.abrupt("return", _this10.withRetries(function () {
1452
- return client.post('/application', mutation);
1453
- }));
1454
- case 4:
1455
- case "end":
1456
- return _context31.stop();
1513
+ while (1) {
1514
+ switch (_context31.prev = _context31.next) {
1515
+ case 0:
1516
+ _context31.next = 2;
1517
+ return mutations.addApplicationSource(applicationId, applicationSource, fragments);
1518
+ case 2:
1519
+ mutation = _context31.sent;
1520
+ return _context31.abrupt("return", _this10.withRetries(function () {
1521
+ return client.post('/application', mutation);
1522
+ }));
1523
+ case 4:
1524
+ case "end":
1525
+ return _context31.stop();
1526
+ }
1457
1527
  }
1458
1528
  }, _callee31);
1459
1529
  }))();
@@ -1463,20 +1533,22 @@ var _default = {
1463
1533
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
1464
1534
  var file, mutation;
1465
1535
  return _regeneratorRuntime().wrap(function _callee32$(_context32) {
1466
- while (1) switch (_context32.prev = _context32.next) {
1467
- case 0:
1468
- _context32.next = 2;
1469
- return getFileFromUrl(client, url);
1470
- case 2:
1471
- file = _context32.sent;
1472
- _context32.next = 5;
1473
- return mutations.addApplicationSource(applicationId, file, fragments);
1474
- case 5:
1475
- mutation = _context32.sent;
1476
- return _context32.abrupt("return", client.post('/application', mutation));
1477
- case 7:
1478
- case "end":
1479
- return _context32.stop();
1536
+ while (1) {
1537
+ switch (_context32.prev = _context32.next) {
1538
+ case 0:
1539
+ _context32.next = 2;
1540
+ return getFileFromUrl(client, url);
1541
+ case 2:
1542
+ file = _context32.sent;
1543
+ _context32.next = 5;
1544
+ return mutations.addApplicationSource(applicationId, file, fragments);
1545
+ case 5:
1546
+ mutation = _context32.sent;
1547
+ return _context32.abrupt("return", client.post('/application', mutation));
1548
+ case 7:
1549
+ case "end":
1550
+ return _context32.stop();
1551
+ }
1480
1552
  }
1481
1553
  }, _callee32);
1482
1554
  }))();
@@ -1486,16 +1558,18 @@ var _default = {
1486
1558
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
1487
1559
  var mutation;
1488
1560
  return _regeneratorRuntime().wrap(function _callee33$(_context33) {
1489
- while (1) switch (_context33.prev = _context33.next) {
1490
- case 0:
1491
- _context33.next = 2;
1492
- return mutations.updateApplicationSource(applicationSource, fragments);
1493
- case 2:
1494
- mutation = _context33.sent;
1495
- return _context33.abrupt("return", client.post('/application', mutation));
1496
- case 4:
1497
- case "end":
1498
- return _context33.stop();
1561
+ while (1) {
1562
+ switch (_context33.prev = _context33.next) {
1563
+ case 0:
1564
+ _context33.next = 2;
1565
+ return mutations.updateApplicationSource(applicationSource, fragments);
1566
+ case 2:
1567
+ mutation = _context33.sent;
1568
+ return _context33.abrupt("return", client.post('/application', mutation));
1569
+ case 4:
1570
+ case "end":
1571
+ return _context33.stop();
1572
+ }
1499
1573
  }
1500
1574
  }, _callee33);
1501
1575
  }))();
@@ -1506,18 +1580,20 @@ var _default = {
1506
1580
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
1507
1581
  var mutation;
1508
1582
  return _regeneratorRuntime().wrap(function _callee34$(_context34) {
1509
- while (1) switch (_context34.prev = _context34.next) {
1510
- case 0:
1511
- _context34.next = 2;
1512
- return mutations.removeSourceFromApplication(sourceId, applicationId, fragments);
1513
- case 2:
1514
- mutation = _context34.sent;
1515
- return _context34.abrupt("return", _this11.withRetries(function () {
1516
- return client.post('/application', mutation);
1517
- }));
1518
- case 4:
1519
- case "end":
1520
- return _context34.stop();
1583
+ while (1) {
1584
+ switch (_context34.prev = _context34.next) {
1585
+ case 0:
1586
+ _context34.next = 2;
1587
+ return mutations.removeSourceFromApplication(sourceId, applicationId, fragments);
1588
+ case 2:
1589
+ mutation = _context34.sent;
1590
+ return _context34.abrupt("return", _this11.withRetries(function () {
1591
+ return client.post('/application', mutation);
1592
+ }));
1593
+ case 4:
1594
+ case "end":
1595
+ return _context34.stop();
1596
+ }
1521
1597
  }
1522
1598
  }, _callee34);
1523
1599
  }))();
@@ -1527,16 +1603,18 @@ var _default = {
1527
1603
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
1528
1604
  var mutation;
1529
1605
  return _regeneratorRuntime().wrap(function _callee35$(_context35) {
1530
- while (1) switch (_context35.prev = _context35.next) {
1531
- case 0:
1532
- _context35.next = 2;
1533
- return mutations.applyTemplate(templateId, appId, fragments);
1534
- case 2:
1535
- mutation = _context35.sent;
1536
- return _context35.abrupt("return", client.post('/application', mutation));
1537
- case 4:
1538
- case "end":
1539
- return _context35.stop();
1606
+ while (1) {
1607
+ switch (_context35.prev = _context35.next) {
1608
+ case 0:
1609
+ _context35.next = 2;
1610
+ return mutations.applyTemplate(templateId, appId, fragments);
1611
+ case 2:
1612
+ mutation = _context35.sent;
1613
+ return _context35.abrupt("return", client.post('/application', mutation));
1614
+ case 4:
1615
+ case "end":
1616
+ return _context35.stop();
1617
+ }
1540
1618
  }
1541
1619
  }, _callee35);
1542
1620
  }))();
@@ -1546,16 +1624,18 @@ var _default = {
1546
1624
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
1547
1625
  var mutation;
1548
1626
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
1549
- while (1) switch (_context36.prev = _context36.next) {
1550
- case 0:
1551
- _context36.next = 2;
1552
- return mutations.updateTemplate(template, fragments);
1553
- case 2:
1554
- mutation = _context36.sent;
1555
- return _context36.abrupt("return", client.post('/application', mutation));
1556
- case 4:
1557
- case "end":
1558
- return _context36.stop();
1627
+ while (1) {
1628
+ switch (_context36.prev = _context36.next) {
1629
+ case 0:
1630
+ _context36.next = 2;
1631
+ return mutations.updateTemplate(template, fragments);
1632
+ case 2:
1633
+ mutation = _context36.sent;
1634
+ return _context36.abrupt("return", client.post('/application', mutation));
1635
+ case 4:
1636
+ case "end":
1637
+ return _context36.stop();
1638
+ }
1559
1639
  }
1560
1640
  }, _callee36);
1561
1641
  }))();
@@ -1563,14 +1643,16 @@ var _default = {
1563
1643
  getApplicationProfiling: function getApplicationProfiling(client, applicationId) {
1564
1644
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
1565
1645
  return _regeneratorRuntime().wrap(function _callee37$(_context37) {
1566
- while (1) switch (_context37.prev = _context37.next) {
1567
- case 0:
1568
- return _context37.abrupt("return", client.get('/profiling-run', {
1569
- applicationId: applicationId
1570
- }));
1571
- case 1:
1572
- case "end":
1573
- return _context37.stop();
1646
+ while (1) {
1647
+ switch (_context37.prev = _context37.next) {
1648
+ case 0:
1649
+ return _context37.abrupt("return", client.get('/profiling-run', {
1650
+ applicationId: applicationId
1651
+ }));
1652
+ case 1:
1653
+ case "end":
1654
+ return _context37.stop();
1655
+ }
1574
1656
  }
1575
1657
  }, _callee37);
1576
1658
  }))();
@@ -1578,14 +1660,16 @@ var _default = {
1578
1660
  deleteProfiling: function deleteProfiling(client, profilingId) {
1579
1661
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
1580
1662
  return _regeneratorRuntime().wrap(function _callee38$(_context38) {
1581
- while (1) switch (_context38.prev = _context38.next) {
1582
- case 0:
1583
- return _context38.abrupt("return", client.patch("/profiling-run/".concat(profilingId), {
1584
- state: 'DELETED'
1585
- }));
1586
- case 1:
1587
- case "end":
1588
- return _context38.stop();
1663
+ while (1) {
1664
+ switch (_context38.prev = _context38.next) {
1665
+ case 0:
1666
+ return _context38.abrupt("return", client.patch("/profiling-run/".concat(profilingId), {
1667
+ state: 'DELETED'
1668
+ }));
1669
+ case 1:
1670
+ case "end":
1671
+ return _context38.stop();
1672
+ }
1589
1673
  }
1590
1674
  }, _callee38);
1591
1675
  }))();
@@ -1602,27 +1686,29 @@ var _default = {
1602
1686
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
1603
1687
  var instrumentation;
1604
1688
  return _regeneratorRuntime().wrap(function _callee39$(_context39) {
1605
- while (1) switch (_context39.prev = _context39.next) {
1606
- case 0:
1607
- _context39.next = 2;
1608
- return _this12.getApplicationProfiling(client, applicationId).catch(function (e) {
1609
- if (e.statusCode !== 404) throw e;
1610
- });
1611
- case 2:
1612
- instrumentation = _context39.sent;
1613
- if (!instrumentation) {
1689
+ while (1) {
1690
+ switch (_context39.prev = _context39.next) {
1691
+ case 0:
1692
+ _context39.next = 2;
1693
+ return _this12.getApplicationProfiling(client, applicationId).catch(function (e) {
1694
+ if (e.statusCode !== 404) throw e;
1695
+ });
1696
+ case 2:
1697
+ instrumentation = _context39.sent;
1698
+ if (!instrumentation) {
1699
+ _context39.next = 6;
1700
+ break;
1701
+ }
1614
1702
  _context39.next = 6;
1615
- break;
1616
- }
1617
- _context39.next = 6;
1618
- return _this12.deleteProfiling(client, instrumentation.data.id);
1619
- case 6:
1620
- return _context39.abrupt("return", client.post('/profiling-run', {
1621
- applicationId: applicationId
1622
- }));
1623
- case 7:
1624
- case "end":
1625
- return _context39.stop();
1703
+ return _this12.deleteProfiling(client, instrumentation.data.id);
1704
+ case 6:
1705
+ return _context39.abrupt("return", client.post('/profiling-run', {
1706
+ applicationId: applicationId
1707
+ }));
1708
+ case 7:
1709
+ case "end":
1710
+ return _context39.stop();
1711
+ }
1626
1712
  }
1627
1713
  }, _callee39);
1628
1714
  }))();
@@ -1632,21 +1718,23 @@ var _default = {
1632
1718
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
1633
1719
  var _yield$introspection$, args, mutation;
1634
1720
  return _regeneratorRuntime().wrap(function _callee40$(_context40) {
1635
- while (1) switch (_context40.prev = _context40.next) {
1636
- case 0:
1637
- _context40.next = 2;
1638
- return introspection.mutation(client, 'createApplicationProtection');
1639
- case 2:
1640
- _yield$introspection$ = _context40.sent;
1641
- args = _yield$introspection$.args;
1642
- _context40.next = 6;
1643
- return mutations.createApplicationProtection(applicationId, fragments, protectionOptions, args);
1644
- case 6:
1645
- mutation = _context40.sent;
1646
- return _context40.abrupt("return", client.post('/application', mutation));
1647
- case 8:
1648
- case "end":
1649
- return _context40.stop();
1721
+ while (1) {
1722
+ switch (_context40.prev = _context40.next) {
1723
+ case 0:
1724
+ _context40.next = 2;
1725
+ return introspection.mutation(client, 'createApplicationProtection');
1726
+ case 2:
1727
+ _yield$introspection$ = _context40.sent;
1728
+ args = _yield$introspection$.args;
1729
+ _context40.next = 6;
1730
+ return mutations.createApplicationProtection(applicationId, fragments, protectionOptions, args);
1731
+ case 6:
1732
+ mutation = _context40.sent;
1733
+ return _context40.abrupt("return", client.post('/application', mutation));
1734
+ case 8:
1735
+ case "end":
1736
+ return _context40.stop();
1737
+ }
1650
1738
  }
1651
1739
  }, _callee40);
1652
1740
  }))();
@@ -1665,50 +1753,52 @@ var _default = {
1665
1753
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
1666
1754
  var result, mutationType, mutation;
1667
1755
  return _regeneratorRuntime().wrap(function _callee41$(_context41) {
1668
- while (1) switch (_context41.prev = _context41.next) {
1669
- case 0:
1670
- if (!(!protectionOptions.numberOfProtections || protectionOptions.numberOfProtections < 2)) {
1671
- _context41.next = 7;
1756
+ while (1) {
1757
+ switch (_context41.prev = _context41.next) {
1758
+ case 0:
1759
+ if (!(!protectionOptions.numberOfProtections || protectionOptions.numberOfProtections < 2)) {
1760
+ _context41.next = 7;
1761
+ break;
1762
+ }
1763
+ _context41.next = 3;
1764
+ return _this13.createApplicationProtection(client, applicationId, _objectSpread(_objectSpread({}, protectionOptions), {}, {
1765
+ numberOfProtections: undefined
1766
+ }), fragments);
1767
+ case 3:
1768
+ result = _context41.sent;
1769
+ if (result.data && result.data.createApplicationProtection) {
1770
+ result.data.protections = [result.data.createApplicationProtection];
1771
+ delete result.data.createApplicationProtection;
1772
+ }
1773
+ _context41.next = 18;
1672
1774
  break;
1673
- }
1674
- _context41.next = 3;
1675
- return _this13.createApplicationProtection(client, applicationId, _objectSpread(_objectSpread({}, protectionOptions), {}, {
1676
- numberOfProtections: undefined
1677
- }), fragments);
1678
- case 3:
1679
- result = _context41.sent;
1680
- if (result.data && result.data.createApplicationProtection) {
1681
- result.data.protections = [result.data.createApplicationProtection];
1682
- delete result.data.createApplicationProtection;
1683
- }
1684
- _context41.next = 18;
1685
- break;
1686
- case 7:
1687
- _context41.next = 9;
1688
- return introspection.mutation(client, 'createApplicationProtections');
1689
- case 9:
1690
- mutationType = _context41.sent;
1691
- if (!mutationType) {
1692
- console.error("\"Create multiple protections at once\" it's only available on Jscrambler version 7.2 and above.");
1693
- process.exit(1);
1694
- }
1695
- _context41.next = 13;
1696
- return mutations.createApplicationProtections(applicationId, fragments, protectionOptions, mutationType.args);
1697
- case 13:
1698
- mutation = _context41.sent;
1699
- _context41.next = 16;
1700
- return client.post('/application', mutation);
1701
- case 16:
1702
- result = _context41.sent;
1703
- if (result.data && result.data.createApplicationProtections) {
1704
- result.data.protections = result.data.createApplicationProtections.protections;
1705
- delete result.data.createApplicationProtections;
1706
- }
1707
- case 18:
1708
- return _context41.abrupt("return", result);
1709
- case 19:
1710
- case "end":
1711
- return _context41.stop();
1775
+ case 7:
1776
+ _context41.next = 9;
1777
+ return introspection.mutation(client, 'createApplicationProtections');
1778
+ case 9:
1779
+ mutationType = _context41.sent;
1780
+ if (!mutationType) {
1781
+ console.error("\"Create multiple protections at once\" it's only available on Jscrambler version 7.2 and above.");
1782
+ process.exit(1);
1783
+ }
1784
+ _context41.next = 13;
1785
+ return mutations.createApplicationProtections(applicationId, fragments, protectionOptions, mutationType.args);
1786
+ case 13:
1787
+ mutation = _context41.sent;
1788
+ _context41.next = 16;
1789
+ return client.post('/application', mutation);
1790
+ case 16:
1791
+ result = _context41.sent;
1792
+ if (result.data && result.data.createApplicationProtections) {
1793
+ result.data.protections = result.data.createApplicationProtections.protections;
1794
+ delete result.data.createApplicationProtections;
1795
+ }
1796
+ case 18:
1797
+ return _context41.abrupt("return", result);
1798
+ case 19:
1799
+ case "end":
1800
+ return _context41.stop();
1801
+ }
1712
1802
  }
1713
1803
  }, _callee41);
1714
1804
  }))();
@@ -1721,12 +1811,14 @@ var _default = {
1721
1811
  getInstrumentation: function getInstrumentation(client, instrumentationId) {
1722
1812
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
1723
1813
  return _regeneratorRuntime().wrap(function _callee42$(_context42) {
1724
- while (1) switch (_context42.prev = _context42.next) {
1725
- case 0:
1726
- return _context42.abrupt("return", client.get("/profiling-run/".concat(instrumentationId)));
1727
- case 1:
1728
- case "end":
1729
- return _context42.stop();
1814
+ while (1) {
1815
+ switch (_context42.prev = _context42.next) {
1816
+ case 0:
1817
+ return _context42.abrupt("return", client.get("/profiling-run/".concat(instrumentationId)));
1818
+ case 1:
1819
+ case "end":
1820
+ return _context42.stop();
1821
+ }
1730
1822
  }
1731
1823
  }, _callee42);
1732
1824
  }))();
@@ -1736,16 +1828,18 @@ var _default = {
1736
1828
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
1737
1829
  var query;
1738
1830
  return _regeneratorRuntime().wrap(function _callee43$(_context43) {
1739
- while (1) switch (_context43.prev = _context43.next) {
1740
- case 0:
1741
- _context43.next = 2;
1742
- return queries.getProtection(applicationId, protectionId, fragments);
1743
- case 2:
1744
- query = _context43.sent;
1745
- return _context43.abrupt("return", client.get('/application', query));
1746
- case 4:
1747
- case "end":
1748
- return _context43.stop();
1831
+ while (1) {
1832
+ switch (_context43.prev = _context43.next) {
1833
+ case 0:
1834
+ _context43.next = 2;
1835
+ return queries.getProtection(applicationId, protectionId, fragments);
1836
+ case 2:
1837
+ query = _context43.sent;
1838
+ return _context43.abrupt("return", client.get('/application', query));
1839
+ case 4:
1840
+ case "end":
1841
+ return _context43.stop();
1842
+ }
1749
1843
  }
1750
1844
  }, _callee43);
1751
1845
  }))();
@@ -1754,12 +1848,14 @@ var _default = {
1754
1848
  downloadSourceMapsRequest: function downloadSourceMapsRequest(client, protectionId) {
1755
1849
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
1756
1850
  return _regeneratorRuntime().wrap(function _callee44$(_context44) {
1757
- while (1) switch (_context44.prev = _context44.next) {
1758
- case 0:
1759
- return _context44.abrupt("return", client.get("/application/sourceMaps/".concat(protectionId), null, false));
1760
- case 1:
1761
- case "end":
1762
- return _context44.stop();
1851
+ while (1) {
1852
+ switch (_context44.prev = _context44.next) {
1853
+ case 0:
1854
+ return _context44.abrupt("return", client.get("/application/sourceMaps/".concat(protectionId), null, false));
1855
+ case 1:
1856
+ case "end":
1857
+ return _context44.stop();
1858
+ }
1763
1859
  }
1764
1860
  }, _callee44);
1765
1861
  }))();
@@ -1767,12 +1863,14 @@ var _default = {
1767
1863
  downloadSymbolTableRequest: function downloadSymbolTableRequest(client, protectionId) {
1768
1864
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
1769
1865
  return _regeneratorRuntime().wrap(function _callee45$(_context45) {
1770
- while (1) switch (_context45.prev = _context45.next) {
1771
- case 0:
1772
- return _context45.abrupt("return", client.get("/application/symbolTable/".concat(protectionId), null, false));
1773
- case 1:
1774
- case "end":
1775
- return _context45.stop();
1866
+ while (1) {
1867
+ switch (_context45.prev = _context45.next) {
1868
+ case 0:
1869
+ return _context45.abrupt("return", client.get("/application/symbolTable/".concat(protectionId), null, false));
1870
+ case 1:
1871
+ case "end":
1872
+ return _context45.stop();
1873
+ }
1776
1874
  }
1777
1875
  }, _callee45);
1778
1876
  }))();
@@ -1781,12 +1879,14 @@ var _default = {
1781
1879
  downloadApplicationProtection: function downloadApplicationProtection(client, protectionId) {
1782
1880
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
1783
1881
  return _regeneratorRuntime().wrap(function _callee46$(_context46) {
1784
- while (1) switch (_context46.prev = _context46.next) {
1785
- case 0:
1786
- return _context46.abrupt("return", client.get("/application/download/".concat(protectionId), null, false));
1787
- case 1:
1788
- case "end":
1789
- return _context46.stop();
1882
+ while (1) {
1883
+ switch (_context46.prev = _context46.next) {
1884
+ case 0:
1885
+ return _context46.abrupt("return", client.get("/application/download/".concat(protectionId), null, false));
1886
+ case 1:
1887
+ case "end":
1888
+ return _context46.stop();
1889
+ }
1790
1890
  }
1791
1891
  }, _callee46);
1792
1892
  }))();
@@ -1812,31 +1912,33 @@ var _default = {
1812
1912
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
1813
1913
  var instrospectionType, client, result, dataArg, isFieldSupported;
1814
1914
  return _regeneratorRuntime().wrap(function _callee47$(_context47) {
1815
- while (1) switch (_context47.prev = _context47.next) {
1816
- case 0:
1817
- instrospectionType = queryOrMutation.toLowerCase() === 'mutation' ? introspection.mutation : introspection.query;
1818
- client = new _this14.Client(_objectSpread({}, config));
1819
- _context47.next = 4;
1820
- return instrospectionType(client, methodName);
1821
- case 4:
1822
- result = _context47.sent;
1823
- if (!(!result || !result.args)) {
1824
- _context47.next = 8;
1825
- break;
1826
- }
1827
- debug && console.log("Method *".concat(methodName, "* not found."));
1828
- return _context47.abrupt("return", false);
1829
- case 8:
1830
- dataArg = result.args.find(function (arg) {
1831
- return arg.name === 'data';
1832
- });
1833
- isFieldSupported = dataArg && dataArg.type.inputFields.some(function (e) {
1834
- return e.name === field;
1835
- });
1836
- return _context47.abrupt("return", isFieldSupported);
1837
- case 11:
1838
- case "end":
1839
- return _context47.stop();
1915
+ while (1) {
1916
+ switch (_context47.prev = _context47.next) {
1917
+ case 0:
1918
+ instrospectionType = queryOrMutation.toLowerCase() === 'mutation' ? introspection.mutation : introspection.query;
1919
+ client = new _this14.Client(_objectSpread({}, config));
1920
+ _context47.next = 4;
1921
+ return instrospectionType(client, methodName);
1922
+ case 4:
1923
+ result = _context47.sent;
1924
+ if (!(!result || !result.args)) {
1925
+ _context47.next = 8;
1926
+ break;
1927
+ }
1928
+ debug && console.log("Method *".concat(methodName, "* not found."));
1929
+ return _context47.abrupt("return", false);
1930
+ case 8:
1931
+ dataArg = result.args.find(function (arg) {
1932
+ return arg.name === 'data';
1933
+ });
1934
+ isFieldSupported = dataArg && dataArg.type.inputFields.some(function (e) {
1935
+ return e.name === field;
1936
+ });
1937
+ return _context47.abrupt("return", isFieldSupported);
1938
+ case 11:
1939
+ case "end":
1940
+ return _context47.stop();
1941
+ }
1840
1942
  }
1841
1943
  }, _callee47);
1842
1944
  }))();