Skip to main content

Crate weirdnet_ext

Crate weirdnet_ext 

Source
Expand description

§weirdnet-ext

The Weirdnet extension host: what an app (such as Morph) needs to install and run third-party extensions safely.

  • Packages (package): a tar archive with manifest.json, manifest.sig and the files. The author’s Weirdnet user key (Ed25519) signs the exact manifest bytes; the manifest lists every file with its size and BLAKE3 hash. Opening a package checks all of it and refuses unlisted files, links, unsafe paths and oversized archives.
  • Install and update rules (Installer): one read-only directory per version; each extension id is pinned to its first author, so another key can’t take it over (not even after an uninstall); an update must be newer; Plan::new_capabilities lists what an update adds so the app can ask the user; every launch hashes the files again.
  • Grants (Grants): capabilities with optional * patterns, checked on every call; a revoked capability fails the next call.
  • Sandbox (sandbox): empty environment, own process group, resource limits, parent-death signal, and only the private socket inherited. Linux adds no_new_privs, Landlock (files limited to the package, the system libraries and the data directory; TCP denied; abstract Unix sockets and signals scoped on 6.12+) and a seccomp filter (no socket(), namespaces, mounts, ptrace, bpf, io_uring, keyrings, modules or terminal injection). macOS uses a deny-by-default sandbox-exec profile. Windows: not yet (WASM only). sandbox::probe reports what a machine gives; the default Require::Full refuses to run with less.
  • Supervisor (supervisor): starts the extension with a fresh socket pair and a one-time token, serves the broker (weirdnet.ext.v1.Host over gRPC), restarts crashes with backoff and gives up after repeated ones, stops idle extensions, and kills stuck ones after a grace period.
use std::sync::Arc;
use weirdnet_ext::{Config, Grants, Installer, NoServices, supervisor};

let installer = Installer::new("/home/me/.local/share/morph/extensions");
let plan = installer.inspect(&bytes)?;      // verify; show plan.new_capabilities to the user
let installed = installer.install(plan)?;
let grants = Grants(installed.manifest.capabilities.clone()); // what the user agreed to
let h = supervisor::start(Config::new("morph 0.5.0", installer, &installed.manifest.id,
    "/home/me/.local/share/morph/ext-data/reader", grants, Arc::new(NoServices)));
h.send("morph.ext.v1.PageLoaded", vec![]).await;
h.stop("quit").await;

Extensions are written with weirdnet-ext-sdk; the wire contract is weirdnet-ext-proto. BSD-3-Clause.

Re-exports§

pub use broker::CallContext;
pub use broker::Need;
pub use broker::NoServices;
pub use broker::Services;
pub use grants::Grants;
pub use manifest::Capability;
pub use manifest::Manifest;
pub use package::Installed;
pub use package::Installer;
pub use package::Package;
pub use package::Plan;
pub use sandbox::Policy;
pub use sandbox::Report;
pub use sandbox::Require;
pub use supervisor::Config;
pub use supervisor::Handle;
pub use supervisor::Status;
pub use weirdnet_ext_proto as proto;

Modules§

broker
The broker: the host side of weirdnet.ext.v1.Host for one extension session.
grants
What the user granted an extension, and checks against it.
manifest
Extension manifests and their signatures.
package
Packages: a tar archive with manifest.json, manifest.sig and the files under files/.
sandbox
The process sandbox for native extensions.
supervisor
The supervisor: starts an installed extension in the sandbox, serves the broker on a private socket pair, restarts it with backoff when it crashes, stops it when idle or asked, and passes events and grant changes to it.

Enums§

Error
Errors from the extension host.

Type Aliases§

Result
Result with Error.