Permissions and grants
ComingThe 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
{
"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"}
}| Field | Meaning |
|---|---|
name | The game's display name. |
entry | The module: name, path relative to the manifest URL, sha256 (hex), size in bytes. |
assets | Files 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. |
permissions | What the game asks for (below). Unknown fields are rejected. |
display | Presentation defaults (see Graphics). Bad values refuse the launch. |
#Permissions
| Permission | Type | What it allows |
|---|---|---|
fetch | list 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). |
tcp | list of "host:port" | Non-blocking TCP streams (sg_guest::TcpStream) to exactly those destinations. |
storage_mb | integer | Persistent per-game key/value storage (sg_guest::kv) up to this many MiB. 0 means no storage. |
workers | integer | How many worker instances the game may run (sg_guest::worker). |
audio | bool | Sound playback (sg_guest::audio). |
rtc | bool | WebRTC data channels to other players, browsers included (sg_guest::rtc). The game carries the SDP itself. |
memory_mb | integer | Linear memory per instance in MiB. Default 512, at most 4096. |
gpu_experimental | bool | Hardware 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.
| Domain | Covers |
|---|---|
events | The event queue (always included with any platform grant). |
user | The signed-in account (ID, name, country, language, online) and auth tickets for your servers. |
entitlements | Ownership of the app and its DLC, build ID, languages. |
stats | Stats (int, float, average rate), achievements and progress, other users' stats. |
leaderboards | Find or create, upload with details, download ranges. |
cloud | Cloud saves (per user, synced; separate from storage_mb, which is per install). |
lobbies | Create, filtered search, join, leave, data, member data, chat, invites, owner and joinable. |
net | Messages to other players by SteamID, reliable or unreliable, with lanes. |
ui | ui_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
- The 0x app reads the manifest and shows the player what the game asks for.
- The player approves (in the app, or
0x approve <game> --yeson the command line). The approval is stored for that game, bound to its manifest source and app ID. - Each launch passes the approval to the runtime as
--grants FILE, bound to that launch's manifest URL. - 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.
