diff --git a/CHANGELOG.md b/CHANGELOG.md index 35feddad8..839cef024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ Change Log +v5.4.2 +--- +* Fixed obfuscated code hanging in Bun when `selfDefending` is enabled. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1404 + v5.4.1 --- * Fixed `Utils.nodeRequire` causing `ReferenceError: require is not defined` in browser build by making it lazy-evaluated diff --git a/CLAUDE.md b/CLAUDE.md index 03d0777fb..0074f22d0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -42,7 +42,7 @@ - **Parser**: Acorn 8.8.2 (ES3-ES2020 support) - **Code Generator**: @javascript-obfuscator/escodegen 2.3.0 - **AST Traversal**: @javascript-obfuscator/estraverse 5.4.0 -- **DI Framework**: InversifyJS 6.0.1 +- **DI Framework**: InversifyJS 7.10.8 - **Testing**: Mocha 10.4.0 + Chai 4.3.7 - **Build System**: Webpack 5.75.0 @@ -210,7 +210,7 @@ The obfuscation process follows a multi-stage pipeline defined in `JavaScriptObf ### Dependency Injection Architecture -The project uses **InversifyJS** for dependency injection, providing: +The project uses **InversifyJS v7** for dependency injection, providing: - **Modularity**: Clean separation of concerns - **Testability**: Easy mocking and testing @@ -219,6 +219,13 @@ The project uses **InversifyJS** for dependency injection, providing: All components are registered in container modules located in `src/container/modules/`. +**Key Changes in InversifyJS v7:** +- Container modules now use `ContainerModuleLoadOptions` instead of separate `bind`, `unbind`, etc. parameters +- `getNamed`, `getTagged`, etc. are replaced by `get(serviceId, { name: ... })` or `get(serviceId, { tag: ... })` +- `load()` and `unload()` are now async, with `loadSync()` and `unloadSync()` alternatives for synchronous operations +- Types like `Context`, `Newable`, `Factory` are now directly exported instead of through `interfaces` namespace +- Custom metadata and middleware features have been removed + ## Key Components Deep Dive ### 1. JavaScriptObfuscator (Main Engine) diff --git a/README.md b/README.md index d86338ae9..937bc642a 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,25 @@ Huge thanks to all supporters! --- -### :rocket: Obfuscator.io with VM Obfuscation is out! +### :rocket: Obfuscator.io with VM Obfuscation -**Obfuscator.io** features **VM-based bytecode obfuscation** — the most advanced code protection available. Your JavaScript functions are transformed into custom bytecode running on an embedded virtual machine, making reverse engineering extremely difficult. +**Obfuscator.io** adds **VM-based bytecode obfuscation** to this package - your JavaScript functions are compiled to custom bytecode that runs on an embedded virtual machine. Each build produces unique opcodes and VM structure, making reverse engineering and automated deobfuscation dramatically harder. -[Try it at obfuscator.io](https://obfuscator.io) +| Protection goal | Free (this package) | [obfuscator.io](https://obfuscator.io) | +| --- |-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Rename identifiers | ✅ variable/function renaming | ✅ + VM-local symbols never exposed as JavaScript | +| Obscure strings | ✅ string array + base64/rc4 | ✅ + strings embedded in bytecode constants | +| Obscure control flow | ✅ control flow flattening | ✅ full bytecode virtualization, [`vmJumpsEncoding`](#vmjumpsencoding) (runtime-computed jump targets), [`vmDeadCodeInjection`](#vmdeadcodeinjection) (fake bytecode sequences) | +| Resist decompilation | ⚠️ output is still JavaScript | ✅ custom opcodes, [`vmStatefulOpcodes`](#vmstatefulopcodes) (position-dependent opcode mapping), [`vmMacroOps`](#vmmacroops) (fused instructions), [`vmDecoyOpcodes`](#vmdecoyopcodes) (fake opcode handlers) | +| Resist automated LLM-based analysis | ❌ fully vulnerable (no LLM-specific defenses) | ✅ bytecode encryption + anti-LLM defenses in [`vmSelfDefending`](#vmselfdefending) and [`vmDebugProtection`](#vmdebugProtection) | +| Encryption | ✅ [`stringArrayEncoding`](#stringarrayencoding) (base64/rc4 on extracted strings) | ✅ [`vmBytecodeEncoding`](#vmbytecodeencoding) (per-instruction encoding), [`vmBytecodeArrayEncoding`](#vmbytecodeArrayEncoding) (whole bytecode array as single block) | +| Anti-debugging | ✅ `debugProtection` (freezes browser DevTools) | ✅ [`vmDebugProtection`](#vmdebugProtection) (multi-layered anti-debugging and anti-analysis defenses) | +| Tamper detection | ✅ `selfDefending` (breaks if beautified) | ✅ [`vmSelfDefending`](#vmselfdefending) (multi-layered tamper detection, anti-hooking, anti-reverse-engineering protection) | +| Runs offline, no network | ✅ | ❌ uses obfuscator.io API (requires token) | -This package provides access to Obfuscator.io Pro API via CLI and Node.js API. +[Visit Obfuscator.io](https://obfuscator.io) · [Pro API methods](#shield-pro-api-methods-vm-obfuscation) + +This package provides access to Obfuscator.io API via CLI and Node.js API. --- @@ -51,6 +63,7 @@ The example of obfuscated code: [github.com](https://github.com/javascript-obfus * Malta: [malta-js-obfuscator](https://github.com/fedeghe/malta-js-obfuscator) * Netlify plugin: [netlify-plugin-js-obfuscator](https://www.npmjs.com/package/netlify-plugin-js-obfuscator) * Snowpack plugin: [snowpack-javascript-obfuscator](https://www.npmjs.com/package/snowpack-javascript-obfuscator) +* Vite plugin: [vite-plugin-bundle-obfuscator](https://github.com/z0ffy/vite-plugin-bundle-obfuscator) [![npm version](https://badge.fury.io/js/javascript-obfuscator.svg)](https://badge.fury.io/js/javascript-obfuscator) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjavascript-obfuscator%2Fjavascript-obfuscator.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fjavascript-obfuscator%2Fjavascript-obfuscator?ref=badge_shield) @@ -513,6 +526,8 @@ When using CLI this prefix will be added automatically. ## JavaScript Obfuscator Options +> :shield: **Looking for VM obfuscation?** Options like `vmObfuscation`, `parseHtml`, and every `vm*` option are Pro-only and require an API token from [obfuscator.io](https://obfuscator.io). Use them via the [`obfuscatePro()`](#shield-pro-api-methods-vm-obfuscation) method, or the `--pro-api-token` CLI flag — see [Pro API Methods](#shield-pro-api-methods-vm-obfuscation). + Following options are available for the JS Obfuscator: #### options: @@ -1870,8 +1885,8 @@ Specify exactly which root-level functions should get VM protection by name. **Example:** ```javascript { - vmObfuscation: true, - vmTargetFunctions: ['someFunctionName'] + vmObfuscation: true, + vmTargetFunctions: ['someFunctionName'] } ``` @@ -1885,8 +1900,8 @@ Specify root-level functions that should never get VM protection. Takes preceden **Example:** ```javascript { - vmObfuscation: true, - vmExcludeFunctions: ['someFunctionName'] + vmObfuscation: true, + vmExcludeFunctions: ['someFunctionName'] } ``` @@ -1906,28 +1921,28 @@ Controls how functions/methods are selected for VM obfuscation. ```javascript // Source code function regularFunction() { - return 'not virtualized'; + return 'not virtualized'; } /* javascript-obfuscator:vm */ function sensitiveFunction() { - return 'this will be VM-protected'; + return 'this will be VM-protected'; } function outer() { - /* javascript-obfuscator:vm */ - function nestedSensitive() { - return 'nested but still VM-protected'; - } - return nestedSensitive(); + /* javascript-obfuscator:vm */ + function nestedSensitive() { + return 'nested but still VM-protected'; + } + return nestedSensitive(); } ``` ```javascript // Obfuscator options { - vmObfuscation: true, - vmTargetFunctionsMode: 'comment' + vmObfuscation: true, + vmTargetFunctionsMode: 'comment' } ``` @@ -2020,10 +2035,10 @@ vmBytecodeArrayEncodingKeyGetter: "window.config.encryption.key" ```ts // Build time JavaScriptObfuscator.obfuscate(code, { - vmObfuscation: true, - vmBytecodeArrayEncoding: true, - vmBytecodeArrayEncodingKey: 'mySecretKey123', - vmBytecodeArrayEncodingKeyGetter: 'window.__VM_KEY__' + vmObfuscation: true, + vmBytecodeArrayEncoding: true, + vmBytecodeArrayEncodingKey: 'mySecretKey123', + vmBytecodeArrayEncodingKeyGetter: 'window.__VM_KEY__' }); // Runtime - key must be set before obfuscated code runs @@ -2045,26 +2060,24 @@ Type: `boolean` Default: `false` Injects fake bytecode sequences that are never executed. These look like real instructions but are skipped during runtime, confusing analysis tools that process them. -### `vmCompactDispatcher` +### `vmMacroOps` Type: `boolean` Default: `false` -Uses a single unified dispatcher (generator-based) for both sync and async/generator code execution. By default (`false`), the VM generates two separate dispatchers: a non-generator version for sync code (faster) and a generator version for async/generator code. When enabled, only the generator-based dispatcher is used for all execution. +Combines common instruction sequences into single "macro" opcodes. For example, `LOAD + ADD + STORE` might become a single `MACRO_ADD_TO_VAR` instruction. This breaks pattern recognition and can improve performance. -**Trade-offs:** -- `false` (default): Larger code size due to dual dispatchers, but faster sync execution (no generator overhead) -- `true`: Smaller code size with single dispatcher, but sync code has generator protocol overhead +### `vmDebugProtection` +Type: `boolean` Default: `false` -Use this when code size is more important than sync execution speed. +Adds multi-layered anti-debugging, anti-analysis, and anti-LLM defenses to the VM runtime. For best results, allow `unsafe-eval` in your Content Security Policy. Works best with `browser`/`browser-no-eval` targets. -### `vmMacroOps` +### `vmSelfDefending` Type: `boolean` Default: `false` -Combines common instruction sequences into single "macro" opcodes. For example, `LOAD + ADD + STORE` might become a single `MACRO_ADD_TO_VAR` instruction. This breaks pattern recognition and can improve performance. +Adds multi-layered tamper detection, anti-hooking, and anti-reverse-engineering protection to the VM runtime. -### `vmDebugProtection` -Type: `boolean` Default: `false` +> :warning: This option force-enables [`vmBytecodeArrayEncoding`](#vmbytecodeArrayEncoding). -Adds anti-debugging measures to the VM runtime. Detects debugger presence and alters behavior when debugging is detected. +Strongly recommended to use together with [`vmDebugProtection`](#vmDebugProtection), [`vmBytecodeArrayEncodingKey`](#vmbytecodeArrayEncodingKey), and [`vmBytecodeArrayEncodingKeyGetter`](#vmbytecodeArrayEncodingKeyGetter). ### `vmStatefulOpcodes` Type: `boolean` Default: `false` @@ -2078,6 +2091,26 @@ Encrypts values on the VM stack during execution. Values are encoded when pushed This option heavily affects performance. +### `vmCompactDispatcher` +Type: `boolean` Default: `false` + +Uses a single VM executor instead of dual executors (sync + generator). Reduces obfuscated code size but adds ~20% performance overhead on recursion-heavy code. + +- `false` (default): dual executors — optimal performance, larger output +- `true`: single executor — smaller output, slightly slower + +### `vmStringArrayBytecodeOnly` +Type: `boolean` Default: `false` + +When enabled, the string array will **only** extract strings from bytecode data — no other strings in the code are transformed. This force-enables `stringArray` even if it's not explicitly set. + +**Why use this:** Extracting all VM runtime strings to a string array is slow. This option targets only bytecode content for string array extraction, improving performance while still protecting bytecode constants. + +- When `vmBytecodeArrayEncoding: false` — strings inside bytecode constant pools (`c` arrays) are extracted +- When `vmBytecodeArrayEncoding: true` — top-level base64 encoded bytecode strings are extracted +- `stringArrayThreshold` still controls what percentage of those bytecode strings are extracted + + ### `strictMode` Type: `boolean | null` Default: `null` diff --git a/package.json b/package.json index 3f6f3f765..0612d2257 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "javascript-obfuscator", - "version": "5.4.1", + "version": "5.4.2", "description": "JavaScript obfuscator", "keywords": [ "obfuscator", @@ -35,7 +35,7 @@ "eslint-scope": "8.4.0", "eslint-visitor-keys": "4.2.1", "fast-deep-equal": "3.1.3", - "inversify": "6.1.4", + "inversify": "7.11.0", "js-string-escape": "1.0.1", "md5": "2.3.0", "multimatch": "5.0.0", @@ -132,10 +132,7 @@ "author": { "name": "Timofei Kachalov" }, - "contributors": [ - "Timofei Kachalov (https://github.com/sanex3339)", - "Dmitry Zamotkin (https://github.com/zamotkin)" - ], + "contributors": ["Timofei Kachalov (https://github.com/sanex3339)", "Dmitry Zamotkin (https://github.com/zamotkin)"], "license": "BSD-2-Clause", "packageManager": "yarn@1.22.21+sha512.ca75da26c00327d26267ce33536e5790f18ebd53266796fbb664d2a4a5116308042dd8ee7003b276a20eace7d3c5561c3577bdd71bcb67071187af124779620a" } diff --git a/src/analyzers/calls-graph-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor.ts b/src/analyzers/calls-graph-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor.ts index 2a3667155..ee5ce750a 100644 --- a/src/analyzers/calls-graph-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor.ts +++ b/src/analyzers/calls-graph-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor.ts @@ -1,4 +1,4 @@ -import { injectable } from 'inversify'; +import { injectable, injectFromBase } from 'inversify'; import * as estraverse from '@javascript-obfuscator/estraverse'; import * as ESTree from 'estree'; @@ -9,6 +9,7 @@ import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor'; import { NodeGuards } from '../../../node/NodeGuards'; import { NodeStatementUtils } from '../../../node/NodeStatementUtils'; +@injectFromBase() @injectable() export class FunctionDeclarationCalleeDataExtractor extends AbstractCalleeDataExtractor { /** diff --git a/src/analyzers/calls-graph-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts b/src/analyzers/calls-graph-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts index a24cb5c04..c0b8e0c0d 100644 --- a/src/analyzers/calls-graph-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts +++ b/src/analyzers/calls-graph-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts @@ -1,4 +1,4 @@ -import { injectable } from 'inversify'; +import { injectable, injectFromBase } from 'inversify'; import * as estraverse from '@javascript-obfuscator/estraverse'; import * as ESTree from 'estree'; @@ -9,6 +9,7 @@ import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor'; import { NodeGuards } from '../../../node/NodeGuards'; import { NodeStatementUtils } from '../../../node/NodeStatementUtils'; +@injectFromBase() @injectable() export class FunctionExpressionCalleeDataExtractor extends AbstractCalleeDataExtractor { /** diff --git a/src/analyzers/calls-graph-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts b/src/analyzers/calls-graph-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts index 57e22783e..8f24f7675 100644 --- a/src/analyzers/calls-graph-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts +++ b/src/analyzers/calls-graph-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts @@ -1,4 +1,4 @@ -import { injectable } from 'inversify'; +import { injectable, injectFromBase } from 'inversify'; import * as estraverse from '@javascript-obfuscator/estraverse'; import * as ESTree from 'estree'; @@ -11,6 +11,7 @@ import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor'; import { NodeGuards } from '../../../node/NodeGuards'; import { NodeStatementUtils } from '../../../node/NodeStatementUtils'; +@injectFromBase() @injectable() export class ObjectExpressionCalleeDataExtractor extends AbstractCalleeDataExtractor { /** diff --git a/src/code-transformers/CodeTransformerNamesGroupsBuilder.ts b/src/code-transformers/CodeTransformerNamesGroupsBuilder.ts index b4a592052..13c5349cc 100644 --- a/src/code-transformers/CodeTransformerNamesGroupsBuilder.ts +++ b/src/code-transformers/CodeTransformerNamesGroupsBuilder.ts @@ -1,4 +1,4 @@ -import { injectable } from 'inversify'; +import { injectable, injectFromBase } from 'inversify'; import { ICodeTransformer } from '../interfaces/code-transformers/ICodeTransformer'; @@ -6,6 +6,7 @@ import { CodeTransformer } from '../enums/code-transformers/CodeTransformer'; import { AbstractTransformerNamesGroupsBuilder } from '../utils/AbstractTransformerNamesGroupsBuilder'; +@injectFromBase() @injectable() export class CodeTransformerNamesGroupsBuilder extends AbstractTransformerNamesGroupsBuilder< CodeTransformer, diff --git a/src/code-transformers/preparing-transformers/HashbangOperatorTransformer.ts b/src/code-transformers/preparing-transformers/HashbangOperatorTransformer.ts index 02cdbd4b8..5cb95fa6a 100644 --- a/src/code-transformers/preparing-transformers/HashbangOperatorTransformer.ts +++ b/src/code-transformers/preparing-transformers/HashbangOperatorTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -8,6 +8,7 @@ import { CodeTransformationStage } from '../../enums/code-transformers/CodeTrans import { AbstractCodeTransformer } from '../AbstractCodeTransformer'; +@injectFromBase() @injectable() export class HashbangOperatorTransformer extends AbstractCodeTransformer { /** diff --git a/src/container/InversifyContainerFacade.ts b/src/container/InversifyContainerFacade.ts index 21eac245e..ec54fc936 100644 --- a/src/container/InversifyContainerFacade.ts +++ b/src/container/InversifyContainerFacade.ts @@ -1,4 +1,4 @@ -import { Container, interfaces } from 'inversify'; +import { Container, ResolutionContext, ServiceIdentifier, Factory } from 'inversify'; import { ServiceIdentifiers } from './ServiceIdentifiers'; import { analyzersModule } from './modules/analyzers/AnalyzersModule'; @@ -42,9 +42,9 @@ import { SourceCode } from '../source-code/SourceCode'; export class InversifyContainerFacade implements IInversifyContainerFacade { /** - * @type {interfaces.Container} + * @type {Container} */ - private readonly container: interfaces.Container; + private readonly container: Container; public constructor() { this.container = new Container(); @@ -55,11 +55,11 @@ export class InversifyContainerFacade implements IInversifyContainerFacade { * @returns {U} */ public static getFactory( - serviceIdentifier: interfaces.ServiceIdentifier - ): (context: interfaces.Context) => (bindingName: T) => U { - return (context: interfaces.Context): ((bindingName: T) => U) => { + serviceIdentifier: ServiceIdentifier + ): (context: ResolutionContext) => (bindingName: T) => U { + return (context: ResolutionContext): ((bindingName: T) => U) => { return (bindingName: T): U => { - return context.container.getNamed(serviceIdentifier, bindingName); + return context.get(serviceIdentifier, { name: bindingName }); }; }; } @@ -69,9 +69,9 @@ export class InversifyContainerFacade implements IInversifyContainerFacade { * @returns {U} */ public static getCacheFactory( - serviceIdentifier: interfaces.ServiceIdentifier - ): (context: interfaces.Context) => (bindingName: T) => U { - return (context: interfaces.Context): ((bindingName: T) => U) => { + serviceIdentifier: ServiceIdentifier + ): (context: ResolutionContext) => (bindingName: T) => U { + return (context: ResolutionContext): ((bindingName: T) => U) => { const cache: Map = new Map(); return (bindingName: T): U => { @@ -79,7 +79,7 @@ export class InversifyContainerFacade implements IInversifyContainerFacade { return cache.get(bindingName); } - const object: U = context.container.getNamed(serviceIdentifier, bindingName); + const object: U = context.get(serviceIdentifier, { name: bindingName }); cache.set(bindingName, object); @@ -91,24 +91,21 @@ export class InversifyContainerFacade implements IInversifyContainerFacade { /** * @param {interfaces.ServiceIdentifier[], U>>} serviceIdentifier * @param {interfaces.ServiceIdentifier[], U>>} dependencies - * @returns {(context: interfaces.Context) => (bindingName: T) => U} + * @returns {(context: ResolutionContext) => (bindingName: T) => U} */ public static getConstructorFactory( - serviceIdentifier: interfaces.ServiceIdentifier[], U>>, - ...dependencies: interfaces.ServiceIdentifier[], U>>[] - ): (context: interfaces.Context) => (bindingName: T) => U { - return (context: interfaces.Context): ((bindingName: T) => U) => { + serviceIdentifier: ServiceIdentifier[], U>>, + ...dependencies: ServiceIdentifier[], U>>[] + ): (context: ResolutionContext) => (bindingName: T) => U { + return (context: ResolutionContext): ((bindingName: T) => U) => { const cache: Map[], U>> = new Map(); const cachedDependencies: Record[] = []; return (bindingName: T): U => { dependencies.forEach( - ( - dependency: interfaces.ServiceIdentifier[], U>>, - index: number - ) => { + (dependency: ServiceIdentifier[], U>>, index: number) => { if (!cachedDependencies[index]) { - cachedDependencies[index] = context.container.get(dependency); + cachedDependencies[index] = context.get(dependency); } } ); @@ -117,10 +114,9 @@ export class InversifyContainerFacade implements IInversifyContainerFacade { return new ([], U>>cache.get(bindingName))(...cachedDependencies); } - const constructor = context.container.getNamed[], U>>( - serviceIdentifier, - bindingName - ); + const constructor = context.get[], U>>(serviceIdentifier, { + name: bindingName + }); cache.set(bindingName, constructor); @@ -130,20 +126,20 @@ export class InversifyContainerFacade implements IInversifyContainerFacade { } /** - * @param {interfaces.ServiceIdentifier} serviceIdentifier + * @param {ServiceIdentifier} serviceIdentifier * @returns {T} */ - public get(serviceIdentifier: interfaces.ServiceIdentifier): T { + public get(serviceIdentifier: ServiceIdentifier): T { return this.container.get(serviceIdentifier); } /** - * @param {interfaces.ServiceIdentifier} serviceIdentifier + * @param {ServiceIdentifier} serviceIdentifier * @param {string | number | symbol} named * @returns {T} */ - public getNamed(serviceIdentifier: interfaces.ServiceIdentifier, named: string | number | symbol): T { - return this.container.getNamed(serviceIdentifier, named); + public getNamed(serviceIdentifier: ServiceIdentifier, named: string | number | symbol): T { + return this.container.get(serviceIdentifier, { name: named }); } /** @@ -182,10 +178,10 @@ export class InversifyContainerFacade implements IInversifyContainerFacade { this.container.bind(ServiceIdentifiers.IObfuscationResult).to(ObfuscationResult); this.container - .bind(ServiceIdentifiers.Factory__IObfuscationResult) - .toFactory((context: interfaces.Context) => { + .bind>(ServiceIdentifiers.Factory__IObfuscationResult) + .toFactory((context: ResolutionContext) => { return (obfuscatedCodeAsString: string, sourceMapAsString: string): IObfuscationResult => { - const obfuscationResult: IObfuscationResult = context.container.get( + const obfuscationResult: IObfuscationResult = context.get( ServiceIdentifiers.IObfuscationResult ); @@ -196,29 +192,29 @@ export class InversifyContainerFacade implements IInversifyContainerFacade { }); // modules - this.container.load(analyzersModule); - this.container.load(codeTransformersModule); - this.container.load(controlFlowTransformersModule); - this.container.load(convertingTransformersModule); - this.container.load(customCodeHelpersModule); - this.container.load(customNodesModule); - this.container.load(deadCodeInjectionTransformersModule); - this.container.load(finalizingTransformersModule); - this.container.load(generatorsModule); - this.container.load(initializingTransformersModule); - this.container.load(nodeModule); - this.container.load(nodeTransformersModule); - this.container.load(optionsModule); - this.container.load(preparingTransformersModule); - this.container.load(renameIdentifiersTransformersModule); - this.container.load(renamePropertiesTransformersModule); - this.container.load(simplifyingTransformersModule); - this.container.load(storagesModule); - this.container.load(stringArrayTransformersModule); - this.container.load(utilsModule); + this.container.loadSync(analyzersModule); + this.container.loadSync(codeTransformersModule); + this.container.loadSync(controlFlowTransformersModule); + this.container.loadSync(convertingTransformersModule); + this.container.loadSync(customCodeHelpersModule); + this.container.loadSync(customNodesModule); + this.container.loadSync(deadCodeInjectionTransformersModule); + this.container.loadSync(finalizingTransformersModule); + this.container.loadSync(generatorsModule); + this.container.loadSync(initializingTransformersModule); + this.container.loadSync(nodeModule); + this.container.loadSync(nodeTransformersModule); + this.container.loadSync(optionsModule); + this.container.loadSync(preparingTransformersModule); + this.container.loadSync(renameIdentifiersTransformersModule); + this.container.loadSync(renamePropertiesTransformersModule); + this.container.loadSync(simplifyingTransformersModule); + this.container.loadSync(storagesModule); + this.container.loadSync(stringArrayTransformersModule); + this.container.loadSync(utilsModule); } public unload(): void { - this.container.unbindAll(); + this.container.unbindAllSync(); } } diff --git a/src/container/modules/analyzers/AnalyzersModule.ts b/src/container/modules/analyzers/AnalyzersModule.ts index ae327cc2b..0de97d579 100644 --- a/src/container/modules/analyzers/AnalyzersModule.ts +++ b/src/container/modules/analyzers/AnalyzersModule.ts @@ -1,5 +1,5 @@ import { InversifyContainerFacade } from '../../InversifyContainerFacade'; -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions, Factory } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { ICalleeDataExtractor } from '../../../interfaces/analyzers/calls-graph-analyzer/ICalleeDataExtractor'; @@ -19,48 +19,53 @@ import { PrevailingKindOfVariablesAnalyzer } from '../../../analyzers/prevailing import { ScopeAnalyzer } from '../../../analyzers/scope-analyzer/ScopeAnalyzer'; import { StringArrayStorageAnalyzer } from '../../../analyzers/string-array-storage-analyzer/StringArrayStorageAnalyzer'; -export const analyzersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { +export const analyzersModule: ContainerModule = new ContainerModule((options: ContainerModuleLoadOptions) => { // calls graph analyzer - bind(ServiceIdentifiers.ICallsGraphAnalyzer).to(CallsGraphAnalyzer).inSingletonScope(); + options.bind(ServiceIdentifiers.ICallsGraphAnalyzer).to(CallsGraphAnalyzer).inSingletonScope(); // number numerical expression analyzer - bind(ServiceIdentifiers.INumberNumericalExpressionAnalyzer) + options + .bind(ServiceIdentifiers.INumberNumericalExpressionAnalyzer) .to(NumberNumericalExpressionAnalyzer) .inSingletonScope(); // prevailing kind of variables analyzer - bind(ServiceIdentifiers.IPrevailingKindOfVariablesAnalyzer) + options + .bind(ServiceIdentifiers.IPrevailingKindOfVariablesAnalyzer) .to(PrevailingKindOfVariablesAnalyzer) .inSingletonScope(); // scope analyzer - bind(ServiceIdentifiers.IScopeAnalyzer).to(ScopeAnalyzer).inSingletonScope(); + options.bind(ServiceIdentifiers.IScopeAnalyzer).to(ScopeAnalyzer).inSingletonScope(); // string array storage analyzer - bind(ServiceIdentifiers.IStringArrayStorageAnalyzer) + options + .bind(ServiceIdentifiers.IStringArrayStorageAnalyzer) .to(StringArrayStorageAnalyzer) .inSingletonScope(); // callee data extractors - bind(ServiceIdentifiers.ICalleeDataExtractor) + options + .bind(ServiceIdentifiers.ICalleeDataExtractor) .to(FunctionDeclarationCalleeDataExtractor) - .whenTargetNamed(CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor); + .whenNamed(CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor); - bind(ServiceIdentifiers.ICalleeDataExtractor) + options + .bind(ServiceIdentifiers.ICalleeDataExtractor) .to(FunctionExpressionCalleeDataExtractor) - .whenTargetNamed(CalleeDataExtractor.FunctionExpressionCalleeDataExtractor); + .whenNamed(CalleeDataExtractor.FunctionExpressionCalleeDataExtractor); - bind(ServiceIdentifiers.ICalleeDataExtractor) + options + .bind(ServiceIdentifiers.ICalleeDataExtractor) .to(ObjectExpressionCalleeDataExtractor) - .whenTargetNamed(CalleeDataExtractor.ObjectExpressionCalleeDataExtractor); + .whenNamed(CalleeDataExtractor.ObjectExpressionCalleeDataExtractor); // callee data extractor factory - bind(ServiceIdentifiers.Factory__ICalleeDataExtractor).toFactory< - ICalleeDataExtractor, - [CalleeDataExtractor] - >( - InversifyContainerFacade.getCacheFactory( - ServiceIdentifiers.ICalleeDataExtractor - ) - ); + options + .bind>(ServiceIdentifiers.Factory__ICalleeDataExtractor) + .toFactory( + InversifyContainerFacade.getCacheFactory( + ServiceIdentifiers.ICalleeDataExtractor + ) + ); }); diff --git a/src/container/modules/code-transformers/CodeTransformersModule.ts b/src/container/modules/code-transformers/CodeTransformersModule.ts index ad8af23e3..33951e0d1 100644 --- a/src/container/modules/code-transformers/CodeTransformersModule.ts +++ b/src/container/modules/code-transformers/CodeTransformersModule.ts @@ -1,5 +1,5 @@ import { InversifyContainerFacade } from '../../InversifyContainerFacade'; -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions, Factory } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { ICodeTransformer } from '../../../interfaces/code-transformers/ICodeTransformer'; @@ -10,21 +10,27 @@ import { CodeTransformer } from '../../../enums/code-transformers/CodeTransforme import { CodeTransformerNamesGroupsBuilder } from '../../../code-transformers/CodeTransformerNamesGroupsBuilder'; import { HashbangOperatorTransformer } from '../../../code-transformers/preparing-transformers/HashbangOperatorTransformer'; -export const codeTransformersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { +export const codeTransformersModule: ContainerModule = new ContainerModule((options: ContainerModuleLoadOptions) => { // code transformers factory - bind(ServiceIdentifiers.Factory__ICodeTransformer).toFactory( - InversifyContainerFacade.getCacheFactory(ServiceIdentifiers.ICodeTransformer) - ); + options + .bind>(ServiceIdentifiers.Factory__ICodeTransformer) + .toFactory( + InversifyContainerFacade.getCacheFactory( + ServiceIdentifiers.ICodeTransformer + ) + ); // code transformer names groups builder - bind>( - ServiceIdentifiers.ICodeTransformerNamesGroupsBuilder - ) + options + .bind< + ITransformerNamesGroupsBuilder + >(ServiceIdentifiers.ICodeTransformerNamesGroupsBuilder) .to(CodeTransformerNamesGroupsBuilder) .inSingletonScope(); // preparing code transformers - bind(ServiceIdentifiers.ICodeTransformer) + options + .bind(ServiceIdentifiers.ICodeTransformer) .to(HashbangOperatorTransformer) - .whenTargetNamed(CodeTransformer.HashbangOperatorTransformer); + .whenNamed(CodeTransformer.HashbangOperatorTransformer); }); diff --git a/src/container/modules/custom-code-helpers/CustomCodeHelpersModule.ts b/src/container/modules/custom-code-helpers/CustomCodeHelpersModule.ts index 6ddca83dd..fdd2c7c5a 100644 --- a/src/container/modules/custom-code-helpers/CustomCodeHelpersModule.ts +++ b/src/container/modules/custom-code-helpers/CustomCodeHelpersModule.ts @@ -1,5 +1,5 @@ import { InversifyContainerFacade } from '../../InversifyContainerFacade'; -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions, Factory } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { ICustomCodeHelper } from '../../../interfaces/custom-code-helpers/ICustomCodeHelper'; @@ -31,100 +31,123 @@ import { StringArrayCallsWrapperRc4CodeHelper } from '../../../custom-code-helpe import { StringArrayCodeHelper } from '../../../custom-code-helpers/string-array/StringArrayCodeHelper'; import { StringArrayRotateFunctionCodeHelper } from '../../../custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper'; -export const customCodeHelpersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { +export const customCodeHelpersModule: ContainerModule = new ContainerModule((options: ContainerModuleLoadOptions) => { // custom code helpers - bind(ServiceIdentifiers.ICustomCodeHelper) + options + .bind(ServiceIdentifiers.ICustomCodeHelper) .to(ConsoleOutputDisableCodeHelper) - .whenTargetNamed(CustomCodeHelper.ConsoleOutputDisable); + .whenNamed(CustomCodeHelper.ConsoleOutputDisable); - bind(ServiceIdentifiers.ICustomCodeHelper) + options + .bind(ServiceIdentifiers.ICustomCodeHelper) .to(DebugProtectionFunctionCallCodeHelper) - .whenTargetNamed(CustomCodeHelper.DebugProtectionFunctionCall); + .whenNamed(CustomCodeHelper.DebugProtectionFunctionCall); - bind(ServiceIdentifiers.ICustomCodeHelper) + options + .bind(ServiceIdentifiers.ICustomCodeHelper) .to(DebugProtectionFunctionIntervalCodeHelper) - .whenTargetNamed(CustomCodeHelper.DebugProtectionFunctionInterval); + .whenNamed(CustomCodeHelper.DebugProtectionFunctionInterval); - bind(ServiceIdentifiers.ICustomCodeHelper) + options + .bind(ServiceIdentifiers.ICustomCodeHelper) .to(DebugProtectionFunctionCodeHelper) - .whenTargetNamed(CustomCodeHelper.DebugProtectionFunction); + .whenNamed(CustomCodeHelper.DebugProtectionFunction); - bind(ServiceIdentifiers.ICustomCodeHelper) + options + .bind(ServiceIdentifiers.ICustomCodeHelper) .to(DomainLockCodeHelper) - .whenTargetNamed(CustomCodeHelper.DomainLock); + .whenNamed(CustomCodeHelper.DomainLock); - bind(ServiceIdentifiers.ICustomCodeHelper) + options + .bind(ServiceIdentifiers.ICustomCodeHelper) .to(CallsControllerFunctionCodeHelper) - .whenTargetNamed(CustomCodeHelper.CallsControllerFunction); + .whenNamed(CustomCodeHelper.CallsControllerFunction); - bind(ServiceIdentifiers.ICustomCodeHelper) + options + .bind(ServiceIdentifiers.ICustomCodeHelper) .to(SelfDefendingCodeHelper) - .whenTargetNamed(CustomCodeHelper.SelfDefending); + .whenNamed(CustomCodeHelper.SelfDefending); - bind(ServiceIdentifiers.ICustomCodeHelper) + options + .bind(ServiceIdentifiers.ICustomCodeHelper) .to(StringArrayCallsWrapperCodeHelper) - .whenTargetNamed(CustomCodeHelper.StringArrayCallsWrapper); + .whenNamed(CustomCodeHelper.StringArrayCallsWrapper); - bind(ServiceIdentifiers.ICustomCodeHelper) + options + .bind(ServiceIdentifiers.ICustomCodeHelper) .to(StringArrayCallsWrapperBase64CodeHelper) - .whenTargetNamed(CustomCodeHelper.StringArrayCallsWrapperBase64); + .whenNamed(CustomCodeHelper.StringArrayCallsWrapperBase64); - bind(ServiceIdentifiers.ICustomCodeHelper) + options + .bind(ServiceIdentifiers.ICustomCodeHelper) .to(StringArrayCallsWrapperRc4CodeHelper) - .whenTargetNamed(CustomCodeHelper.StringArrayCallsWrapperRc4); + .whenNamed(CustomCodeHelper.StringArrayCallsWrapperRc4); - bind(ServiceIdentifiers.ICustomCodeHelper) + options + .bind(ServiceIdentifiers.ICustomCodeHelper) .to(StringArrayCodeHelper) - .whenTargetNamed(CustomCodeHelper.StringArray); + .whenNamed(CustomCodeHelper.StringArray); - bind(ServiceIdentifiers.ICustomCodeHelper) + options + .bind(ServiceIdentifiers.ICustomCodeHelper) .to(StringArrayRotateFunctionCodeHelper) - .whenTargetNamed(CustomCodeHelper.StringArrayRotateFunction); + .whenNamed(CustomCodeHelper.StringArrayRotateFunction); // code helper groups - bind(ServiceIdentifiers.ICustomCodeHelperGroup) + options + .bind(ServiceIdentifiers.ICustomCodeHelperGroup) .to(ConsoleOutputCodeHelperGroup) - .whenTargetNamed(CustomCodeHelperGroup.ConsoleOutput); + .whenNamed(CustomCodeHelperGroup.ConsoleOutput); - bind(ServiceIdentifiers.ICustomCodeHelperGroup) + options + .bind(ServiceIdentifiers.ICustomCodeHelperGroup) .to(DebugProtectionCodeHelperGroup) - .whenTargetNamed(CustomCodeHelperGroup.DebugProtection); + .whenNamed(CustomCodeHelperGroup.DebugProtection); - bind(ServiceIdentifiers.ICustomCodeHelperGroup) + options + .bind(ServiceIdentifiers.ICustomCodeHelperGroup) .to(DomainLockCustomCodeHelperGroup) - .whenTargetNamed(CustomCodeHelperGroup.DomainLock); + .whenNamed(CustomCodeHelperGroup.DomainLock); - bind(ServiceIdentifiers.ICustomCodeHelperGroup) + options + .bind(ServiceIdentifiers.ICustomCodeHelperGroup) .to(SelfDefendingCodeHelperGroup) - .whenTargetNamed(CustomCodeHelperGroup.SelfDefending); + .whenNamed(CustomCodeHelperGroup.SelfDefending); - bind(ServiceIdentifiers.ICustomCodeHelperGroup) + options + .bind(ServiceIdentifiers.ICustomCodeHelperGroup) .to(StringArrayCodeHelperGroup) - .whenTargetNamed(CustomCodeHelperGroup.StringArray); + .whenNamed(CustomCodeHelperGroup.StringArray); // customCodeHelper factory - bind(ServiceIdentifiers.Factory__ICustomCodeHelper).toFactory< - ICustomCodeHelper, - [CustomCodeHelper] - >(InversifyContainerFacade.getFactory(ServiceIdentifiers.ICustomCodeHelper)); + options + .bind>(ServiceIdentifiers.Factory__ICustomCodeHelper) + .toFactory( + InversifyContainerFacade.getFactory( + ServiceIdentifiers.ICustomCodeHelper + ) + ); // customCodeHelperGroup factory - bind(ServiceIdentifiers.Factory__ICustomCodeHelperGroup).toFactory< - ICustomCodeHelperGroup, - [CustomCodeHelperGroup] - >( - InversifyContainerFacade.getFactory( - ServiceIdentifiers.ICustomCodeHelperGroup - ) - ); + options + .bind< + Factory + >(ServiceIdentifiers.Factory__ICustomCodeHelperGroup) + .toFactory( + InversifyContainerFacade.getFactory( + ServiceIdentifiers.ICustomCodeHelperGroup + ) + ); // custom code helper formatter - bind(ServiceIdentifiers.ICustomCodeHelperFormatter) + options + .bind(ServiceIdentifiers.ICustomCodeHelperFormatter) .to(CustomCodeHelperFormatter) .inSingletonScope(); // custom code helper obfuscator - bind(ServiceIdentifiers.ICustomCodeHelperObfuscator) + options + .bind(ServiceIdentifiers.ICustomCodeHelperObfuscator) .to(CustomCodeHelperObfuscator) .inSingletonScope(); }); diff --git a/src/container/modules/custom-nodes/CustomNodesModule.ts b/src/container/modules/custom-nodes/CustomNodesModule.ts index 2d813f0c5..1cc9fe269 100644 --- a/src/container/modules/custom-nodes/CustomNodesModule.ts +++ b/src/container/modules/custom-nodes/CustomNodesModule.ts @@ -1,5 +1,5 @@ import { InversifyContainerFacade } from '../../InversifyContainerFacade'; -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions, Newable, Factory } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; @@ -28,144 +28,159 @@ import { StringArrayScopeCallsWrapperVariableNode } from '../../../custom-nodes/ import { StringLiteralControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode'; import { LiteralNode } from '../../../custom-nodes/control-flow-flattening-nodes/LiteralNode'; -export const customNodesModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { +export const customNodesModule: ContainerModule = new ContainerModule((options: ContainerModuleLoadOptions) => { // control flow custom nodes - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(BinaryExpressionFunctionNode) - .whenTargetNamed(ControlFlowCustomNode.BinaryExpressionFunctionNode); - - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(BlockStatementControlFlowFlatteningNode) - .whenTargetNamed(ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode); - - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(CallExpressionControlFlowStorageCallNode) - .whenTargetNamed(ControlFlowCustomNode.CallExpressionControlFlowStorageCallNode); - - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(CallExpressionFunctionNode) - .whenTargetNamed(ControlFlowCustomNode.CallExpressionFunctionNode); - - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(ControlFlowStorageNode) - .whenTargetNamed(ControlFlowCustomNode.ControlFlowStorageNode); - - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(ExpressionWithOperatorControlFlowStorageCallNode) - .whenTargetNamed(ControlFlowCustomNode.ExpressionWithOperatorControlFlowStorageCallNode); - - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(LiteralNode) - .whenTargetNamed(ControlFlowCustomNode.LiteralNode); - - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(LogicalExpressionFunctionNode) - .whenTargetNamed(ControlFlowCustomNode.LogicalExpressionFunctionNode); - - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(StringLiteralControlFlowStorageCallNode) - .whenTargetNamed(ControlFlowCustomNode.StringLiteralControlFlowStorageCallNode); + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(BinaryExpressionFunctionNode) + .whenNamed(ControlFlowCustomNode.BinaryExpressionFunctionNode); + + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(BlockStatementControlFlowFlatteningNode) + .whenNamed(ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode); + + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(CallExpressionControlFlowStorageCallNode) + .whenNamed(ControlFlowCustomNode.CallExpressionControlFlowStorageCallNode); + + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(CallExpressionFunctionNode) + .whenNamed(ControlFlowCustomNode.CallExpressionFunctionNode); + + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(ControlFlowStorageNode) + .whenNamed(ControlFlowCustomNode.ControlFlowStorageNode); + + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(ExpressionWithOperatorControlFlowStorageCallNode) + .whenNamed(ControlFlowCustomNode.ExpressionWithOperatorControlFlowStorageCallNode); + + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(LiteralNode) + .whenNamed(ControlFlowCustomNode.LiteralNode); + + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(LogicalExpressionFunctionNode) + .whenNamed(ControlFlowCustomNode.LogicalExpressionFunctionNode); + + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(StringLiteralControlFlowStorageCallNode) + .whenNamed(ControlFlowCustomNode.StringLiteralControlFlowStorageCallNode); // dead code injection custom nodes - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(BlockStatementDeadCodeInjectionNode) - .whenTargetNamed(DeadCodeInjectionCustomNode.BlockStatementDeadCodeInjectionNode); + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(BlockStatementDeadCodeInjectionNode) + .whenNamed(DeadCodeInjectionCustomNode.BlockStatementDeadCodeInjectionNode); // object expression keys transformer nodes - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(ObjectExpressionVariableDeclarationHostNode) - .whenTargetNamed(ObjectExpressionKeysTransformerCustomNode.ObjectExpressionVariableDeclarationHostNode); + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(ObjectExpressionVariableDeclarationHostNode) + .whenNamed(ObjectExpressionKeysTransformerCustomNode.ObjectExpressionVariableDeclarationHostNode); // string array nodes - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(StringArrayCallNode) - .whenTargetNamed(StringArrayCustomNode.StringArrayCallNode); + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(StringArrayCallNode) + .whenNamed(StringArrayCustomNode.StringArrayCallNode); - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(StringArrayScopeCallsWrapperFunctionNode) - .whenTargetNamed(StringArrayCustomNode.StringArrayScopeCallsWrapperFunctionNode); + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(StringArrayScopeCallsWrapperFunctionNode) + .whenNamed(StringArrayCustomNode.StringArrayScopeCallsWrapperFunctionNode); - bind>(ServiceIdentifiers.Newable__ICustomNode) - .toConstructor(StringArrayScopeCallsWrapperVariableNode) - .whenTargetNamed(StringArrayCustomNode.StringArrayScopeCallsWrapperVariableNode); + options + .bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstantValue(StringArrayScopeCallsWrapperVariableNode) + .whenNamed(StringArrayCustomNode.StringArrayScopeCallsWrapperVariableNode); // string array index nodes - bind(ServiceIdentifiers.IStringArrayIndexNode) + options + .bind(ServiceIdentifiers.IStringArrayIndexNode) .to(StringArrayHexadecimalNumberIndexNode) .inSingletonScope() - .whenTargetNamed(StringArrayIndexNode.StringArrayHexadecimalNumberIndexNode); + .whenNamed(StringArrayIndexNode.StringArrayHexadecimalNumberIndexNode); - bind(ServiceIdentifiers.IStringArrayIndexNode) + options + .bind(ServiceIdentifiers.IStringArrayIndexNode) .to(StringArrayHexadecimalNumericStringIndexNode) .inSingletonScope() - .whenTargetNamed(StringArrayIndexNode.StringArrayHexadecimalNumericStringIndexNode); + .whenNamed(StringArrayIndexNode.StringArrayHexadecimalNumericStringIndexNode); // control flow customNode constructor factory - bind(ServiceIdentifiers.Factory__IControlFlowCustomNode).toFactory< - ICustomNode, - [ControlFlowCustomNode] - >( - InversifyContainerFacade.getConstructorFactory( - ServiceIdentifiers.Newable__ICustomNode, - ServiceIdentifiers.Factory__IIdentifierNamesGenerator, - ServiceIdentifiers.ICustomCodeHelperFormatter, - ServiceIdentifiers.IRandomGenerator, - ServiceIdentifiers.IOptions - ) - ); + options + .bind>(ServiceIdentifiers.Factory__IControlFlowCustomNode) + .toFactory( + InversifyContainerFacade.getConstructorFactory( + ServiceIdentifiers.Newable__ICustomNode, + ServiceIdentifiers.Factory__IIdentifierNamesGenerator, + ServiceIdentifiers.ICustomCodeHelperFormatter, + ServiceIdentifiers.IRandomGenerator, + ServiceIdentifiers.IOptions + ) + ); // dead code injection customNode constructor factory - bind(ServiceIdentifiers.Factory__IDeadCodeInjectionCustomNode).toFactory< - ICustomNode, - [DeadCodeInjectionCustomNode] - >( - InversifyContainerFacade.getConstructorFactory( - ServiceIdentifiers.Newable__ICustomNode, - ServiceIdentifiers.Factory__IIdentifierNamesGenerator, - ServiceIdentifiers.ICustomCodeHelperFormatter, - ServiceIdentifiers.IRandomGenerator, - ServiceIdentifiers.IOptions - ) - ); + options + .bind< + Factory + >(ServiceIdentifiers.Factory__IDeadCodeInjectionCustomNode) + .toFactory( + InversifyContainerFacade.getConstructorFactory( + ServiceIdentifiers.Newable__ICustomNode, + ServiceIdentifiers.Factory__IIdentifierNamesGenerator, + ServiceIdentifiers.ICustomCodeHelperFormatter, + ServiceIdentifiers.IRandomGenerator, + ServiceIdentifiers.IOptions + ) + ); // object expression keys transformer customNode constructor factory - bind(ServiceIdentifiers.Factory__IObjectExpressionKeysTransformerCustomNode).toFactory< - ICustomNode, - [ObjectExpressionKeysTransformerCustomNode] - >( - InversifyContainerFacade.getConstructorFactory( - ServiceIdentifiers.Newable__ICustomNode, - ServiceIdentifiers.Factory__IIdentifierNamesGenerator, - ServiceIdentifiers.ICustomCodeHelperFormatter, - ServiceIdentifiers.IRandomGenerator, - ServiceIdentifiers.IOptions - ) - ); + options + .bind< + Factory + >(ServiceIdentifiers.Factory__IObjectExpressionKeysTransformerCustomNode) + .toFactory( + InversifyContainerFacade.getConstructorFactory( + ServiceIdentifiers.Newable__ICustomNode, + ServiceIdentifiers.Factory__IIdentifierNamesGenerator, + ServiceIdentifiers.ICustomCodeHelperFormatter, + ServiceIdentifiers.IRandomGenerator, + ServiceIdentifiers.IOptions + ) + ); // string array customNode constructor factory - bind(ServiceIdentifiers.Factory__IStringArrayCustomNode).toFactory< - ICustomNode, - [StringArrayCustomNode] - >( - InversifyContainerFacade.getConstructorFactory( - ServiceIdentifiers.Newable__ICustomNode, - ServiceIdentifiers.Factory__IIdentifierNamesGenerator, - ServiceIdentifiers.Factory__IStringArrayIndexNode, - ServiceIdentifiers.ICustomCodeHelperFormatter, - ServiceIdentifiers.IStringArrayStorage, - ServiceIdentifiers.IArrayUtils, - ServiceIdentifiers.IRandomGenerator, - ServiceIdentifiers.IOptions - ) - ); + options + .bind>(ServiceIdentifiers.Factory__IStringArrayCustomNode) + .toFactory( + InversifyContainerFacade.getConstructorFactory( + ServiceIdentifiers.Newable__ICustomNode, + ServiceIdentifiers.Factory__IIdentifierNamesGenerator, + ServiceIdentifiers.Factory__IStringArrayIndexNode, + ServiceIdentifiers.ICustomCodeHelperFormatter, + ServiceIdentifiers.IStringArrayStorage, + ServiceIdentifiers.IArrayUtils, + ServiceIdentifiers.IRandomGenerator, + ServiceIdentifiers.IOptions + ) + ); // string array index node factory - bind(ServiceIdentifiers.Factory__IStringArrayIndexNode).toFactory< - IStringArrayIndexNode, - [StringArrayIndexNode] - >( - InversifyContainerFacade.getCacheFactory( - ServiceIdentifiers.IStringArrayIndexNode - ) - ); + options + .bind>(ServiceIdentifiers.Factory__IStringArrayIndexNode) + .toFactory( + InversifyContainerFacade.getCacheFactory( + ServiceIdentifiers.IStringArrayIndexNode + ) + ); }); diff --git a/src/container/modules/generators/GeneratorsModule.ts b/src/container/modules/generators/GeneratorsModule.ts index c1ff48e3e..70f62dc0f 100644 --- a/src/container/modules/generators/GeneratorsModule.ts +++ b/src/container/modules/generators/GeneratorsModule.ts @@ -1,4 +1,4 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions, ResolutionContext, Factory } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { IIdentifierNamesGenerator } from '../../../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator'; @@ -11,72 +11,76 @@ import { HexadecimalIdentifierNamesGenerator } from '../../../generators/identif import { MangledIdentifierNamesGenerator } from '../../../generators/identifier-names-generators/MangledIdentifierNamesGenerator'; import { MangledShuffledIdentifierNamesGenerator } from '../../../generators/identifier-names-generators/MangledShuffledIdentifierNamesGenerator'; -export const generatorsModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { +export const generatorsModule: ContainerModule = new ContainerModule((options: ContainerModuleLoadOptions) => { // identifier name generators - bind(ServiceIdentifiers.IIdentifierNamesGenerator) + options + .bind(ServiceIdentifiers.IIdentifierNamesGenerator) .to(DictionaryIdentifierNamesGenerator) .inSingletonScope() - .whenTargetNamed(IdentifierNamesGenerator.DictionaryIdentifierNamesGenerator); + .whenNamed(IdentifierNamesGenerator.DictionaryIdentifierNamesGenerator); - bind(ServiceIdentifiers.IIdentifierNamesGenerator) + options + .bind(ServiceIdentifiers.IIdentifierNamesGenerator) .to(HexadecimalIdentifierNamesGenerator) .inSingletonScope() - .whenTargetNamed(IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator); + .whenNamed(IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator); - bind(ServiceIdentifiers.IIdentifierNamesGenerator) + options + .bind(ServiceIdentifiers.IIdentifierNamesGenerator) .to(MangledIdentifierNamesGenerator) .inSingletonScope() - .whenTargetNamed(IdentifierNamesGenerator.MangledIdentifierNamesGenerator); + .whenNamed(IdentifierNamesGenerator.MangledIdentifierNamesGenerator); - bind(ServiceIdentifiers.IIdentifierNamesGenerator) + options + .bind(ServiceIdentifiers.IIdentifierNamesGenerator) .to(MangledShuffledIdentifierNamesGenerator) .inSingletonScope() - .whenTargetNamed(IdentifierNamesGenerator.MangledShuffledIdentifierNamesGenerator); + .whenNamed(IdentifierNamesGenerator.MangledShuffledIdentifierNamesGenerator); // identifier name generator factory function identifierNameGeneratorFactory(): ( - context: interfaces.Context - ) => (options: IOptions) => IIdentifierNamesGenerator { + context: ResolutionContext + ) => (generatorOptions: IOptions) => IIdentifierNamesGenerator { let cachedIdentifierNamesGenerator: IIdentifierNamesGenerator | null = null; - return (context: interfaces.Context): ((options: IOptions) => IIdentifierNamesGenerator) => - (options: IOptions): IIdentifierNamesGenerator => { + return (context: ResolutionContext): ((generatorOptions: IOptions) => IIdentifierNamesGenerator) => + (generatorOptions: IOptions): IIdentifierNamesGenerator => { if (cachedIdentifierNamesGenerator) { return cachedIdentifierNamesGenerator; } let identifierNamesGenerator: IIdentifierNamesGenerator; - switch (options.identifierNamesGenerator) { + switch (generatorOptions.identifierNamesGenerator) { case IdentifierNamesGenerator.DictionaryIdentifierNamesGenerator: - identifierNamesGenerator = context.container.getNamed( + identifierNamesGenerator = context.get( ServiceIdentifiers.IIdentifierNamesGenerator, - IdentifierNamesGenerator.DictionaryIdentifierNamesGenerator + { name: IdentifierNamesGenerator.DictionaryIdentifierNamesGenerator } ); break; case IdentifierNamesGenerator.MangledIdentifierNamesGenerator: - identifierNamesGenerator = context.container.getNamed( + identifierNamesGenerator = context.get( ServiceIdentifiers.IIdentifierNamesGenerator, - IdentifierNamesGenerator.MangledIdentifierNamesGenerator + { name: IdentifierNamesGenerator.MangledIdentifierNamesGenerator } ); break; case IdentifierNamesGenerator.MangledShuffledIdentifierNamesGenerator: - identifierNamesGenerator = context.container.getNamed( + identifierNamesGenerator = context.get( ServiceIdentifiers.IIdentifierNamesGenerator, - IdentifierNamesGenerator.MangledShuffledIdentifierNamesGenerator + { name: IdentifierNamesGenerator.MangledShuffledIdentifierNamesGenerator } ); break; case IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator: default: - identifierNamesGenerator = context.container.getNamed( + identifierNamesGenerator = context.get( ServiceIdentifiers.IIdentifierNamesGenerator, - IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator + { name: IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator } ); } @@ -85,8 +89,7 @@ export const generatorsModule: interfaces.ContainerModule = new ContainerModule( return identifierNamesGenerator; }; } - bind(ServiceIdentifiers.Factory__IIdentifierNamesGenerator).toFactory< - IIdentifierNamesGenerator, - [IOptions] - >(identifierNameGeneratorFactory()); + options + .bind>(ServiceIdentifiers.Factory__IIdentifierNamesGenerator) + .toFactory(identifierNameGeneratorFactory()); }); diff --git a/src/container/modules/node-transformers/ControlFlowTransformersModule.ts b/src/container/modules/node-transformers/ControlFlowTransformersModule.ts index 02a458e5c..054e2ada0 100644 --- a/src/container/modules/node-transformers/ControlFlowTransformersModule.ts +++ b/src/container/modules/node-transformers/ControlFlowTransformersModule.ts @@ -1,5 +1,5 @@ import { InversifyContainerFacade } from '../../InversifyContainerFacade'; -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions, Factory } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { IControlFlowReplacer } from '../../../interfaces/node-transformers/control-flow-transformers/IControlFlowReplacer'; @@ -17,50 +17,59 @@ import { StringArrayCallControlFlowReplacer } from '../../../node-transformers/c import { StringArrayControlFlowTransformer } from '../../../node-transformers/control-flow-transformers/StringArrayControlFlowTransformer'; import { StringLiteralControlFlowReplacer } from '../../../node-transformers/control-flow-transformers/control-flow-replacers/StringLiteralControlFlowReplacer'; -export const controlFlowTransformersModule: interfaces.ContainerModule = new ContainerModule( - (bind: interfaces.Bind) => { +export const controlFlowTransformersModule: ContainerModule = new ContainerModule( + (options: ContainerModuleLoadOptions) => { // control flow transformers - bind(ServiceIdentifiers.INodeTransformer) + options + .bind(ServiceIdentifiers.INodeTransformer) .to(BlockStatementControlFlowTransformer) - .whenTargetNamed(NodeTransformer.BlockStatementControlFlowTransformer); + .whenNamed(NodeTransformer.BlockStatementControlFlowTransformer); - bind(ServiceIdentifiers.INodeTransformer) + options + .bind(ServiceIdentifiers.INodeTransformer) .to(FunctionControlFlowTransformer) - .whenTargetNamed(NodeTransformer.FunctionControlFlowTransformer); + .whenNamed(NodeTransformer.FunctionControlFlowTransformer); - bind(ServiceIdentifiers.INodeTransformer) + options + .bind(ServiceIdentifiers.INodeTransformer) .to(StringArrayControlFlowTransformer) - .whenTargetNamed(NodeTransformer.StringArrayControlFlowTransformer); + .whenNamed(NodeTransformer.StringArrayControlFlowTransformer); // control flow replacers - bind(ServiceIdentifiers.IControlFlowReplacer) + options + .bind(ServiceIdentifiers.IControlFlowReplacer) .to(BinaryExpressionControlFlowReplacer) - .whenTargetNamed(ControlFlowReplacer.BinaryExpressionControlFlowReplacer); + .whenNamed(ControlFlowReplacer.BinaryExpressionControlFlowReplacer); - bind(ServiceIdentifiers.IControlFlowReplacer) + options + .bind(ServiceIdentifiers.IControlFlowReplacer) .to(CallExpressionControlFlowReplacer) - .whenTargetNamed(ControlFlowReplacer.CallExpressionControlFlowReplacer); + .whenNamed(ControlFlowReplacer.CallExpressionControlFlowReplacer); - bind(ServiceIdentifiers.IControlFlowReplacer) + options + .bind(ServiceIdentifiers.IControlFlowReplacer) .to(LogicalExpressionControlFlowReplacer) - .whenTargetNamed(ControlFlowReplacer.LogicalExpressionControlFlowReplacer); + .whenNamed(ControlFlowReplacer.LogicalExpressionControlFlowReplacer); - bind(ServiceIdentifiers.IControlFlowReplacer) + options + .bind(ServiceIdentifiers.IControlFlowReplacer) .to(StringArrayCallControlFlowReplacer) - .whenTargetNamed(ControlFlowReplacer.StringArrayCallControlFlowReplacer); + .whenNamed(ControlFlowReplacer.StringArrayCallControlFlowReplacer); - bind(ServiceIdentifiers.IControlFlowReplacer) + options + .bind(ServiceIdentifiers.IControlFlowReplacer) .to(StringLiteralControlFlowReplacer) - .whenTargetNamed(ControlFlowReplacer.StringLiteralControlFlowReplacer); + .whenNamed(ControlFlowReplacer.StringLiteralControlFlowReplacer); // control flow replacer factory - bind(ServiceIdentifiers.Factory__IControlFlowReplacer).toFactory< - IControlFlowReplacer, - [ControlFlowReplacer] - >( - InversifyContainerFacade.getCacheFactory( - ServiceIdentifiers.IControlFlowReplacer - ) - ); + options + .bind< + Factory + >(ServiceIdentifiers.Factory__IControlFlowReplacer) + .toFactory( + InversifyContainerFacade.getCacheFactory( + ServiceIdentifiers.IControlFlowReplacer + ) + ); } ); diff --git a/src/container/modules/node-transformers/ConvertingTransformersModule.ts b/src/container/modules/node-transformers/ConvertingTransformersModule.ts index 682550e0c..9d84a7e5b 100644 --- a/src/container/modules/node-transformers/ConvertingTransformersModule.ts +++ b/src/container/modules/node-transformers/ConvertingTransformersModule.ts @@ -1,4 +1,4 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions, Factory } from 'inversify'; import { InversifyContainerFacade } from '../../InversifyContainerFacade'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; @@ -22,68 +22,84 @@ import { ObjectPatternPropertiesTransformer } from '../../../node-transformers/c import { SplitStringTransformer } from '../../../node-transformers/converting-transformers/SplitStringTransformer'; import { TemplateLiteralTransformer } from '../../../node-transformers/converting-transformers/TemplateLiteralTransformer'; -export const convertingTransformersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { - // converting transformers - bind(ServiceIdentifiers.INodeTransformer) - .to(BooleanLiteralTransformer) - .whenTargetNamed(NodeTransformer.BooleanLiteralTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(ExportSpecifierTransformer) - .whenTargetNamed(NodeTransformer.ExportSpecifierTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(MemberExpressionTransformer) - .whenTargetNamed(NodeTransformer.MemberExpressionTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(ClassFieldTransformer) - .whenTargetNamed(NodeTransformer.ClassFieldTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(NumberLiteralTransformer) - .whenTargetNamed(NodeTransformer.NumberLiteralTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(NumberToNumericalExpressionTransformer) - .whenTargetNamed(NodeTransformer.NumberToNumericalExpressionTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(ObjectExpressionKeysTransformer) - .whenTargetNamed(NodeTransformer.ObjectExpressionKeysTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(ObjectExpressionTransformer) - .whenTargetNamed(NodeTransformer.ObjectExpressionTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(ObjectPatternPropertiesTransformer) - .whenTargetNamed(NodeTransformer.ObjectPatternPropertiesTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(SplitStringTransformer) - .whenTargetNamed(NodeTransformer.SplitStringTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(TemplateLiteralTransformer) - .whenTargetNamed(NodeTransformer.TemplateLiteralTransformer); - - // object expression extractors - bind(ServiceIdentifiers.IObjectExpressionExtractor) - .to(ObjectExpressionToVariableDeclarationExtractor) - .whenTargetNamed(ObjectExpressionExtractor.ObjectExpressionToVariableDeclarationExtractor); - - bind(ServiceIdentifiers.IObjectExpressionExtractor) - .to(BasePropertiesExtractor) - .whenTargetNamed(ObjectExpressionExtractor.BasePropertiesExtractor); - - // object expression extractor factory - bind(ServiceIdentifiers.Factory__IObjectExpressionExtractor).toFactory< - IObjectExpressionExtractor, - [ObjectExpressionExtractor] - >( - InversifyContainerFacade.getCacheFactory( - ServiceIdentifiers.IObjectExpressionExtractor - ) - ); -}); +export const convertingTransformersModule: ContainerModule = new ContainerModule( + (options: ContainerModuleLoadOptions) => { + // converting transformers + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(BooleanLiteralTransformer) + .whenNamed(NodeTransformer.BooleanLiteralTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(ExportSpecifierTransformer) + .whenNamed(NodeTransformer.ExportSpecifierTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(MemberExpressionTransformer) + .whenNamed(NodeTransformer.MemberExpressionTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(ClassFieldTransformer) + .whenNamed(NodeTransformer.ClassFieldTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(NumberLiteralTransformer) + .whenNamed(NodeTransformer.NumberLiteralTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(NumberToNumericalExpressionTransformer) + .whenNamed(NodeTransformer.NumberToNumericalExpressionTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(ObjectExpressionKeysTransformer) + .whenNamed(NodeTransformer.ObjectExpressionKeysTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(ObjectExpressionTransformer) + .whenNamed(NodeTransformer.ObjectExpressionTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(ObjectPatternPropertiesTransformer) + .whenNamed(NodeTransformer.ObjectPatternPropertiesTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(SplitStringTransformer) + .whenNamed(NodeTransformer.SplitStringTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(TemplateLiteralTransformer) + .whenNamed(NodeTransformer.TemplateLiteralTransformer); + + // object expression extractors + options + .bind(ServiceIdentifiers.IObjectExpressionExtractor) + .to(ObjectExpressionToVariableDeclarationExtractor) + .whenNamed(ObjectExpressionExtractor.ObjectExpressionToVariableDeclarationExtractor); + + options + .bind(ServiceIdentifiers.IObjectExpressionExtractor) + .to(BasePropertiesExtractor) + .whenNamed(ObjectExpressionExtractor.BasePropertiesExtractor); + + // object expression extractor factory + options + .bind< + Factory + >(ServiceIdentifiers.Factory__IObjectExpressionExtractor) + .toFactory( + InversifyContainerFacade.getCacheFactory( + ServiceIdentifiers.IObjectExpressionExtractor + ) + ); + } +); diff --git a/src/container/modules/node-transformers/DeadCodeInjectionTransformersModule.ts b/src/container/modules/node-transformers/DeadCodeInjectionTransformersModule.ts index 211d510b2..eb62efdd4 100644 --- a/src/container/modules/node-transformers/DeadCodeInjectionTransformersModule.ts +++ b/src/container/modules/node-transformers/DeadCodeInjectionTransformersModule.ts @@ -1,4 +1,4 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { INodeTransformer } from '../../../interfaces/node-transformers/INodeTransformer'; @@ -7,11 +7,11 @@ import { NodeTransformer } from '../../../enums/node-transformers/NodeTransforme import { DeadCodeInjectionTransformer } from '../../../node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer'; -export const deadCodeInjectionTransformersModule: interfaces.ContainerModule = new ContainerModule( - (bind: interfaces.Bind) => { +export const deadCodeInjectionTransformersModule: ContainerModule = new ContainerModule( + (options: ContainerModuleLoadOptions) => { // dead code injection - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(DeadCodeInjectionTransformer) - .whenTargetNamed(NodeTransformer.DeadCodeInjectionTransformer); + .whenNamed(NodeTransformer.DeadCodeInjectionTransformer); } ); diff --git a/src/container/modules/node-transformers/FinalizingTransformersModule.ts b/src/container/modules/node-transformers/FinalizingTransformersModule.ts index c1e0f4338..9c2728deb 100644 --- a/src/container/modules/node-transformers/FinalizingTransformersModule.ts +++ b/src/container/modules/node-transformers/FinalizingTransformersModule.ts @@ -1,4 +1,4 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { INodeTransformer } from '../../../interfaces/node-transformers/INodeTransformer'; @@ -8,13 +8,13 @@ import { NodeTransformer } from '../../../enums/node-transformers/NodeTransforme import { DirectivePlacementTransformer } from '../../../node-transformers/finalizing-transformers/DirectivePlacementTransformer'; import { EscapeSequenceTransformer } from '../../../node-transformers/finalizing-transformers/EscapeSequenceTransformer'; -export const finalizingTransformersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { +export const finalizingTransformersModule: ContainerModule = new ContainerModule((options: ContainerModuleLoadOptions) => { // finalizing transformers - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(DirectivePlacementTransformer) - .whenTargetNamed(NodeTransformer.DirectivePlacementTransformer); + .whenNamed(NodeTransformer.DirectivePlacementTransformer); - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(EscapeSequenceTransformer) - .whenTargetNamed(NodeTransformer.EscapeSequenceTransformer); + .whenNamed(NodeTransformer.EscapeSequenceTransformer); }); diff --git a/src/container/modules/node-transformers/InitializingTransformersModule.ts b/src/container/modules/node-transformers/InitializingTransformersModule.ts index b7753ba5f..a38b916e6 100644 --- a/src/container/modules/node-transformers/InitializingTransformersModule.ts +++ b/src/container/modules/node-transformers/InitializingTransformersModule.ts @@ -1,4 +1,4 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { INodeTransformer } from '../../../interfaces/node-transformers/INodeTransformer'; @@ -7,11 +7,11 @@ import { NodeTransformer } from '../../../enums/node-transformers/NodeTransforme import { CommentsTransformer } from '../../../node-transformers/initializing-transformers/CommentsTransformer'; -export const initializingTransformersModule: interfaces.ContainerModule = new ContainerModule( - (bind: interfaces.Bind) => { +export const initializingTransformersModule: ContainerModule = new ContainerModule( + (options: ContainerModuleLoadOptions) => { // preparing transformers - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(CommentsTransformer) - .whenTargetNamed(NodeTransformer.CommentsTransformer); + .whenNamed(NodeTransformer.CommentsTransformer); } ); diff --git a/src/container/modules/node-transformers/NodeTransformersModule.ts b/src/container/modules/node-transformers/NodeTransformersModule.ts index a637ce34b..aab9ca263 100644 --- a/src/container/modules/node-transformers/NodeTransformersModule.ts +++ b/src/container/modules/node-transformers/NodeTransformersModule.ts @@ -1,5 +1,5 @@ import { InversifyContainerFacade } from '../../InversifyContainerFacade'; -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions, Factory } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { INodeTransformer } from '../../../interfaces/node-transformers/INodeTransformer'; @@ -9,16 +9,21 @@ import { NodeTransformer } from '../../../enums/node-transformers/NodeTransforme import { NodeTransformerNamesGroupsBuilder } from '../../../node-transformers/NodeTransformerNamesGroupsBuilder'; -export const nodeTransformersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { +export const nodeTransformersModule: ContainerModule = new ContainerModule((options: ContainerModuleLoadOptions) => { // node transformers factory - bind(ServiceIdentifiers.Factory__INodeTransformer).toFactory( - InversifyContainerFacade.getCacheFactory(ServiceIdentifiers.INodeTransformer) - ); + options + .bind>(ServiceIdentifiers.Factory__INodeTransformer) + .toFactory( + InversifyContainerFacade.getCacheFactory( + ServiceIdentifiers.INodeTransformer + ) + ); // node transformer names groups builder - bind>( - ServiceIdentifiers.INodeTransformerNamesGroupsBuilder - ) + options + .bind< + ITransformerNamesGroupsBuilder + >(ServiceIdentifiers.INodeTransformerNamesGroupsBuilder) .to(NodeTransformerNamesGroupsBuilder) .inSingletonScope(); }); diff --git a/src/container/modules/node-transformers/PreparingTransformersModule.ts b/src/container/modules/node-transformers/PreparingTransformersModule.ts index 296b632f3..85235ac6d 100644 --- a/src/container/modules/node-transformers/PreparingTransformersModule.ts +++ b/src/container/modules/node-transformers/PreparingTransformersModule.ts @@ -1,5 +1,5 @@ import { InversifyContainerFacade } from '../../InversifyContainerFacade'; -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions, Factory } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { INodeTransformer } from '../../../interfaces/node-transformers/INodeTransformer'; @@ -22,70 +22,89 @@ import { ParentificationTransformer } from '../../../node-transformers/preparing import { ReservedStringObfuscatingGuard } from '../../../node-transformers/preparing-transformers/obfuscating-guards/ReservedStringObfuscatingGuard'; import { VariablePreserveTransformer } from '../../../node-transformers/preparing-transformers/VariablePreserveTransformer'; -export const preparingTransformersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { - // preparing transformers - bind(ServiceIdentifiers.INodeTransformer) - .to(CustomCodeHelpersTransformer) - .whenTargetNamed(NodeTransformer.CustomCodeHelpersTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(EvalCallExpressionTransformer) - .whenTargetNamed(NodeTransformer.EvalCallExpressionTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(MetadataTransformer) - .whenTargetNamed(NodeTransformer.MetadataTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(ObfuscatingGuardsTransformer) - .whenTargetNamed(NodeTransformer.ObfuscatingGuardsTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(ParentificationTransformer) - .whenTargetNamed(NodeTransformer.ParentificationTransformer); - - bind(ServiceIdentifiers.INodeTransformer) - .to(VariablePreserveTransformer) - .whenTargetNamed(NodeTransformer.VariablePreserveTransformer); - - // obfuscating guards - bind(ServiceIdentifiers.INodeGuard) - .to(BlackListObfuscatingGuard) - .inSingletonScope() - .whenTargetNamed(ObfuscatingGuard.BlackListObfuscatingGuard); - - bind(ServiceIdentifiers.INodeGuard) - .to(ConditionalCommentObfuscatingGuard) - .inSingletonScope() - .whenTargetNamed(ObfuscatingGuard.ConditionalCommentObfuscatingGuard); - - bind(ServiceIdentifiers.INodeGuard) - .to(ForceTransformStringObfuscatingGuard) - .inSingletonScope() - .whenTargetNamed(ObfuscatingGuard.ForceTransformStringObfuscatingGuard); - - bind(ServiceIdentifiers.INodeGuard) - .to(IgnoredImportObfuscatingGuard) - .inSingletonScope() - .whenTargetNamed(ObfuscatingGuard.IgnoredImportObfuscatingGuard); - - bind(ServiceIdentifiers.INodeGuard) - .to(ImportMetaObfuscationGuard) - .inSingletonScope() - .whenTargetNamed(ObfuscatingGuard.ImportMetaObfuscationGuard); - - bind(ServiceIdentifiers.INodeGuard) - .to(ProcessEnvObfuscationGuard) - .inSingletonScope() - .whenTargetNamed(ObfuscatingGuard.ProcessEnvObfuscationGuard); - - bind(ServiceIdentifiers.INodeGuard) - .to(ReservedStringObfuscatingGuard) - .inSingletonScope() - .whenTargetNamed(ObfuscatingGuard.ReservedStringObfuscatingGuard); - - // obfuscating guards factory - bind(ServiceIdentifiers.Factory__INodeGuard).toFactory( - InversifyContainerFacade.getCacheFactory(ServiceIdentifiers.INodeGuard) - ); -}); +export const preparingTransformersModule: ContainerModule = new ContainerModule( + (options: ContainerModuleLoadOptions) => { + // preparing transformers + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(CustomCodeHelpersTransformer) + .whenNamed(NodeTransformer.CustomCodeHelpersTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(EvalCallExpressionTransformer) + .whenNamed(NodeTransformer.EvalCallExpressionTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(MetadataTransformer) + .whenNamed(NodeTransformer.MetadataTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(ObfuscatingGuardsTransformer) + .whenNamed(NodeTransformer.ObfuscatingGuardsTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(ParentificationTransformer) + .whenNamed(NodeTransformer.ParentificationTransformer); + + options + .bind(ServiceIdentifiers.INodeTransformer) + .to(VariablePreserveTransformer) + .whenNamed(NodeTransformer.VariablePreserveTransformer); + + // obfuscating guards + options + .bind(ServiceIdentifiers.INodeGuard) + .to(BlackListObfuscatingGuard) + .inSingletonScope() + .whenNamed(ObfuscatingGuard.BlackListObfuscatingGuard); + + options + .bind(ServiceIdentifiers.INodeGuard) + .to(ConditionalCommentObfuscatingGuard) + .inSingletonScope() + .whenNamed(ObfuscatingGuard.ConditionalCommentObfuscatingGuard); + + options + .bind(ServiceIdentifiers.INodeGuard) + .to(ForceTransformStringObfuscatingGuard) + .inSingletonScope() + .whenNamed(ObfuscatingGuard.ForceTransformStringObfuscatingGuard); + + options + .bind(ServiceIdentifiers.INodeGuard) + .to(IgnoredImportObfuscatingGuard) + .inSingletonScope() + .whenNamed(ObfuscatingGuard.IgnoredImportObfuscatingGuard); + + options + .bind(ServiceIdentifiers.INodeGuard) + .to(ImportMetaObfuscationGuard) + .inSingletonScope() + .whenNamed(ObfuscatingGuard.ImportMetaObfuscationGuard); + + options + .bind(ServiceIdentifiers.INodeGuard) + .to(ProcessEnvObfuscationGuard) + .inSingletonScope() + .whenNamed(ObfuscatingGuard.ProcessEnvObfuscationGuard); + + options + .bind(ServiceIdentifiers.INodeGuard) + .to(ReservedStringObfuscatingGuard) + .inSingletonScope() + .whenNamed(ObfuscatingGuard.ReservedStringObfuscatingGuard); + + // obfuscating guards factory + options + .bind>(ServiceIdentifiers.Factory__INodeGuard) + .toFactory( + InversifyContainerFacade.getCacheFactory( + ServiceIdentifiers.INodeGuard + ) + ); + } +); diff --git a/src/container/modules/node-transformers/RenameIdentifiersTransformersModule.ts b/src/container/modules/node-transformers/RenameIdentifiersTransformersModule.ts index 00fcaf836..972dabfaf 100644 --- a/src/container/modules/node-transformers/RenameIdentifiersTransformersModule.ts +++ b/src/container/modules/node-transformers/RenameIdentifiersTransformersModule.ts @@ -1,4 +1,4 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { IIdentifierReplacer } from '../../../interfaces/node-transformers/rename-identifiers-transformers/replacer/IIdentifierReplacer'; @@ -14,29 +14,29 @@ import { ScopeThroughIdentifiersTransformer } from '../../../node-transformers/r import { ThroughIdentifierReplacer } from '../../../node-transformers/rename-identifiers-transformers/through-replacer/ThroughIdentifierReplacer'; import { IThroughIdentifierReplacer } from '../../../interfaces/node-transformers/rename-identifiers-transformers/replacer/IThroughIdentifierReplacer'; -export const renameIdentifiersTransformersModule: interfaces.ContainerModule = new ContainerModule( - (bind: interfaces.Bind) => { +export const renameIdentifiersTransformersModule: ContainerModule = new ContainerModule( + (options: ContainerModuleLoadOptions) => { // rename identifiers transformers - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(DeadCodeInjectionIdentifiersTransformer) - .whenTargetNamed(NodeTransformer.DeadCodeInjectionIdentifiersTransformer); + .whenNamed(NodeTransformer.DeadCodeInjectionIdentifiersTransformer); - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(LabeledStatementTransformer) - .whenTargetNamed(NodeTransformer.LabeledStatementTransformer); + .whenNamed(NodeTransformer.LabeledStatementTransformer); - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(ScopeIdentifiersTransformer) - .whenTargetNamed(NodeTransformer.ScopeIdentifiersTransformer); + .whenNamed(NodeTransformer.ScopeIdentifiersTransformer); - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(ScopeThroughIdentifiersTransformer) - .whenTargetNamed(NodeTransformer.ScopeThroughIdentifiersTransformer); + .whenNamed(NodeTransformer.ScopeThroughIdentifiersTransformer); // identifier replacer - bind(ServiceIdentifiers.IIdentifierReplacer).to(IdentifierReplacer).inSingletonScope(); + options.bind(ServiceIdentifiers.IIdentifierReplacer).to(IdentifierReplacer).inSingletonScope(); - bind(ServiceIdentifiers.IThroughIdentifierReplacer) + options.bind(ServiceIdentifiers.IThroughIdentifierReplacer) .to(ThroughIdentifierReplacer) .inSingletonScope(); } diff --git a/src/container/modules/node-transformers/RenamePropertiesTransformersModule.ts b/src/container/modules/node-transformers/RenamePropertiesTransformersModule.ts index 2d1c79c07..fcdb9bd68 100644 --- a/src/container/modules/node-transformers/RenamePropertiesTransformersModule.ts +++ b/src/container/modules/node-transformers/RenamePropertiesTransformersModule.ts @@ -1,4 +1,4 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { IRenamePropertiesReplacer } from '../../../interfaces/node-transformers/rename-properties-transformers/replacer/IRenamePropertiesReplacer'; @@ -9,14 +9,14 @@ import { NodeTransformer } from '../../../enums/node-transformers/NodeTransforme import { RenamePropertiesReplacer } from '../../../node-transformers/rename-properties-transformers/replacer/RenamePropertiesReplacer'; import { RenamePropertiesTransformer } from '../../../node-transformers/rename-properties-transformers/RenamePropertiesTransformer'; -export const renamePropertiesTransformersModule: interfaces.ContainerModule = new ContainerModule( - (bind: interfaces.Bind) => { +export const renamePropertiesTransformersModule: ContainerModule = new ContainerModule( + (options: ContainerModuleLoadOptions) => { // rename properties transformers - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(RenamePropertiesTransformer) - .whenTargetNamed(NodeTransformer.RenamePropertiesTransformer); + .whenNamed(NodeTransformer.RenamePropertiesTransformer); // rename properties obfuscating replacer - bind(ServiceIdentifiers.IRenamePropertiesReplacer).to(RenamePropertiesReplacer); + options.bind(ServiceIdentifiers.IRenamePropertiesReplacer).to(RenamePropertiesReplacer); } ); diff --git a/src/container/modules/node-transformers/SimplifyingTransformersModule.ts b/src/container/modules/node-transformers/SimplifyingTransformersModule.ts index ea1c8163c..b5ad95e4c 100644 --- a/src/container/modules/node-transformers/SimplifyingTransformersModule.ts +++ b/src/container/modules/node-transformers/SimplifyingTransformersModule.ts @@ -1,4 +1,4 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { INodeTransformer } from '../../../interfaces/node-transformers/INodeTransformer'; @@ -10,23 +10,23 @@ import { ExpressionStatementsMergeTransformer } from '../../../node-transformers import { IfStatementSimplifyTransformer } from '../../../node-transformers/simplifying-transformers/IfStatementSimplifyTransformer'; import { VariableDeclarationsMergeTransformer } from '../../../node-transformers/simplifying-transformers/VariableDeclarationsMergeTransformer'; -export const simplifyingTransformersModule: interfaces.ContainerModule = new ContainerModule( - (bind: interfaces.Bind) => { +export const simplifyingTransformersModule: ContainerModule = new ContainerModule( + (options: ContainerModuleLoadOptions) => { // simplifying transformers - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(BlockStatementSimplifyTransformer) - .whenTargetNamed(NodeTransformer.BlockStatementSimplifyTransformer); + .whenNamed(NodeTransformer.BlockStatementSimplifyTransformer); - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(ExpressionStatementsMergeTransformer) - .whenTargetNamed(NodeTransformer.ExpressionStatementsMergeTransformer); + .whenNamed(NodeTransformer.ExpressionStatementsMergeTransformer); - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(IfStatementSimplifyTransformer) - .whenTargetNamed(NodeTransformer.IfStatementSimplifyTransformer); + .whenNamed(NodeTransformer.IfStatementSimplifyTransformer); - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(VariableDeclarationsMergeTransformer) - .whenTargetNamed(NodeTransformer.VariableDeclarationsMergeTransformer); + .whenNamed(NodeTransformer.VariableDeclarationsMergeTransformer); } ); diff --git a/src/container/modules/node-transformers/StringArrayTransformersModule.ts b/src/container/modules/node-transformers/StringArrayTransformersModule.ts index 1c5d1c4ae..d614a1c0f 100644 --- a/src/container/modules/node-transformers/StringArrayTransformersModule.ts +++ b/src/container/modules/node-transformers/StringArrayTransformersModule.ts @@ -1,4 +1,4 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { INodeTransformer } from '../../../interfaces/node-transformers/INodeTransformer'; @@ -9,19 +9,19 @@ import { StringArrayRotateFunctionTransformer } from '../../../node-transformers import { StringArrayScopeCallsWrapperTransformer } from '../../../node-transformers/string-array-transformers/StringArrayScopeCallsWrapperTransformer'; import { StringArrayTransformer } from '../../../node-transformers/string-array-transformers/StringArrayTransformer'; -export const stringArrayTransformersModule: interfaces.ContainerModule = new ContainerModule( - (bind: interfaces.Bind) => { +export const stringArrayTransformersModule: ContainerModule = new ContainerModule( + (options: ContainerModuleLoadOptions) => { // strings transformers - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(StringArrayRotateFunctionTransformer) - .whenTargetNamed(NodeTransformer.StringArrayRotateFunctionTransformer); + .whenNamed(NodeTransformer.StringArrayRotateFunctionTransformer); - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(StringArrayScopeCallsWrapperTransformer) - .whenTargetNamed(NodeTransformer.StringArrayScopeCallsWrapperTransformer); + .whenNamed(NodeTransformer.StringArrayScopeCallsWrapperTransformer); - bind(ServiceIdentifiers.INodeTransformer) + options.bind(ServiceIdentifiers.INodeTransformer) .to(StringArrayTransformer) - .whenTargetNamed(NodeTransformer.StringArrayTransformer); + .whenNamed(NodeTransformer.StringArrayTransformer); } ); diff --git a/src/container/modules/node/NodeModule.ts b/src/container/modules/node/NodeModule.ts index 71f2143de..36ebec7cd 100644 --- a/src/container/modules/node/NodeModule.ts +++ b/src/container/modules/node/NodeModule.ts @@ -1,13 +1,13 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { IScopeIdentifiersTraverser } from '../../../interfaces/node/IScopeIdentifiersTraverser'; import { ScopeIdentifiersTraverser } from '../../../node/ScopeIdentifiersTraverser'; -export const nodeModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { +export const nodeModule: ContainerModule = new ContainerModule((options: ContainerModuleLoadOptions) => { // scope identifiers traverser - bind(ServiceIdentifiers.IScopeIdentifiersTraverser) + options.bind(ServiceIdentifiers.IScopeIdentifiersTraverser) .to(ScopeIdentifiersTraverser) .inSingletonScope(); }); diff --git a/src/container/modules/options/OptionsModule.ts b/src/container/modules/options/OptionsModule.ts index 1e6fc1502..309e215d7 100644 --- a/src/container/modules/options/OptionsModule.ts +++ b/src/container/modules/options/OptionsModule.ts @@ -1,4 +1,4 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { IOptions } from '../../../interfaces/options/IOptions'; @@ -7,8 +7,8 @@ import { IOptionsNormalizer } from '../../../interfaces/options/IOptionsNormaliz import { Options } from '../../../options/Options'; import { OptionsNormalizer } from '../../../options/OptionsNormalizer'; -export const optionsModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { - bind(ServiceIdentifiers.IOptions).to(Options).inSingletonScope(); +export const optionsModule: ContainerModule = new ContainerModule((options: ContainerModuleLoadOptions) => { + options.bind(ServiceIdentifiers.IOptions).to(Options).inSingletonScope(); - bind(ServiceIdentifiers.IOptionsNormalizer).to(OptionsNormalizer).inSingletonScope(); + options.bind(ServiceIdentifiers.IOptionsNormalizer).to(OptionsNormalizer).inSingletonScope(); }); diff --git a/src/container/modules/storages/StoragesModule.ts b/src/container/modules/storages/StoragesModule.ts index ead8cdc42..a744cd1f0 100644 --- a/src/container/modules/storages/StoragesModule.ts +++ b/src/container/modules/storages/StoragesModule.ts @@ -1,8 +1,6 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions, ResolutionContext, Factory } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; -import { TControlFlowStorageFactory } from '../../../types/container/node-transformers/TControlFlowStorageFactory'; -import { TControlFlowStorageFactoryCreator } from '../../../types/container/node-transformers/TControlFlowStorageFactoryCreator'; import { TCustomCodeHelperGroupStorage } from '../../../types/storages/TCustomCodeHelperGroupStorage'; import { IControlFlowStorage } from '../../../interfaces/storages/control-flow-transformers/IControlFlowStorage'; @@ -25,50 +23,59 @@ import { StringControlFlowStorage } from '../../../storages/control-flow-transfo import { StringArrayStorage } from '../../../storages/string-array-transformers/StringArrayStorage'; import { VisitedLexicalScopeNodesStackStorage } from '../../../storages/string-array-transformers/VisitedLexicalScopeNodesStackStorage'; -export const storagesModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { +export const storagesModule: ContainerModule = new ContainerModule((options: ContainerModuleLoadOptions) => { // storages - bind(ServiceIdentifiers.TCustomNodeGroupStorage) + options + .bind(ServiceIdentifiers.TCustomNodeGroupStorage) .to(CustomCodeHelperGroupStorage) .inSingletonScope(); - bind(ServiceIdentifiers.IControlFlowStorage) + options + .bind(ServiceIdentifiers.IControlFlowStorage) .to(FunctionControlFlowStorage) - .whenTargetNamed(ControlFlowStorage.FunctionControlFlowStorage); + .whenNamed(ControlFlowStorage.FunctionControlFlowStorage); - bind(ServiceIdentifiers.IGlobalIdentifierNamesCacheStorage) + options + .bind(ServiceIdentifiers.IGlobalIdentifierNamesCacheStorage) .to(GlobalIdentifierNamesCacheStorage) .inSingletonScope(); - bind(ServiceIdentifiers.ILiteralNodesCacheStorage) + options + .bind(ServiceIdentifiers.ILiteralNodesCacheStorage) .to(LiteralNodesCacheStorage) .inSingletonScope(); - bind(ServiceIdentifiers.IPropertyIdentifierNamesCacheStorage) + options + .bind(ServiceIdentifiers.IPropertyIdentifierNamesCacheStorage) .to(PropertyIdentifierNamesCacheStorage) .inSingletonScope(); - bind(ServiceIdentifiers.IStringArrayStorage).to(StringArrayStorage).inSingletonScope(); + options.bind(ServiceIdentifiers.IStringArrayStorage).to(StringArrayStorage).inSingletonScope(); - bind(ServiceIdentifiers.IStringArrayScopeCallsWrappersDataStorage) + options + .bind(ServiceIdentifiers.IStringArrayScopeCallsWrappersDataStorage) .to(StringArrayScopeCallsWrappersDataStorage) .inSingletonScope(); - bind(ServiceIdentifiers.IControlFlowStorage) + options + .bind(ServiceIdentifiers.IControlFlowStorage) .to(StringControlFlowStorage) - .whenTargetNamed(ControlFlowStorage.StringControlFlowStorage); + .whenNamed(ControlFlowStorage.StringControlFlowStorage); - bind(ServiceIdentifiers.IVisitedLexicalScopeNodesStackStorage) + options + .bind(ServiceIdentifiers.IVisitedLexicalScopeNodesStackStorage) .to(VisitedLexicalScopeNodesStackStorage) .inSingletonScope(); // controlFlowStorage factory - bind(ServiceIdentifiers.Factory__TControlFlowStorage).toFactory( - (context: interfaces.Context): TControlFlowStorageFactoryCreator => - (controlFlowStorageName: ControlFlowStorage): TControlFlowStorageFactory => - (): IControlFlowStorage => - context.container.getNamed( - ServiceIdentifiers.IControlFlowStorage, - controlFlowStorageName - ) - ); + options + .bind IControlFlowStorage, [ControlFlowStorage]>>(ServiceIdentifiers.Factory__TControlFlowStorage) + .toFactory( + (context: ResolutionContext) => + (controlFlowStorageName: ControlFlowStorage): (() => IControlFlowStorage) => + () => + context.get(ServiceIdentifiers.IControlFlowStorage, { + name: controlFlowStorageName + }) + ); }); diff --git a/src/container/modules/utils/UtilsModule.ts b/src/container/modules/utils/UtilsModule.ts index 5b31f33ae..d5d7fbc0d 100644 --- a/src/container/modules/utils/UtilsModule.ts +++ b/src/container/modules/utils/UtilsModule.ts @@ -1,4 +1,4 @@ -import { ContainerModule, interfaces } from 'inversify'; +import { ContainerModule, ContainerModuleLoadOptions } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { IArrayUtils } from '../../../interfaces/utils/IArrayUtils'; @@ -17,29 +17,29 @@ import { LevelledTopologicalSorter } from '../../../utils/LevelledTopologicalSor import { RandomGenerator } from '../../../utils/RandomGenerator'; import { SetUtils } from '../../../utils/SetUtils'; -export const utilsModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { +export const utilsModule: ContainerModule = new ContainerModule((options: ContainerModuleLoadOptions) => { // array utils - bind(ServiceIdentifiers.IArrayUtils).to(ArrayUtils).inSingletonScope(); + options.bind(ServiceIdentifiers.IArrayUtils).to(ArrayUtils).inSingletonScope(); // random generator - bind(ServiceIdentifiers.IRandomGenerator).to(RandomGenerator).inSingletonScope(); + options.bind(ServiceIdentifiers.IRandomGenerator).to(RandomGenerator).inSingletonScope(); // crypt utils - bind(ServiceIdentifiers.ICryptUtils).to(CryptUtils).inSingletonScope(); + options.bind(ServiceIdentifiers.ICryptUtils).to(CryptUtils).inSingletonScope(); // crypt utils for string array - bind(ServiceIdentifiers.ICryptUtilsStringArray) + options.bind(ServiceIdentifiers.ICryptUtilsStringArray) .to(CryptUtilsStringArray) .inSingletonScope(); // escape sequence encoder - bind(ServiceIdentifiers.IEscapeSequenceEncoder) + options.bind(ServiceIdentifiers.IEscapeSequenceEncoder) .to(EscapeSequenceEncoder) .inSingletonScope(); // levelled topological sorter - bind(ServiceIdentifiers.ILevelledTopologicalSorter).to(LevelledTopologicalSorter); + options.bind(ServiceIdentifiers.ILevelledTopologicalSorter).to(LevelledTopologicalSorter); // set utils - bind(ServiceIdentifiers.ISetUtils).to(SetUtils).inSingletonScope(); + options.bind(ServiceIdentifiers.ISetUtils).to(SetUtils).inSingletonScope(); }); diff --git a/src/custom-code-helpers/calls-controller/CallsControllerFunctionCodeHelper.ts b/src/custom-code-helpers/calls-controller/CallsControllerFunctionCodeHelper.ts index 4f6758ef7..50eb9eb37 100644 --- a/src/custom-code-helpers/calls-controller/CallsControllerFunctionCodeHelper.ts +++ b/src/custom-code-helpers/calls-controller/CallsControllerFunctionCodeHelper.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -18,6 +18,7 @@ import { SingleCallControllerTemplate } from '../common/templates/SingleCallCont import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class CallsControllerFunctionCodeHelper extends AbstractCustomCodeHelper { /** diff --git a/src/custom-code-helpers/console-output/ConsoleOutputDisableCodeHelper.ts b/src/custom-code-helpers/console-output/ConsoleOutputDisableCodeHelper.ts index f342aedf2..5a25edc65 100644 --- a/src/custom-code-helpers/console-output/ConsoleOutputDisableCodeHelper.ts +++ b/src/custom-code-helpers/console-output/ConsoleOutputDisableCodeHelper.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -16,6 +16,7 @@ import { initializable } from '../../decorators/Initializable'; import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class ConsoleOutputDisableCodeHelper extends AbstractCustomCodeHelper { /** diff --git a/src/custom-code-helpers/console-output/group/ConsoleOutputCodeHelperGroup.ts b/src/custom-code-helpers/console-output/group/ConsoleOutputCodeHelperGroup.ts index 75f584ea1..4f2c8013c 100644 --- a/src/custom-code-helpers/console-output/group/ConsoleOutputCodeHelperGroup.ts +++ b/src/custom-code-helpers/console-output/group/ConsoleOutputCodeHelperGroup.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomCodeHelperFactory } from '../../../types/container/custom-code-helpers/TCustomCodeHelperFactory'; @@ -23,6 +23,7 @@ import { ConsoleOutputDisableCodeHelper } from '../ConsoleOutputDisableCodeHelpe import { NodeAppender } from '../../../node/NodeAppender'; import { NodeLexicalScopeUtils } from '../../../node/NodeLexicalScopeUtils'; +@injectFromBase() @injectable() export class ConsoleOutputCodeHelperGroup extends AbstractCustomCodeHelperGroup { /** diff --git a/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCallCodeHelper.ts b/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCallCodeHelper.ts index c00476ecd..7d61c16b2 100644 --- a/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCallCodeHelper.ts +++ b/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCallCodeHelper.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -16,6 +16,7 @@ import { DebugProtectionFunctionCallTemplate } from './templates/debug-protectio import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class DebugProtectionFunctionCallCodeHelper extends AbstractCustomCodeHelper { /** diff --git a/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCodeHelper.ts b/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCodeHelper.ts index 381521de2..798bfe730 100644 --- a/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCodeHelper.ts +++ b/src/custom-code-helpers/debug-protection/DebugProtectionFunctionCodeHelper.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -20,6 +20,7 @@ import { DebugProtectionFunctionTemplate } from './templates/debug-protection-fu import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class DebugProtectionFunctionCodeHelper extends AbstractCustomCodeHelper { /** diff --git a/src/custom-code-helpers/debug-protection/DebugProtectionFunctionIntervalCodeHelper.ts b/src/custom-code-helpers/debug-protection/DebugProtectionFunctionIntervalCodeHelper.ts index 78e8dc187..29c990b55 100644 --- a/src/custom-code-helpers/debug-protection/DebugProtectionFunctionIntervalCodeHelper.ts +++ b/src/custom-code-helpers/debug-protection/DebugProtectionFunctionIntervalCodeHelper.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -19,6 +19,7 @@ import { GlobalVariableNoEvalTemplate } from '../common/templates/GlobalVariable import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class DebugProtectionFunctionIntervalCodeHelper extends AbstractCustomCodeHelper { /** diff --git a/src/custom-code-helpers/debug-protection/group/DebugProtectionCodeHelperGroup.ts b/src/custom-code-helpers/debug-protection/group/DebugProtectionCodeHelperGroup.ts index 14ad7cfdb..1ae1faac5 100644 --- a/src/custom-code-helpers/debug-protection/group/DebugProtectionCodeHelperGroup.ts +++ b/src/custom-code-helpers/debug-protection/group/DebugProtectionCodeHelperGroup.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomCodeHelperFactory } from '../../../types/container/custom-code-helpers/TCustomCodeHelperFactory'; @@ -26,6 +26,7 @@ import { NodeAppender } from '../../../node/NodeAppender'; import { NodeGuards } from '../../../node/NodeGuards'; import { NodeLexicalScopeUtils } from '../../../node/NodeLexicalScopeUtils'; +@injectFromBase() @injectable() export class DebugProtectionCodeHelperGroup extends AbstractCustomCodeHelperGroup { /** diff --git a/src/custom-code-helpers/domain-lock/DomainLockCodeHelper.ts b/src/custom-code-helpers/domain-lock/DomainLockCodeHelper.ts index eb683161a..740530e69 100644 --- a/src/custom-code-helpers/domain-lock/DomainLockCodeHelper.ts +++ b/src/custom-code-helpers/domain-lock/DomainLockCodeHelper.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -20,6 +20,7 @@ import { GlobalVariableNoEvalTemplate } from '../common/templates/GlobalVariable import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class DomainLockCodeHelper extends AbstractCustomCodeHelper { /** diff --git a/src/custom-code-helpers/domain-lock/group/DomainLockCustomCodeHelperGroup.ts b/src/custom-code-helpers/domain-lock/group/DomainLockCustomCodeHelperGroup.ts index e768d03fa..0213a83d6 100644 --- a/src/custom-code-helpers/domain-lock/group/DomainLockCustomCodeHelperGroup.ts +++ b/src/custom-code-helpers/domain-lock/group/DomainLockCustomCodeHelperGroup.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomCodeHelperFactory } from '../../../types/container/custom-code-helpers/TCustomCodeHelperFactory'; @@ -23,6 +23,7 @@ import { DomainLockCodeHelper } from '../DomainLockCodeHelper'; import { NodeAppender } from '../../../node/NodeAppender'; import { NodeLexicalScopeUtils } from '../../../node/NodeLexicalScopeUtils'; +@injectFromBase() @injectable() export class DomainLockCustomCodeHelperGroup extends AbstractCustomCodeHelperGroup { /** diff --git a/src/custom-code-helpers/self-defending/SelfDefendingCodeHelper.ts b/src/custom-code-helpers/self-defending/SelfDefendingCodeHelper.ts index b03a052c2..e35856251 100644 --- a/src/custom-code-helpers/self-defending/SelfDefendingCodeHelper.ts +++ b/src/custom-code-helpers/self-defending/SelfDefendingCodeHelper.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -16,6 +16,7 @@ import { SelfDefendingTemplate } from './templates/SelfDefendingTemplate'; import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class SelfDefendingCodeHelper extends AbstractCustomCodeHelper { /** diff --git a/src/custom-code-helpers/self-defending/group/SelfDefendingCodeHelperGroup.ts b/src/custom-code-helpers/self-defending/group/SelfDefendingCodeHelperGroup.ts index ebb46590c..810db865d 100644 --- a/src/custom-code-helpers/self-defending/group/SelfDefendingCodeHelperGroup.ts +++ b/src/custom-code-helpers/self-defending/group/SelfDefendingCodeHelperGroup.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomCodeHelperFactory } from '../../../types/container/custom-code-helpers/TCustomCodeHelperFactory'; @@ -23,6 +23,7 @@ import { NodeAppender } from '../../../node/NodeAppender'; import { NodeLexicalScopeUtils } from '../../../node/NodeLexicalScopeUtils'; import { SelfDefendingCodeHelper } from '../SelfDefendingCodeHelper'; +@injectFromBase() @injectable() export class SelfDefendingCodeHelperGroup extends AbstractCustomCodeHelperGroup { /** diff --git a/src/custom-code-helpers/string-array/StringArrayCallsWrapperBase64CodeHelper.ts b/src/custom-code-helpers/string-array/StringArrayCallsWrapperBase64CodeHelper.ts index 61cf1113d..42e1e76df 100644 --- a/src/custom-code-helpers/string-array/StringArrayCallsWrapperBase64CodeHelper.ts +++ b/src/custom-code-helpers/string-array/StringArrayCallsWrapperBase64CodeHelper.ts @@ -1,10 +1,11 @@ -import { injectable } from 'inversify'; +import { injectable, injectFromBase } from 'inversify'; import { AtobTemplate } from './templates/string-array-calls-wrapper/AtobTemplate'; import { StringArrayBase64DecodeTemplate } from './templates/string-array-calls-wrapper/StringArrayBase64DecodeTemplate'; import { StringArrayCallsWrapperCodeHelper } from './StringArrayCallsWrapperCodeHelper'; +@injectFromBase() @injectable() export class StringArrayCallsWrapperBase64CodeHelper extends StringArrayCallsWrapperCodeHelper { /** diff --git a/src/custom-code-helpers/string-array/StringArrayCallsWrapperCodeHelper.ts b/src/custom-code-helpers/string-array/StringArrayCallsWrapperCodeHelper.ts index ac4e30051..b7dfee192 100644 --- a/src/custom-code-helpers/string-array/StringArrayCallsWrapperCodeHelper.ts +++ b/src/custom-code-helpers/string-array/StringArrayCallsWrapperCodeHelper.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -18,6 +18,7 @@ import { StringArrayCallsWrapperTemplate } from './templates/string-array-calls- import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class StringArrayCallsWrapperCodeHelper extends AbstractCustomCodeHelper { /** diff --git a/src/custom-code-helpers/string-array/StringArrayCallsWrapperRc4CodeHelper.ts b/src/custom-code-helpers/string-array/StringArrayCallsWrapperRc4CodeHelper.ts index 2f830cbda..b9c7dd223 100644 --- a/src/custom-code-helpers/string-array/StringArrayCallsWrapperRc4CodeHelper.ts +++ b/src/custom-code-helpers/string-array/StringArrayCallsWrapperRc4CodeHelper.ts @@ -1,4 +1,4 @@ -import { injectable } from 'inversify'; +import { injectable, injectFromBase } from 'inversify'; import { AtobTemplate } from './templates/string-array-calls-wrapper/AtobTemplate'; import { Rc4Template } from './templates/string-array-calls-wrapper/Rc4Template'; @@ -6,6 +6,7 @@ import { StringArrayRC4DecodeTemplate } from './templates/string-array-calls-wra import { StringArrayCallsWrapperCodeHelper } from './StringArrayCallsWrapperCodeHelper'; +@injectFromBase() @injectable() export class StringArrayCallsWrapperRc4CodeHelper extends StringArrayCallsWrapperCodeHelper { /** diff --git a/src/custom-code-helpers/string-array/StringArrayCodeHelper.ts b/src/custom-code-helpers/string-array/StringArrayCodeHelper.ts index 47ce86139..b0822be96 100644 --- a/src/custom-code-helpers/string-array/StringArrayCodeHelper.ts +++ b/src/custom-code-helpers/string-array/StringArrayCodeHelper.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -19,6 +19,7 @@ import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper'; import { NodeUtils } from '../../node/NodeUtils'; import { StringUtils } from '../../utils/StringUtils'; +@injectFromBase() @injectable() export class StringArrayCodeHelper extends AbstractCustomCodeHelper { /** diff --git a/src/custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper.ts b/src/custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper.ts index 563c87495..f36159ba0 100644 --- a/src/custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper.ts +++ b/src/custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper.ts @@ -1,5 +1,5 @@ import type { Expression } from 'estree'; -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -17,6 +17,7 @@ import { StringArrayRotateFunctionTemplate } from './templates/string-array-rota import { AbstractCustomCodeHelper } from '../AbstractCustomCodeHelper'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class StringArrayRotateFunctionCodeHelper extends AbstractCustomCodeHelper { /** diff --git a/src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts b/src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts index 242dd8e34..0368e7cbc 100644 --- a/src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts +++ b/src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomCodeHelperFactory } from '../../../types/container/custom-code-helpers/TCustomCodeHelperFactory'; @@ -24,6 +24,7 @@ import { NodeAppender } from '../../../node/NodeAppender'; import { StringArrayCallsWrapperCodeHelper } from '../StringArrayCallsWrapperCodeHelper'; import { StringArrayCodeHelper } from '../StringArrayCodeHelper'; +@injectFromBase() @injectable() export class StringArrayCodeHelperGroup extends AbstractCustomCodeHelperGroup { /** diff --git a/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/AtobTemplate.ts b/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/AtobTemplate.ts index 340d7b42a..f94a27569 100644 --- a/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/AtobTemplate.ts +++ b/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/AtobTemplate.ts @@ -12,8 +12,15 @@ export function AtobTemplate(selfDefending: boolean): string { let output = ''; let tempEncodedString = ''; - ${selfDefending ? 'let func = output + {atobFunctionName};' : ''} - + ${ + selfDefending + ? ` + let func = output + {atobFunctionName}; + let __ = ('' + function(){return 0;}).indexOf('\\n') !== -1; + ` + : '' + } + for ( let bc = 0, bs, buffer, idx = 0; buffer = input.charAt(idx++); @@ -21,7 +28,13 @@ export function AtobTemplate(selfDefending: boolean): string { ? output += ${((): string => { const basePart: string = 'String.fromCharCode(255 & bs >> (-2 * bc & 6))'; - return selfDefending ? `((func.charCodeAt(idx + 10) - 10 !== 0) ? ${basePart} : bc)` : basePart; + return selfDefending + ? ` + ((__ || func.charCodeAt(idx + 10) - 10 !== 0) + ? ${basePart} + : bc) + ` + : basePart; })()} : 0 ) { diff --git a/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/SelfDefendingTemplate.ts b/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/SelfDefendingTemplate.ts index def5c29e9..92abd981d 100644 --- a/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/SelfDefendingTemplate.ts +++ b/src/custom-code-helpers/string-array/templates/string-array-calls-wrapper/SelfDefendingTemplate.ts @@ -57,6 +57,8 @@ export function SelfDefendingTemplate( return ${rc4BytesIdentifier}(this.${statesIdentifier}[0]); }; - new StatesClass({stringArrayCallsWrapperName}).${checkStateIdentifier}(); + if (('' + function(){return 0;}).indexOf('\\n') === -1) { + new StatesClass({stringArrayCallsWrapperName}).${checkStateIdentifier}(); + } `; } diff --git a/src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts b/src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts index 55c02da8a..d7bc4e670 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import type { BinaryOperator } from 'estree'; @@ -14,6 +14,7 @@ import { AbstractCustomNode } from '../AbstractCustomNode'; import { NodeFactory } from '../../node/NodeFactory'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class BinaryExpressionFunctionNode extends AbstractCustomNode { /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode.ts b/src/custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode.ts index 84f64b935..b17f8d70c 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -19,6 +19,7 @@ import { NodeFactory } from '../../node/NodeFactory'; import { NodeGuards } from '../../node/NodeGuards'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class BlockStatementControlFlowFlatteningNode extends AbstractCustomNode { /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts b/src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts index 8202db775..eba2a228f 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -17,6 +17,7 @@ import { NodeFactory } from '../../node/NodeFactory'; import { NodeUtils } from '../../node/NodeUtils'; import { NodeGuards } from '../../node/NodeGuards'; +@injectFromBase() @injectable() export class CallExpressionFunctionNode extends AbstractCustomNode { /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/LiteralNode.ts b/src/custom-nodes/control-flow-flattening-nodes/LiteralNode.ts index 29097ceb7..a0f5c9c20 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/LiteralNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/LiteralNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import type * as ESTree from 'estree'; @@ -15,6 +15,7 @@ import { initializable } from '../../decorators/Initializable'; import { AbstractCustomNode } from '../AbstractCustomNode'; import { NodeFactory } from '../../node/NodeFactory'; +@injectFromBase() @injectable() export class LiteralNode extends AbstractCustomNode { /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts b/src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts index 65da3d95c..cc728f735 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import type { LogicalOperator } from 'estree'; @@ -14,6 +14,7 @@ import { AbstractCustomNode } from '../AbstractCustomNode'; import { NodeFactory } from '../../node/NodeFactory'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class LogicalExpressionFunctionNode extends AbstractCustomNode { /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts index a024ec1a3..972f97650 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import type * as ESTree from 'estree'; @@ -16,6 +16,7 @@ import { AbstractCustomNode } from '../../AbstractCustomNode'; import { NodeFactory } from '../../../node/NodeFactory'; import { NodeUtils } from '../../../node/NodeUtils'; +@injectFromBase() @injectable() export class CallExpressionControlFlowStorageCallNode extends AbstractCustomNode { /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts index 463f6a16e..c0e7718c9 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -18,6 +18,7 @@ import { AbstractCustomNode } from '../../AbstractCustomNode'; import { NodeFactory } from '../../../node/NodeFactory'; import { NodeGuards } from '../../../node/NodeGuards'; +@injectFromBase() @injectable() export class ControlFlowStorageNode extends AbstractCustomNode { /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode.ts b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode.ts index a5cc0eec5..d4fc1740d 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import type { Expression } from 'estree'; @@ -16,6 +16,7 @@ import { AbstractCustomNode } from '../../AbstractCustomNode'; import { NodeFactory } from '../../../node/NodeFactory'; import { NodeUtils } from '../../../node/NodeUtils'; +@injectFromBase() @injectable() export class ExpressionWithOperatorControlFlowStorageCallNode extends AbstractCustomNode { /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode.ts b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode.ts index a597e0161..daa632fa6 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -14,6 +14,7 @@ import { AbstractCustomNode } from '../../AbstractCustomNode'; import { NodeFactory } from '../../../node/NodeFactory'; import { NodeUtils } from '../../../node/NodeUtils'; +@injectFromBase() @injectable() export class StringLiteralControlFlowStorageCallNode extends AbstractCustomNode { /** diff --git a/src/custom-nodes/dead-code-injection-nodes/BlockStatementDeadCodeInjectionNode.ts b/src/custom-nodes/dead-code-injection-nodes/BlockStatementDeadCodeInjectionNode.ts index c711d1525..dc2bbe9da 100644 --- a/src/custom-nodes/dead-code-injection-nodes/BlockStatementDeadCodeInjectionNode.ts +++ b/src/custom-nodes/dead-code-injection-nodes/BlockStatementDeadCodeInjectionNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import type { BinaryOperator, BlockStatement } from 'estree'; @@ -14,6 +14,7 @@ import { AbstractCustomNode } from '../AbstractCustomNode'; import { NodeFactory } from '../../node/NodeFactory'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class BlockStatementDeadCodeInjectionNode extends AbstractCustomNode { /** diff --git a/src/custom-nodes/object-expression-keys-transformer-nodes/ObjectExpressionVariableDeclarationHostNode.ts b/src/custom-nodes/object-expression-keys-transformer-nodes/ObjectExpressionVariableDeclarationHostNode.ts index dfdd1a152..9477c3bde 100644 --- a/src/custom-nodes/object-expression-keys-transformer-nodes/ObjectExpressionVariableDeclarationHostNode.ts +++ b/src/custom-nodes/object-expression-keys-transformer-nodes/ObjectExpressionVariableDeclarationHostNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -15,6 +15,7 @@ import { AbstractCustomNode } from '../AbstractCustomNode'; import { NodeFactory } from '../../node/NodeFactory'; import { NodeGuards } from '../../node/NodeGuards'; +@injectFromBase() @injectable() export class ObjectExpressionVariableDeclarationHostNode extends AbstractCustomNode { /** diff --git a/src/custom-nodes/string-array-nodes/AbstractStringArrayCallNode.ts b/src/custom-nodes/string-array-nodes/AbstractStringArrayCallNode.ts index 296d4f7ce..026b98bb9 100644 --- a/src/custom-nodes/string-array-nodes/AbstractStringArrayCallNode.ts +++ b/src/custom-nodes/string-array-nodes/AbstractStringArrayCallNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -21,6 +21,7 @@ import { NodeMetadata } from '../../node/NodeMetadata'; import { NodeUtils } from '../../node/NodeUtils'; import { IArrayUtils } from '../../interfaces/utils/IArrayUtils'; +@injectFromBase() @injectable() export abstract class AbstractStringArrayCallNode extends AbstractCustomNode { /** diff --git a/src/custom-nodes/string-array-nodes/StringArrayCallNode.ts b/src/custom-nodes/string-array-nodes/StringArrayCallNode.ts index d330eecd0..2934893e4 100644 --- a/src/custom-nodes/string-array-nodes/StringArrayCallNode.ts +++ b/src/custom-nodes/string-array-nodes/StringArrayCallNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -20,6 +20,7 @@ import { NodeFactory } from '../../node/NodeFactory'; import { NodeUtils } from '../../node/NodeUtils'; import { IStringArrayScopeCallsWrapperData } from '../../interfaces/node-transformers/string-array-transformers/IStringArrayScopeCallsWrapperData'; +@injectFromBase() @injectable() export class StringArrayCallNode extends AbstractStringArrayCallNode { /** diff --git a/src/custom-nodes/string-array-nodes/StringArrayScopeCallsWrapperFunctionNode.ts b/src/custom-nodes/string-array-nodes/StringArrayScopeCallsWrapperFunctionNode.ts index 7ebf4e707..9710671bf 100644 --- a/src/custom-nodes/string-array-nodes/StringArrayScopeCallsWrapperFunctionNode.ts +++ b/src/custom-nodes/string-array-nodes/StringArrayScopeCallsWrapperFunctionNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -20,6 +20,7 @@ import { AbstractStringArrayCallNode } from './AbstractStringArrayCallNode'; import { NodeFactory } from '../../node/NodeFactory'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class StringArrayScopeCallsWrapperFunctionNode extends AbstractStringArrayCallNode { /** diff --git a/src/custom-nodes/string-array-nodes/StringArrayScopeCallsWrapperVariableNode.ts b/src/custom-nodes/string-array-nodes/StringArrayScopeCallsWrapperVariableNode.ts index 2a19f05be..d3f43068d 100644 --- a/src/custom-nodes/string-array-nodes/StringArrayScopeCallsWrapperVariableNode.ts +++ b/src/custom-nodes/string-array-nodes/StringArrayScopeCallsWrapperVariableNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -18,6 +18,7 @@ import { AbstractStringArrayCallNode } from './AbstractStringArrayCallNode'; import { NodeFactory } from '../../node/NodeFactory'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class StringArrayScopeCallsWrapperVariableNode extends AbstractStringArrayCallNode { /** diff --git a/src/custom-nodes/string-array-nodes/string-array-index-nodes/StringArrayHexadecimalNumberIndexNode.ts b/src/custom-nodes/string-array-nodes/string-array-index-nodes/StringArrayHexadecimalNumberIndexNode.ts index ed3fb3e38..46894c114 100644 --- a/src/custom-nodes/string-array-nodes/string-array-index-nodes/StringArrayHexadecimalNumberIndexNode.ts +++ b/src/custom-nodes/string-array-nodes/string-array-index-nodes/StringArrayHexadecimalNumberIndexNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import * as ESTree from 'estree'; @@ -11,6 +11,7 @@ import { AbstractStringArrayIndexNode } from './AbstractStringArrayIndexNode'; import { NodeFactory } from '../../../node/NodeFactory'; import { NumberUtils } from '../../../utils/NumberUtils'; +@injectFromBase() @injectable() export class StringArrayHexadecimalNumberIndexNode extends AbstractStringArrayIndexNode { /** diff --git a/src/custom-nodes/string-array-nodes/string-array-index-nodes/StringArrayHexadecimalNumericStringIndexNode.ts b/src/custom-nodes/string-array-nodes/string-array-index-nodes/StringArrayHexadecimalNumericStringIndexNode.ts index afaa3d2e3..ad5c98f72 100644 --- a/src/custom-nodes/string-array-nodes/string-array-index-nodes/StringArrayHexadecimalNumericStringIndexNode.ts +++ b/src/custom-nodes/string-array-nodes/string-array-index-nodes/StringArrayHexadecimalNumericStringIndexNode.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import * as ESTree from 'estree'; @@ -11,6 +11,7 @@ import { AbstractStringArrayIndexNode } from './AbstractStringArrayIndexNode'; import { NodeFactory } from '../../../node/NodeFactory'; import { NumberUtils } from '../../../utils/NumberUtils'; +@injectFromBase() @injectable() export class StringArrayHexadecimalNumericStringIndexNode extends AbstractStringArrayIndexNode { /** diff --git a/src/generators/identifier-names-generators/DictionaryIdentifierNamesGenerator.ts b/src/generators/identifier-names-generators/DictionaryIdentifierNamesGenerator.ts index 4db36fccd..946a05a4d 100644 --- a/src/generators/identifier-names-generators/DictionaryIdentifierNamesGenerator.ts +++ b/src/generators/identifier-names-generators/DictionaryIdentifierNamesGenerator.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { IArrayUtils } from '../../interfaces/utils/IArrayUtils'; @@ -9,6 +9,7 @@ import { AbstractIdentifierNamesGenerator } from './AbstractIdentifierNamesGener import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope'; import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils'; +@injectFromBase() @injectable() export class DictionaryIdentifierNamesGenerator extends AbstractIdentifierNamesGenerator { /** diff --git a/src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.ts b/src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.ts index 97020c724..c97659c60 100644 --- a/src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.ts +++ b/src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope'; @@ -10,6 +10,7 @@ import { AbstractIdentifierNamesGenerator } from './AbstractIdentifierNamesGener import { NumberUtils } from '../../utils/NumberUtils'; import { Utils } from '../../utils/Utils'; +@injectFromBase() @injectable() export class HexadecimalIdentifierNamesGenerator extends AbstractIdentifierNamesGenerator { /** diff --git a/src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.ts b/src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.ts index f76c71c97..9d4b16269 100644 --- a/src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.ts +++ b/src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope'; @@ -15,6 +15,7 @@ import { reservedIdentifierNames } from '../../constants/ReservedIdentifierNames import { AbstractIdentifierNamesGenerator } from './AbstractIdentifierNamesGenerator'; import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils'; +@injectFromBase() @injectable() export class MangledIdentifierNamesGenerator extends AbstractIdentifierNamesGenerator { /** diff --git a/src/generators/identifier-names-generators/MangledShuffledIdentifierNamesGenerator.ts b/src/generators/identifier-names-generators/MangledShuffledIdentifierNamesGenerator.ts index e4705ae3b..b9f9452a2 100644 --- a/src/generators/identifier-names-generators/MangledShuffledIdentifierNamesGenerator.ts +++ b/src/generators/identifier-names-generators/MangledShuffledIdentifierNamesGenerator.ts @@ -1,4 +1,4 @@ -import { inject, injectable, postConstruct } from 'inversify'; +import { inject, injectable, injectFromBase, postConstruct } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { IArrayUtils } from '../../interfaces/utils/IArrayUtils'; @@ -12,6 +12,7 @@ import { alphabetStringUppercase } from '../../constants/AlphabetStringUppercase import { MangledIdentifierNamesGenerator } from './MangledIdentifierNamesGenerator'; +@injectFromBase() @injectable() export class MangledShuffledIdentifierNamesGenerator extends MangledIdentifierNamesGenerator { /** diff --git a/src/interfaces/container/IInversifyContainerFacade.ts b/src/interfaces/container/IInversifyContainerFacade.ts index ccd4bbe74..db129069a 100644 --- a/src/interfaces/container/IInversifyContainerFacade.ts +++ b/src/interfaces/container/IInversifyContainerFacade.ts @@ -1,4 +1,4 @@ -import { interfaces } from 'inversify'; +import { ServiceIdentifier } from 'inversify'; import { TInputOptions } from '../../types/options/TInputOptions'; @@ -6,13 +6,13 @@ export interface IInversifyContainerFacade { /** * @param serviceIdentifier */ - get(serviceIdentifier: interfaces.ServiceIdentifier): T; + get(serviceIdentifier: ServiceIdentifier): T; /** * @param serviceIdentifier * @param named */ - getNamed(serviceIdentifier: interfaces.ServiceIdentifier, named: string | number | symbol): T; + getNamed(serviceIdentifier: ServiceIdentifier, named: string | number | symbol): T; /** * @param {string} sourceCode diff --git a/src/node-transformers/NodeTransformerNamesGroupsBuilder.ts b/src/node-transformers/NodeTransformerNamesGroupsBuilder.ts index d29fca702..de0588ef4 100644 --- a/src/node-transformers/NodeTransformerNamesGroupsBuilder.ts +++ b/src/node-transformers/NodeTransformerNamesGroupsBuilder.ts @@ -1,4 +1,4 @@ -import { injectable } from 'inversify'; +import { injectable, injectFromBase } from 'inversify'; import { INodeTransformer } from '../interfaces/node-transformers/INodeTransformer'; @@ -6,6 +6,7 @@ import { NodeTransformer } from '../enums/node-transformers/NodeTransformer'; import { AbstractTransformerNamesGroupsBuilder } from '../utils/AbstractTransformerNamesGroupsBuilder'; +@injectFromBase() @injectable() export class NodeTransformerNamesGroupsBuilder extends AbstractTransformerNamesGroupsBuilder< NodeTransformer, diff --git a/src/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.ts b/src/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.ts index 9a09ca261..89e15b742 100644 --- a/src/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.ts +++ b/src/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as estraverse from '@javascript-obfuscator/estraverse'; @@ -22,6 +22,7 @@ import { BlockStatementControlFlowFlatteningNode } from '../../custom-nodes/cont import { NodeGuards } from '../../node/NodeGuards'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class BlockStatementControlFlowTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts b/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts index 362317f03..6e64c55e8 100644 --- a/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts +++ b/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as estraverse from '@javascript-obfuscator/estraverse'; @@ -31,6 +31,7 @@ import { NodeMetadata } from '../../node/NodeMetadata'; import { NodeStatementUtils } from '../../node/NodeStatementUtils'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class FunctionControlFlowTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/control-flow-transformers/StringArrayControlFlowTransformer.ts b/src/node-transformers/control-flow-transformers/StringArrayControlFlowTransformer.ts index 0de2115a9..3f6d287f4 100644 --- a/src/node-transformers/control-flow-transformers/StringArrayControlFlowTransformer.ts +++ b/src/node-transformers/control-flow-transformers/StringArrayControlFlowTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as estraverse from '@javascript-obfuscator/estraverse'; @@ -23,6 +23,7 @@ import { NodeTransformer } from '../../enums/node-transformers/NodeTransformer'; import { FunctionControlFlowTransformer } from './FunctionControlFlowTransformer'; import { NodeGuards } from '../../node/NodeGuards'; +@injectFromBase() @injectable() export class StringArrayControlFlowTransformer extends FunctionControlFlowTransformer { /** diff --git a/src/node-transformers/control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.ts b/src/node-transformers/control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.ts index af926ae08..7b308cdeb 100644 --- a/src/node-transformers/control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.ts +++ b/src/node-transformers/control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -17,6 +17,7 @@ import { ControlFlowCustomNode } from '../../../enums/custom-nodes/ControlFlowCu import { BinaryExpressionFunctionNode } from '../../../custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode'; import { ExpressionWithOperatorControlFlowReplacer } from './ExpressionWithOperatorControlFlowReplacer'; +@injectFromBase() @injectable() export class BinaryExpressionControlFlowReplacer extends ExpressionWithOperatorControlFlowReplacer { /** diff --git a/src/node-transformers/control-flow-transformers/control-flow-replacers/CallExpressionControlFlowReplacer.ts b/src/node-transformers/control-flow-transformers/control-flow-replacers/CallExpressionControlFlowReplacer.ts index e6362c81e..a3d17e589 100644 --- a/src/node-transformers/control-flow-transformers/control-flow-replacers/CallExpressionControlFlowReplacer.ts +++ b/src/node-transformers/control-flow-transformers/control-flow-replacers/CallExpressionControlFlowReplacer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -20,6 +20,7 @@ import { CallExpressionFunctionNode } from '../../../custom-nodes/control-flow-f import { CallExpressionControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode'; import { NodeGuards } from '../../../node/NodeGuards'; +@injectFromBase() @injectable() export class CallExpressionControlFlowReplacer extends AbstractControlFlowReplacer { /** diff --git a/src/node-transformers/control-flow-transformers/control-flow-replacers/ExpressionWithOperatorControlFlowReplacer.ts b/src/node-transformers/control-flow-transformers/control-flow-replacers/ExpressionWithOperatorControlFlowReplacer.ts index be9604ff8..6107cb3f1 100644 --- a/src/node-transformers/control-flow-transformers/control-flow-replacers/ExpressionWithOperatorControlFlowReplacer.ts +++ b/src/node-transformers/control-flow-transformers/control-flow-replacers/ExpressionWithOperatorControlFlowReplacer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -18,6 +18,7 @@ import { AbstractControlFlowReplacer } from './AbstractControlFlowReplacer'; import { ExpressionWithOperatorControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode'; import { NodeGuards } from '../../../node/NodeGuards'; +@injectFromBase() @injectable() export abstract class ExpressionWithOperatorControlFlowReplacer extends AbstractControlFlowReplacer { /** diff --git a/src/node-transformers/control-flow-transformers/control-flow-replacers/LogicalExpressionControlFlowReplacer.ts b/src/node-transformers/control-flow-transformers/control-flow-replacers/LogicalExpressionControlFlowReplacer.ts index d4f5d6265..bd14e0aa1 100644 --- a/src/node-transformers/control-flow-transformers/control-flow-replacers/LogicalExpressionControlFlowReplacer.ts +++ b/src/node-transformers/control-flow-transformers/control-flow-replacers/LogicalExpressionControlFlowReplacer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -20,6 +20,7 @@ import { LogicalExpressionFunctionNode } from '../../../custom-nodes/control-flo import { NodeGuards } from '../../../node/NodeGuards'; import { NodeUtils } from '../../../node/NodeUtils'; +@injectFromBase() @injectable() export class LogicalExpressionControlFlowReplacer extends ExpressionWithOperatorControlFlowReplacer { /** diff --git a/src/node-transformers/control-flow-transformers/control-flow-replacers/StringArrayCallControlFlowReplacer.ts b/src/node-transformers/control-flow-transformers/control-flow-replacers/StringArrayCallControlFlowReplacer.ts index ea5340056..4a2ca6856 100644 --- a/src/node-transformers/control-flow-transformers/control-flow-replacers/StringArrayCallControlFlowReplacer.ts +++ b/src/node-transformers/control-flow-transformers/control-flow-replacers/StringArrayCallControlFlowReplacer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -22,6 +22,7 @@ import { NodeMetadata } from '../../../node/NodeMetadata'; import { StringLiteralControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode'; import { LiteralNode } from '../../../custom-nodes/control-flow-flattening-nodes/LiteralNode'; +@injectFromBase() @injectable() export class StringArrayCallControlFlowReplacer extends AbstractControlFlowReplacer { /** diff --git a/src/node-transformers/control-flow-transformers/control-flow-replacers/StringLiteralControlFlowReplacer.ts b/src/node-transformers/control-flow-transformers/control-flow-replacers/StringLiteralControlFlowReplacer.ts index f4de203ee..eafbb188f 100644 --- a/src/node-transformers/control-flow-transformers/control-flow-replacers/StringLiteralControlFlowReplacer.ts +++ b/src/node-transformers/control-flow-transformers/control-flow-replacers/StringLiteralControlFlowReplacer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -21,6 +21,7 @@ import { NodeLiteralUtils } from '../../../node/NodeLiteralUtils'; import { StringLiteralControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode'; import { LiteralNode } from '../../../custom-nodes/control-flow-flattening-nodes/LiteralNode'; +@injectFromBase() @injectable() export class StringLiteralControlFlowReplacer extends AbstractControlFlowReplacer { /** diff --git a/src/node-transformers/converting-transformers/BooleanLiteralTransformer.ts b/src/node-transformers/converting-transformers/BooleanLiteralTransformer.ts index f1bc652bc..d3a6672ce 100644 --- a/src/node-transformers/converting-transformers/BooleanLiteralTransformer.ts +++ b/src/node-transformers/converting-transformers/BooleanLiteralTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -14,6 +14,7 @@ import { NodeGuards } from '../../node/NodeGuards'; import { NodeUtils } from '../../node/NodeUtils'; import { NodeFactory } from '../../node/NodeFactory'; +@injectFromBase() @injectable() export class BooleanLiteralTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/converting-transformers/ClassFieldTransformer.ts b/src/node-transformers/converting-transformers/ClassFieldTransformer.ts index 6ed14af3c..5b4ac2023 100644 --- a/src/node-transformers/converting-transformers/ClassFieldTransformer.ts +++ b/src/node-transformers/converting-transformers/ClassFieldTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -29,6 +29,7 @@ import { IdentifierReplacer } from '../rename-identifiers-transformers/replacer/ * * Literal node will be obfuscated by LiteralTransformer */ +@injectFromBase() @injectable() export class ClassFieldTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/converting-transformers/ExportSpecifierTransformer.ts b/src/node-transformers/converting-transformers/ExportSpecifierTransformer.ts index fd49aad2c..5962dff03 100644 --- a/src/node-transformers/converting-transformers/ExportSpecifierTransformer.ts +++ b/src/node-transformers/converting-transformers/ExportSpecifierTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -13,6 +13,7 @@ import { AbstractNodeTransformer } from '../AbstractNodeTransformer'; import { NodeGuards } from '../../node/NodeGuards'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class ExportSpecifierTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/converting-transformers/MemberExpressionTransformer.ts b/src/node-transformers/converting-transformers/MemberExpressionTransformer.ts index bf1e9cd6f..0bd5738de 100644 --- a/src/node-transformers/converting-transformers/MemberExpressionTransformer.ts +++ b/src/node-transformers/converting-transformers/MemberExpressionTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -14,6 +14,7 @@ import { NodeFactory } from '../../node/NodeFactory'; import { NodeGuards } from '../../node/NodeGuards'; import { NodeMetadata } from '../../node/NodeMetadata'; +@injectFromBase() @injectable() export class MemberExpressionTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/converting-transformers/NumberLiteralTransformer.ts b/src/node-transformers/converting-transformers/NumberLiteralTransformer.ts index cc84588c5..2d340cde3 100644 --- a/src/node-transformers/converting-transformers/NumberLiteralTransformer.ts +++ b/src/node-transformers/converting-transformers/NumberLiteralTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -15,6 +15,7 @@ import { NodeFactory } from '../../node/NodeFactory'; import { NodeGuards } from '../../node/NodeGuards'; import { NumberUtils } from '../../utils/NumberUtils'; +@injectFromBase() @injectable() export class NumberLiteralTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/converting-transformers/NumberToNumericalExpressionTransformer.ts b/src/node-transformers/converting-transformers/NumberToNumericalExpressionTransformer.ts index 8ceaa0bda..80430a82f 100644 --- a/src/node-transformers/converting-transformers/NumberToNumericalExpressionTransformer.ts +++ b/src/node-transformers/converting-transformers/NumberToNumericalExpressionTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -26,6 +26,7 @@ import { NumericalExpressionDataToNodeConverter } from '../../node/NumericalExpr * on: * var number = 50 + (100 * 2) - 127; */ +@injectFromBase() @injectable() export class NumberToNumericalExpressionTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/converting-transformers/ObjectExpressionKeysTransformer.ts b/src/node-transformers/converting-transformers/ObjectExpressionKeysTransformer.ts index 9918d1d23..c700cfa8c 100644 --- a/src/node-transformers/converting-transformers/ObjectExpressionKeysTransformer.ts +++ b/src/node-transformers/converting-transformers/ObjectExpressionKeysTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as estraverse from '@javascript-obfuscator/estraverse'; @@ -17,6 +17,7 @@ import { AbstractNodeTransformer } from '../AbstractNodeTransformer'; import { NodeGuards } from '../../node/NodeGuards'; import { NodeStatementUtils } from '../../node/NodeStatementUtils'; +@injectFromBase() @injectable() export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/converting-transformers/ObjectExpressionTransformer.ts b/src/node-transformers/converting-transformers/ObjectExpressionTransformer.ts index 828c60dd9..07ae38601 100644 --- a/src/node-transformers/converting-transformers/ObjectExpressionTransformer.ts +++ b/src/node-transformers/converting-transformers/ObjectExpressionTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -20,6 +20,7 @@ import { NodeGuards } from '../../node/NodeGuards'; * on: * var object = { 'PSEUDO': 1 }; */ +@injectFromBase() @injectable() export class ObjectExpressionTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/converting-transformers/ObjectPatternPropertiesTransformer.ts b/src/node-transformers/converting-transformers/ObjectPatternPropertiesTransformer.ts index 3b9b378f3..6122c0c15 100644 --- a/src/node-transformers/converting-transformers/ObjectPatternPropertiesTransformer.ts +++ b/src/node-transformers/converting-transformers/ObjectPatternPropertiesTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -16,6 +16,7 @@ import { NodeGuards } from '../../node/NodeGuards'; import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class ObjectPatternPropertiesTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/converting-transformers/SplitStringTransformer.ts b/src/node-transformers/converting-transformers/SplitStringTransformer.ts index 3ab4de010..fbe614a0a 100644 --- a/src/node-transformers/converting-transformers/SplitStringTransformer.ts +++ b/src/node-transformers/converting-transformers/SplitStringTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as estraverse from '@javascript-obfuscator/estraverse'; @@ -21,6 +21,7 @@ import { NodeUtils } from '../../node/NodeUtils'; /** * Splits strings into parts */ +@injectFromBase() @injectable() export class SplitStringTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/converting-transformers/TemplateLiteralTransformer.ts b/src/node-transformers/converting-transformers/TemplateLiteralTransformer.ts index 9de8392a2..422187f90 100644 --- a/src/node-transformers/converting-transformers/TemplateLiteralTransformer.ts +++ b/src/node-transformers/converting-transformers/TemplateLiteralTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -18,6 +18,7 @@ import { NodeUtils } from '../../node/NodeUtils'; * Transform ES2015 template literals to ES5 * Thanks to Babel for algorithm */ +@injectFromBase() @injectable() export class TemplateLiteralTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionIdentifiersTransformer.ts b/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionIdentifiersTransformer.ts index 04044b2ae..9f253f346 100644 --- a/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionIdentifiersTransformer.ts +++ b/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionIdentifiersTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as eslintScope from 'eslint-scope'; @@ -21,6 +21,7 @@ import { NodeGuards } from '../../node/NodeGuards'; /** * Renames all scope through identifiers for Dead Code Injection */ +@injectFromBase() @injectable() export class DeadCodeInjectionIdentifiersTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts b/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts index cb706d338..c73860022 100644 --- a/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts +++ b/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as estraverse from '@javascript-obfuscator/estraverse'; @@ -27,6 +27,7 @@ import { NodeMetadata } from '../../node/NodeMetadata'; import { NodeStatementUtils } from '../../node/NodeStatementUtils'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class DeadCodeInjectionTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/finalizing-transformers/DirectivePlacementTransformer.ts b/src/node-transformers/finalizing-transformers/DirectivePlacementTransformer.ts index 8d25c0f93..2ae60c7e5 100644 --- a/src/node-transformers/finalizing-transformers/DirectivePlacementTransformer.ts +++ b/src/node-transformers/finalizing-transformers/DirectivePlacementTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as estraverse from '@javascript-obfuscator/estraverse'; @@ -23,6 +23,7 @@ import { NodeUtils } from '../../node/NodeUtils'; * It's easier to fix "use strict"; placement after obfuscation as a separate stage * than ignore this directive in other transformers like control flow and dead code injection transformers */ +@injectFromBase() @injectable() export class DirectivePlacementTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/finalizing-transformers/EscapeSequenceTransformer.ts b/src/node-transformers/finalizing-transformers/EscapeSequenceTransformer.ts index 19dde7dfc..d4ffd593b 100644 --- a/src/node-transformers/finalizing-transformers/EscapeSequenceTransformer.ts +++ b/src/node-transformers/finalizing-transformers/EscapeSequenceTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -17,6 +17,7 @@ import { NodeLiteralUtils } from '../../node/NodeLiteralUtils'; import { NodeFactory } from '../../node/NodeFactory'; import { NodeUtils } from '../../node/NodeUtils'; +@injectFromBase() @injectable() export class EscapeSequenceTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/initializing-transformers/CommentsTransformer.ts b/src/node-transformers/initializing-transformers/CommentsTransformer.ts index d3877052e..4f0aca83a 100644 --- a/src/node-transformers/initializing-transformers/CommentsTransformer.ts +++ b/src/node-transformers/initializing-transformers/CommentsTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -14,6 +14,7 @@ import { AbstractNodeTransformer } from '../AbstractNodeTransformer'; import { ConditionalCommentObfuscatingGuard } from '../preparing-transformers/obfuscating-guards/ConditionalCommentObfuscatingGuard'; import { NodeGuards } from '../../node/NodeGuards'; +@injectFromBase() @injectable() export class CommentsTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/preparing-transformers/CustomCodeHelpersTransformer.ts b/src/node-transformers/preparing-transformers/CustomCodeHelpersTransformer.ts index b8cc19c42..436199356 100644 --- a/src/node-transformers/preparing-transformers/CustomCodeHelpersTransformer.ts +++ b/src/node-transformers/preparing-transformers/CustomCodeHelpersTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -23,6 +23,7 @@ import { NodeGuards } from '../../node/NodeGuards'; /** * Analyzing AST-tree and appending custom code helpers */ +@injectFromBase() @injectable() export class CustomCodeHelpersTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/preparing-transformers/EvalCallExpressionTransformer.ts b/src/node-transformers/preparing-transformers/EvalCallExpressionTransformer.ts index 137a4557c..c8576f0eb 100644 --- a/src/node-transformers/preparing-transformers/EvalCallExpressionTransformer.ts +++ b/src/node-transformers/preparing-transformers/EvalCallExpressionTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -17,6 +17,7 @@ import { NodeMetadata } from '../../node/NodeMetadata'; import { NodeUtils } from '../../node/NodeUtils'; import { StringUtils } from '../../utils/StringUtils'; +@injectFromBase() @injectable() export class EvalCallExpressionTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/preparing-transformers/MetadataTransformer.ts b/src/node-transformers/preparing-transformers/MetadataTransformer.ts index dd916c8b2..b74ccc037 100644 --- a/src/node-transformers/preparing-transformers/MetadataTransformer.ts +++ b/src/node-transformers/preparing-transformers/MetadataTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -17,6 +17,7 @@ import { NodeMetadata } from '../../node/NodeMetadata'; /** * Adds metadata properties to each node */ +@injectFromBase() @injectable() export class MetadataTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/preparing-transformers/ObfuscatingGuardsTransformer.ts b/src/node-transformers/preparing-transformers/ObfuscatingGuardsTransformer.ts index 8d10290c8..713210417 100644 --- a/src/node-transformers/preparing-transformers/ObfuscatingGuardsTransformer.ts +++ b/src/node-transformers/preparing-transformers/ObfuscatingGuardsTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -22,6 +22,7 @@ import { NodeMetadata } from '../../node/NodeMetadata'; /** * Adds `ignoredNode` properties to each node */ +@injectFromBase() @injectable() export class ObfuscatingGuardsTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/preparing-transformers/ParentificationTransformer.ts b/src/node-transformers/preparing-transformers/ParentificationTransformer.ts index 4e2f27608..bcdc872ac 100644 --- a/src/node-transformers/preparing-transformers/ParentificationTransformer.ts +++ b/src/node-transformers/preparing-transformers/ParentificationTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -15,6 +15,7 @@ import { NodeUtils } from '../../node/NodeUtils'; /** * Adds `parentNode` properties to each node */ +@injectFromBase() @injectable() export class ParentificationTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/preparing-transformers/VariablePreserveTransformer.ts b/src/node-transformers/preparing-transformers/VariablePreserveTransformer.ts index dc9326100..2d6f8b3a5 100644 --- a/src/node-transformers/preparing-transformers/VariablePreserveTransformer.ts +++ b/src/node-transformers/preparing-transformers/VariablePreserveTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import * as ESTree from 'estree'; import * as eslintScope from 'eslint-scope'; @@ -21,6 +21,7 @@ import { NodeGuards } from '../../node/NodeGuards'; /** * Preserve non-replaceable variables */ +@injectFromBase() @injectable() export class VariablePreserveTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/rename-identifiers-transformers/LabeledStatementTransformer.ts b/src/node-transformers/rename-identifiers-transformers/LabeledStatementTransformer.ts index b56ddbea3..5c3556ced 100644 --- a/src/node-transformers/rename-identifiers-transformers/LabeledStatementTransformer.ts +++ b/src/node-transformers/rename-identifiers-transformers/LabeledStatementTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as estraverse from '@javascript-obfuscator/estraverse'; @@ -33,6 +33,7 @@ import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils'; * } * */ +@injectFromBase() @injectable() export class LabeledStatementTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/rename-identifiers-transformers/ScopeIdentifiersTransformer.ts b/src/node-transformers/rename-identifiers-transformers/ScopeIdentifiersTransformer.ts index 028a51350..689d8ec0e 100644 --- a/src/node-transformers/rename-identifiers-transformers/ScopeIdentifiersTransformer.ts +++ b/src/node-transformers/rename-identifiers-transformers/ScopeIdentifiersTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as eslintScope from 'eslint-scope'; @@ -23,6 +23,7 @@ import { NodeMetadata } from '../../node/NodeMetadata'; /** * Replaces all replaceable identifiers in scope */ +@injectFromBase() @injectable() export class ScopeIdentifiersTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/rename-identifiers-transformers/ScopeThroughIdentifiersTransformer.ts b/src/node-transformers/rename-identifiers-transformers/ScopeThroughIdentifiersTransformer.ts index 242bcecdb..ff2c93d88 100644 --- a/src/node-transformers/rename-identifiers-transformers/ScopeThroughIdentifiersTransformer.ts +++ b/src/node-transformers/rename-identifiers-transformers/ScopeThroughIdentifiersTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as eslintScope from 'eslint-scope'; @@ -21,6 +21,7 @@ import { NodeGuards } from '../../node/NodeGuards'; /** * Renames all through identifiers */ +@injectFromBase() @injectable() export class ScopeThroughIdentifiersTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/rename-properties-transformers/RenamePropertiesTransformer.ts b/src/node-transformers/rename-properties-transformers/RenamePropertiesTransformer.ts index 4a0b45b68..7dc409628 100644 --- a/src/node-transformers/rename-properties-transformers/RenamePropertiesTransformer.ts +++ b/src/node-transformers/rename-properties-transformers/RenamePropertiesTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -16,6 +16,7 @@ import { NodeGuards } from '../../node/NodeGuards'; import { NodeLiteralUtils } from '../../node/NodeLiteralUtils'; import { NodeMetadata } from '../../node/NodeMetadata'; +@injectFromBase() @injectable() export class RenamePropertiesTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/simplifying-transformers/AbstractStatementSimplifyTransformer.ts b/src/node-transformers/simplifying-transformers/AbstractStatementSimplifyTransformer.ts index 9014aa3a5..c7d2b63a5 100644 --- a/src/node-transformers/simplifying-transformers/AbstractStatementSimplifyTransformer.ts +++ b/src/node-transformers/simplifying-transformers/AbstractStatementSimplifyTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -17,6 +17,7 @@ import { NodeFactory } from '../../node/NodeFactory'; /** * Simplifies `Statement` node */ +@injectFromBase() @injectable() export abstract class AbstractStatementSimplifyTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/simplifying-transformers/BlockStatementSimplifyTransformer.ts b/src/node-transformers/simplifying-transformers/BlockStatementSimplifyTransformer.ts index 010f9b5c9..14d139a11 100644 --- a/src/node-transformers/simplifying-transformers/BlockStatementSimplifyTransformer.ts +++ b/src/node-transformers/simplifying-transformers/BlockStatementSimplifyTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -19,6 +19,7 @@ import { NodeUtils } from '../../node/NodeUtils'; /** * Simplifies `BlockStatement` node */ +@injectFromBase() @injectable() export class BlockStatementSimplifyTransformer extends AbstractStatementSimplifyTransformer { /** diff --git a/src/node-transformers/simplifying-transformers/ExpressionStatementsMergeTransformer.ts b/src/node-transformers/simplifying-transformers/ExpressionStatementsMergeTransformer.ts index ef2dcf818..0ae976eaa 100644 --- a/src/node-transformers/simplifying-transformers/ExpressionStatementsMergeTransformer.ts +++ b/src/node-transformers/simplifying-transformers/ExpressionStatementsMergeTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as estraverse from '@javascript-obfuscator/estraverse'; @@ -26,6 +26,7 @@ import { NodeUtils } from '../../node/NodeUtils'; * on: * (console.log(1), console.log(2)); */ +@injectFromBase() @injectable() export class ExpressionStatementsMergeTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/simplifying-transformers/IfStatementSimplifyTransformer.ts b/src/node-transformers/simplifying-transformers/IfStatementSimplifyTransformer.ts index 7ff89e296..cde029aa3 100644 --- a/src/node-transformers/simplifying-transformers/IfStatementSimplifyTransformer.ts +++ b/src/node-transformers/simplifying-transformers/IfStatementSimplifyTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -18,6 +18,7 @@ import { NodeUtils } from '../../node/NodeUtils'; /** * Simplifies `IfStatement` node */ +@injectFromBase() @injectable() export class IfStatementSimplifyTransformer extends AbstractStatementSimplifyTransformer { /** diff --git a/src/node-transformers/simplifying-transformers/VariableDeclarationsMergeTransformer.ts b/src/node-transformers/simplifying-transformers/VariableDeclarationsMergeTransformer.ts index d89c5c03a..c9c9101cf 100644 --- a/src/node-transformers/simplifying-transformers/VariableDeclarationsMergeTransformer.ts +++ b/src/node-transformers/simplifying-transformers/VariableDeclarationsMergeTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as estraverse from '@javascript-obfuscator/estraverse'; @@ -25,6 +25,7 @@ import { NodeStatementUtils } from '../../node/NodeStatementUtils'; * var foo = 1, * bar = 2; */ +@injectFromBase() @injectable() export class VariableDeclarationsMergeTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/string-array-transformers/StringArrayRotateFunctionTransformer.ts b/src/node-transformers/string-array-transformers/StringArrayRotateFunctionTransformer.ts index 4788a9434..50b7c5d90 100644 --- a/src/node-transformers/string-array-transformers/StringArrayRotateFunctionTransformer.ts +++ b/src/node-transformers/string-array-transformers/StringArrayRotateFunctionTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as estraverse from '@javascript-obfuscator/estraverse'; @@ -33,6 +33,7 @@ import { NodeUtils } from '../../node/NodeUtils'; import { NumericalExpressionDataToNodeConverter } from '../../node/NumericalExpressionDataToNodeConverter'; import { StringArrayRotateFunctionCodeHelper } from '../../custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper'; +@injectFromBase() @injectable() export class StringArrayRotateFunctionTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/string-array-transformers/StringArrayScopeCallsWrapperTransformer.ts b/src/node-transformers/string-array-transformers/StringArrayScopeCallsWrapperTransformer.ts index 5aa19210a..513da4a26 100644 --- a/src/node-transformers/string-array-transformers/StringArrayScopeCallsWrapperTransformer.ts +++ b/src/node-transformers/string-array-transformers/StringArrayScopeCallsWrapperTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -30,6 +30,7 @@ import { NodeGuards } from '../../node/NodeGuards'; import { StringArrayScopeCallsWrapperFunctionNode } from '../../custom-nodes/string-array-nodes/StringArrayScopeCallsWrapperFunctionNode'; import { StringArrayScopeCallsWrapperVariableNode } from '../../custom-nodes/string-array-nodes/StringArrayScopeCallsWrapperVariableNode'; +@injectFromBase() @injectable() export class StringArrayScopeCallsWrapperTransformer extends AbstractNodeTransformer { /** diff --git a/src/node-transformers/string-array-transformers/StringArrayTransformer.ts b/src/node-transformers/string-array-transformers/StringArrayTransformer.ts index 6993f1f9c..dbc487fbc 100644 --- a/src/node-transformers/string-array-transformers/StringArrayTransformer.ts +++ b/src/node-transformers/string-array-transformers/StringArrayTransformer.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -36,6 +36,7 @@ import { NodeMetadata } from '../../node/NodeMetadata'; import { NodeUtils } from '../../node/NodeUtils'; import { StringArrayCallNode } from '../../custom-nodes/string-array-nodes/StringArrayCallNode'; +@injectFromBase() @injectable() export class StringArrayTransformer extends AbstractNodeTransformer { /** diff --git a/src/storages/control-flow-transformers/FunctionControlFlowStorage.ts b/src/storages/control-flow-transformers/FunctionControlFlowStorage.ts index 30b4b9c0e..30ea688c6 100644 --- a/src/storages/control-flow-transformers/FunctionControlFlowStorage.ts +++ b/src/storages/control-flow-transformers/FunctionControlFlowStorage.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -11,6 +11,7 @@ import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; import { MapStorage } from '../MapStorage'; +@injectFromBase() @injectable() export class FunctionControlFlowStorage extends MapStorage implements IControlFlowStorage { /** diff --git a/src/storages/control-flow-transformers/StringControlFlowStorage.ts b/src/storages/control-flow-transformers/StringControlFlowStorage.ts index 7288e7b22..148c6ee07 100644 --- a/src/storages/control-flow-transformers/StringControlFlowStorage.ts +++ b/src/storages/control-flow-transformers/StringControlFlowStorage.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -8,6 +8,7 @@ import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; import { FunctionControlFlowStorage } from './FunctionControlFlowStorage'; +@injectFromBase() @injectable() export class StringControlFlowStorage extends FunctionControlFlowStorage { /** diff --git a/src/storages/custom-code-helpers/CustomCodeHelperGroupStorage.ts b/src/storages/custom-code-helpers/CustomCodeHelperGroupStorage.ts index d43fa5aff..3e22750b4 100644 --- a/src/storages/custom-code-helpers/CustomCodeHelperGroupStorage.ts +++ b/src/storages/custom-code-helpers/CustomCodeHelperGroupStorage.ts @@ -1,4 +1,4 @@ -import { inject, injectable, postConstruct } from 'inversify'; +import { inject, injectable, injectFromBase, postConstruct } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TCustomCodeHelperGroupFactory } from '../../types/container/custom-code-helpers/TCustomCodeHelperGroupFactory'; @@ -11,6 +11,7 @@ import { CustomCodeHelperGroup } from '../../enums/custom-code-helpers/CustomCod import { MapStorage } from '../MapStorage'; +@injectFromBase() @injectable() export class CustomCodeHelperGroupStorage extends MapStorage { /** diff --git a/src/storages/identifier-names-cache/GlobalIdentifierNamesCacheStorage.ts b/src/storages/identifier-names-cache/GlobalIdentifierNamesCacheStorage.ts index 04fc83a13..f2115d299 100644 --- a/src/storages/identifier-names-cache/GlobalIdentifierNamesCacheStorage.ts +++ b/src/storages/identifier-names-cache/GlobalIdentifierNamesCacheStorage.ts @@ -1,4 +1,4 @@ -import { inject, injectable, postConstruct } from 'inversify'; +import { inject, injectable, injectFromBase, postConstruct } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { IGlobalIdentifierNamesCacheStorage } from '../../interfaces/storages/identifier-names-cache/IGlobalIdentifierNamesCacheStorage'; @@ -7,6 +7,7 @@ import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; import { MapStorage } from '../MapStorage'; +@injectFromBase() @injectable() export class GlobalIdentifierNamesCacheStorage extends MapStorage diff --git a/src/storages/identifier-names-cache/PropertyIdentifierNamesCacheStorage.ts b/src/storages/identifier-names-cache/PropertyIdentifierNamesCacheStorage.ts index de7015281..4de03cce3 100644 --- a/src/storages/identifier-names-cache/PropertyIdentifierNamesCacheStorage.ts +++ b/src/storages/identifier-names-cache/PropertyIdentifierNamesCacheStorage.ts @@ -1,4 +1,4 @@ -import { inject, injectable, postConstruct } from 'inversify'; +import { inject, injectable, injectFromBase, postConstruct } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -7,6 +7,7 @@ import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; import { MapStorage } from '../MapStorage'; +@injectFromBase() @injectable() export class PropertyIdentifierNamesCacheStorage extends MapStorage diff --git a/src/storages/string-array-transformers/LiteralNodesCacheStorage.ts b/src/storages/string-array-transformers/LiteralNodesCacheStorage.ts index 1df62350e..31d3e3c6e 100644 --- a/src/storages/string-array-transformers/LiteralNodesCacheStorage.ts +++ b/src/storages/string-array-transformers/LiteralNodesCacheStorage.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; @@ -12,6 +12,7 @@ import { StringArrayEncoding } from '../../enums/node-transformers/string-array- import { MapStorage } from '../MapStorage'; +@injectFromBase() @injectable() export class LiteralNodesCacheStorage extends MapStorage implements ILiteralNodesCacheStorage { /** diff --git a/src/storages/string-array-transformers/StringArrayScopeCallsWrappersDataStorage.ts b/src/storages/string-array-transformers/StringArrayScopeCallsWrappersDataStorage.ts index 11d15a671..9d933bf3e 100644 --- a/src/storages/string-array-transformers/StringArrayScopeCallsWrappersDataStorage.ts +++ b/src/storages/string-array-transformers/StringArrayScopeCallsWrappersDataStorage.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TNodeWithLexicalScopeStatements } from '../../types/node/TNodeWithLexicalScopeStatements'; @@ -10,6 +10,7 @@ import { IStringArrayScopeCallsWrappersDataStorage } from '../../interfaces/stor import { WeakMapStorage } from '../WeakMapStorage'; +@injectFromBase() @injectable() export class StringArrayScopeCallsWrappersDataStorage extends WeakMapStorage diff --git a/src/storages/string-array-transformers/StringArrayStorage.ts b/src/storages/string-array-transformers/StringArrayStorage.ts index d58c8586d..7bf7bde79 100644 --- a/src/storages/string-array-transformers/StringArrayStorage.ts +++ b/src/storages/string-array-transformers/StringArrayStorage.ts @@ -1,4 +1,4 @@ -import { inject, injectable, postConstruct } from 'inversify'; +import { inject, injectable, injectFromBase, postConstruct } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; @@ -17,6 +17,7 @@ import { StringArrayEncoding } from '../../enums/node-transformers/string-array- import { MapStorage } from '../MapStorage'; +@injectFromBase() @injectable() export class StringArrayStorage extends MapStorage<`${string}-${TStringArrayEncoding}`, IStringArrayStorageItemData> diff --git a/src/storages/string-array-transformers/VisitedLexicalScopeNodesStackStorage.ts b/src/storages/string-array-transformers/VisitedLexicalScopeNodesStackStorage.ts index cbc72fd3e..16a8779f6 100644 --- a/src/storages/string-array-transformers/VisitedLexicalScopeNodesStackStorage.ts +++ b/src/storages/string-array-transformers/VisitedLexicalScopeNodesStackStorage.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TNodeWithLexicalScopeStatements } from '../../types/node/TNodeWithLexicalScopeStatements'; @@ -10,6 +10,7 @@ import { IVisitedLexicalScopeNodesStackStorage } from '../../interfaces/storages import { ArrayStorage } from '../ArrayStorage'; +@injectFromBase() @injectable() export class VisitedLexicalScopeNodesStackStorage extends ArrayStorage diff --git a/src/utils/CryptUtilsStringArray.ts b/src/utils/CryptUtilsStringArray.ts index b51049274..f704d4036 100644 --- a/src/utils/CryptUtilsStringArray.ts +++ b/src/utils/CryptUtilsStringArray.ts @@ -1,4 +1,4 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, injectFromBase } from 'inversify'; import { ServiceIdentifiers } from '../container/ServiceIdentifiers'; import { ICryptUtilsStringArray } from '../interfaces/utils/ICryptUtilsStringArray'; @@ -8,6 +8,7 @@ import { base64alphabetSwapped } from '../constants/Base64AlphabetSwapped'; import { CryptUtils } from './CryptUtils'; +@injectFromBase() @injectable() export class CryptUtilsStringArray extends CryptUtils implements ICryptUtilsStringArray { /** diff --git a/test/functional-tests/custom-code-helpers/string-array/templates/string-array-calls-wrapper-node-template/StringArrayCallsWrapperTemplate.spec.ts b/test/functional-tests/custom-code-helpers/string-array/templates/string-array-calls-wrapper-node-template/StringArrayCallsWrapperTemplate.spec.ts index 68a393509..393fd2e71 100644 --- a/test/functional-tests/custom-code-helpers/string-array/templates/string-array-calls-wrapper-node-template/StringArrayCallsWrapperTemplate.spec.ts +++ b/test/functional-tests/custom-code-helpers/string-array/templates/string-array-calls-wrapper-node-template/StringArrayCallsWrapperTemplate.spec.ts @@ -332,9 +332,9 @@ describe('StringArrayCallsWrapperTemplate', () => { decodedValue = Function(` ${stringArrayTemplate} - + ${stringArrayCallsWrapperTemplate} - + return ${stringArrayCallsWrapperName}(${index}); `)(); }); @@ -379,9 +379,9 @@ describe('StringArrayCallsWrapperTemplate', () => { decodedValue = Function(` ${stringArrayTemplate} - + ${stringArrayCallsWrapperTemplate} - + return ${stringArrayCallsWrapperName}(${index}); `)(); }); @@ -391,6 +391,118 @@ describe('StringArrayCallsWrapperTemplate', () => { }); }); }); + + describe('Variant #3: correct code evaluation when engine reformats Function.prototype.toString', () => { + const origToString = Function.prototype.toString; + + afterEach(() => { + Function.prototype.toString = origToString; + }); + + describe('Variant #1: long decoded string', () => { + const index: string = '0x0'; + + const indexShiftAmount: number = 0; + + const expectedDecodedValue: string = 'test1test1'; + + let decodedValue: string; + + before(() => { + const stringArrayTemplate = format(StringArrayTemplate(), { + stringArrayName, + stringArrayFunctionName, + stringArrayStorageItems: `'${cryptUtilsSwappedAlphabet.btoa('test1test1')}'` + }); + const atobPolyfill = format(AtobTemplate(selfDefendingEnabled), { + atobFunctionName + }); + const atobDecodeTemplate: string = format(StringArrayBase64DecodeTemplate(randomGenerator), { + atobPolyfill, + atobFunctionName, + selfDefendingCode: '', + stringArrayCacheName, + stringArrayCallsWrapperName + }); + const stringArrayCallsWrapperTemplate: string = format(StringArrayCallsWrapperTemplate(), { + decodeCodeHelperTemplate: atobDecodeTemplate, + indexShiftAmount, + stringArrayCacheName, + stringArrayCallsWrapperName, + stringArrayFunctionName + }); + + // Simulate Bun/JSC: Function.prototype.toString adds newlines + Function.prototype.toString = function () { + return origToString.call(this).replace('){', '){\n'); + }; + + decodedValue = Function(` + ${stringArrayTemplate} + + ${stringArrayCallsWrapperTemplate} + + return ${stringArrayCallsWrapperName}(${index}); + `)(); + }); + + it('should correctly return decoded value when engine reformats toString', () => { + assert.deepEqual(decodedValue, expectedDecodedValue); + }); + }); + + describe('Variant #2: 3-characters decoded string', () => { + const index: string = '0x0'; + + const indexShiftAmount: number = 0; + + const expectedDecodedValue: string = 'foo'; + + let decodedValue: string; + + before(() => { + const stringArrayTemplate = format(StringArrayTemplate(), { + stringArrayName, + stringArrayFunctionName, + stringArrayStorageItems: `'${cryptUtilsSwappedAlphabet.btoa('foo')}'` + }); + const atobPolyfill = format(AtobTemplate(selfDefendingEnabled), { + atobFunctionName + }); + const atobDecodeTemplate: string = format(StringArrayBase64DecodeTemplate(randomGenerator), { + atobPolyfill, + atobFunctionName, + selfDefendingCode: '', + stringArrayCacheName, + stringArrayCallsWrapperName + }); + const stringArrayCallsWrapperTemplate: string = format(StringArrayCallsWrapperTemplate(), { + decodeCodeHelperTemplate: atobDecodeTemplate, + indexShiftAmount, + stringArrayCacheName, + stringArrayCallsWrapperName, + stringArrayFunctionName + }); + + // Simulate Bun/JSC: Function.prototype.toString adds newlines + Function.prototype.toString = function () { + return origToString.call(this).replace('){', '){\n'); + }; + + decodedValue = Function(` + ${stringArrayTemplate} + + ${stringArrayCallsWrapperTemplate} + + return ${stringArrayCallsWrapperName}(${index}); + `)(); + }); + + it('should correctly return decoded value when engine reformats toString', () => { + assert.deepEqual(decodedValue, expectedDecodedValue); + }); + }); + }); }); }); diff --git a/yarn.lock b/yarn.lock index 0d919ff1b..832bb6048 100644 --- a/yarn.lock +++ b/yarn.lock @@ -260,23 +260,46 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz#4a2868d75d6d6963e423bcf90b7fd1be343409d3" integrity sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA== -"@inversifyjs/common@1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@inversifyjs/common/-/common-1.3.3.tgz#c34bba10be8c511bf3cd25473bd32c2a08987111" - integrity sha512-ZH0wrgaJwIo3s9gMCDM2wZoxqrJ6gB97jWXncROfYdqZJv8f3EkqT57faZqN5OTeHWgtziQ6F6g3L8rCvGceCw== +"@inversifyjs/common@1.5.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@inversifyjs/common/-/common-1.5.2.tgz#6836287fef1c25dddbdf6af345a33a6d6caf6835" + integrity sha512-WlzR9xGadABS9gtgZQ+luoZ8V6qm4Ii6RQfcfC9Ho2SOlE6ZuemFo7PKJvKI0ikm8cmKbU8hw5UK6E4qovH21w== + +"@inversifyjs/container@1.15.0": + version "1.15.0" + resolved "https://registry.yarnpkg.com/@inversifyjs/container/-/container-1.15.0.tgz#e92e2a881f5300f373a855fd74aa8280dc863825" + integrity sha512-U2xYsPrJTz5za2TExi5lg8qOWf8TEVBpN+pQM7B8BVA2rajtbRE9A66SLRHk8c1eGXmg+0K4Hdki6tWAsSQBUA== + dependencies: + "@inversifyjs/common" "1.5.2" + "@inversifyjs/core" "9.2.0" + "@inversifyjs/plugin" "0.2.0" + "@inversifyjs/reflect-metadata-utils" "1.4.1" + +"@inversifyjs/core@9.2.0": + version "9.2.0" + resolved "https://registry.yarnpkg.com/@inversifyjs/core/-/core-9.2.0.tgz#f587ccb917c82698ac0f9ceb2a544af42acff36f" + integrity sha512-Nm7BR6KmpgshIHpVQWuEDehqRVb6GBm8LFEuhc2s4kSZWrArZ15RmXQzROLk4m+hkj4kMXgvMm5Qbopot/D6Sg== + dependencies: + "@inversifyjs/common" "1.5.2" + "@inversifyjs/prototype-utils" "0.1.3" + "@inversifyjs/reflect-metadata-utils" "1.4.1" + +"@inversifyjs/plugin@0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@inversifyjs/plugin/-/plugin-0.2.0.tgz#03957c7d02803f32254a2ff2f8f8ffb05ec57eec" + integrity sha512-R/JAdkTSD819pV1zi0HP54mWHyX+H2m8SxldXRgPQarS3ySV4KPyRdosWcfB8Se0JJZWZLHYiUNiS6JvMWSPjw== -"@inversifyjs/core@1.3.4": - version "1.3.4" - resolved "https://registry.yarnpkg.com/@inversifyjs/core/-/core-1.3.4.tgz#17d2614ff48fc6e0db20c2fe3258c3d5bef9b5e0" - integrity sha512-gCCmA4BdbHEFwvVZ2elWgHuXZWk6AOu/1frxsS+2fWhjEk2c/IhtypLo5ytSUie1BCiT6i9qnEo4bruBomQsAA== +"@inversifyjs/prototype-utils@0.1.3": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@inversifyjs/prototype-utils/-/prototype-utils-0.1.3.tgz#c720e7d2d847e4748534c5986b25e271186898d2" + integrity sha512-EzRamZzNgE9Sn3QtZ8NncNa2lpPMZfspqbK6BWFguWnOpK8ymp2TUuH46ruFHZhrHKnknPd7fG22ZV7iF517TQ== dependencies: - "@inversifyjs/common" "1.3.3" - "@inversifyjs/reflect-metadata-utils" "0.2.3" + "@inversifyjs/common" "1.5.2" -"@inversifyjs/reflect-metadata-utils@0.2.3": - version "0.2.3" - resolved "https://registry.yarnpkg.com/@inversifyjs/reflect-metadata-utils/-/reflect-metadata-utils-0.2.3.tgz#b17359fd4fdfc85726d3b1af7ad3647136950ea0" - integrity sha512-d3D0o9TeSlvaGM2I24wcNw/Aj3rc4OYvHXOKDC09YEph5fMMiKd6fq1VTQd9tOkDNWvVbw+cnt45Wy9P/t5Lvw== +"@inversifyjs/reflect-metadata-utils@1.4.1": + version "1.4.1" + resolved "https://registry.yarnpkg.com/@inversifyjs/reflect-metadata-utils/-/reflect-metadata-utils-1.4.1.tgz#6219df487e6aab1810a0feee4a625a0e11397340" + integrity sha512-Cp77C4d2wLaHXiUB7iH6Cxb7i1lD/YDuTIHLTDzKINqGSz0DCSoL/Dg2wVkW/6Qx03r/yQMLJ+32Agl32N2X8g== "@isaacs/balanced-match@^4.0.1": version "4.0.1" @@ -3042,13 +3065,14 @@ interpret@^3.1.1: resolved "https://registry.yarnpkg.com/interpret/-/interpret-3.1.1.tgz#5be0ceed67ca79c6c4bc5cf0d7ee843dcea110c4" integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ== -inversify@6.1.4: - version "6.1.4" - resolved "https://registry.yarnpkg.com/inversify/-/inversify-6.1.4.tgz#7dc288b190bc6c0e2081d7a003cbf6c4f94d946f" - integrity sha512-PbxrZH/gTa1fpPEEGAjJQzK8tKMIp5gRg6EFNJlCtzUcycuNdmhv3uk5P8Itm/RIjgHJO16oQRLo9IHzQN51bA== +inversify@7.11.0: + version "7.11.0" + resolved "https://registry.yarnpkg.com/inversify/-/inversify-7.11.0.tgz#571cede6346081b5af224eaea49bb97a91268f92" + integrity sha512-yZDprSSr8TyVeMGI/AOV4ws6gwjX22hj9Z8/oHAVpJORY6WRFTcUzhnZtibBUHEw2U8ArvHcR+i863DplQ3Cwg== dependencies: - "@inversifyjs/common" "1.3.3" - "@inversifyjs/core" "1.3.4" + "@inversifyjs/common" "1.5.2" + "@inversifyjs/container" "1.15.0" + "@inversifyjs/core" "9.2.0" is-arguments@^1.0.4: version "1.0.4" @@ -4921,8 +4945,7 @@ string-template@1.0.0: resolved "https://registry.npmjs.org/string-template/-/string-template-1.0.0.tgz" integrity sha1-np8iM9wA8hhxjsN5oopWc+zKi5Y= -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.2.3: - name string-width-cjs +"string-width-cjs@npm:string-width@^4.2.0": version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -4940,6 +4963,15 @@ string-width@^4.1.0, string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" +string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^5.0.1, string-width@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" @@ -5020,7 +5052,7 @@ stringz@2.1.0: dependencies: char-regex "^1.0.2" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -5034,6 +5066,13 @@ strip-ansi@^6.0.0: dependencies: ansi-regex "^5.0.0" +strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^7.0.1: version "7.1.2" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.2.tgz#132875abde678c7ea8d691533f2e7e22bb744dba"