Sfoglia il codice sorgente

Merge pull request #533 from javascript-obfuscator/source-map-browser-only-revert

Reverted validation errors under `node` target for `sourceMap*` options
Timofey Kachalov 5 anni fa
parent
commit
48f7d2c188

+ 4 - 0
CHANGELOG.md

@@ -1,5 +1,9 @@
 Change Log
 Change Log
 
 
+v0.24.2
+---
+* Reverted validation errors under `node` target for `sourceMap*` options
+
 v0.24.1
 v0.24.1
 ---
 ---
 * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/531
 * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/531

File diff suppressed because it is too large
+ 0 - 0
dist/index.browser.js


File diff suppressed because it is too large
+ 0 - 0
dist/index.cli.js


File diff suppressed because it is too large
+ 0 - 0
dist/index.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "javascript-obfuscator",
   "name": "javascript-obfuscator",
-  "version": "0.24.1",
+  "version": "0.24.2",
   "description": "JavaScript obfuscator",
   "description": "JavaScript obfuscator",
   "keywords": [
   "keywords": [
     "obfuscator",
     "obfuscator",

+ 0 - 16
src/options/Options.ts

@@ -209,10 +209,6 @@ export class Options implements IOptions {
      * @type {boolean}
      * @type {boolean}
      */
      */
     @IsBoolean()
     @IsBoolean()
-    @IsAllowedForObfuscationTargets([
-        ObfuscationTarget.Browser,
-        ObfuscationTarget.BrowserNoEval,
-    ])
     public readonly sourceMap!: boolean;
     public readonly sourceMap!: boolean;
 
 
     /**
     /**
@@ -225,30 +221,18 @@ export class Options implements IOptions {
         require_tld: false,
         require_tld: false,
         require_valid_protocol: true
         require_valid_protocol: true
     })
     })
-    @IsAllowedForObfuscationTargets([
-        ObfuscationTarget.Browser,
-        ObfuscationTarget.BrowserNoEval,
-    ])
     public readonly sourceMapBaseUrl!: string;
     public readonly sourceMapBaseUrl!: string;
 
 
     /**
     /**
      * @type {string}
      * @type {string}
      */
      */
     @IsString()
     @IsString()
-    @IsAllowedForObfuscationTargets([
-        ObfuscationTarget.Browser,
-        ObfuscationTarget.BrowserNoEval,
-    ])
     public readonly sourceMapFileName!: string;
     public readonly sourceMapFileName!: string;
 
 
     /**
     /**
      * @type {SourceMapMode}
      * @type {SourceMapMode}
      */
      */
     @IsIn([SourceMapMode.Inline, SourceMapMode.Separate])
     @IsIn([SourceMapMode.Inline, SourceMapMode.Separate])
-    @IsAllowedForObfuscationTargets([
-        ObfuscationTarget.Browser,
-        ObfuscationTarget.BrowserNoEval,
-    ])
     public readonly sourceMapMode!: TypeFromEnum<typeof SourceMapMode>;
     public readonly sourceMapMode!: TypeFromEnum<typeof SourceMapMode>;
 
 
     /**
     /**

+ 0 - 72
test/functional-tests/options/source-map-base-url/Validation.spec.ts

@@ -1,72 +0,0 @@
-import { assert } from 'chai';
-
-import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';
-
-import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
-
-import { ObfuscationTarget } from '../../../../src/enums/ObfuscationTarget';
-
-describe('`sourceMapBaseUrl` validation', () => {
-    describe('IsAllowedForObfuscationTarget', () => {
-        describe('Variant #1: positive validation', () => {
-            describe('Variant #1: obfuscation target: `browser`', () => {
-                let testFunc: () => string;
-
-                beforeEach(() => {
-                    testFunc = () => JavaScriptObfuscator.obfuscate(
-                        '',
-                        {
-                            ...NO_ADDITIONAL_NODES_PRESET,
-                            sourceMapBaseUrl: 'http://www.example.com',
-                            target: ObfuscationTarget.Browser
-                        }
-                    ).getObfuscatedCode();
-                });
-
-                it('should pass validation when obfuscation target is `browser`', () => {
-                    assert.doesNotThrow(testFunc);
-                });
-            });
-
-            describe('Variant #2: obfuscation target: `node` and default value', () => {
-                let testFunc: () => string;
-
-                beforeEach(() => {
-                    testFunc = () => JavaScriptObfuscator.obfuscate(
-                        '',
-                        {
-                            ...NO_ADDITIONAL_NODES_PRESET,
-                            sourceMapBaseUrl: '',
-                            target: ObfuscationTarget.Node
-                        }
-                    ).getObfuscatedCode();
-                });
-
-                it('should pass validation when obfuscation target is `node` and value is default', () => {
-                    assert.doesNotThrow(testFunc);
-                });
-            });
-        });
-
-        describe('Variant #2: negative validation', () => {
-            const expectedError: string = 'This option allowed only for obfuscation targets';
-
-            let testFunc: () => string;
-
-            beforeEach(() => {
-                testFunc = () => JavaScriptObfuscator.obfuscate(
-                    '',
-                    {
-                        ...NO_ADDITIONAL_NODES_PRESET,
-                        sourceMapBaseUrl: 'http://www.example.com',
-                        target: ObfuscationTarget.Node
-                    }
-                ).getObfuscatedCode();
-            });
-
-            it('should not pass validation when obfuscation target is `node` and value is not default', () => {
-                assert.throws(testFunc, expectedError);
-            });
-        });
-    });
-});

+ 0 - 72
test/functional-tests/options/source-map-file-name/Validation.spec.ts

@@ -1,72 +0,0 @@
-import { assert } from 'chai';
-
-import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';
-
-import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
-
-import { ObfuscationTarget } from '../../../../src/enums/ObfuscationTarget';
-
-describe('`sourceMapFileName` validation', () => {
-    describe('IsAllowedForObfuscationTarget', () => {
-        describe('Variant #1: positive validation', () => {
-            describe('Variant #1: obfuscation target: `browser`', () => {
-                let testFunc: () => string;
-
-                beforeEach(() => {
-                    testFunc = () => JavaScriptObfuscator.obfuscate(
-                        '',
-                        {
-                            ...NO_ADDITIONAL_NODES_PRESET,
-                            sourceMapFileName: 'foo',
-                            target: ObfuscationTarget.Browser
-                        }
-                    ).getObfuscatedCode();
-                });
-
-                it('should pass validation when obfuscation target is `browser`', () => {
-                    assert.doesNotThrow(testFunc);
-                });
-            });
-
-            describe('Variant #2: obfuscation target: `node` and default value', () => {
-                let testFunc: () => string;
-
-                beforeEach(() => {
-                    testFunc = () => JavaScriptObfuscator.obfuscate(
-                        '',
-                        {
-                            ...NO_ADDITIONAL_NODES_PRESET,
-                            sourceMapFileName: '',
-                            target: ObfuscationTarget.Node
-                        }
-                    ).getObfuscatedCode();
-                });
-
-                it('should pass validation when obfuscation target is `node` and value is default', () => {
-                    assert.doesNotThrow(testFunc);
-                });
-            });
-        });
-
-        describe('Variant #2: negative validation', () => {
-            const expectedError: string = 'This option allowed only for obfuscation targets';
-
-            let testFunc: () => string;
-
-            beforeEach(() => {
-                testFunc = () => JavaScriptObfuscator.obfuscate(
-                    '',
-                    {
-                        ...NO_ADDITIONAL_NODES_PRESET,
-                        sourceMapFileName: 'foo',
-                        target: ObfuscationTarget.Node
-                    }
-                ).getObfuscatedCode();
-            });
-
-            it('should not pass validation when obfuscation target is `node` and value is not default', () => {
-                assert.throws(testFunc, expectedError);
-            });
-        });
-    });
-});

+ 0 - 73
test/functional-tests/options/source-map-mode/Validation.spec.ts

@@ -1,73 +0,0 @@
-import { assert } from 'chai';
-
-import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';
-
-import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
-
-import { ObfuscationTarget } from '../../../../src/enums/ObfuscationTarget';
-import { SourceMapMode } from '../../../../src/enums/source-map/SourceMapMode';
-
-describe('`sourceMapMode` validation', () => {
-    describe('IsAllowedForObfuscationTarget', () => {
-        describe('Variant #1: positive validation', () => {
-            describe('Variant #1: obfuscation target: `browser`', () => {
-                let testFunc: () => string;
-
-                beforeEach(() => {
-                    testFunc = () => JavaScriptObfuscator.obfuscate(
-                        '',
-                        {
-                            ...NO_ADDITIONAL_NODES_PRESET,
-                            sourceMapMode: SourceMapMode.Inline,
-                            target: ObfuscationTarget.Browser
-                        }
-                    ).getObfuscatedCode();
-                });
-
-                it('should pass validation when obfuscation target is `browser`', () => {
-                    assert.doesNotThrow(testFunc);
-                });
-            });
-
-            describe('Variant #2: obfuscation target: `node` and default value', () => {
-                let testFunc: () => string;
-
-                beforeEach(() => {
-                    testFunc = () => JavaScriptObfuscator.obfuscate(
-                        '',
-                        {
-                            ...NO_ADDITIONAL_NODES_PRESET,
-                            sourceMapMode: SourceMapMode.Separate,
-                            target: ObfuscationTarget.Node
-                        }
-                    ).getObfuscatedCode();
-                });
-
-                it('should pass validation when obfuscation target is `node` and value is default', () => {
-                    assert.doesNotThrow(testFunc);
-                });
-            });
-        });
-
-        describe('Variant #2: negative validation', () => {
-            const expectedError: string = 'This option allowed only for obfuscation targets';
-
-            let testFunc: () => string;
-
-            beforeEach(() => {
-                testFunc = () => JavaScriptObfuscator.obfuscate(
-                    '',
-                    {
-                        ...NO_ADDITIONAL_NODES_PRESET,
-                        sourceMapMode: SourceMapMode.Inline,
-                        target: ObfuscationTarget.Node
-                    }
-                ).getObfuscatedCode();
-            });
-
-            it('should not pass validation when obfuscation target is `node` and value is not default', () => {
-                assert.throws(testFunc, expectedError);
-            });
-        });
-    });
-});

+ 0 - 72
test/functional-tests/options/source-map/Validation.spec.ts

@@ -1,72 +0,0 @@
-import { assert } from 'chai';
-
-import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';
-
-import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
-
-import { ObfuscationTarget } from '../../../../src/enums/ObfuscationTarget';
-
-describe('`sourceMap` validation', () => {
-    describe('IsAllowedForObfuscationTarget', () => {
-        describe('Variant #1: positive validation', () => {
-            describe('Variant #1: obfuscation target: `browser`', () => {
-                let testFunc: () => string;
-
-                beforeEach(() => {
-                    testFunc = () => JavaScriptObfuscator.obfuscate(
-                        '',
-                        {
-                            ...NO_ADDITIONAL_NODES_PRESET,
-                            sourceMap: true,
-                            target: ObfuscationTarget.Browser
-                        }
-                    ).getObfuscatedCode();
-                });
-
-                it('should pass validation when obfuscation target is `browser`', () => {
-                    assert.doesNotThrow(testFunc);
-                });
-            });
-
-            describe('Variant #2: obfuscation target: `node` and default value', () => {
-                let testFunc: () => string;
-
-                beforeEach(() => {
-                    testFunc = () => JavaScriptObfuscator.obfuscate(
-                        '',
-                        {
-                            ...NO_ADDITIONAL_NODES_PRESET,
-                            sourceMap: false,
-                            target: ObfuscationTarget.Node
-                        }
-                    ).getObfuscatedCode();
-                });
-
-                it('should pass validation when obfuscation target is `node` and value is default', () => {
-                    assert.doesNotThrow(testFunc);
-                });
-            });
-        });
-
-        describe('Variant #2: negative validation', () => {
-            const expectedError: string = 'This option allowed only for obfuscation targets';
-
-            let testFunc: () => string;
-
-            beforeEach(() => {
-                testFunc = () => JavaScriptObfuscator.obfuscate(
-                    '',
-                    {
-                        ...NO_ADDITIONAL_NODES_PRESET,
-                        sourceMap: true,
-                        target: ObfuscationTarget.Node
-                    }
-                ).getObfuscatedCode();
-            });
-
-            it('should not pass validation when obfuscation target is `node` and value is not default', () => {
-                assert.throws(testFunc, expectedError);
-            });
-        });
-    });
-});

+ 0 - 4
test/index.spec.ts

@@ -91,10 +91,6 @@ import './functional-tests/node-transformers/preparing-transformers/obfuscating-
 import './functional-tests/node-transformers/preparing-transformers/obfuscating-guards/reserved-string-obfuscating-guard/ReservedStringObfuscatingGuard.spec';
 import './functional-tests/node-transformers/preparing-transformers/obfuscating-guards/reserved-string-obfuscating-guard/ReservedStringObfuscatingGuard.spec';
 import './functional-tests/options/OptionsNormalizer.spec';
 import './functional-tests/options/OptionsNormalizer.spec';
 import './functional-tests/options/domain-lock/Validation.spec';
 import './functional-tests/options/domain-lock/Validation.spec';
-import './functional-tests/options/source-map/Validation.spec';
-import './functional-tests/options/source-map-base-url/Validation.spec';
-import './functional-tests/options/source-map-file-name/Validation.spec';
-import './functional-tests/options/source-map-mode/Validation.spec';
 import './functional-tests/storages/string-array-storage/StringArrayStorage.spec';
 import './functional-tests/storages/string-array-storage/StringArrayStorage.spec';
 import './functional-tests/templates/debug-protection-nodes/DebugProtectionFunctionCallTemplate.spec';
 import './functional-tests/templates/debug-protection-nodes/DebugProtectionFunctionCallTemplate.spec';
 import './functional-tests/templates/domain-lock-nodes/DomainLockNodeTemplate.spec';
 import './functional-tests/templates/domain-lock-nodes/DomainLockNodeTemplate.spec';

Some files were not shown because too many files changed in this diff