domainDest => domainLockRedirectUrl option rename

This commit is contained in:
sanex
2021-06-11 10:38:23 +03:00
parent ada04e5106
commit 616ae59d75
20 changed files with 159 additions and 155 deletions
+2 -2
View File
@@ -237,8 +237,8 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
ArraySanitizer
)
.option(
'--domain-dest <string>',
'Allows the browser to be redirected to a passed domain if the source code isn\'t run on the domains specified by --domain-lock',
'--domain-lock-redirect-url <string>',
'Allows the browser to be redirected to a passed URL if the source code isn\'t run on the domains specified by --domain-lock',
)
.option(
'--exclude <list> (comma separated, without whitespaces)',
@@ -89,14 +89,14 @@ export class DomainLockCodeHelper extends AbstractCustomCodeHelper {
*/
protected override getCodeHelperTemplate (): string {
const domainsString: string = this.options.domainLock.join(';');
const domainsDest: string = this.options.domainDest;
const domainsLockRedirectUrl: string = this.options.domainLockRedirectUrl;
const [hiddenDomainsString, domainsStringDiff]: string[] = this.cryptUtils.hideString(
domainsString,
domainsString.length * 3
);
const [hiddenDomainDest, domainDestDiff]: string[] = this.cryptUtils.hideString(
domainsDest,
domainsDest.length * 3
const [hiddenDomainLockRedirectUrl, domainLockRedirectUrlDiff]: string[] = this.cryptUtils.hideString(
domainsLockRedirectUrl,
domainsLockRedirectUrl.length * 3
);
const globalVariableTemplate: string = this.options.target !== ObfuscationTarget.BrowserNoEval
? this.getGlobalVariableTemplate()
@@ -107,8 +107,8 @@ export class DomainLockCodeHelper extends AbstractCustomCodeHelper {
domainLockFunctionName: this.domainLockFunctionName,
domainsStringDiff,
domains: hiddenDomainsString,
domainDestDiff,
domainDest: hiddenDomainDest,
domainLockRedirectUrlDiff: domainLockRedirectUrlDiff,
hiddenDomainLockRedirectUrl: hiddenDomainLockRedirectUrl,
globalVariableTemplate
});
}
@@ -107,10 +107,10 @@ export function DomainLockTemplate (): string {
}
if (!ok) {
const regExp2 = new RegExp("[{domainDestDiff}]", "g");
const domainDest = "{domainDest}".replace(regExp2, "");
const regExp2 = new RegExp("[{domainLockRedirectUrlDiff}]", "g");
const domainLockRedirectUrl = "{hiddenDomainLockRedirectUrl}".replace(regExp2, "");
that[document][location] = domainDest;
that[document][location] = domainLockRedirectUrl;
}
});
+1 -1
View File
@@ -20,7 +20,7 @@ export interface IOptions {
readonly debugProtectionInterval: boolean;
readonly disableConsoleOutput: boolean;
readonly domainLock: string[];
readonly domainDest: string;
readonly domainLockRedirectUrl: string;
readonly forceTransformStrings: string[];
readonly identifierNamesCache: TIdentifierNamesCache;
readonly identifierNamesGenerator: TTypeFromEnum<typeof IdentifierNamesGenerator>;
+3 -3
View File
@@ -46,7 +46,7 @@ import { HIGH_OBFUSCATION_PRESET } from './presets/HighObfuscation';
import { ValidationErrorsFormatter } from './ValidationErrorsFormatter';
import { IsAllowedForObfuscationTargets } from './validators/IsAllowedForObfuscationTargets';
import { IsDomainDestUrl } from './validators/IsDomainDestUrl';
import { IsDomainLockRedirectUrl } from './validators/IsDomainLockRedirectUrl';
import { IsIdentifierNamesCache } from './validators/IsIdentifierNamesCache';
@injectable()
@@ -138,8 +138,8 @@ export class Options implements IOptions {
/**
* @type {string}
*/
@IsDomainDestUrl()
public readonly domainDest!: string;
@IsDomainLockRedirectUrl()
public readonly domainLockRedirectUrl!: string;
/**
* @type {string[]}
+2 -2
View File
@@ -8,7 +8,7 @@ import { IOptionsNormalizer } from '../interfaces/options/IOptionsNormalizer';
import { ControlFlowFlatteningThresholdRule } from './normalizer-rules/ControlFlowFlatteningThresholdRule';
import { DeadCodeInjectionRule } from './normalizer-rules/DeadCodeInjectionRule';
import { DeadCodeInjectionThresholdRule } from './normalizer-rules/DeadCodeInjectionThresholdRule';
import { DomainDestRule } from './normalizer-rules/DomainDestRule';
import { DomainLockRedirectUrlRule } from './normalizer-rules/DomainLockRedirectUrlRule';
import { DomainLockRule } from './normalizer-rules/DomainLockRule';
import { IdentifierNamesCacheRule } from './normalizer-rules/IdentifierNamesCacheRule';
import { InputFileNameRule } from './normalizer-rules/InputFileNameRule';
@@ -30,7 +30,7 @@ export class OptionsNormalizer implements IOptionsNormalizer {
ControlFlowFlatteningThresholdRule,
DeadCodeInjectionRule,
DeadCodeInjectionThresholdRule,
DomainDestRule,
DomainLockRedirectUrlRule,
DomainLockRule,
IdentifierNamesCacheRule,
InputFileNameRule,
@@ -8,11 +8,11 @@ import { DEFAULT_PRESET } from '../presets/Default';
* @param {IOptions} options
* @returns {IOptions}
*/
export const DomainDestRule: TOptionsNormalizerRule = (options: IOptions): IOptions => {
export const DomainLockRedirectUrlRule: TOptionsNormalizerRule = (options: IOptions): IOptions => {
if (!options.domainLock.length) {
options = {
...options,
domainDest: <string>DEFAULT_PRESET.domainDest
domainLockRedirectUrl: <string>DEFAULT_PRESET.domainLockRedirectUrl
};
}
+1 -1
View File
@@ -20,7 +20,7 @@ export const DEFAULT_PRESET: TInputOptions = Object.freeze({
debugProtectionInterval: false,
disableConsoleOutput: false,
domainLock: [],
domainDest: 'about:blank',
domainLockRedirectUrl: 'about:blank',
exclude: [],
forceTransformStrings: [],
identifierNamesCache: null,
+1 -1
View File
@@ -18,7 +18,7 @@ export const NO_ADDITIONAL_NODES_PRESET: TInputOptions = Object.freeze({
debugProtectionInterval: false,
disableConsoleOutput: false,
domainLock: [],
domainDest: 'about:blank',
domainLockRedirectUrl: 'about:blank',
exclude: [],
forceTransformStrings: [],
identifierNamesGenerator: IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator,
@@ -13,10 +13,10 @@ import { IsAllowedForObfuscationTargets } from './IsAllowedForObfuscationTargets
/**
* @returns {PropertyDecorator}
*/
export const IsDomainDestUrl = (): PropertyDecorator => {
export const IsDomainLockRedirectUrl = (): PropertyDecorator => {
return (target: any, key: string | symbol): void => {
ValidateIf(({domainDest}: TInputOptions) => {
return domainDest !== DEFAULT_PRESET.domainDest;
ValidateIf(({domainLockRedirectUrl}: TInputOptions) => {
return domainLockRedirectUrl !== DEFAULT_PRESET.domainLockRedirectUrl;
})(target, key);
IsUrl({
require_protocol: false,