summaryrefslogtreecommitdiff
path: root/src/node_modules/javascript-obfuscator/src/custom-code-helpers
diff options
context:
space:
mode:
Diffstat (limited to 'src/node_modules/javascript-obfuscator/src/custom-code-helpers')
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/AbstractCustomCodeHelper.ts121
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/AbstractCustomCodeHelperGroup.ts104
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/CustomCodeHelperFormatter.ts65
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/CustomCodeHelperObfuscator.ts57
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/calls-controller/CallsControllerFunctionCodeHelper.ts92
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/GlobalVariableNoEvalTemplate.ts14
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/GlobalVariableTemplate1.ts16
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/GlobalVariableTemplate2.ts19
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/SingleCallControllerTemplate.ts24
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/console-output/ConsoleOutputDisableCodeHelper.ts91
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/console-output/group/ConsoleOutputCodeHelperGroup.ts126
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/console-output/templates/ConsoleOutputDisableTemplate.ts26
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCallCodeHelper.ts83
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCodeHelper.ts83
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/DebugProtectionFunctionIntervalCodeHelper.ts74
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/group/DebugProtectionCodeHelperGroup.ts164
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function-call/DebugProtectionFunctionCallTemplate.ts24
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function-interval/DebugProtectionFunctionIntervalTemplate.ts10
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function/DebugProtectionFunctionTemplate.ts23
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function/DebuggerTemplate.ts17
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function/DebuggerTemplateNoEval.ts21
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/domain-lock/DomainLockCodeHelper.ts108
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/domain-lock/group/DomainLockCustomCodeHelperGroup.ts126
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/domain-lock/templates/DomainLockTemplate.ts111
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/SelfDefendingUnicodeCodeHelper.ts95
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/group/SelfDefendingCodeHelperGroup.ts126
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/templates/SelfDefendingNoEvalTemplate.ts22
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/templates/SelfDefendingTemplate.ts22
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCallsWrapperBase64CodeHelper.ts32
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCallsWrapperCodeHelper.ts144
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCallsWrapperRc4CodeHelper.ts36
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCodeHelper.ts103
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper.ts121
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts175
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/AtobTemplate.ts24
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/Rc4Template.ts45
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/SelfDefendingTemplate.ts66
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/StringArrayBase64DecodeTemplate.ts47
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/StringArrayCallsWrapperTemplate.ts16
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/StringArrayRC4DecodeTemplate.ts44
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-rotate-function/SelfDefendingTemplate.ts81
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-rotate-function/StringArrayRotateFunctionTemplate.ts16
-rw-r--r--src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array/StringArrayTemplate.ts8
43 files changed, 2822 insertions, 0 deletions
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/AbstractCustomCodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/AbstractCustomCodeHelper.ts
new file mode 100644
index 0000000..be1d24f
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/AbstractCustomCodeHelper.ts
@@ -0,0 +1,121 @@
+import { inject, injectable } from 'inversify';
+import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
+
+import { TIdentifierNamesGeneratorFactory } from '../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TStatement } from '../types/node/TStatement';
+
+import { ICustomCodeHelper } from '../interfaces/custom-code-helpers/ICustomCodeHelper';
+import { ICustomCodeHelperFormatter } from '../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
+import { ICustomCodeHelperObfuscator } from '../interfaces/custom-code-helpers/ICustomCodeHelperObfuscator';
+import { IIdentifierNamesGenerator } from '../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
+import { IOptions } from '../interfaces/options/IOptions';
+import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';
+
+import { GlobalVariableTemplate1 } from './common/templates/GlobalVariableTemplate1';
+import { GlobalVariableTemplate2 } from './common/templates/GlobalVariableTemplate2';
+
+@injectable()
+export abstract class AbstractCustomCodeHelper <
+ TInitialData extends unknown[] = unknown[]
+> implements ICustomCodeHelper <TInitialData> {
+ /**
+ * @type {string[]}
+ */
+ private static readonly globalVariableTemplateFunctions: string[] = [
+ GlobalVariableTemplate1(),
+ GlobalVariableTemplate2()
+ ];
+
+ /**
+ * @type {TStatement[] | null}
+ */
+ protected cachedNode: TStatement[] | null = null;
+
+ /**
+ * @type {ICustomCodeHelperFormatter}
+ */
+ protected readonly customCodeHelperFormatter: ICustomCodeHelperFormatter;
+
+ /**
+ * @type {ICustomCodeHelperObfuscator}
+ */
+ protected readonly customCodeHelperObfuscator: ICustomCodeHelperObfuscator;
+
+ /**
+ * @type {IIdentifierNamesGenerator}
+ */
+ protected readonly identifierNamesGenerator: IIdentifierNamesGenerator;
+
+ /**
+ * @type {IOptions}
+ */
+ protected readonly options: IOptions;
+
+ /**
+ * @type {IRandomGenerator}
+ */
+ protected readonly randomGenerator: IRandomGenerator;
+
+ /**
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
+ * @param {ICustomCodeHelperObfuscator} customCodeHelperObfuscator
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ protected constructor (
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
+ @inject(ServiceIdentifiers.ICustomCodeHelperObfuscator) customCodeHelperObfuscator: ICustomCodeHelperObfuscator,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ this.identifierNamesGenerator = identifierNamesGeneratorFactory(options);
+ this.customCodeHelperFormatter = customCodeHelperFormatter;
+ this.customCodeHelperObfuscator = customCodeHelperObfuscator;
+ this.randomGenerator = randomGenerator;
+ this.options = options;
+ }
+
+ /**
+ * @returns {TStatement[]}
+ */
+ public getNode (): TStatement[] {
+ if (!this.cachedNode) {
+ const codeHelperTemplate: string = this.getCodeHelperTemplate();
+
+ this.cachedNode = this.customCodeHelperFormatter.formatStructure(
+ this.getNodeStructure(codeHelperTemplate)
+ );
+ }
+
+ return this.cachedNode;
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getGlobalVariableTemplate (): string {
+ return this.randomGenerator
+ .getRandomGenerator()
+ .pickone(AbstractCustomCodeHelper.globalVariableTemplateFunctions);
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getCodeHelperTemplate (): string {
+ return '';
+ }
+
+ /**
+ * @param {TInitialData} args
+ */
+ public abstract initialize (...args: TInitialData): void;
+
+ /**
+ * @returns {TStatement[]}
+ */
+ protected abstract getNodeStructure (codeHelperTemplate: string): TStatement[];
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/AbstractCustomCodeHelperGroup.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/AbstractCustomCodeHelperGroup.ts
new file mode 100644
index 0000000..ddffa36
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/AbstractCustomCodeHelperGroup.ts
@@ -0,0 +1,104 @@
+import { inject, injectable } from 'inversify';
+import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
+
+import { TIdentifierNamesGeneratorFactory } from '../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TNodeWithStatements } from '../types/node/TNodeWithStatements';
+
+import { ICallsGraphData } from '../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
+import { ICustomCodeHelper } from '../interfaces/custom-code-helpers/ICustomCodeHelper';
+import { ICustomCodeHelperGroup } from '../interfaces/custom-code-helpers/ICustomCodeHelperGroup';
+import { IIdentifierNamesGenerator } from '../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
+import { IOptions } from '../interfaces/options/IOptions';
+import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';
+
+import { CustomCodeHelper } from '../enums/custom-code-helpers/CustomCodeHelper';
+import { ObfuscationEvent } from '../enums/event-emitters/ObfuscationEvent';
+
+@injectable()
+export abstract class AbstractCustomCodeHelperGroup implements ICustomCodeHelperGroup {
+ /**
+ * @type {IIdentifierNamesGenerator}
+ */
+ protected readonly identifierNamesGenerator: IIdentifierNamesGenerator;
+
+ /**
+ * @type {IOptions}
+ */
+ protected readonly options: IOptions;
+
+ /**
+ * @type {IRandomGenerator}
+ */
+ protected readonly randomGenerator: IRandomGenerator;
+
+ /**
+ * @type {ObfuscationEvent}
+ */
+ protected abstract readonly appendEvent: ObfuscationEvent;
+
+ /**
+ * @type {Map<CustomCodeHelper, ICustomCodeHelper>}
+ */
+ protected abstract customCodeHelpers: Map <CustomCodeHelper, ICustomCodeHelper>;
+
+ /**
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ this.identifierNamesGenerator = identifierNamesGeneratorFactory(options);
+ this.randomGenerator = randomGenerator;
+ this.options = options;
+ }
+
+ /**
+ * @returns {ObfuscationEvent}
+ */
+ public getAppendEvent (): ObfuscationEvent {
+ return this.appendEvent;
+ }
+
+ /**
+ * @returns {Map<CustomCodeHelper, ICustomCodeHelper>}
+ */
+ public getCustomCodeHelpers (): Map <CustomCodeHelper, ICustomCodeHelper> {
+ return this.customCodeHelpers;
+ }
+
+ /**
+ * @param {CustomCodeHelper} customCodeHelperName
+ * @param {callback} callback
+ */
+ protected appendCustomNodeIfExist (customCodeHelperName: CustomCodeHelper, callback: (customCodeHelper: ICustomCodeHelper) => void): void {
+ const customCodeHelper: ICustomCodeHelper | undefined = this.customCodeHelpers.get(customCodeHelperName);
+
+ if (!customCodeHelper) {
+ return;
+ }
+
+ callback(customCodeHelper);
+ }
+
+ /**
+ * @param {number} callsGraphLength
+ * @returns {number}
+ */
+
+ protected getRandomCallsGraphIndex (callsGraphLength: number): number {
+ return this.randomGenerator.getRandomInteger(0, Math.max(0, Math.round(callsGraphLength - 1)));
+ }
+
+ /**
+ * @param {TNodeWithStatements} nodeWithStatements
+ * @param {ICallsGraphData[]} callsGraphData
+ */
+ public abstract appendNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void;
+
+ public abstract initialize (): void;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/CustomCodeHelperFormatter.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/CustomCodeHelperFormatter.ts
new file mode 100644
index 0000000..101f8c7
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/CustomCodeHelperFormatter.ts
@@ -0,0 +1,65 @@
+import { inject, injectable } from 'inversify';
+import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
+
+import * as estraverse from 'estraverse';
+import * as ESTree from 'estree';
+import format from 'string-template';
+
+import { TDictionary } from '../types/TDictionary';
+import { TStatement } from '../types/node/TStatement';
+
+import { ICustomCodeHelperFormatter } from '../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
+import { IPrevailingKindOfVariablesAnalyzer } from '../interfaces/analyzers/calls-graph-analyzer/IPrevailingKindOfVariablesAnalyzer';
+
+import { NodeGuards } from '../node/NodeGuards';
+
+@injectable()
+export class CustomCodeHelperFormatter implements ICustomCodeHelperFormatter {
+ /**
+ * @type {ESTree.VariableDeclaration['kind']}
+ */
+ private readonly prevailingKindOfVariables: ESTree.VariableDeclaration['kind'];
+
+ public constructor (
+ @inject(ServiceIdentifiers.IPrevailingKindOfVariablesAnalyzer)
+ prevailingKindOfVariablesAnalyzer: IPrevailingKindOfVariablesAnalyzer
+ ) {
+ this.prevailingKindOfVariables = prevailingKindOfVariablesAnalyzer.getPrevailingKind();
+ }
+
+ /**
+ * @param {string} template
+ * @param {TMapping} mapping
+ * @returns {string}
+ */
+ public formatTemplate <TMapping extends TDictionary> (
+ template: string,
+ mapping: TMapping
+ ): string {
+ return format(template, mapping);
+ }
+
+ /**
+ * @param {TStatement[]} statements
+ * @returns {TStatement[]}
+ */
+ public formatStructure (statements: TStatement[]): TStatement[] {
+ for (const statement of statements) {
+ estraverse.replace(statement, {
+ enter: (node: ESTree.Node): ESTree.Node | void => {
+ if (!NodeGuards.isVariableDeclarationNode(node)) {
+ return;
+ }
+
+ if (this.prevailingKindOfVariables === 'var') {
+ node.kind = 'var';
+ }
+
+ return node;
+ }
+ });
+ }
+
+ return statements;
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/CustomCodeHelperObfuscator.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/CustomCodeHelperObfuscator.ts
new file mode 100644
index 0000000..f33bc25
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/CustomCodeHelperObfuscator.ts
@@ -0,0 +1,57 @@
+import { inject, injectable } from 'inversify';
+import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
+
+import { TInputOptions } from '../types/options/TInputOptions';
+
+import { ICustomCodeHelperObfuscator } from '../interfaces/custom-code-helpers/ICustomCodeHelperObfuscator';
+import { IOptions } from '../interfaces/options/IOptions';
+import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';
+
+import { NO_ADDITIONAL_NODES_PRESET } from '../options/presets/NoCustomNodes';
+
+import { JavaScriptObfuscator } from '../JavaScriptObfuscatorFacade';
+
+@injectable()
+export class CustomCodeHelperObfuscator implements ICustomCodeHelperObfuscator {
+ /**
+ * @type {IOptions}
+ */
+ private readonly options: IOptions;
+
+ /**
+ * @type {IRandomGenerator}
+ */
+ private readonly randomGenerator: IRandomGenerator;
+
+ /**
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ this.randomGenerator = randomGenerator;
+ this.options = options;
+ }
+
+ /**
+ * @param {string} template
+ * @param {TInputOptions} additionalOptions
+ * @returns {string}
+ */
+ public obfuscateTemplate (template: string, additionalOptions: TInputOptions = {}): string {
+ return JavaScriptObfuscator.obfuscate(
+ template,
+ {
+ ...NO_ADDITIONAL_NODES_PRESET,
+ identifierNamesGenerator: this.options.identifierNamesGenerator,
+ identifiersDictionary: this.options.identifiersDictionary,
+ numbersToExpressions: this.options.numbersToExpressions,
+ simplify: this.options.simplify,
+ seed: this.randomGenerator.getRawSeed(),
+ ...additionalOptions
+ }
+ ).getObfuscatedCode();
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/calls-controller/CallsControllerFunctionCodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/calls-controller/CallsControllerFunctionCodeHelper.ts
new file mode 100644
index 0000000..a134f90
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/calls-controller/CallsControllerFunctionCodeHelper.ts
@@ -0,0 +1,92 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
+
+import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TStatement } from '../../types/node/TStatement';
+
+import { ICustomCodeHelperObfuscator } from '../../interfaces/custom-code-helpers/ICustomCodeHelperObfuscator';
+import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
+import { IOptions } from '../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
+
+import { ObfuscationEvent } from '../../enums/event-emitters/ObfuscationEvent';
+
+import { initializable } from '../../decorators/Initializable';
+
+import { SingleCallControllerTemplate } from '../common/templates/SingleCallControllerTemplate';
+
+import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper';
+import { NodeUtils } from '../../node/NodeUtils';
+
+@injectable()
+export class CallsControllerFunctionCodeHelper extends AbstractCustomCodeHelper {
+ /**
+ * @type {string}
+ */
+ @initializable()
+ protected callsControllerFunctionName!: string;
+
+ /**
+ * @type {ObfuscationEvent}
+ */
+ @initializable()
+ private appendEvent!: ObfuscationEvent;
+
+ /**
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
+ * @param {ICustomCodeHelperObfuscator} customCodeHelperObfuscator
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
+ @inject(ServiceIdentifiers.ICustomCodeHelperObfuscator) customCodeHelperObfuscator: ICustomCodeHelperObfuscator,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ super(
+ identifierNamesGeneratorFactory,
+ customCodeHelperFormatter,
+ customCodeHelperObfuscator,
+ randomGenerator,
+ options
+ );
+ }
+
+ /**
+ * @param {ObfuscationEvent} appendEvent
+ * @param {string} callsControllerFunctionName
+ */
+ public initialize (appendEvent: ObfuscationEvent, callsControllerFunctionName: string): void {
+ this.appendEvent = appendEvent;
+ this.callsControllerFunctionName = callsControllerFunctionName;
+ }
+
+ /**
+ * @param {string} codeHelperTemplate
+ * @returns {TStatement[]}
+ */
+ protected getNodeStructure (codeHelperTemplate: string): TStatement[] {
+ return NodeUtils.convertCodeToStructure(codeHelperTemplate);
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getCodeHelperTemplate (): string {
+ if (this.appendEvent === ObfuscationEvent.AfterObfuscation) {
+ return this.customCodeHelperObfuscator.obfuscateTemplate(
+ this.customCodeHelperFormatter.formatTemplate(SingleCallControllerTemplate(), {
+ callControllerFunctionName: this.callsControllerFunctionName
+ })
+ );
+ }
+
+ return this.customCodeHelperFormatter.formatTemplate(SingleCallControllerTemplate(), {
+ callControllerFunctionName: this.callsControllerFunctionName
+ });
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/GlobalVariableNoEvalTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/GlobalVariableNoEvalTemplate.ts
new file mode 100644
index 0000000..7afff69
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/GlobalVariableNoEvalTemplate.ts
@@ -0,0 +1,14 @@
+/**
+ * @returns {string}
+ */
+export function GlobalVariableNoEvalTemplate (): string {
+ return `
+ const that = (typeof window !== 'undefined'
+ ? window
+ : (typeof process === 'object' &&
+ typeof require === 'function' &&
+ typeof global === 'object')
+ ? global
+ : this);
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/GlobalVariableTemplate1.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/GlobalVariableTemplate1.ts
new file mode 100644
index 0000000..af10d72
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/GlobalVariableTemplate1.ts
@@ -0,0 +1,16 @@
+/**
+ * @returns {string}
+ */
+export function GlobalVariableTemplate1 (): string {
+ return `
+ let that;
+
+ try {
+ const getGlobal = Function('return (function() ' + '{}.constructor("return this")( )' + ');');
+
+ that = getGlobal();
+ } catch (e) {
+ that = window;
+ }
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/GlobalVariableTemplate2.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/GlobalVariableTemplate2.ts
new file mode 100644
index 0000000..76257d4
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/GlobalVariableTemplate2.ts
@@ -0,0 +1,19 @@
+/**
+ * @returns {string}
+ */
+export function GlobalVariableTemplate2 (): string {
+ return `
+ const getGlobal = function () {
+ let globalObject;
+
+ try {
+ globalObject = Function('return (function() ' + '{}.constructor("return this")( )' + ');')();
+ } catch (e) {
+ globalObject = window;
+ }
+
+ return globalObject;
+ };
+ const that = getGlobal();
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/SingleCallControllerTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/SingleCallControllerTemplate.ts
new file mode 100644
index 0000000..a70217c
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/common/templates/SingleCallControllerTemplate.ts
@@ -0,0 +1,24 @@
+/**
+ * @returns {string}
+ */
+export function SingleCallControllerTemplate (): string {
+ return `
+ const {callControllerFunctionName} = (function(){
+ let firstCall = true;
+
+ return function (context, fn){
+ const rfn = firstCall ? function(){
+ if(fn){
+ const res = fn.apply(context, arguments);
+ fn = null;
+ return res;
+ }
+ } : function(){}
+
+ firstCall = false;
+
+ return rfn;
+ }
+ })();
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/console-output/ConsoleOutputDisableCodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/console-output/ConsoleOutputDisableCodeHelper.ts
new file mode 100644
index 0000000..fba2955
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/console-output/ConsoleOutputDisableCodeHelper.ts
@@ -0,0 +1,91 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
+
+import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TStatement } from '../../types/node/TStatement';
+
+import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
+import { ICustomCodeHelperObfuscator } from '../../interfaces/custom-code-helpers/ICustomCodeHelperObfuscator';
+import { IOptions } from '../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
+
+import { ObfuscationTarget } from '../../enums/ObfuscationTarget';
+
+import { ConsoleOutputDisableTemplate } from './templates/ConsoleOutputDisableTemplate';
+import { GlobalVariableNoEvalTemplate } from '../common/templates/GlobalVariableNoEvalTemplate';
+
+import { initializable } from '../../decorators/Initializable';
+
+import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper';
+import { NodeUtils } from '../../node/NodeUtils';
+
+@injectable()
+export class ConsoleOutputDisableCodeHelper extends AbstractCustomCodeHelper {
+ /**
+ * @type {string}
+ */
+ @initializable()
+ private callsControllerFunctionName!: string;
+
+ /**
+ * @type {string}
+ */
+ @initializable()
+ private consoleOutputDisableFunctionName!: string;
+
+ /**
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
+ * @param {ICustomCodeHelperObfuscator} customCodeHelperObfuscator
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
+ @inject(ServiceIdentifiers.ICustomCodeHelperObfuscator) customCodeHelperObfuscator: ICustomCodeHelperObfuscator,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ super(
+ identifierNamesGeneratorFactory,
+ customCodeHelperFormatter,
+ customCodeHelperObfuscator,
+ randomGenerator,
+ options
+ );
+ }
+
+ /**
+ * @param {string} callsControllerFunctionName
+ * @param {StaticRange} consoleOutputDisableFunctionName
+ */
+ public initialize (callsControllerFunctionName: string, consoleOutputDisableFunctionName: string): void {
+ this.callsControllerFunctionName = callsControllerFunctionName;
+ this.consoleOutputDisableFunctionName = consoleOutputDisableFunctionName;
+ }
+
+ /**
+ * @param {string} codeHelperTemplate
+ * @returns {TStatement[]}
+ */
+ protected getNodeStructure (codeHelperTemplate: string): TStatement[] {
+ return NodeUtils.convertCodeToStructure(codeHelperTemplate);
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getCodeHelperTemplate (): string {
+ const globalVariableTemplate: string = this.options.target !== ObfuscationTarget.BrowserNoEval
+ ? this.getGlobalVariableTemplate()
+ : GlobalVariableNoEvalTemplate();
+
+ return this.customCodeHelperFormatter.formatTemplate(ConsoleOutputDisableTemplate(), {
+ callControllerFunctionName: this.callsControllerFunctionName,
+ consoleLogDisableFunctionName: this.consoleOutputDisableFunctionName,
+ globalVariableTemplate
+ });
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/console-output/group/ConsoleOutputCodeHelperGroup.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/console-output/group/ConsoleOutputCodeHelperGroup.ts
new file mode 100644
index 0000000..70d8dc8
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/console-output/group/ConsoleOutputCodeHelperGroup.ts
@@ -0,0 +1,126 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
+
+import { TCustomCodeHelperFactory } from '../../../types/container/custom-code-helpers/TCustomCodeHelperFactory';
+import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TInitialData } from '../../../types/TInitialData';
+import { TNodeWithLexicalScope } from '../../../types/node/TNodeWithLexicalScope';
+import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
+
+import { ICustomCodeHelper } from '../../../interfaces/custom-code-helpers/ICustomCodeHelper';
+import { IOptions } from '../../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
+import { ICallsGraphData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
+
+import { initializable } from '../../../decorators/Initializable';
+
+import { CustomCodeHelper } from '../../../enums/custom-code-helpers/CustomCodeHelper';
+import { ObfuscationEvent } from '../../../enums/event-emitters/ObfuscationEvent';
+
+import { AbstractCustomCodeHelperGroup } from '../../AbstractCustomCodeHelperGroup';
+import { CallsControllerFunctionCodeHelper } from '../../calls-controller/CallsControllerFunctionCodeHelper';
+import { ConsoleOutputDisableCodeHelper } from '../ConsoleOutputDisableCodeHelper';
+import { NodeAppender } from '../../../node/NodeAppender';
+import { NodeLexicalScopeUtils } from '../../../node/NodeLexicalScopeUtils';
+
+@injectable()
+export class ConsoleOutputCodeHelperGroup extends AbstractCustomCodeHelperGroup {
+ /**
+ * @type {Map<CustomCodeHelper, ICustomCodeHelper>}
+ */
+ @initializable()
+ protected customCodeHelpers!: Map <CustomCodeHelper, ICustomCodeHelper>;
+
+ /**
+ * @type {ObfuscationEvent}
+ */
+ protected readonly appendEvent: ObfuscationEvent = ObfuscationEvent.BeforeObfuscation;
+
+ /**
+ * @type {TCustomCodeHelperFactory}
+ */
+ private readonly customCodeHelperFactory: TCustomCodeHelperFactory;
+
+ /**
+ * @param {TCustomCodeHelperFactory} customCodeHelperFactory
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__ICustomCodeHelper) customCodeHelperFactory: TCustomCodeHelperFactory,
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ super(identifierNamesGeneratorFactory, randomGenerator, options);
+
+ this.customCodeHelperFactory = customCodeHelperFactory;
+ }
+
+ /**
+ * @param {TNodeWithStatements} nodeWithStatements
+ * @param {ICallsGraphData[]} callsGraphData
+ */
+ public appendNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void {
+ if (!this.options.disableConsoleOutput) {
+ return;
+ }
+
+ const randomCallsGraphIndex: number = this.getRandomCallsGraphIndex(callsGraphData.length);
+
+ const consoleOutputDisableHostNode: TNodeWithStatements = callsGraphData.length
+ ? NodeAppender.getOptimalBlockScope(callsGraphData, randomCallsGraphIndex)
+ : nodeWithStatements;
+ const callsControllerHostNode: TNodeWithStatements = callsGraphData.length
+ ? NodeAppender.getOptimalBlockScope(callsGraphData, randomCallsGraphIndex, 1)
+ : nodeWithStatements;
+
+ const consoleOutputDisableLexicalScopeNode: TNodeWithLexicalScope | null = NodeLexicalScopeUtils
+ .getLexicalScope(consoleOutputDisableHostNode) ?? null;
+
+ const consoleOutputDisableFunctionName: string = consoleOutputDisableLexicalScopeNode
+ ? this.identifierNamesGenerator.generate(consoleOutputDisableLexicalScopeNode)
+ : this.identifierNamesGenerator.generateNext();
+ const callsControllerFunctionName: string = consoleOutputDisableLexicalScopeNode
+ ? this.identifierNamesGenerator.generate(consoleOutputDisableLexicalScopeNode)
+ : this.identifierNamesGenerator.generateNext();
+
+ // consoleOutputDisableExpression helper nodes append
+ this.appendCustomNodeIfExist(
+ CustomCodeHelper.ConsoleOutputDisable,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<ConsoleOutputDisableCodeHelper>>) => {
+ customCodeHelper.initialize(callsControllerFunctionName, consoleOutputDisableFunctionName);
+
+ NodeAppender.prepend(consoleOutputDisableHostNode, customCodeHelper.getNode());
+ }
+ );
+
+ // nodeCallsControllerFunction helper nodes append
+ this.appendCustomNodeIfExist(
+ CustomCodeHelper.CallsControllerFunction,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<CallsControllerFunctionCodeHelper>>) => {
+ customCodeHelper.initialize(this.appendEvent, callsControllerFunctionName);
+
+ NodeAppender.prepend(callsControllerHostNode, customCodeHelper.getNode());
+ }
+ );
+ }
+
+ public initialize (): void {
+ this.customCodeHelpers = new Map <CustomCodeHelper, ICustomCodeHelper>();
+
+ if (!this.options.disableConsoleOutput) {
+ return;
+ }
+
+ const consoleOutputDisableExpressionCodeHelper: ICustomCodeHelper<TInitialData<ConsoleOutputDisableCodeHelper>> =
+ this.customCodeHelperFactory(CustomCodeHelper.ConsoleOutputDisable);
+ const callsControllerFunctionCodeHelper: ICustomCodeHelper<TInitialData<CallsControllerFunctionCodeHelper>> =
+ this.customCodeHelperFactory(CustomCodeHelper.CallsControllerFunction);
+
+ this.customCodeHelpers.set(CustomCodeHelper.ConsoleOutputDisable, consoleOutputDisableExpressionCodeHelper);
+ this.customCodeHelpers.set(CustomCodeHelper.CallsControllerFunction, callsControllerFunctionCodeHelper);
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/console-output/templates/ConsoleOutputDisableTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/console-output/templates/ConsoleOutputDisableTemplate.ts
new file mode 100644
index 0000000..35d83f9
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/console-output/templates/ConsoleOutputDisableTemplate.ts
@@ -0,0 +1,26 @@
+/**
+ * @returns {string}
+ */
+export function ConsoleOutputDisableTemplate (): string {
+ return `
+ const {consoleLogDisableFunctionName} = {callControllerFunctionName}(this, function () {
+ {globalVariableTemplate}
+
+ const consoleObject = (that.console = that.console || {});
+ const methods = ['log', 'warn', 'info', 'error', 'exception', 'table', 'trace'];
+
+ for (let index = 0; index < methods.length; index++){
+ const func = {callControllerFunctionName}.constructor.prototype.bind({callControllerFunctionName});
+ const methodName = methods[index];
+ const originalFunction = consoleObject[methodName] || func;
+
+ func.__proto__ = {callControllerFunctionName}.bind({callControllerFunctionName});
+ func.toString = originalFunction.toString.bind(originalFunction);
+
+ consoleObject[methodName] = func;
+ }
+ });
+
+ {consoleLogDisableFunctionName}();
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCallCodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCallCodeHelper.ts
new file mode 100644
index 0000000..b0409d0
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCallCodeHelper.ts
@@ -0,0 +1,83 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
+
+import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TStatement } from '../../types/node/TStatement';
+
+import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
+import { ICustomCodeHelperObfuscator } from '../../interfaces/custom-code-helpers/ICustomCodeHelperObfuscator';
+import { IOptions } from '../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
+
+import { initializable } from '../../decorators/Initializable';
+
+import { DebugProtectionFunctionCallTemplate } from './templates/debug-protection-function-call/DebugProtectionFunctionCallTemplate';
+
+import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper';
+import { NodeUtils } from '../../node/NodeUtils';
+
+@injectable()
+export class DebugProtectionFunctionCallCodeHelper extends AbstractCustomCodeHelper {
+ /**
+ * @type {string}
+ */
+ @initializable()
+ private callsControllerFunctionName!: string;
+
+ /**
+ * @type {string}
+ */
+ @initializable()
+ private debugProtectionFunctionName!: string;
+
+ /**
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
+ * @param {ICustomCodeHelperObfuscator} customCodeHelperObfuscator
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
+ @inject(ServiceIdentifiers.ICustomCodeHelperObfuscator) customCodeHelperObfuscator: ICustomCodeHelperObfuscator,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ super(
+ identifierNamesGeneratorFactory,
+ customCodeHelperFormatter,
+ customCodeHelperObfuscator,
+ randomGenerator,
+ options
+ );
+ }
+
+ /**
+ * @param {string} debugProtectionFunctionName
+ * @param {string} callsControllerFunctionName
+ */
+ public initialize (debugProtectionFunctionName: string, callsControllerFunctionName: string): void {
+ this.debugProtectionFunctionName = debugProtectionFunctionName;
+ this.callsControllerFunctionName = callsControllerFunctionName;
+ }
+
+ /**
+ * @param {string} codeHelperTemplate
+ * @returns {TStatement[]}
+ */
+ protected getNodeStructure (codeHelperTemplate: string): TStatement[] {
+ return NodeUtils.convertCodeToStructure(codeHelperTemplate);
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getCodeHelperTemplate (): string {
+ return this.customCodeHelperFormatter.formatTemplate(DebugProtectionFunctionCallTemplate(), {
+ debugProtectionFunctionName: this.debugProtectionFunctionName,
+ callControllerFunctionName: this.callsControllerFunctionName
+ });
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCodeHelper.ts
new file mode 100644
index 0000000..2575854
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCodeHelper.ts
@@ -0,0 +1,83 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
+
+import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TStatement } from '../../types/node/TStatement';
+
+import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
+import { ICustomCodeHelperObfuscator } from '../../interfaces/custom-code-helpers/ICustomCodeHelperObfuscator';
+import { IOptions } from '../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
+
+import { ObfuscationTarget } from '../../enums/ObfuscationTarget';
+
+import { initializable } from '../../decorators/Initializable';
+
+import { DebuggerTemplate } from './templates/debug-protection-function/DebuggerTemplate';
+import { DebuggerTemplateNoEval } from './templates/debug-protection-function/DebuggerTemplateNoEval';
+import { DebugProtectionFunctionTemplate } from './templates/debug-protection-function/DebugProtectionFunctionTemplate';
+
+import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper';
+import { NodeUtils } from '../../node/NodeUtils';
+
+@injectable()
+export class DebugProtectionFunctionCodeHelper extends AbstractCustomCodeHelper {
+ /**
+ * @type {string}
+ */
+ @initializable()
+ private debugProtectionFunctionName!: string;
+
+ /**
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
+ * @param {ICustomCodeHelperObfuscator} customCodeHelperObfuscator
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
+ @inject(ServiceIdentifiers.ICustomCodeHelperObfuscator) customCodeHelperObfuscator: ICustomCodeHelperObfuscator,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ super(
+ identifierNamesGeneratorFactory,
+ customCodeHelperFormatter,
+ customCodeHelperObfuscator,
+ randomGenerator,
+ options
+ );
+ }
+
+ /**
+ * @param {string} debugProtectionFunctionName
+ */
+ public initialize (debugProtectionFunctionName: string): void {
+ this.debugProtectionFunctionName = debugProtectionFunctionName;
+ }
+
+ /**
+ * @param {string} codeHelperTemplate
+ * @returns {TStatement[]}
+ */
+ protected getNodeStructure (codeHelperTemplate: string): TStatement[] {
+ return NodeUtils.convertCodeToStructure(codeHelperTemplate);
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getCodeHelperTemplate (): string {
+ const debuggerTemplate: string = this.options.target !== ObfuscationTarget.BrowserNoEval
+ ? DebuggerTemplate()
+ : DebuggerTemplateNoEval();
+
+ return this.customCodeHelperFormatter.formatTemplate(DebugProtectionFunctionTemplate(), {
+ debuggerTemplate,
+ debugProtectionFunctionName: this.debugProtectionFunctionName
+ });
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/DebugProtectionFunctionIntervalCodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/DebugProtectionFunctionIntervalCodeHelper.ts
new file mode 100644
index 0000000..b19c949
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/DebugProtectionFunctionIntervalCodeHelper.ts
@@ -0,0 +1,74 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
+
+import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TStatement } from '../../types/node/TStatement';
+
+import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
+import { ICustomCodeHelperObfuscator } from '../../interfaces/custom-code-helpers/ICustomCodeHelperObfuscator';
+import { IOptions } from '../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
+
+import { initializable } from '../../decorators/Initializable';
+
+import { DebugProtectionFunctionIntervalTemplate } from './templates/debug-protection-function-interval/DebugProtectionFunctionIntervalTemplate';
+
+import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper';
+import { NodeUtils } from '../../node/NodeUtils';
+
+@injectable()
+export class DebugProtectionFunctionIntervalCodeHelper extends AbstractCustomCodeHelper {
+ /**
+ * @type {string}
+ */
+ @initializable()
+ private debugProtectionFunctionName!: string;
+
+ /**
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
+ * @param {ICustomCodeHelperObfuscator} customCodeHelperObfuscator
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
+ @inject(ServiceIdentifiers.ICustomCodeHelperObfuscator) customCodeHelperObfuscator: ICustomCodeHelperObfuscator,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ super(
+ identifierNamesGeneratorFactory,
+ customCodeHelperFormatter,
+ customCodeHelperObfuscator,
+ randomGenerator,
+ options
+ );
+ }
+
+ /**
+ * @param {string} debugProtectionFunctionName
+ */
+ public initialize (debugProtectionFunctionName: string): void {
+ this.debugProtectionFunctionName = debugProtectionFunctionName;
+ }
+
+ /**
+ * @param {string} codeHelperTemplate
+ * @returns {TStatement[]}
+ */
+ protected getNodeStructure (codeHelperTemplate: string): TStatement[] {
+ return NodeUtils.convertCodeToStructure(codeHelperTemplate);
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getCodeHelperTemplate (): string {
+ return this.customCodeHelperFormatter.formatTemplate(DebugProtectionFunctionIntervalTemplate(), {
+ debugProtectionFunctionName: this.debugProtectionFunctionName
+ });
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/group/DebugProtectionCodeHelperGroup.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/group/DebugProtectionCodeHelperGroup.ts
new file mode 100644
index 0000000..2d1aa36
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/group/DebugProtectionCodeHelperGroup.ts
@@ -0,0 +1,164 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
+
+import { TCustomCodeHelperFactory } from '../../../types/container/custom-code-helpers/TCustomCodeHelperFactory';
+import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TInitialData } from '../../../types/TInitialData';
+import { TNodeWithLexicalScope } from '../../../types/node/TNodeWithLexicalScope';
+import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
+
+import { ICustomCodeHelper } from '../../../interfaces/custom-code-helpers/ICustomCodeHelper';
+import { IOptions } from '../../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
+import { ICallsGraphData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
+
+import { initializable } from '../../../decorators/Initializable';
+
+import { CustomCodeHelper } from '../../../enums/custom-code-helpers/CustomCodeHelper';
+import { ObfuscationEvent } from '../../../enums/event-emitters/ObfuscationEvent';
+
+import { AbstractCustomCodeHelperGroup } from '../../AbstractCustomCodeHelperGroup';
+import { CallsControllerFunctionCodeHelper } from '../../calls-controller/CallsControllerFunctionCodeHelper';
+import { DebugProtectionFunctionCodeHelper } from '../DebugProtectionFunctionCodeHelper';
+import { DebugProtectionFunctionCallCodeHelper } from '../DebugProtectionFunctionCallCodeHelper';
+import { DebugProtectionFunctionIntervalCodeHelper } from '../DebugProtectionFunctionIntervalCodeHelper';
+import { NodeAppender } from '../../../node/NodeAppender';
+import { NodeGuards } from '../../../node/NodeGuards';
+import { NodeLexicalScopeUtils } from '../../../node/NodeLexicalScopeUtils';
+
+@injectable()
+export class DebugProtectionCodeHelperGroup extends AbstractCustomCodeHelperGroup {
+ /**
+ * @type {Map<CustomCodeHelper, ICustomCodeHelper>}
+ */
+ @initializable()
+ protected customCodeHelpers!: Map <CustomCodeHelper, ICustomCodeHelper>;
+
+ /**
+ * @type {ObfuscationEvent}
+ */
+ protected readonly appendEvent: ObfuscationEvent = ObfuscationEvent.BeforeObfuscation;
+
+ /**
+ * @type {TCustomCodeHelperFactory}
+ */
+ private readonly customCodeHelperFactory: TCustomCodeHelperFactory;
+
+ /**
+ * @param {TCustomCodeHelperFactory} customCodeHelperFactory
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__ICustomCodeHelper) customCodeHelperFactory: TCustomCodeHelperFactory,
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ super(identifierNamesGeneratorFactory, randomGenerator, options);
+
+ this.customCodeHelperFactory = customCodeHelperFactory;
+ }
+
+ /**
+ * @param {TNodeWithStatements} nodeWithStatements
+ * @param {ICallsGraphData[]} callsGraphData
+ */
+ public appendNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void {
+ if (!this.options.debugProtection) {
+ return;
+ }
+
+ const randomCallsGraphIndex: number = this.getRandomCallsGraphIndex(callsGraphData.length);
+
+ const debugProtectionFunctionCallHostNode: TNodeWithStatements = callsGraphData.length
+ ? NodeAppender.getOptimalBlockScope(callsGraphData, randomCallsGraphIndex)
+ : nodeWithStatements;
+ const callsControllerHostNode: TNodeWithStatements = callsGraphData.length
+ ? NodeAppender.getOptimalBlockScope(callsGraphData, randomCallsGraphIndex, 1)
+ : nodeWithStatements;
+
+ const debugProtectionFunctionCallScopeNode: TNodeWithLexicalScope | null = NodeLexicalScopeUtils
+ .getLexicalScope(debugProtectionFunctionCallHostNode) ?? null;
+
+ const debugProtectionFunctionName: string = debugProtectionFunctionCallScopeNode
+ ? this.identifierNamesGenerator.generate(debugProtectionFunctionCallScopeNode)
+ : this.identifierNamesGenerator.generateNext();
+ const callsControllerFunctionName: string = debugProtectionFunctionCallScopeNode
+ ? this.identifierNamesGenerator.generate(debugProtectionFunctionCallScopeNode)
+ : this.identifierNamesGenerator.generateNext();
+
+ // debugProtectionFunctionCall helper nodes append
+ this.appendCustomNodeIfExist(
+ CustomCodeHelper.DebugProtectionFunctionCall,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<DebugProtectionFunctionCallCodeHelper>>) => {
+ customCodeHelper.initialize(debugProtectionFunctionName, callsControllerFunctionName);
+
+ NodeAppender.prepend(debugProtectionFunctionCallHostNode, customCodeHelper.getNode());
+ }
+ );
+
+ // nodeCallsControllerFunction helper nodes append
+ this.appendCustomNodeIfExist(
+ CustomCodeHelper.CallsControllerFunction,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<CallsControllerFunctionCodeHelper>>) => {
+ customCodeHelper.initialize(this.appendEvent, callsControllerFunctionName);
+
+ NodeAppender.prepend(callsControllerHostNode, customCodeHelper.getNode());
+ }
+ );
+
+ // debugProtectionFunction helper nodes append
+ this.appendCustomNodeIfExist(
+ CustomCodeHelper.DebugProtectionFunction,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<DebugProtectionFunctionCodeHelper>>) => {
+ customCodeHelper.initialize(debugProtectionFunctionName);
+
+ NodeAppender.append(nodeWithStatements, customCodeHelper.getNode());
+ }
+ );
+
+ // debugProtectionFunctionInterval helper nodes append
+ this.appendCustomNodeIfExist(
+ CustomCodeHelper.DebugProtectionFunctionInterval,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<DebugProtectionFunctionIntervalCodeHelper>>) => {
+ const programBodyLength: number = NodeGuards.isSwitchCaseNode(nodeWithStatements)
+ ? nodeWithStatements.consequent.length
+ : nodeWithStatements.body.length;
+ const randomIndex: number = this.randomGenerator.getRandomInteger(0, programBodyLength);
+
+ customCodeHelper.initialize(debugProtectionFunctionName);
+
+ NodeAppender.insertAtIndex(nodeWithStatements, customCodeHelper.getNode(), randomIndex);
+ }
+ );
+ }
+
+ public initialize (): void {
+ this.customCodeHelpers = new Map <CustomCodeHelper, ICustomCodeHelper>();
+
+ if (!this.options.debugProtection) {
+ return;
+ }
+
+ const debugProtectionFunctionCodeHelper: ICustomCodeHelper<TInitialData<DebugProtectionFunctionCodeHelper>> =
+ this.customCodeHelperFactory(CustomCodeHelper.DebugProtectionFunction);
+ const debugProtectionFunctionCallCodeHelper: ICustomCodeHelper<TInitialData<DebugProtectionFunctionCallCodeHelper>> =
+ this.customCodeHelperFactory(CustomCodeHelper.DebugProtectionFunctionCall);
+ const debugProtectionFunctionIntervalCodeHelper: ICustomCodeHelper<TInitialData<DebugProtectionFunctionIntervalCodeHelper>> =
+ this.customCodeHelperFactory(CustomCodeHelper.DebugProtectionFunctionInterval);
+ const callsControllerFunctionCodeHelper: ICustomCodeHelper<TInitialData<CallsControllerFunctionCodeHelper>> =
+ this.customCodeHelperFactory(CustomCodeHelper.CallsControllerFunction);
+
+ this.customCodeHelpers.set(CustomCodeHelper.DebugProtectionFunction, debugProtectionFunctionCodeHelper);
+ this.customCodeHelpers.set(CustomCodeHelper.DebugProtectionFunctionCall, debugProtectionFunctionCallCodeHelper);
+
+ if (this.options.debugProtectionInterval) {
+ this.customCodeHelpers.set(CustomCodeHelper.DebugProtectionFunctionInterval, debugProtectionFunctionIntervalCodeHelper);
+ }
+
+ this.customCodeHelpers.set(CustomCodeHelper.CallsControllerFunction, callsControllerFunctionCodeHelper);
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function-call/DebugProtectionFunctionCallTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function-call/DebugProtectionFunctionCallTemplate.ts
new file mode 100644
index 0000000..2382da7
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function-call/DebugProtectionFunctionCallTemplate.ts
@@ -0,0 +1,24 @@
+/**
+ * @returns {string}
+ */
+export function DebugProtectionFunctionCallTemplate (): string {
+ return `
+ (function () {
+ {callControllerFunctionName}(
+ this,
+ function () {
+ const regExp1 = new RegExp('function *\\\\( *\\\\)');
+ const regExp2 = new RegExp('\\\\+\\\\+ *\\(?:[a-zA-Z_$][0-9a-zA-Z_$]*\\)', 'i');
+
+ const result = {debugProtectionFunctionName}('init');
+
+ if (!regExp1.test(result + 'chain') || !regExp2.test(result + 'input')) {
+ result('0');
+ } else {
+ {debugProtectionFunctionName}();
+ }
+ }
+ )();
+ })();
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function-interval/DebugProtectionFunctionIntervalTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function-interval/DebugProtectionFunctionIntervalTemplate.ts
new file mode 100644
index 0000000..d1bdb7d
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function-interval/DebugProtectionFunctionIntervalTemplate.ts
@@ -0,0 +1,10 @@
+/**
+ * @returns {string}
+ */
+export function DebugProtectionFunctionIntervalTemplate (): string {
+ return `
+ setInterval(function () {
+ {debugProtectionFunctionName}();
+ }, 4000);
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function/DebugProtectionFunctionTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function/DebugProtectionFunctionTemplate.ts
new file mode 100644
index 0000000..8f2ee49
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function/DebugProtectionFunctionTemplate.ts
@@ -0,0 +1,23 @@
+/**
+ * @returns {string}
+ */
+export function DebugProtectionFunctionTemplate (): string {
+ return `
+ function {debugProtectionFunctionName} (ret) {
+ function debuggerProtection (counter) {
+
+ {debuggerTemplate}
+
+ debuggerProtection(++counter);
+ }
+
+ try {
+ if (ret) {
+ return debuggerProtection;
+ } else {
+ debuggerProtection(0);
+ }
+ } catch (y) {}
+ }
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function/DebuggerTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function/DebuggerTemplate.ts
new file mode 100644
index 0000000..eeb93b3
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function/DebuggerTemplate.ts
@@ -0,0 +1,17 @@
+/**
+ * @returns {string}
+ */
+export function DebuggerTemplate (): string {
+ return `
+ if (typeof counter === 'string') {
+ return (function (arg) {}.constructor('while (true) {}').apply('counter'));
+ } else {
+ if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {
+ (function () {return true;}.constructor('debu' + 'gger').call('action'));
+ } else {
+ (function () {return false;}.constructor('debu' + 'gger').apply('stateObject'));
+ }
+
+ }
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function/DebuggerTemplateNoEval.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function/DebuggerTemplateNoEval.ts
new file mode 100644
index 0000000..fe52b6b
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/debug-protection/templates/debug-protection-function/DebuggerTemplateNoEval.ts
@@ -0,0 +1,21 @@
+/**
+ * @returns {string}
+ */
+export function DebuggerTemplateNoEval (): string {
+ return `
+ if (typeof counter === 'string') {
+ const func = function () {
+ while (true) {}
+ };
+
+ return func();
+ } else {
+ if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {
+ debugger;
+ } else {
+ debugger;
+ }
+
+ }
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/domain-lock/DomainLockCodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/domain-lock/DomainLockCodeHelper.ts
new file mode 100644
index 0000000..56e0af2
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/domain-lock/DomainLockCodeHelper.ts
@@ -0,0 +1,108 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
+
+import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TStatement } from '../../types/node/TStatement';
+
+import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
+import { ICustomCodeHelperObfuscator } from '../../interfaces/custom-code-helpers/ICustomCodeHelperObfuscator';
+import { ICryptUtils } from '../../interfaces/utils/ICryptUtils';
+import { IOptions } from '../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
+
+import { ObfuscationTarget } from '../../enums/ObfuscationTarget';
+
+import { initializable } from '../../decorators/Initializable';
+
+import { DomainLockTemplate } from './templates/DomainLockTemplate';
+import { GlobalVariableNoEvalTemplate } from '../common/templates/GlobalVariableNoEvalTemplate';
+
+import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper';
+import { NodeUtils } from '../../node/NodeUtils';
+
+@injectable()
+export class DomainLockCodeHelper extends AbstractCustomCodeHelper {
+ /**
+ * @type {string}
+ */
+ @initializable()
+ private callsControllerFunctionName!: string;
+
+ /**
+ * @type {string}
+ */
+ @initializable()
+ private domainLockFunctionName!: string;
+
+ /**
+ * @type {ICryptUtils}
+ */
+ private readonly cryptUtils: ICryptUtils;
+
+ /**
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
+ * @param {ICustomCodeHelperObfuscator} customCodeHelperObfuscator
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ * @param {ICryptUtils} cryptUtils
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
+ @inject(ServiceIdentifiers.ICustomCodeHelperObfuscator) customCodeHelperObfuscator: ICustomCodeHelperObfuscator,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions,
+ @inject(ServiceIdentifiers.ICryptUtils) cryptUtils: ICryptUtils
+ ) {
+ super(
+ identifierNamesGeneratorFactory,
+ customCodeHelperFormatter,
+ customCodeHelperObfuscator,
+ randomGenerator,
+ options
+ );
+
+ this.cryptUtils = cryptUtils;
+ }
+
+ /**
+ * @param {string} callsControllerFunctionName
+ * @param {string} domainLockFunctionName
+ */
+ public initialize (callsControllerFunctionName: string, domainLockFunctionName: string): void {
+ this.callsControllerFunctionName = callsControllerFunctionName;
+ this.domainLockFunctionName = domainLockFunctionName;
+ }
+
+ /**
+ * @param {string} codeHelperTemplate
+ * @returns {TStatement[]}
+ */
+ protected getNodeStructure (codeHelperTemplate: string): TStatement[] {
+ return NodeUtils.convertCodeToStructure(codeHelperTemplate);
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getCodeHelperTemplate (): string {
+ const domainsString: string = this.options.domainLock.join(';');
+ const [hiddenDomainsString, diff]: string[] = this.cryptUtils.hideString(
+ domainsString,
+ domainsString.length * 3
+ );
+ const globalVariableTemplate: string = this.options.target !== ObfuscationTarget.BrowserNoEval
+ ? this.getGlobalVariableTemplate()
+ : GlobalVariableNoEvalTemplate();
+
+ return this.customCodeHelperFormatter.formatTemplate(DomainLockTemplate(), {
+ callControllerFunctionName: this.callsControllerFunctionName,
+ domainLockFunctionName: this.domainLockFunctionName,
+ diff,
+ domains: hiddenDomainsString,
+ globalVariableTemplate
+ });
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/domain-lock/group/DomainLockCustomCodeHelperGroup.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/domain-lock/group/DomainLockCustomCodeHelperGroup.ts
new file mode 100644
index 0000000..ab3a0a1
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/domain-lock/group/DomainLockCustomCodeHelperGroup.ts
@@ -0,0 +1,126 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
+
+import { TCustomCodeHelperFactory } from '../../../types/container/custom-code-helpers/TCustomCodeHelperFactory';
+import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TInitialData } from '../../../types/TInitialData';
+import { TNodeWithLexicalScope } from '../../../types/node/TNodeWithLexicalScope';
+import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
+
+import { ICustomCodeHelper } from '../../../interfaces/custom-code-helpers/ICustomCodeHelper';
+import { IOptions } from '../../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
+import { ICallsGraphData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
+
+import { initializable } from '../../../decorators/Initializable';
+
+import { CustomCodeHelper } from '../../../enums/custom-code-helpers/CustomCodeHelper';
+import { ObfuscationEvent } from '../../../enums/event-emitters/ObfuscationEvent';
+
+import { AbstractCustomCodeHelperGroup } from '../../AbstractCustomCodeHelperGroup';
+import { CallsControllerFunctionCodeHelper } from '../../calls-controller/CallsControllerFunctionCodeHelper';
+import { DomainLockCodeHelper } from '../DomainLockCodeHelper';
+import { NodeAppender } from '../../../node/NodeAppender';
+import { NodeLexicalScopeUtils } from '../../../node/NodeLexicalScopeUtils';
+
+@injectable()
+export class DomainLockCustomCodeHelperGroup extends AbstractCustomCodeHelperGroup {
+ /**
+ * @type {Map<CustomCodeHelper, ICustomCodeHelper>}
+ */
+ @initializable()
+ protected customCodeHelpers!: Map <CustomCodeHelper, ICustomCodeHelper>;
+
+ /**
+ * @type {ObfuscationEvent}
+ */
+ protected readonly appendEvent: ObfuscationEvent = ObfuscationEvent.BeforeObfuscation;
+
+ /**
+ * @type {TCustomCodeHelperFactory}
+ */
+ private readonly customCodeHelperFactory: TCustomCodeHelperFactory;
+
+ /**
+ * @param {TCustomCodeHelperFactory} customCodeHelperFactory
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__ICustomCodeHelper) customCodeHelperFactory: TCustomCodeHelperFactory,
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ super(identifierNamesGeneratorFactory, randomGenerator, options);
+
+ this.customCodeHelperFactory = customCodeHelperFactory;
+ }
+
+ /**
+ * @param {TNodeWithStatements} nodeWithStatements
+ * @param {ICallsGraphData[]} callsGraphData
+ */
+ public appendNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void {
+ if (!this.options.domainLock.length) {
+ return;
+ }
+
+ const randomCallsGraphIndex: number = this.getRandomCallsGraphIndex(callsGraphData.length);
+
+ const domainLockFunctionHostNode: TNodeWithStatements = callsGraphData.length
+ ? NodeAppender.getOptimalBlockScope(callsGraphData, randomCallsGraphIndex)
+ : nodeWithStatements;
+ const callsControllerHostNode: TNodeWithStatements = callsGraphData.length
+ ? NodeAppender.getOptimalBlockScope(callsGraphData, randomCallsGraphIndex, 1)
+ : nodeWithStatements;
+
+ const domainLockFunctionLexicalScopeNode: TNodeWithLexicalScope | null = NodeLexicalScopeUtils
+ .getLexicalScope(domainLockFunctionHostNode) ?? null;
+
+ const domainLockFunctionName: string = domainLockFunctionLexicalScopeNode
+ ? this.identifierNamesGenerator.generate(domainLockFunctionLexicalScopeNode)
+ : this.identifierNamesGenerator.generateNext();
+ const callsControllerFunctionName: string = domainLockFunctionLexicalScopeNode
+ ? this.identifierNamesGenerator.generate(domainLockFunctionLexicalScopeNode)
+ : this.identifierNamesGenerator.generateNext();
+
+ // domainLock helper nodes append
+ this.appendCustomNodeIfExist(
+ CustomCodeHelper.DomainLock,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<DomainLockCodeHelper>>) => {
+ customCodeHelper.initialize(callsControllerFunctionName, domainLockFunctionName);
+
+ NodeAppender.prepend(domainLockFunctionHostNode, customCodeHelper.getNode());
+ }
+ );
+
+ // nodeCallsControllerFunction helper nodes append
+ this.appendCustomNodeIfExist(
+ CustomCodeHelper.CallsControllerFunction,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<CallsControllerFunctionCodeHelper>>) => {
+ customCodeHelper.initialize(this.appendEvent, callsControllerFunctionName);
+
+ NodeAppender.prepend(callsControllerHostNode, customCodeHelper.getNode());
+ }
+ );
+ }
+
+ public initialize (): void {
+ this.customCodeHelpers = new Map <CustomCodeHelper, ICustomCodeHelper>();
+
+ if (!this.options.domainLock.length) {
+ return;
+ }
+
+ const domainLockCodeHelper: ICustomCodeHelper<TInitialData<DomainLockCodeHelper>> =
+ this.customCodeHelperFactory(CustomCodeHelper.DomainLock);
+ const callsControllerFunctionCodeHelper: ICustomCodeHelper<TInitialData<CallsControllerFunctionCodeHelper>> =
+ this.customCodeHelperFactory(CustomCodeHelper.CallsControllerFunction);
+
+ this.customCodeHelpers.set(CustomCodeHelper.DomainLock, domainLockCodeHelper);
+ this.customCodeHelpers.set(CustomCodeHelper.CallsControllerFunction, callsControllerFunctionCodeHelper);
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/domain-lock/templates/DomainLockTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/domain-lock/templates/DomainLockTemplate.ts
new file mode 100644
index 0000000..691b361
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/domain-lock/templates/DomainLockTemplate.ts
@@ -0,0 +1,111 @@
+/**
+ * @returns {string}
+ */
+export function DomainLockTemplate (): string {
+ return `
+ const {domainLockFunctionName} = {callControllerFunctionName}(this, function () {
+
+ {globalVariableTemplate}
+
+ const func = function () {
+ return {
+ key: 'item',
+ value: 'attribute',
+ getAttribute: function () {
+ for (let i = 0; i < 1000; i--) {
+ const isPositive = i > 0;
+
+ switch (isPositive) {
+ case true:
+ return this.item + '_' + this.value + '_' + i;
+ default:
+ this.item + '_' + this.value;
+ }
+ }
+ }()
+ };
+ };
+
+ const regExp = new RegExp("[{diff}]", "g");
+ const domains = "{domains}".replace(regExp, "").split(";");
+ let document;
+ let domain;
+ let location;
+ let hostname;
+
+ for (let d in that) {
+ if (d.length == 8 && d.charCodeAt(7) == 116 && d.charCodeAt(5) == 101 && d.charCodeAt(3) == 117 && d.charCodeAt(0) == 100) {
+ document = d;
+
+ break;
+ }
+ }
+
+ for (let d1 in that[document]) {
+ if (d1.length == 6 && d1.charCodeAt(5) == 110 && d1.charCodeAt(0) == 100) {
+ domain = d1;
+
+ break;
+ }
+ }
+
+ if (!("~" > domain)) {
+ for (let d2 in that[document]) {
+ if (d2.length == 8 && d2.charCodeAt(7) == 110 && d2.charCodeAt(0) == 108) {
+ location = d2;
+
+ break;
+ }
+ }
+
+ for (let d3 in that[document][location]) {
+ if (d3.length == 8 && d3.charCodeAt(7) == 101 && d3.charCodeAt(0) == 104) {
+ hostname = d3;
+
+ break;
+ }
+ }
+ }
+
+ if (!document || !that[document]) {
+ return;
+ }
+
+ const documentDomain = that[document][domain];
+ const documentLocationHostName = !!that[document][location] && that[document][location][hostname];
+ const currentDomain = documentDomain || documentLocationHostName;
+
+ if (!currentDomain) {
+ return;
+ }
+
+ let ok = false;
+
+ for (let i = 0; i < domains.length; i++) {
+ const domain = domains[i];
+ const domainNormalized = domain[0] === String.fromCharCode(46)
+ ? domain.slice(1)
+ : domain;
+ const position = currentDomain.length - domainNormalized.length;
+ const lastIndex = currentDomain.indexOf(domainNormalized, position);
+ const endsWith = lastIndex !== -1 && lastIndex === position;
+
+ if (endsWith) {
+ if (currentDomain.length == domain.length || domain.indexOf(".") === 0) {
+ ok = true;
+ }
+ }
+ }
+
+ if (!ok) {
+ data;
+ } else {
+ return;
+ }
+
+ func();
+ });
+
+ {domainLockFunctionName}();
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/SelfDefendingUnicodeCodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/SelfDefendingUnicodeCodeHelper.ts
new file mode 100644
index 0000000..2828476
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/SelfDefendingUnicodeCodeHelper.ts
@@ -0,0 +1,95 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
+
+import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TStatement } from '../../types/node/TStatement';
+
+import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
+import { ICustomCodeHelperObfuscator } from '../../interfaces/custom-code-helpers/ICustomCodeHelperObfuscator';
+import { IOptions } from '../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
+
+import { ObfuscationTarget } from '../../enums/ObfuscationTarget';
+
+import { initializable } from '../../decorators/Initializable';
+
+import { SelfDefendingTemplate } from './templates/SelfDefendingTemplate';
+import { SelfDefendingNoEvalTemplate } from './templates/SelfDefendingNoEvalTemplate';
+
+import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper';
+import { NodeUtils } from '../../node/NodeUtils';
+import { GlobalVariableNoEvalTemplate } from '../common/templates/GlobalVariableNoEvalTemplate';
+
+@injectable()
+export class SelfDefendingUnicodeCodeHelper extends AbstractCustomCodeHelper {
+ /**
+ * @type {string}
+ */
+ @initializable()
+ private callsControllerFunctionName!: string;
+
+ /**
+ * @type {string}
+ */
+ @initializable()
+ private selfDefendingFunctionName!: string;
+
+ /**
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
+ * @param {ICustomCodeHelperObfuscator} customCodeHelperObfuscator
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
+ @inject(ServiceIdentifiers.ICustomCodeHelperObfuscator) customCodeHelperObfuscator: ICustomCodeHelperObfuscator,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ super(
+ identifierNamesGeneratorFactory,
+ customCodeHelperFormatter,
+ customCodeHelperObfuscator,
+ randomGenerator,
+ options
+ );
+ }
+
+ /**
+ * @param {string} callsControllerFunctionName
+ * @param {string} selfDefendingFunctionName
+ */
+ public initialize (callsControllerFunctionName: string, selfDefendingFunctionName: string): void {
+ this.callsControllerFunctionName = callsControllerFunctionName;
+ this.selfDefendingFunctionName = selfDefendingFunctionName;
+ }
+
+ /**
+ * @param {string} codeHelperTemplate
+ * @returns {TStatement[]}
+ */
+ protected getNodeStructure (codeHelperTemplate: string): TStatement[] {
+ return NodeUtils.convertCodeToStructure(codeHelperTemplate);
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getCodeHelperTemplate (): string {
+ const globalVariableTemplate: string = this.options.target !== ObfuscationTarget.BrowserNoEval
+ ? this.getGlobalVariableTemplate()
+ : GlobalVariableNoEvalTemplate();
+ const selfDefendingTemplate: string = this.options.target !== ObfuscationTarget.BrowserNoEval
+ ? SelfDefendingTemplate()
+ : SelfDefendingNoEvalTemplate();
+
+ return this.customCodeHelperFormatter.formatTemplate(selfDefendingTemplate, {
+ callControllerFunctionName: this.callsControllerFunctionName,
+ selfDefendingFunctionName: this.selfDefendingFunctionName,
+ globalVariableTemplate
+ });
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/group/SelfDefendingCodeHelperGroup.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/group/SelfDefendingCodeHelperGroup.ts
new file mode 100644
index 0000000..46be4cb
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/group/SelfDefendingCodeHelperGroup.ts
@@ -0,0 +1,126 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
+
+import { TCustomCodeHelperFactory } from '../../../types/container/custom-code-helpers/TCustomCodeHelperFactory';
+import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TInitialData } from '../../../types/TInitialData';
+import { TNodeWithLexicalScope } from '../../../types/node/TNodeWithLexicalScope';
+import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
+
+import { ICustomCodeHelper } from '../../../interfaces/custom-code-helpers/ICustomCodeHelper';
+import { IOptions } from '../../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
+import { ICallsGraphData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
+
+import { initializable } from '../../../decorators/Initializable';
+
+import { CustomCodeHelper } from '../../../enums/custom-code-helpers/CustomCodeHelper';
+import { ObfuscationEvent } from '../../../enums/event-emitters/ObfuscationEvent';
+
+import { AbstractCustomCodeHelperGroup } from '../../AbstractCustomCodeHelperGroup';
+import { CallsControllerFunctionCodeHelper } from '../../calls-controller/CallsControllerFunctionCodeHelper';
+import { NodeAppender } from '../../../node/NodeAppender';
+import { NodeLexicalScopeUtils } from '../../../node/NodeLexicalScopeUtils';
+import { SelfDefendingUnicodeCodeHelper } from '../SelfDefendingUnicodeCodeHelper';
+
+@injectable()
+export class SelfDefendingCodeHelperGroup extends AbstractCustomCodeHelperGroup {
+ /**
+ * @type {Map<CustomCodeHelper, ICustomCodeHelper>}
+ */
+ @initializable()
+ protected customCodeHelpers!: Map <CustomCodeHelper, ICustomCodeHelper>;
+
+ /**
+ * @type {ObfuscationEvent}
+ */
+ protected appendEvent: ObfuscationEvent = ObfuscationEvent.BeforeObfuscation;
+
+ /**
+ * @type {TCustomCodeHelperFactory}
+ */
+ private readonly customCodeHelperFactory: TCustomCodeHelperFactory;
+
+ /**
+ * @param {TCustomCodeHelperFactory} customCodeHelperFactory
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__ICustomCodeHelper) customCodeHelperFactory: TCustomCodeHelperFactory,
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ super(identifierNamesGeneratorFactory, randomGenerator, options);
+
+ this.customCodeHelperFactory = customCodeHelperFactory;
+ }
+
+ /**
+ * @param {TNodeWithStatements} nodeWithStatements
+ * @param {ICallsGraphData[]} callsGraphData
+ */
+ public appendNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void {
+ if (!this.options.selfDefending) {
+ return;
+ }
+
+ const randomCallsGraphIndex: number = this.getRandomCallsGraphIndex(callsGraphData.length);
+
+ const selfDefendingFunctionHostNode: TNodeWithStatements = callsGraphData.length
+ ? NodeAppender.getOptimalBlockScope(callsGraphData, randomCallsGraphIndex)
+ : nodeWithStatements;
+ const callsControllerHostNode: TNodeWithStatements = callsGraphData.length
+ ? NodeAppender.getOptimalBlockScope(callsGraphData, randomCallsGraphIndex, 1)
+ : nodeWithStatements;
+
+ const selfDefendingFunctionLexicalScopeNode: TNodeWithLexicalScope | null = NodeLexicalScopeUtils
+ .getLexicalScope(selfDefendingFunctionHostNode) ?? null;
+
+ const selfDefendingFunctionName: string = selfDefendingFunctionLexicalScopeNode
+ ? this.identifierNamesGenerator.generate(selfDefendingFunctionLexicalScopeNode)
+ : this.identifierNamesGenerator.generateNext();
+ const callsControllerFunctionName: string = selfDefendingFunctionLexicalScopeNode
+ ? this.identifierNamesGenerator.generate(selfDefendingFunctionLexicalScopeNode)
+ : this.identifierNamesGenerator.generateNext();
+
+ // selfDefendingUnicode helper nodes append
+ this.appendCustomNodeIfExist(
+ CustomCodeHelper.SelfDefendingUnicode,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<SelfDefendingUnicodeCodeHelper>>) => {
+ customCodeHelper.initialize(callsControllerFunctionName, selfDefendingFunctionName);
+
+ NodeAppender.prepend(selfDefendingFunctionHostNode, customCodeHelper.getNode());
+ }
+ );
+
+ // nodeCallsControllerFunction helper nodes append
+ this.appendCustomNodeIfExist(
+ CustomCodeHelper.CallsControllerFunction,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<CallsControllerFunctionCodeHelper>>) => {
+ customCodeHelper.initialize(this.appendEvent, callsControllerFunctionName);
+
+ NodeAppender.prepend(callsControllerHostNode, customCodeHelper.getNode());
+ }
+ );
+ }
+
+ public initialize (): void {
+ this.customCodeHelpers = new Map <CustomCodeHelper, ICustomCodeHelper>();
+
+ if (!this.options.selfDefending) {
+ return;
+ }
+
+ const selfDefendingUnicodeCodeHelper: ICustomCodeHelper<TInitialData<SelfDefendingUnicodeCodeHelper>> =
+ this.customCodeHelperFactory(CustomCodeHelper.SelfDefendingUnicode);
+ const callsControllerFunctionCodeHelper: ICustomCodeHelper<TInitialData<CallsControllerFunctionCodeHelper>> =
+ this.customCodeHelperFactory(CustomCodeHelper.CallsControllerFunction);
+
+ this.customCodeHelpers.set(CustomCodeHelper.SelfDefendingUnicode, selfDefendingUnicodeCodeHelper);
+ this.customCodeHelpers.set(CustomCodeHelper.CallsControllerFunction, callsControllerFunctionCodeHelper);
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/templates/SelfDefendingNoEvalTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/templates/SelfDefendingNoEvalTemplate.ts
new file mode 100644
index 0000000..667bdb7
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/templates/SelfDefendingNoEvalTemplate.ts
@@ -0,0 +1,22 @@
+/**
+ * SelfDefendingTemplate. Enters code in infinity loop.
+ *
+ * @returns {string}
+ */
+export function SelfDefendingNoEvalTemplate (): string {
+ return `
+ const {selfDefendingFunctionName} = {callControllerFunctionName}(this, function () {
+ {globalVariableTemplate}
+
+ const test = function () {
+ const regExp = new that.RegExp('^([^ ]+( +[^ ]+)+)+[^ ]}');
+
+ return !regExp.test({selfDefendingFunctionName});
+ };
+
+ return test();
+ });
+
+ {selfDefendingFunctionName}();
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/templates/SelfDefendingTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/templates/SelfDefendingTemplate.ts
new file mode 100644
index 0000000..e8c5963
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/self-defending/templates/SelfDefendingTemplate.ts
@@ -0,0 +1,22 @@
+/**
+ * SelfDefendingTemplate. Enters code in infinity loop.
+ *
+ * @returns {string}
+ */
+export function SelfDefendingTemplate (): string {
+ return `
+ const {selfDefendingFunctionName} = {callControllerFunctionName}(this, function () {
+ const test = function () {
+ const regExp = test
+ .constructor('return /" + this + "/')()
+ .constructor('^([^ ]+( +[^ ]+)+)+[^ ]}');
+
+ return !regExp.test({selfDefendingFunctionName});
+ };
+
+ return test();
+ });
+
+ {selfDefendingFunctionName}();
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCallsWrapperBase64CodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCallsWrapperBase64CodeHelper.ts
new file mode 100644
index 0000000..44b20d0
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCallsWrapperBase64CodeHelper.ts
@@ -0,0 +1,32 @@
+import { injectable, } from 'inversify';
+
+import { AtobTemplate } from './templates/string-array-calls-wrapper/AtobTemplate';
+import { StringArrayBase64DecodeTemplate } from './templates/string-array-calls-wrapper/StringArrayBase64DecodeTemplate';
+
+import { StringArrayCallsWrapperCodeHelper } from './StringArrayCallsWrapperCodeHelper';
+
+@injectable()
+export class StringArrayCallsWrapperBase64CodeHelper extends StringArrayCallsWrapperCodeHelper {
+ /**
+ * @returns {string}
+ */
+ protected getDecodeStringArrayTemplate (): string {
+ const atobFunctionName: string = this.randomGenerator.getRandomString(6);
+
+ const atobPolyfill: string = this.customCodeHelperFormatter.formatTemplate(AtobTemplate(), {
+ atobFunctionName: atobFunctionName
+ });
+
+ const selfDefendingCode: string = this.getSelfDefendingTemplate();
+
+ return this.customCodeHelperFormatter.formatTemplate(
+ StringArrayBase64DecodeTemplate(this.randomGenerator),
+ {
+ atobPolyfill,
+ atobFunctionName,
+ selfDefendingCode,
+ stringArrayCallsWrapperName: this.stringArrayCallsWrapperName
+ }
+ );
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCallsWrapperCodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCallsWrapperCodeHelper.ts
new file mode 100644
index 0000000..0f5b793
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCallsWrapperCodeHelper.ts
@@ -0,0 +1,144 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
+
+import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TStatement } from '../../types/node/TStatement';
+
+import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
+import { ICustomCodeHelperObfuscator } from '../../interfaces/custom-code-helpers/ICustomCodeHelperObfuscator';
+import { IEscapeSequenceEncoder } from '../../interfaces/utils/IEscapeSequenceEncoder';
+import { IOptions } from '../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
+
+import { initializable } from '../../decorators/Initializable';
+
+import { SelfDefendingTemplate } from './templates/string-array-calls-wrapper/SelfDefendingTemplate';
+import { StringArrayCallsWrapperTemplate } from './templates/string-array-calls-wrapper/StringArrayCallsWrapperTemplate';
+
+import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper';
+import { NodeUtils } from '../../node/NodeUtils';
+
+@injectable()
+export class StringArrayCallsWrapperCodeHelper extends AbstractCustomCodeHelper {
+ /**
+ * @type {number}
+ */
+ @initializable()
+ protected indexShiftAmount!: number;
+
+ /**
+ * @type {string}
+ */
+ @initializable()
+ protected stringArrayName!: string;
+
+ /**
+ * @type {string}
+ */
+ @initializable()
+ protected stringArrayCallsWrapperName!: string;
+
+ /**
+ * @type {IEscapeSequenceEncoder}
+ */
+ private readonly escapeSequenceEncoder: IEscapeSequenceEncoder;
+
+ /**
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
+ * @param {ICustomCodeHelperObfuscator} customCodeHelperObfuscator
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ * @param {IEscapeSequenceEncoder} escapeSequenceEncoder
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
+ @inject(ServiceIdentifiers.ICustomCodeHelperObfuscator) customCodeHelperObfuscator: ICustomCodeHelperObfuscator,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions,
+ @inject(ServiceIdentifiers.IEscapeSequenceEncoder) escapeSequenceEncoder: IEscapeSequenceEncoder
+ ) {
+ super(
+ identifierNamesGeneratorFactory,
+ customCodeHelperFormatter,
+ customCodeHelperObfuscator,
+ randomGenerator,
+ options
+ );
+
+ this.escapeSequenceEncoder = escapeSequenceEncoder;
+ }
+
+ /**
+ * @param {string} stringArrayName
+ * @param {string} stringArrayCallsWrapperName
+ * @param {number} indexShiftAmount
+ */
+ public initialize (
+ stringArrayName: string,
+ stringArrayCallsWrapperName: string,
+ indexShiftAmount: number
+ ): void {
+ this.stringArrayName = stringArrayName;
+ this.stringArrayCallsWrapperName = stringArrayCallsWrapperName;
+ this.indexShiftAmount = indexShiftAmount;
+ }
+
+ /**
+ * @param {string} codeHelperTemplate
+ * @returns {TStatement[]}
+ */
+ protected getNodeStructure (codeHelperTemplate: string): TStatement[] {
+ return NodeUtils.convertCodeToStructure(codeHelperTemplate);
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getCodeHelperTemplate (): string {
+ const decodeCodeHelperTemplate: string = this.getDecodeStringArrayTemplate();
+
+ const preservedNames: string[] = [`^${this.stringArrayName}$`];
+
+ return this.customCodeHelperObfuscator.obfuscateTemplate(
+ this.customCodeHelperFormatter.formatTemplate(StringArrayCallsWrapperTemplate(), {
+ decodeCodeHelperTemplate,
+ stringArrayCallsWrapperName: this.stringArrayCallsWrapperName,
+ stringArrayName: this.stringArrayName,
+ indexShiftAmount: this.indexShiftAmount
+ }),
+ {
+ reservedNames: preservedNames
+ }
+ );
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getDecodeStringArrayTemplate (): string {
+ return '';
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getSelfDefendingTemplate (): string {
+ if (!this.options.selfDefending) {
+ return '';
+ }
+
+ return this.customCodeHelperFormatter.formatTemplate(
+ SelfDefendingTemplate(
+ this.randomGenerator,
+ this.escapeSequenceEncoder
+ ),
+ {
+ stringArrayCallsWrapperName: this.stringArrayCallsWrapperName,
+ stringArrayName: this.stringArrayName
+ }
+ );
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCallsWrapperRc4CodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCallsWrapperRc4CodeHelper.ts
new file mode 100644
index 0000000..88a91d2
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCallsWrapperRc4CodeHelper.ts
@@ -0,0 +1,36 @@
+import { injectable, } from 'inversify';
+
+import { AtobTemplate } from './templates/string-array-calls-wrapper/AtobTemplate';
+import { Rc4Template } from './templates/string-array-calls-wrapper/Rc4Template';
+import { StringArrayRC4DecodeTemplate } from './templates/string-array-calls-wrapper/StringArrayRC4DecodeTemplate';
+
+import { StringArrayCallsWrapperCodeHelper } from './StringArrayCallsWrapperCodeHelper';
+
+@injectable()
+export class StringArrayCallsWrapperRc4CodeHelper extends StringArrayCallsWrapperCodeHelper {
+ /**
+ * @returns {string}
+ */
+ protected getDecodeStringArrayTemplate (): string {
+ const atobFunctionName: string = this.randomGenerator.getRandomString(6);
+
+ const atobPolyfill: string = this.customCodeHelperFormatter.formatTemplate(AtobTemplate(), {
+ atobFunctionName
+ });
+ const rc4Polyfill: string = this.customCodeHelperFormatter.formatTemplate(Rc4Template(), {
+ atobFunctionName
+ });
+
+ const selfDefendingCode: string = this.getSelfDefendingTemplate();
+
+ return this.customCodeHelperFormatter.formatTemplate(
+ StringArrayRC4DecodeTemplate(this.randomGenerator),
+ {
+ atobPolyfill,
+ rc4Polyfill,
+ selfDefendingCode,
+ stringArrayCallsWrapperName: this.stringArrayCallsWrapperName
+ }
+ );
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCodeHelper.ts
new file mode 100644
index 0000000..71aad95
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayCodeHelper.ts
@@ -0,0 +1,103 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
+
+import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TStatement } from '../../types/node/TStatement';
+
+import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
+import { ICustomCodeHelperObfuscator } from '../../interfaces/custom-code-helpers/ICustomCodeHelperObfuscator';
+import { IOptions } from '../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
+import { IStringArrayStorage } from '../../interfaces/storages/string-array-transformers/IStringArrayStorage';
+import { IStringArrayStorageItemData } from '../../interfaces/storages/string-array-transformers/IStringArrayStorageItem';
+
+import { initializable } from '../../decorators/Initializable';
+
+import { StringArrayTemplate } from './templates/string-array/StringArrayTemplate';
+
+import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper';
+import { NodeUtils } from '../../node/NodeUtils';
+import { StringUtils } from '../../utils/StringUtils';
+
+@injectable()
+export class StringArrayCodeHelper extends AbstractCustomCodeHelper {
+ /**
+ * @type {IStringArrayStorage}
+ */
+ @initializable()
+ private stringArrayStorage!: IStringArrayStorage;
+
+ /**
+ * @type {string}
+ */
+ @initializable()
+ private stringArrayName!: string;
+
+ /**
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
+ * @param {ICustomCodeHelperObfuscator} customCodeHelperObfuscator
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
+ @inject(ServiceIdentifiers.ICustomCodeHelperObfuscator) customCodeHelperObfuscator: ICustomCodeHelperObfuscator,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ super(
+ identifierNamesGeneratorFactory,
+ customCodeHelperFormatter,
+ customCodeHelperObfuscator,
+ randomGenerator,
+ options
+ );
+ }
+
+ /**
+ * @param {IStringArrayStorage} stringArrayStorage
+ * @param {string} stringArrayName
+ */
+ public initialize (
+ stringArrayStorage: IStringArrayStorage,
+ stringArrayName: string
+ ): void {
+ this.stringArrayStorage = stringArrayStorage;
+ this.stringArrayName = stringArrayName;
+ }
+
+ /**
+ * @param {string} codeHelperTemplate
+ * @returns {TStatement[]}
+ */
+ protected getNodeStructure (codeHelperTemplate: string): TStatement[] {
+ return NodeUtils.convertCodeToStructure(codeHelperTemplate);
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getCodeHelperTemplate (): string {
+ return this.customCodeHelperFormatter.formatTemplate(StringArrayTemplate(), {
+ stringArrayName: this.stringArrayName,
+ stringArrayStorageItems: this.getEncodedStringArrayStorageItems()
+ });
+ }
+
+ /**
+ * @returns {string}
+ */
+ private getEncodedStringArrayStorageItems (): string {
+ return Array
+ .from(this.stringArrayStorage.getStorage().values())
+ .map((stringArrayStorageItemData: IStringArrayStorageItemData): string => {
+ const escapedEncodedValue: string = StringUtils.escapeJsString(stringArrayStorageItemData.encodedValue);
+
+ return `'${escapedEncodedValue}'`;
+ })
+ .toString();
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper.ts
new file mode 100644
index 0000000..b907e2c
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper.ts
@@ -0,0 +1,121 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
+
+import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TStatement } from '../../types/node/TStatement';
+
+import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
+import { ICustomCodeHelperObfuscator } from '../../interfaces/custom-code-helpers/ICustomCodeHelperObfuscator';
+import { IEscapeSequenceEncoder } from '../../interfaces/utils/IEscapeSequenceEncoder';
+import { IOptions } from '../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
+
+import { initializable } from '../../decorators/Initializable';
+
+import { SelfDefendingTemplate } from './templates/string-array-rotate-function/SelfDefendingTemplate';
+import { StringArrayRotateFunctionTemplate } from './templates/string-array-rotate-function/StringArrayRotateFunctionTemplate';
+
+import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper';
+import { NodeUtils } from '../../node/NodeUtils';
+import { NumberUtils } from '../../utils/NumberUtils';
+
+@injectable()
+export class StringArrayRotateFunctionCodeHelper extends AbstractCustomCodeHelper {
+ /**
+ * @type {string}
+ */
+ @initializable()
+ private stringArrayName!: string;
+
+ /**
+ * @param {number}
+ */
+ @initializable()
+ private stringArrayRotationAmount!: number;
+
+ /**
+ * @type {IEscapeSequenceEncoder}
+ */
+ private readonly escapeSequenceEncoder: IEscapeSequenceEncoder;
+
+ /**
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
+ * @param {ICustomCodeHelperObfuscator} customCodeHelperObfuscator
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ * @param {IEscapeSequenceEncoder} escapeSequenceEncoder
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
+ @inject(ServiceIdentifiers.ICustomCodeHelperObfuscator) customCodeHelperObfuscator: ICustomCodeHelperObfuscator,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions,
+ @inject(ServiceIdentifiers.IEscapeSequenceEncoder) escapeSequenceEncoder: IEscapeSequenceEncoder
+ ) {
+ super(
+ identifierNamesGeneratorFactory,
+ customCodeHelperFormatter,
+ customCodeHelperObfuscator,
+ randomGenerator,
+ options
+ );
+
+ this.escapeSequenceEncoder = escapeSequenceEncoder;
+ }
+
+ /**
+ * @param {string} stringArrayName
+ * @param {number} stringArrayRotationAmount
+ */
+ public initialize (
+ stringArrayName: string,
+ stringArrayRotationAmount: number
+ ): void {
+ this.stringArrayName = stringArrayName;
+ this.stringArrayRotationAmount = stringArrayRotationAmount;
+ }
+
+ /**
+ * @param {string} codeHelperTemplate
+ * @returns {TStatement[]}
+ */
+ protected getNodeStructure (codeHelperTemplate: string): TStatement[] {
+ return NodeUtils.convertCodeToStructure(codeHelperTemplate);
+ }
+
+ /**
+ * @returns {string}
+ */
+ protected getCodeHelperTemplate (): string {
+ const timesName: string = this.identifierNamesGenerator.generateNext();
+ const whileFunctionName: string = this.identifierNamesGenerator.generateNext();
+ const preservedNames: string[] = [`^${this.stringArrayName}$`];
+
+ let code: string = '';
+
+ if (this.options.selfDefending) {
+ code = this.customCodeHelperFormatter.formatTemplate(SelfDefendingTemplate(this.escapeSequenceEncoder), {
+ timesName,
+ whileFunctionName
+ });
+ } else {
+ code = `${whileFunctionName}(++${timesName})`;
+ }
+
+ return this.customCodeHelperObfuscator.obfuscateTemplate(
+ this.customCodeHelperFormatter.formatTemplate(StringArrayRotateFunctionTemplate(), {
+ code,
+ timesName,
+ whileFunctionName,
+ stringArrayName: this.stringArrayName,
+ stringArrayRotationAmount: NumberUtils.toHex(this.stringArrayRotationAmount)
+ }),
+ {
+ reservedNames: preservedNames
+ }
+ );
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts
new file mode 100644
index 0000000..8bea906
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts
@@ -0,0 +1,175 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
+
+import { TCustomCodeHelperFactory } from '../../../types/container/custom-code-helpers/TCustomCodeHelperFactory';
+import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
+import { TInitialData } from '../../../types/TInitialData';
+import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
+import { TStringArrayEncoding } from '../../../types/options/TStringArrayEncoding';
+
+import { ICallsGraphData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
+import { ICustomCodeHelper } from '../../../interfaces/custom-code-helpers/ICustomCodeHelper';
+import { IOptions } from '../../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
+import { IStringArrayStorage } from '../../../interfaces/storages/string-array-transformers/IStringArrayStorage';
+
+import { initializable } from '../../../decorators/Initializable';
+
+import { CustomCodeHelper } from '../../../enums/custom-code-helpers/CustomCodeHelper';
+import { ObfuscationEvent } from '../../../enums/event-emitters/ObfuscationEvent';
+import { StringArrayEncoding } from '../../../enums/node-transformers/string-array-transformers/StringArrayEncoding';
+
+import { AbstractCustomCodeHelperGroup } from '../../AbstractCustomCodeHelperGroup';
+import { NodeAppender } from '../../../node/NodeAppender';
+import { StringArrayCallsWrapperCodeHelper } from '../StringArrayCallsWrapperCodeHelper';
+import { StringArrayCodeHelper } from '../StringArrayCodeHelper';
+import { StringArrayRotateFunctionCodeHelper } from '../StringArrayRotateFunctionCodeHelper';
+
+@injectable()
+export class StringArrayCodeHelperGroup extends AbstractCustomCodeHelperGroup {
+ /**
+ * @type {Map<TStringArrayEncoding, CustomCodeHelper>}
+ */
+ private static readonly stringArrayCallsWrapperCodeHelperMap: Map<TStringArrayEncoding, CustomCodeHelper> = new Map([
+ [StringArrayEncoding.None, CustomCodeHelper.StringArrayCallsWrapper],
+ [StringArrayEncoding.Base64, CustomCodeHelper.StringArrayCallsWrapperBase64],
+ [StringArrayEncoding.Rc4, CustomCodeHelper.StringArrayCallsWrapperRc4]
+ ]);
+
+ /**
+ * @type {Map<CustomCodeHelper, ICustomCodeHelper>}
+ */
+ @initializable()
+ protected customCodeHelpers!: Map <CustomCodeHelper, ICustomCodeHelper>;
+
+ /**
+ * @type {ObfuscationEvent}
+ */
+ protected appendEvent: ObfuscationEvent = ObfuscationEvent.AfterObfuscation;
+
+ /**
+ * @type {TCustomCodeHelperFactory}
+ */
+ private readonly customCodeHelperFactory: TCustomCodeHelperFactory;
+
+ /**
+ * @type {IStringArrayStorage}
+ */
+ private readonly stringArrayStorage: IStringArrayStorage;
+
+ /**
+ * @param {TCustomCodeHelperFactory} customCodeHelperFactory
+ * @param {IStringArrayStorage} stringArrayStorage
+ * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IOptions} options
+ */
+ public constructor (
+ @inject(ServiceIdentifiers.Factory__ICustomCodeHelper) customCodeHelperFactory: TCustomCodeHelperFactory,
+ @inject(ServiceIdentifiers.IStringArrayStorage) stringArrayStorage: IStringArrayStorage,
+ @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
+ identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
+ @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
+ ) {
+ super(identifierNamesGeneratorFactory, randomGenerator, options);
+
+ this.customCodeHelperFactory = customCodeHelperFactory;
+ this.stringArrayStorage = stringArrayStorage;
+ }
+
+ /**
+ * @param {TNodeWithStatements} nodeWithStatements
+ * @param {ICallsGraphData[]} callsGraphData
+ */
+ public appendNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void {
+ if (!this.stringArrayStorage.getLength()) {
+ return;
+ }
+
+ // stringArray helper nodes append
+ this.appendCustomNodeIfExist(
+ CustomCodeHelper.StringArray,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<StringArrayCodeHelper>>) => {
+ NodeAppender.prepend(nodeWithStatements, customCodeHelper.getNode());
+ }
+ );
+
+ // stringArrayCallsWrapper helper nodes append
+ const stringArrayEncodingsLength: number = this.options.stringArrayEncoding.length;
+ for (let i = 0; i < stringArrayEncodingsLength; i++) {
+ const stringArrayEncoding: TStringArrayEncoding = this.options.stringArrayEncoding[i];
+ const stringArrayCallsWrapperCodeHelperName: CustomCodeHelper = this.getStringArrayCallsWrapperCodeHelperName(stringArrayEncoding);
+
+ this.appendCustomNodeIfExist(
+ stringArrayCallsWrapperCodeHelperName,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<StringArrayCallsWrapperCodeHelper>>) => {
+ NodeAppender.insertAtIndex(nodeWithStatements, customCodeHelper.getNode(), i + 1);
+ }
+ );
+ }
+
+ // stringArrayRotateFunction helper nodes append
+ this.appendCustomNodeIfExist(
+ CustomCodeHelper.StringArrayRotateFunction,
+ (customCodeHelper: ICustomCodeHelper<TInitialData<StringArrayRotateFunctionCodeHelper>>) => {
+ NodeAppender.insertAtIndex(nodeWithStatements, customCodeHelper.getNode(), 1);
+ }
+ );
+ }
+
+ public initialize (): void {
+ this.customCodeHelpers = new Map <CustomCodeHelper, ICustomCodeHelper>();
+
+ if (!this.options.stringArray) {
+ return;
+ }
+
+ // stringArray helper initialize
+ const stringArrayCodeHelper: ICustomCodeHelper<TInitialData<StringArrayCodeHelper>> =
+ this.customCodeHelperFactory(CustomCodeHelper.StringArray);
+ const stringArrayName: string = this.stringArrayStorage.getStorageName();
+
+ stringArrayCodeHelper.initialize(this.stringArrayStorage, stringArrayName);
+ this.customCodeHelpers.set(CustomCodeHelper.StringArray, stringArrayCodeHelper);
+
+ // stringArrayCallsWrapper helper initialize
+ for (const stringArrayEncoding of this.options.stringArrayEncoding) {
+ const stringArrayCallsWrapperCodeHelperName: CustomCodeHelper = this.getStringArrayCallsWrapperCodeHelperName(stringArrayEncoding);
+ const stringArrayCallsWrapperCodeHelper: ICustomCodeHelper<TInitialData<StringArrayCallsWrapperCodeHelper>> =
+ this.customCodeHelperFactory(stringArrayCallsWrapperCodeHelperName);
+ const stringArrayCallsWrapperName: string = this.stringArrayStorage.getStorageCallsWrapperName(stringArrayEncoding);
+
+ stringArrayCallsWrapperCodeHelper.initialize(
+ stringArrayName,
+ stringArrayCallsWrapperName,
+ this.stringArrayStorage.getIndexShiftAmount()
+ );
+
+ this.customCodeHelpers.set(stringArrayCallsWrapperCodeHelperName, stringArrayCallsWrapperCodeHelper);
+ }
+
+ // stringArrayRotateFunction helper initialize
+ const stringArrayRotateFunctionCodeHelper: ICustomCodeHelper<TInitialData<StringArrayRotateFunctionCodeHelper>> =
+ this.customCodeHelperFactory(CustomCodeHelper.StringArrayRotateFunction);
+
+ stringArrayRotateFunctionCodeHelper.initialize(
+ stringArrayName,
+ this.stringArrayStorage.getRotationAmount()
+ );
+
+ if (this.options.rotateStringArray) {
+ this.customCodeHelpers.set(CustomCodeHelper.StringArrayRotateFunction, stringArrayRotateFunctionCodeHelper);
+ }
+ }
+
+ /**
+ * @param {TStringArrayEncoding} stringArrayEncoding
+ * @returns {CustomCodeHelper}
+ */
+ private getStringArrayCallsWrapperCodeHelperName (stringArrayEncoding: TStringArrayEncoding): CustomCodeHelper {
+ return StringArrayCodeHelperGroup
+ .stringArrayCallsWrapperCodeHelperMap.get(stringArrayEncoding)
+ ?? CustomCodeHelper.StringArrayCallsWrapper;
+ }
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/AtobTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/AtobTemplate.ts
new file mode 100644
index 0000000..8933a9d
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/AtobTemplate.ts
@@ -0,0 +1,24 @@
+import { base64alphabetSwapped } from '../../../../constants/Base64AlphabetSwapped';
+
+/**
+ * @returns {string}
+ */
+export function AtobTemplate (): string {
+ return `
+ var {atobFunctionName} = function (input) {
+ const chars = '${base64alphabetSwapped}';
+
+ const str = String(input).replace(/=+$/, '');
+ let output = '';
+ for (
+ let bc = 0, bs, buffer, idx = 0;
+ buffer = str.charAt(idx++);
+ ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
+ bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
+ ) {
+ buffer = chars.indexOf(buffer);
+ }
+ return output;
+ };
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/Rc4Template.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/Rc4Template.ts
new file mode 100644
index 0000000..865cbaf
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/Rc4Template.ts
@@ -0,0 +1,45 @@
+/**
+ * @returns {string}
+ */
+export function Rc4Template (): string {
+ return `
+ const rc4 = function (str, key) {
+ let s = [], j = 0, x, res = '', newStr = '';
+
+ str = {atobFunctionName}(str);
+
+ for (let k = 0, length = str.length; k < length; k++) {
+ newStr += '%' + ('00' + str.charCodeAt(k).toString(16)).slice(-2);
+ }
+
+ str = decodeURIComponent(newStr);
+
+ let i;
+
+ for (i = 0; i < 256; i++) {
+ s[i] = i;
+ }
+
+ for (i = 0; i < 256; i++) {
+ j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;
+ x = s[i];
+ s[i] = s[j];
+ s[j] = x;
+ }
+
+ i = 0;
+ j = 0;
+
+ for (let y = 0; y < str.length; y++) {
+ i = (i + 1) % 256;
+ j = (j + s[i]) % 256;
+ x = s[i];
+ s[i] = s[j];
+ s[j] = x;
+ res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);
+ }
+
+ return res;
+ }
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/SelfDefendingTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/SelfDefendingTemplate.ts
new file mode 100644
index 0000000..bf08c20
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/SelfDefendingTemplate.ts
@@ -0,0 +1,66 @@
+import { IEscapeSequenceEncoder } from '../../../../interfaces/utils/IEscapeSequenceEncoder';
+import { IRandomGenerator } from '../../../../interfaces/utils/IRandomGenerator';
+
+/**
+ * @param {IRandomGenerator} randomGenerator
+ * @param {IEscapeSequenceEncoder} escapeSequenceEncoder
+ * @returns {string}
+ * @constructor
+ */
+export function SelfDefendingTemplate (
+ randomGenerator: IRandomGenerator,
+ escapeSequenceEncoder: IEscapeSequenceEncoder
+): string {
+ const identifierLength: number = 6;
+ const rc4BytesIdentifier: string = randomGenerator.getRandomString(identifierLength);
+ const statesIdentifier: string = randomGenerator.getRandomString(identifierLength);
+ const newStateIdentifier: string = randomGenerator.getRandomString(identifierLength);
+ const firstStateIdentifier: string = randomGenerator.getRandomString(identifierLength);
+ const secondStateIdentifier: string = randomGenerator.getRandomString(identifierLength);
+ const checkStateIdentifier: string = randomGenerator.getRandomString(identifierLength);
+ const runStateIdentifier: string = randomGenerator.getRandomString(identifierLength);
+ const getStateIdentifier: string = randomGenerator.getRandomString(identifierLength);
+ const stateResultIdentifier: string = randomGenerator.getRandomString(identifierLength);
+
+ return `
+ const StatesClass = function (${rc4BytesIdentifier}) {
+ this.${rc4BytesIdentifier} = ${rc4BytesIdentifier};
+ this.${statesIdentifier} = [1, 0, 0];
+ this.${newStateIdentifier} = function(){return 'newState';};
+ this.${firstStateIdentifier} = '${
+ escapeSequenceEncoder.encode('\\w+ *\\(\\) *{\\w+ *', true)
+ }';
+ this.${secondStateIdentifier} = '${
+ escapeSequenceEncoder.encode('[\'|"].+[\'|"];? *}', true)
+ }';
+ };
+
+ StatesClass.prototype.${checkStateIdentifier} = function () {
+ const regExp = new RegExp(this.${firstStateIdentifier} + this.${secondStateIdentifier});
+ const expression = regExp.test(this.${newStateIdentifier}.toString())
+ ? --this.${statesIdentifier}[1]
+ : --this.${statesIdentifier}[0];
+
+ return this.${runStateIdentifier}(expression);
+ };
+
+ StatesClass.prototype.${runStateIdentifier} = function (${stateResultIdentifier}) {
+ if (!Boolean(~${stateResultIdentifier})) {
+ return ${stateResultIdentifier};
+ }
+
+ return this.${getStateIdentifier}(this.${rc4BytesIdentifier});
+ };
+
+ StatesClass.prototype.${getStateIdentifier} = function (${rc4BytesIdentifier}) {
+ for (let i = 0, len = this.${statesIdentifier}.length; i < len; i++) {
+ this.${statesIdentifier}.push(Math.round(Math.random()));
+ len = this.${statesIdentifier}.length;
+ }
+
+ return ${rc4BytesIdentifier}(this.${statesIdentifier}[0]);
+ };
+
+ new StatesClass({stringArrayCallsWrapperName}).${checkStateIdentifier}();
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/StringArrayBase64DecodeTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/StringArrayBase64DecodeTemplate.ts
new file mode 100644
index 0000000..1ad7eba
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/StringArrayBase64DecodeTemplate.ts
@@ -0,0 +1,47 @@
+import { IRandomGenerator } from '../../../../interfaces/utils/IRandomGenerator';
+
+/**
+ * @param {IRandomGenerator} randomGenerator
+ * @returns {string}
+ * @constructor
+ */
+export function StringArrayBase64DecodeTemplate (
+ randomGenerator: IRandomGenerator
+): string {
+ const identifierLength: number = 6;
+ const initializedIdentifier: string = randomGenerator.getRandomString(identifierLength);
+ const base64DecodeFunctionIdentifier: string = randomGenerator.getRandomString(identifierLength);
+ const dataIdentifier: string = randomGenerator.getRandomString(identifierLength);
+
+ return `
+ if ({stringArrayCallsWrapperName}.${initializedIdentifier} === undefined) {
+ {atobPolyfill}
+
+ {stringArrayCallsWrapperName}.${base64DecodeFunctionIdentifier} = function (str) {
+ const string = {atobFunctionName}(str);
+ let newStringChars = [];
+
+ for (let i = 0, length = string.length; i < length; i++) {
+ newStringChars += '%' + ('00' + string.charCodeAt(i).toString(16)).slice(-2);
+ }
+
+ return decodeURIComponent(newStringChars);
+ };
+
+ {stringArrayCallsWrapperName}.${dataIdentifier} = {};
+
+ {stringArrayCallsWrapperName}.${initializedIdentifier} = true;
+ }
+
+ const cachedValue = {stringArrayCallsWrapperName}.${dataIdentifier}[index];
+
+ if (cachedValue === undefined) {
+ {selfDefendingCode}
+
+ value = {stringArrayCallsWrapperName}.${base64DecodeFunctionIdentifier}(value);
+ {stringArrayCallsWrapperName}.${dataIdentifier}[index] = value;
+ } else {
+ value = cachedValue;
+ }
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/StringArrayCallsWrapperTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/StringArrayCallsWrapperTemplate.ts
new file mode 100644
index 0000000..e58ded1
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/StringArrayCallsWrapperTemplate.ts
@@ -0,0 +1,16 @@
+/**
+ * @returns {string}
+ */
+export function StringArrayCallsWrapperTemplate (): string {
+ return `
+ const {stringArrayCallsWrapperName} = function (index, key) {
+ index = index - {indexShiftAmount};
+
+ let value = {stringArrayName}[index];
+
+ {decodeCodeHelperTemplate}
+
+ return value;
+ };
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/StringArrayRC4DecodeTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/StringArrayRC4DecodeTemplate.ts
new file mode 100644
index 0000000..092a396
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/StringArrayRC4DecodeTemplate.ts
@@ -0,0 +1,44 @@
+import { IRandomGenerator } from '../../../../interfaces/utils/IRandomGenerator';
+
+/**
+ * @param {IRandomGenerator} randomGenerator
+ * @returns {string}
+ * @constructor
+ */
+export function StringArrayRC4DecodeTemplate (
+ randomGenerator: IRandomGenerator
+): string {
+ const identifierLength: number = 6;
+ const initializedIdentifier: string = randomGenerator.getRandomString(identifierLength);
+ const rc4Identifier: string = randomGenerator.getRandomString(identifierLength);
+ const dataIdentifier: string = randomGenerator.getRandomString(identifierLength);
+ const onceIdentifier: string = randomGenerator.getRandomString(identifierLength);
+
+ return `
+ if ({stringArrayCallsWrapperName}.${initializedIdentifier} === undefined) {
+ {atobPolyfill}
+
+ {rc4Polyfill}
+ {stringArrayCallsWrapperName}.${rc4Identifier} = rc4;
+
+ {stringArrayCallsWrapperName}.${dataIdentifier} = {};
+
+ {stringArrayCallsWrapperName}.${initializedIdentifier} = true;
+ }
+
+ const cachedValue = {stringArrayCallsWrapperName}.${dataIdentifier}[index];
+
+ if (cachedValue === undefined) {
+ if ({stringArrayCallsWrapperName}.${onceIdentifier} === undefined) {
+ {selfDefendingCode}
+
+ {stringArrayCallsWrapperName}.${onceIdentifier} = true;
+ }
+
+ value = {stringArrayCallsWrapperName}.${rc4Identifier}(value, key);
+ {stringArrayCallsWrapperName}.${dataIdentifier}[index] = value;
+ } else {
+ value = cachedValue;
+ }
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-rotate-function/SelfDefendingTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-rotate-function/SelfDefendingTemplate.ts
new file mode 100644
index 0000000..72f16bf
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-rotate-function/SelfDefendingTemplate.ts
@@ -0,0 +1,81 @@
+import { IEscapeSequenceEncoder } from '../../../../interfaces/utils/IEscapeSequenceEncoder';
+
+/**
+ * SelfDefendingTemplate. Enter code in infinity loop.
+ *
+ * @param {IEscapeSequenceEncoder} escapeSequenceEncoder
+ * @returns {string}
+ */
+export function SelfDefendingTemplate (escapeSequenceEncoder: IEscapeSequenceEncoder): string {
+ return `
+ const selfDefendingFunc = function () {
+ const object = {
+ data: {
+ key: 'cookie',
+ value: 'timeout'
+ },
+ setCookie: function (options, name, value, document) {
+ document = document || {};
+
+ let updatedCookie = name + "=" + value;
+ let i = 0;
+
+ for (let i = 0, len = options.length; i < len; i++) {
+ const propName = options[i];
+
+ updatedCookie += "; " + propName;
+
+ const propValue = options[propName];
+
+ options.push(propValue);
+ len = options.length;
+
+ if (propValue !== true) {
+ updatedCookie += "=" + propValue;
+ }
+ }
+
+ document['cookie'] = updatedCookie;
+ },
+ removeCookie: function(){return 'dev';},
+ getCookie: function (document, name) {
+ document = document || function (value) { return value };
+ const matches = document(new RegExp(
+ "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
+ ));
+
+ const func = function (param1, param2) {
+ param1(++param2);
+ };
+
+ func({whileFunctionName}, {timesName});
+
+ return matches ? decodeURIComponent(matches[1]) : undefined;
+ }
+ };
+
+ const test1 = function () {
+ const regExp = new RegExp('${
+ escapeSequenceEncoder.encode('\\w+ *\\(\\) *{\\w+ *[\'|"].+[\'|"];? *}', true)
+ }');
+
+ return regExp.test(object.removeCookie.toString());
+ };
+
+ object['updateCookie'] = test1;
+
+ let cookie = '';
+ const result = object['updateCookie']();
+
+ if (!result) {
+ object['setCookie'](['*'], 'counter', 1);
+ } else if (result) {
+ cookie = object['getCookie'](null, 'counter');
+ } else {
+ object['removeCookie']();
+ }
+ };
+
+ selfDefendingFunc();
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-rotate-function/StringArrayRotateFunctionTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-rotate-function/StringArrayRotateFunctionTemplate.ts
new file mode 100644
index 0000000..af55db6
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array-rotate-function/StringArrayRotateFunctionTemplate.ts
@@ -0,0 +1,16 @@
+/**
+ * @returns {string}
+ */
+export function StringArrayRotateFunctionTemplate (): string {
+ return `
+ (function (array, {timesName}) {
+ const {whileFunctionName} = function (times) {
+ while (--times) {
+ array['push'](array['shift']());
+ }
+ };
+
+ {code}
+ })({stringArrayName}, {stringArrayRotationAmount});
+ `;
+}
diff --git a/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array/StringArrayTemplate.ts b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array/StringArrayTemplate.ts
new file mode 100644
index 0000000..6d5447c
--- /dev/null
+++ b/src/node_modules/javascript-obfuscator/src/custom-code-helpers/string-array/templates/string-array/StringArrayTemplate.ts
@@ -0,0 +1,8 @@
+/**
+ * @returns {string}
+ */
+export function StringArrayTemplate (): string {
+ return `
+ const {stringArrayName} = [{stringArrayStorageItems}];
+ `;
+}