mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
0.12.2 release
This commit is contained in:
@@ -82,9 +82,9 @@ export class CLIUtils {
|
||||
|
||||
/**
|
||||
* @param {string} outputPath
|
||||
* @param {any} data
|
||||
* @param {string} data
|
||||
*/
|
||||
public static writeFile (outputPath: string, data: any): void {
|
||||
public static writeFile (outputPath: string, data: string): void {
|
||||
mkdirp.sync(path.dirname(outputPath));
|
||||
|
||||
fs.writeFileSync(outputPath, data, {
|
||||
|
||||
@@ -109,14 +109,41 @@ export class FunctionTransformer extends AbstractNodeTransformer {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Property[]} properties
|
||||
* @param {Set<string>} ignoredIdentifierNamesSet
|
||||
*/
|
||||
private addIdentifiersToIgnoredIdentifierNamesSet (
|
||||
properties: ESTree.Property[],
|
||||
ignoredIdentifierNamesSet: Set<string>
|
||||
): void {
|
||||
properties.forEach((property: ESTree.Property) => {
|
||||
if (!NodeGuards.isIdentifierNode(property.key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ignoredIdentifierNamesSet.add(property.key.name);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} functionNode
|
||||
* @param {number} nodeIdentifier
|
||||
*/
|
||||
private replaceFunctionParams (functionNode: ESTree.Function, nodeIdentifier: number): void {
|
||||
const ignoredIdentifierNamesSet: Set<string> = new Set();
|
||||
|
||||
const replaceVisitor: estraverse.Visitor = {
|
||||
enter: (node: ESTree.Node, parentNode: ESTree.Node | null): any => {
|
||||
if (parentNode && NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
|
||||
if (NodeGuards.isObjectPatternNode(node)) {
|
||||
this.addIdentifiersToIgnoredIdentifierNamesSet(node.properties, ignoredIdentifierNamesSet);
|
||||
}
|
||||
|
||||
if (
|
||||
parentNode &&
|
||||
NodeGuards.isReplaceableIdentifierNode(node, parentNode) &&
|
||||
!ignoredIdentifierNamesSet.has(node.name)
|
||||
) {
|
||||
const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
|
||||
const newIdentifierName: string = newIdentifier.name;
|
||||
|
||||
|
||||
@@ -221,7 +221,9 @@ export class NodeGuards {
|
||||
parentNode.property === node
|
||||
);
|
||||
|
||||
return !parentNodeIsPropertyNode && !parentNodeIsMemberExpressionNode && !NodeGuards.isLabelIdentifierNode(node, parentNode);
|
||||
return !parentNodeIsPropertyNode &&
|
||||
!parentNodeIsMemberExpressionNode &&
|
||||
!NodeGuards.isLabelIdentifierNode(node, parentNode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user