Client Mod Extension (JS/WASM)

The client mod now executes untrusted server-provided scripts using a JavaScript/WASM sandbox.

Architecture

Script Registration

SCRIPT_REGISTER body:

{
  "name": "example",
  "source": "...js source...",
  "kind": "js",
  "auto_start": true,
  "metadata": {"capabilities": ["logger.info", "event.tick"]}
}

For WASM:

{
  "name": "example",
  "kind": "wasm",
  "source": "<base64 wasm>",
  "metadata": {"capabilities": ["logger.info"]}
}

API

The wrapper provides pjb (and globals capability, print, log, request, client, Player, inventory, storage, menu, etc.).

Permissions

Permissions are enforced per capability call. Scripts can declare via pjb.capabilities([...]).

WASM ABI

Standalone WASM modules can import pjb functions; see wrapper for details. Host provides controlled imports only.