weirdnet-collab 0.1.0

Collaboration control for Weirdnet apps: project members and roles, signed allow and deny rules, owner consent grants, a decision with a reason chain, invites and a signed, mergeable audit log. App-agnostic: the app defines what a project, role and permission are.
Documentation
//! A host, an editor and a viewer; one decision with its reason chain.
use weirdnet_collab::*;
use weirdnet_contacts::UserId;
use weirdnet_net::Keypair;

fn main() {
    let roles = RoleTable::new()
        .role("host", RoleSpec::everything().inviting(&["editor", "viewer"]))
        .role("editor", RoleSpec::with(&["project.edit", "recording.listen"]).inviting(&["viewer"]))
        .role("viewer", RoleSpec::with(&["recording.listen"]))
        .with_host("host")
        .with_default_role("viewer");
    let host = Keypair::generate_ed25519();
    let mut project = Project::new("demo", &host, roles, 0).expect("project");

    let guest = Keypair::generate_ed25519();
    let spec = InviteSpec { role: RoleId::new("viewer"), to: None, expires_ms: 60_000, max_uses: Some(1), approval: Approval::Auto };
    let invite = project.create_invite(&host, spec, 1).expect("invite");
    project.redeem(&host, &invite.id, &UserId::of_keypair(&guest), 2).expect("join");

    let who = UserId::of_keypair(&guest);
    let why = project.decide(&who, &Permission::new("project.edit"), &Ctx::at(3));
    println!("{:?}", why.decision);
    for step in &why.chain {
        println!("  {step:?}");
    }
}