mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
More complex object keys transformation + some string literal transformations refactoring
This commit is contained in:
@@ -228,6 +228,23 @@ export class NodeFactory {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {(ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[]} specifiers
|
||||
* @param {Literal} source
|
||||
* @returns {ImportDeclaration}
|
||||
*/
|
||||
public static importDeclarationNode (
|
||||
specifiers: (ESTree.ImportSpecifier | ESTree.ImportDefaultSpecifier | ESTree.ImportNamespaceSpecifier)[],
|
||||
source: ESTree.Literal
|
||||
): ESTree.ImportDeclaration {
|
||||
return {
|
||||
type: NodeType.ImportDeclaration,
|
||||
specifiers,
|
||||
source,
|
||||
metadata: { ignoredNode: false }
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean | number | string} value
|
||||
* @param {string} raw
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { NodeGuards } from './NodeGuards';
|
||||
|
||||
export class NodeLiteralUtils {
|
||||
/**
|
||||
* @param {Literal} literalNode
|
||||
* @param {Node} parentNode
|
||||
* @returns {boolean}
|
||||
*/
|
||||
public static isProhibitedLiteralNode (literalNode: ESTree.Literal, parentNode: ESTree.Node): boolean {
|
||||
if (NodeGuards.isPropertyNode(parentNode) && !parentNode.computed && parentNode.key === literalNode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (NodeGuards.isImportDeclarationNode(parentNode)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user