|
@@ -207,6 +207,14 @@ var Utils = function () {
|
|
|
value: function isInteger(number) {
|
|
|
return number % 1 === 0;
|
|
|
}
|
|
|
+ }, {
|
|
|
+ key: 'normalizeUrl',
|
|
|
+ value: function normalizeUrl(url) {
|
|
|
+ if (!url.endsWith('/')) {
|
|
|
+ url += '/';
|
|
|
+ }
|
|
|
+ return url;
|
|
|
+ }
|
|
|
}, {
|
|
|
key: 'strEnumify',
|
|
|
value: function strEnumify(obj) {
|
|
@@ -934,8 +942,8 @@ var JavaScriptObfuscatorInternal = function () {
|
|
|
_createClass(JavaScriptObfuscatorInternal, [{
|
|
|
key: 'getObfuscationResult',
|
|
|
value: function getObfuscationResult() {
|
|
|
- if (this.options.sourceMapBaseUrl) {
|
|
|
- this.setSourceMapUrl(this.options.sourceMapBaseUrl);
|
|
|
+ if (this.sourceMapUrl) {
|
|
|
+ this.sourceMapUrl = this.options.sourceMapBaseUrl + this.sourceMapUrl;
|
|
|
}
|
|
|
return new SourceMapCorrector_1.SourceMapCorrector(new ObfuscationResult_1.ObfuscationResult(this.generatorOutput.code, this.generatorOutput.map), this.sourceMapUrl, this.options.sourceMapMode).correct();
|
|
|
}
|
|
@@ -1545,7 +1553,7 @@ var JavaScriptObfuscatorCLI = function () {
|
|
|
value: function configureCommands() {
|
|
|
this.commands = new commander.Command().version(JavaScriptObfuscatorCLI.getBuildVersion(), '-v, --version').usage('<inputPath> [options]').option('-o, --output <path>', 'Output path for obfuscated code').option('--compact <boolean>', 'Disable one line output code compacting', JavaScriptObfuscatorCLI.parseBoolean).option('--debugProtection <boolean>', 'Disable browser Debug panel (can cause DevTools enabled browser freeze)', JavaScriptObfuscatorCLI.parseBoolean).option('--debugProtectionInterval <boolean>', 'Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)', JavaScriptObfuscatorCLI.parseBoolean).option('--disableConsoleOutput <boolean>', 'Allow console.log, console.info, console.error and console.warn messages output into browser console', JavaScriptObfuscatorCLI.parseBoolean).option('--encodeUnicodeLiterals <boolean>', 'All literals in Unicode array become encoded in Base64 (this option can slightly slow down your code speed)', JavaScriptObfuscatorCLI.parseBoolean).option('--reservedNames <list>', 'Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)', function (val) {
|
|
|
return val.split(',');
|
|
|
- }).option('--rotateUnicodeArray <boolean>', 'Disable rotation of unicode array values during obfuscation', JavaScriptObfuscatorCLI.parseBoolean).option('--selfDefending <boolean>', 'Disables self-defending for obfuscated code', JavaScriptObfuscatorCLI.parseBoolean).option('--sourceMap <boolean>', 'Enables source map generation', JavaScriptObfuscatorCLI.parseBoolean).option('--sourceMapBaseUrl <boolean>', 'Inserts custom Url for source map').option('--sourceMapMode <string> [inline, separate]', 'Specify source map output mode', JavaScriptObfuscatorCLI.parseSourceMapMode).option('--unicodeArray <boolean>', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', JavaScriptObfuscatorCLI.parseBoolean).option('--unicodeArrayThreshold <number>', 'The probability that the literal string will be inserted into unicodeArray (Default: 0.8, Min: 0, Max: 1)', parseFloat).option('--wrapUnicodeArrayCalls <boolean>', 'Disables usage of special access function instead of direct array call', JavaScriptObfuscatorCLI.parseBoolean).option('--domainLock <list>', 'Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)', function (val) {
|
|
|
+ }).option('--rotateUnicodeArray <boolean>', 'Disable rotation of unicode array values during obfuscation', JavaScriptObfuscatorCLI.parseBoolean).option('--selfDefending <boolean>', 'Disables self-defending for obfuscated code', JavaScriptObfuscatorCLI.parseBoolean).option('--sourceMap <boolean>', 'Enables source map generation', JavaScriptObfuscatorCLI.parseBoolean).option('--sourceMapBaseUrl <boolean>', 'Adds base url to the source map import url when `--sourceMapMode=separate`').option('--sourceMapMode <string> [inline, separate]', 'Specify source map output mode', JavaScriptObfuscatorCLI.parseSourceMapMode).option('--unicodeArray <boolean>', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', JavaScriptObfuscatorCLI.parseBoolean).option('--unicodeArrayThreshold <number>', 'The probability that the literal string will be inserted into unicodeArray (Default: 0.8, Min: 0, Max: 1)', parseFloat).option('--wrapUnicodeArrayCalls <boolean>', 'Disables usage of special access function instead of direct array call', JavaScriptObfuscatorCLI.parseBoolean).option('--domainLock <list>', 'Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)', function (val) {
|
|
|
return val.split(',');
|
|
|
}).parse(this.rawArguments);
|
|
|
this.commands.on('--help', function () {
|
|
@@ -3347,7 +3355,9 @@ var OptionsNormalizer = function () {
|
|
|
key: "sourceMapBaseUrl",
|
|
|
value: function sourceMapBaseUrl(options) {
|
|
|
if (options.sourceMapBaseUrl) {
|
|
|
- Object.assign(options, OptionsNormalizer.SOURCE_MAP_BASE_URL_OPTIONS);
|
|
|
+ Object.assign(options, {
|
|
|
+ sourceMapBaseUrl: Utils_1.Utils.normalizeUrl(options.sourceMapBaseUrl)
|
|
|
+ });
|
|
|
}
|
|
|
return options;
|
|
|
}
|
|
@@ -3387,9 +3397,6 @@ OptionsNormalizer.SELF_DEFENDING_OPTIONS = {
|
|
|
compact: true,
|
|
|
selfDefending: true
|
|
|
};
|
|
|
-OptionsNormalizer.SOURCE_MAP_BASE_URL_OPTIONS = {
|
|
|
- sourceMapMode: 'separate'
|
|
|
-};
|
|
|
OptionsNormalizer.normalizerRules = [OptionsNormalizer.domainLockRule, OptionsNormalizer.unicodeArrayRule, OptionsNormalizer.unicodeArrayThresholdRule, OptionsNormalizer.encodeUnicodeLiteralsRule, OptionsNormalizer.sourceMapBaseUrl, OptionsNormalizer.selfDefendingRule];
|
|
|
exports.OptionsNormalizer = OptionsNormalizer;
|
|
|
|