jscrambler 6.4.21 → 6.4.23

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/queries.js CHANGED
@@ -10,10 +10,15 @@ exports.getApplicationSource = getApplicationSource;
10
10
  exports.getApplications = getApplications;
11
11
  exports.getProtection = getProtection;
12
12
  exports.getTemplates = getTemplates;
13
- 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; }
14
- 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; }
15
- 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; }
16
- var getApplicationDefaultFragments = "\n _id,\n name,\n createdAt,\n sources {\n _id,\n filename,\n extension\n }\n";
13
+ require("core-js/modules/es.regexp.exec.js");
14
+ require("core-js/modules/es.string.replace.js");
15
+ require("core-js/modules/es.symbol.description.js");
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+ 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; }
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
20
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21
+ const getApplicationDefaultFragments = "\n _id,\n name,\n createdAt,\n sources {\n _id,\n filename,\n extension\n }\n";
17
22
  /**
18
23
  * Return one application by id.
19
24
  * The options params argument can be used to filter protections by version and limit the number of protections returned.
@@ -22,60 +27,56 @@ var getApplicationDefaultFragments = "\n _id,\n name,\n createdAt,\n sources
22
27
  * @param {Array} params {{String}protectionsVersion, {Integer} protectionsNumber}
23
28
  */
24
29
  function getApplication(applicationId) {
25
- var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationDefaultFragments;
26
- var params = arguments.length > 2 ? arguments[2] : undefined;
30
+ let fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationDefaultFragments;
31
+ let params = arguments.length > 2 ? arguments[2] : undefined;
27
32
  return {
28
33
  query: "\n query getApplication ($applicationId: String!, $protectionsVersion: String, $protectionsLimit: Int) {\n application(_id: $applicationId, protectionsVersion: $protectionsVersion, protectionsLimit: $protectionsLimit) {\n ".concat(fragments, "\n }\n }\n "),
29
34
  params: JSON.stringify(_objectSpread({
30
- applicationId: applicationId
35
+ applicationId
31
36
  }, params))
32
37
  };
33
38
  }
34
- var getApplicationSourceDefaultFragments = "\n _id,\n filename,\n extension\n";
39
+ const getApplicationSourceDefaultFragments = "\n _id,\n filename,\n extension\n";
35
40
  function getApplicationSource(sourceId) {
36
- var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationSourceDefaultFragments;
37
- var limits = arguments.length > 2 ? arguments[2] : undefined;
41
+ let fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationSourceDefaultFragments;
42
+ let limits = arguments.length > 2 ? arguments[2] : undefined;
38
43
  return {
39
44
  query: "\n query getApplicationSource ($sourceId: String!, $contentLimit: Int, $transformedLimit: Int) {\n applicationSource(_id: $sourceId, contentLimit: $contentLimit, transformedLimit: $transformedLimit) {\n ".concat(fragments, "\n }\n }\n "),
40
45
  params: JSON.stringify(_objectSpread({
41
- sourceId: sourceId
46
+ sourceId
42
47
  }, limits))
43
48
  };
44
49
  }
45
- var getApplicationProtectionsDefaultFragments = "\n _id,\n sources,\n parameters,\n finishedAt,\n randomizationSeed\n";
50
+ const getApplicationProtectionsDefaultFragments = "\n _id,\n sources,\n parameters,\n finishedAt,\n randomizationSeed\n";
46
51
  function getApplicationProtections(applicationId, params) {
47
- var fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getApplicationProtectionsDefaultFragments;
48
- var queryArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
52
+ let fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getApplicationProtectionsDefaultFragments;
53
+ let queryArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
49
54
  return {
50
- query: "\n query getApplicationProtections ($applicationId: String!, $sort: String, $order: String, $limit: Int, $page: Int".concat(queryArgs.map(function (v) {
51
- return ",".concat(v);
52
- }), ") {\n applicationProtections(_id: $applicationId, sort: $sort, order: $order, limit: $limit, page: $page").concat(queryArgs.map(function (v) {
53
- return ", ".concat(v.split(':')[0].replace('$', ''), ": ").concat(v.split(':')[0]);
54
- }), ") {\n ").concat(fragments, "\n }\n }\n "),
55
+ query: "\n query getApplicationProtections ($applicationId: String!, $sort: String, $order: String, $limit: Int, $page: Int".concat(queryArgs.map(v => ",".concat(v)), ") {\n applicationProtections(_id: $applicationId, sort: $sort, order: $order, limit: $limit, page: $page").concat(queryArgs.map(v => ", ".concat(v.split(':')[0].replace('$', ''), ": ").concat(v.split(':')[0])), ") {\n ").concat(fragments, "\n }\n }\n "),
55
56
  params: JSON.stringify(_objectSpread({
56
- applicationId: applicationId
57
+ applicationId
57
58
  }, params))
58
59
  };
59
60
  }
60
- var getApplicationProtectionsCountDefaultFragments = "\n count\n";
61
+ const getApplicationProtectionsCountDefaultFragments = "\n count\n";
61
62
  function getApplicationProtectionsCount(applicationId) {
62
- var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationProtectionsCountDefaultFragments;
63
+ let fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationProtectionsCountDefaultFragments;
63
64
  return {
64
65
  query: "\n query getApplicationProtectionsCount ($applicationId: String!) {\n applicationProtectionsCount(_id: $applicationId) {\n ".concat(fragments, "\n }\n }\n "),
65
66
  params: JSON.stringify({
66
- applicationId: applicationId
67
+ applicationId
67
68
  })
68
69
  };
69
70
  }
70
- var getTemplatesDefaultFragments = "\n _id,\n parameters\n";
71
+ const getTemplatesDefaultFragments = "\n _id,\n parameters\n";
71
72
  function getTemplates() {
72
- var fragments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getTemplatesDefaultFragments;
73
+ let fragments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getTemplatesDefaultFragments;
73
74
  return {
74
75
  query: "\n query getTemplates {\n templates {\n ".concat(fragments, "\n }\n }\n "),
75
76
  params: '{}'
76
77
  };
77
78
  }
78
- var getApplicationsDefaultFragments = "\n _id,\n name,\n protections,\n parameters\n";
79
+ const getApplicationsDefaultFragments = "\n _id,\n name,\n protections,\n parameters\n";
79
80
  /**
80
81
  * Return all applications.
81
82
  * The options params argument can be used to filter protections by version and limit the number of protections returned.
@@ -83,24 +84,24 @@ var getApplicationsDefaultFragments = "\n _id,\n name,\n protections,\n para
83
84
  * @param {Array} params {{String}protectionsVersion, {Integer} protectionsNumber}
84
85
  */
85
86
  function getApplications() {
86
- var fragments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getApplicationsDefaultFragments;
87
- var params = arguments.length > 1 ? arguments[1] : undefined;
87
+ let fragments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getApplicationsDefaultFragments;
88
+ let params = arguments.length > 1 ? arguments[1] : undefined;
88
89
  return {
89
90
  query: "\n query getApplications($protectionsVersion:String, $protectionsLimit: Int) {\n applications(protectionsVersion: $protectionsVersion, protectionsLimit: $protectionsLimit) {\n ".concat(fragments, "\n }\n }\n "),
90
91
  params: JSON.stringify(_objectSpread({}, params))
91
92
  };
92
93
  }
93
- var getProtectionDefaultFragments = {
94
+ const getProtectionDefaultFragments = {
94
95
  application: "\n name\n ",
95
96
  applicationProtection: "\n _id,\n state,\n bail,\n deprecations {\n type,\n entity\n },\n errorMessage,\n sources {\n filename,\n errorMessages {\n message,\n line,\n column,\n fatal\n }\n }\n "
96
97
  };
97
98
  function getProtection(applicationId, protectionId) {
98
- var fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getProtectionDefaultFragments;
99
+ let fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getProtectionDefaultFragments;
99
100
  return {
100
101
  query: "\n query getProtection ($applicationId: String!, $protectionId: String!) {\n application (_id: $applicationId) {\n ".concat(fragments.application, "\n }\n applicationProtection (_id: $protectionId) {\n ").concat(fragments.applicationProtection, "\n }\n }\n "),
101
102
  params: JSON.stringify({
102
- applicationId: applicationId,
103
- protectionId: protectionId
103
+ applicationId,
104
+ protectionId
104
105
  })
105
106
  };
106
107
  }
package/dist/utils.js CHANGED
@@ -14,7 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
14
14
  * @returns {string[]}
15
15
  */
16
16
  function getMatchedFiles(pattern) {
17
- var matchedFiles = _glob.default.sync(pattern, {
17
+ let matchedFiles = _glob.default.sync(pattern, {
18
18
  dot: true
19
19
  });
20
20
 
@@ -28,7 +28,7 @@ function validateNProtections(n) {
28
28
  if (n === undefined) {
29
29
  return n;
30
30
  }
31
- var nProtections = parseInt(n, 10);
31
+ const nProtections = parseInt(n, 10);
32
32
  if (Number.isNaN(nProtections) || nProtections.toString() !== n.toString() || nProtections < 1) {
33
33
  console.error("*protections* requires an integer greater than 0.");
34
34
  process.exit(1);
package/dist/zip.js CHANGED
@@ -1,18 +1,19 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  Object.defineProperty(exports, "outputFileSync", {
8
7
  enumerable: true,
9
- get: function get() {
8
+ get: function () {
10
9
  return _fsExtra.outputFileSync;
11
10
  }
12
11
  });
13
12
  exports.unzip = unzip;
14
13
  exports.zip = zip;
15
14
  exports.zipSources = zipSources;
15
+ require("core-js/modules/es.regexp.exec.js");
16
+ require("core-js/modules/web.dom-collections.iterator.js");
16
17
  var _lodash = _interopRequireDefault(require("lodash.size"));
17
18
  var _temp = _interopRequireDefault(require("temp"));
18
19
  var _jszip = _interopRequireDefault(require("jszip"));
@@ -21,124 +22,80 @@ var _path2 = require("path");
21
22
  var _q = require("q");
22
23
  var _util = require("util");
23
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
- 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; }
25
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
26
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
27
- 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); }
28
- 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; }
29
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
30
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
31
- 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); } }
32
- 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); }); }; }
33
- var debug = !!process.env.DEBUG;
25
+ // TODO Replace `sync` functions with async versions
26
+
27
+ const debug = !!process.env.DEBUG;
34
28
 
35
29
  // ./zip.js module is excluded from browser-like environments. We take advantage of that here.
36
- function zip(_x, _x2) {
37
- return _zip.apply(this, arguments);
38
- }
39
- function _zip() {
40
- _zip = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(files, cwd) {
41
- var deferred, hasFiles, _zip2, zipFile, _zip3, i, l, buffer, name, sPath;
42
- return _regeneratorRuntime().wrap(function _callee$(_context) {
43
- while (1) {
44
- switch (_context.prev = _context.next) {
45
- case 0:
46
- debug && console.log('Zipping files', (0, _util.inspect)(files));
47
- deferred = (0, _q.defer)(); // Flag to detect if any file was added to the zip archive
48
- hasFiles = false; // Sanitize `cwd`
49
- if (cwd) {
50
- cwd = (0, _path2.normalize)(cwd);
51
- }
52
- // If it's already a zip file
53
- if (!(files.length === 1 && /^.*\.zip$/.test(files[0]))) {
54
- _context.next = 14;
55
- break;
56
- }
57
- hasFiles = true;
58
- _zip2 = new _jszip.default();
59
- zipFile = (0, _fsExtra.readFileSync)(files[0]);
60
- _context.next = 10;
61
- return _zip2.loadAsync(zipFile);
62
- case 10:
63
- zipFile = _context.sent;
64
- deferred.resolve(zipFile);
65
- _context.next = 31;
66
- break;
67
- case 14:
68
- _zip3 = new _jszip.default();
69
- i = 0, l = files.length;
70
- case 16:
71
- if (!(i < l)) {
72
- _context.next = 28;
73
- break;
74
- }
75
- // Sanitise path
76
- if (typeof files[i] === 'string') {
77
- files[i] = (0, _path2.normalize)(files[i]);
78
- if (files[i].indexOf('../') === 0) {
79
- files[i] = (0, _path2.resolve)(files[i]);
80
- }
81
- }
82
- // Bypass unwanted patterns from `files`
83
- if (!/.*\.(git|hg)(\/.*|$)/.test(files[i].path || files[i])) {
84
- _context.next = 20;
85
- break;
86
- }
87
- return _context.abrupt("continue", 25);
88
- case 20:
89
- buffer = void 0, name = void 0;
90
- sPath = void 0;
91
- if (cwd && files[i].indexOf && files[i].indexOf(cwd) !== 0) {
92
- sPath = (0, _path2.join)(cwd, files[i]);
93
- } else {
94
- sPath = files[i];
95
- }
96
- // If buffer
97
- if (files[i].contents) {
98
- name = (0, _path2.relative)(files[i].cwd, files[i].path);
99
- buffer = files[i].contents;
100
- } else if (!(0, _fsExtra.statSync)(sPath).isDirectory()) {
101
- // Else if it's a path and not a directory
102
- if (cwd && files[i].indexOf && files[i].indexOf(cwd) === 0) {
103
- name = files[i].substring(cwd.length);
104
- } else {
105
- name = files[i];
106
- }
107
- buffer = (0, _fsExtra.readFileSync)(sPath);
108
- } else {
109
- // Else if it's a directory path
110
- _zip3.folder(sPath);
111
- }
112
- if (name) {
113
- hasFiles = true;
114
- _zip3.file(name, buffer);
115
- }
116
- case 25:
117
- ++i;
118
- _context.next = 16;
119
- break;
120
- case 28:
121
- if (hasFiles) {
122
- _context.next = 30;
123
- break;
124
- }
125
- throw new Error('No source files found. If you intend to send a whole directory sufix your path with "**" (e.g. ./my-directory/**)');
126
- case 30:
127
- deferred.resolve(_zip3);
128
- case 31:
129
- return _context.abrupt("return", deferred.promise);
130
- case 32:
131
- case "end":
132
- return _context.stop();
30
+
31
+ async function zip(files, cwd) {
32
+ debug && console.log('Zipping files', (0, _util.inspect)(files));
33
+ const deferred = (0, _q.defer)();
34
+ // Flag to detect if any file was added to the zip archive
35
+ let hasFiles = false;
36
+ // Sanitize `cwd`
37
+ if (cwd) {
38
+ cwd = (0, _path2.normalize)(cwd);
39
+ }
40
+ // If it's already a zip file
41
+ if (files.length === 1 && /^.*\.zip$/.test(files[0])) {
42
+ hasFiles = true;
43
+ const zip = new _jszip.default();
44
+ let zipFile = (0, _fsExtra.readFileSync)(files[0]);
45
+ zipFile = await zip.loadAsync(zipFile);
46
+ deferred.resolve(zipFile);
47
+ } else {
48
+ const zip = new _jszip.default();
49
+ for (let i = 0, l = files.length; i < l; ++i) {
50
+ // Sanitise path
51
+ if (typeof files[i] === 'string') {
52
+ files[i] = (0, _path2.normalize)(files[i]);
53
+ if (files[i].indexOf('../') === 0) {
54
+ files[i] = (0, _path2.resolve)(files[i]);
55
+ }
56
+ }
57
+ // Bypass unwanted patterns from `files`
58
+ if (/.*\.(git|hg)(\/.*|$)/.test(files[i].path || files[i])) {
59
+ continue;
60
+ }
61
+ let buffer, name;
62
+ let sPath;
63
+ if (cwd && files[i].indexOf && files[i].indexOf(cwd) !== 0) {
64
+ sPath = (0, _path2.join)(cwd, files[i]);
65
+ } else {
66
+ sPath = files[i];
67
+ }
68
+ // If buffer
69
+ if (files[i].contents) {
70
+ name = (0, _path2.relative)(files[i].cwd, files[i].path);
71
+ buffer = files[i].contents;
72
+ } else if (!(0, _fsExtra.statSync)(sPath).isDirectory()) {
73
+ // Else if it's a path and not a directory
74
+ if (cwd && files[i].indexOf && files[i].indexOf(cwd) === 0) {
75
+ name = files[i].substring(cwd.length);
76
+ } else {
77
+ name = files[i];
133
78
  }
79
+ buffer = (0, _fsExtra.readFileSync)(sPath);
80
+ } else {
81
+ // Else if it's a directory path
82
+ zip.folder(sPath);
83
+ }
84
+ if (name) {
85
+ hasFiles = true;
86
+ zip.file(name, buffer);
134
87
  }
135
- }, _callee);
136
- }));
137
- return _zip.apply(this, arguments);
88
+ }
89
+ if (!hasFiles) {
90
+ throw new Error('No source files found. If you intend to send a whole directory sufix your path with "**" (e.g. ./my-directory/**)');
91
+ }
92
+ deferred.resolve(zip);
93
+ }
94
+ return deferred.promise;
138
95
  }
139
96
  function zipSources(sources) {
140
- var zipFile = new _jszip.default();
141
- var fileNames = sources.map(function (source) {
97
+ const zipFile = new _jszip.default();
98
+ const fileNames = sources.map(source => {
142
99
  zipFile.file(source.filename, source.content);
143
100
  return source.filename;
144
101
  });
@@ -151,92 +108,48 @@ function isWinAbsolutePath(path) {
151
108
  return (0, _path2.isAbsolute)(path) && /^([a-z]:)(.*)/i.test(path);
152
109
  }
153
110
  function parseWinAbsolutePath(_path) {
154
- var _path$match = _path.match(/^([a-z]:)(.*)/i),
155
- _path$match2 = _slicedToArray(_path$match, 3),
156
- full = _path$match2[0],
157
- drv = _path$match2[1],
158
- path = _path$match2[2];
111
+ const [full, drv, path] = _path.match(/^([a-z]:)(.*)/i);
159
112
  return {
160
- drv: drv,
161
- path: path
113
+ drv,
114
+ path
162
115
  };
163
116
  }
164
- function unzip(_x3, _x4) {
165
- return _unzip.apply(this, arguments);
166
- }
167
- function _unzip() {
168
- _unzip = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(zipFile, dest) {
169
- var stream,
170
- zip,
171
- _size,
172
- results,
173
- file,
174
- buffer,
175
- destPath,
176
- lastDestChar,
177
- _file,
178
- _args2 = arguments;
179
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
180
- while (1) {
181
- switch (_context2.prev = _context2.next) {
182
- case 0:
183
- stream = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : true;
184
- zip = new _jszip.default();
185
- _context2.next = 4;
186
- return zip.loadAsync(zipFile);
187
- case 4:
188
- _size = (0, _lodash.default)(zip.files);
189
- results = [];
190
- _context2.t0 = _regeneratorRuntime().keys(zip.files);
191
- case 7:
192
- if ((_context2.t1 = _context2.t0()).done) {
193
- _context2.next = 16;
194
- break;
195
- }
196
- file = _context2.t1.value;
197
- if (zip.files[file].dir) {
198
- _context2.next = 14;
199
- break;
200
- }
201
- _context2.next = 12;
202
- return zip.file(file).async('nodebuffer');
203
- case 12:
204
- buffer = _context2.sent;
205
- if (typeof dest === 'function') {
206
- if (stream) {
207
- dest(buffer, file);
208
- } else {
209
- results.push({
210
- filename: file,
211
- content: buffer.toString()
212
- });
213
- }
214
- } else if (dest && typeof dest === 'string') {
215
- lastDestChar = dest[dest.length - 1];
216
- if (_size === 1 && lastDestChar !== '/' && lastDestChar !== '\\') {
217
- destPath = dest;
218
- } else {
219
- _file = file; // Deal with win path join c:\dest\:c\src
220
- if (isWinAbsolutePath(_file)) {
221
- _file = parseWinAbsolutePath(_file).path;
222
- }
223
- destPath = (0, _path2.join)(dest, _file);
224
- }
225
- (0, _fsExtra.outputFileSync)(destPath, buffer);
226
- }
227
- case 14:
228
- _context2.next = 7;
229
- break;
230
- case 16:
231
- if (!stream) {
232
- dest(results);
233
- }
234
- case 17:
235
- case "end":
236
- return _context2.stop();
117
+ async function unzip(zipFile, dest) {
118
+ let stream = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
119
+ const zip = new _jszip.default();
120
+ await zip.loadAsync(zipFile);
121
+ const _size = (0, _lodash.default)(zip.files);
122
+ const results = [];
123
+ for (const file in zip.files) {
124
+ if (!zip.files[file].dir) {
125
+ const buffer = await zip.file(file).async('nodebuffer');
126
+ if (typeof dest === 'function') {
127
+ if (stream) {
128
+ dest(buffer, file);
129
+ } else {
130
+ results.push({
131
+ filename: file,
132
+ content: buffer.toString()
133
+ });
237
134
  }
135
+ } else if (dest && typeof dest === 'string') {
136
+ var destPath;
137
+ const lastDestChar = dest[dest.length - 1];
138
+ if (_size === 1 && lastDestChar !== '/' && lastDestChar !== '\\') {
139
+ destPath = dest;
140
+ } else {
141
+ let _file = file;
142
+ // Deal with win path join c:\dest\:c\src
143
+ if (isWinAbsolutePath(_file)) {
144
+ _file = parseWinAbsolutePath(_file).path;
145
+ }
146
+ destPath = (0, _path2.join)(dest, _file);
147
+ }
148
+ (0, _fsExtra.outputFileSync)(destPath, buffer);
238
149
  }
239
- }, _callee2);
240
- }));
241
- return _unzip.apply(this, arguments);
150
+ }
151
+ }
152
+ if (!stream) {
153
+ dest(results);
154
+ }
242
155
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "jscrambler",
3
3
  "description": "Jscrambler API client.",
4
- "version": "6.4.21",
4
+ "version": "6.4.23",
5
5
  "homepage": "https://github.com/jscrambler/jscrambler",
6
- "author": "Jscrambler <code@jscrambler.com>",
6
+ "author": "Jscrambler <support@jscrambler.com>",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/jscrambler/jscrambler.git"
@@ -11,17 +11,10 @@
11
11
  "bugs": {
12
12
  "url": "https://github.com/jscrambler/jscrambler/issues"
13
13
  },
14
- "licenses": [
15
- {
16
- "type": "MIT",
17
- "url": "https://github.com/jscrambler/javascript-jscrambler/blob/master/LICENSE-MIT"
18
- }
19
- ],
20
- "scripts": {
21
- "clean": "rm -rf ./dist",
22
- "build": "babel src --out-dir dist",
23
- "watch": "grunt watch",
24
- "prepublish": "npm run build"
14
+ "license": "MIT",
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "registry": "https://registry.npmjs.org/"
25
18
  },
26
19
  "engines": {
27
20
  "node": ">= 6.10.0"
@@ -43,27 +36,36 @@
43
36
  "lodash.size": "^4.0.1",
44
37
  "q": "^1.4.1",
45
38
  "rc": "^1.1.0",
46
- "regenerator-runtime": "^0.13.9",
47
39
  "snake-case": "^2.1.0",
48
40
  "temp": "^0.8.3"
49
41
  },
50
42
  "devDependencies": {
51
- "@babel/cli": "^7.14.8",
52
- "@babel/core": "^7.15.0",
53
- "@babel/plugin-proposal-object-rest-spread": "^7.14.7",
54
- "@babel/preset-env": "^7.15.0",
55
- "grunt": "^1.0.2",
56
- "grunt-cli": "^1.2.0",
57
- "grunt-contrib-clean": "^1.0.0",
58
- "grunt-contrib-copy": "^1.0.0",
59
- "grunt-contrib-watch": "^1.0.0"
43
+ "@babel/cli": "^7.23.4",
44
+ "@babel/core": "^7.23.7",
45
+ "@babel/preset-env": "^7.23.8"
60
46
  },
61
47
  "files": [
62
48
  "dist",
63
- "LICENSE-MIT"
49
+ "CHANGELOG.md"
64
50
  ],
65
51
  "main": "dist/index.js",
66
52
  "bin": {
67
53
  "jscrambler": "dist/bin/jscrambler.js"
54
+ },
55
+ "keywords": [
56
+ "cli",
57
+ "jscrambler",
58
+ "obfuscate",
59
+ "protect",
60
+ "js",
61
+ "javascript"
62
+ ],
63
+ "scripts": {
64
+ "clean": "rm -rf ./dist",
65
+ "build": "babel src --out-dir dist",
66
+ "watch": "babel -w src --out-dir dist",
67
+ "prepublish": "npm run build",
68
+ "eslint": "eslint src/",
69
+ "eslint:fix": "eslint src/ --fix"
68
70
  }
69
- }
71
+ }
File without changes