mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
refactoring
This commit is contained in:
Vendored
+154
-167
@@ -112,37 +112,31 @@ module.exports = require("tslib");
|
||||
"use strict";
|
||||
|
||||
|
||||
var _symbol = __webpack_require__(137);
|
||||
|
||||
var _symbol2 = _interopRequireDefault(_symbol);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.ServiceIdentifiers = {
|
||||
Factory__ICalleeDataExtractor: (0, _symbol2.default)('Factory<ICalleeDataExtractor>'),
|
||||
Factory__IControlFlowReplacer: (0, _symbol2.default)('Factory<IControlFlowReplacer>'),
|
||||
Factory__ICustomNode: (0, _symbol2.default)('Factory<ICustomNode>'),
|
||||
Factory__ICustomNodeGroup: (0, _symbol2.default)('Factory<ICustomNodeGroup>'),
|
||||
Factory__INodeTransformer: (0, _symbol2.default)('Factory<INodeTransformer[]>'),
|
||||
Factory__IObfuscationResult: (0, _symbol2.default)('Factory<IObfuscationResult>'),
|
||||
Factory__IObfuscatorReplacer: (0, _symbol2.default)('Factory<IObfuscationReplacer>'),
|
||||
Factory__TControlFlowStorage: (0, _symbol2.default)('Factory<TControlFlowStorage>'),
|
||||
ICalleeDataExtractor: (0, _symbol2.default)('ICalleeDataExtractor'),
|
||||
ICustomNodeGroup: (0, _symbol2.default)('ICustomNodeGroup'),
|
||||
IControlFlowReplacer: (0, _symbol2.default)('IControlFlowReplacer'),
|
||||
IJavaScriptObfuscator: (0, _symbol2.default)('IJavaScriptObfuscator'),
|
||||
INodeTransformer: (0, _symbol2.default)('INodeTransformer'),
|
||||
IObfuscationEventEmitter: (0, _symbol2.default)('IObfuscationEventEmitter'),
|
||||
IObfuscationResult: (0, _symbol2.default)('IObfuscationResult'),
|
||||
IObfuscator: (0, _symbol2.default)('IObfuscator'),
|
||||
IOptions: (0, _symbol2.default)('IOptions'),
|
||||
IObfuscatorReplacer: (0, _symbol2.default)('IObfuscationReplacer'),
|
||||
ISourceMapCorrector: (0, _symbol2.default)('ISourceMapCorrector'),
|
||||
IStackTraceAnalyzer: (0, _symbol2.default)('IStackTraceAnalyzer'),
|
||||
Newable__ICustomNode: (0, _symbol2.default)('Newable<ICustomNode>'),
|
||||
Newable__TControlFlowStorage: (0, _symbol2.default)('Newable<TControlFlowStorage>'),
|
||||
TCustomNodeGroupStorage: (0, _symbol2.default)('TCustomNodeGroupStorage'),
|
||||
TStringArrayStorage: (0, _symbol2.default)('TStringArrayStorage')
|
||||
Factory__ICalleeDataExtractor: Symbol('Factory<ICalleeDataExtractor>'),
|
||||
Factory__IControlFlowReplacer: Symbol('Factory<IControlFlowReplacer>'),
|
||||
Factory__ICustomNode: Symbol('Factory<ICustomNode>'),
|
||||
Factory__ICustomNodeGroup: Symbol('Factory<ICustomNodeGroup>'),
|
||||
Factory__INodeTransformer: Symbol('Factory<INodeTransformer[]>'),
|
||||
Factory__IObfuscationResult: Symbol('Factory<IObfuscationResult>'),
|
||||
Factory__IObfuscationReplacer: Symbol('Factory<IObfuscationReplacer>'),
|
||||
Factory__TControlFlowStorage: Symbol('Factory<TControlFlowStorage>'),
|
||||
ICalleeDataExtractor: Symbol('ICalleeDataExtractor'),
|
||||
ICustomNodeGroup: Symbol('ICustomNodeGroup'),
|
||||
IControlFlowReplacer: Symbol('IControlFlowReplacer'),
|
||||
IJavaScriptObfuscator: Symbol('IJavaScriptObfuscator'),
|
||||
INodeTransformer: Symbol('INodeTransformer'),
|
||||
IObfuscationEventEmitter: Symbol('IObfuscationEventEmitter'),
|
||||
IObfuscationResult: Symbol('IObfuscationResult'),
|
||||
IObfuscator: Symbol('IObfuscator'),
|
||||
IOptions: Symbol('IOptions'),
|
||||
IObfuscationReplacer: Symbol('IObfuscationReplacer'),
|
||||
ISourceMapCorrector: Symbol('ISourceMapCorrector'),
|
||||
IStackTraceAnalyzer: Symbol('IStackTraceAnalyzer'),
|
||||
Newable__ICustomNode: Symbol('Newable<ICustomNode>'),
|
||||
Newable__TControlFlowStorage: Symbol('Newable<TControlFlowStorage>'),
|
||||
TCustomNodeGroupStorage: Symbol('TCustomNodeGroupStorage'),
|
||||
TStringArrayStorage: Symbol('TStringArrayStorage')
|
||||
};
|
||||
|
||||
/***/ }),
|
||||
@@ -436,8 +430,9 @@ var RandomGeneratorUtils = function () {
|
||||
}();
|
||||
|
||||
RandomGeneratorUtils.randomGeneratorPool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
RandomGeneratorUtils.randomGeneratorPoolHexadecimal = 'abcdef0123456789';
|
||||
RandomGeneratorUtils.randomGeneratorPoolWithNumbers = RandomGeneratorUtils.randomGeneratorPool + "0123456789";
|
||||
RandomGeneratorUtils.randomGeneratorPoolNumbers = '0123456789';
|
||||
RandomGeneratorUtils.randomGeneratorPoolHexadecimal = "abcdef" + RandomGeneratorUtils.randomGeneratorPoolNumbers;
|
||||
RandomGeneratorUtils.randomGeneratorPoolWithNumbers = "" + RandomGeneratorUtils.randomGeneratorPool + RandomGeneratorUtils.randomGeneratorPoolNumbers;
|
||||
RandomGeneratorUtils.randomVariableNameSet = new Set();
|
||||
exports.RandomGeneratorUtils = RandomGeneratorUtils;
|
||||
|
||||
@@ -1326,21 +1321,7 @@ exports.ObfuscationEvents = {
|
||||
};
|
||||
|
||||
/***/ }),
|
||||
/* 22 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
var NodeObfuscatorsReplacers;
|
||||
(function (NodeObfuscatorsReplacers) {
|
||||
NodeObfuscatorsReplacers[NodeObfuscatorsReplacers["BooleanReplacer"] = 0] = "BooleanReplacer";
|
||||
NodeObfuscatorsReplacers[NodeObfuscatorsReplacers["IdentifierReplacer"] = 1] = "IdentifierReplacer";
|
||||
NodeObfuscatorsReplacers[NodeObfuscatorsReplacers["NumberLiteralReplacer"] = 2] = "NumberLiteralReplacer";
|
||||
NodeObfuscatorsReplacers[NodeObfuscatorsReplacers["StringLiteralReplacer"] = 3] = "StringLiteralReplacer";
|
||||
})(NodeObfuscatorsReplacers = exports.NodeObfuscatorsReplacers || (exports.NodeObfuscatorsReplacers = {}));
|
||||
|
||||
/***/ }),
|
||||
/* 22 */,
|
||||
/* 23 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
@@ -1870,20 +1851,7 @@ var CustomNodeGroups;
|
||||
})(CustomNodeGroups = exports.CustomNodeGroups || (exports.CustomNodeGroups = {}));
|
||||
|
||||
/***/ }),
|
||||
/* 39 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
var NodeControlFlowReplacers;
|
||||
(function (NodeControlFlowReplacers) {
|
||||
NodeControlFlowReplacers[NodeControlFlowReplacers["BinaryExpressionControlFlowReplacer"] = 0] = "BinaryExpressionControlFlowReplacer";
|
||||
NodeControlFlowReplacers[NodeControlFlowReplacers["CallExpressionControlFlowReplacer"] = 1] = "CallExpressionControlFlowReplacer";
|
||||
NodeControlFlowReplacers[NodeControlFlowReplacers["LogicalExpressionControlFlowReplacer"] = 2] = "LogicalExpressionControlFlowReplacer";
|
||||
})(NodeControlFlowReplacers = exports.NodeControlFlowReplacers || (exports.NodeControlFlowReplacers = {}));
|
||||
|
||||
/***/ }),
|
||||
/* 39 */,
|
||||
/* 40 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
@@ -2381,13 +2349,13 @@ var VisitorDirection_1 = __webpack_require__(85);
|
||||
var Node_1 = __webpack_require__(11);
|
||||
var NodeUtils_1 = __webpack_require__(8);
|
||||
var Obfuscator = Obfuscator_1 = function () {
|
||||
function Obfuscator(stackTraceAnalyzer, obfuscationEventEmitter, customNodeGroupStorage, nodeTransformersFactory, options) {
|
||||
function Obfuscator(stackTraceAnalyzer, obfuscationEventEmitter, customNodeGroupStorage, nodeTransformerFactory, options) {
|
||||
_classCallCheck(this, Obfuscator);
|
||||
|
||||
this.stackTraceAnalyzer = stackTraceAnalyzer;
|
||||
this.obfuscationEventEmitter = obfuscationEventEmitter;
|
||||
this.customNodeGroupStorage = customNodeGroupStorage;
|
||||
this.nodeTransformersFactory = nodeTransformersFactory;
|
||||
this.nodeTransformerFactory = nodeTransformerFactory;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
@@ -2421,7 +2389,7 @@ var Obfuscator = Obfuscator_1 = function () {
|
||||
var nodeTransformersLength = nodeTransformers.length;
|
||||
var visitor = void 0;
|
||||
for (var i = 0; i < nodeTransformersLength; i++) {
|
||||
visitor = this.nodeTransformersFactory(nodeTransformers[i]).getVisitor();
|
||||
visitor = this.nodeTransformerFactory(nodeTransformers[i]).getVisitor();
|
||||
if (visitor.enter) {
|
||||
enterVisitors.push(visitor);
|
||||
}
|
||||
@@ -2950,24 +2918,18 @@ exports.customNodesModule = new inversify_1.ContainerModule(function (bind) {
|
||||
"use strict";
|
||||
|
||||
|
||||
var _map = __webpack_require__(14);
|
||||
|
||||
var _map2 = _interopRequireDefault(_map);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var inversify_1 = __webpack_require__(0);
|
||||
var ServiceIdentifiers_1 = __webpack_require__(2);
|
||||
var NodeControlFlowReplacers_1 = __webpack_require__(39);
|
||||
var ControlFlowReplacers_1 = __webpack_require__(148);
|
||||
var BinaryExpressionControlFlowReplacer_1 = __webpack_require__(89);
|
||||
var CallExpressionControlFlowReplacer_1 = __webpack_require__(90);
|
||||
var LogicalExpressionControlFlowReplacer_1 = __webpack_require__(91);
|
||||
exports.controlFlowTransformersModule = new inversify_1.ContainerModule(function (bind) {
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(BinaryExpressionControlFlowReplacer_1.BinaryExpressionControlFlowReplacer).whenTargetNamed(NodeControlFlowReplacers_1.NodeControlFlowReplacers.BinaryExpressionControlFlowReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(CallExpressionControlFlowReplacer_1.CallExpressionControlFlowReplacer).whenTargetNamed(NodeControlFlowReplacers_1.NodeControlFlowReplacers.CallExpressionControlFlowReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(LogicalExpressionControlFlowReplacer_1.LogicalExpressionControlFlowReplacer).whenTargetNamed(NodeControlFlowReplacers_1.NodeControlFlowReplacers.LogicalExpressionControlFlowReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(BinaryExpressionControlFlowReplacer_1.BinaryExpressionControlFlowReplacer).whenTargetNamed(ControlFlowReplacers_1.ControlFlowReplacers.BinaryExpressionControlFlowReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(CallExpressionControlFlowReplacer_1.CallExpressionControlFlowReplacer).whenTargetNamed(ControlFlowReplacers_1.ControlFlowReplacers.CallExpressionControlFlowReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(LogicalExpressionControlFlowReplacer_1.LogicalExpressionControlFlowReplacer).whenTargetNamed(ControlFlowReplacers_1.ControlFlowReplacers.LogicalExpressionControlFlowReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowReplacer).toFactory(function (context) {
|
||||
var cache = new _map2.default();
|
||||
var cache = new Map();
|
||||
return function (replacerName) {
|
||||
if (cache.has(replacerName)) {
|
||||
return cache.get(replacerName);
|
||||
@@ -3040,31 +3002,25 @@ exports.nodeTransformersModule = new inversify_1.ContainerModule(function (bind)
|
||||
"use strict";
|
||||
|
||||
|
||||
var _map = __webpack_require__(14);
|
||||
|
||||
var _map2 = _interopRequireDefault(_map);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var inversify_1 = __webpack_require__(0);
|
||||
var ServiceIdentifiers_1 = __webpack_require__(2);
|
||||
var NodeObfuscationReplacers_1 = __webpack_require__(22);
|
||||
var ObfuscationReplacers_1 = __webpack_require__(147);
|
||||
var BooleanLiteralReplacer_1 = __webpack_require__(102);
|
||||
var IdentifierReplacer_1 = __webpack_require__(103);
|
||||
var NumberLiteralReplacer_1 = __webpack_require__(104);
|
||||
var StringLiteralReplacer_1 = __webpack_require__(105);
|
||||
exports.obfuscatingTransformersModule = new inversify_1.ContainerModule(function (bind) {
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatorReplacer).to(BooleanLiteralReplacer_1.BooleanLiteralReplacer).whenTargetNamed(NodeObfuscationReplacers_1.NodeObfuscatorsReplacers.BooleanReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatorReplacer).to(IdentifierReplacer_1.IdentifierReplacer).whenTargetNamed(NodeObfuscationReplacers_1.NodeObfuscatorsReplacers.IdentifierReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatorReplacer).to(NumberLiteralReplacer_1.NumberLiteralReplacer).whenTargetNamed(NodeObfuscationReplacers_1.NodeObfuscatorsReplacers.NumberLiteralReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatorReplacer).to(StringLiteralReplacer_1.StringLiteralReplacer).whenTargetNamed(NodeObfuscationReplacers_1.NodeObfuscatorsReplacers.StringLiteralReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscatorReplacer).toFactory(function (context) {
|
||||
var cache = new _map2.default();
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationReplacer).to(BooleanLiteralReplacer_1.BooleanLiteralReplacer).whenTargetNamed(ObfuscationReplacers_1.ObfuscationReplacers.BooleanReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationReplacer).to(IdentifierReplacer_1.IdentifierReplacer).whenTargetNamed(ObfuscationReplacers_1.ObfuscationReplacers.IdentifierReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationReplacer).to(NumberLiteralReplacer_1.NumberLiteralReplacer).whenTargetNamed(ObfuscationReplacers_1.ObfuscationReplacers.NumberLiteralReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationReplacer).to(StringLiteralReplacer_1.StringLiteralReplacer).whenTargetNamed(ObfuscationReplacers_1.ObfuscationReplacers.StringLiteralReplacer);
|
||||
bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscationReplacer).toFactory(function (context) {
|
||||
var cache = new Map();
|
||||
return function (replacerName) {
|
||||
if (cache.has(replacerName)) {
|
||||
return cache.get(replacerName);
|
||||
}
|
||||
var obfuscationReplacer = context.container.getNamed(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatorReplacer, replacerName);
|
||||
var obfuscationReplacer = context.container.getNamed(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationReplacer, replacerName);
|
||||
cache.set(replacerName, obfuscationReplacer);
|
||||
return obfuscationReplacer;
|
||||
};
|
||||
@@ -5086,7 +5042,7 @@ var NodeType_1 = __webpack_require__(19);
|
||||
var AbstractNodeTransformer_1 = __webpack_require__(16);
|
||||
var Node_1 = __webpack_require__(11);
|
||||
var NodeAppender_1 = __webpack_require__(24);
|
||||
var NodeControlFlowReplacers_1 = __webpack_require__(39);
|
||||
var ControlFlowReplacers_1 = __webpack_require__(148);
|
||||
var NodeUtils_1 = __webpack_require__(8);
|
||||
var RandomGeneratorUtils_1 = __webpack_require__(9);
|
||||
var FunctionControlFlowTransformer = FunctionControlFlowTransformer_1 = function (_AbstractNodeTransfor) {
|
||||
@@ -5199,7 +5155,7 @@ var FunctionControlFlowTransformer = FunctionControlFlowTransformer_1 = function
|
||||
|
||||
return FunctionControlFlowTransformer;
|
||||
}(AbstractNodeTransformer_1.AbstractNodeTransformer);
|
||||
FunctionControlFlowTransformer.controlFlowReplacersMap = new Map([[NodeType_1.NodeType.BinaryExpression, NodeControlFlowReplacers_1.NodeControlFlowReplacers.BinaryExpressionControlFlowReplacer], [NodeType_1.NodeType.CallExpression, NodeControlFlowReplacers_1.NodeControlFlowReplacers.CallExpressionControlFlowReplacer], [NodeType_1.NodeType.LogicalExpression, NodeControlFlowReplacers_1.NodeControlFlowReplacers.LogicalExpressionControlFlowReplacer]]);
|
||||
FunctionControlFlowTransformer.controlFlowReplacersMap = new Map([[NodeType_1.NodeType.BinaryExpression, ControlFlowReplacers_1.ControlFlowReplacers.BinaryExpressionControlFlowReplacer], [NodeType_1.NodeType.CallExpression, ControlFlowReplacers_1.ControlFlowReplacers.CallExpressionControlFlowReplacer], [NodeType_1.NodeType.LogicalExpression, ControlFlowReplacers_1.ControlFlowReplacers.LogicalExpressionControlFlowReplacer]]);
|
||||
FunctionControlFlowTransformer.hostNodeSearchMinDepth = 0;
|
||||
FunctionControlFlowTransformer.hostNodeSearchMaxDepth = 2;
|
||||
FunctionControlFlowTransformer = FunctionControlFlowTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__TControlFlowStorage)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowReplacer)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Function, Function, Object])], FunctionControlFlowTransformer);
|
||||
@@ -5660,18 +5616,18 @@ var tslib_1 = __webpack_require__(1);
|
||||
var inversify_1 = __webpack_require__(0);
|
||||
var ServiceIdentifiers_1 = __webpack_require__(2);
|
||||
var estraverse = __webpack_require__(17);
|
||||
var NodeObfuscationReplacers_1 = __webpack_require__(22);
|
||||
var ObfuscationReplacers_1 = __webpack_require__(147);
|
||||
var AbstractNodeTransformer_1 = __webpack_require__(16);
|
||||
var Node_1 = __webpack_require__(11);
|
||||
var CatchClauseTransformer = function (_AbstractNodeTransfor) {
|
||||
_inherits(CatchClauseTransformer, _AbstractNodeTransfor);
|
||||
|
||||
function CatchClauseTransformer(replacersFactory, options) {
|
||||
function CatchClauseTransformer(obfuscationReplacerFactory, options) {
|
||||
_classCallCheck(this, CatchClauseTransformer);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (CatchClauseTransformer.__proto__ || Object.getPrototypeOf(CatchClauseTransformer)).call(this, options));
|
||||
|
||||
_this.identifierReplacer = replacersFactory(NodeObfuscationReplacers_1.NodeObfuscatorsReplacers.IdentifierReplacer);
|
||||
_this.identifierReplacer = obfuscationReplacerFactory(ObfuscationReplacers_1.ObfuscationReplacers.IdentifierReplacer);
|
||||
return _this;
|
||||
}
|
||||
|
||||
@@ -5724,7 +5680,7 @@ var CatchClauseTransformer = function (_AbstractNodeTransfor) {
|
||||
|
||||
return CatchClauseTransformer;
|
||||
}(AbstractNodeTransformer_1.AbstractNodeTransformer);
|
||||
CatchClauseTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscatorReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], CatchClauseTransformer);
|
||||
CatchClauseTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscationReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], CatchClauseTransformer);
|
||||
exports.CatchClauseTransformer = CatchClauseTransformer;
|
||||
|
||||
/***/ }),
|
||||
@@ -5746,7 +5702,7 @@ var tslib_1 = __webpack_require__(1);
|
||||
var inversify_1 = __webpack_require__(0);
|
||||
var ServiceIdentifiers_1 = __webpack_require__(2);
|
||||
var estraverse = __webpack_require__(17);
|
||||
var NodeObfuscationReplacers_1 = __webpack_require__(22);
|
||||
var ObfuscationReplacers_1 = __webpack_require__(147);
|
||||
var NodeType_1 = __webpack_require__(19);
|
||||
var AbstractNodeTransformer_1 = __webpack_require__(16);
|
||||
var Node_1 = __webpack_require__(11);
|
||||
@@ -5754,13 +5710,13 @@ var NodeUtils_1 = __webpack_require__(8);
|
||||
var FunctionDeclarationTransformer = function (_AbstractNodeTransfor) {
|
||||
_inherits(FunctionDeclarationTransformer, _AbstractNodeTransfor);
|
||||
|
||||
function FunctionDeclarationTransformer(nodeObfuscatorsReplacersFactory, options) {
|
||||
function FunctionDeclarationTransformer(obfuscationReplacerFactory, options) {
|
||||
_classCallCheck(this, FunctionDeclarationTransformer);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (FunctionDeclarationTransformer.__proto__ || Object.getPrototypeOf(FunctionDeclarationTransformer)).call(this, options));
|
||||
|
||||
_this.replaceableIdentifiers = new Map();
|
||||
_this.identifierReplacer = nodeObfuscatorsReplacersFactory(NodeObfuscationReplacers_1.NodeObfuscatorsReplacers.IdentifierReplacer);
|
||||
_this.identifierReplacer = obfuscationReplacerFactory(ObfuscationReplacers_1.ObfuscationReplacers.IdentifierReplacer);
|
||||
return _this;
|
||||
}
|
||||
|
||||
@@ -5786,7 +5742,11 @@ var FunctionDeclarationTransformer = function (_AbstractNodeTransfor) {
|
||||
return functionDeclarationNode;
|
||||
}
|
||||
this.storeFunctionName(functionDeclarationNode, nodeIdentifier);
|
||||
this.replaceFunctionName(blockScopeOfFunctionDeclarationNode, nodeIdentifier);
|
||||
if (this.replaceableIdentifiers.has(blockScopeOfFunctionDeclarationNode)) {
|
||||
this.replaceScopeCachedIdentifiers(blockScopeOfFunctionDeclarationNode, nodeIdentifier);
|
||||
} else {
|
||||
this.replaceScopeIdentifiers(blockScopeOfFunctionDeclarationNode, nodeIdentifier);
|
||||
}
|
||||
return functionDeclarationNode;
|
||||
}
|
||||
}, {
|
||||
@@ -5795,38 +5755,40 @@ var FunctionDeclarationTransformer = function (_AbstractNodeTransfor) {
|
||||
this.identifierReplacer.storeNames(functionDeclarationNode.id.name, nodeIdentifier);
|
||||
}
|
||||
}, {
|
||||
key: "replaceFunctionName",
|
||||
value: function replaceFunctionName(scopeNode, nodeIdentifier) {
|
||||
key: "replaceScopeCachedIdentifiers",
|
||||
value: function replaceScopeCachedIdentifiers(scopeNode, nodeIdentifier) {
|
||||
var _this3 = this;
|
||||
|
||||
var replaceableIdentifiersForCurrentScope = void 0;
|
||||
if (this.replaceableIdentifiers.has(scopeNode)) {
|
||||
replaceableIdentifiersForCurrentScope = this.replaceableIdentifiers.get(scopeNode);
|
||||
replaceableIdentifiersForCurrentScope.forEach(function (replaceableIdentifier) {
|
||||
replaceableIdentifier.name = _this3.identifierReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
|
||||
});
|
||||
return;
|
||||
}
|
||||
replaceableIdentifiersForCurrentScope = [];
|
||||
var cachedReplaceableIdentifiers = this.replaceableIdentifiers.get(scopeNode);
|
||||
cachedReplaceableIdentifiers.forEach(function (replaceableIdentifier) {
|
||||
replaceableIdentifier.name = _this3.identifierReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "replaceScopeIdentifiers",
|
||||
value: function replaceScopeIdentifiers(scopeNode, nodeIdentifier) {
|
||||
var _this4 = this;
|
||||
|
||||
var storedReplaceableIdentifiers = [];
|
||||
estraverse.replace(scopeNode, {
|
||||
enter: function enter(node, parentNode) {
|
||||
if (Node_1.Node.isReplaceableIdentifierNode(node, parentNode)) {
|
||||
var newNodeName = _this3.identifierReplacer.replace(node.name, nodeIdentifier);
|
||||
var newNodeName = _this4.identifierReplacer.replace(node.name, nodeIdentifier);
|
||||
if (node.name !== newNodeName) {
|
||||
node.name = newNodeName;
|
||||
} else {
|
||||
replaceableIdentifiersForCurrentScope.push(node);
|
||||
storedReplaceableIdentifiers.push(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.replaceableIdentifiers.set(scopeNode, replaceableIdentifiersForCurrentScope);
|
||||
this.replaceableIdentifiers.set(scopeNode, storedReplaceableIdentifiers);
|
||||
}
|
||||
}]);
|
||||
|
||||
return FunctionDeclarationTransformer;
|
||||
}(AbstractNodeTransformer_1.AbstractNodeTransformer);
|
||||
FunctionDeclarationTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscatorReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], FunctionDeclarationTransformer);
|
||||
FunctionDeclarationTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscationReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], FunctionDeclarationTransformer);
|
||||
exports.FunctionDeclarationTransformer = FunctionDeclarationTransformer;
|
||||
|
||||
/***/ }),
|
||||
@@ -5848,18 +5810,18 @@ var tslib_1 = __webpack_require__(1);
|
||||
var inversify_1 = __webpack_require__(0);
|
||||
var ServiceIdentifiers_1 = __webpack_require__(2);
|
||||
var estraverse = __webpack_require__(17);
|
||||
var NodeObfuscationReplacers_1 = __webpack_require__(22);
|
||||
var ObfuscationReplacers_1 = __webpack_require__(147);
|
||||
var AbstractNodeTransformer_1 = __webpack_require__(16);
|
||||
var Node_1 = __webpack_require__(11);
|
||||
var FunctionTransformer = function (_AbstractNodeTransfor) {
|
||||
_inherits(FunctionTransformer, _AbstractNodeTransfor);
|
||||
|
||||
function FunctionTransformer(nodeObfuscatorsReplacersFactory, options) {
|
||||
function FunctionTransformer(obfuscationReplacerFactory, options) {
|
||||
_classCallCheck(this, FunctionTransformer);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (FunctionTransformer.__proto__ || Object.getPrototypeOf(FunctionTransformer)).call(this, options));
|
||||
|
||||
_this.identifierReplacer = nodeObfuscatorsReplacersFactory(NodeObfuscationReplacers_1.NodeObfuscatorsReplacers.IdentifierReplacer);
|
||||
_this.identifierReplacer = obfuscationReplacerFactory(ObfuscationReplacers_1.ObfuscationReplacers.IdentifierReplacer);
|
||||
return _this;
|
||||
}
|
||||
|
||||
@@ -5931,7 +5893,7 @@ var FunctionTransformer = function (_AbstractNodeTransfor) {
|
||||
|
||||
return FunctionTransformer;
|
||||
}(AbstractNodeTransformer_1.AbstractNodeTransformer);
|
||||
FunctionTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscatorReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], FunctionTransformer);
|
||||
FunctionTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscationReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], FunctionTransformer);
|
||||
exports.FunctionTransformer = FunctionTransformer;
|
||||
|
||||
/***/ }),
|
||||
@@ -5953,18 +5915,18 @@ var tslib_1 = __webpack_require__(1);
|
||||
var inversify_1 = __webpack_require__(0);
|
||||
var ServiceIdentifiers_1 = __webpack_require__(2);
|
||||
var estraverse = __webpack_require__(17);
|
||||
var NodeObfuscationReplacers_1 = __webpack_require__(22);
|
||||
var ObfuscationReplacers_1 = __webpack_require__(147);
|
||||
var AbstractNodeTransformer_1 = __webpack_require__(16);
|
||||
var Node_1 = __webpack_require__(11);
|
||||
var LabeledStatementTransformer = function (_AbstractNodeTransfor) {
|
||||
_inherits(LabeledStatementTransformer, _AbstractNodeTransfor);
|
||||
|
||||
function LabeledStatementTransformer(nodeObfuscatorsReplacersFactory, options) {
|
||||
function LabeledStatementTransformer(obfuscationReplacerFactory, options) {
|
||||
_classCallCheck(this, LabeledStatementTransformer);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (LabeledStatementTransformer.__proto__ || Object.getPrototypeOf(LabeledStatementTransformer)).call(this, options));
|
||||
|
||||
_this.identifierReplacer = nodeObfuscatorsReplacersFactory(NodeObfuscationReplacers_1.NodeObfuscatorsReplacers.IdentifierReplacer);
|
||||
_this.identifierReplacer = obfuscationReplacerFactory(ObfuscationReplacers_1.ObfuscationReplacers.IdentifierReplacer);
|
||||
return _this;
|
||||
}
|
||||
|
||||
@@ -6011,7 +5973,7 @@ var LabeledStatementTransformer = function (_AbstractNodeTransfor) {
|
||||
|
||||
return LabeledStatementTransformer;
|
||||
}(AbstractNodeTransformer_1.AbstractNodeTransformer);
|
||||
LabeledStatementTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscatorReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], LabeledStatementTransformer);
|
||||
LabeledStatementTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscationReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], LabeledStatementTransformer);
|
||||
exports.LabeledStatementTransformer = LabeledStatementTransformer;
|
||||
|
||||
/***/ }),
|
||||
@@ -6035,18 +5997,18 @@ var tslib_1 = __webpack_require__(1);
|
||||
var inversify_1 = __webpack_require__(0);
|
||||
var ServiceIdentifiers_1 = __webpack_require__(2);
|
||||
var escodegen = __webpack_require__(26);
|
||||
var NodeObfuscationReplacers_1 = __webpack_require__(22);
|
||||
var ObfuscationReplacers_1 = __webpack_require__(147);
|
||||
var AbstractNodeTransformer_1 = __webpack_require__(16);
|
||||
var Node_1 = __webpack_require__(11);
|
||||
var LiteralTransformer = function (_AbstractNodeTransfor) {
|
||||
_inherits(LiteralTransformer, _AbstractNodeTransfor);
|
||||
|
||||
function LiteralTransformer(replacersFactory, options) {
|
||||
function LiteralTransformer(obfuscationReplacerFactory, options) {
|
||||
_classCallCheck(this, LiteralTransformer);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (LiteralTransformer.__proto__ || Object.getPrototypeOf(LiteralTransformer)).call(this, options));
|
||||
|
||||
_this.replacersFactory = replacersFactory;
|
||||
_this.obfuscationReplacerFactory = obfuscationReplacerFactory;
|
||||
return _this;
|
||||
}
|
||||
|
||||
@@ -6072,13 +6034,13 @@ var LiteralTransformer = function (_AbstractNodeTransfor) {
|
||||
var content = void 0;
|
||||
switch (_typeof(literalNode.value)) {
|
||||
case 'boolean':
|
||||
content = this.replacersFactory(NodeObfuscationReplacers_1.NodeObfuscatorsReplacers.BooleanReplacer).replace(literalNode.value);
|
||||
content = this.obfuscationReplacerFactory(ObfuscationReplacers_1.ObfuscationReplacers.BooleanReplacer).replace(literalNode.value);
|
||||
break;
|
||||
case 'number':
|
||||
content = this.replacersFactory(NodeObfuscationReplacers_1.NodeObfuscatorsReplacers.NumberLiteralReplacer).replace(literalNode.value);
|
||||
content = this.obfuscationReplacerFactory(ObfuscationReplacers_1.ObfuscationReplacers.NumberLiteralReplacer).replace(literalNode.value);
|
||||
break;
|
||||
case 'string':
|
||||
content = this.replacersFactory(NodeObfuscationReplacers_1.NodeObfuscatorsReplacers.StringLiteralReplacer).replace(literalNode.value);
|
||||
content = this.obfuscationReplacerFactory(ObfuscationReplacers_1.ObfuscationReplacers.StringLiteralReplacer).replace(literalNode.value);
|
||||
break;
|
||||
default:
|
||||
return literalNode;
|
||||
@@ -6093,7 +6055,7 @@ var LiteralTransformer = function (_AbstractNodeTransfor) {
|
||||
|
||||
return LiteralTransformer;
|
||||
}(AbstractNodeTransformer_1.AbstractNodeTransformer);
|
||||
LiteralTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscatorReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], LiteralTransformer);
|
||||
LiteralTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscationReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], LiteralTransformer);
|
||||
exports.LiteralTransformer = LiteralTransformer;
|
||||
|
||||
/***/ }),
|
||||
@@ -6207,7 +6169,7 @@ var tslib_1 = __webpack_require__(1);
|
||||
var inversify_1 = __webpack_require__(0);
|
||||
var ServiceIdentifiers_1 = __webpack_require__(2);
|
||||
var estraverse = __webpack_require__(17);
|
||||
var NodeObfuscationReplacers_1 = __webpack_require__(22);
|
||||
var ObfuscationReplacers_1 = __webpack_require__(147);
|
||||
var NodeType_1 = __webpack_require__(19);
|
||||
var AbstractNodeTransformer_1 = __webpack_require__(16);
|
||||
var Node_1 = __webpack_require__(11);
|
||||
@@ -6215,13 +6177,13 @@ var NodeUtils_1 = __webpack_require__(8);
|
||||
var VariableDeclarationTransformer = function (_AbstractNodeTransfor) {
|
||||
_inherits(VariableDeclarationTransformer, _AbstractNodeTransfor);
|
||||
|
||||
function VariableDeclarationTransformer(replacersFactory, options) {
|
||||
function VariableDeclarationTransformer(obfuscationReplacerFactory, options) {
|
||||
_classCallCheck(this, VariableDeclarationTransformer);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (VariableDeclarationTransformer.__proto__ || Object.getPrototypeOf(VariableDeclarationTransformer)).call(this, options));
|
||||
|
||||
_this.replaceableIdentifiers = new Map();
|
||||
_this.identifierReplacer = replacersFactory(NodeObfuscationReplacers_1.NodeObfuscatorsReplacers.IdentifierReplacer);
|
||||
_this.identifierReplacer = obfuscationReplacerFactory(ObfuscationReplacers_1.ObfuscationReplacers.IdentifierReplacer);
|
||||
return _this;
|
||||
}
|
||||
|
||||
@@ -6248,7 +6210,11 @@ var VariableDeclarationTransformer = function (_AbstractNodeTransfor) {
|
||||
var nodeIdentifier = this.nodeIdentifier++;
|
||||
var scopeNode = variableDeclarationNode.kind === 'var' ? blockScopeOfVariableDeclarationNode : parentNode;
|
||||
this.storeVariableNames(variableDeclarationNode, nodeIdentifier);
|
||||
this.replaceVariableNames(scopeNode, nodeIdentifier);
|
||||
if (this.replaceableIdentifiers.has(scopeNode)) {
|
||||
this.replaceScopeCachedIdentifiers(scopeNode, nodeIdentifier);
|
||||
} else {
|
||||
this.replaceScopeIdentifiers(scopeNode, nodeIdentifier);
|
||||
}
|
||||
return variableDeclarationNode;
|
||||
}
|
||||
}, {
|
||||
@@ -6268,38 +6234,40 @@ var VariableDeclarationTransformer = function (_AbstractNodeTransfor) {
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "replaceVariableNames",
|
||||
value: function replaceVariableNames(scopeNode, nodeIdentifier) {
|
||||
key: "replaceScopeCachedIdentifiers",
|
||||
value: function replaceScopeCachedIdentifiers(scopeNode, nodeIdentifier) {
|
||||
var _this4 = this;
|
||||
|
||||
var replaceableIdentifiersForCurrentScope = void 0;
|
||||
if (this.replaceableIdentifiers.has(scopeNode)) {
|
||||
replaceableIdentifiersForCurrentScope = this.replaceableIdentifiers.get(scopeNode);
|
||||
replaceableIdentifiersForCurrentScope.forEach(function (replaceableIdentifier) {
|
||||
replaceableIdentifier.name = _this4.identifierReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
|
||||
});
|
||||
return;
|
||||
}
|
||||
replaceableIdentifiersForCurrentScope = [];
|
||||
var cachedReplaceableIdentifiers = this.replaceableIdentifiers.get(scopeNode);
|
||||
cachedReplaceableIdentifiers.forEach(function (replaceableIdentifier) {
|
||||
replaceableIdentifier.name = _this4.identifierReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "replaceScopeIdentifiers",
|
||||
value: function replaceScopeIdentifiers(scopeNode, nodeIdentifier) {
|
||||
var _this5 = this;
|
||||
|
||||
var storedReplaceableIdentifiers = [];
|
||||
estraverse.replace(scopeNode, {
|
||||
enter: function enter(node, parentNode) {
|
||||
if (!node.obfuscatedNode && Node_1.Node.isReplaceableIdentifierNode(node, parentNode)) {
|
||||
var newNodeName = _this4.identifierReplacer.replace(node.name, nodeIdentifier);
|
||||
var newNodeName = _this5.identifierReplacer.replace(node.name, nodeIdentifier);
|
||||
if (node.name !== newNodeName) {
|
||||
node.name = newNodeName;
|
||||
} else {
|
||||
replaceableIdentifiersForCurrentScope.push(node);
|
||||
storedReplaceableIdentifiers.push(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.replaceableIdentifiers.set(scopeNode, replaceableIdentifiersForCurrentScope);
|
||||
this.replaceableIdentifiers.set(scopeNode, storedReplaceableIdentifiers);
|
||||
}
|
||||
}]);
|
||||
|
||||
return VariableDeclarationTransformer;
|
||||
}(AbstractNodeTransformer_1.AbstractNodeTransformer);
|
||||
VariableDeclarationTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscatorReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], VariableDeclarationTransformer);
|
||||
VariableDeclarationTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscationReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], VariableDeclarationTransformer);
|
||||
exports.VariableDeclarationTransformer = VariableDeclarationTransformer;
|
||||
|
||||
/***/ }),
|
||||
@@ -6939,15 +6907,9 @@ exports.ValidationErrorsFormatter = ValidationErrorsFormatter;
|
||||
"use strict";
|
||||
|
||||
|
||||
var _classCallCheck2 = __webpack_require__(3);
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
||||
|
||||
var _createClass2 = __webpack_require__(4);
|
||||
|
||||
var _createClass3 = _interopRequireDefault(_createClass2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var tslib_1 = __webpack_require__(1);
|
||||
var inversify_1 = __webpack_require__(0);
|
||||
@@ -6957,13 +6919,13 @@ var CalleeDataExtractors_1 = __webpack_require__(37);
|
||||
var Node_1 = __webpack_require__(11);
|
||||
var NodeUtils_1 = __webpack_require__(8);
|
||||
var StackTraceAnalyzer = StackTraceAnalyzer_1 = function () {
|
||||
function StackTraceAnalyzer(calleeDataExtractorsFactory) {
|
||||
(0, _classCallCheck3.default)(this, StackTraceAnalyzer);
|
||||
function StackTraceAnalyzer(calleeDataExtractorFactory) {
|
||||
_classCallCheck(this, StackTraceAnalyzer);
|
||||
|
||||
this.calleeDataExtractorsFactory = calleeDataExtractorsFactory;
|
||||
this.calleeDataExtractorFactory = calleeDataExtractorFactory;
|
||||
}
|
||||
|
||||
(0, _createClass3.default)(StackTraceAnalyzer, [{
|
||||
_createClass(StackTraceAnalyzer, [{
|
||||
key: "analyze",
|
||||
value: function analyze(blockScopeBody) {
|
||||
return this.analyzeRecursive(blockScopeBody);
|
||||
@@ -7008,7 +6970,7 @@ var StackTraceAnalyzer = StackTraceAnalyzer_1 = function () {
|
||||
var _this2 = this;
|
||||
|
||||
StackTraceAnalyzer_1.calleeDataExtractorsList.forEach(function (calleeDataExtractorName) {
|
||||
var calleeData = _this2.calleeDataExtractorsFactory(calleeDataExtractorName).extract(blockScopeBody, callExpressionNode.callee);
|
||||
var calleeData = _this2.calleeDataExtractorFactory(calleeDataExtractorName).extract(blockScopeBody, callExpressionNode.callee);
|
||||
if (!calleeData) {
|
||||
return;
|
||||
}
|
||||
@@ -7030,6 +6992,7 @@ var StackTraceAnalyzer = StackTraceAnalyzer_1 = function () {
|
||||
return limitIndex;
|
||||
}
|
||||
}]);
|
||||
|
||||
return StackTraceAnalyzer;
|
||||
}();
|
||||
StackTraceAnalyzer.calleeDataExtractorsList = [CalleeDataExtractors_1.CalleeDataExtractors.FunctionDeclarationCalleeDataExtractor, CalleeDataExtractors_1.CalleeDataExtractors.FunctionExpressionCalleeDataExtractor, CalleeDataExtractors_1.CalleeDataExtractors.ObjectExpressionCalleeDataExtractor];
|
||||
@@ -7867,12 +7830,7 @@ module.exports = require("babel-runtime/core-js/object/define-property");
|
||||
module.exports = require("babel-runtime/core-js/object/get-own-property-descriptor");
|
||||
|
||||
/***/ }),
|
||||
/* 137 */
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = require("babel-runtime/core-js/symbol");
|
||||
|
||||
/***/ }),
|
||||
/* 137 */,
|
||||
/* 138 */
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
@@ -7925,6 +7883,35 @@ module.exports = require("reflect-metadata");
|
||||
var JavaScriptObfuscator_1 = __webpack_require__(23);
|
||||
module.exports = JavaScriptObfuscator_1.JavaScriptObfuscator;
|
||||
|
||||
/***/ }),
|
||||
/* 147 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
var ObfuscationReplacers;
|
||||
(function (ObfuscationReplacers) {
|
||||
ObfuscationReplacers[ObfuscationReplacers["BooleanReplacer"] = 0] = "BooleanReplacer";
|
||||
ObfuscationReplacers[ObfuscationReplacers["IdentifierReplacer"] = 1] = "IdentifierReplacer";
|
||||
ObfuscationReplacers[ObfuscationReplacers["NumberLiteralReplacer"] = 2] = "NumberLiteralReplacer";
|
||||
ObfuscationReplacers[ObfuscationReplacers["StringLiteralReplacer"] = 3] = "StringLiteralReplacer";
|
||||
})(ObfuscationReplacers = exports.ObfuscationReplacers || (exports.ObfuscationReplacers = {}));
|
||||
|
||||
/***/ }),
|
||||
/* 148 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
var ControlFlowReplacers;
|
||||
(function (ControlFlowReplacers) {
|
||||
ControlFlowReplacers[ControlFlowReplacers["BinaryExpressionControlFlowReplacer"] = 0] = "BinaryExpressionControlFlowReplacer";
|
||||
ControlFlowReplacers[ControlFlowReplacers["CallExpressionControlFlowReplacer"] = 1] = "CallExpressionControlFlowReplacer";
|
||||
ControlFlowReplacers[ControlFlowReplacers["LogicalExpressionControlFlowReplacer"] = 2] = "LogicalExpressionControlFlowReplacer";
|
||||
})(ControlFlowReplacers = exports.ControlFlowReplacers || (exports.ControlFlowReplacers = {}));
|
||||
|
||||
/***/ })
|
||||
/******/ ]);
|
||||
//# sourceMappingURL=index.js.map
|
||||
+2
-2
@@ -44,7 +44,7 @@
|
||||
"@types/lodash": "4.14.50",
|
||||
"@types/mkdirp": "0.3.29",
|
||||
"@types/mocha": "2.2.38",
|
||||
"@types/node": "7.0.3",
|
||||
"@types/node": "7.0.4",
|
||||
"@types/sinon": "1.16.34",
|
||||
"@types/string-template": "1.0.2",
|
||||
"awesome-typescript-loader": "3.0.0-beta.18",
|
||||
@@ -58,7 +58,7 @@
|
||||
"mocha": "3.2.0",
|
||||
"sinon": "2.0.0-pre.4",
|
||||
"ts-node": "2.0.0",
|
||||
"tslint": "4.3.1",
|
||||
"tslint": "4.4.1",
|
||||
"tslint-loader": "3.3.0",
|
||||
"typescript": "2.1.5",
|
||||
"webpack": "2.2.0",
|
||||
|
||||
+7
-7
@@ -4,7 +4,7 @@ import { ServiceIdentifiers } from './container/ServiceIdentifiers';
|
||||
import * as estraverse from 'estraverse';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { TNodeTransformersFactory } from './types/container/TNodeTransformersFactory';
|
||||
import { TNodeTransformerFactory } from './types/container/TNodeTransformerFactory';
|
||||
import { TVisitorDirection } from './types/TVisitorDirection';
|
||||
import { TVisitorFunction } from './types/TVisitorFunction';
|
||||
|
||||
@@ -62,9 +62,9 @@ export class Obfuscator implements IObfuscator {
|
||||
private readonly customNodeGroupStorage: IStorage<ICustomNodeGroup>;
|
||||
|
||||
/**
|
||||
* @type {TNodeTransformersFactory}
|
||||
* @type {TNodeTransformerFactory}
|
||||
*/
|
||||
private readonly nodeTransformersFactory: TNodeTransformersFactory;
|
||||
private readonly nodeTransformerFactory: TNodeTransformerFactory;
|
||||
|
||||
/**
|
||||
* @type {IObfuscationEventEmitter}
|
||||
@@ -85,20 +85,20 @@ export class Obfuscator implements IObfuscator {
|
||||
* @param stackTraceAnalyzer
|
||||
* @param obfuscationEventEmitter
|
||||
* @param customNodeGroupStorage
|
||||
* @param nodeTransformersFactory
|
||||
* @param nodeTransformerFactory
|
||||
* @param options
|
||||
*/
|
||||
constructor (
|
||||
@inject(ServiceIdentifiers.IStackTraceAnalyzer) stackTraceAnalyzer: IStackTraceAnalyzer,
|
||||
@inject(ServiceIdentifiers.IObfuscationEventEmitter) obfuscationEventEmitter: IObfuscationEventEmitter,
|
||||
@inject(ServiceIdentifiers.TCustomNodeGroupStorage) customNodeGroupStorage: IStorage<ICustomNodeGroup>,
|
||||
@inject(ServiceIdentifiers.Factory__INodeTransformer) nodeTransformersFactory: TNodeTransformersFactory,
|
||||
@inject(ServiceIdentifiers.Factory__INodeTransformer) nodeTransformerFactory: TNodeTransformerFactory,
|
||||
@inject(ServiceIdentifiers.IOptions) options: IOptions
|
||||
) {
|
||||
this.stackTraceAnalyzer = stackTraceAnalyzer;
|
||||
this.obfuscationEventEmitter = obfuscationEventEmitter;
|
||||
this.customNodeGroupStorage = customNodeGroupStorage;
|
||||
this.nodeTransformersFactory = nodeTransformersFactory;
|
||||
this.nodeTransformerFactory = nodeTransformerFactory;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ export class Obfuscator implements IObfuscator {
|
||||
let visitor: IVisitor;
|
||||
|
||||
for (let i: number = 0; i < nodeTransformersLength; i++) {
|
||||
visitor = this.nodeTransformersFactory(nodeTransformers[i]).getVisitor();
|
||||
visitor = this.nodeTransformerFactory(nodeTransformers[i]).getVisitor();
|
||||
|
||||
if (visitor.enter) {
|
||||
enterVisitors.push(visitor);
|
||||
|
||||
@@ -5,7 +5,7 @@ export const ServiceIdentifiers: any = {
|
||||
Factory__ICustomNodeGroup: Symbol('Factory<ICustomNodeGroup>'),
|
||||
Factory__INodeTransformer: Symbol('Factory<INodeTransformer[]>'),
|
||||
Factory__IObfuscationResult: Symbol('Factory<IObfuscationResult>'),
|
||||
Factory__IObfuscatorReplacer: Symbol('Factory<IObfuscationReplacer>'),
|
||||
Factory__IObfuscationReplacer: Symbol('Factory<IObfuscationReplacer>'),
|
||||
Factory__TControlFlowStorage: Symbol('Factory<TControlFlowStorage>'),
|
||||
ICalleeDataExtractor: Symbol('ICalleeDataExtractor'),
|
||||
ICustomNodeGroup: Symbol('ICustomNodeGroup'),
|
||||
@@ -16,7 +16,7 @@ export const ServiceIdentifiers: any = {
|
||||
IObfuscationResult: Symbol('IObfuscationResult'),
|
||||
IObfuscator: Symbol('IObfuscator'),
|
||||
IOptions: Symbol('IOptions'),
|
||||
IObfuscatorReplacer: Symbol('IObfuscationReplacer'),
|
||||
IObfuscationReplacer: Symbol('IObfuscationReplacer'),
|
||||
ISourceMapCorrector: Symbol('ISourceMapCorrector'),
|
||||
IStackTraceAnalyzer: Symbol('IStackTraceAnalyzer'),
|
||||
Newable__ICustomNode: Symbol('Newable<ICustomNode>'),
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../ServiceIdentifiers';
|
||||
|
||||
import { IControlFlowReplacer } from '../../../interfaces/node-transformers/IControlFlowReplacer';
|
||||
|
||||
import { NodeControlFlowReplacers } from '../../../enums/container/NodeControlFlowReplacers';
|
||||
import { ControlFlowReplacers } from '../../../enums/container/ControlFlowReplacers';
|
||||
|
||||
import { BinaryExpressionControlFlowReplacer } from '../../../node-transformers/control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer';
|
||||
import { CallExpressionControlFlowReplacer } from '../../../node-transformers/control-flow-transformers/control-flow-replacers/CallExpressionControlFlowReplacer';
|
||||
@@ -12,21 +12,21 @@ import { LogicalExpressionControlFlowReplacer } from '../../../node-transformers
|
||||
export const controlFlowTransformersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
|
||||
bind<IControlFlowReplacer>(ServiceIdentifiers.IControlFlowReplacer)
|
||||
.to(BinaryExpressionControlFlowReplacer)
|
||||
.whenTargetNamed(NodeControlFlowReplacers.BinaryExpressionControlFlowReplacer);
|
||||
.whenTargetNamed(ControlFlowReplacers.BinaryExpressionControlFlowReplacer);
|
||||
|
||||
bind<IControlFlowReplacer>(ServiceIdentifiers.IControlFlowReplacer)
|
||||
.to(CallExpressionControlFlowReplacer)
|
||||
.whenTargetNamed(NodeControlFlowReplacers.CallExpressionControlFlowReplacer);
|
||||
.whenTargetNamed(ControlFlowReplacers.CallExpressionControlFlowReplacer);
|
||||
|
||||
bind<IControlFlowReplacer>(ServiceIdentifiers.IControlFlowReplacer)
|
||||
.to(LogicalExpressionControlFlowReplacer)
|
||||
.whenTargetNamed(NodeControlFlowReplacers.LogicalExpressionControlFlowReplacer);
|
||||
.whenTargetNamed(ControlFlowReplacers.LogicalExpressionControlFlowReplacer);
|
||||
|
||||
bind<IControlFlowReplacer>(ServiceIdentifiers.Factory__IControlFlowReplacer)
|
||||
.toFactory<IControlFlowReplacer>((context: interfaces.Context) => {
|
||||
const cache: Map <NodeControlFlowReplacers, IControlFlowReplacer> = new Map();
|
||||
const cache: Map <ControlFlowReplacers, IControlFlowReplacer> = new Map();
|
||||
|
||||
return (replacerName: NodeControlFlowReplacers) => {
|
||||
return (replacerName: ControlFlowReplacers) => {
|
||||
if (cache.has(replacerName)) {
|
||||
return <IControlFlowReplacer>cache.get(replacerName);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../ServiceIdentifiers';
|
||||
|
||||
import { IObfuscationReplacer } from '../../../interfaces/node-transformers/IObfuscationReplacer';
|
||||
|
||||
import { NodeObfuscatorsReplacers } from '../../../enums/container/NodeObfuscationReplacers';
|
||||
import { ObfuscationReplacers } from '../../../enums/container/ObfuscationReplacers';
|
||||
|
||||
import { BooleanLiteralReplacer } from '../../../node-transformers/obfuscating-transformers/replacers/BooleanLiteralReplacer';
|
||||
import { IdentifierReplacer } from '../../../node-transformers/obfuscating-transformers/replacers/IdentifierReplacer';
|
||||
@@ -11,33 +11,33 @@ import { NumberLiteralReplacer } from '../../../node-transformers/obfuscating-tr
|
||||
import { StringLiteralReplacer } from '../../../node-transformers/obfuscating-transformers/replacers/StringLiteralReplacer';
|
||||
|
||||
export const obfuscatingTransformersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
|
||||
bind<IObfuscationReplacer>(ServiceIdentifiers.IObfuscatorReplacer)
|
||||
bind<IObfuscationReplacer>(ServiceIdentifiers.IObfuscationReplacer)
|
||||
.to(BooleanLiteralReplacer)
|
||||
.whenTargetNamed(NodeObfuscatorsReplacers.BooleanReplacer);
|
||||
.whenTargetNamed(ObfuscationReplacers.BooleanReplacer);
|
||||
|
||||
bind<IObfuscationReplacer>(ServiceIdentifiers.IObfuscatorReplacer)
|
||||
bind<IObfuscationReplacer>(ServiceIdentifiers.IObfuscationReplacer)
|
||||
.to(IdentifierReplacer)
|
||||
.whenTargetNamed(NodeObfuscatorsReplacers.IdentifierReplacer);
|
||||
.whenTargetNamed(ObfuscationReplacers.IdentifierReplacer);
|
||||
|
||||
bind<IObfuscationReplacer>(ServiceIdentifiers.IObfuscatorReplacer)
|
||||
bind<IObfuscationReplacer>(ServiceIdentifiers.IObfuscationReplacer)
|
||||
.to(NumberLiteralReplacer)
|
||||
.whenTargetNamed(NodeObfuscatorsReplacers.NumberLiteralReplacer);
|
||||
.whenTargetNamed(ObfuscationReplacers.NumberLiteralReplacer);
|
||||
|
||||
bind<IObfuscationReplacer>(ServiceIdentifiers.IObfuscatorReplacer)
|
||||
bind<IObfuscationReplacer>(ServiceIdentifiers.IObfuscationReplacer)
|
||||
.to(StringLiteralReplacer)
|
||||
.whenTargetNamed(NodeObfuscatorsReplacers.StringLiteralReplacer);
|
||||
.whenTargetNamed(ObfuscationReplacers.StringLiteralReplacer);
|
||||
|
||||
bind<IObfuscationReplacer>(ServiceIdentifiers.Factory__IObfuscatorReplacer)
|
||||
bind<IObfuscationReplacer>(ServiceIdentifiers.Factory__IObfuscationReplacer)
|
||||
.toFactory<IObfuscationReplacer>((context: interfaces.Context) => {
|
||||
const cache: Map <NodeObfuscatorsReplacers, IObfuscationReplacer> = new Map();
|
||||
const cache: Map <ObfuscationReplacers, IObfuscationReplacer> = new Map();
|
||||
|
||||
return (replacerName: NodeObfuscatorsReplacers) => {
|
||||
return (replacerName: ObfuscationReplacers) => {
|
||||
if (cache.has(replacerName)) {
|
||||
return <IObfuscationReplacer>cache.get(replacerName);
|
||||
}
|
||||
|
||||
const obfuscationReplacer: IObfuscationReplacer = context.container.getNamed<IObfuscationReplacer>(
|
||||
ServiceIdentifiers.IObfuscatorReplacer,
|
||||
ServiceIdentifiers.IObfuscationReplacer,
|
||||
replacerName
|
||||
);
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
export enum NodeControlFlowReplacers {
|
||||
export enum ControlFlowReplacers {
|
||||
BinaryExpressionControlFlowReplacer,
|
||||
CallExpressionControlFlowReplacer,
|
||||
LogicalExpressionControlFlowReplacer
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
export enum NodeObfuscatorsReplacers {
|
||||
export enum ObfuscationReplacers {
|
||||
BooleanReplacer,
|
||||
IdentifierReplacer,
|
||||
NumberLiteralReplacer,
|
||||
@@ -20,19 +20,19 @@ import { NodeType } from '../../enums/NodeType';
|
||||
import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
|
||||
import { Node } from '../../node/Node';
|
||||
import { NodeAppender } from '../../node/NodeAppender';
|
||||
import { NodeControlFlowReplacers } from '../../enums/container/NodeControlFlowReplacers';
|
||||
import { ControlFlowReplacers } from '../../enums/container/ControlFlowReplacers';
|
||||
import { NodeUtils } from '../../node/NodeUtils';
|
||||
import { RandomGeneratorUtils } from '../../utils/RandomGeneratorUtils';
|
||||
|
||||
@injectable()
|
||||
export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
|
||||
/**
|
||||
* @type {Map <string, NodeControlFlowReplacers>}
|
||||
* @type {Map <string, ControlFlowReplacers>}
|
||||
*/
|
||||
private static readonly controlFlowReplacersMap: Map <string, NodeControlFlowReplacers> = new Map([
|
||||
[NodeType.BinaryExpression, NodeControlFlowReplacers.BinaryExpressionControlFlowReplacer],
|
||||
[NodeType.CallExpression, NodeControlFlowReplacers.CallExpressionControlFlowReplacer],
|
||||
[NodeType.LogicalExpression, NodeControlFlowReplacers.LogicalExpressionControlFlowReplacer]
|
||||
private static readonly controlFlowReplacersMap: Map <string, ControlFlowReplacers> = new Map([
|
||||
[NodeType.BinaryExpression, ControlFlowReplacers.BinaryExpressionControlFlowReplacer],
|
||||
[NodeType.CallExpression, ControlFlowReplacers.CallExpressionControlFlowReplacer],
|
||||
[NodeType.LogicalExpression, ControlFlowReplacers.LogicalExpressionControlFlowReplacer]
|
||||
]);
|
||||
|
||||
/**
|
||||
@@ -217,7 +217,7 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
|
||||
return node;
|
||||
}
|
||||
|
||||
const controlFlowReplacerName: NodeControlFlowReplacers = <NodeControlFlowReplacers>FunctionControlFlowTransformer
|
||||
const controlFlowReplacerName: ControlFlowReplacers = <ControlFlowReplacers>FunctionControlFlowTransformer
|
||||
.controlFlowReplacersMap.get(node.type);
|
||||
|
||||
return {
|
||||
|
||||
@@ -4,12 +4,13 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
|
||||
import * as estraverse from 'estraverse';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { TObfuscationReplacerFactory } from '../../types/container/TObfuscationReplacerFactory';
|
||||
|
||||
import { IOptions } from '../../interfaces/options/IOptions';
|
||||
import { IObfuscationReplacer } from '../../interfaces/node-transformers/IObfuscationReplacer';
|
||||
import { IObfuscationReplacerWithStorage } from '../../interfaces/node-transformers/IObfuscationReplacerWithStorage';
|
||||
import { IVisitor } from '../../interfaces/IVisitor';
|
||||
|
||||
import { NodeObfuscatorsReplacers } from '../../enums/container/NodeObfuscationReplacers';
|
||||
import { ObfuscationReplacers } from '../../enums/container/ObfuscationReplacers';
|
||||
|
||||
import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
|
||||
import { Node } from '../../node/Node';
|
||||
@@ -30,16 +31,16 @@ export class CatchClauseTransformer extends AbstractNodeTransformer {
|
||||
private readonly identifierReplacer: IObfuscationReplacerWithStorage;
|
||||
|
||||
/**
|
||||
* @param replacersFactory
|
||||
* @param obfuscationReplacerFactory
|
||||
* @param options
|
||||
*/
|
||||
constructor (
|
||||
@inject(ServiceIdentifiers.Factory__IObfuscatorReplacer) replacersFactory: (replacer: NodeObfuscatorsReplacers) => IObfuscationReplacer,
|
||||
@inject(ServiceIdentifiers.Factory__IObfuscationReplacer) obfuscationReplacerFactory: TObfuscationReplacerFactory,
|
||||
@inject(ServiceIdentifiers.IOptions) options: IOptions
|
||||
) {
|
||||
super(options);
|
||||
|
||||
this.identifierReplacer = <IObfuscationReplacerWithStorage>replacersFactory(NodeObfuscatorsReplacers.IdentifierReplacer);
|
||||
this.identifierReplacer = <IObfuscationReplacerWithStorage>obfuscationReplacerFactory(ObfuscationReplacers.IdentifierReplacer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,13 +5,13 @@ import * as estraverse from 'estraverse';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { TNodeWithBlockStatement } from '../../types/node/TNodeWithBlockStatement';
|
||||
import { TObfuscationReplacerFactory } from '../../types/container/TObfuscationReplacerFactory';
|
||||
|
||||
import { IOptions } from '../../interfaces/options/IOptions';
|
||||
import { IObfuscationReplacer } from '../../interfaces/node-transformers/IObfuscationReplacer';
|
||||
import { IObfuscationReplacerWithStorage } from '../../interfaces/node-transformers/IObfuscationReplacerWithStorage';
|
||||
import { IVisitor } from '../../interfaces/IVisitor';
|
||||
|
||||
import { NodeObfuscatorsReplacers } from '../../enums/container/NodeObfuscationReplacers';
|
||||
import { ObfuscationReplacers } from '../../enums/container/ObfuscationReplacers';
|
||||
import { NodeType } from '../../enums/NodeType';
|
||||
|
||||
import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
|
||||
@@ -40,16 +40,16 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
|
||||
private readonly replaceableIdentifiers: Map <ESTree.Node, ESTree.Identifier[]> = new Map();
|
||||
|
||||
/**
|
||||
* @param nodeObfuscatorsReplacersFactory
|
||||
* @param obfuscationReplacerFactory
|
||||
* @param options
|
||||
*/
|
||||
constructor (
|
||||
@inject(ServiceIdentifiers.Factory__IObfuscatorReplacer) nodeObfuscatorsReplacersFactory: (replacer: NodeObfuscatorsReplacers) => IObfuscationReplacer,
|
||||
@inject(ServiceIdentifiers.Factory__IObfuscationReplacer) obfuscationReplacerFactory: TObfuscationReplacerFactory,
|
||||
@inject(ServiceIdentifiers.IOptions) options: IOptions
|
||||
) {
|
||||
super(options);
|
||||
|
||||
this.identifierReplacer = <IObfuscationReplacerWithStorage>nodeObfuscatorsReplacersFactory(NodeObfuscatorsReplacers.IdentifierReplacer);
|
||||
this.identifierReplacer = <IObfuscationReplacerWithStorage>obfuscationReplacerFactory(ObfuscationReplacers.IdentifierReplacer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,13 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
|
||||
}
|
||||
|
||||
this.storeFunctionName(functionDeclarationNode, nodeIdentifier);
|
||||
this.replaceFunctionName(blockScopeOfFunctionDeclarationNode, nodeIdentifier);
|
||||
|
||||
// check for cached identifiers for current scope node. If exist - loop through them.
|
||||
if (this.replaceableIdentifiers.has(blockScopeOfFunctionDeclarationNode)) {
|
||||
this.replaceScopeCachedIdentifiers(blockScopeOfFunctionDeclarationNode, nodeIdentifier);
|
||||
} else {
|
||||
this.replaceScopeIdentifiers(blockScopeOfFunctionDeclarationNode, nodeIdentifier);
|
||||
}
|
||||
|
||||
return functionDeclarationNode;
|
||||
}
|
||||
@@ -97,21 +103,20 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
|
||||
* @param scopeNode
|
||||
* @param nodeIdentifier
|
||||
*/
|
||||
private replaceFunctionName (scopeNode: ESTree.Node, nodeIdentifier: number): void {
|
||||
let replaceableIdentifiersForCurrentScope: ESTree.Identifier[];
|
||||
private replaceScopeCachedIdentifiers (scopeNode: ESTree.Node, nodeIdentifier: number): void {
|
||||
const cachedReplaceableIdentifiers: ESTree.Identifier[] = <ESTree.Identifier[]>this.replaceableIdentifiers.get(scopeNode);
|
||||
|
||||
// check for cached identifiers for current scope node. If exist - loop through them.
|
||||
if (this.replaceableIdentifiers.has(scopeNode)) {
|
||||
replaceableIdentifiersForCurrentScope = <ESTree.Identifier[]>this.replaceableIdentifiers.get(scopeNode);
|
||||
cachedReplaceableIdentifiers.forEach((replaceableIdentifier: ESTree.Identifier) => {
|
||||
replaceableIdentifier.name = this.identifierReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
|
||||
});
|
||||
}
|
||||
|
||||
replaceableIdentifiersForCurrentScope.forEach((replaceableIdentifier: ESTree.Identifier) => {
|
||||
replaceableIdentifier.name = this.identifierReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
replaceableIdentifiersForCurrentScope = [];
|
||||
/**
|
||||
* @param scopeNode
|
||||
* @param nodeIdentifier
|
||||
*/
|
||||
private replaceScopeIdentifiers (scopeNode: ESTree.Node, nodeIdentifier: number): void {
|
||||
const storedReplaceableIdentifiers: ESTree.Identifier[] = [];
|
||||
|
||||
estraverse.replace(scopeNode, {
|
||||
enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
|
||||
@@ -121,12 +126,12 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
|
||||
if (node.name !== newNodeName) {
|
||||
node.name = newNodeName;
|
||||
} else {
|
||||
replaceableIdentifiersForCurrentScope.push(node);
|
||||
storedReplaceableIdentifiers.push(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.replaceableIdentifiers.set(scopeNode, replaceableIdentifiersForCurrentScope);
|
||||
this.replaceableIdentifiers.set(scopeNode, storedReplaceableIdentifiers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
|
||||
import * as estraverse from 'estraverse';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { TObfuscationReplacerFactory } from '../../types/container/TObfuscationReplacerFactory';
|
||||
|
||||
import { IOptions } from '../../interfaces/options/IOptions';
|
||||
import { IObfuscationReplacer } from '../../interfaces/node-transformers/IObfuscationReplacer';
|
||||
import { IObfuscationReplacerWithStorage } from '../../interfaces/node-transformers/IObfuscationReplacerWithStorage';
|
||||
import { IVisitor } from '../../interfaces/IVisitor';
|
||||
|
||||
import { NodeObfuscatorsReplacers } from '../../enums/container/NodeObfuscationReplacers';
|
||||
import { ObfuscationReplacers } from '../../enums/container/ObfuscationReplacers';
|
||||
|
||||
import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
|
||||
import { Node } from '../../node/Node';
|
||||
@@ -30,16 +31,16 @@ export class FunctionTransformer extends AbstractNodeTransformer {
|
||||
private readonly identifierReplacer: IObfuscationReplacerWithStorage;
|
||||
|
||||
/**
|
||||
* @param nodeObfuscatorsReplacersFactory
|
||||
* @param obfuscationReplacerFactory
|
||||
* @param options
|
||||
*/
|
||||
constructor (
|
||||
@inject(ServiceIdentifiers.Factory__IObfuscatorReplacer) nodeObfuscatorsReplacersFactory: (replacer: NodeObfuscatorsReplacers) => IObfuscationReplacer,
|
||||
@inject(ServiceIdentifiers.Factory__IObfuscationReplacer) obfuscationReplacerFactory: TObfuscationReplacerFactory,
|
||||
@inject(ServiceIdentifiers.IOptions) options: IOptions
|
||||
) {
|
||||
super(options);
|
||||
|
||||
this.identifierReplacer = <IObfuscationReplacerWithStorage>nodeObfuscatorsReplacersFactory(NodeObfuscatorsReplacers.IdentifierReplacer);
|
||||
this.identifierReplacer = <IObfuscationReplacerWithStorage>obfuscationReplacerFactory(ObfuscationReplacers.IdentifierReplacer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,12 +4,13 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
|
||||
import * as estraverse from 'estraverse';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { TObfuscationReplacerFactory } from '../../types/container/TObfuscationReplacerFactory';
|
||||
|
||||
import { IOptions } from '../../interfaces/options/IOptions';
|
||||
import { IObfuscationReplacer } from '../../interfaces/node-transformers/IObfuscationReplacer';
|
||||
import { IObfuscationReplacerWithStorage } from '../../interfaces/node-transformers/IObfuscationReplacerWithStorage';
|
||||
import { IVisitor } from '../../interfaces/IVisitor';
|
||||
|
||||
import { NodeObfuscatorsReplacers } from '../../enums/container/NodeObfuscationReplacers';
|
||||
import { ObfuscationReplacers } from '../../enums/container/ObfuscationReplacers';
|
||||
|
||||
import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
|
||||
import { Node } from '../../node/Node';
|
||||
@@ -38,16 +39,16 @@ export class LabeledStatementTransformer extends AbstractNodeTransformer {
|
||||
private readonly identifierReplacer: IObfuscationReplacerWithStorage;
|
||||
|
||||
/**
|
||||
* @param nodeObfuscatorsReplacersFactory
|
||||
* @param obfuscationReplacerFactory
|
||||
* @param options
|
||||
*/
|
||||
constructor (
|
||||
@inject(ServiceIdentifiers.Factory__IObfuscatorReplacer) nodeObfuscatorsReplacersFactory: (replacer: NodeObfuscatorsReplacers) => IObfuscationReplacer,
|
||||
@inject(ServiceIdentifiers.Factory__IObfuscationReplacer) obfuscationReplacerFactory: TObfuscationReplacerFactory,
|
||||
@inject(ServiceIdentifiers.IOptions) options: IOptions
|
||||
) {
|
||||
super(options);
|
||||
|
||||
this.identifierReplacer = <IObfuscationReplacerWithStorage>nodeObfuscatorsReplacersFactory(NodeObfuscatorsReplacers.IdentifierReplacer);
|
||||
this.identifierReplacer = <IObfuscationReplacerWithStorage>obfuscationReplacerFactory(ObfuscationReplacers.IdentifierReplacer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,11 +4,12 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
|
||||
import * as escodegen from 'escodegen';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { TObfuscationReplacerFactory } from '../../types/container/TObfuscationReplacerFactory';
|
||||
|
||||
import { IOptions } from '../../interfaces/options/IOptions';
|
||||
import { IObfuscationReplacer } from '../../interfaces/node-transformers/IObfuscationReplacer';
|
||||
import { IVisitor } from '../../interfaces/IVisitor';
|
||||
|
||||
import { NodeObfuscatorsReplacers } from '../../enums/container/NodeObfuscationReplacers';
|
||||
import { ObfuscationReplacers } from '../../enums/container/ObfuscationReplacers';
|
||||
|
||||
import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
|
||||
import { Node } from '../../node/Node';
|
||||
@@ -16,21 +17,21 @@ import { Node } from '../../node/Node';
|
||||
@injectable()
|
||||
export class LiteralTransformer extends AbstractNodeTransformer {
|
||||
/**
|
||||
* @type {(replacer: NodeObfuscatorsReplacers) => IObfuscationReplacer}
|
||||
* @type {TObfuscationReplacerFactory}
|
||||
*/
|
||||
private readonly replacersFactory: (replacer: NodeObfuscatorsReplacers) => IObfuscationReplacer;
|
||||
private readonly obfuscationReplacerFactory: TObfuscationReplacerFactory;
|
||||
|
||||
/**
|
||||
* @param replacersFactory
|
||||
* @param obfuscationReplacerFactory
|
||||
* @param options
|
||||
*/
|
||||
constructor (
|
||||
@inject(ServiceIdentifiers.Factory__IObfuscatorReplacer) replacersFactory: (replacer: NodeObfuscatorsReplacers) => IObfuscationReplacer,
|
||||
@inject(ServiceIdentifiers.Factory__IObfuscationReplacer) obfuscationReplacerFactory: TObfuscationReplacerFactory,
|
||||
@inject(ServiceIdentifiers.IOptions) options: IOptions
|
||||
) {
|
||||
super(options);
|
||||
|
||||
this.replacersFactory = replacersFactory;
|
||||
this.obfuscationReplacerFactory = obfuscationReplacerFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,19 +61,19 @@ export class LiteralTransformer extends AbstractNodeTransformer {
|
||||
|
||||
switch (typeof literalNode.value) {
|
||||
case 'boolean':
|
||||
content = this.replacersFactory(NodeObfuscatorsReplacers.BooleanReplacer)
|
||||
content = this.obfuscationReplacerFactory(ObfuscationReplacers.BooleanReplacer)
|
||||
.replace(<boolean>literalNode.value);
|
||||
|
||||
break;
|
||||
|
||||
case 'number':
|
||||
content = this.replacersFactory(NodeObfuscatorsReplacers.NumberLiteralReplacer)
|
||||
content = this.obfuscationReplacerFactory(ObfuscationReplacers.NumberLiteralReplacer)
|
||||
.replace(<number>literalNode.value);
|
||||
|
||||
break;
|
||||
|
||||
case 'string':
|
||||
content = this.replacersFactory(NodeObfuscatorsReplacers.StringLiteralReplacer)
|
||||
content = this.obfuscationReplacerFactory(ObfuscationReplacers.StringLiteralReplacer)
|
||||
.replace(<string>literalNode.value);
|
||||
|
||||
break;
|
||||
|
||||
@@ -5,13 +5,13 @@ import * as estraverse from 'estraverse';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { TNodeWithBlockStatement } from '../../types/node/TNodeWithBlockStatement';
|
||||
import { TObfuscationReplacerFactory } from '../../types/container/TObfuscationReplacerFactory';
|
||||
|
||||
import { IOptions } from '../../interfaces/options/IOptions';
|
||||
import { IObfuscationReplacer } from '../../interfaces/node-transformers/IObfuscationReplacer';
|
||||
import { IObfuscationReplacerWithStorage } from '../../interfaces/node-transformers/IObfuscationReplacerWithStorage';
|
||||
import { IVisitor } from '../../interfaces/IVisitor';
|
||||
|
||||
import { NodeObfuscatorsReplacers } from '../../enums/container/NodeObfuscationReplacers';
|
||||
import { ObfuscationReplacers } from '../../enums/container/ObfuscationReplacers';
|
||||
import { NodeType } from '../../enums/NodeType';
|
||||
|
||||
import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
|
||||
@@ -41,16 +41,16 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
|
||||
private readonly replaceableIdentifiers: Map <ESTree.Node, ESTree.Identifier[]> = new Map();
|
||||
|
||||
/**
|
||||
* @param replacersFactory
|
||||
* @param obfuscationReplacerFactory
|
||||
* @param options
|
||||
*/
|
||||
constructor (
|
||||
@inject(ServiceIdentifiers.Factory__IObfuscatorReplacer) replacersFactory: (replacer: NodeObfuscatorsReplacers) => IObfuscationReplacer,
|
||||
@inject(ServiceIdentifiers.Factory__IObfuscationReplacer) obfuscationReplacerFactory: TObfuscationReplacerFactory,
|
||||
@inject(ServiceIdentifiers.IOptions) options: IOptions
|
||||
) {
|
||||
super(options);
|
||||
|
||||
this.identifierReplacer = <IObfuscationReplacerWithStorage>replacersFactory(NodeObfuscatorsReplacers.IdentifierReplacer);
|
||||
this.identifierReplacer = <IObfuscationReplacerWithStorage>obfuscationReplacerFactory(ObfuscationReplacers.IdentifierReplacer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +85,13 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
|
||||
: parentNode;
|
||||
|
||||
this.storeVariableNames(variableDeclarationNode, nodeIdentifier);
|
||||
this.replaceVariableNames(scopeNode, nodeIdentifier);
|
||||
|
||||
// check for cached identifiers for current scope node. If exist - loop through them.
|
||||
if (this.replaceableIdentifiers.has(scopeNode)) {
|
||||
this.replaceScopeCachedIdentifiers(scopeNode, nodeIdentifier);
|
||||
} else {
|
||||
this.replaceScopeIdentifiers(scopeNode, nodeIdentifier);
|
||||
}
|
||||
|
||||
return variableDeclarationNode;
|
||||
}
|
||||
@@ -111,21 +117,20 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
|
||||
* @param scopeNode
|
||||
* @param nodeIdentifier
|
||||
*/
|
||||
private replaceVariableNames (scopeNode: ESTree.Node, nodeIdentifier: number): void {
|
||||
let replaceableIdentifiersForCurrentScope: ESTree.Identifier[];
|
||||
private replaceScopeCachedIdentifiers (scopeNode: ESTree.Node, nodeIdentifier: number): void {
|
||||
const cachedReplaceableIdentifiers: ESTree.Identifier[] = <ESTree.Identifier[]>this.replaceableIdentifiers.get(scopeNode);
|
||||
|
||||
// check for cached identifiers for current scope node. If exist - loop through them.
|
||||
if (this.replaceableIdentifiers.has(scopeNode)) {
|
||||
replaceableIdentifiersForCurrentScope = <ESTree.Identifier[]>this.replaceableIdentifiers.get(scopeNode);
|
||||
cachedReplaceableIdentifiers.forEach((replaceableIdentifier: ESTree.Identifier) => {
|
||||
replaceableIdentifier.name = this.identifierReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
|
||||
});
|
||||
}
|
||||
|
||||
replaceableIdentifiersForCurrentScope.forEach((replaceableIdentifier: ESTree.Identifier) => {
|
||||
replaceableIdentifier.name = this.identifierReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
replaceableIdentifiersForCurrentScope = [];
|
||||
/**
|
||||
* @param scopeNode
|
||||
* @param nodeIdentifier
|
||||
*/
|
||||
private replaceScopeIdentifiers (scopeNode: ESTree.Node, nodeIdentifier: number): void {
|
||||
const storedReplaceableIdentifiers: ESTree.Identifier[] = [];
|
||||
|
||||
estraverse.replace(scopeNode, {
|
||||
enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
|
||||
@@ -135,12 +140,12 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
|
||||
if (node.name !== newNodeName) {
|
||||
node.name = newNodeName;
|
||||
} else {
|
||||
replaceableIdentifiersForCurrentScope.push(node);
|
||||
storedReplaceableIdentifiers.push(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.replaceableIdentifiers.set(scopeNode, replaceableIdentifiersForCurrentScope);
|
||||
this.replaceableIdentifiers.set(scopeNode, storedReplaceableIdentifiers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
|
||||
import * as estraverse from 'estraverse';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { TCalleeDataExtractorsFactory } from '../types/container/TCalleeDataExtractorsFactory';
|
||||
import { TCalleeDataExtractorFactory } from '../types/container/TCalleeDataExtractorFactory';
|
||||
|
||||
import { ICalleeData } from '../interfaces/stack-trace-analyzer/ICalleeData';
|
||||
import { ICalleeDataExtractor } from '../interfaces/stack-trace-analyzer/ICalleeDataExtractor';
|
||||
@@ -71,12 +71,12 @@ export class StackTraceAnalyzer implements IStackTraceAnalyzer {
|
||||
/**
|
||||
* @type {(calleeDataExtractorName: CalleeDataExtractors) => ICalleeDataExtractor}
|
||||
*/
|
||||
private calleeDataExtractorsFactory: (calleeDataExtractorName: CalleeDataExtractors) => ICalleeDataExtractor;
|
||||
private calleeDataExtractorFactory: (calleeDataExtractorName: CalleeDataExtractors) => ICalleeDataExtractor;
|
||||
|
||||
constructor (
|
||||
@inject(ServiceIdentifiers.Factory__ICalleeDataExtractor) calleeDataExtractorsFactory: TCalleeDataExtractorsFactory
|
||||
@inject(ServiceIdentifiers.Factory__ICalleeDataExtractor) calleeDataExtractorFactory: TCalleeDataExtractorFactory
|
||||
) {
|
||||
this.calleeDataExtractorsFactory = calleeDataExtractorsFactory;
|
||||
this.calleeDataExtractorFactory = calleeDataExtractorFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ export class StackTraceAnalyzer implements IStackTraceAnalyzer {
|
||||
callExpressionNode: ESTree.CallExpression
|
||||
): void {
|
||||
StackTraceAnalyzer.calleeDataExtractorsList.forEach((calleeDataExtractorName: CalleeDataExtractors) => {
|
||||
const calleeData: ICalleeData | null = this.calleeDataExtractorsFactory(calleeDataExtractorName)
|
||||
const calleeData: ICalleeData | null = this.calleeDataExtractorFactory(calleeDataExtractorName)
|
||||
.extract(blockScopeBody, callExpressionNode.callee);
|
||||
|
||||
if (!calleeData) {
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@ import { ICalleeDataExtractor } from '../../interfaces/stack-trace-analyzer/ICal
|
||||
|
||||
import { CalleeDataExtractors } from '../../enums/container/CalleeDataExtractors';
|
||||
|
||||
export type TCalleeDataExtractorsFactory = (calleeDataExtractorName: CalleeDataExtractors) => ICalleeDataExtractor;
|
||||
export type TCalleeDataExtractorFactory = (calleeDataExtractorName: CalleeDataExtractors) => ICalleeDataExtractor;
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { IControlFlowReplacer } from '../../interfaces/node-transformers/IControlFlowReplacer';
|
||||
|
||||
import { NodeControlFlowReplacers } from '../../enums/container/NodeControlFlowReplacers';
|
||||
import { ControlFlowReplacers } from '../../enums/container/ControlFlowReplacers';
|
||||
|
||||
export type TControlFlowReplacerFactory = (replacer: NodeControlFlowReplacers) => IControlFlowReplacer;
|
||||
export type TControlFlowReplacerFactory = (replacer: ControlFlowReplacers) => IControlFlowReplacer;
|
||||
|
||||
src/types/container/TNodeTransformersFactory.d.ts → src/types/container/TNodeTransformerFactory.d.ts
Vendored
+1
-1
@@ -2,4 +2,4 @@ import { INodeTransformer } from '../../interfaces/node-transformers/INodeTransf
|
||||
|
||||
import { NodeTransformers } from '../../enums/container/NodeTransformers';
|
||||
|
||||
export type TNodeTransformersFactory = (nodeTransformerName: NodeTransformers) => INodeTransformer;
|
||||
export type TNodeTransformerFactory = (nodeTransformerName: NodeTransformers) => INodeTransformer;
|
||||
@@ -0,0 +1,5 @@
|
||||
import { IObfuscationReplacer } from '../../interfaces/node-transformers/IObfuscationReplacer';
|
||||
|
||||
import { ObfuscationReplacers } from '../../enums/container/ObfuscationReplacers';
|
||||
|
||||
export type TObfuscationReplacerFactory = (replacer: ObfuscationReplacers) => IObfuscationReplacer;
|
||||
@@ -11,12 +11,17 @@ export class RandomGeneratorUtils {
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
public static readonly randomGeneratorPoolHexadecimal: string = 'abcdef0123456789';
|
||||
public static readonly randomGeneratorPoolNumbers: string = '0123456789';
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
public static readonly randomGeneratorPoolWithNumbers: string = `${RandomGeneratorUtils.randomGeneratorPool}0123456789`;
|
||||
public static readonly randomGeneratorPoolHexadecimal: string = `abcdef${RandomGeneratorUtils.randomGeneratorPoolNumbers}`;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
public static readonly randomGeneratorPoolWithNumbers: string = `${RandomGeneratorUtils.randomGeneratorPool}${RandomGeneratorUtils.randomGeneratorPoolNumbers}`;
|
||||
|
||||
/**
|
||||
* @type {Set<string>}
|
||||
|
||||
Reference in New Issue
Block a user