Apps · tutorial

Build your first app.

Build a small Notes app that runs in the rumahl shell. You’ll sign and import a web package, use the bridge to expose search to other apps and check what happens when the user denies access.

25 minUpdated 26 November 2026Web runtime

Before starting, open the shell and sign in with the test account from the local setup guide.

What you will build

A web app called Notes with one screen. It runs in a sandboxed browser window that cannot read the shell session, provides a search capability to other apps and requests only the window permission it needs. The app is packaged, signed and imported through the platform API.

You do not need to publish this app to a store yet. The goal is to understand the full path from a folder to a running app.

PieceValue in this tutorial
App IDcom.example.notes
Runtimeweb with a web-asset entrypoint
Lifecycleon-demand
Permissioncom.rumahl.os.window, scope user-own
Capabilitycom.example.notes.search
HostingAssets published under the installation asset root

What you will learn

  • How a signed app package is structured.
  • How to sign a manifest and verify every payload file.
  • How the shell imports and launches an app.
  • How the bridge connects an app to the platform.
  • How permissions, denial and uninstall behave in practice.

Prerequisites

  • A running developer server, as described in local setup.
  • The rumahl source checkout with the package CLI available.
  • A terminal and a browser profile that trusts the development certificate.
  • No published npm package is required; the CLI runs from the repository.

Understand the three boundaries

The package boundary

An app is a signed directory. package.json is the manifest. The signature covers the exact manifest bytes, and every payload file is listed with a SHA-256 digest. The importer rejects unknown manifest fields rather than silently ignoring them.

The runtime boundary

A web app is served from an isolated app origin and launched inside <iframe sandbox="allow-scripts"> without allow-same-origin. It has an opaque origin, no shell session token and no broad platform bearer credential.

The authority boundary

The shell asks the platform to launch the app. Rust re-reads the live account, session, installation and grants. A lease is short-lived, bound to one session and installation, and cannot authorize a shell API call or an arbitrary file.

Signed packagemanifest + SHA-256 payload
Importverify, publish, install
Launchaccount + grants + lease
Bridgedeclared methods only

1. Create the package

Start with a clean directory outside the shell source. The name of the folder is not the app identity; the manifest decides that.

shell
mkdir -p notes-app/dist/notes
cd notes-app
cat > dist/notes/index.html <<'HTML'
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Notes</title>
    <link rel="stylesheet" href="./style.css" />
  </head>
  <body>
    <main class="notes">
      <header><h1>Notes</h1><p>Local notes, one window.</p></header>
      <ul id="notes"></ul>
    </main>
    <script type="module" src="./main.js"></script>
  </body>
</html>
HTML

cat > dist/notes/style.css <<'CSS'
body {
  margin: 0;
  font: 16px/1.6 system-ui, sans-serif;
  background: #f6f8f5;
  color: #18201c;
}
.notes { max-width: 38rem; margin: 3rem auto; padding: 0 1.25rem; }
.notes ul { padding-left: 1.1rem; }
CSS

Keep every URL relative. The app is served under a lease path, not at the host root, and navigation must not assume a fixed mount point. The tutorial keeps the package at dist/notes/ so the signing command and the manifest refer to the same root.

2. Write the manifest

The manifest is the contract. It declares the app identity, runtime, entrypoint, lifecycle, requested permissions and the settings the app can persist.

dist/notes/package.json
{
  "formatVersion": 1,
  "publisherId": "com.example",
  "app": {
    "appId": "com.example.notes",
    "version": "0.1.0",
    "displayName": "Notes",
    "runtime": {
      "kind": "web",
      "entrypoints": [
        { "id": "main", "kind": "web-asset", "path": "index.html" }
      ]
    },
    "lifecycle": "on-demand",
    "permissions": [
      {
        "id": "com.rumahl.os.window",
        "scope": "user-own",
        "required": true,
        "reason": "Control its own window"
      }
    ],
    "providedCapabilities": ["com.example.notes.search"],
    "settings": [
      {
        "key": "notes.title",
        "title": "Window title",
        "type": "text",
        "required": false
      }
    ]
  },
  "files": [
    { "path": "index.html", "size": 512, "sha256": "<hex digest>" },
    { "path": "style.css", "size": 420, "sha256": "<hex digest>" },
    { "path": "main.js", "size": 1300, "sha256": "<hex digest>" }
  ]
}

What each field means

FieldWhy it exists
formatVersionAllows the package format to evolve without ambiguity.
publisherIdStable publisher identity used by the trust store.
appIdStable app identity. A new installation ID does not silently inherit old data.
runtime.kindSelects the hosting and isolation model. This tutorial uses web.
entrypointsDeclares which paths the host may publish and serve.
permissionsRequests a capability; it does not grant it.
providedCapabilitiesNames the operations this app can serve to other apps.

3. Add the app logic

The app must not fetch the shell API with a session cookie it does not have. It talks through the bridge, and the platform decides what the app is allowed to do.

dist/notes/main.js
import { connectRumahlBridge } from "@rumahl/bridge-client";

const rumahl = connectRumahlBridge();
await rumahl.ready();

const notes = [
  { id: '1', title: 'Buy oats', body: 'The good ones, not the dust.' },
  { id: '2', title: 'Water the monstera', body: 'Every second Tuesday.' }
];

// Publish a capability. The platform decides whether a caller may invoke it.
rumahl.provide('com.example.notes.search', async (invocation) => {
  const query = String(invocation.resource?.key ?? '').toLowerCase();
  return notes
    .filter((note) => `${note.title} ${note.body}`.toLowerCase().includes(query))
    .map((note) => ({ id: note.id, title: note.title }));
});

The client is framework-agnostic and safe outside rumahl OS: when there is no parent shell, available is false and calls reject. It performs the hello/welcome handshake before exposing typed helpers.

Keep the return shape of a capability stable and document it with the app. A caller receives the result through the platform, not through a direct app-to-app channel.

4. Sign and verify

Signing is a build step, not a runtime step. The private key belongs in a keystore that is never published inside the app assets.

shell
cargo run -p rumahl-app-packages --bin rumahl-package -- keygen \
  --key-id example-1 \
  --publisher com.example \
  --keystore keys/example.json

cargo run -p rumahl-app-packages --bin rumahl-package -- sign \
  --package dist/notes \
  --manifest dist/notes/package.json \
  --keystore keys/example.json

cargo run -p rumahl-app-packages --bin rumahl-package -- verify \
  --package dist/notes \
  --trust-store trust.json

A successful verify proves the manifest bytes and every listed payload file are intact. It does not prove the app is safe, useful or compatible with the current OS build.

5. Import the package

Use a live shell session and the exact shell origin. The import endpoint is a mutating request and requires the same-origin check.

POST /api/v1/shell/apps/import
{
  "importVersion": 1,
  "files": [
    { "path": "package.json", "content": "<base64>" },
    { "path": "package.sig.json", "content": "<base64>" },
    { "path": "index.html", "content": "<base64>" },
    { "path": "main.js", "content": "<base64>" }
  ],
  "device": "<device-id>",
  "installOrigin": "store"
}

The import endpoint accepts a JSON envelope, not a raw archive. The shell sends the same verified files it received from a package document; the Rust importer checks the signature and every digest again. The request body is capped at 32 MiB.

The successful response contains the installation identity. Keep that value: launch, settings and data routes are scoped to the installation, not just the app ID.

6. Launch and connect

The shell obtains the session-filtered catalog and asks the platform to launch one installation.

HTTP
GET  /api/v1/shell/apps
POST /api/v1/shell/apps/{id}/launch

{
  "installationId": "6f18…a2"
}

The response includes a frame URL, a lease and a renewal interval. The lease expires quickly and is renewed while the window remains open. Losing renewal should close the frame and offer Retry, not reuse a stale URL.

bridge
// Inside the hosted app, the bridge is the only route to the shell.
// Methods are declared and capability-gated.
rumahl.provide('com.example.notes.search', async (invocation) => {
  return searchNotes(invocation);
});

7. Settings and local network access

Two resources make an app genuinely useful without giving it a socket: own settings and a brokered HTTP(S) request.

Settings

Declare com.rumahl.os.settings and a settings schema in the manifest. The platform stores values per installation. A secret value is write-only and encrypted at rest; the app never receives it back.

manifest excerpt
"permissions": [
  { "id": "com.rumahl.os.settings", "scope": "app-private", "required": true },
  { "id": "com.rumahl.os.network", "scope": "user-selected", "required": true }
],
"settings": [
  { "key": "ha.url", "title": "Home Assistant address", "type": "text", "required": true },
  { "key": "ha.token", "title": "Access token", "type": "secret", "required": true }
]

Network consent

The app never receives a cookie jar or a secret in plaintext. It asks the platform to make the request after the user approves the exact origin for that installation.

HTTP
GET  /api/v1/shell/apps/{id}/network/consent
PUT  /api/v1/shell/apps/{id}/network/consent
POST /api/v1/shell/apps/{id}/network/request

# a denied request returns 403 with a reason
{ "reason": "approval-required", "origin": "http://homeassistant.local:8123" }

8. Expose and invoke a capability

A capability is an operation, not a permission. First-party and third-party apps use the same contract.

bridge
const rumahl = connectRumahlBridge();
await rumahl.ready();

// Provider: register a handler inside the hosted app.
rumahl.provide('com.example.notes.search', async (invocation) => {
  return searchNotes(invocation);
});

// Caller: the shell authorizes and delivers it through the platform.
const result = await rumahl.invokeCapability('com.example.notes.search', {
  namespace: 'com.example.notes',
  kind: 'query',
  key: 'monstera'
});

Callers use the declared bridge method os.capabilities.invoke through invokeCapability. The shell delivers the request to the provider through the platform; apps never open a direct channel to each other.

The exact authorization is repeated by Rust. A caller that saw a button in the UI still needs a live account, installation and grant. A disabled UI state is not an authorization decision.

9. Test the boundaries

Test the app in the same order the platform checks it. A successful page load is the weakest possible signal.

CheckExpected result
Launch without permissionDenied, not a rendered app with a hidden button
Wrong or expired leaseFrame rejected; renewal or retry required
Unknown bridge methodRefused, never silently executed
Settings secret readNever returned as plaintext
Network request without consent403 with approval-required
UninstallGrants and consents are revoked; data follows the retention policy
A second accountSees only its own catalog, grants and settings

10. Publish checklist

  • The manifest contains no unknown fields and no secrets.
  • The signature verifies against the intended publisher trust store.
  • Every asset is public-only; no keystore, source map with secrets or local database is inside the payload.
  • The entrypoint works under a lease path and uses relative URLs.
  • Settings are validated against the manifest; required values are handled.
  • Network origins are narrow, explicit and revocable.
  • At least one denial path is tested for each permission.
  • The public store is store.rumahl.com; package downloads and updates resolve to github.com/rumahl/apps.
  • A certification program, a support promise and staged rollback policy are not released.

Where to go next