jscrambler 6.0.4 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -329,17 +329,18 @@ exports.default = {
329
329
  // Jscrambler or if you're provided access to beta features of our product.
330
330
  //
331
331
  protectAndDownload: function () {
332
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(configPathOrObject, destCallback) {
332
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(configPathOrObject, destCallback) {
333
333
  var _this2 = this;
334
334
 
335
- var 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, forceAppEnvironment, accessKey, secretKey, client, filesSrc, filesDest, source, updateApplicationSourcePromise, appProfiling, _ref4, updateData, dataToValidate, prop, value, applicationUpdate, updateApplicationRes, protectionOptions, inputSymbolTableContents, _ref5, _ref6, createApplicationProtectionRes, protectionId, onExitCancelProtection, protection, sourcesErrors, download;
335
+ 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, _ref4, updateData, dataToValidate, prop, value, applicationUpdate, updateApplicationRes, protectionOptions, inputSymbolTableContents, _ref5, _ref6, createApplicationProtectionRes, protectionIds, onExitCancelProtection, processedProtections, handleProtection, i, protection;
336
336
 
337
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
337
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
338
338
  while (1) {
339
- switch (_context2.prev = _context2.next) {
339
+ switch (_context4.prev = _context4.next) {
340
340
  case 0:
341
+ start = Date.now();
341
342
  finalConfig = buildFinalConfig(configPathOrObject);
342
- 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 === undefined ? 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 === undefined ? 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, forceAppEnvironment = finalConfig.forceAppEnvironment;
343
+ 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 === undefined ? 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 === undefined ? 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, forceAppEnvironment = finalConfig.forceAppEnvironment;
343
344
  accessKey = keys.accessKey, secretKey = keys.secretKey;
344
345
  client = new this.Client({
345
346
  accessKey: accessKey,
@@ -367,49 +368,49 @@ exports.default = {
367
368
  }
368
369
 
369
370
  if (applicationId) {
370
- _context2.next = 10;
371
+ _context4.next = 11;
371
372
  break;
372
373
  }
373
374
 
374
375
  throw new Error('Required *applicationId* not provided');
375
376
 
376
- case 10:
377
+ case 11:
377
378
  if (!(!filesDest && !destCallback)) {
378
- _context2.next = 12;
379
+ _context4.next = 13;
379
380
  break;
380
381
  }
381
382
 
382
383
  throw new Error('Required *filesDest* not provided');
383
384
 
384
- case 12:
385
+ case 13:
385
386
  source = void 0, updateApplicationSourcePromise = void 0;
386
387
 
387
388
  if (skipSources) {
388
- _context2.next = 28;
389
+ _context4.next = 29;
389
390
  break;
390
391
  }
391
392
 
392
- _context2.next = 16;
393
+ _context4.next = 17;
393
394
  return this.getApplicationProfiling(client, applicationId).catch(function (e) {
394
395
  if (![_constants.HTTP_STATUS_CODES.NOT_FOUND, _constants.HTTP_STATUS_CODES.FORBIDDEN, _constants.HTTP_STATUS_CODES.SERVICE_UNAVAILABLE].includes(e.statusCode)) throw e;
395
396
  });
396
397
 
397
- case 16:
398
- appProfiling = _context2.sent;
398
+ case 17:
399
+ appProfiling = _context4.sent;
399
400
 
400
401
  if (!(appProfiling && removeProfilingData)) {
401
- _context2.next = 21;
402
+ _context4.next = 22;
402
403
  break;
403
404
  }
404
405
 
405
- _context2.next = 20;
406
+ _context4.next = 21;
406
407
  return this.deleteProfiling(client, appProfiling.data.id);
407
408
 
408
- case 20:
409
+ case 21:
409
410
  appProfiling.data.state = 'DELETED';
410
411
 
411
- case 21:
412
- _context2.next = 23;
412
+ case 22:
413
+ _context4.next = 24;
413
414
  return this.updateApplicationSources(client, applicationId, {
414
415
  sources: sources,
415
416
  filesSrc: filesSrc,
@@ -417,17 +418,17 @@ exports.default = {
417
418
  appProfiling: appProfiling
418
419
  });
419
420
 
420
- case 23:
421
- _ref4 = _context2.sent;
421
+ case 24:
422
+ _ref4 = _context4.sent;
422
423
  source = _ref4.source;
423
424
  updateApplicationSourcePromise = _ref4.promise;
424
- _context2.next = 29;
425
+ _context4.next = 30;
425
426
  break;
426
427
 
427
- case 28:
428
+ case 29:
428
429
  console.log('Update source files SKIPPED');
429
430
 
430
- case 29:
431
+ case 30:
431
432
  updateData = {
432
433
  _id: applicationId,
433
434
  debugMode: !!debugMode,
@@ -463,7 +464,7 @@ exports.default = {
463
464
  }
464
465
 
465
466
  if (!(updateData.parameters || updateData.applicationTypes || updateData.languageSpecifications || updateData.browsers || typeof updateData.areSubscribersOrdered !== 'undefined')) {
466
- _context2.next = 43;
467
+ _context4.next = 44;
467
468
  break;
468
469
  }
469
470
 
@@ -471,16 +472,16 @@ exports.default = {
471
472
  console.log('Updating parameters of protection');
472
473
  }
473
474
 
474
- _context2.next = 37;
475
+ _context4.next = 38;
475
476
  return intoObjectType(client, updateData, 'Application');
476
477
 
477
- case 37:
478
- applicationUpdate = _context2.sent;
479
- _context2.next = 40;
478
+ case 38:
479
+ applicationUpdate = _context4.sent;
480
+ _context4.next = 41;
480
481
  return this.updateApplication(client, applicationUpdate);
481
482
 
482
- case 40:
483
- updateApplicationRes = _context2.sent;
483
+ case 41:
484
+ updateApplicationRes = _context4.sent;
484
485
 
485
486
  if (debug) {
486
487
  console.log('Finished updating parameters of protection');
@@ -488,7 +489,7 @@ exports.default = {
488
489
  }
489
490
  errorHandler(updateApplicationRes);
490
491
 
491
- case 43:
492
+ case 44:
492
493
 
493
494
  if (debug) {
494
495
  console.log('Creating Application Protection');
@@ -503,6 +504,7 @@ exports.default = {
503
504
  randomizationSeed: randomizationSeed,
504
505
  source: source,
505
506
  tolerateMinification: tolerateMinification,
507
+ numberOfProtections: numberOfProtections,
506
508
  forceAppEnvironment: forceAppEnvironment
507
509
  });
508
510
 
@@ -516,147 +518,267 @@ exports.default = {
516
518
  protectionOptions.inputSymbolTable = inputSymbolTableContents;
517
519
  }
518
520
 
519
- _context2.next = 49;
520
- return Promise.all([this.createApplicationProtection(client, applicationId, protectionOptions), updateApplicationSourcePromise]);
521
+ _context4.next = 50;
522
+ return Promise.all([this.createApplicationProtections(client, applicationId, protectionOptions), updateApplicationSourcePromise]);
521
523
 
522
- case 49:
523
- _ref5 = _context2.sent;
524
+ case 50:
525
+ _ref5 = _context4.sent;
524
526
  _ref6 = _slicedToArray(_ref5, 1);
525
527
  createApplicationProtectionRes = _ref6[0];
526
528
 
527
529
  errorHandler(createApplicationProtectionRes);
528
530
 
529
- protectionId = createApplicationProtectionRes.data.createApplicationProtection._id;
531
+ protectionIds = createApplicationProtectionRes.data.protections.map(function (_ref7) {
532
+ var _id = _ref7._id;
533
+ return _id;
534
+ });
530
535
 
531
- onExitCancelProtection = function onExitCancelProtection() {
532
- _this2.cancelProtection(client, protectionId, applicationId).then(function () {
533
- return console.log('\n** Protection %s WAS CANCELLED **', protectionId);
534
- }).catch(function () {
535
- return debug && console.error(e);
536
- }).finally(function () {
537
- return process.exit(1);
538
- });
539
- };
536
+ onExitCancelProtection = function () {
537
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
538
+ var i, protectionId;
539
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
540
+ while (1) {
541
+ switch (_context2.prev = _context2.next) {
542
+ case 0:
543
+ i = 0;
544
+
545
+ case 1:
546
+ if (!(i < protectionIds.length)) {
547
+ _context2.next = 15;
548
+ break;
549
+ }
550
+
551
+ protectionId = protectionIds[i];
552
+ _context2.prev = 3;
553
+ _context2.next = 6;
554
+ return _this2.cancelProtection(client, protectionId, applicationId);
555
+
556
+ case 6:
557
+ console.log('** Protection %s WAS CANCELLED **', protectionId);
558
+ _context2.next = 12;
559
+ break;
560
+
561
+ case 9:
562
+ _context2.prev = 9;
563
+ _context2.t0 = _context2['catch'](3);
564
+
565
+ if (debug) {
566
+ console.error(_context2.t0);
567
+ }
568
+
569
+ case 12:
570
+ i++;
571
+ _context2.next = 1;
572
+ break;
573
+
574
+ case 15:
575
+ process.exit(1);
576
+
577
+ case 16:
578
+ case 'end':
579
+ return _context2.stop();
580
+ }
581
+ }
582
+ }, _callee2, _this2, [[3, 9]]);
583
+ }));
584
+
585
+ return function onExitCancelProtection() {
586
+ return _ref8.apply(this, arguments);
587
+ };
588
+ }();
540
589
 
541
590
  process.once('SIGINT', onExitCancelProtection).once('SIGTERM', onExitCancelProtection);
542
591
 
543
- _context2.t0 = this;
544
- _context2.t1 = client;
545
- _context2.t2 = applicationId;
546
- _context2.t3 = protectionId;
547
- _context2.next = 62;
592
+ _context4.t0 = this;
593
+ _context4.t1 = client;
594
+ _context4.t2 = applicationId;
595
+ _context4.t3 = protectionIds;
596
+ _context4.next = 63;
548
597
  return (0, _getProtectionDefaultFragments2.default)(client);
549
598
 
550
- case 62:
551
- _context2.t4 = _context2.sent;
552
- _context2.next = 65;
553
- return _context2.t0.pollProtection.call(_context2.t0, _context2.t1, _context2.t2, _context2.t3, _context2.t4);
599
+ case 63:
600
+ _context4.t4 = _context4.sent;
601
+ _context4.next = 66;
602
+ return _context4.t0.pollProtections.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3, _context4.t4);
554
603
 
555
- case 65:
556
- protection = _context2.sent;
604
+ case 66:
605
+ processedProtections = _context4.sent;
557
606
 
558
607
 
559
608
  process.removeListener('SIGINT', onExitCancelProtection).removeListener('SIGTERM', onExitCancelProtection);
560
609
 
561
- if (protection.growthWarning) {
562
- 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: ' + APP_URL + '.');
563
- }
564
- if (debug) {
565
- console.log('Finished protecting');
566
- }
610
+ handleProtection = function () {
611
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(protection) {
612
+ var _ref10 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
613
+ _ref10$outPrefix = _ref10.outPrefix,
614
+ outPrefix = _ref10$outPrefix === undefined ? '' : _ref10$outPrefix,
615
+ _ref10$printProtectio = _ref10.printProtectionId,
616
+ printProtectionId = _ref10$printProtectio === undefined ? true : _ref10$printProtectio;
567
617
 
568
- if (protection.deprecations) {
569
- protection.deprecations.forEach(function (deprecation) {
570
- if (deprecation.type === 'Transformation') {
571
- console.warn('Warning: ' + deprecation.type + ' ' + deprecation.entity + ' is no longer maintained. Please consider removing it from your configuration.');
572
- } else if (deprecation.type && deprecation.entity) {
573
- console.warn('Warning: ' + deprecation.type + ' ' + deprecation.entity + ' is deprecated.');
574
- }
575
- });
576
- }
618
+ var sourcesErrors, download;
619
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
620
+ while (1) {
621
+ switch (_context3.prev = _context3.next) {
622
+ case 0:
623
+ if (protection.growthWarning) {
624
+ 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: ' + APP_URL + '.');
625
+ }
626
+ if (debug) {
627
+ console.log('Finished protecting');
628
+ }
577
629
 
578
- sourcesErrors = [];
630
+ if (protection.deprecations) {
631
+ protection.deprecations.forEach(function (deprecation) {
632
+ if (deprecation.type === 'Transformation') {
633
+ console.warn('Warning: ' + deprecation.type + ' ' + deprecation.entity + ' is no longer maintained. Please consider removing it from your configuration.');
634
+ } else if (deprecation.type && deprecation.entity) {
635
+ console.warn('Warning: ' + deprecation.type + ' ' + deprecation.entity + ' is deprecated.');
636
+ }
637
+ });
638
+ }
579
639
 
640
+ sourcesErrors = [];
580
641
 
581
- protection.sources.forEach(function (s) {
582
- if (s.errorMessages && s.errorMessages.length > 0) {
583
- sourcesErrors.push.apply(sourcesErrors, _toConsumableArray(s.errorMessages.map(function (e) {
584
- return Object.assign({
585
- filename: s.filename
586
- }, e);
587
- })));
588
- }
589
- });
590
642
 
591
- if (!(protection.state === 'errored')) {
592
- _context2.next = 80;
593
- break;
594
- }
643
+ protection.sources.forEach(function (s) {
644
+ if (s.errorMessages && s.errorMessages.length > 0) {
645
+ sourcesErrors.push.apply(sourcesErrors, _toConsumableArray(s.errorMessages.map(function (e) {
646
+ return Object.assign({
647
+ filename: s.filename
648
+ }, e);
649
+ })));
650
+ }
651
+ });
595
652
 
596
- console.error('Global protection errors:');
597
- console.error('- ' + protection.errorMessage);
598
- console.error('');
599
- if (sourcesErrors.length > 0) {
600
- printSourcesErrors(sourcesErrors);
601
- }
602
- throw new Error('Protection failed. For more information visit: ' + APP_URL + '.');
653
+ if (!(protection.state === 'errored')) {
654
+ _context3.next = 13;
655
+ break;
656
+ }
603
657
 
604
- case 80:
605
- if (!(sourcesErrors.length > 0)) {
606
- _context2.next = 87;
607
- break;
608
- }
658
+ console.error('Global protection errors:');
659
+ console.error('- ' + protection.errorMessage);
660
+ console.error('');
661
+ if (sourcesErrors.length > 0) {
662
+ printSourcesErrors(sourcesErrors);
663
+ }
664
+ throw new Error('Protection failed. For more information visit: ' + APP_URL + '.');
609
665
 
610
- if (!protection.bail) {
611
- _context2.next = 86;
612
- break;
613
- }
666
+ case 13:
667
+ if (!(sourcesErrors.length > 0)) {
668
+ _context3.next = 20;
669
+ break;
670
+ }
614
671
 
615
- printSourcesErrors(sourcesErrors);
616
- throw new Error('Your protection has failed.');
672
+ if (!protection.bail) {
673
+ _context3.next = 19;
674
+ break;
675
+ }
617
676
 
618
- case 86:
619
- sourcesErrors.forEach(function (e) {
620
- return console.warn('Non-fatal error: "' + e.message + '" in ' + e.filename);
621
- });
677
+ printSourcesErrors(sourcesErrors);
678
+ throw new Error('Your protection has failed.');
622
679
 
623
- case 87:
680
+ case 19:
681
+ sourcesErrors.forEach(function (e) {
682
+ return console.warn('Non-fatal error: "' + e.message + '" in ' + e.filename);
683
+ });
624
684
 
625
- if (debug) {
626
- console.log('Downloading protection result');
627
- }
628
- _context2.next = 90;
629
- return this.downloadApplicationProtection(client, protectionId);
685
+ case 20:
630
686
 
631
- case 90:
632
- download = _context2.sent;
687
+ if (debug) {
688
+ console.log('Downloading protection result');
689
+ }
690
+ _context3.next = 23;
691
+ return _this2.downloadApplicationProtection(client, protection._id);
633
692
 
693
+ case 23:
694
+ download = _context3.sent;
634
695
 
635
- errorHandler(download);
636
696
 
637
- if (debug) {
638
- console.log('Unzipping files');
697
+ errorHandler(download);
698
+
699
+ if (debug) {
700
+ console.log('Unzipping files');
701
+ }
702
+
703
+ _context3.next = 28;
704
+ return (0, _zip.unzip)(download, (filesDest ? '' + filesDest + outPrefix : filesDest) || destCallback, stream);
705
+
706
+ case 28:
707
+
708
+ if (debug) {
709
+ console.log('Finished unzipping files');
710
+ }
711
+
712
+ if (printProtectionId) {
713
+ console.log(protection._id);
714
+ }
715
+
716
+ return _context3.abrupt('return', protection._id);
717
+
718
+ case 31:
719
+ case 'end':
720
+ return _context3.stop();
721
+ }
722
+ }
723
+ }, _callee3, _this2);
724
+ }));
725
+
726
+ return function handleProtection(_x7) {
727
+ return _ref9.apply(this, arguments);
728
+ };
729
+ }();
730
+
731
+ if (!(processedProtections.length === 1)) {
732
+ _context4.next = 71;
733
+ break;
639
734
  }
640
735
 
641
- _context2.next = 95;
642
- return (0, _zip.unzip)(download, filesDest || destCallback, stream);
736
+ return _context4.abrupt('return', handleProtection(processedProtections[0]));
643
737
 
644
- case 95:
738
+ case 71:
645
739
 
646
- if (debug) {
647
- console.log('Finished unzipping files');
740
+ console.log('Protections stored in ' + filesDest + '/[protection-id]');
741
+
742
+ i = 0;
743
+
744
+ case 73:
745
+ if (!(i < processedProtections.length)) {
746
+ _context4.next = 86;
747
+ break;
648
748
  }
649
749
 
650
- console.log(protectionId);
750
+ protection = processedProtections[i];
751
+ _context4.prev = 75;
752
+ _context4.next = 78;
753
+ return handleProtection(protection, { outPrefix: '/' + protection._id + '/', printProtectionId: false });
754
+
755
+ case 78:
756
+ _context4.next = 83;
757
+ break;
758
+
759
+ case 80:
760
+ _context4.prev = 80;
761
+ _context4.t5 = _context4['catch'](75);
762
+
763
+ console.error(_context4.t5);
764
+
765
+ case 83:
766
+ i++;
767
+ _context4.next = 73;
768
+ break;
769
+
770
+ case 86:
771
+
772
+ console.log('Runtime: ' + processedProtections.length + ' protections in ' + Math.round((Date.now() - start) / 1000) + 's');
651
773
 
652
- return _context2.abrupt('return', protectionId);
774
+ return _context4.abrupt('return', protectionIds);
653
775
 
654
- case 98:
776
+ case 88:
655
777
  case 'end':
656
- return _context2.stop();
778
+ return _context4.stop();
657
779
  }
658
780
  }
659
- }, _callee2, this);
781
+ }, _callee4, this, [[75, 80]]);
660
782
  }));
661
783
 
662
784
  function protectAndDownload(_x4, _x5) {
@@ -673,14 +795,14 @@ exports.default = {
673
795
  * @returns {Promise<string>}
674
796
  */
675
797
  instrumentAndDownload: function () {
676
- var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(configPathOrObject, destCallback) {
798
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(configPathOrObject, destCallback) {
677
799
  var _this3 = this;
678
800
 
679
- 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;
801
+ var finalConfig, applicationId, host, port, basePath, protocol, cafile, keys, sources, _finalConfig$stream2, stream, cwd, jscramblerVersion, proxy, utc, skipSources, clientId, accessKey, secretKey, client, filesSrc, filesDest, _ref12, updateApplicationSourcePromise, instrumentation, onExitCancelInstrumentation, download;
680
802
 
681
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
803
+ return regeneratorRuntime.wrap(function _callee5$(_context5) {
682
804
  while (1) {
683
- switch (_context3.prev = _context3.next) {
805
+ switch (_context5.prev = _context5.next) {
684
806
  case 0:
685
807
  finalConfig = buildFinalConfig(configPathOrObject);
686
808
  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 === undefined ? true : _finalConfig$stream2, cwd = finalConfig.cwd, jscramblerVersion = finalConfig.jscramblerVersion, proxy = finalConfig.proxy, utc = finalConfig.utc, skipSources = finalConfig.skipSources, clientId = finalConfig.clientId;
@@ -710,7 +832,7 @@ exports.default = {
710
832
  }
711
833
 
712
834
  if (applicationId) {
713
- _context3.next = 9;
835
+ _context5.next = 9;
714
836
  break;
715
837
  }
716
838
 
@@ -718,7 +840,7 @@ exports.default = {
718
840
 
719
841
  case 9:
720
842
  if (!(!filesDest && !destCallback)) {
721
- _context3.next = 11;
843
+ _context5.next = 11;
722
844
  break;
723
845
  }
724
846
 
@@ -726,11 +848,11 @@ exports.default = {
726
848
 
727
849
  case 11:
728
850
  if (skipSources) {
729
- _context3.next = 16;
851
+ _context5.next = 20;
730
852
  break;
731
853
  }
732
854
 
733
- _context3.next = 14;
855
+ _context5.next = 14;
734
856
  return this.updateApplicationSources(client, applicationId, {
735
857
  sources: sources,
736
858
  filesSrc: filesSrc,
@@ -738,18 +860,24 @@ exports.default = {
738
860
  });
739
861
 
740
862
  case 14:
741
- _context3.next = 17;
863
+ _ref12 = _context5.sent;
864
+ updateApplicationSourcePromise = _ref12.promise;
865
+ _context5.next = 18;
866
+ return updateApplicationSourcePromise;
867
+
868
+ case 18:
869
+ _context5.next = 21;
742
870
  break;
743
871
 
744
- case 16:
872
+ case 20:
745
873
  console.log('Update source files SKIPPED');
746
874
 
747
- case 17:
748
- _context3.next = 19;
875
+ case 21:
876
+ _context5.next = 23;
749
877
  return this.startInstrumentation(client, applicationId);
750
878
 
751
- case 19:
752
- instrumentation = _context3.sent;
879
+ case 23:
880
+ instrumentation = _context5.sent;
753
881
 
754
882
  errorHandler(instrumentation);
755
883
 
@@ -765,11 +893,11 @@ exports.default = {
765
893
 
766
894
  process.once('SIGINT', onExitCancelInstrumentation).once('SIGTERM', onExitCancelInstrumentation);
767
895
 
768
- _context3.next = 25;
896
+ _context5.next = 29;
769
897
  return this.pollInstrumentation(client, instrumentation.data.id);
770
898
 
771
- case 25:
772
- instrumentation = _context3.sent;
899
+ case 29:
900
+ instrumentation = _context5.sent;
773
901
 
774
902
 
775
903
  process.removeListener('SIGINT', onExitCancelInstrumentation).removeListener('SIGTERM', onExitCancelInstrumentation);
@@ -778,11 +906,11 @@ exports.default = {
778
906
  console.log('Finished instrumention with id ' + instrumentation.data.id + '. Downloading...');
779
907
  }
780
908
 
781
- _context3.next = 30;
909
+ _context5.next = 34;
782
910
  return this.downloadApplicationInstrumented(client, instrumentation.data.id);
783
911
 
784
- case 30:
785
- download = _context3.sent;
912
+ case 34:
913
+ download = _context5.sent;
786
914
 
787
915
  errorHandler(download);
788
916
 
@@ -790,10 +918,10 @@ exports.default = {
790
918
  console.log('Unzipping files');
791
919
  }
792
920
 
793
- _context3.next = 35;
921
+ _context5.next = 39;
794
922
  return (0, _zip.unzip)(download, filesDest || destCallback, stream);
795
923
 
796
- case 35:
924
+ case 39:
797
925
 
798
926
  if (debug) {
799
927
  console.log('Finished unzipping files');
@@ -803,18 +931,18 @@ exports.default = {
803
931
 
804
932
  console.log('Application ' + applicationId + ' was instrumented. Bootstrap your instrumented application and run *--start-profiling* command.');
805
933
 
806
- return _context3.abrupt('return', instrumentation.data.id);
934
+ return _context5.abrupt('return', instrumentation.data.id);
807
935
 
808
- case 39:
936
+ case 43:
809
937
  case 'end':
810
- return _context3.stop();
938
+ return _context5.stop();
811
939
  }
812
940
  }
813
- }, _callee3, this);
941
+ }, _callee5, this);
814
942
  }));
815
943
 
816
- function instrumentAndDownload(_x6, _x7) {
817
- return _ref7.apply(this, arguments);
944
+ function instrumentAndDownload(_x8, _x9) {
945
+ return _ref11.apply(this, arguments);
818
946
  }
819
947
 
820
948
  return instrumentAndDownload;
@@ -830,11 +958,11 @@ exports.default = {
830
958
  * @returns {Promise<string>} The previous state
831
959
  */
832
960
  setProfilingState: function () {
833
- var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(configPathOrObject, state, label, nextStepMessage) {
961
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(configPathOrObject, state, label, nextStepMessage) {
834
962
  var finalConfig, keys, host, port, basePath, protocol, cafile, applicationId, proxy, utc, jscramblerVersion, clientId, accessKey, secretKey, client, instrumentation, previousState;
835
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
963
+ return regeneratorRuntime.wrap(function _callee6$(_context6) {
836
964
  while (1) {
837
- switch (_context4.prev = _context4.next) {
965
+ switch (_context6.prev = _context6.next) {
838
966
  case 0:
839
967
  finalConfig = buildFinalConfig(configPathOrObject);
840
968
  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;
@@ -852,16 +980,16 @@ exports.default = {
852
980
  jscramblerVersion: jscramblerVersion,
853
981
  clientId: clientId
854
982
  });
855
- _context4.next = 6;
983
+ _context6.next = 6;
856
984
  return client.get('/profiling-run', { applicationId: applicationId }).catch(function (e) {
857
985
  if (e.statusCode !== 404) throw e;
858
986
  });
859
987
 
860
988
  case 6:
861
- instrumentation = _context4.sent;
989
+ instrumentation = _context6.sent;
862
990
 
863
991
  if (instrumentation) {
864
- _context4.next = 9;
992
+ _context6.next = 9;
865
993
  break;
866
994
  }
867
995
 
@@ -871,15 +999,15 @@ exports.default = {
871
999
  previousState = instrumentation.data.state;
872
1000
 
873
1001
  if (!(previousState === state)) {
874
- _context4.next = 13;
1002
+ _context6.next = 13;
875
1003
  break;
876
1004
  }
877
1005
 
878
1006
  console.log('Profiling was already ' + label + ' for application ' + applicationId + '. ' + nextStepMessage);
879
- return _context4.abrupt('return');
1007
+ return _context6.abrupt('return');
880
1008
 
881
1009
  case 13:
882
- _context4.next = 15;
1010
+ _context6.next = 15;
883
1011
  return client.patch('/profiling-run/' + instrumentation.data.id, {
884
1012
  state: state
885
1013
  });
@@ -890,25 +1018,25 @@ exports.default = {
890
1018
 
891
1019
  case 16:
892
1020
  case 'end':
893
- return _context4.stop();
1021
+ return _context6.stop();
894
1022
  }
895
1023
  }
896
- }, _callee4, this);
1024
+ }, _callee6, this);
897
1025
  }));
898
1026
 
899
- function setProfilingState(_x8, _x9, _x10, _x11) {
900
- return _ref8.apply(this, arguments);
1027
+ function setProfilingState(_x10, _x11, _x12, _x13) {
1028
+ return _ref13.apply(this, arguments);
901
1029
  }
902
1030
 
903
1031
  return setProfilingState;
904
1032
  }(),
905
1033
  downloadSourceMaps: function () {
906
- var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(configs, destCallback) {
1034
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(configs, destCallback) {
907
1035
  var keys, host, port, basePath, protocol, cafile, _configs$stream, stream, filesDest, filesSrc, protectionId, jscramblerVersion, utc, proxy, accessKey, secretKey, client, download;
908
1036
 
909
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
1037
+ return regeneratorRuntime.wrap(function _callee7$(_context7) {
910
1038
  while (1) {
911
- switch (_context5.prev = _context5.next) {
1039
+ switch (_context7.prev = _context7.next) {
912
1040
  case 0:
913
1041
  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 === undefined ? true : _configs$stream, filesDest = configs.filesDest, filesSrc = configs.filesSrc, protectionId = configs.protectionId, jscramblerVersion = configs.jscramblerVersion, utc = configs.utc, proxy = configs.proxy;
914
1042
  accessKey = keys.accessKey, secretKey = keys.secretKey;
@@ -926,7 +1054,7 @@ exports.default = {
926
1054
  });
927
1055
 
928
1056
  if (!(!filesDest && !destCallback)) {
929
- _context5.next = 5;
1057
+ _context7.next = 5;
930
1058
  break;
931
1059
  }
932
1060
 
@@ -934,7 +1062,7 @@ exports.default = {
934
1062
 
935
1063
  case 5:
936
1064
  if (protectionId) {
937
- _context5.next = 7;
1065
+ _context7.next = 7;
938
1066
  break;
939
1067
  }
940
1068
 
@@ -946,46 +1074,46 @@ exports.default = {
946
1074
  console.warn('[Warning] Ignoring sources supplied. Downloading source maps of given protection');
947
1075
  }
948
1076
  download = void 0;
949
- _context5.prev = 9;
950
- _context5.next = 12;
1077
+ _context7.prev = 9;
1078
+ _context7.next = 12;
951
1079
  return this.downloadSourceMapsRequest(client, protectionId);
952
1080
 
953
1081
  case 12:
954
- download = _context5.sent;
955
- _context5.next = 18;
1082
+ download = _context7.sent;
1083
+ _context7.next = 18;
956
1084
  break;
957
1085
 
958
1086
  case 15:
959
- _context5.prev = 15;
960
- _context5.t0 = _context5['catch'](9);
1087
+ _context7.prev = 15;
1088
+ _context7.t0 = _context7['catch'](9);
961
1089
 
962
- errorHandler(_context5.t0);
1090
+ errorHandler(_context7.t0);
963
1091
 
964
1092
  case 18:
965
- _context5.next = 20;
1093
+ _context7.next = 20;
966
1094
  return (0, _zip.unzip)(download, filesDest || destCallback, stream);
967
1095
 
968
1096
  case 20:
969
1097
  case 'end':
970
- return _context5.stop();
1098
+ return _context7.stop();
971
1099
  }
972
1100
  }
973
- }, _callee5, this, [[9, 15]]);
1101
+ }, _callee7, this, [[9, 15]]);
974
1102
  }));
975
1103
 
976
- function downloadSourceMaps(_x12, _x13) {
977
- return _ref9.apply(this, arguments);
1104
+ function downloadSourceMaps(_x14, _x15) {
1105
+ return _ref14.apply(this, arguments);
978
1106
  }
979
1107
 
980
1108
  return downloadSourceMaps;
981
1109
  }(),
982
1110
  downloadSymbolTable: function () {
983
- var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(configs, destCallback) {
1111
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(configs, destCallback) {
984
1112
  var keys, host, port, basePath, protocol, cafile, _configs$stream2, stream, filesDest, filesSrc, protectionId, jscramblerVersion, utc, proxy, accessKey, secretKey, client, download;
985
1113
 
986
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
1114
+ return regeneratorRuntime.wrap(function _callee8$(_context8) {
987
1115
  while (1) {
988
- switch (_context6.prev = _context6.next) {
1116
+ switch (_context8.prev = _context8.next) {
989
1117
  case 0:
990
1118
  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 === undefined ? true : _configs$stream2, filesDest = configs.filesDest, filesSrc = configs.filesSrc, protectionId = configs.protectionId, jscramblerVersion = configs.jscramblerVersion, utc = configs.utc, proxy = configs.proxy;
991
1119
  accessKey = keys.accessKey, secretKey = keys.secretKey;
@@ -1003,7 +1131,7 @@ exports.default = {
1003
1131
  });
1004
1132
 
1005
1133
  if (!(!filesDest && !destCallback)) {
1006
- _context6.next = 5;
1134
+ _context8.next = 5;
1007
1135
  break;
1008
1136
  }
1009
1137
 
@@ -1011,7 +1139,7 @@ exports.default = {
1011
1139
 
1012
1140
  case 5:
1013
1141
  if (protectionId) {
1014
- _context6.next = 7;
1142
+ _context8.next = 7;
1015
1143
  break;
1016
1144
  }
1017
1145
 
@@ -1023,20 +1151,20 @@ exports.default = {
1023
1151
  console.warn('[Warning] Ignoring sources supplied. Downloading symbol table of given protection');
1024
1152
  }
1025
1153
  download = void 0;
1026
- _context6.prev = 9;
1027
- _context6.next = 12;
1154
+ _context8.prev = 9;
1155
+ _context8.next = 12;
1028
1156
  return this.downloadSymbolTableRequest(client, protectionId);
1029
1157
 
1030
1158
  case 12:
1031
- download = _context6.sent;
1032
- _context6.next = 18;
1159
+ download = _context8.sent;
1160
+ _context8.next = 18;
1033
1161
  break;
1034
1162
 
1035
1163
  case 15:
1036
- _context6.prev = 15;
1037
- _context6.t0 = _context6['catch'](9);
1164
+ _context8.prev = 15;
1165
+ _context8.t0 = _context8['catch'](9);
1038
1166
 
1039
- errorHandler(_context6.t0);
1167
+ errorHandler(_context8.t0);
1040
1168
 
1041
1169
  case 18:
1042
1170
 
@@ -1048,14 +1176,14 @@ exports.default = {
1048
1176
 
1049
1177
  case 19:
1050
1178
  case 'end':
1051
- return _context6.stop();
1179
+ return _context8.stop();
1052
1180
  }
1053
1181
  }
1054
- }, _callee6, this, [[9, 15]]);
1182
+ }, _callee8, this, [[9, 15]]);
1055
1183
  }));
1056
1184
 
1057
- function downloadSymbolTable(_x14, _x15) {
1058
- return _ref10.apply(this, arguments);
1185
+ function downloadSymbolTable(_x16, _x17) {
1186
+ return _ref15.apply(this, arguments);
1059
1187
  }
1060
1188
 
1061
1189
  return downloadSymbolTable;
@@ -1070,30 +1198,30 @@ exports.default = {
1070
1198
  * @throws {Error} due to errors in instrumentation process or user cancel the operation
1071
1199
  */
1072
1200
  pollInstrumentation: function () {
1073
- var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(client, instrumentationId) {
1201
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(client, instrumentationId) {
1074
1202
  var _this4 = this;
1075
1203
 
1076
1204
  var start, poll;
1077
- return regeneratorRuntime.wrap(function _callee8$(_context8) {
1205
+ return regeneratorRuntime.wrap(function _callee10$(_context10) {
1078
1206
  while (1) {
1079
- switch (_context8.prev = _context8.next) {
1207
+ switch (_context10.prev = _context10.next) {
1080
1208
  case 0:
1081
1209
  start = Date.now();
1082
1210
 
1083
1211
  poll = function () {
1084
- var _ref12 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
1212
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {
1085
1213
  var instrumentation;
1086
- return regeneratorRuntime.wrap(function _callee7$(_context7) {
1214
+ return regeneratorRuntime.wrap(function _callee9$(_context9) {
1087
1215
  while (1) {
1088
- switch (_context7.prev = _context7.next) {
1216
+ switch (_context9.prev = _context9.next) {
1089
1217
  case 0:
1090
- _context7.next = 2;
1218
+ _context9.next = 2;
1091
1219
  return _this4.getInstrumentation(client, instrumentationId);
1092
1220
 
1093
1221
  case 2:
1094
- instrumentation = _context7.sent;
1095
- _context7.t0 = instrumentation.data.state;
1096
- _context7.next = _context7.t0 === 'DELETED' ? 6 : _context7.t0 === 'FAILED_INSTRUMENTATION' ? 7 : _context7.t0 === 'FINISHED_INSTRUMENTATION' ? 9 : 10;
1222
+ instrumentation = _context9.sent;
1223
+ _context9.t0 = instrumentation.data.state;
1224
+ _context9.next = _context9.t0 === 'DELETED' ? 6 : _context9.t0 === 'FAILED_INSTRUMENTATION' ? 7 : _context9.t0 === 'FINISHED_INSTRUMENTATION' ? 9 : 10;
1097
1225
  break;
1098
1226
 
1099
1227
  case 6:
@@ -1105,84 +1233,84 @@ exports.default = {
1105
1233
  message: e.message + ' at ' + e.fileName + ':' + e.lineNumber
1106
1234
  };
1107
1235
  }));
1108
- return _context7.abrupt('return', errorHandler(instrumentation));
1236
+ return _context9.abrupt('return', errorHandler(instrumentation));
1109
1237
 
1110
1238
  case 9:
1111
- return _context7.abrupt('return', instrumentation);
1239
+ return _context9.abrupt('return', instrumentation);
1112
1240
 
1113
1241
  case 10:
1114
- _context7.next = 12;
1242
+ _context9.next = 12;
1115
1243
  return new Promise(function (resolve) {
1116
1244
  return setTimeout(resolve, getPollingInterval(start));
1117
1245
  });
1118
1246
 
1119
1247
  case 12:
1120
- return _context7.abrupt('return', poll());
1248
+ return _context9.abrupt('return', poll());
1121
1249
 
1122
1250
  case 13:
1123
1251
  case 'end':
1124
- return _context7.stop();
1252
+ return _context9.stop();
1125
1253
  }
1126
1254
  }
1127
- }, _callee7, _this4);
1255
+ }, _callee9, _this4);
1128
1256
  }));
1129
1257
 
1130
1258
  return function poll() {
1131
- return _ref12.apply(this, arguments);
1259
+ return _ref17.apply(this, arguments);
1132
1260
  };
1133
1261
  }();
1134
1262
 
1135
- return _context8.abrupt('return', poll());
1263
+ return _context10.abrupt('return', poll());
1136
1264
 
1137
1265
  case 3:
1138
1266
  case 'end':
1139
- return _context8.stop();
1267
+ return _context10.stop();
1140
1268
  }
1141
1269
  }
1142
- }, _callee8, this);
1270
+ }, _callee10, this);
1143
1271
  }));
1144
1272
 
1145
- function pollInstrumentation(_x16, _x17) {
1146
- return _ref11.apply(this, arguments);
1273
+ function pollInstrumentation(_x18, _x19) {
1274
+ return _ref16.apply(this, arguments);
1147
1275
  }
1148
1276
 
1149
1277
  return pollInstrumentation;
1150
1278
  }(),
1151
1279
  withRetries: function () {
1152
- var _ref13 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(action) {
1280
+ var _ref18 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(action) {
1153
1281
  var retriesLeft;
1154
- return regeneratorRuntime.wrap(function _callee9$(_context9) {
1282
+ return regeneratorRuntime.wrap(function _callee11$(_context11) {
1155
1283
  while (1) {
1156
- switch (_context9.prev = _context9.next) {
1284
+ switch (_context11.prev = _context11.next) {
1157
1285
  case 0:
1158
1286
  retriesLeft = _config3.default.maxRetries;
1159
1287
 
1160
1288
  case 1:
1161
- _context9.prev = 1;
1162
- _context9.next = 4;
1289
+ _context11.prev = 1;
1290
+ _context11.next = 4;
1163
1291
  return action();
1164
1292
 
1165
1293
  case 4:
1166
- return _context9.abrupt('return', _context9.sent);
1294
+ return _context11.abrupt('return', _context11.sent);
1167
1295
 
1168
1296
  case 7:
1169
- _context9.prev = 7;
1170
- _context9.t0 = _context9['catch'](1);
1297
+ _context11.prev = 7;
1298
+ _context11.t0 = _context11['catch'](1);
1171
1299
 
1172
1300
  if (!(retriesLeft <= 0)) {
1173
- _context9.next = 11;
1301
+ _context11.next = 11;
1174
1302
  break;
1175
1303
  }
1176
1304
 
1177
- throw _context9.t0;
1305
+ throw _context11.t0;
1178
1306
 
1179
1307
  case 11:
1180
- if (!(_context9.t0.statusCode !== _constants.HTTP_STATUS_CODES.SERVICE_UNAVAILABLE && _context9.t0.statusCode !== _constants.HTTP_STATUS_CODES.GATEWAY_TIMEOUT)) {
1181
- _context9.next = 13;
1308
+ if (!(_context11.t0.statusCode !== _constants.HTTP_STATUS_CODES.SERVICE_UNAVAILABLE && _context11.t0.statusCode !== _constants.HTTP_STATUS_CODES.GATEWAY_TIMEOUT)) {
1309
+ _context11.next = 13;
1182
1310
  break;
1183
1311
  }
1184
1312
 
1185
- throw _context9.t0;
1313
+ throw _context11.t0;
1186
1314
 
1187
1315
  case 13:
1188
1316
  // Retry
@@ -1192,51 +1320,51 @@ exports.default = {
1192
1320
  retriesLeft--;
1193
1321
 
1194
1322
  case 15:
1195
- _context9.next = 1;
1323
+ _context11.next = 1;
1196
1324
  break;
1197
1325
 
1198
1326
  case 17:
1199
1327
  case 'end':
1200
- return _context9.stop();
1328
+ return _context11.stop();
1201
1329
  }
1202
1330
  }
1203
- }, _callee9, this, [[1, 7]]);
1331
+ }, _callee11, this, [[1, 7]]);
1204
1332
  }));
1205
1333
 
1206
- function withRetries(_x18) {
1207
- return _ref13.apply(this, arguments);
1334
+ function withRetries(_x20) {
1335
+ return _ref18.apply(this, arguments);
1208
1336
  }
1209
1337
 
1210
1338
  return withRetries;
1211
1339
  }(),
1212
1340
  pollProtection: function () {
1213
- var _ref14 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(client, applicationId, protectionId, fragments) {
1341
+ var _ref19 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13(client, applicationId, protectionId, fragments) {
1214
1342
  var _this5 = this;
1215
1343
 
1216
1344
  var start, poll;
1217
- return regeneratorRuntime.wrap(function _callee11$(_context11) {
1345
+ return regeneratorRuntime.wrap(function _callee13$(_context13) {
1218
1346
  while (1) {
1219
- switch (_context11.prev = _context11.next) {
1347
+ switch (_context13.prev = _context13.next) {
1220
1348
  case 0:
1221
1349
  start = Date.now();
1222
1350
 
1223
1351
  poll = function () {
1224
- var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() {
1352
+ var _ref20 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {
1225
1353
  var applicationProtection, state;
1226
- return regeneratorRuntime.wrap(function _callee10$(_context10) {
1354
+ return regeneratorRuntime.wrap(function _callee12$(_context12) {
1227
1355
  while (1) {
1228
- switch (_context10.prev = _context10.next) {
1356
+ switch (_context12.prev = _context12.next) {
1229
1357
  case 0:
1230
- _context10.next = 2;
1358
+ _context12.next = 2;
1231
1359
  return _this5.withRetries(function () {
1232
1360
  return _this5.getApplicationProtection(client, applicationId, protectionId, fragments);
1233
1361
  });
1234
1362
 
1235
1363
  case 2:
1236
- applicationProtection = _context10.sent;
1364
+ applicationProtection = _context12.sent;
1237
1365
 
1238
1366
  if (!applicationProtection.errors) {
1239
- _context10.next = 8;
1367
+ _context12.next = 8;
1240
1368
  break;
1241
1369
  }
1242
1370
 
@@ -1248,102 +1376,217 @@ exports.default = {
1248
1376
  state = applicationProtection.data.applicationProtection.state;
1249
1377
 
1250
1378
  if (!(state !== 'finished' && state !== 'errored' && state !== 'canceled')) {
1251
- _context10.next = 15;
1379
+ _context12.next = 15;
1252
1380
  break;
1253
1381
  }
1254
1382
 
1255
- _context10.next = 12;
1383
+ _context12.next = 12;
1256
1384
  return new Promise(function (resolve) {
1257
1385
  return setTimeout(resolve, getPollingInterval(start));
1258
1386
  });
1259
1387
 
1260
1388
  case 12:
1261
- return _context10.abrupt('return', poll());
1389
+ return _context12.abrupt('return', poll());
1262
1390
 
1263
1391
  case 15:
1264
1392
  if (!(state === 'canceled')) {
1265
- _context10.next = 19;
1393
+ _context12.next = 19;
1266
1394
  break;
1267
1395
  }
1268
1396
 
1269
1397
  throw new Error('Protection canceled by user');
1270
1398
 
1271
1399
  case 19:
1272
- return _context10.abrupt('return', applicationProtection.data.applicationProtection);
1400
+ return _context12.abrupt('return', applicationProtection.data.applicationProtection);
1273
1401
 
1274
1402
  case 20:
1275
1403
  case 'end':
1276
- return _context10.stop();
1404
+ return _context12.stop();
1277
1405
  }
1278
1406
  }
1279
- }, _callee10, _this5);
1407
+ }, _callee12, _this5);
1280
1408
  }));
1281
1409
 
1282
1410
  return function poll() {
1283
- return _ref15.apply(this, arguments);
1411
+ return _ref20.apply(this, arguments);
1284
1412
  };
1285
1413
  }();
1286
1414
 
1287
- return _context11.abrupt('return', poll());
1415
+ return _context13.abrupt('return', poll());
1288
1416
 
1289
1417
  case 3:
1290
1418
  case 'end':
1291
- return _context11.stop();
1419
+ return _context13.stop();
1292
1420
  }
1293
1421
  }
1294
- }, _callee11, this);
1422
+ }, _callee13, this);
1295
1423
  }));
1296
1424
 
1297
- function pollProtection(_x19, _x20, _x21, _x22) {
1298
- return _ref14.apply(this, arguments);
1425
+ function pollProtection(_x21, _x22, _x23, _x24) {
1426
+ return _ref19.apply(this, arguments);
1299
1427
  }
1300
1428
 
1301
1429
  return pollProtection;
1302
1430
  }(),
1431
+ pollProtections: function () {
1432
+ var _ref21 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(client, applicationId, protectionIds, fragments) {
1433
+ var _this6 = this;
1303
1434
 
1304
- //
1305
- createApplication: function () {
1306
- var _ref16 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12(client, data, fragments) {
1307
- return regeneratorRuntime.wrap(function _callee12$(_context12) {
1435
+ var start, seen, poll;
1436
+ return regeneratorRuntime.wrap(function _callee15$(_context15) {
1308
1437
  while (1) {
1309
- switch (_context12.prev = _context12.next) {
1438
+ switch (_context15.prev = _context15.next) {
1310
1439
  case 0:
1311
- return _context12.abrupt('return', client.post('/application', mutations.createApplication(data, fragments)));
1440
+ if (!(protectionIds.length === 1)) {
1441
+ _context15.next = 5;
1442
+ break;
1443
+ }
1312
1444
 
1313
- case 1:
1445
+ _context15.next = 3;
1446
+ return this.pollProtection(client, applicationId, protectionIds[0], fragments);
1447
+
1448
+ case 3:
1449
+ _context15.t0 = _context15.sent;
1450
+ return _context15.abrupt('return', [_context15.t0]);
1451
+
1452
+ case 5:
1453
+ start = Date.now();
1454
+ seen = {};
1455
+
1456
+ poll = function () {
1457
+ var _ref22 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14() {
1458
+ var applicationProtections, ended;
1459
+ return regeneratorRuntime.wrap(function _callee14$(_context14) {
1460
+ while (1) {
1461
+ switch (_context14.prev = _context14.next) {
1462
+ case 0:
1463
+ _context14.next = 2;
1464
+ return _this6.withRetries(function () {
1465
+ return _this6.getApplicationProtections(client, applicationId, { protectionIds: protectionIds }, fragments.applicationProtection, ["$protectionIds: [String]"]);
1466
+ });
1467
+
1468
+ case 2:
1469
+ applicationProtections = _context14.sent;
1470
+
1471
+ if (!applicationProtections.errors) {
1472
+ _context14.next = 8;
1473
+ break;
1474
+ }
1475
+
1476
+ console.log('Error polling protection', applicationProtections.errors);
1477
+
1478
+ throw new Error('Protection failed. For more information visit: ' + APP_URL + '.');
1479
+
1480
+ case 8:
1481
+ ended = applicationProtections.data.applicationProtections.filter(function (_ref23) {
1482
+ var state = _ref23.state;
1483
+ return state === 'finished' || state === 'errored' || state === 'canceled';
1484
+ });
1485
+ // print progress
1486
+
1487
+ ended.filter(function (_ref24) {
1488
+ var _id = _ref24._id,
1489
+ state = _ref24.state;
1490
+ return !seen[_id] && state !== 'canceled';
1491
+ }).forEach(function (_ref25) {
1492
+ var _id = _ref25._id,
1493
+ startedAt = _ref25.startedAt,
1494
+ finishedAt = _ref25.finishedAt,
1495
+ state = _ref25.state;
1496
+
1497
+ seen[_id] = true;
1498
+ console.log('[' + Object.keys(seen).length + '/' + protectionIds.length + '] Protection=' + _id + ', state=' + state + ', build-time=' + Math.round((new Date(finishedAt) - new Date(startedAt)) / 1000) + 's');
1499
+ });
1500
+
1501
+ if (!(ended.length < protectionIds.length)) {
1502
+ _context14.next = 14;
1503
+ break;
1504
+ }
1505
+
1506
+ _context14.next = 13;
1507
+ return new Promise(function (resolve) {
1508
+ return setTimeout(resolve, getPollingInterval(start));
1509
+ });
1510
+
1511
+ case 13:
1512
+ return _context14.abrupt('return', poll());
1513
+
1514
+ case 14:
1515
+ return _context14.abrupt('return', applicationProtections.data.applicationProtections);
1516
+
1517
+ case 15:
1518
+ case 'end':
1519
+ return _context14.stop();
1520
+ }
1521
+ }
1522
+ }, _callee14, _this6);
1523
+ }));
1524
+
1525
+ return function poll() {
1526
+ return _ref22.apply(this, arguments);
1527
+ };
1528
+ }();
1529
+
1530
+ return _context15.abrupt('return', poll());
1531
+
1532
+ case 9:
1314
1533
  case 'end':
1315
- return _context12.stop();
1534
+ return _context15.stop();
1316
1535
  }
1317
1536
  }
1318
- }, _callee12, this);
1537
+ }, _callee15, this);
1319
1538
  }));
1320
1539
 
1321
- function createApplication(_x23, _x24, _x25) {
1322
- return _ref16.apply(this, arguments);
1540
+ function pollProtections(_x25, _x26, _x27, _x28) {
1541
+ return _ref21.apply(this, arguments);
1323
1542
  }
1324
1543
 
1325
- return createApplication;
1544
+ return pollProtections;
1326
1545
  }(),
1327
1546
 
1328
1547
  //
1329
- duplicateApplication: function () {
1330
- var _ref17 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13(client, data, fragments) {
1331
- return regeneratorRuntime.wrap(function _callee13$(_context13) {
1548
+ createApplication: function () {
1549
+ var _ref26 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(client, data, fragments) {
1550
+ return regeneratorRuntime.wrap(function _callee16$(_context16) {
1332
1551
  while (1) {
1333
- switch (_context13.prev = _context13.next) {
1552
+ switch (_context16.prev = _context16.next) {
1334
1553
  case 0:
1335
- return _context13.abrupt('return', client.post('/application', mutations.duplicateApplication(data, fragments)));
1554
+ return _context16.abrupt('return', client.post('/application', mutations.createApplication(data, fragments)));
1336
1555
 
1337
1556
  case 1:
1338
1557
  case 'end':
1339
- return _context13.stop();
1558
+ return _context16.stop();
1340
1559
  }
1341
1560
  }
1342
- }, _callee13, this);
1561
+ }, _callee16, this);
1343
1562
  }));
1344
1563
 
1345
- function duplicateApplication(_x26, _x27, _x28) {
1346
- return _ref17.apply(this, arguments);
1564
+ function createApplication(_x29, _x30, _x31) {
1565
+ return _ref26.apply(this, arguments);
1566
+ }
1567
+
1568
+ return createApplication;
1569
+ }(),
1570
+
1571
+ //
1572
+ duplicateApplication: function () {
1573
+ var _ref27 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17(client, data, fragments) {
1574
+ return regeneratorRuntime.wrap(function _callee17$(_context17) {
1575
+ while (1) {
1576
+ switch (_context17.prev = _context17.next) {
1577
+ case 0:
1578
+ return _context17.abrupt('return', client.post('/application', mutations.duplicateApplication(data, fragments)));
1579
+
1580
+ case 1:
1581
+ case 'end':
1582
+ return _context17.stop();
1583
+ }
1584
+ }
1585
+ }, _callee17, this);
1586
+ }));
1587
+
1588
+ function duplicateApplication(_x32, _x33, _x34) {
1589
+ return _ref27.apply(this, arguments);
1347
1590
  }
1348
1591
 
1349
1592
  return duplicateApplication;
@@ -1351,23 +1594,23 @@ exports.default = {
1351
1594
 
1352
1595
  //
1353
1596
  removeApplication: function () {
1354
- var _ref18 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(client, id) {
1355
- return regeneratorRuntime.wrap(function _callee14$(_context14) {
1597
+ var _ref28 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18(client, id) {
1598
+ return regeneratorRuntime.wrap(function _callee18$(_context18) {
1356
1599
  while (1) {
1357
- switch (_context14.prev = _context14.next) {
1600
+ switch (_context18.prev = _context18.next) {
1358
1601
  case 0:
1359
- return _context14.abrupt('return', client.post('/application', mutations.removeApplication(id)));
1602
+ return _context18.abrupt('return', client.post('/application', mutations.removeApplication(id)));
1360
1603
 
1361
1604
  case 1:
1362
1605
  case 'end':
1363
- return _context14.stop();
1606
+ return _context18.stop();
1364
1607
  }
1365
1608
  }
1366
- }, _callee14, this);
1609
+ }, _callee18, this);
1367
1610
  }));
1368
1611
 
1369
- function removeApplication(_x29, _x30) {
1370
- return _ref18.apply(this, arguments);
1612
+ function removeApplication(_x35, _x36) {
1613
+ return _ref28.apply(this, arguments);
1371
1614
  }
1372
1615
 
1373
1616
  return removeApplication;
@@ -1375,23 +1618,23 @@ exports.default = {
1375
1618
 
1376
1619
  //
1377
1620
  removeProtection: function () {
1378
- var _ref19 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(client, id, appId, fragments) {
1379
- return regeneratorRuntime.wrap(function _callee15$(_context15) {
1621
+ var _ref29 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19(client, id, appId, fragments) {
1622
+ return regeneratorRuntime.wrap(function _callee19$(_context19) {
1380
1623
  while (1) {
1381
- switch (_context15.prev = _context15.next) {
1624
+ switch (_context19.prev = _context19.next) {
1382
1625
  case 0:
1383
- return _context15.abrupt('return', client.post('/application', mutations.removeProtection(id, appId, fragments)));
1626
+ return _context19.abrupt('return', client.post('/application', mutations.removeProtection(id, appId, fragments)));
1384
1627
 
1385
1628
  case 1:
1386
1629
  case 'end':
1387
- return _context15.stop();
1630
+ return _context19.stop();
1388
1631
  }
1389
1632
  }
1390
- }, _callee15, this);
1633
+ }, _callee19, this);
1391
1634
  }));
1392
1635
 
1393
- function removeProtection(_x31, _x32, _x33, _x34) {
1394
- return _ref19.apply(this, arguments);
1636
+ function removeProtection(_x37, _x38, _x39, _x40) {
1637
+ return _ref29.apply(this, arguments);
1395
1638
  }
1396
1639
 
1397
1640
  return removeProtection;
@@ -1399,29 +1642,29 @@ exports.default = {
1399
1642
 
1400
1643
  //
1401
1644
  cancelProtection: function () {
1402
- var _ref20 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(client, id, appId, fragments) {
1645
+ var _ref30 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20(client, id, appId, fragments) {
1403
1646
  var mutation;
1404
- return regeneratorRuntime.wrap(function _callee16$(_context16) {
1647
+ return regeneratorRuntime.wrap(function _callee20$(_context20) {
1405
1648
  while (1) {
1406
- switch (_context16.prev = _context16.next) {
1649
+ switch (_context20.prev = _context20.next) {
1407
1650
  case 0:
1408
- _context16.next = 2;
1651
+ _context20.next = 2;
1409
1652
  return mutations.cancelProtection(id, appId, fragments);
1410
1653
 
1411
1654
  case 2:
1412
- mutation = _context16.sent;
1413
- return _context16.abrupt('return', client.post('/application', mutation));
1655
+ mutation = _context20.sent;
1656
+ return _context20.abrupt('return', client.post('/application', mutation));
1414
1657
 
1415
1658
  case 4:
1416
1659
  case 'end':
1417
- return _context16.stop();
1660
+ return _context20.stop();
1418
1661
  }
1419
1662
  }
1420
- }, _callee16, this);
1663
+ }, _callee20, this);
1421
1664
  }));
1422
1665
 
1423
- function cancelProtection(_x35, _x36, _x37, _x38) {
1424
- return _ref20.apply(this, arguments);
1666
+ function cancelProtection(_x41, _x42, _x43, _x44) {
1667
+ return _ref30.apply(this, arguments);
1425
1668
  }
1426
1669
 
1427
1670
  return cancelProtection;
@@ -1429,29 +1672,29 @@ exports.default = {
1429
1672
 
1430
1673
  //
1431
1674
  updateApplication: function () {
1432
- var _ref21 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17(client, application, fragments) {
1675
+ var _ref31 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21(client, application, fragments) {
1433
1676
  var mutation;
1434
- return regeneratorRuntime.wrap(function _callee17$(_context17) {
1677
+ return regeneratorRuntime.wrap(function _callee21$(_context21) {
1435
1678
  while (1) {
1436
- switch (_context17.prev = _context17.next) {
1679
+ switch (_context21.prev = _context21.next) {
1437
1680
  case 0:
1438
- _context17.next = 2;
1681
+ _context21.next = 2;
1439
1682
  return mutations.updateApplication(application, fragments);
1440
1683
 
1441
1684
  case 2:
1442
- mutation = _context17.sent;
1443
- return _context17.abrupt('return', client.post('/application', mutation));
1685
+ mutation = _context21.sent;
1686
+ return _context21.abrupt('return', client.post('/application', mutation));
1444
1687
 
1445
1688
  case 4:
1446
1689
  case 'end':
1447
- return _context17.stop();
1690
+ return _context21.stop();
1448
1691
  }
1449
1692
  }
1450
- }, _callee17, this);
1693
+ }, _callee21, this);
1451
1694
  }));
1452
1695
 
1453
- function updateApplication(_x39, _x40, _x41) {
1454
- return _ref21.apply(this, arguments);
1696
+ function updateApplication(_x45, _x46, _x47) {
1697
+ return _ref31.apply(this, arguments);
1455
1698
  }
1456
1699
 
1457
1700
  return updateApplication;
@@ -1459,29 +1702,29 @@ exports.default = {
1459
1702
 
1460
1703
  //
1461
1704
  unlockApplication: function () {
1462
- var _ref22 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18(client, application, fragments) {
1705
+ var _ref32 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22(client, application, fragments) {
1463
1706
  var mutation;
1464
- return regeneratorRuntime.wrap(function _callee18$(_context18) {
1707
+ return regeneratorRuntime.wrap(function _callee22$(_context22) {
1465
1708
  while (1) {
1466
- switch (_context18.prev = _context18.next) {
1709
+ switch (_context22.prev = _context22.next) {
1467
1710
  case 0:
1468
- _context18.next = 2;
1711
+ _context22.next = 2;
1469
1712
  return mutations.unlockApplication(application, fragments);
1470
1713
 
1471
1714
  case 2:
1472
- mutation = _context18.sent;
1473
- return _context18.abrupt('return', client.post('/application', mutation));
1715
+ mutation = _context22.sent;
1716
+ return _context22.abrupt('return', client.post('/application', mutation));
1474
1717
 
1475
1718
  case 4:
1476
1719
  case 'end':
1477
- return _context18.stop();
1720
+ return _context22.stop();
1478
1721
  }
1479
1722
  }
1480
- }, _callee18, this);
1723
+ }, _callee22, this);
1481
1724
  }));
1482
1725
 
1483
- function unlockApplication(_x42, _x43, _x44) {
1484
- return _ref22.apply(this, arguments);
1726
+ function unlockApplication(_x48, _x49, _x50) {
1727
+ return _ref32.apply(this, arguments);
1485
1728
  }
1486
1729
 
1487
1730
  return unlockApplication;
@@ -1489,29 +1732,29 @@ exports.default = {
1489
1732
 
1490
1733
  //
1491
1734
  getApplication: function () {
1492
- var _ref23 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19(client, applicationId, fragments, params) {
1735
+ var _ref33 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23(client, applicationId, fragments, params) {
1493
1736
  var query;
1494
- return regeneratorRuntime.wrap(function _callee19$(_context19) {
1737
+ return regeneratorRuntime.wrap(function _callee23$(_context23) {
1495
1738
  while (1) {
1496
- switch (_context19.prev = _context19.next) {
1739
+ switch (_context23.prev = _context23.next) {
1497
1740
  case 0:
1498
- _context19.next = 2;
1741
+ _context23.next = 2;
1499
1742
  return queries.getApplication(applicationId, fragments, params);
1500
1743
 
1501
1744
  case 2:
1502
- query = _context19.sent;
1503
- return _context19.abrupt('return', client.get('/application', query));
1745
+ query = _context23.sent;
1746
+ return _context23.abrupt('return', client.get('/application', query));
1504
1747
 
1505
1748
  case 4:
1506
1749
  case 'end':
1507
- return _context19.stop();
1750
+ return _context23.stop();
1508
1751
  }
1509
1752
  }
1510
- }, _callee19, this);
1753
+ }, _callee23, this);
1511
1754
  }));
1512
1755
 
1513
- function getApplication(_x45, _x46, _x47, _x48) {
1514
- return _ref23.apply(this, arguments);
1756
+ function getApplication(_x51, _x52, _x53, _x54) {
1757
+ return _ref33.apply(this, arguments);
1515
1758
  }
1516
1759
 
1517
1760
  return getApplication;
@@ -1519,29 +1762,29 @@ exports.default = {
1519
1762
 
1520
1763
  //
1521
1764
  getApplicationSource: function () {
1522
- var _ref24 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20(client, sourceId, fragments, limits) {
1765
+ var _ref34 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24(client, sourceId, fragments, limits) {
1523
1766
  var query;
1524
- return regeneratorRuntime.wrap(function _callee20$(_context20) {
1767
+ return regeneratorRuntime.wrap(function _callee24$(_context24) {
1525
1768
  while (1) {
1526
- switch (_context20.prev = _context20.next) {
1769
+ switch (_context24.prev = _context24.next) {
1527
1770
  case 0:
1528
- _context20.next = 2;
1771
+ _context24.next = 2;
1529
1772
  return queries.getApplicationSource(sourceId, fragments, limits);
1530
1773
 
1531
1774
  case 2:
1532
- query = _context20.sent;
1533
- return _context20.abrupt('return', client.get('/application', query));
1775
+ query = _context24.sent;
1776
+ return _context24.abrupt('return', client.get('/application', query));
1534
1777
 
1535
1778
  case 4:
1536
1779
  case 'end':
1537
- return _context20.stop();
1780
+ return _context24.stop();
1538
1781
  }
1539
1782
  }
1540
- }, _callee20, this);
1783
+ }, _callee24, this);
1541
1784
  }));
1542
1785
 
1543
- function getApplicationSource(_x49, _x50, _x51, _x52) {
1544
- return _ref24.apply(this, arguments);
1786
+ function getApplicationSource(_x55, _x56, _x57, _x58) {
1787
+ return _ref34.apply(this, arguments);
1545
1788
  }
1546
1789
 
1547
1790
  return getApplicationSource;
@@ -1549,29 +1792,25 @@ exports.default = {
1549
1792
 
1550
1793
  //
1551
1794
  getApplicationProtections: function () {
1552
- var _ref25 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21(client, applicationId, params, fragments) {
1795
+ var _ref35 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee25(client, applicationId, params, fragments, queryArgs) {
1553
1796
  var query;
1554
- return regeneratorRuntime.wrap(function _callee21$(_context21) {
1797
+ return regeneratorRuntime.wrap(function _callee25$(_context25) {
1555
1798
  while (1) {
1556
- switch (_context21.prev = _context21.next) {
1799
+ switch (_context25.prev = _context25.next) {
1557
1800
  case 0:
1558
- _context21.next = 2;
1559
- return queries.getApplicationProtections(applicationId, params, fragments);
1801
+ query = queries.getApplicationProtections(applicationId, params, fragments, queryArgs);
1802
+ return _context25.abrupt('return', client.get('/application', query));
1560
1803
 
1561
1804
  case 2:
1562
- query = _context21.sent;
1563
- return _context21.abrupt('return', client.get('/application', query));
1564
-
1565
- case 4:
1566
1805
  case 'end':
1567
- return _context21.stop();
1806
+ return _context25.stop();
1568
1807
  }
1569
1808
  }
1570
- }, _callee21, this);
1809
+ }, _callee25, this);
1571
1810
  }));
1572
1811
 
1573
- function getApplicationProtections(_x53, _x54, _x55, _x56) {
1574
- return _ref25.apply(this, arguments);
1812
+ function getApplicationProtections(_x59, _x60, _x61, _x62, _x63) {
1813
+ return _ref35.apply(this, arguments);
1575
1814
  }
1576
1815
 
1577
1816
  return getApplicationProtections;
@@ -1579,29 +1818,29 @@ exports.default = {
1579
1818
 
1580
1819
  //
1581
1820
  getApplicationProtectionsCount: function () {
1582
- var _ref26 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22(client, applicationId, fragments) {
1821
+ var _ref36 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee26(client, applicationId, fragments) {
1583
1822
  var query;
1584
- return regeneratorRuntime.wrap(function _callee22$(_context22) {
1823
+ return regeneratorRuntime.wrap(function _callee26$(_context26) {
1585
1824
  while (1) {
1586
- switch (_context22.prev = _context22.next) {
1825
+ switch (_context26.prev = _context26.next) {
1587
1826
  case 0:
1588
- _context22.next = 2;
1827
+ _context26.next = 2;
1589
1828
  return queries.getApplicationProtectionsCount(applicationId, fragments);
1590
1829
 
1591
1830
  case 2:
1592
- query = _context22.sent;
1593
- return _context22.abrupt('return', client.get('/application', query));
1831
+ query = _context26.sent;
1832
+ return _context26.abrupt('return', client.get('/application', query));
1594
1833
 
1595
1834
  case 4:
1596
1835
  case 'end':
1597
- return _context22.stop();
1836
+ return _context26.stop();
1598
1837
  }
1599
1838
  }
1600
- }, _callee22, this);
1839
+ }, _callee26, this);
1601
1840
  }));
1602
1841
 
1603
- function getApplicationProtectionsCount(_x57, _x58, _x59) {
1604
- return _ref26.apply(this, arguments);
1842
+ function getApplicationProtectionsCount(_x64, _x65, _x66) {
1843
+ return _ref36.apply(this, arguments);
1605
1844
  }
1606
1845
 
1607
1846
  return getApplicationProtectionsCount;
@@ -1609,29 +1848,29 @@ exports.default = {
1609
1848
 
1610
1849
  //
1611
1850
  createTemplate: function () {
1612
- var _ref27 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23(client, template, fragments) {
1851
+ var _ref37 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee27(client, template, fragments) {
1613
1852
  var mutation;
1614
- return regeneratorRuntime.wrap(function _callee23$(_context23) {
1853
+ return regeneratorRuntime.wrap(function _callee27$(_context27) {
1615
1854
  while (1) {
1616
- switch (_context23.prev = _context23.next) {
1855
+ switch (_context27.prev = _context27.next) {
1617
1856
  case 0:
1618
- _context23.next = 2;
1857
+ _context27.next = 2;
1619
1858
  return mutations.createTemplate(template, fragments);
1620
1859
 
1621
1860
  case 2:
1622
- mutation = _context23.sent;
1623
- return _context23.abrupt('return', client.post('/application', mutation));
1861
+ mutation = _context27.sent;
1862
+ return _context27.abrupt('return', client.post('/application', mutation));
1624
1863
 
1625
1864
  case 4:
1626
1865
  case 'end':
1627
- return _context23.stop();
1866
+ return _context27.stop();
1628
1867
  }
1629
1868
  }
1630
- }, _callee23, this);
1869
+ }, _callee27, this);
1631
1870
  }));
1632
1871
 
1633
- function createTemplate(_x60, _x61, _x62) {
1634
- return _ref27.apply(this, arguments);
1872
+ function createTemplate(_x67, _x68, _x69) {
1873
+ return _ref37.apply(this, arguments);
1635
1874
  }
1636
1875
 
1637
1876
  return createTemplate;
@@ -1639,29 +1878,29 @@ exports.default = {
1639
1878
 
1640
1879
  //
1641
1880
  removeTemplate: function () {
1642
- var _ref28 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24(client, id) {
1881
+ var _ref38 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee28(client, id) {
1643
1882
  var mutation;
1644
- return regeneratorRuntime.wrap(function _callee24$(_context24) {
1883
+ return regeneratorRuntime.wrap(function _callee28$(_context28) {
1645
1884
  while (1) {
1646
- switch (_context24.prev = _context24.next) {
1885
+ switch (_context28.prev = _context28.next) {
1647
1886
  case 0:
1648
- _context24.next = 2;
1887
+ _context28.next = 2;
1649
1888
  return mutations.removeTemplate(id);
1650
1889
 
1651
1890
  case 2:
1652
- mutation = _context24.sent;
1653
- return _context24.abrupt('return', client.post('/application', mutation));
1891
+ mutation = _context28.sent;
1892
+ return _context28.abrupt('return', client.post('/application', mutation));
1654
1893
 
1655
1894
  case 4:
1656
1895
  case 'end':
1657
- return _context24.stop();
1896
+ return _context28.stop();
1658
1897
  }
1659
1898
  }
1660
- }, _callee24, this);
1899
+ }, _callee28, this);
1661
1900
  }));
1662
1901
 
1663
- function removeTemplate(_x63, _x64) {
1664
- return _ref28.apply(this, arguments);
1902
+ function removeTemplate(_x70, _x71) {
1903
+ return _ref38.apply(this, arguments);
1665
1904
  }
1666
1905
 
1667
1906
  return removeTemplate;
@@ -1669,29 +1908,29 @@ exports.default = {
1669
1908
 
1670
1909
  //
1671
1910
  getTemplates: function () {
1672
- var _ref29 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee25(client, fragments) {
1911
+ var _ref39 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee29(client, fragments) {
1673
1912
  var query;
1674
- return regeneratorRuntime.wrap(function _callee25$(_context25) {
1913
+ return regeneratorRuntime.wrap(function _callee29$(_context29) {
1675
1914
  while (1) {
1676
- switch (_context25.prev = _context25.next) {
1915
+ switch (_context29.prev = _context29.next) {
1677
1916
  case 0:
1678
- _context25.next = 2;
1917
+ _context29.next = 2;
1679
1918
  return queries.getTemplates(fragments);
1680
1919
 
1681
1920
  case 2:
1682
- query = _context25.sent;
1683
- return _context25.abrupt('return', client.get('/application', query));
1921
+ query = _context29.sent;
1922
+ return _context29.abrupt('return', client.get('/application', query));
1684
1923
 
1685
1924
  case 4:
1686
1925
  case 'end':
1687
- return _context25.stop();
1926
+ return _context29.stop();
1688
1927
  }
1689
1928
  }
1690
- }, _callee25, this);
1929
+ }, _callee29, this);
1691
1930
  }));
1692
1931
 
1693
- function getTemplates(_x65, _x66) {
1694
- return _ref29.apply(this, arguments);
1932
+ function getTemplates(_x72, _x73) {
1933
+ return _ref39.apply(this, arguments);
1695
1934
  }
1696
1935
 
1697
1936
  return getTemplates;
@@ -1699,29 +1938,29 @@ exports.default = {
1699
1938
 
1700
1939
  //
1701
1940
  getApplications: function () {
1702
- var _ref30 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee26(client, fragments, params) {
1941
+ var _ref40 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee30(client, fragments, params) {
1703
1942
  var query;
1704
- return regeneratorRuntime.wrap(function _callee26$(_context26) {
1943
+ return regeneratorRuntime.wrap(function _callee30$(_context30) {
1705
1944
  while (1) {
1706
- switch (_context26.prev = _context26.next) {
1945
+ switch (_context30.prev = _context30.next) {
1707
1946
  case 0:
1708
- _context26.next = 2;
1947
+ _context30.next = 2;
1709
1948
  return queries.getApplications(fragments, params);
1710
1949
 
1711
1950
  case 2:
1712
- query = _context26.sent;
1713
- return _context26.abrupt('return', client.get('/application', query));
1951
+ query = _context30.sent;
1952
+ return _context30.abrupt('return', client.get('/application', query));
1714
1953
 
1715
1954
  case 4:
1716
1955
  case 'end':
1717
- return _context26.stop();
1956
+ return _context30.stop();
1718
1957
  }
1719
1958
  }
1720
- }, _callee26, this);
1959
+ }, _callee30, this);
1721
1960
  }));
1722
1961
 
1723
- function getApplications(_x67, _x68, _x69) {
1724
- return _ref30.apply(this, arguments);
1962
+ function getApplications(_x74, _x75, _x76) {
1963
+ return _ref40.apply(this, arguments);
1725
1964
  }
1726
1965
 
1727
1966
  return getApplications;
@@ -1729,31 +1968,31 @@ exports.default = {
1729
1968
 
1730
1969
  //
1731
1970
  addApplicationSource: function () {
1732
- var _ref31 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee27(client, applicationId, applicationSource, fragments) {
1971
+ var _ref41 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee31(client, applicationId, applicationSource, fragments) {
1733
1972
  var mutation;
1734
- return regeneratorRuntime.wrap(function _callee27$(_context27) {
1973
+ return regeneratorRuntime.wrap(function _callee31$(_context31) {
1735
1974
  while (1) {
1736
- switch (_context27.prev = _context27.next) {
1975
+ switch (_context31.prev = _context31.next) {
1737
1976
  case 0:
1738
- _context27.next = 2;
1977
+ _context31.next = 2;
1739
1978
  return mutations.addApplicationSource(applicationId, applicationSource, fragments);
1740
1979
 
1741
1980
  case 2:
1742
- mutation = _context27.sent;
1743
- return _context27.abrupt('return', this.withRetries(function () {
1981
+ mutation = _context31.sent;
1982
+ return _context31.abrupt('return', this.withRetries(function () {
1744
1983
  return client.post('/application', mutation);
1745
1984
  }));
1746
1985
 
1747
1986
  case 4:
1748
1987
  case 'end':
1749
- return _context27.stop();
1988
+ return _context31.stop();
1750
1989
  }
1751
1990
  }
1752
- }, _callee27, this);
1991
+ }, _callee31, this);
1753
1992
  }));
1754
1993
 
1755
- function addApplicationSource(_x70, _x71, _x72, _x73) {
1756
- return _ref31.apply(this, arguments);
1994
+ function addApplicationSource(_x77, _x78, _x79, _x80) {
1995
+ return _ref41.apply(this, arguments);
1757
1996
  }
1758
1997
 
1759
1998
  return addApplicationSource;
@@ -1761,34 +2000,34 @@ exports.default = {
1761
2000
 
1762
2001
  //
1763
2002
  addApplicationSourceFromURL: function () {
1764
- var _ref32 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee28(client, applicationId, url, fragments) {
2003
+ var _ref42 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee32(client, applicationId, url, fragments) {
1765
2004
  var file, mutation;
1766
- return regeneratorRuntime.wrap(function _callee28$(_context28) {
2005
+ return regeneratorRuntime.wrap(function _callee32$(_context32) {
1767
2006
  while (1) {
1768
- switch (_context28.prev = _context28.next) {
2007
+ switch (_context32.prev = _context32.next) {
1769
2008
  case 0:
1770
- _context28.next = 2;
2009
+ _context32.next = 2;
1771
2010
  return getFileFromUrl(client, url);
1772
2011
 
1773
2012
  case 2:
1774
- file = _context28.sent;
1775
- _context28.next = 5;
2013
+ file = _context32.sent;
2014
+ _context32.next = 5;
1776
2015
  return mutations.addApplicationSource(applicationId, file, fragments);
1777
2016
 
1778
2017
  case 5:
1779
- mutation = _context28.sent;
1780
- return _context28.abrupt('return', client.post('/application', mutation));
2018
+ mutation = _context32.sent;
2019
+ return _context32.abrupt('return', client.post('/application', mutation));
1781
2020
 
1782
2021
  case 7:
1783
2022
  case 'end':
1784
- return _context28.stop();
2023
+ return _context32.stop();
1785
2024
  }
1786
2025
  }
1787
- }, _callee28, this);
2026
+ }, _callee32, this);
1788
2027
  }));
1789
2028
 
1790
- function addApplicationSourceFromURL(_x74, _x75, _x76, _x77) {
1791
- return _ref32.apply(this, arguments);
2029
+ function addApplicationSourceFromURL(_x81, _x82, _x83, _x84) {
2030
+ return _ref42.apply(this, arguments);
1792
2031
  }
1793
2032
 
1794
2033
  return addApplicationSourceFromURL;
@@ -1796,29 +2035,29 @@ exports.default = {
1796
2035
 
1797
2036
  //
1798
2037
  updateApplicationSource: function () {
1799
- var _ref33 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee29(client, applicationSource, fragments) {
2038
+ var _ref43 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee33(client, applicationSource, fragments) {
1800
2039
  var mutation;
1801
- return regeneratorRuntime.wrap(function _callee29$(_context29) {
2040
+ return regeneratorRuntime.wrap(function _callee33$(_context33) {
1802
2041
  while (1) {
1803
- switch (_context29.prev = _context29.next) {
2042
+ switch (_context33.prev = _context33.next) {
1804
2043
  case 0:
1805
- _context29.next = 2;
2044
+ _context33.next = 2;
1806
2045
  return mutations.updateApplicationSource(applicationSource, fragments);
1807
2046
 
1808
2047
  case 2:
1809
- mutation = _context29.sent;
1810
- return _context29.abrupt('return', client.post('/application', mutation));
2048
+ mutation = _context33.sent;
2049
+ return _context33.abrupt('return', client.post('/application', mutation));
1811
2050
 
1812
2051
  case 4:
1813
2052
  case 'end':
1814
- return _context29.stop();
2053
+ return _context33.stop();
1815
2054
  }
1816
2055
  }
1817
- }, _callee29, this);
2056
+ }, _callee33, this);
1818
2057
  }));
1819
2058
 
1820
- function updateApplicationSource(_x78, _x79, _x80) {
1821
- return _ref33.apply(this, arguments);
2059
+ function updateApplicationSource(_x85, _x86, _x87) {
2060
+ return _ref43.apply(this, arguments);
1822
2061
  }
1823
2062
 
1824
2063
  return updateApplicationSource;
@@ -1826,31 +2065,31 @@ exports.default = {
1826
2065
 
1827
2066
  //
1828
2067
  removeSourceFromApplication: function () {
1829
- var _ref34 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee30(client, sourceId, applicationId, fragments) {
2068
+ var _ref44 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee34(client, sourceId, applicationId, fragments) {
1830
2069
  var mutation;
1831
- return regeneratorRuntime.wrap(function _callee30$(_context30) {
2070
+ return regeneratorRuntime.wrap(function _callee34$(_context34) {
1832
2071
  while (1) {
1833
- switch (_context30.prev = _context30.next) {
2072
+ switch (_context34.prev = _context34.next) {
1834
2073
  case 0:
1835
- _context30.next = 2;
2074
+ _context34.next = 2;
1836
2075
  return mutations.removeSourceFromApplication(sourceId, applicationId, fragments);
1837
2076
 
1838
2077
  case 2:
1839
- mutation = _context30.sent;
1840
- return _context30.abrupt('return', this.withRetries(function () {
2078
+ mutation = _context34.sent;
2079
+ return _context34.abrupt('return', this.withRetries(function () {
1841
2080
  return client.post('/application', mutation);
1842
2081
  }));
1843
2082
 
1844
2083
  case 4:
1845
2084
  case 'end':
1846
- return _context30.stop();
2085
+ return _context34.stop();
1847
2086
  }
1848
2087
  }
1849
- }, _callee30, this);
2088
+ }, _callee34, this);
1850
2089
  }));
1851
2090
 
1852
- function removeSourceFromApplication(_x81, _x82, _x83, _x84) {
1853
- return _ref34.apply(this, arguments);
2091
+ function removeSourceFromApplication(_x88, _x89, _x90, _x91) {
2092
+ return _ref44.apply(this, arguments);
1854
2093
  }
1855
2094
 
1856
2095
  return removeSourceFromApplication;
@@ -1858,29 +2097,29 @@ exports.default = {
1858
2097
 
1859
2098
  //
1860
2099
  applyTemplate: function () {
1861
- var _ref35 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee31(client, templateId, appId, fragments) {
2100
+ var _ref45 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee35(client, templateId, appId, fragments) {
1862
2101
  var mutation;
1863
- return regeneratorRuntime.wrap(function _callee31$(_context31) {
2102
+ return regeneratorRuntime.wrap(function _callee35$(_context35) {
1864
2103
  while (1) {
1865
- switch (_context31.prev = _context31.next) {
2104
+ switch (_context35.prev = _context35.next) {
1866
2105
  case 0:
1867
- _context31.next = 2;
2106
+ _context35.next = 2;
1868
2107
  return mutations.applyTemplate(templateId, appId, fragments);
1869
2108
 
1870
2109
  case 2:
1871
- mutation = _context31.sent;
1872
- return _context31.abrupt('return', client.post('/application', mutation));
2110
+ mutation = _context35.sent;
2111
+ return _context35.abrupt('return', client.post('/application', mutation));
1873
2112
 
1874
2113
  case 4:
1875
2114
  case 'end':
1876
- return _context31.stop();
2115
+ return _context35.stop();
1877
2116
  }
1878
2117
  }
1879
- }, _callee31, this);
2118
+ }, _callee35, this);
1880
2119
  }));
1881
2120
 
1882
- function applyTemplate(_x85, _x86, _x87, _x88) {
1883
- return _ref35.apply(this, arguments);
2121
+ function applyTemplate(_x92, _x93, _x94, _x95) {
2122
+ return _ref45.apply(this, arguments);
1884
2123
  }
1885
2124
 
1886
2125
  return applyTemplate;
@@ -1888,75 +2127,75 @@ exports.default = {
1888
2127
 
1889
2128
  //
1890
2129
  updateTemplate: function () {
1891
- var _ref36 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee32(client, template, fragments) {
2130
+ var _ref46 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee36(client, template, fragments) {
1892
2131
  var mutation;
1893
- return regeneratorRuntime.wrap(function _callee32$(_context32) {
2132
+ return regeneratorRuntime.wrap(function _callee36$(_context36) {
1894
2133
  while (1) {
1895
- switch (_context32.prev = _context32.next) {
2134
+ switch (_context36.prev = _context36.next) {
1896
2135
  case 0:
1897
- _context32.next = 2;
2136
+ _context36.next = 2;
1898
2137
  return mutations.updateTemplate(template, fragments);
1899
2138
 
1900
2139
  case 2:
1901
- mutation = _context32.sent;
1902
- return _context32.abrupt('return', client.post('/application', mutation));
2140
+ mutation = _context36.sent;
2141
+ return _context36.abrupt('return', client.post('/application', mutation));
1903
2142
 
1904
2143
  case 4:
1905
2144
  case 'end':
1906
- return _context32.stop();
2145
+ return _context36.stop();
1907
2146
  }
1908
2147
  }
1909
- }, _callee32, this);
2148
+ }, _callee36, this);
1910
2149
  }));
1911
2150
 
1912
- function updateTemplate(_x89, _x90, _x91) {
1913
- return _ref36.apply(this, arguments);
2151
+ function updateTemplate(_x96, _x97, _x98) {
2152
+ return _ref46.apply(this, arguments);
1914
2153
  }
1915
2154
 
1916
2155
  return updateTemplate;
1917
2156
  }(),
1918
2157
  getApplicationProfiling: function () {
1919
- var _ref37 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee33(client, applicationId) {
1920
- return regeneratorRuntime.wrap(function _callee33$(_context33) {
2158
+ var _ref47 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee37(client, applicationId) {
2159
+ return regeneratorRuntime.wrap(function _callee37$(_context37) {
1921
2160
  while (1) {
1922
- switch (_context33.prev = _context33.next) {
2161
+ switch (_context37.prev = _context37.next) {
1923
2162
  case 0:
1924
- return _context33.abrupt('return', client.get('/profiling-run', { applicationId: applicationId }));
2163
+ return _context37.abrupt('return', client.get('/profiling-run', { applicationId: applicationId }));
1925
2164
 
1926
2165
  case 1:
1927
2166
  case 'end':
1928
- return _context33.stop();
2167
+ return _context37.stop();
1929
2168
  }
1930
2169
  }
1931
- }, _callee33, this);
2170
+ }, _callee37, this);
1932
2171
  }));
1933
2172
 
1934
- function getApplicationProfiling(_x92, _x93) {
1935
- return _ref37.apply(this, arguments);
2173
+ function getApplicationProfiling(_x99, _x100) {
2174
+ return _ref47.apply(this, arguments);
1936
2175
  }
1937
2176
 
1938
2177
  return getApplicationProfiling;
1939
2178
  }(),
1940
2179
  deleteProfiling: function () {
1941
- var _ref38 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee34(client, profilingId) {
1942
- return regeneratorRuntime.wrap(function _callee34$(_context34) {
2180
+ var _ref48 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee38(client, profilingId) {
2181
+ return regeneratorRuntime.wrap(function _callee38$(_context38) {
1943
2182
  while (1) {
1944
- switch (_context34.prev = _context34.next) {
2183
+ switch (_context38.prev = _context38.next) {
1945
2184
  case 0:
1946
- return _context34.abrupt('return', client.patch('/profiling-run/' + profilingId, {
2185
+ return _context38.abrupt('return', client.patch('/profiling-run/' + profilingId, {
1947
2186
  state: 'DELETED'
1948
2187
  }));
1949
2188
 
1950
2189
  case 1:
1951
2190
  case 'end':
1952
- return _context34.stop();
2191
+ return _context38.stop();
1953
2192
  }
1954
2193
  }
1955
- }, _callee34, this);
2194
+ }, _callee38, this);
1956
2195
  }));
1957
2196
 
1958
- function deleteProfiling(_x94, _x95) {
1959
- return _ref38.apply(this, arguments);
2197
+ function deleteProfiling(_x101, _x102) {
2198
+ return _ref48.apply(this, arguments);
1960
2199
  }
1961
2200
 
1962
2201
  return deleteProfiling;
@@ -1970,41 +2209,41 @@ exports.default = {
1970
2209
  * @returns {Promise<*>}
1971
2210
  */
1972
2211
  startInstrumentation: function () {
1973
- var _ref39 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee35(client, applicationId) {
2212
+ var _ref49 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee39(client, applicationId) {
1974
2213
  var instrumentation;
1975
- return regeneratorRuntime.wrap(function _callee35$(_context35) {
2214
+ return regeneratorRuntime.wrap(function _callee39$(_context39) {
1976
2215
  while (1) {
1977
- switch (_context35.prev = _context35.next) {
2216
+ switch (_context39.prev = _context39.next) {
1978
2217
  case 0:
1979
- _context35.next = 2;
2218
+ _context39.next = 2;
1980
2219
  return this.getApplicationProfiling(client, applicationId).catch(function (e) {
1981
2220
  if (e.statusCode !== 404) throw e;
1982
2221
  });
1983
2222
 
1984
2223
  case 2:
1985
- instrumentation = _context35.sent;
2224
+ instrumentation = _context39.sent;
1986
2225
 
1987
2226
  if (!instrumentation) {
1988
- _context35.next = 6;
2227
+ _context39.next = 6;
1989
2228
  break;
1990
2229
  }
1991
2230
 
1992
- _context35.next = 6;
2231
+ _context39.next = 6;
1993
2232
  return this.deleteProfiling(client, instrumentation.data.id);
1994
2233
 
1995
2234
  case 6:
1996
- return _context35.abrupt('return', client.post('/profiling-run', { applicationId: applicationId }));
2235
+ return _context39.abrupt('return', client.post('/profiling-run', { applicationId: applicationId }));
1997
2236
 
1998
2237
  case 7:
1999
2238
  case 'end':
2000
- return _context35.stop();
2239
+ return _context39.stop();
2001
2240
  }
2002
2241
  }
2003
- }, _callee35, this);
2242
+ }, _callee39, this);
2004
2243
  }));
2005
2244
 
2006
- function startInstrumentation(_x96, _x97) {
2007
- return _ref39.apply(this, arguments);
2245
+ function startInstrumentation(_x103, _x104) {
2246
+ return _ref49.apply(this, arguments);
2008
2247
  }
2009
2248
 
2010
2249
  return startInstrumentation;
@@ -2012,64 +2251,147 @@ exports.default = {
2012
2251
 
2013
2252
  //
2014
2253
  createApplicationProtection: function () {
2015
- var _ref40 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee36(client, applicationId, protectionOptions, fragments) {
2016
- var _ref41, args, mutation;
2254
+ var _ref50 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee40(client, applicationId, protectionOptions, fragments) {
2255
+ var _ref51, args, mutation;
2017
2256
 
2018
- return regeneratorRuntime.wrap(function _callee36$(_context36) {
2257
+ return regeneratorRuntime.wrap(function _callee40$(_context40) {
2019
2258
  while (1) {
2020
- switch (_context36.prev = _context36.next) {
2259
+ switch (_context40.prev = _context40.next) {
2021
2260
  case 0:
2022
- _context36.next = 2;
2261
+ _context40.next = 2;
2023
2262
  return introspection.mutation(client, 'createApplicationProtection');
2024
2263
 
2025
2264
  case 2:
2026
- _ref41 = _context36.sent;
2027
- args = _ref41.args;
2028
- _context36.next = 6;
2265
+ _ref51 = _context40.sent;
2266
+ args = _ref51.args;
2267
+ _context40.next = 6;
2029
2268
  return mutations.createApplicationProtection(applicationId, fragments, protectionOptions, args);
2030
2269
 
2031
2270
  case 6:
2032
- mutation = _context36.sent;
2033
- return _context36.abrupt('return', client.post('/application', mutation));
2271
+ mutation = _context40.sent;
2272
+ return _context40.abrupt('return', client.post('/application', mutation));
2034
2273
 
2035
2274
  case 8:
2036
2275
  case 'end':
2037
- return _context36.stop();
2276
+ return _context40.stop();
2038
2277
  }
2039
2278
  }
2040
- }, _callee36, this);
2279
+ }, _callee40, this);
2041
2280
  }));
2042
2281
 
2043
- function createApplicationProtection(_x98, _x99, _x100, _x101) {
2044
- return _ref40.apply(this, arguments);
2282
+ function createApplicationProtection(_x105, _x106, _x107, _x108) {
2283
+ return _ref50.apply(this, arguments);
2045
2284
  }
2046
2285
 
2047
2286
  return createApplicationProtection;
2048
2287
  }(),
2049
2288
 
2289
+ /**
2290
+ * Create one or more application protections at once
2291
+ * @param {JscramblerClient} client
2292
+ * @param {string} applicationId
2293
+ * @param {object} protectionOptions
2294
+ * @param {number} [protectionOptions.numberOfProtections]
2295
+ * @param {object} fragments
2296
+ * @returns {Promise<{data: {protections: Array.<{_id}>}, errors: Array}>}
2297
+ */
2298
+ createApplicationProtections: function () {
2299
+ var _ref52 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee41(client, applicationId, protectionOptions, fragments) {
2300
+ var result, mutationType, mutation;
2301
+ return regeneratorRuntime.wrap(function _callee41$(_context41) {
2302
+ while (1) {
2303
+ switch (_context41.prev = _context41.next) {
2304
+ case 0:
2305
+ result = void 0;
2306
+
2307
+ if (!(!protectionOptions.numberOfProtections || protectionOptions.numberOfProtections < 2)) {
2308
+ _context41.next = 8;
2309
+ break;
2310
+ }
2311
+
2312
+ _context41.next = 4;
2313
+ return this.createApplicationProtection(client, applicationId, protectionOptions, fragments);
2314
+
2315
+ case 4:
2316
+ result = _context41.sent;
2317
+
2318
+ if (result.data && result.data.createApplicationProtection) {
2319
+ result.data.protections = [result.data.createApplicationProtection];
2320
+ delete result.data.createApplicationProtection;
2321
+ }
2322
+ _context41.next = 19;
2323
+ break;
2324
+
2325
+ case 8:
2326
+ _context41.next = 10;
2327
+ return introspection.mutation(client, 'createApplicationProtections');
2328
+
2329
+ case 10:
2330
+ mutationType = _context41.sent;
2331
+
2332
+
2333
+ if (!mutationType) {
2334
+ console.error('"Create multiple protections at once" it\'s only available on Jscrambler version 7.2 and above.');
2335
+ process.exit(1);
2336
+ }
2337
+
2338
+ _context41.next = 14;
2339
+ return mutations.createApplicationProtections(applicationId, fragments, protectionOptions, mutationType.args);
2340
+
2341
+ case 14:
2342
+ mutation = _context41.sent;
2343
+ _context41.next = 17;
2344
+ return client.post('/application', mutation);
2345
+
2346
+ case 17:
2347
+ result = _context41.sent;
2348
+
2349
+ if (result.data && result.data.createApplicationProtections) {
2350
+ result.data.protections = result.data.createApplicationProtections.protections;
2351
+ delete result.data.createApplicationProtections;
2352
+ }
2353
+
2354
+ case 19:
2355
+ return _context41.abrupt('return', result);
2356
+
2357
+ case 20:
2358
+ case 'end':
2359
+ return _context41.stop();
2360
+ }
2361
+ }
2362
+ }, _callee41, this);
2363
+ }));
2364
+
2365
+ function createApplicationProtections(_x109, _x110, _x111, _x112) {
2366
+ return _ref52.apply(this, arguments);
2367
+ }
2368
+
2369
+ return createApplicationProtections;
2370
+ }(),
2371
+
2050
2372
  /**
2051
2373
  * @param {object} client
2052
2374
  * @param {string} instrumentationId
2053
2375
  * @returns {Promise<object>}
2054
2376
  */
2055
2377
  getInstrumentation: function () {
2056
- var _ref42 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee37(client, instrumentationId) {
2057
- return regeneratorRuntime.wrap(function _callee37$(_context37) {
2378
+ var _ref53 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee42(client, instrumentationId) {
2379
+ return regeneratorRuntime.wrap(function _callee42$(_context42) {
2058
2380
  while (1) {
2059
- switch (_context37.prev = _context37.next) {
2381
+ switch (_context42.prev = _context42.next) {
2060
2382
  case 0:
2061
- return _context37.abrupt('return', client.get('/profiling-run/' + instrumentationId));
2383
+ return _context42.abrupt('return', client.get('/profiling-run/' + instrumentationId));
2062
2384
 
2063
2385
  case 1:
2064
2386
  case 'end':
2065
- return _context37.stop();
2387
+ return _context42.stop();
2066
2388
  }
2067
2389
  }
2068
- }, _callee37, this);
2390
+ }, _callee42, this);
2069
2391
  }));
2070
2392
 
2071
- function getInstrumentation(_x102, _x103) {
2072
- return _ref42.apply(this, arguments);
2393
+ function getInstrumentation(_x113, _x114) {
2394
+ return _ref53.apply(this, arguments);
2073
2395
  }
2074
2396
 
2075
2397
  return getInstrumentation;
@@ -2077,29 +2399,29 @@ exports.default = {
2077
2399
 
2078
2400
  //
2079
2401
  getApplicationProtection: function () {
2080
- var _ref43 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee38(client, applicationId, protectionId, fragments) {
2402
+ var _ref54 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee43(client, applicationId, protectionId, fragments) {
2081
2403
  var query;
2082
- return regeneratorRuntime.wrap(function _callee38$(_context38) {
2404
+ return regeneratorRuntime.wrap(function _callee43$(_context43) {
2083
2405
  while (1) {
2084
- switch (_context38.prev = _context38.next) {
2406
+ switch (_context43.prev = _context43.next) {
2085
2407
  case 0:
2086
- _context38.next = 2;
2408
+ _context43.next = 2;
2087
2409
  return queries.getProtection(applicationId, protectionId, fragments);
2088
2410
 
2089
2411
  case 2:
2090
- query = _context38.sent;
2091
- return _context38.abrupt('return', client.get('/application', query));
2412
+ query = _context43.sent;
2413
+ return _context43.abrupt('return', client.get('/application', query));
2092
2414
 
2093
2415
  case 4:
2094
2416
  case 'end':
2095
- return _context38.stop();
2417
+ return _context43.stop();
2096
2418
  }
2097
2419
  }
2098
- }, _callee38, this);
2420
+ }, _callee43, this);
2099
2421
  }));
2100
2422
 
2101
- function getApplicationProtection(_x104, _x105, _x106, _x107) {
2102
- return _ref43.apply(this, arguments);
2423
+ function getApplicationProtection(_x115, _x116, _x117, _x118) {
2424
+ return _ref54.apply(this, arguments);
2103
2425
  }
2104
2426
 
2105
2427
  return getApplicationProtection;
@@ -2107,45 +2429,45 @@ exports.default = {
2107
2429
 
2108
2430
  //
2109
2431
  downloadSourceMapsRequest: function () {
2110
- var _ref44 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee39(client, protectionId) {
2111
- return regeneratorRuntime.wrap(function _callee39$(_context39) {
2432
+ var _ref55 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee44(client, protectionId) {
2433
+ return regeneratorRuntime.wrap(function _callee44$(_context44) {
2112
2434
  while (1) {
2113
- switch (_context39.prev = _context39.next) {
2435
+ switch (_context44.prev = _context44.next) {
2114
2436
  case 0:
2115
- return _context39.abrupt('return', client.get('/application/sourceMaps/' + protectionId, null, false));
2437
+ return _context44.abrupt('return', client.get('/application/sourceMaps/' + protectionId, null, false));
2116
2438
 
2117
2439
  case 1:
2118
2440
  case 'end':
2119
- return _context39.stop();
2441
+ return _context44.stop();
2120
2442
  }
2121
2443
  }
2122
- }, _callee39, this);
2444
+ }, _callee44, this);
2123
2445
  }));
2124
2446
 
2125
- function downloadSourceMapsRequest(_x108, _x109) {
2126
- return _ref44.apply(this, arguments);
2447
+ function downloadSourceMapsRequest(_x119, _x120) {
2448
+ return _ref55.apply(this, arguments);
2127
2449
  }
2128
2450
 
2129
2451
  return downloadSourceMapsRequest;
2130
2452
  }(),
2131
2453
  downloadSymbolTableRequest: function () {
2132
- var _ref45 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee40(client, protectionId) {
2133
- return regeneratorRuntime.wrap(function _callee40$(_context40) {
2454
+ var _ref56 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee45(client, protectionId) {
2455
+ return regeneratorRuntime.wrap(function _callee45$(_context45) {
2134
2456
  while (1) {
2135
- switch (_context40.prev = _context40.next) {
2457
+ switch (_context45.prev = _context45.next) {
2136
2458
  case 0:
2137
- return _context40.abrupt('return', client.get('/application/symbolTable/' + protectionId, null, false));
2459
+ return _context45.abrupt('return', client.get('/application/symbolTable/' + protectionId, null, false));
2138
2460
 
2139
2461
  case 1:
2140
2462
  case 'end':
2141
- return _context40.stop();
2463
+ return _context45.stop();
2142
2464
  }
2143
2465
  }
2144
- }, _callee40, this);
2466
+ }, _callee45, this);
2145
2467
  }));
2146
2468
 
2147
- function downloadSymbolTableRequest(_x110, _x111) {
2148
- return _ref45.apply(this, arguments);
2469
+ function downloadSymbolTableRequest(_x121, _x122) {
2470
+ return _ref56.apply(this, arguments);
2149
2471
  }
2150
2472
 
2151
2473
  return downloadSymbolTableRequest;
@@ -2153,23 +2475,23 @@ exports.default = {
2153
2475
 
2154
2476
  //
2155
2477
  downloadApplicationProtection: function () {
2156
- var _ref46 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee41(client, protectionId) {
2157
- return regeneratorRuntime.wrap(function _callee41$(_context41) {
2478
+ var _ref57 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee46(client, protectionId) {
2479
+ return regeneratorRuntime.wrap(function _callee46$(_context46) {
2158
2480
  while (1) {
2159
- switch (_context41.prev = _context41.next) {
2481
+ switch (_context46.prev = _context46.next) {
2160
2482
  case 0:
2161
- return _context41.abrupt('return', client.get('/application/download/' + protectionId, null, false));
2483
+ return _context46.abrupt('return', client.get('/application/download/' + protectionId, null, false));
2162
2484
 
2163
2485
  case 1:
2164
2486
  case 'end':
2165
- return _context41.stop();
2487
+ return _context46.stop();
2166
2488
  }
2167
2489
  }
2168
- }, _callee41, this);
2490
+ }, _callee46, this);
2169
2491
  }));
2170
2492
 
2171
- function downloadApplicationProtection(_x112, _x113) {
2172
- return _ref46.apply(this, arguments);
2493
+ function downloadApplicationProtection(_x123, _x124) {
2494
+ return _ref57.apply(this, arguments);
2173
2495
  }
2174
2496
 
2175
2497
  return downloadApplicationProtection;
@@ -2193,27 +2515,27 @@ exports.default = {
2193
2515
  * @returns {Boolean} true if the field is supported, false otherwise
2194
2516
  */
2195
2517
  introspectFieldOnMethod: function () {
2196
- var _ref47 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee42(config, queryOrMutation, methodName, field) {
2518
+ var _ref58 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee47(config, queryOrMutation, methodName, field) {
2197
2519
  var instrospectionType, client, result, dataArg, isFieldSupported;
2198
- return regeneratorRuntime.wrap(function _callee42$(_context42) {
2520
+ return regeneratorRuntime.wrap(function _callee47$(_context47) {
2199
2521
  while (1) {
2200
- switch (_context42.prev = _context42.next) {
2522
+ switch (_context47.prev = _context47.next) {
2201
2523
  case 0:
2202
2524
  instrospectionType = queryOrMutation.toLowerCase() === 'mutation' ? introspection.mutation : introspection.query;
2203
2525
  client = new this.Client(Object.assign({}, config));
2204
- _context42.next = 4;
2526
+ _context47.next = 4;
2205
2527
  return instrospectionType(client, methodName);
2206
2528
 
2207
2529
  case 4:
2208
- result = _context42.sent;
2530
+ result = _context47.sent;
2209
2531
 
2210
2532
  if (!(!result || !result.args)) {
2211
- _context42.next = 8;
2533
+ _context47.next = 8;
2212
2534
  break;
2213
2535
  }
2214
2536
 
2215
2537
  debug && console.log('Method *' + methodName + '* not found.');
2216
- return _context42.abrupt('return', false);
2538
+ return _context47.abrupt('return', false);
2217
2539
 
2218
2540
  case 8:
2219
2541
  dataArg = result.args.find(function (arg) {
@@ -2222,18 +2544,18 @@ exports.default = {
2222
2544
  isFieldSupported = dataArg && dataArg.type.inputFields.some(function (e) {
2223
2545
  return e.name === field;
2224
2546
  });
2225
- return _context42.abrupt('return', isFieldSupported);
2547
+ return _context47.abrupt('return', isFieldSupported);
2226
2548
 
2227
2549
  case 11:
2228
2550
  case 'end':
2229
- return _context42.stop();
2551
+ return _context47.stop();
2230
2552
  }
2231
2553
  }
2232
- }, _callee42, this);
2554
+ }, _callee47, this);
2233
2555
  }));
2234
2556
 
2235
- function introspectFieldOnMethod(_x114, _x115, _x116, _x117) {
2236
- return _ref47.apply(this, arguments);
2557
+ function introspectFieldOnMethod(_x125, _x126, _x127, _x128) {
2558
+ return _ref58.apply(this, arguments);
2237
2559
  }
2238
2560
 
2239
2561
  return introspectFieldOnMethod;