jscrambler 6.0.1 → 6.1.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/LICENSE-MIT CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 magalhas
1
+ Copyright (c) 2014 Jscrambler
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
package/README.md CHANGED
@@ -129,6 +129,7 @@ Options:
129
129
  --debugMode Protect in debug mode
130
130
  --skip-sources Prevent source files from being updated
131
131
  --force-app-environment <environment> (version 7.1 and above) Override application's environment detected automatically. Possible values: node,browser,isomorphic,automatic
132
+ -n <number> (version 7.2 and above) Create multiple protections at once.
132
133
  -h, --help output usage information
133
134
  ```
134
135
 
@@ -1,67 +1,66 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';
2
+ "use strict";
3
3
 
4
- var _commander = require('commander');
4
+ var _commander = _interopRequireDefault(require("commander"));
5
5
 
6
- var _commander2 = _interopRequireDefault(_commander);
6
+ var _lodash = _interopRequireDefault(require("lodash.defaults"));
7
7
 
8
- var _lodash = require('lodash.defaults');
8
+ var _path = _interopRequireDefault(require("path"));
9
9
 
10
- var _lodash2 = _interopRequireDefault(_lodash);
10
+ var _filesizeParser = _interopRequireDefault(require("filesize-parser"));
11
11
 
12
- var _path = require('path');
12
+ var _config3 = _interopRequireDefault(require("../config"));
13
13
 
14
- var _path2 = _interopRequireDefault(_path);
14
+ var _ = _interopRequireDefault(require("../"));
15
15
 
16
- var _filesizeParser = require('filesize-parser');
16
+ var _cli = require("../cli");
17
17
 
18
- var _filesizeParser2 = _interopRequireDefault(_filesizeParser);
18
+ var _utils = require("../utils");
19
19
 
20
- var _config3 = require('../config');
21
-
22
- var _config4 = _interopRequireDefault(_config3);
23
-
24
- var _ = require('../');
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
21
 
26
- var _2 = _interopRequireDefault(_);
22
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
23
 
28
- var _cli = require('../cli');
24
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
25
 
30
- var _utils = require('../utils');
26
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
27
 
32
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
33
29
 
34
- function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
30
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
35
31
 
36
32
  var debug = !!process.env.DEBUG;
33
+
37
34
  var validateBool = function validateBool(option) {
38
35
  return function (val) {
39
36
  if (!/^(true|false)$/i.test(val)) {
40
- console.error('*' + option + '* requires a <bool> value.');
37
+ console.error("*".concat(option, "* requires a <bool> value."));
41
38
  process.exit(1);
42
39
  }
40
+
43
41
  return val.toLowerCase();
44
42
  };
45
43
  };
46
44
 
47
45
  var validateCodeHardeningThreshold = function validateCodeHardeningThreshold(val) {
48
- var inBytes = void 0;
46
+ var inBytes;
47
+
49
48
  try {
50
- inBytes = (0, _filesizeParser2.default)(val);
49
+ inBytes = (0, _filesizeParser.default)(val);
51
50
  } catch (e) {
52
51
  console.error('*code-hardening-threshold* requires a valid <threshold> value. Format: {number}{unit="b,kb,mb"}. Example: --code-hardening-threshold 200kb');
53
52
  process.exit(1);
54
53
  }
54
+
55
55
  return inBytes;
56
56
  };
57
57
 
58
58
  var validateProfilingDataMode = function validateProfilingDataMode(mode) {
59
59
  var availableModes = ['automatic', 'annotations', 'off'];
60
-
61
60
  var normalizedMode = mode.toLowerCase();
62
61
 
63
62
  if (!availableModes.includes(normalizedMode)) {
64
- console.error('*profiling-data-mode* requires one of the following modes: {' + availableModes.toString() + '}. Example: --profiling-data-mode ' + availableModes[0]);
63
+ console.error("*profiling-data-mode* requires one of the following modes: {".concat(availableModes.toString(), "}. Example: --profiling-data-mode ").concat(availableModes[0]));
65
64
  process.exit(1);
66
65
  }
67
66
 
@@ -69,76 +68,73 @@ var validateProfilingDataMode = function validateProfilingDataMode(mode) {
69
68
  };
70
69
 
71
70
  var availableEnvironments = ['node', 'browser', 'isomorphic', 'automatic'];
71
+
72
72
  var validateForceAppEnvironment = function validateForceAppEnvironment(env) {
73
73
  var normalizeEnvironment = env.toLowerCase();
74
74
 
75
75
  if (!availableEnvironments.includes(normalizeEnvironment)) {
76
- console.error('*force-app-environment* requires one of the following values: {' + availableEnvironments.toString() + '}. Example: --force-app-environment ' + availableEnvironments[0]);
76
+ console.error("*force-app-environment* requires one of the following values: {".concat(availableEnvironments.toString(), "}. Example: --force-app-environment ").concat(availableEnvironments[0]));
77
77
  process.exit(1);
78
78
  }
79
79
 
80
80
  return normalizeEnvironment;
81
81
  };
82
82
 
83
- _commander2.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: ' + availableEnvironments.toString(), validateForceAppEnvironment).parse(process.argv);
83
+ _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('-n <number>', "(version 7.2 and above) Create multiple protections at once.").parse(process.argv);
84
84
 
85
- var globSrc = void 0,
86
- filesSrc = void 0,
87
- config = void 0;
85
+ var globSrc, filesSrc, config; // If -c, --config file was provided
88
86
 
89
- // If -c, --config file was provided
90
- if (_commander2.default.config) {
87
+ if (_commander.default.config) {
91
88
  // We're using `commander` (CLI) as the source of all truths, falling back to
92
89
  // the `config` provided by the file passed as argument
93
- config = require(_path2.default.resolve(_commander2.default.config, '.'));
90
+ config = require(_path.default.resolve(_commander.default.config, '.'));
94
91
  } else {
95
92
  config = {};
96
93
  }
97
94
 
98
- config.accessKey = _commander2.default.accessKey || (config.keys ? config.keys.accessKey : undefined);
99
- config.secretKey = _commander2.default.secretKey || (config.keys ? config.keys.secretKey : undefined);
100
- config.host = _commander2.default.host || config.host;
101
- config.port = _commander2.default.port || config.port;
102
- config.basePath = _commander2.default.basePath || config.basePath;
95
+ config.accessKey = _commander.default.accessKey || (config.keys ? config.keys.accessKey : undefined);
96
+ config.secretKey = _commander.default.secretKey || (config.keys ? config.keys.secretKey : undefined);
97
+ config.host = _commander.default.host || config.host;
98
+ config.port = _commander.default.port || config.port;
99
+ config.basePath = _commander.default.basePath || config.basePath;
103
100
  config.port = config.port && parseInt(config.port);
104
- config.protocol = _commander2.default.protocol || config.protocol;
105
- config.cafile = _commander2.default.cafile || config.cafile;
106
- config.filesDest = _commander2.default.outputDir || config.filesDest;
107
- config.applicationId = _commander2.default.applicationId || config.applicationId;
108
- config.randomizationSeed = _commander2.default.randomizationSeed || config.randomizationSeed;
109
- config.cwd = _commander2.default.cwd || config.cwd;
110
- config.useRecommendedOrder = _commander2.default.recommendedOrder ? _commander2.default.recommendedOrder !== 'false' : config.useRecommendedOrder;
111
- config.tolerateMinification = _commander2.default.tolerateMinification ? _commander2.default.tolerateMinification !== 'false' : config.tolerateMinification;
112
- config.werror = _commander2.default.werror ? _commander2.default.werror !== 'false' : config.werror;
113
- config.jscramblerVersion = _commander2.default.jscramblerVersion || config.jscramblerVersion;
114
- config.inputSymbolTable = _commander2.default.inputSymbolTable || config.inputSymbolTable;
115
- config.removeProfilingData = _commander2.default.removeProfilingData;
116
- config.skipSources = _commander2.default.skipSources;
117
- config.debugMode = _commander2.default.debugMode || config.debugMode;
118
-
119
- // handle codeHardening = 0
120
- if (typeof _commander2.default.codeHardeningThreshold === 'undefined') {
101
+ config.protocol = _commander.default.protocol || config.protocol;
102
+ config.cafile = _commander.default.cafile || config.cafile;
103
+ config.filesDest = _commander.default.outputDir || config.filesDest;
104
+ config.applicationId = _commander.default.applicationId || config.applicationId;
105
+ config.randomizationSeed = _commander.default.randomizationSeed || config.randomizationSeed;
106
+ config.cwd = _commander.default.cwd || config.cwd;
107
+ config.useRecommendedOrder = _commander.default.recommendedOrder ? _commander.default.recommendedOrder !== 'false' : config.useRecommendedOrder;
108
+ config.tolerateMinification = _commander.default.tolerateMinification ? _commander.default.tolerateMinification !== 'false' : config.tolerateMinification;
109
+ config.werror = _commander.default.werror ? _commander.default.werror !== 'false' : config.werror;
110
+ config.jscramblerVersion = _commander.default.jscramblerVersion || config.jscramblerVersion;
111
+ config.inputSymbolTable = _commander.default.inputSymbolTable || config.inputSymbolTable;
112
+ config.removeProfilingData = _commander.default.removeProfilingData;
113
+ config.skipSources = _commander.default.skipSources;
114
+ config.debugMode = _commander.default.debugMode || config.debugMode; // handle codeHardening = 0
115
+
116
+ if (typeof _commander.default.codeHardeningThreshold === 'undefined') {
121
117
  config.codeHardeningThreshold = config.codeHardeningThreshold ? validateCodeHardeningThreshold(config.codeHardeningThreshold) : undefined;
122
118
  } else {
123
- config.codeHardeningThreshold = _commander2.default.codeHardeningThreshold;
119
+ config.codeHardeningThreshold = _commander.default.codeHardeningThreshold;
124
120
  }
125
121
 
126
- if (_commander2.default.profilingDataMode) {
127
- config.profilingDataMode = _commander2.default.profilingDataMode;
122
+ if (_commander.default.profilingDataMode) {
123
+ config.profilingDataMode = _commander.default.profilingDataMode;
128
124
  } else {
129
125
  config.profilingDataMode = config.profilingDataMode ? validateProfilingDataMode(config.profilingDataMode) : undefined;
130
126
  }
131
127
 
132
- if (_commander2.default.utc) {
133
- config.utc = _commander2.default.utc !== 'false';
128
+ if (_commander.default.utc) {
129
+ config.utc = _commander.default.utc !== 'false';
134
130
  }
135
131
 
136
- if (_commander2.default.useProfilingData) {
137
- config.useProfilingData = _commander2.default.useProfilingData !== 'false';
132
+ if (_commander.default.useProfilingData) {
133
+ config.useProfilingData = _commander.default.useProfilingData !== 'false';
138
134
  }
139
135
 
140
- if (_commander2.default.useAppClassification) {
141
- config.useAppClassification = _commander2.default.useAppClassification !== 'false';
136
+ if (_commander.default.useAppClassification) {
137
+ config.useAppClassification = _commander.default.useAppClassification !== 'false';
142
138
  }
143
139
 
144
140
  if (config.jscramblerVersion && !/^(?:\d+\.\d+(?:-f)?|stable|latest)$/.test(config.jscramblerVersion)) {
@@ -146,13 +142,14 @@ if (config.jscramblerVersion && !/^(?:\d+\.\d+(?:-f)?|stable|latest)$/.test(conf
146
142
  process.exit(1);
147
143
  }
148
144
 
149
- if (_commander2.default.forceAppEnvironment) {
150
- config.forceAppEnvironment = _commander2.default.forceAppEnvironment;
145
+ if (_commander.default.forceAppEnvironment) {
146
+ config.forceAppEnvironment = _commander.default.forceAppEnvironment;
151
147
  } else {
152
148
  config.forceAppEnvironment = config.forceAppEnvironment ? validateForceAppEnvironment(config.forceAppEnvironment) : undefined;
153
149
  }
154
150
 
155
- config = (0, _lodash2.default)(config, _config4.default);
151
+ config = (0, _lodash.default)(config, _config3.default);
152
+ config.numberOfProtections = (0, _utils.validateNProtections)(_commander.default.N);
156
153
 
157
154
  if (config.codeHardeningThreshold) {
158
155
  config.codeHardeningThreshold = validateCodeHardeningThreshold(config.codeHardeningThreshold);
@@ -162,23 +159,22 @@ if (config.profilingDataMode) {
162
159
  config.profilingDataMode = validateProfilingDataMode(config.profilingDataMode);
163
160
  }
164
161
 
165
- globSrc = config.filesSrc;
166
- // If src paths have been provided
167
- if (_commander2.default.args.length > 0) {
168
- globSrc = _commander2.default.args;
162
+ globSrc = config.filesSrc; // If src paths have been provided
163
+
164
+ if (_commander.default.args.length > 0) {
165
+ globSrc = _commander.default.args;
169
166
  }
170
167
 
171
168
  if (globSrc && globSrc.length) {
172
169
  // this will be translated to real files in the updateApplicationSources method
173
170
  filesSrc = globSrc;
174
- var nSources = 0;
175
- // Iterate `globSrc` to build a list of source files into `filesSrc`
171
+ var nSources = 0; // Iterate `globSrc` to build a list of source files into `filesSrc`
172
+
176
173
  for (var i = 0, l = globSrc.length; i < l; i += 1) {
177
174
  // Calling sync `glob` because async is pointless for the CLI use case
178
175
  // (as of now at least)
179
-
180
176
  // If the user is providing a zip alongside more files
181
- if (_path2.default.extname(globSrc[i]) === '.zip' && globSrc.length > 1) {
177
+ if (_path.default.extname(globSrc[i]) === '.zip' && globSrc.length > 1) {
182
178
  console.error('Please provide either a zip file containing all your source files or use the minimatch syntax');
183
179
  process.exit(1);
184
180
  }
@@ -186,22 +182,24 @@ if (globSrc && globSrc.length) {
186
182
  var tmpGlob = (0, _utils.getMatchedFiles)(globSrc[i]);
187
183
 
188
184
  if (config.werror && tmpGlob.length === 0) {
189
- console.error('Pattern "' + globSrc[i] + '" doesn\'t match any files.');
185
+ console.error("Pattern \"".concat(globSrc[i], "\" doesn't match any files."));
190
186
  process.exit(1);
191
187
  }
192
188
 
193
189
  if (debug) {
194
190
  if (tmpGlob.length === 0) {
195
- console.log('Pattern "' + globSrc[i] + '" doesn\'t match any files. Will be ignored.');
191
+ console.log("Pattern \"".concat(globSrc[i], "\" doesn't match any files. Will be ignored."));
196
192
  } else {
197
- console.log('Pattern "' + globSrc[i] + '" matched the following files:');
193
+ console.log("Pattern \"".concat(globSrc[i], "\" matched the following files:"));
198
194
  tmpGlob.forEach(function (file) {
199
- console.log(' ' + file);
195
+ console.log(" ".concat(file));
200
196
  });
201
197
  }
202
198
  }
199
+
203
200
  nSources += tmpGlob.length;
204
201
  }
202
+
205
203
  if (nSources === 0) {
206
204
  console.error('No files matched.');
207
205
  process.exit(1);
@@ -226,7 +224,7 @@ var _config2 = config,
226
224
  cwd = _config2.cwd,
227
225
  randomizationSeed = _config2.randomizationSeed,
228
226
  _config2$sourceMaps = _config2.sourceMaps,
229
- sourceMaps = _config2$sourceMaps === undefined ? false : _config2$sourceMaps,
227
+ sourceMaps = _config2$sourceMaps === void 0 ? false : _config2$sourceMaps,
230
228
  useRecommendedOrder = _config2.useRecommendedOrder,
231
229
  werror = _config2.werror,
232
230
  tolerateMinification = _config2.tolerateMinification,
@@ -244,37 +242,17 @@ var _config2 = config,
244
242
  utc = _config2.utc,
245
243
  entryPoint = _config2.entryPoint,
246
244
  excludeList = _config2.excludeList,
245
+ numberOfProtections = _config2.numberOfProtections,
247
246
  forceAppEnvironment = _config2.forceAppEnvironment;
248
-
249
-
250
- var params = (0, _cli.mergeAndParseParams)(_commander2.default, config.params);
251
-
247
+ var params = (0, _cli.mergeAndParseParams)(_commander.default, config.params);
252
248
  var incompatibleOptions = ['sourceMaps', 'instrument', 'startProfiling', 'stopProfiling'];
253
249
  var usedIncompatibleOptions = [];
254
- var _iteratorNormalCompletion = true;
255
- var _didIteratorError = false;
256
- var _iteratorError = undefined;
257
250
 
258
- try {
259
- for (var _iterator = incompatibleOptions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
260
- var incompatibleOption = _step.value;
251
+ for (var _i = 0, _incompatibleOptions = incompatibleOptions; _i < _incompatibleOptions.length; _i++) {
252
+ var incompatibleOption = _incompatibleOptions[_i];
261
253
 
262
- if (_commander2.default[incompatibleOption]) {
263
- usedIncompatibleOptions.push(incompatibleOption);
264
- }
265
- }
266
- } catch (err) {
267
- _didIteratorError = true;
268
- _iteratorError = err;
269
- } finally {
270
- try {
271
- if (!_iteratorNormalCompletion && _iterator.return) {
272
- _iterator.return();
273
- }
274
- } finally {
275
- if (_didIteratorError) {
276
- throw _iteratorError;
277
- }
254
+ if (_commander.default[incompatibleOption]) {
255
+ usedIncompatibleOptions.push(incompatibleOption);
278
256
  }
279
257
  }
280
258
 
@@ -298,7 +276,7 @@ var clientSettings = {
298
276
  jscramblerVersion: jscramblerVersion
299
277
  };
300
278
 
301
- if (_commander2.default.sourceMaps) {
279
+ if (_commander.default.sourceMaps) {
302
280
  // Go, go, go download
303
281
  _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
304
282
  return regeneratorRuntime.wrap(function _callee$(_context) {
@@ -307,10 +285,10 @@ if (_commander2.default.sourceMaps) {
307
285
  case 0:
308
286
  _context.prev = 0;
309
287
  _context.next = 3;
310
- return _2.default.downloadSourceMaps(Object.assign({}, clientSettings, {
288
+ return _.default.downloadSourceMaps(_objectSpread(_objectSpread({}, clientSettings), {}, {
311
289
  filesDest: filesDest,
312
290
  filesSrc: filesSrc,
313
- protectionId: _commander2.default.sourceMaps
291
+ protectionId: _commander.default.sourceMaps
314
292
  }));
315
293
 
316
294
  case 3:
@@ -319,19 +297,18 @@ if (_commander2.default.sourceMaps) {
319
297
 
320
298
  case 5:
321
299
  _context.prev = 5;
322
- _context.t0 = _context['catch'](0);
323
-
300
+ _context.t0 = _context["catch"](0);
324
301
  console.error(debug ? _context.t0 : _context.t0.message || _context.t0);
325
302
  process.exit(1);
326
303
 
327
304
  case 9:
328
- case 'end':
305
+ case "end":
329
306
  return _context.stop();
330
307
  }
331
308
  }
332
- }, _callee, undefined, [[0, 5]]);
309
+ }, _callee, null, [[0, 5]]);
333
310
  }))();
334
- } else if (_commander2.default.outputSymbolTable) {
311
+ } else if (_commander.default.outputSymbolTable) {
335
312
  // Go, go, go download
336
313
  _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
337
314
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
@@ -340,10 +317,10 @@ if (_commander2.default.sourceMaps) {
340
317
  case 0:
341
318
  _context2.prev = 0;
342
319
  _context2.next = 3;
343
- return _2.default.downloadSymbolTable(Object.assign({}, clientSettings, {
320
+ return _.default.downloadSymbolTable(_objectSpread(_objectSpread({}, clientSettings), {}, {
344
321
  filesDest: filesDest,
345
322
  filesSrc: filesSrc,
346
- protectionId: _commander2.default.outputSymbolTable
323
+ protectionId: _commander.default.outputSymbolTable
347
324
  }));
348
325
 
349
326
  case 3:
@@ -352,20 +329,19 @@ if (_commander2.default.sourceMaps) {
352
329
 
353
330
  case 5:
354
331
  _context2.prev = 5;
355
- _context2.t0 = _context2['catch'](0);
356
-
332
+ _context2.t0 = _context2["catch"](0);
357
333
  console.error(debug ? _context2.t0 : _context2.t0.message || _context2.t0);
358
334
  process.exit(1);
359
335
 
360
336
  case 9:
361
- case 'end':
337
+ case "end":
362
338
  return _context2.stop();
363
339
  }
364
340
  }
365
- }, _callee2, undefined, [[0, 5]]);
341
+ }, _callee2, null, [[0, 5]]);
366
342
  }))();
367
- } else if (_commander2.default.instrument) {
368
- _2.default.instrumentAndDownload(Object.assign({}, clientSettings, {
343
+ } else if (_commander.default.instrument) {
344
+ _.default.instrumentAndDownload(_objectSpread(_objectSpread({}, clientSettings), {}, {
369
345
  applicationId: applicationId,
370
346
  filesSrc: filesSrc,
371
347
  filesDest: filesDest,
@@ -375,15 +351,15 @@ if (_commander2.default.sourceMaps) {
375
351
  console.error(debug ? error : error.message || error);
376
352
  process.exit(1);
377
353
  });
378
- } else if (_commander2.default.startProfiling) {
379
- _2.default.setProfilingState(Object.assign({}, clientSettings, {
354
+ } else if (_commander.default.startProfiling) {
355
+ _.default.setProfilingState(_objectSpread(_objectSpread({}, clientSettings), {}, {
380
356
  applicationId: applicationId
381
357
  }), 'RUNNING', 'STARTED', "Exercise your application and when you're finished run *--stop-profiling* command").catch(function (error) {
382
358
  console.error(debug ? error : error.message || error);
383
359
  process.exit(1);
384
360
  });
385
- } else if (_commander2.default.stopProfiling) {
386
- _2.default.setProfilingState(Object.assign({}, clientSettings, {
361
+ } else if (_commander.default.stopProfiling) {
362
+ _.default.setProfilingState(_objectSpread(_objectSpread({}, clientSettings), {}, {
387
363
  applicationId: applicationId
388
364
  }), 'READY', 'STOPPED', 'Protect your application with 2 extra arguments: *--profiling-data-mode automatic* and *--skip-sources*').catch(function (error) {
389
365
  console.error(debug ? error : error.message || error);
@@ -397,7 +373,7 @@ if (_commander2.default.sourceMaps) {
397
373
  while (1) {
398
374
  switch (_context3.prev = _context3.next) {
399
375
  case 0:
400
- protectAndDownloadOptions = Object.assign({}, clientSettings, {
376
+ protectAndDownloadOptions = _objectSpread(_objectSpread({}, clientSettings), {}, {
401
377
  applicationId: applicationId,
402
378
  filesSrc: filesSrc,
403
379
  filesDest: filesDest,
@@ -421,6 +397,7 @@ if (_commander2.default.sourceMaps) {
421
397
  inputSymbolTable: inputSymbolTable,
422
398
  entryPoint: entryPoint,
423
399
  excludeList: excludeList,
400
+ numberOfProtections: numberOfProtections,
424
401
  forceAppEnvironment: forceAppEnvironment
425
402
  });
426
403
  _context3.prev = 1;
@@ -428,8 +405,9 @@ if (_commander2.default.sourceMaps) {
428
405
  if (typeof werror !== 'undefined') {
429
406
  protectAndDownloadOptions.bail = werror;
430
407
  }
408
+
431
409
  _context3.next = 5;
432
- return _2.default.protectAndDownload(protectAndDownloadOptions);
410
+ return _.default.protectAndDownload(protectAndDownloadOptions);
433
411
 
434
412
  case 5:
435
413
  _context3.next = 11;
@@ -437,16 +415,15 @@ if (_commander2.default.sourceMaps) {
437
415
 
438
416
  case 7:
439
417
  _context3.prev = 7;
440
- _context3.t0 = _context3['catch'](1);
441
-
418
+ _context3.t0 = _context3["catch"](1);
442
419
  console.error(debug ? _context3.t0 : _context3.t0.message || _context3.t0);
443
420
  process.exit(1);
444
421
 
445
422
  case 11:
446
- case 'end':
423
+ case "end":
447
424
  return _context3.stop();
448
425
  }
449
426
  }
450
- }, _callee3, undefined, [[1, 7]]);
427
+ }, _callee3, null, [[1, 7]]);
451
428
  }))();
452
429
  }
@@ -1,14 +1,13 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = cleanupInputFields;
7
+
7
8
  function cleanupInputFields(args, fragments) {
8
9
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
9
-
10
10
  var cleanedUpFragments = fragments;
11
-
12
11
  var dataArg = args.find(function (arg) {
13
12
  return arg.name === 'data';
14
13
  });
@@ -20,13 +19,11 @@ function cleanupInputFields(args, fragments) {
20
19
 
21
20
  if (!hasFieldArg && typeof options[field] !== 'undefined') {
22
21
  options[field] = undefined;
23
- cleanedUpFragments = cleanedUpFragments.replace(new RegExp(',?[s|\n]*' + field), '');
24
-
25
- console.warn('This API Version does not support the ' + field + ' argument.');
22
+ cleanedUpFragments = cleanedUpFragments.replace(new RegExp(",?[s|\n]*".concat(field)), '');
23
+ console.warn("This API Version does not support the ".concat(field, " argument."));
26
24
  }
27
25
  }
28
26
 
29
27
  ['tolerateMinification', 'useProfilingData', 'useAppClassification', 'inputSymbolTable', 'entryPoint'].forEach(fieldCleanUp);
30
-
31
28
  return [options, cleanedUpFragments];
32
29
  }
package/dist/cli.js CHANGED
@@ -1,17 +1,13 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.mergeAndParseParams = mergeAndParseParams;
7
7
 
8
- var _lodash = require('lodash.clone');
8
+ var _lodash = _interopRequireDefault(require("lodash.clone"));
9
9
 
10
- var _lodash2 = _interopRequireDefault(_lodash);
11
-
12
- var _snakeCase = require('snake-case');
13
-
14
- var _snakeCase2 = _interopRequireDefault(_snakeCase);
10
+ var _snakeCase = _interopRequireDefault(require("snake-case"));
15
11
 
16
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
13
 
@@ -48,15 +44,14 @@ var isBoolFlag = {
48
44
  domainLock: false,
49
45
  osLock: false,
50
46
  preserveAnnotations: true
51
- };
47
+ }; // Convert from command line option format to Jscrambler API format.
52
48
 
53
- // Convert from command line option format to JScrambler API format.
54
49
  function mergeAndParseParams(commander, params) {
55
- var finalParams = (0, _lodash2.default)(params || {});
56
-
50
+ var finalParams = (0, _lodash.default)(params || {});
57
51
  Object.keys(isBoolFlag).forEach(function (name) {
58
52
  if (commander[name] !== undefined) {
59
- var snakeCaseName = (0, _snakeCase2.default)(name);
53
+ var snakeCaseName = (0, _snakeCase.default)(name);
54
+
60
55
  if (isBoolFlag[name] === true) {
61
56
  finalParams[snakeCaseName] = {
62
57
  status: 1
@@ -64,11 +59,11 @@ function mergeAndParseParams(commander, params) {
64
59
  } else {
65
60
  finalParams[snakeCaseName] = commander[name];
66
61
  }
62
+
67
63
  if (typeof finalParams[snakeCaseName].status === 'undefined') {
68
64
  finalParams[snakeCaseName].status = 1;
69
65
  }
70
66
  }
71
67
  });
72
-
73
68
  return finalParams;
74
69
  }