jscrambler 8.8.6 → 8.9.1

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # jscrambler
2
2
 
3
+ ## 8.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [18409eb]: Change the minimum version of the new useNamesOnModules option to 8.5
8
+ - [64ba5a3]: added new flag for forcing global names on modules or iifes
9
+
10
+ ## 8.9.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [f1f886e]: Option to retrieve the balance of the user
15
+
3
16
  ## 8.8.6
4
17
 
5
18
  ### Patch Changes
package/README.md CHANGED
@@ -144,6 +144,7 @@ Options:
144
144
  --mode <mode> (version 8.4 and above) Define protection mode. Possible values: automatic, manual (default: manual)
145
145
  --save-src <bool> Protection should save application sources (default: true)
146
146
  --protection-report <string> (version 8.4 and above) Protection id for the metadata report
147
+ --use-global-names-on-modules <bool> (version 8.5 and above) Force the usage of more complex names on modules (default: false)
147
148
  -h, --help output usage information
148
149
  ```
149
150
 
@@ -393,6 +394,18 @@ Similarly, the resulting symbol table can be obtained using the `--output-symbol
393
394
 
394
395
  **NOTE**: It only makes sense to use symbol tables on protections that use the identifiers renaming parameter.
395
396
 
397
+ ## Use Global Names On Modules
398
+
399
+ When we detect we're protecting an ES module, we may generate top-level single-character identifiers for code size purposes. If, in your use case, you expect to transpile this module into a script using a tool that cannot guarantee ES Module isolation (as it should), this may lead to collisions, especially if you're doing this with multiple obfuscated modules.
400
+ To reduce the chance of collisions, you can set the `useGlobalNamesOnModules` option on your protection request:
401
+
402
+ // jscrambler.json
403
+ {
404
+ "useGlobalNamesOnModules": true
405
+ }
406
+
407
+ If you apply the previous configuration, all generated global variable names will follow the same principle as global variables (not on modules), and have at least 5 characters, thus reducing the chance of collisions.
408
+
396
409
  ## Global Names Prefix
397
410
 
398
411
  If you need to make **separate obfuscation requests** for source code that belong to the same application instance, there is a small chance that you will encounter a **naming collision** on the generate global names.
@@ -411,7 +424,7 @@ To prevent **global naming collisions**, you can set the `globalNamesPrefix` par
411
424
  }
412
425
  ```
413
426
 
414
- If apply the previous configuration, all generated global variable names will start with the letters *p1* for *micro-frontend 1* and *p2* for *micro-frontend 2*.
427
+ If you apply the previous configuration, all generated global variable names will start with the letters *p1* for *micro-frontend 1* and *p2* for *micro-frontend 2*.
415
428
 
416
429
  ***Note***: The `globalNamesPrefix` parameter must be **short** and **unintelligible** to avoid code size increase and automated attacks
417
430
 
@@ -106,7 +106,7 @@ const validateBeforeProtection = function () {
106
106
  });
107
107
  return beforeProtectionArray;
108
108
  };
109
- _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).option('--save-src <bool>', 'Protection should save application sources (default: true)', validateBool('--save-src')).option('--protection-report <string>', '(version 8.4 and above) Protection id for the metadata report').parse(process.argv);
109
+ _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).option('--save-src <bool>', 'Protection should save application sources (default: true)', validateBool('--save-src')).option('--protection-report <string>', '(version 8.4 and above) Protection id for the metadata report').option('--use-global-names-on-modules <bool>', '(version 8.5 and above) Force the usage of more complex names on modules').option('--balance', '(version 8.4 and above) Gets the balance of the user').parse(process.argv);
110
110
  let globSrc, filesSrc, config;
111
111
 
112
112
  // If -c, --config file was provided
@@ -140,6 +140,7 @@ config.debugMode = _commander.default.debugMode || config.debugMode;
140
140
  config.instrument = _commander.default.instrument || config.instrument;
141
141
  config.mode = _commander.default.mode || config.mode;
142
142
  config.globalNamesPrefix = _commander.default.globalNamesPrefix || config.globalNamesPrefix;
143
+ config.useGlobalNamesOnModules = _commander.default.useGlobalNamesOnModules || config.useGlobalNamesOnModules;
143
144
 
144
145
  // handle codeHardening = 0
145
146
  if (typeof _commander.default.codeHardeningThreshold === 'undefined') {
@@ -275,7 +276,8 @@ const {
275
276
  deleteProtectionOnSuccess,
276
277
  mode,
277
278
  saveSrc,
278
- globalNamesPrefix
279
+ globalNamesPrefix,
280
+ useGlobalNamesOnModules
279
281
  } = config;
280
282
  const params = config.params;
281
283
  const incompatibleOptions = ['sourceMaps', 'instrument', 'startProfiling', 'stopProfiling'];
@@ -307,7 +309,21 @@ const clientSettings = {
307
309
  utc,
308
310
  jscramblerVersion
309
311
  };
310
- if (_commander.default.sourceMaps) {
312
+ if (_commander.default.balance) {
313
+ (async () => {
314
+ try {
315
+ await _.default.getBalance(clientSettings);
316
+ process.exit(0);
317
+ } catch (error) {
318
+ if (error.statusCode === 404) {
319
+ console.error('Not found: Ensure you are using version 8.4 or above.');
320
+ } else {
321
+ console.error(debug ? error : error.message || error);
322
+ }
323
+ process.exit(1);
324
+ }
325
+ })();
326
+ } else if (_commander.default.sourceMaps) {
311
327
  // Go, go, go download
312
328
  (async () => {
313
329
  try {
@@ -403,7 +419,8 @@ if (_commander.default.sourceMaps) {
403
419
  deleteProtectionOnSuccess,
404
420
  mode,
405
421
  saveSrc,
406
- globalNamesPrefix
422
+ globalNamesPrefix,
423
+ useGlobalNamesOnModules
407
424
  });
408
425
  try {
409
426
  if (typeof werror !== 'undefined') {
package/dist/index.js CHANGED
@@ -285,7 +285,8 @@ var _default = exports.default = {
285
285
  deleteProtectionOnSuccess,
286
286
  mode,
287
287
  saveSrc,
288
- globalNamesPrefix
288
+ globalNamesPrefix,
289
+ useGlobalNamesOnModules
289
290
  } = finalConfig;
290
291
  const {
291
292
  accessKey,
@@ -407,7 +408,8 @@ var _default = exports.default = {
407
408
  numberOfProtections,
408
409
  forceAppEnvironment,
409
410
  mode,
410
- globalNamesPrefix
411
+ globalNamesPrefix,
412
+ useGlobalNamesOnModules
411
413
  });
412
414
  if (finalConfig.inputSymbolTable) {
413
415
  const inputSymbolTableContents = await _fs.default.promises.readFile(finalConfig.inputSymbolTable, 'utf-8');
@@ -1199,6 +1201,41 @@ var _default = exports.default = {
1199
1201
  } else {
1200
1202
  console.log(metadataJson);
1201
1203
  }
1204
+ },
1205
+ async getBalance(conf) {
1206
+ const finalConfig = buildFinalConfig(conf);
1207
+ const {
1208
+ host,
1209
+ port,
1210
+ basePath,
1211
+ protocol,
1212
+ cafile,
1213
+ keys,
1214
+ jscramblerVersion,
1215
+ proxy,
1216
+ utc,
1217
+ clientId
1218
+ } = finalConfig;
1219
+ const {
1220
+ accessKey,
1221
+ secretKey
1222
+ } = keys;
1223
+ const client = new this.Client({
1224
+ accessKey,
1225
+ secretKey,
1226
+ host,
1227
+ port,
1228
+ basePath,
1229
+ protocol,
1230
+ cafile,
1231
+ jscramblerVersion,
1232
+ proxy,
1233
+ utc,
1234
+ clientId
1235
+ });
1236
+ const balance = await client.get('/balance');
1237
+ console.log(balance);
1238
+ return balance;
1202
1239
  }
1203
1240
  };
1204
1241
  function getFileFromUrl(client, url) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jscrambler",
3
3
  "description": "Jscrambler Code Integrity API client.",
4
- "version": "8.8.6",
4
+ "version": "8.9.1",
5
5
  "homepage": "https://github.com/jscrambler/jscrambler",
6
6
  "author": "Jscrambler <support@jscrambler.com>",
7
7
  "repository": {