jscrambler 8.4.2 → 8.5.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/CHANGELOG.md +6 -0
- package/dist/bin/jscrambler.js +19 -3
- package/dist/index.js +6 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/bin/jscrambler.js
CHANGED
|
@@ -53,6 +53,15 @@ const validateForceAppEnvironment = env => {
|
|
|
53
53
|
}
|
|
54
54
|
return normalizeEnvironment;
|
|
55
55
|
};
|
|
56
|
+
const validateMode = mode => {
|
|
57
|
+
const availableModes = ['automatic', 'manual'];
|
|
58
|
+
const normalizedMode = mode.toLowerCase();
|
|
59
|
+
if (!availableModes.includes(normalizedMode)) {
|
|
60
|
+
console.error("*mode* requires one of the following modes: {".concat(availableModes.toString(), "}. Example: --mode ").concat(availableModes[0]));
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
return normalizedMode;
|
|
64
|
+
};
|
|
56
65
|
const validateBeforeProtection = function () {
|
|
57
66
|
let beforeProtectionArray = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
58
67
|
if (beforeProtectionArray.length === 0) {
|
|
@@ -108,7 +117,7 @@ const validateBeforeProtection = function () {
|
|
|
108
117
|
});
|
|
109
118
|
return beforeProtectionArray;
|
|
110
119
|
};
|
|
111
|
-
_commander.default.version(require('../../package.json').version).usage('[options] <file ...>').option('-a, --access-key <accessKey>', 'Access key').option('-c, --config <config>', 'Jscrambler configuration options').option('-H, --host <host>', 'Hostname').option('-i, --application-id <id>', 'Application ID').option('-o, --output-dir <dir>', 'Output directory').option('-p, --port <port>', 'Port').option('--base-path <path>', 'Base Path').option('--protocol <protocol>', 'Protocol (http or https)').option('--cafile <path>', 'Internal certificate authority').option('-C, --cwd <dir>', 'Current Working Directory').option('-s, --secret-key <secretKey>', 'Secret key').option('-m, --source-maps <id>', 'Download source maps').option('-R, --randomization-seed <seed>', 'Set randomization seed').option('--instrument', 'Instrument file(s) before start profiling. ATTENTION: previous profiling information will be deleted').option('--start-profiling', 'Starts profiling (assumes an already instrumented application)').option('--stop-profiling', 'Stops profiling').option('--code-hardening-threshold <threshold>', 'Set code hardening file size threshold. Format: {value}{unit="b,kb,mb"}. Example: 200kb', validateCodeHardeningThreshold).option('--recommended-order <bool>', 'Use recommended order', validateBool('recommended-order')).option('-W, --werror <bool>', 'Set werror flag value (default: true)', validateBool('werror')).option('--utc <bool>', 'Set UTC as the request time zone. Otherwise it uses the local time zone (default: true)', validateBool('utc')).option('--tolerate-minification <bool>', "Don't detect minification as malicious tampering (default: true)", validateBool('tolerate-minification')).option('--use-profiling-data <bool>', "(version 6.2 only) Protection should use the existing profiling data (default: true)", validateBool('use-profiling-data')).option('--profiling-data-mode <mode>', "(version 6.3 and above) Select profiling mode (default: automatic)", validateProfilingDataMode).option('--remove-profiling-data', "Removes the current application profiling information").option('--use-app-classification <bool>', '(version 6.3 and above) Protection should use Application Classification metadata when protecting (default: true)', validateBool('--use-app-classification')).option('--input-symbol-table <file>', '(version 6.3 and above) Protection should use symbol table when protecting. (default: no file)').option('--output-symbol-table <id>', '(version 6.3 and above) Download output symbol table (json)').option('--jscramblerVersion <version>', 'Use a specific Jscrambler version').option('--debugMode', 'Protect in debug mode').option('--skip-sources', 'Prevent source files from being updated').option('--force-app-environment <environment>', "(version 7.1 and above) Override application's environment detected automatically. Possible values: ".concat(availableEnvironments.toString()), validateForceAppEnvironment).option('--ensure-code-annotation <bool>', "(version 7.3 and above) Fail protection if no annotations are found on the source code (default: false)", validateBool('ensure-code-annotation')).option('-n <number>', "(version 7.2 and above) Create multiple protections at once.").option('--delete-protection-on-success <bool>', 'Deletes the protection files after they have been protected and downloaded (default: false)', validateBool('--delete-protection-on-success')).parse(process.argv);
|
|
120
|
+
_commander.default.version(require('../../package.json').version).usage('[options] <file ...>').option('-a, --access-key <accessKey>', 'Access key').option('-c, --config <config>', 'Jscrambler configuration options').option('-H, --host <host>', 'Hostname').option('-i, --application-id <id>', 'Application ID').option('-o, --output-dir <dir>', 'Output directory').option('-p, --port <port>', 'Port').option('--base-path <path>', 'Base Path').option('--protocol <protocol>', 'Protocol (http or https)').option('--cafile <path>', 'Internal certificate authority').option('-C, --cwd <dir>', 'Current Working Directory').option('-s, --secret-key <secretKey>', 'Secret key').option('-m, --source-maps <id>', 'Download source maps').option('-R, --randomization-seed <seed>', 'Set randomization seed').option('--instrument', 'Instrument file(s) before start profiling. ATTENTION: previous profiling information will be deleted').option('--start-profiling', 'Starts profiling (assumes an already instrumented application)').option('--stop-profiling', 'Stops profiling').option('--code-hardening-threshold <threshold>', 'Set code hardening file size threshold. Format: {value}{unit="b,kb,mb"}. Example: 200kb', validateCodeHardeningThreshold).option('--recommended-order <bool>', 'Use recommended order', validateBool('recommended-order')).option('-W, --werror <bool>', 'Set werror flag value (default: true)', validateBool('werror')).option('--utc <bool>', 'Set UTC as the request time zone. Otherwise it uses the local time zone (default: true)', validateBool('utc')).option('--tolerate-minification <bool>', "Don't detect minification as malicious tampering (default: true)", validateBool('tolerate-minification')).option('--use-profiling-data <bool>', "(version 6.2 only) Protection should use the existing profiling data (default: true)", validateBool('use-profiling-data')).option('--profiling-data-mode <mode>', "(version 6.3 and above) Select profiling mode (default: automatic)", validateProfilingDataMode).option('--remove-profiling-data', "Removes the current application profiling information").option('--use-app-classification <bool>', '(version 6.3 and above) Protection should use Application Classification metadata when protecting (default: true)', validateBool('--use-app-classification')).option('--input-symbol-table <file>', '(version 6.3 and above) Protection should use symbol table when protecting. (default: no file)').option('--output-symbol-table <id>', '(version 6.3 and above) Download output symbol table (json)').option('--jscramblerVersion <version>', 'Use a specific Jscrambler version').option('--debugMode', 'Protect in debug mode').option('--skip-sources', 'Prevent source files from being updated').option('--force-app-environment <environment>', "(version 7.1 and above) Override application's environment detected automatically. Possible values: ".concat(availableEnvironments.toString()), validateForceAppEnvironment).option('--ensure-code-annotation <bool>', "(version 7.3 and above) Fail protection if no annotations are found on the source code (default: false)", validateBool('ensure-code-annotation')).option('-n <number>', "(version 7.2 and above) Create multiple protections at once.").option('--delete-protection-on-success <bool>', 'Deletes the protection files after they have been protected and downloaded (default: false)', validateBool('--delete-protection-on-success')).option('--mode <mode>', "(version 8.4 and above) Define protection mode. Possible values: automatic, manual (default: manual)", validateMode).parse(process.argv);
|
|
112
121
|
let globSrc, filesSrc, config;
|
|
113
122
|
|
|
114
123
|
// If -c, --config file was provided
|
|
@@ -140,6 +149,7 @@ config.removeProfilingData = _commander.default.removeProfilingData;
|
|
|
140
149
|
config.skipSources = _commander.default.skipSources;
|
|
141
150
|
config.debugMode = _commander.default.debugMode || config.debugMode;
|
|
142
151
|
config.instrument = _commander.default.instrument || config.instrument;
|
|
152
|
+
config.mode = _commander.default.mode || config.mode;
|
|
143
153
|
|
|
144
154
|
// handle codeHardening = 0
|
|
145
155
|
if (typeof _commander.default.codeHardeningThreshold === 'undefined') {
|
|
@@ -267,7 +277,8 @@ const {
|
|
|
267
277
|
ensureCodeAnnotation,
|
|
268
278
|
forceAppEnvironment,
|
|
269
279
|
beforeProtection,
|
|
270
|
-
deleteProtectionOnSuccess
|
|
280
|
+
deleteProtectionOnSuccess,
|
|
281
|
+
mode
|
|
271
282
|
} = config;
|
|
272
283
|
const params = config.params;
|
|
273
284
|
const incompatibleOptions = ['sourceMaps', 'instrument', 'startProfiling', 'stopProfiling'];
|
|
@@ -281,6 +292,10 @@ if (usedIncompatibleOptions.length > 1) {
|
|
|
281
292
|
console.error('Using mutually exclusive options:', usedIncompatibleOptions);
|
|
282
293
|
process.exit(1);
|
|
283
294
|
}
|
|
295
|
+
if ((_commander.default.mode === 'automatic' || config.mode === 'automatic') && config.params) {
|
|
296
|
+
console.error('Cannot submit a Jscrambler configuration file in automatic mode with parameters.');
|
|
297
|
+
process.exit(1);
|
|
298
|
+
}
|
|
284
299
|
const clientSettings = {
|
|
285
300
|
keys: {
|
|
286
301
|
accessKey,
|
|
@@ -379,7 +394,8 @@ if (_commander.default.sourceMaps) {
|
|
|
379
394
|
numberOfProtections,
|
|
380
395
|
forceAppEnvironment,
|
|
381
396
|
beforeProtection,
|
|
382
|
-
deleteProtectionOnSuccess
|
|
397
|
+
deleteProtectionOnSuccess,
|
|
398
|
+
mode
|
|
383
399
|
});
|
|
384
400
|
try {
|
|
385
401
|
if (typeof werror !== 'undefined') {
|
package/dist/index.js
CHANGED
|
@@ -268,7 +268,8 @@ var _default = exports.default = {
|
|
|
268
268
|
numberOfProtections,
|
|
269
269
|
ensureCodeAnnotation,
|
|
270
270
|
forceAppEnvironment,
|
|
271
|
-
deleteProtectionOnSuccess
|
|
271
|
+
deleteProtectionOnSuccess,
|
|
272
|
+
mode
|
|
272
273
|
} = finalConfig;
|
|
273
274
|
const {
|
|
274
275
|
accessKey,
|
|
@@ -354,7 +355,8 @@ var _default = exports.default = {
|
|
|
354
355
|
useAppClassification,
|
|
355
356
|
ensureCodeAnnotation,
|
|
356
357
|
useProfilingData,
|
|
357
|
-
useRecommendedOrder
|
|
358
|
+
useRecommendedOrder,
|
|
359
|
+
mode
|
|
358
360
|
};
|
|
359
361
|
for (const prop in dataToValidate) {
|
|
360
362
|
const value = dataToValidate[prop];
|
|
@@ -386,7 +388,8 @@ var _default = exports.default = {
|
|
|
386
388
|
source,
|
|
387
389
|
tolerateMinification,
|
|
388
390
|
numberOfProtections,
|
|
389
|
-
forceAppEnvironment
|
|
391
|
+
forceAppEnvironment,
|
|
392
|
+
mode
|
|
390
393
|
});
|
|
391
394
|
if (finalConfig.inputSymbolTable) {
|
|
392
395
|
const inputSymbolTableContents = await _fs.default.promises.readFile(finalConfig.inputSymbolTable, 'utf-8');
|
package/package.json
CHANGED