jscrambler 6.1.0 → 6.1.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/dist/bin/jscrambler.js +106 -133
- package/dist/cleanup-input-fields.js +4 -7
- package/dist/cli.js +8 -13
- package/dist/client.js +105 -84
- package/dist/config.js +7 -8
- package/dist/constants.js +10 -8
- package/dist/generate-signed-params.js +21 -26
- package/dist/get-protection-default-fragments.js +50 -50
- package/dist/index.js +631 -917
- package/dist/introspection.js +66 -66
- package/dist/mutations.js +70 -79
- package/dist/queries.js +38 -36
- package/dist/utils.js +11 -12
- package/dist/zip.js +152 -124
- package/package.json +7 -6
package/dist/bin/jscrambler.js
CHANGED
|
@@ -1,67 +1,66 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
"use strict";
|
|
3
3
|
|
|
4
|
-
var _commander = require(
|
|
4
|
+
var _commander = _interopRequireDefault(require("commander"));
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _lodash = _interopRequireDefault(require("lodash.defaults"));
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _filesizeParser = _interopRequireDefault(require("filesize-parser"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _config3 = _interopRequireDefault(require("../config"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _ = _interopRequireDefault(require("../"));
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _cli = require("../cli");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _utils = require("../utils");
|
|
19
19
|
|
|
20
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
46
|
+
var inBytes;
|
|
47
|
+
|
|
49
48
|
try {
|
|
50
|
-
inBytes = (0,
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
|
86
|
-
filesSrc = void 0,
|
|
87
|
-
config = void 0;
|
|
85
|
+
var globSrc, filesSrc, config; // If -c, --config file was provided
|
|
88
86
|
|
|
89
|
-
|
|
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(
|
|
90
|
+
config = require(_path.default.resolve(_commander.default.config, '.'));
|
|
94
91
|
} else {
|
|
95
92
|
config = {};
|
|
96
93
|
}
|
|
97
94
|
|
|
98
|
-
config.accessKey =
|
|
99
|
-
config.secretKey =
|
|
100
|
-
config.host =
|
|
101
|
-
config.port =
|
|
102
|
-
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 =
|
|
105
|
-
config.cafile =
|
|
106
|
-
config.filesDest =
|
|
107
|
-
config.applicationId =
|
|
108
|
-
config.randomizationSeed =
|
|
109
|
-
config.cwd =
|
|
110
|
-
config.useRecommendedOrder =
|
|
111
|
-
config.tolerateMinification =
|
|
112
|
-
config.werror =
|
|
113
|
-
config.jscramblerVersion =
|
|
114
|
-
config.inputSymbolTable =
|
|
115
|
-
config.removeProfilingData =
|
|
116
|
-
config.skipSources =
|
|
117
|
-
config.debugMode =
|
|
118
|
-
|
|
119
|
-
|
|
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 =
|
|
119
|
+
config.codeHardeningThreshold = _commander.default.codeHardeningThreshold;
|
|
124
120
|
}
|
|
125
121
|
|
|
126
|
-
if (
|
|
127
|
-
config.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 (
|
|
133
|
-
config.utc =
|
|
128
|
+
if (_commander.default.utc) {
|
|
129
|
+
config.utc = _commander.default.utc !== 'false';
|
|
134
130
|
}
|
|
135
131
|
|
|
136
|
-
if (
|
|
137
|
-
config.useProfilingData =
|
|
132
|
+
if (_commander.default.useProfilingData) {
|
|
133
|
+
config.useProfilingData = _commander.default.useProfilingData !== 'false';
|
|
138
134
|
}
|
|
139
135
|
|
|
140
|
-
if (
|
|
141
|
-
config.useAppClassification =
|
|
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,15 +142,14 @@ if (config.jscramblerVersion && !/^(?:\d+\.\d+(?:-f)?|stable|latest)$/.test(conf
|
|
|
146
142
|
process.exit(1);
|
|
147
143
|
}
|
|
148
144
|
|
|
149
|
-
if (
|
|
150
|
-
config.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,
|
|
156
|
-
|
|
157
|
-
config.numberOfProtections = (0, _utils.validateNProtections)(_commander2.default.N);
|
|
151
|
+
config = (0, _lodash.default)(config, _config3.default);
|
|
152
|
+
config.numberOfProtections = (0, _utils.validateNProtections)(_commander.default.N);
|
|
158
153
|
|
|
159
154
|
if (config.codeHardeningThreshold) {
|
|
160
155
|
config.codeHardeningThreshold = validateCodeHardeningThreshold(config.codeHardeningThreshold);
|
|
@@ -164,23 +159,22 @@ if (config.profilingDataMode) {
|
|
|
164
159
|
config.profilingDataMode = validateProfilingDataMode(config.profilingDataMode);
|
|
165
160
|
}
|
|
166
161
|
|
|
167
|
-
globSrc = config.filesSrc;
|
|
168
|
-
|
|
169
|
-
if (
|
|
170
|
-
globSrc =
|
|
162
|
+
globSrc = config.filesSrc; // If src paths have been provided
|
|
163
|
+
|
|
164
|
+
if (_commander.default.args.length > 0) {
|
|
165
|
+
globSrc = _commander.default.args;
|
|
171
166
|
}
|
|
172
167
|
|
|
173
168
|
if (globSrc && globSrc.length) {
|
|
174
169
|
// this will be translated to real files in the updateApplicationSources method
|
|
175
170
|
filesSrc = globSrc;
|
|
176
|
-
var nSources = 0;
|
|
177
|
-
|
|
171
|
+
var nSources = 0; // Iterate `globSrc` to build a list of source files into `filesSrc`
|
|
172
|
+
|
|
178
173
|
for (var i = 0, l = globSrc.length; i < l; i += 1) {
|
|
179
174
|
// Calling sync `glob` because async is pointless for the CLI use case
|
|
180
175
|
// (as of now at least)
|
|
181
|
-
|
|
182
176
|
// If the user is providing a zip alongside more files
|
|
183
|
-
if (
|
|
177
|
+
if (_path.default.extname(globSrc[i]) === '.zip' && globSrc.length > 1) {
|
|
184
178
|
console.error('Please provide either a zip file containing all your source files or use the minimatch syntax');
|
|
185
179
|
process.exit(1);
|
|
186
180
|
}
|
|
@@ -188,22 +182,24 @@ if (globSrc && globSrc.length) {
|
|
|
188
182
|
var tmpGlob = (0, _utils.getMatchedFiles)(globSrc[i]);
|
|
189
183
|
|
|
190
184
|
if (config.werror && tmpGlob.length === 0) {
|
|
191
|
-
console.error(
|
|
185
|
+
console.error("Pattern \"".concat(globSrc[i], "\" doesn't match any files."));
|
|
192
186
|
process.exit(1);
|
|
193
187
|
}
|
|
194
188
|
|
|
195
189
|
if (debug) {
|
|
196
190
|
if (tmpGlob.length === 0) {
|
|
197
|
-
console.log(
|
|
191
|
+
console.log("Pattern \"".concat(globSrc[i], "\" doesn't match any files. Will be ignored."));
|
|
198
192
|
} else {
|
|
199
|
-
console.log(
|
|
193
|
+
console.log("Pattern \"".concat(globSrc[i], "\" matched the following files:"));
|
|
200
194
|
tmpGlob.forEach(function (file) {
|
|
201
|
-
console.log(
|
|
195
|
+
console.log(" ".concat(file));
|
|
202
196
|
});
|
|
203
197
|
}
|
|
204
198
|
}
|
|
199
|
+
|
|
205
200
|
nSources += tmpGlob.length;
|
|
206
201
|
}
|
|
202
|
+
|
|
207
203
|
if (nSources === 0) {
|
|
208
204
|
console.error('No files matched.');
|
|
209
205
|
process.exit(1);
|
|
@@ -228,7 +224,7 @@ var _config2 = config,
|
|
|
228
224
|
cwd = _config2.cwd,
|
|
229
225
|
randomizationSeed = _config2.randomizationSeed,
|
|
230
226
|
_config2$sourceMaps = _config2.sourceMaps,
|
|
231
|
-
sourceMaps = _config2$sourceMaps ===
|
|
227
|
+
sourceMaps = _config2$sourceMaps === void 0 ? false : _config2$sourceMaps,
|
|
232
228
|
useRecommendedOrder = _config2.useRecommendedOrder,
|
|
233
229
|
werror = _config2.werror,
|
|
234
230
|
tolerateMinification = _config2.tolerateMinification,
|
|
@@ -248,36 +244,15 @@ var _config2 = config,
|
|
|
248
244
|
excludeList = _config2.excludeList,
|
|
249
245
|
numberOfProtections = _config2.numberOfProtections,
|
|
250
246
|
forceAppEnvironment = _config2.forceAppEnvironment;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
var params = (0, _cli.mergeAndParseParams)(_commander2.default, config.params);
|
|
254
|
-
|
|
247
|
+
var params = (0, _cli.mergeAndParseParams)(_commander.default, config.params);
|
|
255
248
|
var incompatibleOptions = ['sourceMaps', 'instrument', 'startProfiling', 'stopProfiling'];
|
|
256
249
|
var usedIncompatibleOptions = [];
|
|
257
|
-
var _iteratorNormalCompletion = true;
|
|
258
|
-
var _didIteratorError = false;
|
|
259
|
-
var _iteratorError = undefined;
|
|
260
250
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
var incompatibleOption = _step.value;
|
|
251
|
+
for (var _i = 0, _incompatibleOptions = incompatibleOptions; _i < _incompatibleOptions.length; _i++) {
|
|
252
|
+
var incompatibleOption = _incompatibleOptions[_i];
|
|
264
253
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
} catch (err) {
|
|
270
|
-
_didIteratorError = true;
|
|
271
|
-
_iteratorError = err;
|
|
272
|
-
} finally {
|
|
273
|
-
try {
|
|
274
|
-
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
275
|
-
_iterator.return();
|
|
276
|
-
}
|
|
277
|
-
} finally {
|
|
278
|
-
if (_didIteratorError) {
|
|
279
|
-
throw _iteratorError;
|
|
280
|
-
}
|
|
254
|
+
if (_commander.default[incompatibleOption]) {
|
|
255
|
+
usedIncompatibleOptions.push(incompatibleOption);
|
|
281
256
|
}
|
|
282
257
|
}
|
|
283
258
|
|
|
@@ -301,7 +276,7 @@ var clientSettings = {
|
|
|
301
276
|
jscramblerVersion: jscramblerVersion
|
|
302
277
|
};
|
|
303
278
|
|
|
304
|
-
if (
|
|
279
|
+
if (_commander.default.sourceMaps) {
|
|
305
280
|
// Go, go, go download
|
|
306
281
|
_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
307
282
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -310,10 +285,10 @@ if (_commander2.default.sourceMaps) {
|
|
|
310
285
|
case 0:
|
|
311
286
|
_context.prev = 0;
|
|
312
287
|
_context.next = 3;
|
|
313
|
-
return
|
|
288
|
+
return _.default.downloadSourceMaps(_objectSpread(_objectSpread({}, clientSettings), {}, {
|
|
314
289
|
filesDest: filesDest,
|
|
315
290
|
filesSrc: filesSrc,
|
|
316
|
-
protectionId:
|
|
291
|
+
protectionId: _commander.default.sourceMaps
|
|
317
292
|
}));
|
|
318
293
|
|
|
319
294
|
case 3:
|
|
@@ -322,19 +297,18 @@ if (_commander2.default.sourceMaps) {
|
|
|
322
297
|
|
|
323
298
|
case 5:
|
|
324
299
|
_context.prev = 5;
|
|
325
|
-
_context.t0 = _context[
|
|
326
|
-
|
|
300
|
+
_context.t0 = _context["catch"](0);
|
|
327
301
|
console.error(debug ? _context.t0 : _context.t0.message || _context.t0);
|
|
328
302
|
process.exit(1);
|
|
329
303
|
|
|
330
304
|
case 9:
|
|
331
|
-
case
|
|
305
|
+
case "end":
|
|
332
306
|
return _context.stop();
|
|
333
307
|
}
|
|
334
308
|
}
|
|
335
|
-
}, _callee,
|
|
309
|
+
}, _callee, null, [[0, 5]]);
|
|
336
310
|
}))();
|
|
337
|
-
} else if (
|
|
311
|
+
} else if (_commander.default.outputSymbolTable) {
|
|
338
312
|
// Go, go, go download
|
|
339
313
|
_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
340
314
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
@@ -343,10 +317,10 @@ if (_commander2.default.sourceMaps) {
|
|
|
343
317
|
case 0:
|
|
344
318
|
_context2.prev = 0;
|
|
345
319
|
_context2.next = 3;
|
|
346
|
-
return
|
|
320
|
+
return _.default.downloadSymbolTable(_objectSpread(_objectSpread({}, clientSettings), {}, {
|
|
347
321
|
filesDest: filesDest,
|
|
348
322
|
filesSrc: filesSrc,
|
|
349
|
-
protectionId:
|
|
323
|
+
protectionId: _commander.default.outputSymbolTable
|
|
350
324
|
}));
|
|
351
325
|
|
|
352
326
|
case 3:
|
|
@@ -355,20 +329,19 @@ if (_commander2.default.sourceMaps) {
|
|
|
355
329
|
|
|
356
330
|
case 5:
|
|
357
331
|
_context2.prev = 5;
|
|
358
|
-
_context2.t0 = _context2[
|
|
359
|
-
|
|
332
|
+
_context2.t0 = _context2["catch"](0);
|
|
360
333
|
console.error(debug ? _context2.t0 : _context2.t0.message || _context2.t0);
|
|
361
334
|
process.exit(1);
|
|
362
335
|
|
|
363
336
|
case 9:
|
|
364
|
-
case
|
|
337
|
+
case "end":
|
|
365
338
|
return _context2.stop();
|
|
366
339
|
}
|
|
367
340
|
}
|
|
368
|
-
}, _callee2,
|
|
341
|
+
}, _callee2, null, [[0, 5]]);
|
|
369
342
|
}))();
|
|
370
|
-
} else if (
|
|
371
|
-
|
|
343
|
+
} else if (_commander.default.instrument) {
|
|
344
|
+
_.default.instrumentAndDownload(_objectSpread(_objectSpread({}, clientSettings), {}, {
|
|
372
345
|
applicationId: applicationId,
|
|
373
346
|
filesSrc: filesSrc,
|
|
374
347
|
filesDest: filesDest,
|
|
@@ -378,15 +351,15 @@ if (_commander2.default.sourceMaps) {
|
|
|
378
351
|
console.error(debug ? error : error.message || error);
|
|
379
352
|
process.exit(1);
|
|
380
353
|
});
|
|
381
|
-
} else if (
|
|
382
|
-
|
|
354
|
+
} else if (_commander.default.startProfiling) {
|
|
355
|
+
_.default.setProfilingState(_objectSpread(_objectSpread({}, clientSettings), {}, {
|
|
383
356
|
applicationId: applicationId
|
|
384
357
|
}), 'RUNNING', 'STARTED', "Exercise your application and when you're finished run *--stop-profiling* command").catch(function (error) {
|
|
385
358
|
console.error(debug ? error : error.message || error);
|
|
386
359
|
process.exit(1);
|
|
387
360
|
});
|
|
388
|
-
} else if (
|
|
389
|
-
|
|
361
|
+
} else if (_commander.default.stopProfiling) {
|
|
362
|
+
_.default.setProfilingState(_objectSpread(_objectSpread({}, clientSettings), {}, {
|
|
390
363
|
applicationId: applicationId
|
|
391
364
|
}), 'READY', 'STOPPED', 'Protect your application with 2 extra arguments: *--profiling-data-mode automatic* and *--skip-sources*').catch(function (error) {
|
|
392
365
|
console.error(debug ? error : error.message || error);
|
|
@@ -400,7 +373,7 @@ if (_commander2.default.sourceMaps) {
|
|
|
400
373
|
while (1) {
|
|
401
374
|
switch (_context3.prev = _context3.next) {
|
|
402
375
|
case 0:
|
|
403
|
-
protectAndDownloadOptions =
|
|
376
|
+
protectAndDownloadOptions = _objectSpread(_objectSpread({}, clientSettings), {}, {
|
|
404
377
|
applicationId: applicationId,
|
|
405
378
|
filesSrc: filesSrc,
|
|
406
379
|
filesDest: filesDest,
|
|
@@ -432,8 +405,9 @@ if (_commander2.default.sourceMaps) {
|
|
|
432
405
|
if (typeof werror !== 'undefined') {
|
|
433
406
|
protectAndDownloadOptions.bail = werror;
|
|
434
407
|
}
|
|
408
|
+
|
|
435
409
|
_context3.next = 5;
|
|
436
|
-
return
|
|
410
|
+
return _.default.protectAndDownload(protectAndDownloadOptions);
|
|
437
411
|
|
|
438
412
|
case 5:
|
|
439
413
|
_context3.next = 11;
|
|
@@ -441,16 +415,15 @@ if (_commander2.default.sourceMaps) {
|
|
|
441
415
|
|
|
442
416
|
case 7:
|
|
443
417
|
_context3.prev = 7;
|
|
444
|
-
_context3.t0 = _context3[
|
|
445
|
-
|
|
418
|
+
_context3.t0 = _context3["catch"](1);
|
|
446
419
|
console.error(debug ? _context3.t0 : _context3.t0.message || _context3.t0);
|
|
447
420
|
process.exit(1);
|
|
448
421
|
|
|
449
422
|
case 11:
|
|
450
|
-
case
|
|
423
|
+
case "end":
|
|
451
424
|
return _context3.stop();
|
|
452
425
|
}
|
|
453
426
|
}
|
|
454
|
-
}, _callee3,
|
|
427
|
+
}, _callee3, null, [[1, 7]]);
|
|
455
428
|
}))();
|
|
456
429
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
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(
|
|
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
|
-
|
|
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(
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash.clone"));
|
|
9
9
|
|
|
10
|
-
var
|
|
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,
|
|
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,
|
|
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
|
}
|