jscrambler 6.1.3 → 6.1.6

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/client.js CHANGED
@@ -63,6 +63,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
63
63
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
64
64
 
65
65
  var debug = !!process.env.DEBUG;
66
+ var metrics = !!process.env.METRICS;
66
67
 
67
68
  var ClientError = /*#__PURE__*/function (_Error) {
68
69
  _inherits(ClientError, _Error);
@@ -294,7 +295,12 @@ JScramblerClient.prototype.request = function (method, path) {
294
295
  promise = this.axiosInstance[method.toLowerCase()](formattedUrl, data, settings);
295
296
  }
296
297
 
298
+ var start = Date.now();
297
299
  return promise.then(function (res) {
300
+ if (metrics || debug) {
301
+ console.log("".concat(method, " ").concat(path, " ").concat(((data || settings.params).query || '').split('(')[0].trim().replace(' ', '-'), " ").concat(JSON.stringify(data || settings.params).length, "B ").concat(Date.now() - start, "ms"));
302
+ }
303
+
298
304
  return res.data;
299
305
  }).catch(function (err) {
300
306
  var errorMessage = 'Unexpected Response: ';
package/dist/index.js CHANGED
@@ -49,22 +49,14 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
49
49
 
50
50
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
51
51
 
52
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
53
+
52
54
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
53
55
 
54
56
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
55
57
 
56
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
57
-
58
- 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."); }
59
-
60
- 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); }
61
-
62
58
  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; }
63
59
 
64
- 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; }
65
-
66
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
67
-
68
60
  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; }
69
61
 
70
62
  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; }
@@ -165,33 +157,37 @@ var _default = {
165
157
  var _this = this;
166
158
 
167
159
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
168
- var sources, filesSrc, cwd, appProfiling, promise, zipped, source, _filesSrc, i, l, content;
160
+ var sources, filesSrc, cwd, appProfiling, removeSourceRes, zipped, source, _filesSrc, i, l, content;
169
161
 
170
162
  return regeneratorRuntime.wrap(function _callee$(_context) {
171
163
  while (1) {
172
164
  switch (_context.prev = _context.next) {
173
165
  case 0:
174
166
  sources = _ref.sources, filesSrc = _ref.filesSrc, cwd = _ref.cwd, appProfiling = _ref.appProfiling;
175
- promise = Promise.resolve();
176
167
 
177
168
  if (!(sources || filesSrc && filesSrc.length)) {
178
- _context.next = 6;
169
+ _context.next = 8;
179
170
  break;
180
171
  }
181
172
 
182
173
  if (!(appProfiling && appProfiling.data && appProfiling.data.state === 'READY')) {
183
- _context.next = 5;
174
+ _context.next = 4;
184
175
  break;
185
176
  }
186
177
 
187
178
  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*.');
188
179
 
189
- case 5:
190
- promise = _this.removeSourceFromApplication(client, '', applicationId);
180
+ case 4:
181
+ _context.next = 6;
182
+ return _this.removeSourceFromApplication(client, '', applicationId);
191
183
 
192
184
  case 6:
185
+ removeSourceRes = _context.sent;
186
+ errorHandler(removeSourceRes);
187
+
188
+ case 8:
193
189
  if (!(filesSrc && filesSrc.length)) {
194
- _context.next = 15;
190
+ _context.next = 17;
195
191
  break;
196
192
  }
197
193
 
@@ -209,17 +205,17 @@ var _default = {
209
205
  console.log('Creating zip from source files');
210
206
  }
211
207
 
212
- _context.next = 12;
208
+ _context.next = 14;
213
209
  return (0, _zip.zip)(_filesSrc, cwd);
214
210
 
215
- case 12:
211
+ case 14:
216
212
  zipped = _context.sent;
217
- _context.next = 20;
213
+ _context.next = 22;
218
214
  break;
219
215
 
220
- case 15:
216
+ case 17:
221
217
  if (!sources) {
222
- _context.next = 20;
218
+ _context.next = 22;
223
219
  break;
224
220
  }
225
221
 
@@ -227,24 +223,29 @@ var _default = {
227
223
  console.log('Creating zip from sources');
228
224
  }
229
225
 
230
- _context.next = 19;
226
+ _context.next = 21;
231
227
  return (0, _zip.zipSources)(sources);
232
228
 
233
- case 19:
229
+ case 21:
234
230
  zipped = _context.sent;
235
231
 
236
- case 20:
232
+ case 22:
237
233
  if (!zipped) {
238
- _context.next = 27;
234
+ _context.next = 33;
239
235
  break;
240
236
  }
241
237
 
242
- _context.next = 23;
238
+ _context.next = 25;
243
239
  return zipped.generateAsync({
244
- type: 'base64'
240
+ type: 'base64',
241
+ compression: 'DEFLATE',
242
+ compressionOptions: {
243
+ // 1 - 9 (max compression)
244
+ level: 5
245
+ }
245
246
  });
246
247
 
247
- case 23:
248
+ case 25:
248
249
  content = _context.sent;
249
250
 
250
251
  if (debug) {
@@ -256,20 +257,18 @@ var _default = {
256
257
  filename: 'application.zip',
257
258
  extension: 'zip'
258
259
  };
259
- promise = promise.then(function (removeRes) {
260
- errorHandler(removeRes);
261
- return _this.addApplicationSource(client, applicationId, source);
262
- }).then(errorHandler).catch(function (e) {
263
- console.warn("Update application sources failed with ".concat(e.message));
264
- });
260
+ _context.t0 = errorHandler;
261
+ _context.next = 31;
262
+ return _this.addApplicationSource(client, applicationId, source);
265
263
 
266
- case 27:
267
- return _context.abrupt("return", {
268
- source: source,
269
- promise: promise
270
- });
264
+ case 31:
265
+ _context.t1 = _context.sent;
266
+ (0, _context.t0)(_context.t1);
271
267
 
272
- case 28:
268
+ case 33:
269
+ return _context.abrupt("return", source);
270
+
271
+ case 34:
273
272
  case "end":
274
273
  return _context.stop();
275
274
  }
@@ -324,7 +323,7 @@ var _default = {
324
323
  var _this2 = this;
325
324
 
326
325
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
327
- 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, forceAppEnvironment, accessKey, secretKey, client, filesSrc, filesDest, source, updateApplicationSourcePromise, appProfiling, _yield$_this2$updateA, updateData, dataToValidate, prop, value, applicationUpdate, updateApplicationRes, protectionOptions, inputSymbolTableContents, _yield$Promise$all, _yield$Promise$all2, createApplicationProtectionRes, protectionIds, onExitCancelProtection, processedProtections, handleProtection, i, protection;
326
+ 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, forceAppEnvironment, accessKey, secretKey, client, filesSrc, filesDest, source, appProfiling, updateData, dataToValidate, prop, value, applicationUpdate, updateApplicationRes, protectionOptions, inputSymbolTableContents, createApplicationProtectionRes, protectionIds, onExitCancelProtection, processedProtections, handleProtection, i, protection;
328
327
 
329
328
  return regeneratorRuntime.wrap(function _callee4$(_context4) {
330
329
  while (1) {
@@ -375,7 +374,7 @@ var _default = {
375
374
 
376
375
  case 13:
377
376
  if (skipSources) {
378
- _context4.next = 28;
377
+ _context4.next = 26;
379
378
  break;
380
379
  }
381
380
 
@@ -408,16 +407,14 @@ var _default = {
408
407
  });
409
408
 
410
409
  case 23:
411
- _yield$_this2$updateA = _context4.sent;
412
- source = _yield$_this2$updateA.source;
413
- updateApplicationSourcePromise = _yield$_this2$updateA.promise;
414
- _context4.next = 29;
410
+ source = _context4.sent;
411
+ _context4.next = 27;
415
412
  break;
416
413
 
417
- case 28:
414
+ case 26:
418
415
  console.log('Update source files SKIPPED');
419
416
 
420
- case 29:
417
+ case 27:
421
418
  updateData = {
422
419
  _id: applicationId,
423
420
  debugMode: !!debugMode,
@@ -451,7 +448,7 @@ var _default = {
451
448
  }
452
449
 
453
450
  if (!(updateData.parameters || updateData.applicationTypes || updateData.languageSpecifications || updateData.browsers || typeof updateData.areSubscribersOrdered !== 'undefined')) {
454
- _context4.next = 43;
451
+ _context4.next = 41;
455
452
  break;
456
453
  }
457
454
 
@@ -459,15 +456,15 @@ var _default = {
459
456
  console.log('Updating parameters of protection');
460
457
  }
461
458
 
462
- _context4.next = 37;
459
+ _context4.next = 35;
463
460
  return intoObjectType(client, updateData, 'Application');
464
461
 
465
- case 37:
462
+ case 35:
466
463
  applicationUpdate = _context4.sent;
467
- _context4.next = 40;
464
+ _context4.next = 38;
468
465
  return _this2.updateApplication(client, applicationUpdate);
469
466
 
470
- case 40:
467
+ case 38:
471
468
  updateApplicationRes = _context4.sent;
472
469
 
473
470
  if (debug) {
@@ -477,7 +474,7 @@ var _default = {
477
474
 
478
475
  errorHandler(updateApplicationRes);
479
476
 
480
- case 43:
477
+ case 41:
481
478
  if (debug) {
482
479
  console.log('Creating Application Protection');
483
480
  }
@@ -503,13 +500,11 @@ var _default = {
503
500
  protectionOptions.inputSymbolTable = inputSymbolTableContents;
504
501
  }
505
502
 
506
- _context4.next = 49;
507
- return Promise.all([_this2.createApplicationProtections(client, applicationId, protectionOptions), updateApplicationSourcePromise]);
503
+ _context4.next = 47;
504
+ return _this2.createApplicationProtections(client, applicationId, protectionOptions);
508
505
 
509
- case 49:
510
- _yield$Promise$all = _context4.sent;
511
- _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 1);
512
- createApplicationProtectionRes = _yield$Promise$all2[0];
506
+ case 47:
507
+ createApplicationProtectionRes = _context4.sent;
513
508
  errorHandler(createApplicationProtectionRes);
514
509
  protectionIds = createApplicationProtectionRes.data.protections.map(function (_ref2) {
515
510
  var _id = _ref2._id;
@@ -575,15 +570,15 @@ var _default = {
575
570
  _context4.t1 = client;
576
571
  _context4.t2 = applicationId;
577
572
  _context4.t3 = protectionIds;
578
- _context4.next = 62;
573
+ _context4.next = 58;
579
574
  return (0, _getProtectionDefaultFragments.default)(client);
580
575
 
581
- case 62:
576
+ case 58:
582
577
  _context4.t4 = _context4.sent;
583
- _context4.next = 65;
578
+ _context4.next = 61;
584
579
  return _context4.t0.pollProtections.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3, _context4.t4);
585
580
 
586
- case 65:
581
+ case 61:
587
582
  processedProtections = _context4.sent;
588
583
  process.removeListener('SIGINT', onExitCancelProtection).removeListener('SIGTERM', onExitCancelProtection);
589
584
 
@@ -711,54 +706,54 @@ var _default = {
711
706
  }();
712
707
 
713
708
  if (!(processedProtections.length === 1)) {
714
- _context4.next = 70;
709
+ _context4.next = 66;
715
710
  break;
716
711
  }
717
712
 
718
713
  return _context4.abrupt("return", handleProtection(processedProtections[0]));
719
714
 
720
- case 70:
715
+ case 66:
721
716
  console.log("Protections stored in ".concat(filesDest, "/[protection-id]"));
722
717
  i = 0;
723
718
 
724
- case 72:
719
+ case 68:
725
720
  if (!(i < processedProtections.length)) {
726
- _context4.next = 85;
721
+ _context4.next = 81;
727
722
  break;
728
723
  }
729
724
 
730
725
  protection = processedProtections[i];
731
- _context4.prev = 74;
732
- _context4.next = 77;
726
+ _context4.prev = 70;
727
+ _context4.next = 73;
733
728
  return handleProtection(protection, {
734
729
  outPrefix: "/".concat(protection._id, "/"),
735
730
  printProtectionId: false
736
731
  });
737
732
 
738
- case 77:
739
- _context4.next = 82;
733
+ case 73:
734
+ _context4.next = 78;
740
735
  break;
741
736
 
742
- case 79:
743
- _context4.prev = 79;
744
- _context4.t5 = _context4["catch"](74);
737
+ case 75:
738
+ _context4.prev = 75;
739
+ _context4.t5 = _context4["catch"](70);
745
740
  console.error(_context4.t5);
746
741
 
747
- case 82:
742
+ case 78:
748
743
  i++;
749
- _context4.next = 72;
744
+ _context4.next = 68;
750
745
  break;
751
746
 
752
- case 85:
747
+ case 81:
753
748
  console.log("Runtime: ".concat(processedProtections.length, " protections in ").concat(Math.round((Date.now() - start) / 1000), "s"));
754
749
  return _context4.abrupt("return", protectionIds);
755
750
 
756
- case 87:
751
+ case 83:
757
752
  case "end":
758
753
  return _context4.stop();
759
754
  }
760
755
  }
761
- }, _callee4, null, [[74, 79]]);
756
+ }, _callee4, null, [[70, 75]]);
762
757
  }))();
763
758
  },
764
759
 
package/dist/zip.js CHANGED
@@ -53,7 +53,7 @@ function zip(_x, _x2) {
53
53
 
54
54
  function _zip() {
55
55
  _zip = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(files, cwd) {
56
- var deferred, hasFiles, _zip2, zipFile, _zip3, i, l, buffer, name, sPath, tempFile;
56
+ var deferred, hasFiles, _zip2, zipFile, _zip3, i, l, buffer, name, sPath;
57
57
 
58
58
  return regeneratorRuntime.wrap(function _callee$(_context) {
59
59
  while (1) {
@@ -70,32 +70,29 @@ function _zip() {
70
70
 
71
71
 
72
72
  if (!(files.length === 1 && /^.*\.zip$/.test(files[0]))) {
73
- _context.next = 15;
73
+ _context.next = 14;
74
74
  break;
75
75
  }
76
76
 
77
77
  hasFiles = true;
78
78
  _zip2 = new _jszip.default();
79
79
  zipFile = (0, _fsExtra.readFileSync)(files[0]);
80
- (0, _fsExtra.outputFileSync)(_temp.default.openSync({
81
- suffix: '.zip'
82
- }).path, zipFile);
83
- _context.next = 11;
80
+ _context.next = 10;
84
81
  return _zip2.loadAsync(zipFile);
85
82
 
86
- case 11:
83
+ case 10:
87
84
  zipFile = _context.sent;
88
85
  deferred.resolve(zipFile);
89
- _context.next = 43;
86
+ _context.next = 31;
90
87
  break;
91
88
 
92
- case 15:
89
+ case 14:
93
90
  _zip3 = new _jszip.default();
94
91
  i = 0, l = files.length;
95
92
 
96
- case 17:
93
+ case 16:
97
94
  if (!(i < l)) {
98
- _context.next = 29;
95
+ _context.next = 28;
99
96
  break;
100
97
  }
101
98
 
@@ -110,13 +107,13 @@ function _zip() {
110
107
 
111
108
 
112
109
  if (!/.*\.(git|hg)(\/.*|$)/.test(files[i].path || files[i])) {
113
- _context.next = 21;
110
+ _context.next = 20;
114
111
  break;
115
112
  }
116
113
 
117
- return _context.abrupt("continue", 26);
114
+ return _context.abrupt("continue", 25);
118
115
 
119
- case 21:
116
+ case 20:
120
117
  buffer = void 0, name = void 0;
121
118
  sPath = void 0;
122
119
 
@@ -150,43 +147,26 @@ function _zip() {
150
147
  _zip3.file(name, buffer);
151
148
  }
152
149
 
153
- case 26:
150
+ case 25:
154
151
  ++i;
155
- _context.next = 17;
152
+ _context.next = 16;
156
153
  break;
157
154
 
158
- case 29:
159
- if (!hasFiles) {
160
- _context.next = 42;
155
+ case 28:
156
+ if (hasFiles) {
157
+ _context.next = 30;
161
158
  break;
162
159
  }
163
160
 
164
- tempFile = _temp.default.openSync({
165
- suffix: '.zip'
166
- });
167
- _context.t0 = _fsExtra.outputFileSync;
168
- _context.t1 = tempFile.path;
169
- _context.next = 35;
170
- return _zip3.generateAsync({
171
- type: 'nodebuffer'
172
- });
173
-
174
- case 35:
175
- _context.t2 = _context.sent;
176
- (0, _context.t0)(_context.t1, _context.t2);
177
- files[0] = tempFile.path;
178
- files.length = 1;
179
- deferred.resolve(_zip3);
180
- _context.next = 43;
181
- break;
182
-
183
- case 42:
184
161
  throw new Error('No source files found. If you intend to send a whole directory sufix your path with "**" (e.g. ./my-directory/**)');
185
162
 
186
- case 43:
163
+ case 30:
164
+ deferred.resolve(_zip3);
165
+
166
+ case 31:
187
167
  return _context.abrupt("return", deferred.promise);
188
168
 
189
- case 44:
169
+ case 32:
190
170
  case "end":
191
171
  return _context.stop();
192
172
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jscrambler",
3
3
  "description": "Jscrambler API client.",
4
- "version": "6.1.3",
4
+ "version": "6.1.6",
5
5
  "homepage": "https://github.com/jscrambler/jscrambler",
6
6
  "author": "Jscrambler <code@jscrambler.com>",
7
7
  "repository": {