SpaceMIX v0.1.0 (latest)

Environment and identity

stablefor bothsince protocol 1

host.env and host.manifest: where the extension runs, who is signed in, which server it is, and the manifest it was installed with.

Two plain values, fixed for the life of the frame: host.env and host.manifest. Neither is a call; reading them never crosses the bridge.

interface SpacemixHost {
  env: HostEnv;
  manifest: ExtensionManifest;
}

interface HostEnv {
  desktop: boolean;
  platform: string;
  me: { id: string; name: string; email: string };
  serverName: string;
}

Permission: none.

host.env

  • desktop: true in the SpaceMIX desktop app (native file pickers, OS drag and drop), false in a browser.
  • platform: in the desktop app "macos", "windows", "linux", "ios" or "android", from the user agent; in a browser always "web".
  • me: the person signed in on this server: their user id (the ids host.notifications.people() and host.chat use), display name and email. All three are "" if the host couldn't tell.
  • serverName: the server's name as the server switcher shows it, "" if unknown.

Every person on the team who may use the extension runs their own copy of the frame, each with their own me (see Who can use an extension). Use me.id for "mine" filters, never as a security check: the host already acts as that person on every call.

React: useEnv() from @spacemix/sdk/react.

host.manifest

The manifest the host installed this extension with: the package's own manifest, except that permissions is the list that was approved on the server (by the owner, or a member with the server:extensions permission). While an update that asks for more waits for approval, permissions is the old list, and so are the optional namespaces on host (see index.md).

import { host } from "@spacemix/sdk";

export const canReachAnyHost = (): boolean => host.manifest.permissions.includes("net:*");

Call it from a function, not at module scope (see the import-time rule).

Stability

Stable. platform is a string so new platforms can be added; compare against the values above and have a default for anything else.

This page as markdown · All pages as one file