jscrambler 8.9.2 → 8.9.4
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 +61 -38
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# jscrambler
|
|
2
2
|
|
|
3
|
+
## 8.9.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [5deff47]: Fixed jscrambler cli single protection
|
|
8
|
+
|
|
9
|
+
## 8.9.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [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
|
|
14
|
+
|
|
3
15
|
## 8.9.2
|
|
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
|
+
await this.handleApplicationProtectionDownload(client, protection._id, applicationId, 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,47 @@ 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} protectionId
|
|
518
|
+
* @param {string} applicationId
|
|
519
|
+
* @param {object} downloadOptions
|
|
520
|
+
* @returns {Promise<object>}
|
|
521
|
+
*/
|
|
522
|
+
async handleApplicationProtectionDownload(client, protectionId, applicationId, downloadOptions) {
|
|
523
|
+
const {
|
|
524
|
+
filesDest,
|
|
525
|
+
destCallback,
|
|
526
|
+
stream,
|
|
527
|
+
multiple,
|
|
528
|
+
deleteProtectionOnSuccess
|
|
529
|
+
} = downloadOptions;
|
|
530
|
+
if (debug) {
|
|
531
|
+
console.log("Downloading protection ".concat(multiple ? "".concat(protectionId, " ") : '', "result"));
|
|
532
|
+
}
|
|
533
|
+
const download = await this.downloadApplicationProtection(client, protectionId);
|
|
534
|
+
errorHandler(download);
|
|
535
|
+
if (debug) {
|
|
536
|
+
console.log("Unzipping files".concat(multiple ? " from protection ".concat(protectionId) : ''));
|
|
537
|
+
}
|
|
538
|
+
await (0, _zip.unzip)(download, (filesDest ? "".concat(filesDest).concat(multiple ? "/".concat(protectionId, "/") : '') : filesDest) || destCallback, stream);
|
|
539
|
+
if (debug) {
|
|
540
|
+
console.log("Finished unzipping files for protection".concat(multiple ? " ".concat(protectionId) : ''));
|
|
541
|
+
}
|
|
542
|
+
if (!multiple) {
|
|
543
|
+
console.log(protectionId);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// change this to have the variable that checks if the protection is to be removed
|
|
547
|
+
if (deleteProtectionOnSuccess) {
|
|
548
|
+
await this.removeProtection(client, protectionId, applicationId).then(() => {
|
|
549
|
+
if (debug) {
|
|
550
|
+
console.log('Protection has been successful and will now be deleted');
|
|
551
|
+
}
|
|
552
|
+
}).catch(error => console.error(error));
|
|
553
|
+
}
|
|
554
|
+
},
|
|
534
555
|
/**
|
|
535
556
|
* Instrument and download application sources for profiling purposes
|
|
536
557
|
* @param {object} configPathOrObject
|
|
@@ -857,7 +878,7 @@ var _default = exports.default = {
|
|
|
857
878
|
};
|
|
858
879
|
return poll();
|
|
859
880
|
},
|
|
860
|
-
async pollProtections(client, applicationId, protectionIds, fragments) {
|
|
881
|
+
async pollProtections(client, applicationId, protectionIds, fragments, downloadOptions) {
|
|
861
882
|
if (protectionIds.length === 1) {
|
|
862
883
|
return [await this.pollProtection(client, applicationId, protectionIds[0], fragments)];
|
|
863
884
|
}
|
|
@@ -884,7 +905,7 @@ var _default = exports.default = {
|
|
|
884
905
|
state
|
|
885
906
|
} = _ref4;
|
|
886
907
|
return !seen[_id] && state !== 'canceled';
|
|
887
|
-
}).forEach(_ref5 => {
|
|
908
|
+
}).forEach(async _ref5 => {
|
|
888
909
|
let {
|
|
889
910
|
_id,
|
|
890
911
|
startedAt,
|
|
@@ -893,6 +914,8 @@ var _default = exports.default = {
|
|
|
893
914
|
} = _ref5;
|
|
894
915
|
seen[_id] = true;
|
|
895
916
|
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"));
|
|
917
|
+
await this.handleApplicationProtectionDownload(client, _id, applicationId, downloadOptions);
|
|
918
|
+
console.log("Downloaded: ".concat(_id));
|
|
896
919
|
});
|
|
897
920
|
if (ended.length < protectionIds.length) {
|
|
898
921
|
await new Promise(resolve => setTimeout(resolve, getPollingInterval(start)));
|
package/package.json
CHANGED