Skip to content

gigamono/tera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tera

tera is a lean secure capability-based runtime for JavaScript. It is primarily designed for multi-tenant serverless environment but has uses in other contexts.

tera provides a small set of low-level permission-enabled APIs that you can get started with but it can also be extended with your own permission types and host API implementation.

There is currently no plan to strictly support web-compatible APIs or out-of-the-box typescript compilation. If need those functionalities, take a look at deno.

tera is based on deno core and inspired by deno runtime.

If you are looking to get started with the Gigamono framework, check the Gigamono repo.

Content

  1. Usage

Usage

You need to add tokio to your dependencies.

⚠️ The current API is subject to change. ⚠️
#[tokio::main]
async fn main() -> Result<()> {
    // Create permitted resources
    let allow_list = [FsPath::from("/examples/txt/**")];

    // Create permissions
    let permissions = Permissions::builder()
        .add_state(FsRoot::try_from(env!("CARGO_MANIFEST_DIR"))?)
        .add_permissions_with_allow_lists(&[
            (Fs::Open, &allow_list),
            (Fs::Read, &allow_list),
            (Fs::Write, &allow_list),
        ])?
        .build();

    // Create a new runtime.
    let mut runtime =
        Runtime::with_permissions(permissions, false, vec![], Default::default()).await?;

    // Get the code.
    let code = fs::read_to_string("examples/js/files.js")?;

    // Execute main module.
    runtime.execute_module("/examples/js/files.js", code).await
}

Check the examples folder for more examples.

About

A Lean Secure Runtime for JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published