The pieces / weirdnet-schemes

weirdnet-schemes

The URL scheme registry: signed prefixes and schemes, the canonical list, a resolver, and OS handler registration.

v0.1.1 GitHub crates.io docs.rs weirdnet-schemes = "0.1.1"

What it brings

Make a weirdnet-<app>:// link mean the same thing on every device: which app owns a scheme, who published it, how to install it if it's missing, and how to register it with the OS. Every app registers a signed prefix; prefixes beginning with weirdnet are reserved for WeirdBrains, and the resolver never hands a link to a stranger's app without asking.

What it is

The registry every Weirdnet app shares, so a weirdnet-<app>:// link means the same thing on every device and to every app. Prefixes beginning with weirdnet are reserved for WeirdBrains.

How it works

  • Names (names): an app's schemes are its prefix or prefix-…. First-party apps use weirdnet-<app> (first_party("morph") is weirdnet-morph). Standard schemes (https, file, mailto, …) can't be claimed. weirdnet:// is internal only: never registered with the OS and never resolved to an app.
  • Records: a PrefixRecord and a SchemeRecord (scheme, prefix, app id, publisher key, display name, capabilities, install hints, seq, expiry, withdrawal), each signed by the publisher's Ed25519 key over its exact JSON. Reserved prefixes also carry the WeirdBrains root signature and appear only on the canonical list, which the root key signs as a whole. A prefix moves to a new publisher only with a transfer signature from the old one; the root key rotates by a record both keys sign.
  • Resolver (Registry): loads the canonical list, records from relays (later the DHT) and installed apps; refuses unsigned, stale, expired and withdrawn records and any weirdnet… claim not on the list. Resolution prefers the user's pin, then the canonical list, then an installed app whose publisher matches, and otherwise returns Resolution::Choose so the app asks the user. The registry serializes as the device's local cache.
  • Links (Link): <scheme>://join/<code>, <scheme>://answer/<code>, and <scheme>://<name or user id>/<path> for resources held by peers.
  • Install hints: Salty Gull, App Store, Google Play, F-Droid or an HTTPS page, filtered by Platform; shown, never acted on without the user.
  • OS registration (os): the Linux .desktop entry and xdg-mime defaults, per-user Windows registry keys (or a .reg file), CFBundleURLTypes for macOS and iOS, and the Android intent filter. All refuse weirdnet://.

The WeirdBrains root key is used through weirdnetctl; apps ship its public key as their trust anchor (TrustAnchors).

Key types and modules

  • names: prefix and scheme rules, reserved and standard schemes, first_party.
  • PrefixRecord, SchemeRecord, CanonicalList, RootRotation, TrustAnchors, Signed: signed records.
  • Registry, Resolution: the local resolver with pins and conflict rules.
  • Link, Action: join, answer and resource links.
  • os: Linux, Windows, Apple and Android handler registration.

Feature flags

None: everything is on by default.

Usage

In Cargo.toml:

[dependencies]
weirdnet-schemes = "0.1.1"

Then (built and run against the published crate when this page was made):

// First-party scheme names, the reserved prefix, and parsing an invite link.
use weirdnet_schemes::{Action, Link, names};

fn main() -> weirdnet_schemes::Result<()> {
    assert_eq!(names::first_party("morph"), "weirdnet-morph");
    assert!(names::is_reserved("weirdnet-morph")); // only on the WeirdBrains-signed list
    let link = Link::parse("weirdnet-morph://join/abc123")?;
    assert_eq!(link.action, Action::Join("abc123".into()));
    Ok(())
}

Where it fits

  • Used by Morph, weirdnetctl.
  • License: BSD-3-Clause.