jscrambler 8.9.1 → 8.9.3
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/CHANGELOG.md +12 -0
- package/dist/index.js +62 -38
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# jscrambler
|
|
2
2
|
|
|
3
|
+
## 8.9.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [3f1a05c]: When doing multiple protections at the same time using the option -n, start downloading whenever protections finish, instead of waiting for all to finish
|
|
8
|
+
|
|
9
|
+
## 8.9.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [b10a097]: When downloading the symbol table it should create the directory if it does not exists
|
|
14
|
+
|
|
3
15
|
## 8.9.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -241,7 +241,6 @@ var _default = exports.default = {
|
|
|
241
241
|
// Jscrambler or if you're provided access to beta features of our product.
|
|
242
242
|
//
|
|
243
243
|
async protectAndDownload(configPathOrObject, destCallback) {
|
|
244
|
-
var _this = this;
|
|
245
244
|
const start = Date.now();
|
|
246
245
|
const finalConfig = buildFinalConfig(configPathOrObject);
|
|
247
246
|
const {
|
|
@@ -308,6 +307,9 @@ var _default = exports.default = {
|
|
|
308
307
|
let filesSrc = finalConfig.filesSrc;
|
|
309
308
|
let filesDest = finalConfig.filesDest;
|
|
310
309
|
let runBeforeProtection = finalConfig.beforeProtection;
|
|
310
|
+
if (finalConfig.numberOfProtections && finalConfig.numberOfProtections > 1) {
|
|
311
|
+
console.log("Protections will be stored in ".concat(filesDest).concat(filesDest.slice(-1) === '/' ? '' : '/', "[protection-id]"));
|
|
312
|
+
}
|
|
311
313
|
if (sources) {
|
|
312
314
|
filesSrc = undefined;
|
|
313
315
|
}
|
|
@@ -438,13 +440,16 @@ var _default = exports.default = {
|
|
|
438
440
|
process.exit(1);
|
|
439
441
|
};
|
|
440
442
|
process.once('SIGINT', onExitCancelProtection).once('SIGTERM', onExitCancelProtection);
|
|
441
|
-
const
|
|
443
|
+
const downloadOptions = {
|
|
444
|
+
filesDest,
|
|
445
|
+
destCallback,
|
|
446
|
+
stream,
|
|
447
|
+
multiple: protectionOptions.numberOfProtections && protectionOptions.numberOfProtections > 1,
|
|
448
|
+
deleteProtectionOnSuccess
|
|
449
|
+
};
|
|
450
|
+
const processedProtections = await this.pollProtections(client, applicationId, protectionIds, await (0, _getProtectionDefaultFragments.default)(client), downloadOptions);
|
|
442
451
|
process.removeListener('SIGINT', onExitCancelProtection).removeListener('SIGTERM', onExitCancelProtection);
|
|
443
|
-
const handleProtection = async
|
|
444
|
-
let {
|
|
445
|
-
outPrefix = '',
|
|
446
|
-
printProtectionId = true
|
|
447
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
452
|
+
const handleProtection = async protection => {
|
|
448
453
|
if (protection.growthWarning) {
|
|
449
454
|
console.warn("Warning: Your protected application has surpassed a reasonable file growth.\nFor more information on what might have caused this, please see the Protection Report.\nLink: ".concat(APP_URL, "."));
|
|
450
455
|
}
|
|
@@ -452,7 +457,7 @@ var _default = exports.default = {
|
|
|
452
457
|
console.warn("Warning: Since your plan is a Trial, your protected files will stop working on ".concat(protection.parameters.find(p => p.name === 'dateLock' && p.options.endDate).options.endDate));
|
|
453
458
|
}
|
|
454
459
|
if (debug) {
|
|
455
|
-
console.log(
|
|
460
|
+
console.log("Finished protecting".concat(downloadOptions.multiple ? ": ".concat(protection._id) : ''));
|
|
456
461
|
}
|
|
457
462
|
if (protection.deprecations) {
|
|
458
463
|
protection.deprecations.forEach(deprecation => {
|
|
@@ -487,43 +492,18 @@ var _default = exports.default = {
|
|
|
487
492
|
sourcesErrors.forEach(e => console.warn("Non-fatal error: \"".concat(e.message, "\" in ").concat(e.filename)));
|
|
488
493
|
}
|
|
489
494
|
}
|
|
490
|
-
if (
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
const download = await _this.downloadApplicationProtection(client, protection._id);
|
|
494
|
-
errorHandler(download);
|
|
495
|
-
if (debug) {
|
|
496
|
-
console.log('Unzipping files');
|
|
497
|
-
}
|
|
498
|
-
await (0, _zip.unzip)(download, (filesDest ? "".concat(filesDest).concat(outPrefix) : filesDest) || destCallback, stream);
|
|
499
|
-
if (debug) {
|
|
500
|
-
console.log('Finished unzipping files');
|
|
501
|
-
}
|
|
502
|
-
if (printProtectionId) {
|
|
503
|
-
console.log(protection._id);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
// change this to have the variable that checks if the protection is to be removed
|
|
507
|
-
if (deleteProtectionOnSuccess) {
|
|
508
|
-
await _this.removeProtection(client, protection._id, applicationId).then(() => {
|
|
509
|
-
if (debug) {
|
|
510
|
-
console.log('Protection has been successful and will now be deleted');
|
|
511
|
-
}
|
|
512
|
-
}).catch(error => console.error(error));
|
|
495
|
+
if (!protectionOptions.numberOfProtections || protectionOptions.numberOfProtections === 1) {
|
|
496
|
+
this.handleApplicationProtectionDownload(client, protection._id, downloadOptions);
|
|
513
497
|
}
|
|
514
498
|
return protection._id;
|
|
515
499
|
};
|
|
516
500
|
if (processedProtections.length === 1) {
|
|
517
501
|
return handleProtection(processedProtections[0]);
|
|
518
502
|
}
|
|
519
|
-
console.log("Protections stored in ".concat(filesDest, "/[protection-id]"));
|
|
520
503
|
for (let i = 0; i < processedProtections.length; i++) {
|
|
521
504
|
const protection = processedProtections[i];
|
|
522
505
|
try {
|
|
523
|
-
await handleProtection(protection
|
|
524
|
-
outPrefix: "/".concat(protection._id, "/"),
|
|
525
|
-
printProtectionId: false
|
|
526
|
-
});
|
|
506
|
+
await handleProtection(protection);
|
|
527
507
|
} catch (e) {
|
|
528
508
|
console.error(e);
|
|
529
509
|
}
|
|
@@ -531,6 +511,45 @@ var _default = exports.default = {
|
|
|
531
511
|
console.log("Runtime: ".concat(processedProtections.length, " protections in ").concat(Math.round((Date.now() - start) / 1000), "s"));
|
|
532
512
|
return protectionIds;
|
|
533
513
|
},
|
|
514
|
+
/**
|
|
515
|
+
* Handle the download, unzipping, and possible deletion of protections
|
|
516
|
+
* @param {object} client
|
|
517
|
+
* @param {string} instrumentationId
|
|
518
|
+
* @returns {Promise<object>}
|
|
519
|
+
*/
|
|
520
|
+
async handleApplicationProtectionDownload(client, protectionId, downloadOptions) {
|
|
521
|
+
const {
|
|
522
|
+
filesDest,
|
|
523
|
+
destCallback,
|
|
524
|
+
stream,
|
|
525
|
+
multiple,
|
|
526
|
+
deleteProtectionOnSuccess
|
|
527
|
+
} = downloadOptions;
|
|
528
|
+
if (debug) {
|
|
529
|
+
console.log("Downloading protection ".concat(multiple ? "".concat(protectionId, " ") : '', "result"));
|
|
530
|
+
}
|
|
531
|
+
const download = await this.downloadApplicationProtection(client, protectionId);
|
|
532
|
+
errorHandler(download);
|
|
533
|
+
if (debug) {
|
|
534
|
+
console.log("Unzipping files".concat(multiple ? " from protection ".concat(protectionId) : ''));
|
|
535
|
+
}
|
|
536
|
+
await (0, _zip.unzip)(download, (filesDest ? "".concat(filesDest).concat(multiple ? "/".concat(protectionId, "/") : '') : filesDest) || destCallback, stream);
|
|
537
|
+
if (debug) {
|
|
538
|
+
console.log("Finished unzipping files for protection".concat(multiple ? " ".concat(protectionId) : ''));
|
|
539
|
+
}
|
|
540
|
+
if (!multiple) {
|
|
541
|
+
console.log(protectionId);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// change this to have the variable that checks if the protection is to be removed
|
|
545
|
+
if (deleteProtectionOnSuccess) {
|
|
546
|
+
await this.removeProtection(client, protectionId, applicationId).then(() => {
|
|
547
|
+
if (debug) {
|
|
548
|
+
console.log('Protection has been successful and will now be deleted');
|
|
549
|
+
}
|
|
550
|
+
}).catch(error => console.error(error));
|
|
551
|
+
}
|
|
552
|
+
},
|
|
534
553
|
/**
|
|
535
554
|
* Instrument and download application sources for profiling purposes
|
|
536
555
|
* @param {object} configPathOrObject
|
|
@@ -779,6 +798,9 @@ var _default = exports.default = {
|
|
|
779
798
|
if (typeof destCallback === 'function') {
|
|
780
799
|
destCallback(download, filesDest);
|
|
781
800
|
} else {
|
|
801
|
+
await _fs.default.promises.mkdir(filesDest, {
|
|
802
|
+
recursive: true
|
|
803
|
+
});
|
|
782
804
|
await _fs.default.promises.writeFile(_path.default.join(filesDest, "".concat(protectionId, "_symbolTable.json")), download);
|
|
783
805
|
}
|
|
784
806
|
},
|
|
@@ -854,7 +876,7 @@ var _default = exports.default = {
|
|
|
854
876
|
};
|
|
855
877
|
return poll();
|
|
856
878
|
},
|
|
857
|
-
async pollProtections(client, applicationId, protectionIds, fragments) {
|
|
879
|
+
async pollProtections(client, applicationId, protectionIds, fragments, downloadOptions) {
|
|
858
880
|
if (protectionIds.length === 1) {
|
|
859
881
|
return [await this.pollProtection(client, applicationId, protectionIds[0], fragments)];
|
|
860
882
|
}
|
|
@@ -881,7 +903,7 @@ var _default = exports.default = {
|
|
|
881
903
|
state
|
|
882
904
|
} = _ref4;
|
|
883
905
|
return !seen[_id] && state !== 'canceled';
|
|
884
|
-
}).forEach(_ref5 => {
|
|
906
|
+
}).forEach(async _ref5 => {
|
|
885
907
|
let {
|
|
886
908
|
_id,
|
|
887
909
|
startedAt,
|
|
@@ -890,6 +912,8 @@ var _default = exports.default = {
|
|
|
890
912
|
} = _ref5;
|
|
891
913
|
seen[_id] = true;
|
|
892
914
|
console.log("[".concat(Object.keys(seen).length, "/").concat(protectionIds.length, "] Protection=").concat(_id, ", state=").concat(state, ", build-time=").concat(Math.round((new Date(finishedAt) - new Date(startedAt)) / 1000), "s"));
|
|
915
|
+
await this.handleApplicationProtectionDownload(client, _id, downloadOptions);
|
|
916
|
+
console.log("Downloaded: ".concat(_id));
|
|
893
917
|
});
|
|
894
918
|
if (ended.length < protectionIds.length) {
|
|
895
919
|
await new Promise(resolve => setTimeout(resolve, getPollingInterval(start)));
|
package/package.json
CHANGED