jscrambler 6.4.18 → 6.4.20

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