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 withmanifest.json,manifest.sigand 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_capabilitieslists 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 addsno_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 (nosocket(), namespaces, mounts,ptrace,bpf,io_uring, keyrings, modules or terminal injection). macOS uses a deny-by-defaultsandbox-execprofile. Windows: not yet (WASM only).sandbox::probereports what a machine gives; the defaultRequire::Fullrefuses to run with less. - Supervisor (
supervisor): starts the extension with a fresh socket pair and a one-time token, serves thebroker(weirdnet.ext.v1.Hostover 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.Hostfor 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.sigand the files underfiles/. - 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.