Merge pull request #1014 from javascript-obfuscator/dependencies-update-19.10.21

Dependencies update
This commit is contained in:
Timofey Kachalov
2021-10-19 19:51:43 +03:00
committed by GitHub
21 changed files with 44 additions and 39 deletions
+1 -1
View File
@@ -32,7 +32,7 @@
"commander": "8.2.0",
"eslint-scope": "6.0.0",
"fast-deep-equal": "3.1.3",
"inversify": "5.1.1",
"inversify": "6.0.1",
"js-string-escape": "1.0.1",
"md5": "2.3.0",
"mkdirp": "1.0.4",
@@ -29,7 +29,7 @@ export abstract class AbstractCodeTransformer implements ICodeTransformer {
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
protected constructor (
public constructor (
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
+12 -11
View File
@@ -22,6 +22,7 @@ import { storagesModule } from './modules/storages/StoragesModule';
import { stringArrayTransformersModule } from './modules/node-transformers/StringArrayTransformersModule';
import { utilsModule } from './modules/utils/UtilsModule';
import { TConstructor } from '../types/TConstructor';
import { TInputOptions } from '../types/options/TInputOptions';
import { ICodeTransformersRunner } from '../interfaces/code-transformers/ICodeTransformersRunner';
@@ -88,21 +89,21 @@ export class InversifyContainerFacade implements IInversifyContainerFacade {
}
/**
* @param {interfaces.ServiceIdentifier<interfaces.Newable<U>>} serviceIdentifier
* @param {interfaces.ServiceIdentifier<interfaces.Newable<Object>>[]} dependencies
* @returns {U}
* @param {interfaces.ServiceIdentifier<TConstructor<Record<string, any>[], U>>} serviceIdentifier
* @param {interfaces.ServiceIdentifier<TConstructor<Record<string, any>[], U>>} dependencies
* @returns {(context: interfaces.Context) => (bindingName: T) => U}
*/
public static getConstructorFactory <T extends string, U> (
serviceIdentifier: interfaces.ServiceIdentifier<interfaces.Newable<U>>,
...dependencies: interfaces.ServiceIdentifier<interfaces.Newable<Record<string, any>>>[]
serviceIdentifier: interfaces.ServiceIdentifier<TConstructor<Record<string, any>[], U>>,
...dependencies: interfaces.ServiceIdentifier<TConstructor<Record<string, any>[], U>>[]
): (context: interfaces.Context) => (bindingName: T) => U {
return (context: interfaces.Context): (bindingName: T) => U => {
const cache: Map<T, interfaces.Newable<U>> = new Map();
const cache: Map<T, TConstructor<Record<string, any>[], U>> = new Map();
const cachedDependencies: Record<string, any>[] = [];
return (bindingName: T): U => {
dependencies.forEach((
dependency: interfaces.ServiceIdentifier<interfaces.Newable<Record<string, any>>>,
dependency: interfaces.ServiceIdentifier<TConstructor<Record<string, any>[], U>>,
index: number
) => {
if (!cachedDependencies[index]) {
@@ -111,11 +112,11 @@ export class InversifyContainerFacade implements IInversifyContainerFacade {
});
if (cache.has(bindingName)) {
return new (<interfaces.Newable<U>>cache.get(bindingName))(...cachedDependencies);
return new (<TConstructor<Record<string, any>[], U>>cache.get(bindingName))(...cachedDependencies);
}
const constructor: interfaces.Newable<U> = context.container
.getNamed<interfaces.Newable<U>>(
const constructor = context.container
.getNamed<TConstructor<Record<string, any>[], U>>(
serviceIdentifier,
bindingName
);
@@ -186,7 +187,7 @@ export class InversifyContainerFacade implements IInversifyContainerFacade {
this.container
.bind<IObfuscationResult>(ServiceIdentifiers.Factory__IObfuscationResult)
.toFactory<IObfuscationResult>((context: interfaces.Context) => {
.toFactory<IObfuscationResult, [string, string]>((context: interfaces.Context) => {
return (obfuscatedCodeAsString: string, sourceMapAsString: string): IObfuscationResult => {
const obfuscationResult: IObfuscationResult = context.container
.get<IObfuscationResult>(ServiceIdentifiers.IObfuscationResult);
@@ -60,7 +60,7 @@ export const analyzersModule: interfaces.ContainerModule = new ContainerModule((
// callee data extractor factory
bind<ICalleeDataExtractor>(ServiceIdentifiers.Factory__ICalleeDataExtractor)
.toFactory<ICalleeDataExtractor>(InversifyContainerFacade
.toFactory<ICalleeDataExtractor, [CalleeDataExtractor]>(InversifyContainerFacade
.getCacheFactory<CalleeDataExtractor, ICalleeDataExtractor>(
ServiceIdentifiers.ICalleeDataExtractor
));
@@ -13,7 +13,7 @@ import { HashbangOperatorTransformer } from '../../../code-transformers/preparin
export const codeTransformersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
// code transformers factory
bind<ICodeTransformer>(ServiceIdentifiers.Factory__ICodeTransformer)
.toFactory<ICodeTransformer>(InversifyContainerFacade
.toFactory<ICodeTransformer, [CodeTransformer]>(InversifyContainerFacade
.getCacheFactory<CodeTransformer, ICodeTransformer>(ServiceIdentifiers.ICodeTransformer));
// code transformer names groups builder
@@ -104,12 +104,12 @@ export const customCodeHelpersModule: interfaces.ContainerModule = new Container
// customCodeHelper factory
bind<ICustomCodeHelper>(ServiceIdentifiers.Factory__ICustomCodeHelper)
.toFactory<ICustomCodeHelper>(InversifyContainerFacade
.toFactory<ICustomCodeHelper, [CustomCodeHelper]>(InversifyContainerFacade
.getFactory<CustomCodeHelper, ICustomCodeHelper>(ServiceIdentifiers.ICustomCodeHelper));
// customCodeHelperGroup factory
bind<ICustomCodeHelperGroup>(ServiceIdentifiers.Factory__ICustomCodeHelperGroup)
.toFactory<ICustomCodeHelperGroup>(InversifyContainerFacade
.toFactory<ICustomCodeHelperGroup, [CustomCodeHelperGroup]>(InversifyContainerFacade
.getFactory<CustomCodeHelperGroup, ICustomCodeHelperGroup>(ServiceIdentifiers.ICustomCodeHelperGroup));
// custom code helper formatter
@@ -102,7 +102,7 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
// control flow customNode constructor factory
bind<ICustomNode>(ServiceIdentifiers.Factory__IControlFlowCustomNode)
.toFactory<ICustomNode>(InversifyContainerFacade
.toFactory<ICustomNode, [ControlFlowCustomNode]>(InversifyContainerFacade
.getConstructorFactory<ControlFlowCustomNode, ICustomNode>(
ServiceIdentifiers.Newable__ICustomNode,
ServiceIdentifiers.Factory__IIdentifierNamesGenerator,
@@ -113,7 +113,7 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
// dead code injection customNode constructor factory
bind<ICustomNode>(ServiceIdentifiers.Factory__IDeadCodeInjectionCustomNode)
.toFactory<ICustomNode>(InversifyContainerFacade
.toFactory<ICustomNode, [DeadCodeInjectionCustomNode]>(InversifyContainerFacade
.getConstructorFactory<DeadCodeInjectionCustomNode, ICustomNode>(
ServiceIdentifiers.Newable__ICustomNode,
ServiceIdentifiers.Factory__IIdentifierNamesGenerator,
@@ -124,7 +124,7 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
// object expression keys transformer customNode constructor factory
bind<ICustomNode>(ServiceIdentifiers.Factory__IObjectExpressionKeysTransformerCustomNode)
.toFactory<ICustomNode>(InversifyContainerFacade
.toFactory<ICustomNode, [ObjectExpressionKeysTransformerCustomNode]>(InversifyContainerFacade
.getConstructorFactory<ObjectExpressionKeysTransformerCustomNode, ICustomNode>(
ServiceIdentifiers.Newable__ICustomNode,
ServiceIdentifiers.Factory__IIdentifierNamesGenerator,
@@ -135,7 +135,7 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
// string array customNode constructor factory
bind<ICustomNode>(ServiceIdentifiers.Factory__IStringArrayCustomNode)
.toFactory<ICustomNode>(InversifyContainerFacade
.toFactory<ICustomNode, [StringArrayCustomNode]>(InversifyContainerFacade
.getConstructorFactory<StringArrayCustomNode, ICustomNode>(
ServiceIdentifiers.Newable__ICustomNode,
ServiceIdentifiers.Factory__IIdentifierNamesGenerator,
@@ -149,6 +149,6 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
// string array index node factory
bind<IStringArrayIndexNode>(ServiceIdentifiers.Factory__IStringArrayIndexNode)
.toFactory<IStringArrayIndexNode>(InversifyContainerFacade
.toFactory<IStringArrayIndexNode, [StringArrayIndexNode]>(InversifyContainerFacade
.getCacheFactory<StringArrayIndexNode, IStringArrayIndexNode>(ServiceIdentifiers.IStringArrayIndexNode));
});
@@ -83,5 +83,5 @@ export const generatorsModule: interfaces.ContainerModule = new ContainerModule(
};
}
bind<IIdentifierNamesGenerator>(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
.toFactory<IIdentifierNamesGenerator>(identifierNameGeneratorFactory());
.toFactory<IIdentifierNamesGenerator, [IOptions]>(identifierNameGeneratorFactory());
});
@@ -44,6 +44,6 @@ export const controlFlowTransformersModule: interfaces.ContainerModule = new Con
// control flow replacer factory
bind<IControlFlowReplacer>(ServiceIdentifiers.Factory__IControlFlowReplacer)
.toFactory<IControlFlowReplacer>(InversifyContainerFacade
.toFactory<IControlFlowReplacer, [ControlFlowReplacer]>(InversifyContainerFacade
.getCacheFactory<ControlFlowReplacer, IControlFlowReplacer>(ServiceIdentifiers.IControlFlowReplacer));
});
@@ -79,7 +79,7 @@ export const convertingTransformersModule: interfaces.ContainerModule = new Cont
// object expression extractor factory
bind<IObjectExpressionExtractor>(ServiceIdentifiers.Factory__IObjectExpressionExtractor)
.toFactory<IObjectExpressionExtractor>(InversifyContainerFacade
.toFactory<IObjectExpressionExtractor, [ObjectExpressionExtractor]>(InversifyContainerFacade
.getCacheFactory<ObjectExpressionExtractor, IObjectExpressionExtractor>(
ServiceIdentifiers.IObjectExpressionExtractor
));
@@ -12,7 +12,7 @@ import { NodeTransformerNamesGroupsBuilder } from '../../../node-transformers/No
export const nodeTransformersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
// node transformers factory
bind<INodeTransformer>(ServiceIdentifiers.Factory__INodeTransformer)
.toFactory<INodeTransformer>(InversifyContainerFacade
.toFactory<INodeTransformer, [NodeTransformer]>(InversifyContainerFacade
.getCacheFactory<NodeTransformer, INodeTransformer>(ServiceIdentifiers.INodeTransformer));
// node transformer names groups builder
@@ -74,7 +74,7 @@ export const preparingTransformersModule: interfaces.ContainerModule = new Conta
// obfuscating guards factory
bind<IObfuscatingGuard>(ServiceIdentifiers.Factory__INodeGuard)
.toFactory<IObfuscatingGuard>(InversifyContainerFacade
.toFactory<IObfuscatingGuard, [ObfuscatingGuard]>(InversifyContainerFacade
.getCacheFactory<ObfuscatingGuard, IObfuscatingGuard>(
ServiceIdentifiers.INodeGuard
));
@@ -2,6 +2,7 @@ import { ContainerModule, interfaces } from 'inversify';
import { ServiceIdentifiers } from '../../ServiceIdentifiers';
import { TControlFlowStorage } from '../../../types/storages/TControlFlowStorage';
import { TConstructor } from '../../../types/TConstructor';
import { TCustomCodeHelperGroupStorage } from '../../../types/storages/TCustomCodeHelperGroupStorage';
import { IGlobalIdentifierNamesCacheStorage } from '../../../interfaces/storages/identifier-names-cache/IGlobalIdentifierNamesCacheStorage';
@@ -59,8 +60,10 @@ export const storagesModule: interfaces.ContainerModule = new ContainerModule((b
bind<TControlFlowStorage>(ServiceIdentifiers.Factory__TControlFlowStorage)
.toFactory<TControlFlowStorage>((context: interfaces.Context) => {
return (): TControlFlowStorage => {
const constructor: interfaces.Newable<TControlFlowStorage> = context.container
.get<interfaces.Newable<TControlFlowStorage>>(ServiceIdentifiers.Newable__TControlFlowStorage);
const constructor = context.container
.get<TConstructor<[IRandomGenerator, IOptions], TControlFlowStorage>>(
ServiceIdentifiers.Newable__TControlFlowStorage
);
const randomGenerator: IRandomGenerator = context.container
.get<IRandomGenerator>(ServiceIdentifiers.IRandomGenerator);
const options: IOptions = context.container
@@ -63,7 +63,7 @@ export abstract class AbstractCustomCodeHelper <
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
protected constructor (
public constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
+1 -1
View File
@@ -45,7 +45,7 @@ export abstract class AbstractCustomNode <
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
protected constructor (
public constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.ICustomCodeHelperFormatter) customCodeHelperFormatter: ICustomCodeHelperFormatter,
@@ -62,7 +62,7 @@ export abstract class AbstractStringArrayCallNode extends AbstractCustomNode {
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
protected constructor (
public constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IStringArrayIndexNode)
@@ -24,7 +24,7 @@ export abstract class AbstractStringArrayIndexNode implements IStringArrayIndexN
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
protected constructor (
public constructor (
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
@@ -31,7 +31,7 @@ export abstract class AbstractStatementSimplifyTransformer extends AbstractNodeT
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
protected constructor (
public constructor (
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
+1 -1
View File
@@ -40,7 +40,7 @@ export abstract class ArrayStorage <V> implements IArrayStorage <V> {
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
protected constructor (
public constructor (
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
+1
View File
@@ -0,0 +1 @@
export type TConstructor<TArgs extends any[], TInstanceType> = new (...args: TArgs) => TInstanceType;
+4 -4
View File
@@ -2683,10 +2683,10 @@ interpret@^2.2.0:
resolved "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz"
integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==
inversify@5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/inversify/-/inversify-5.1.1.tgz#6fbd668c591337404e005a1946bfe0d802c08730"
integrity sha512-j8grHGDzv1v+8T1sAQ+3boTCntFPfvxLCkNcxB1J8qA0lUN+fAlSyYd+RXKvaPRL4AGyPxViutBEJHNXOyUdFQ==
inversify@6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/inversify/-/inversify-6.0.1.tgz#b20d35425d5d8c5cd156120237aad0008d969f02"
integrity sha512-B3ex30927698TJENHR++8FfEaJGqoWOgI6ZY5Ht/nLUsFCwHn6akbwtnUAPCgUepAnTpe2qHxhDNjoKLyz6rgQ==
is-arguments@^1.0.4:
version "1.0.4"