UNAVI Docs unavi.xyz
Build · Scripting API

wired:peer

Local identity and per-document authorship and physics authority.

A document's author is the DID owning its write key (fixed). Its holder is the peer currently driving its physics simulation (defaults to the author and can be transferred via take-hold and release-hold).

Interface identity

Uses did, error.

self-did

funcself-did: func() -> result<did, error>

Returns the local user's DID.

Interface authority

Uses did, error, document.

author

funcauthor: func(document: borrow<document>) -> result<option<did>, error>

Returns the author's DID for document, or none if unauthenticated.

holder

funcholder: func(document: borrow<document>) -> result<option<did>, error>

Returns the current holder's DID (the latest peer to call take-hold, or the author by default). Returns none outside a space.

is-author

funcis-author: func(document: borrow<document>) -> result<bool, error>

Returns whether the local user authored document.

is-holder

funcis-holder: func(document: borrow<document>) -> result<bool, error>

Returns whether this peer currently holds document.

take-hold

functake-hold: func(document: borrow<document>) -> result<_, error>

Claims physics authority for a writable document. The most recent claim takes precedence over earlier ones.

release-hold

funcrelease-hold: func(document: borrow<document>) -> result<_, error>

Releases this peer's hold, falling back to the next-most-recent holder or the author.

Source

/// Local identity and per-document authorship and physics authority.
///
/// A document's **author** is the DID owning its write key (fixed). Its
/// **holder** is the peer currently driving its physics simulation (defaults to
/// the author and can be transferred via `take-hold` and `release-hold`).
package wired:peer;

interface identity {
  use wired:core/ids.{did};
  use wired:core/error.{error};

  /// Returns the local user's DID.
  self-did: func() -> result<did, error>;
}

interface authority {
  use wired:core/ids.{did};
  use wired:core/error.{error};
  use wired:scene/document.{document};

  /// Returns the author's DID for `document`, or `none` if unauthenticated.
  author: func(document: borrow<document>) -> result<option<did>, error>;
  /// Returns the current holder's DID (the latest peer to call `take-hold`, or
  /// the author by default). Returns `none` outside a space.
  holder: func(document: borrow<document>) -> result<option<did>, error>;

  /// Returns whether the local user authored `document`.
  is-author: func(document: borrow<document>) -> result<bool, error>;
  /// Returns whether this peer currently holds `document`.
  is-holder: func(document: borrow<document>) -> result<bool, error>;

  /// Claims physics authority for a writable document. The most recent claim
  /// takes precedence over earlier ones.
  take-hold: func(document: borrow<document>) -> result<_, error>;
  /// Releases this peer's hold, falling back to the next-most-recent holder or
  /// the author.
  release-hold: func(document: borrow<document>) -> result<_, error>;
}