javascript-obfuscator
Version:
JavaScript obfuscator
84 lines (72 loc) • 3.38 kB
text/typescript
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';
()
export class DebugProtectionFunctionCallCodeHelper extends AbstractCustomCodeHelper {
/**
* @type {string}
*/
()
private callsControllerFunctionName!: string;
/**
* @type {string}
*/
()
private debugProtectionFunctionName!: string;
/**
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
* @param {ICustomCodeHelperObfuscator} customCodeHelperObfuscator
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
public constructor (
(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
(ServiceIdentifiers.ICustomCodeHelperObfuscator) customCodeHelperObfuscator: ICustomCodeHelperObfuscator,
(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
(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
});
}
}