Skip to main content
API reference for the @enclave-vm/ast package.

Installation

JSAstValidator Class

Main AST validation class.

Constructor

Methods

validate(code)

Validate JavaScript code against the preset rules.
Returns: ValidationResult
Example:

PreScanner Class

Fast pre-scanning for DoS protection.

Constructor

Methods

scan(code)

Scan code for potential issues before parsing.
Returns: PreScanResult
Example:

Factory Functions

createAgentScriptPreset(options?)

Create the AgentScript validation preset.
Options:
Example:

createPreScannerConfig(preset)

Create pre-scanner configuration.
PreScannerConfig:

createSecurityRules()

Get all built-in security rules.

ValidationPreset

ValidationRule

Built-in Rules

Code Transformation

transformAgentScript(code, options)

Transform code for safe execution.
Options:
Example:

Custom Rules

Creating a Custom Rule

Using Custom Rules

Complete Example