jscrambler 6.4.20 → 6.4.23
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 +14 -0
- package/dist/bin/jscrambler.js +154 -202
- package/dist/cleanup-input-fields.js +7 -8
- package/dist/client.js +69 -76
- package/dist/config.js +2 -3
- package/dist/constants.js +12 -10
- package/dist/generate-signed-params.js +13 -11
- package/dist/get-protection-default-fragments.js +42 -99
- package/dist/index.js +834 -1689
- package/dist/introspection.js +50 -172
- package/dist/mutations.js +70 -82
- package/dist/queries.js +33 -32
- package/dist/utils.js +2 -2
- package/dist/zip.js +110 -197
- package/package.json +27 -25
- /package/{LICENSE-MIT → LICENSE} +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# jscrambler
|
|
2
|
+
|
|
3
|
+
## 6.4.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [5cbeccd]: Set access to public on publishConfig
|
|
8
|
+
|
|
9
|
+
## 6.4.22
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [4fa2580]: Adjust transpilation settings to generate better code
|
|
14
|
+
- [4fa2580]: Infrastructure updates
|
package/dist/bin/jscrambler.js
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
require("core-js/modules/es.symbol.description.js");
|
|
5
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
6
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
5
7
|
var _commander = _interopRequireDefault(require("commander"));
|
|
6
8
|
var _lodash = _interopRequireDefault(require("lodash.defaults"));
|
|
7
9
|
var _path = _interopRequireDefault(require("path"));
|
|
8
10
|
var _filesizeParser = _interopRequireDefault(require("filesize-parser"));
|
|
9
|
-
var
|
|
11
|
+
var _config2 = _interopRequireDefault(require("../config"));
|
|
10
12
|
var _ = _interopRequireDefault(require("../"));
|
|
11
13
|
var _utils = require("../utils");
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
14
|
-
function
|
|
15
|
-
function
|
|
16
|
-
function
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
return val.toLowerCase();
|
|
27
|
-
};
|
|
15
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
19
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
|
+
const debug = !!process.env.DEBUG;
|
|
21
|
+
const validateBool = option => val => {
|
|
22
|
+
if (!/^(true|false)$/i.test(val)) {
|
|
23
|
+
console.error("*".concat(option, "* requires a <bool> value."));
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
return val.toLowerCase();
|
|
28
27
|
};
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const validateCodeHardeningThreshold = val => {
|
|
29
|
+
let inBytes;
|
|
31
30
|
try {
|
|
32
31
|
inBytes = (0, _filesizeParser.default)(val);
|
|
33
32
|
} catch (e) {
|
|
@@ -36,18 +35,18 @@ var validateCodeHardeningThreshold = function validateCodeHardeningThreshold(val
|
|
|
36
35
|
}
|
|
37
36
|
return inBytes;
|
|
38
37
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
const validateProfilingDataMode = mode => {
|
|
39
|
+
const availableModes = ['automatic', 'annotations', 'off'];
|
|
40
|
+
const normalizedMode = mode.toLowerCase();
|
|
42
41
|
if (!availableModes.includes(normalizedMode)) {
|
|
43
42
|
console.error("*profiling-data-mode* requires one of the following modes: {".concat(availableModes.toString(), "}. Example: --profiling-data-mode ").concat(availableModes[0]));
|
|
44
43
|
process.exit(1);
|
|
45
44
|
}
|
|
46
45
|
return normalizedMode;
|
|
47
46
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
const availableEnvironments = ['node', 'browser', 'isomorphic', 'automatic'];
|
|
48
|
+
const validateForceAppEnvironment = env => {
|
|
49
|
+
const normalizeEnvironment = env.toLowerCase();
|
|
51
50
|
if (!availableEnvironments.includes(normalizeEnvironment)) {
|
|
52
51
|
console.error("*force-app-environment* requires one of the following values: {".concat(availableEnvironments.toString(), "}. Example: --force-app-environment ").concat(availableEnvironments[0]));
|
|
53
52
|
process.exit(1);
|
|
@@ -55,7 +54,7 @@ var validateForceAppEnvironment = function validateForceAppEnvironment(env) {
|
|
|
55
54
|
return normalizeEnvironment;
|
|
56
55
|
};
|
|
57
56
|
_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.").parse(process.argv);
|
|
58
|
-
|
|
57
|
+
let globSrc, filesSrc, config;
|
|
59
58
|
|
|
60
59
|
// If -c, --config file was provided
|
|
61
60
|
if (_commander.default.config) {
|
|
@@ -118,7 +117,7 @@ if (_commander.default.forceAppEnvironment) {
|
|
|
118
117
|
} else {
|
|
119
118
|
config.forceAppEnvironment = config.forceAppEnvironment ? validateForceAppEnvironment(config.forceAppEnvironment) : undefined;
|
|
120
119
|
}
|
|
121
|
-
config = (0, _lodash.default)(config,
|
|
120
|
+
config = (0, _lodash.default)(config, _config2.default);
|
|
122
121
|
config.numberOfProtections = (0, _utils.validateNProtections)(_commander.default.N);
|
|
123
122
|
if (config.codeHardeningThreshold) {
|
|
124
123
|
config.codeHardeningThreshold = validateCodeHardeningThreshold(config.codeHardeningThreshold);
|
|
@@ -134,9 +133,9 @@ if (_commander.default.args.length > 0) {
|
|
|
134
133
|
if (globSrc && globSrc.length) {
|
|
135
134
|
// this will be translated to real files in the updateApplicationSources method
|
|
136
135
|
filesSrc = globSrc;
|
|
137
|
-
|
|
136
|
+
let nSources = 0;
|
|
138
137
|
// Iterate `globSrc` to build a list of source files into `filesSrc`
|
|
139
|
-
for (
|
|
138
|
+
for (let i = 0, l = globSrc.length; i < l; i += 1) {
|
|
140
139
|
// Calling sync `glob` because async is pointless for the CLI use case
|
|
141
140
|
// (as of now at least)
|
|
142
141
|
|
|
@@ -145,7 +144,7 @@ if (globSrc && globSrc.length) {
|
|
|
145
144
|
console.error('Please provide either a zip file containing all your source files or use the minimatch syntax');
|
|
146
145
|
process.exit(1);
|
|
147
146
|
}
|
|
148
|
-
|
|
147
|
+
const tmpGlob = (0, _utils.getMatchedFiles)(globSrc[i]);
|
|
149
148
|
if (config.werror && tmpGlob.length === 0) {
|
|
150
149
|
console.error("Pattern \"".concat(globSrc[i], "\" doesn't match any files."));
|
|
151
150
|
process.exit(1);
|
|
@@ -155,7 +154,7 @@ if (globSrc && globSrc.length) {
|
|
|
155
154
|
console.log("Pattern \"".concat(globSrc[i], "\" doesn't match any files. Will be ignored."));
|
|
156
155
|
} else {
|
|
157
156
|
console.log("Pattern \"".concat(globSrc[i], "\" matched the following files:"));
|
|
158
|
-
tmpGlob.forEach(
|
|
157
|
+
tmpGlob.forEach(file => {
|
|
159
158
|
console.log(" ".concat(file));
|
|
160
159
|
});
|
|
161
160
|
}
|
|
@@ -169,48 +168,47 @@ if (globSrc && globSrc.length) {
|
|
|
169
168
|
} else if (debug) {
|
|
170
169
|
console.log('No filesSrc provided. Using the ones in the application (if any).');
|
|
171
170
|
}
|
|
172
|
-
|
|
173
|
-
applicationId
|
|
174
|
-
accessKey
|
|
175
|
-
secretKey
|
|
176
|
-
filesDest
|
|
177
|
-
host
|
|
178
|
-
port
|
|
179
|
-
basePath
|
|
180
|
-
protocol
|
|
181
|
-
cafile
|
|
182
|
-
applicationTypes
|
|
183
|
-
languageSpecifications
|
|
184
|
-
areSubscribersOrdered
|
|
185
|
-
cwd
|
|
186
|
-
randomizationSeed
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
for (
|
|
213
|
-
var incompatibleOption = _incompatibleOptions[_i];
|
|
171
|
+
const {
|
|
172
|
+
applicationId,
|
|
173
|
+
accessKey,
|
|
174
|
+
secretKey,
|
|
175
|
+
filesDest,
|
|
176
|
+
host,
|
|
177
|
+
port,
|
|
178
|
+
basePath,
|
|
179
|
+
protocol,
|
|
180
|
+
cafile,
|
|
181
|
+
applicationTypes,
|
|
182
|
+
languageSpecifications,
|
|
183
|
+
areSubscribersOrdered,
|
|
184
|
+
cwd,
|
|
185
|
+
randomizationSeed,
|
|
186
|
+
sourceMaps = false,
|
|
187
|
+
useRecommendedOrder,
|
|
188
|
+
werror,
|
|
189
|
+
tolerateMinification,
|
|
190
|
+
jscramblerVersion,
|
|
191
|
+
debugMode,
|
|
192
|
+
proxy,
|
|
193
|
+
codeHardeningThreshold,
|
|
194
|
+
useProfilingData,
|
|
195
|
+
profilingDataMode,
|
|
196
|
+
browsers,
|
|
197
|
+
useAppClassification,
|
|
198
|
+
removeProfilingData,
|
|
199
|
+
skipSources,
|
|
200
|
+
inputSymbolTable,
|
|
201
|
+
utc,
|
|
202
|
+
entryPoint,
|
|
203
|
+
excludeList,
|
|
204
|
+
numberOfProtections,
|
|
205
|
+
ensureCodeAnnotation,
|
|
206
|
+
forceAppEnvironment
|
|
207
|
+
} = config;
|
|
208
|
+
const params = config.params;
|
|
209
|
+
const incompatibleOptions = ['sourceMaps', 'instrument', 'startProfiling', 'stopProfiling'];
|
|
210
|
+
const usedIncompatibleOptions = [];
|
|
211
|
+
for (const incompatibleOption of incompatibleOptions) {
|
|
214
212
|
if (_commander.default[incompatibleOption]) {
|
|
215
213
|
usedIncompatibleOptions.push(incompatibleOption);
|
|
216
214
|
}
|
|
@@ -219,158 +217,112 @@ if (usedIncompatibleOptions.length > 1) {
|
|
|
219
217
|
console.error('Using mutually exclusive options:', usedIncompatibleOptions);
|
|
220
218
|
process.exit(1);
|
|
221
219
|
}
|
|
222
|
-
|
|
220
|
+
const clientSettings = {
|
|
223
221
|
keys: {
|
|
224
|
-
accessKey
|
|
225
|
-
secretKey
|
|
222
|
+
accessKey,
|
|
223
|
+
secretKey
|
|
226
224
|
},
|
|
227
|
-
host
|
|
228
|
-
port
|
|
229
|
-
basePath
|
|
230
|
-
protocol
|
|
231
|
-
cafile
|
|
232
|
-
proxy
|
|
233
|
-
utc
|
|
234
|
-
jscramblerVersion
|
|
225
|
+
host,
|
|
226
|
+
port,
|
|
227
|
+
basePath,
|
|
228
|
+
protocol,
|
|
229
|
+
cafile,
|
|
230
|
+
proxy,
|
|
231
|
+
utc,
|
|
232
|
+
jscramblerVersion
|
|
235
233
|
};
|
|
236
234
|
if (_commander.default.sourceMaps) {
|
|
237
235
|
// Go, go, go download
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
case 3:
|
|
251
|
-
_context.next = 9;
|
|
252
|
-
break;
|
|
253
|
-
case 5:
|
|
254
|
-
_context.prev = 5;
|
|
255
|
-
_context.t0 = _context["catch"](0);
|
|
256
|
-
console.error(debug ? _context.t0 : _context.t0.message || _context.t0);
|
|
257
|
-
process.exit(1);
|
|
258
|
-
case 9:
|
|
259
|
-
case "end":
|
|
260
|
-
return _context.stop();
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}, _callee, null, [[0, 5]]);
|
|
264
|
-
}))();
|
|
236
|
+
(async () => {
|
|
237
|
+
try {
|
|
238
|
+
await _.default.downloadSourceMaps(_objectSpread(_objectSpread({}, clientSettings), {}, {
|
|
239
|
+
filesDest,
|
|
240
|
+
filesSrc,
|
|
241
|
+
protectionId: _commander.default.sourceMaps
|
|
242
|
+
}));
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error(debug ? error : error.message || error);
|
|
245
|
+
process.exit(1);
|
|
246
|
+
}
|
|
247
|
+
})();
|
|
265
248
|
} else if (_commander.default.outputSymbolTable) {
|
|
266
249
|
// Go, go, go download
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
case 3:
|
|
280
|
-
_context2.next = 9;
|
|
281
|
-
break;
|
|
282
|
-
case 5:
|
|
283
|
-
_context2.prev = 5;
|
|
284
|
-
_context2.t0 = _context2["catch"](0);
|
|
285
|
-
console.error(debug ? _context2.t0 : _context2.t0.message || _context2.t0);
|
|
286
|
-
process.exit(1);
|
|
287
|
-
case 9:
|
|
288
|
-
case "end":
|
|
289
|
-
return _context2.stop();
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}, _callee2, null, [[0, 5]]);
|
|
293
|
-
}))();
|
|
250
|
+
(async () => {
|
|
251
|
+
try {
|
|
252
|
+
await _.default.downloadSymbolTable(_objectSpread(_objectSpread({}, clientSettings), {}, {
|
|
253
|
+
filesDest,
|
|
254
|
+
filesSrc,
|
|
255
|
+
protectionId: _commander.default.outputSymbolTable
|
|
256
|
+
}));
|
|
257
|
+
} catch (error) {
|
|
258
|
+
console.error(debug ? error : error.message || error);
|
|
259
|
+
process.exit(1);
|
|
260
|
+
}
|
|
261
|
+
})();
|
|
294
262
|
} else if (_commander.default.instrument) {
|
|
295
263
|
_.default.instrumentAndDownload(_objectSpread(_objectSpread({}, clientSettings), {}, {
|
|
296
|
-
applicationId
|
|
297
|
-
filesSrc
|
|
298
|
-
filesDest
|
|
299
|
-
skipSources
|
|
300
|
-
cwd
|
|
301
|
-
})).catch(
|
|
264
|
+
applicationId,
|
|
265
|
+
filesSrc,
|
|
266
|
+
filesDest,
|
|
267
|
+
skipSources,
|
|
268
|
+
cwd
|
|
269
|
+
})).catch(error => {
|
|
302
270
|
console.error(debug ? error : error.message || error);
|
|
303
271
|
process.exit(1);
|
|
304
272
|
});
|
|
305
273
|
} else if (_commander.default.startProfiling) {
|
|
306
274
|
_.default.setProfilingState(_objectSpread(_objectSpread({}, clientSettings), {}, {
|
|
307
|
-
applicationId
|
|
308
|
-
}), 'RUNNING', 'STARTED', "Exercise your application and when you're finished run *--stop-profiling* command").catch(
|
|
275
|
+
applicationId
|
|
276
|
+
}), 'RUNNING', 'STARTED', "Exercise your application and when you're finished run *--stop-profiling* command").catch(error => {
|
|
309
277
|
console.error(debug ? error : error.message || error);
|
|
310
278
|
process.exit(1);
|
|
311
279
|
});
|
|
312
280
|
} else if (_commander.default.stopProfiling) {
|
|
313
281
|
_.default.setProfilingState(_objectSpread(_objectSpread({}, clientSettings), {}, {
|
|
314
|
-
applicationId
|
|
315
|
-
}), 'READY', 'STOPPED', 'Protect your application with 2 extra arguments: *--profiling-data-mode automatic* and *--skip-sources*').catch(
|
|
282
|
+
applicationId
|
|
283
|
+
}), 'READY', 'STOPPED', 'Protect your application with 2 extra arguments: *--profiling-data-mode automatic* and *--skip-sources*').catch(error => {
|
|
316
284
|
console.error(debug ? error : error.message || error);
|
|
317
285
|
process.exit(1);
|
|
318
286
|
});
|
|
319
287
|
} else {
|
|
320
288
|
// Go, go, go
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
forceAppEnvironment: forceAppEnvironment
|
|
354
|
-
});
|
|
355
|
-
_context3.prev = 1;
|
|
356
|
-
if (typeof werror !== 'undefined') {
|
|
357
|
-
protectAndDownloadOptions.bail = werror;
|
|
358
|
-
}
|
|
359
|
-
_context3.next = 5;
|
|
360
|
-
return _.default.protectAndDownload(protectAndDownloadOptions);
|
|
361
|
-
case 5:
|
|
362
|
-
_context3.next = 11;
|
|
363
|
-
break;
|
|
364
|
-
case 7:
|
|
365
|
-
_context3.prev = 7;
|
|
366
|
-
_context3.t0 = _context3["catch"](1);
|
|
367
|
-
console.error(debug ? _context3.t0 : _context3.t0.message || _context3.t0);
|
|
368
|
-
process.exit(1);
|
|
369
|
-
case 11:
|
|
370
|
-
case "end":
|
|
371
|
-
return _context3.stop();
|
|
372
|
-
}
|
|
289
|
+
(async () => {
|
|
290
|
+
const protectAndDownloadOptions = _objectSpread(_objectSpread({}, clientSettings), {}, {
|
|
291
|
+
applicationId,
|
|
292
|
+
filesSrc,
|
|
293
|
+
filesDest,
|
|
294
|
+
params,
|
|
295
|
+
applicationTypes,
|
|
296
|
+
languageSpecifications,
|
|
297
|
+
areSubscribersOrdered,
|
|
298
|
+
cwd,
|
|
299
|
+
sourceMaps,
|
|
300
|
+
randomizationSeed,
|
|
301
|
+
useRecommendedOrder,
|
|
302
|
+
tolerateMinification,
|
|
303
|
+
debugMode,
|
|
304
|
+
codeHardeningThreshold,
|
|
305
|
+
useProfilingData,
|
|
306
|
+
profilingDataMode,
|
|
307
|
+
browsers,
|
|
308
|
+
useAppClassification,
|
|
309
|
+
skipSources,
|
|
310
|
+
removeProfilingData,
|
|
311
|
+
inputSymbolTable,
|
|
312
|
+
entryPoint,
|
|
313
|
+
excludeList,
|
|
314
|
+
ensureCodeAnnotation,
|
|
315
|
+
numberOfProtections,
|
|
316
|
+
forceAppEnvironment
|
|
317
|
+
});
|
|
318
|
+
try {
|
|
319
|
+
if (typeof werror !== 'undefined') {
|
|
320
|
+
protectAndDownloadOptions.bail = werror;
|
|
373
321
|
}
|
|
374
|
-
|
|
375
|
-
|
|
322
|
+
await _.default.protectAndDownload(protectAndDownloadOptions);
|
|
323
|
+
} catch (error) {
|
|
324
|
+
console.error(debug ? error : error.message || error);
|
|
325
|
+
process.exit(1);
|
|
326
|
+
}
|
|
327
|
+
})();
|
|
376
328
|
}
|
|
@@ -4,16 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = cleanupInputFields;
|
|
7
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
8
|
+
require("core-js/modules/es.string.replace.js");
|
|
9
|
+
require("core-js/modules/es.regexp.constructor.js");
|
|
7
10
|
function cleanupInputFields(args, fragments) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return arg.name === 'data';
|
|
12
|
-
});
|
|
11
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
12
|
+
let cleanedUpFragments = fragments;
|
|
13
|
+
const dataArg = args.find(arg => arg.name === 'data');
|
|
13
14
|
function fieldCleanUp(field) {
|
|
14
|
-
|
|
15
|
-
return e.name === field;
|
|
16
|
-
});
|
|
15
|
+
const hasFieldArg = dataArg && dataArg.type.inputFields.some(e => e.name === field);
|
|
17
16
|
if (!hasFieldArg && typeof options[field] !== 'undefined') {
|
|
18
17
|
options[field] = undefined;
|
|
19
18
|
cleanedUpFragments = cleanedUpFragments.replace(new RegExp(",?[s|\n]*".concat(field)), '');
|