From bbba8252de6e39f31e815c46b0ac4765f73b7eca Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 7 Jun 2021 13:46:10 +0200 Subject: [PATCH] Use isNameVariant1 etc for naming, update README --- README.md | 9 ++++++++ .../templates/DomainLockTemplate.ts | 22 +++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4dc1efbc..5b3ccbd7 100644 --- a/README.md +++ b/README.md @@ -361,6 +361,7 @@ Following options are available for the JS Obfuscator: debugProtectionInterval: false, disableConsoleOutput: false, domainLock: [], + domainDest: 'about:blank', forceTransformStrings: [], identifierNamesCache: null, identifierNamesGenerator: 'hexadecimal', @@ -421,6 +422,7 @@ Following options are available for the JS Obfuscator: --debug-protection-interval --disable-console-output --domain-lock '' (comma separated) + --domain-dest 'url' --exclude '' (comma separated) --force-transform-strings '' (comma separated) --identifier-names-cache-path @@ -691,6 +693,13 @@ Allows to run the obfuscated source code only on specific domains and/or sub-dom ##### Multiple domains and sub-domains It's possible to lock your code to more than one domain or sub-domain. For instance, to lock it so the code only runs on **www.example.com** add `www.example.com`. To make it work on the root domain including any sub-domains (`example.com`, `sub.example.com`), use `.example.com`. +### `domainDest` +Type: `string` Default: `about:blank` + +##### :warning: This option does not work with `target: 'node'` + +Location to redirect the browser to when domainLock is triggered. + ### `exclude` Type: `string[]` Default: `[]` diff --git a/src/custom-code-helpers/domain-lock/templates/DomainLockTemplate.ts b/src/custom-code-helpers/domain-lock/templates/DomainLockTemplate.ts index 6df55390..ded2d765 100644 --- a/src/custom-code-helpers/domain-lock/templates/DomainLockTemplate.ts +++ b/src/custom-code-helpers/domain-lock/templates/DomainLockTemplate.ts @@ -14,7 +14,7 @@ export function DomainLockTemplate (): string { let location; let hostname; - const isName_nlc = function(name, length, cs) { + const isName = function(name, length, cs) { if (name.length != length) { return false; } @@ -30,20 +30,20 @@ export function DomainLockTemplate (): string { return true; }; - const isName_cnl = function(cs, name, length) { - return isName_nlc(name, length, cs); + const isNameVariant1 = function(cs, name, length) { + return isName(name, length, cs); }; - const isName_ncl = function(name, cs, length) { - return isName_cnl(cs, name, length); + const isNameVariant2 = function(name, cs, length) { + return isNameVariant1(cs, name, length); }; - const isName_lnc = function(length, name, cs) { - return isName_nlc(name, length, cs); + const isNameVariant3 = function(length, name, cs) { + return isNameVariant2(name, cs, length); }; for (let d in that) { - if (isName_nlc(d, 8, [7, 116, 5, 101, 3, 117, 0, 100])) { + if (isName(d, 8, [7, 116, 5, 101, 3, 117, 0, 100])) { document = d; break; @@ -51,7 +51,7 @@ export function DomainLockTemplate (): string { } for (let d1 in that[document]) { - if (isName_lnc(6, d1, [5, 110, 0, 100])) { + if (isNameVariant3(6, d1, [5, 110, 0, 100])) { domain = d1; break; @@ -59,7 +59,7 @@ export function DomainLockTemplate (): string { } for (let d2 in that[document]) { - if (isName_ncl(d2, [7, 110, 0, 108], 8)) { + if (isNameVariant2(d2, [7, 110, 0, 108], 8)) { location = d2; break; @@ -68,7 +68,7 @@ export function DomainLockTemplate (): string { if (!("~" > domain)) { for (let d3 in that[document][location]) { - if (isName_cnl([7, 101, 0, 104], d3, 8)) { + if (isNameVariant1([7, 101, 0, 104], d3, 8)) { hostname = d3; break;