0xDocs 0x.limo

Docs / Native runtime

Permissions and grants

Coming

The native game manifest, every permission a game can request (network, storage, workers, audio, WebRTC, memory, experimental GPU, platform services), and how the player's approval becomes the game's grant.

A native game's manifest.json only requests capabilities. What the game actually gets is the intersection of that request and what the player approved. Anything not granted is denied and listed in the runtime's log at launch; a call that needs it fails (most trap, for example a TCP connect to an undeclared destination).

#The manifest

json
{
  "name": "My Game",
  "entry": {"name": "main", "path": "game.wasm", "sha256": "…", "size": 1234567},
  "assets": [
    {"name": "level1.bin", "path": "data/level1.bin", "sha256": "…", "size": 40960}
  ],
  "permissions": {
    "fetch": [{"prefix": "https://mygame-play.0x.limo/sites/mygame/3/"}],
    "tcp": ["game.example.com:7777"],
    "storage_mb": 32,
    "workers": 2,
    "audio": true,
    "rtc": true,
    "memory_mb": 1024,
    "gpu_experimental": false,
    "platform": {"appid": 1234, "domains": ["user", "entitlements", "stats", "cloud"]}
  },
  "display": {"present_mode": "fifo", "frame_latency": 1, "fps_cap": 0, "fullscreen": "borderless"}
}
FieldMeaning
nameThe game's display name.
entryThe module: name, path relative to the manifest URL, sha256 (hex), size in bytes.
assetsFiles the runtime downloads before sg_init and the game reads with sg_guest::asset(name). Each is verified against its SHA-256 and kept in a content-addressed cache, shared across games and versions.
permissionsWhat the game asks for (below). Unknown fields are rejected.
displayPresentation defaults (see Graphics). Bad values refuse the launch.

#Permissions

PermissionTypeWhat it allows
fetchlist of {prefix, tls?}HTTP(S) requests (sg_guest::Fetch) to URLs under each prefix. A prefix must end with /. tls is "system" (default, normal certificate checks) or "insecure-lan" (no certificate check, allowed only when every address the host resolves to is private or loopback, for self-signed LAN servers).
tcplist of "host:port"Non-blocking TCP streams (sg_guest::TcpStream) to exactly those destinations.
storage_mbintegerPersistent per-game key/value storage (sg_guest::kv) up to this many MiB. 0 means no storage.
workersintegerHow many worker instances the game may run (sg_guest::worker).
audioboolSound playback (sg_guest::audio).
rtcboolWebRTC data channels to other players, browsers included (sg_guest::rtc). The game carries the SDP itself.
memory_mbintegerLinear memory per instance in MiB. Default 512, at most 4096.
gpu_experimentalboolHardware ray queries and mesh shaders.
platform{appid, domains}0x platform services for app appid, in the listed domains (below).

A game that asks for nothing still runs. Without the player's approval (a direct launch with no grant), the runtime applies a default policy: 64 MiB of storage, 4 workers, audio, and no network, platform services or experimental GPU features.

#Platform services

platform gives the game the sg_platform_v1 import module, the native equivalent of the Steamworks APIs, served by the same core as Steamworks compatibility. It has 55 functions, 11 records and 17 events in 9 domains. Async calls return a request ID, and every completion arrives through one queue (event_next). Records and events are CBOR maps, so there is no struct packing to get wrong. Bindings exist for Rust (sg-platform-guest), C (sg_platform.h) and a source-compatible subset of the Steamworks C++ headers, so C++ Steamworks code can be recompiled to WebAssembly.

DomainCovers
eventsThe event queue (always included with any platform grant).
userThe signed-in account (ID, name, country, language, online) and auth tickets for your servers.
entitlementsOwnership of the app and its DLC, build ID, languages.
statsStats (int, float, average rate), achievements and progress, other users' stats.
leaderboardsFind or create, upload with details, download ranges.
cloudCloud saves (per user, synced; separate from storage_mb, which is per install).
lobbiesCreate, filtered search, join, leave, data, member data, chat, invites, owner and joinable.
netMessages to other players by SteamID, reliable or unreliable, with lanes.
uiui_open: trusted UI drawn by the host (store, purchase, invite, overlay), which a game cannot fake.

Calling a function of an undeclared domain traps. The guest never sees a credential: the host reads the 0x app's tokens, refreshes them and makes every platform call itself. A game cannot claim another app's identity: the approval is bound to the app ID, and a manifest that names a different one is refused.

#How approval works

  1. The 0x app reads the manifest and shows the player what the game asks for.
  2. The player approves (in the app, or 0x approve <game> --yes on the command line). The approval is stored for that game, bound to its manifest source and app ID.
  3. Each launch passes the approval to the runtime as --grants FILE, bound to that launch's manifest URL.
  4. The runtime grants the intersection. Anything the manifest asks for beyond the approval is denied and logged, and the game keeps running without it.

If a new version of the game asks for more, the player is asked again. During development, sg-runtime --trust-manifest (or SG_TRUST_MANIFEST=1) grants the manifest as written.

The player's own P2P setting applies on top of rtc: direct links on, relay-only (addresses kept private), or off.