| Crates.io | otter-engine |
| lib.rs | otter-engine |
| version | 0.1.3 |
| created_at | 2026-01-15 12:37:50.909152+00 |
| updated_at | 2026-01-16 06:42:14.040019+00 |
| description | Otter JavaScript engine |
| homepage | https://github.com/octofhir/otter |
| repository | https://github.com/octofhir/otter |
| max_upload_size | |
| id | 2045478 |
| size | 132,039 |
ESM module loader and capability-based security for Otter.
otter-engine provides the module loading infrastructure for the Otter runtime:
Add to your Cargo.toml:
[dependencies]
otter-engine = "0.1"
use otter_engine::{ModuleLoader, ModuleGraph, LoaderConfig};
use std::sync::Arc;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = LoaderConfig::default();
let loader = Arc::new(ModuleLoader::new(config));
let mut graph = ModuleGraph::new(loader);
// Load a module and its dependencies
graph.load("file:///path/to/main.ts").await?;
// Get execution order (topologically sorted)
for url in graph.execution_order() {
println!("Execute: {}", url);
}
Ok(())
}
use otter_engine::{Capabilities, CapabilitiesBuilder};
use std::path::PathBuf;
let caps = CapabilitiesBuilder::new()
.allow_read([PathBuf::from("/app/src")])
.allow_net(["api.example.com".to_string()])
.allow_env(["NODE_ENV".to_string()])
.build();
// Check permissions
if caps.can_read("/app/src/main.ts") {
// allowed
}
// Or require permission (returns error if denied)
caps.require_net("api.example.com")?;
MIT