# Host your app on Witbitz Witbitz can host your app's static site — HTML, JavaScript, CSS and assets — at `.witbitz.app`. You upload a built folder; Witbitz stores it, gives it the next version number, has its build enclave measure it, and serves it. Every version is a public, signed entry anyone can check, and your visitors get the same release cycle the Witbitz app has: Official, Beta and Pinned, never backwards. > See also: [Restricted keys](./sdk-builder.md#restricted-keys) (the `apps:release` capability) · [API reference](./api-reference.md) (`/v1/apps`) · > [Verify it](./verify.md) (what an attestation proves and does not). ## What it is, and what it is not - **Static files only.** No server code: an upload with `_worker.js`, `functions/` or `_routes.json` is refused, and so are `_headers` / `_redirects` — headers come from the platform — and the paths Witbitz serves itself (`b/`, `.well-known/`, `channels.json`). Your backend stays yours (and your app calls it under the Content Security Policy below). - **Your own origin.** Each app is on its own subdomain of `witbitz.app`, a domain apart from `witbitz.chat`: its own storage and service worker. Browsers still treat every `*.witbitz.app` app as one *site* — `witbitz.app` is not on the Public Suffix List yet — so one app can set cookies the others receive, and a request from one to another counts as same-site. Use `__Host-` cookies on `witbitz.app` (no other app can overwrite one). [Your own domain](#your-domain) gives your app a site of its own. - **What is proved is what was served.** A version's entry names the exact bytes Witbitz served for it. It does not prove what a browser then runs, and Witbitz does not review your code. **The free tier, per app:** an upload of at most 100 MB, 5,000 files and 25 MB a file; the 10 newest releases served as pins. ## Get the CLI One file, Node 22 or later: ``` curl -fsSLO https://app.witbitz.chat/downloads/witbitz-app.mjs node witbitz-app.mjs verify https://apphost-test.witbitz.app/ ``` Commands that change your app need your tenant's **secret key** (`wsk_…`) in `WITBITZ_SECRET_KEY`. `upload`, `reproduce`, `withdraw` and `status` also take a restricted key (`wrk_…`) with the `apps:release` capability; `create` and `domain` take the secret key only. `verify` and `log` need no key. ## Publish ``` export WITBITZ_SECRET_KEY=wsk_… node witbitz-app.mjs create com.acme.notes --label acme-notes --contact you@acme.example node witbitz-app.mjs upload com.acme.notes ./dist --wait ``` - **`create`** claims the app id and its address (`acme-notes.witbitz.app`). The contact is the email Witbitz writes to about the app (a takedown, for one); run `create` again with a new `--contact` to change it. The address is never changed. A few names are reserved (`www`, `api`, `login`, `admin`, `mail`, …, and any name containing `witbitz`). - **`upload`** sends the built folder. `index.html` is the entry page; a `witbitz.json` at the folder's root may name another (`{ "entry": "app.html", "fallback": "index.html" }` — the fallback answers any path that is not a file, for a single-page app). The build enclave hashes every file itself and signs the manifest it computed; only then is the version released and served. `--wait` follows it until it is. - **`withdraw `** retires one of your versions. It stops being served; its entry stays in the log. - **`log `** prints the app's public release log. - **`status []`** prints the app (its next version, the release in flight) or one release's state. A released version says whether it is served: `published` once it is, `publishError` when its publish failed — then `upload --wait` says "released, not served yet", and `POST /v1/apps/{app}/releases/{id}/publish` publishes it again. Each released version is also served at `/b//` (its build id); the newest one standing is **Official** at the root. ## Rebuilt from source ``` node witbitz-app.mjs reproduce com.acme.notes --build 'npm run build' --out dist [--commit ] [--wait] ``` - **What it does.** `reproduce` archives the commit's source and builds it on your machine as the version it will be. It then sends **both** the built folder and the source. A Witbitz enclave rebuilds the source with the same command, and the version is released only if its build is byte for byte the one you uploaded. Your visitors are then served your upload, now proven equal to a rebuild, and the log says **rebuilt from source** with the commit and the recipe. - **Your source is published.** The source is published with the version, at `/.well-known/witbitz-source/.tgz` on your app's address, so anyone can rebuild what runs. If your source stays private, use `upload`. - **Where the rebuild runs.** It runs in the **builder enclave**, a separate enclave image used only for builders' apps: - It is booted fresh for each release. - Your commands run as an unprivileged user with no way out of it except reading npm packages through a read-only proxy. They cannot publish, use credentials, or reach any other host. - Its verdicts are checked against its own published images, never the build enclave's. - **What the build may do.** - `npm ci --ignore-scripts`, then your command. - Dependencies come from the npm registry only, pinned by your lockfile. - Limits: 15 minutes, 2 GB of disk, 3 rebuilds a day per app (a failed rebuild counts). - A build that downloads anything else, or that gives different bytes each time it runs, is not released. ## Official, Beta and Pinned for your visitors Register the loader once, from your page: ```js navigator.serviceWorker.register('/witbitz-sw.js') ``` `/witbitz-sw.js` is served by Witbitz (a file of that name in your upload is not served). It gives each visitor's device: | choice | the device runs | |---|---| | **Official** (default) | the newest released version | | **Beta** | the build Witbitz published last — never one older than the release the device already ran. A version you withdraw is never Beta: Beta then runs the newest version still standing. Publishing an older version again does not move Beta back to it. A build is published only once it is released, so today Beta runs what Official runs | | **Pinned** | one released version the person chose — never one older than what the device already ran | **Never backwards:** a device never goes back to an older release than one it ran — except that a withdrawn version is never served. A page keeps the build it opened with until it reloads. Let people choose, from your own settings screen: ```js const ask = (msg) => new Promise((resolve) => { const ch = new MessageChannel() ch.port1.onmessage = (e) => resolve(e.data) navigator.serviceWorker.controller.postMessage({ witbitz: 'channel', ...msg }, [ch.port2]) }) const now = await ask({}) // { mode, pin, running: { version, build }, channels } const res = await ask({ set: { mode: 'pinned', pin: 4 } }) // { ok } — or { ok: false, error } (e.g. older than what ran) ``` A choice takes effect at the next page load. ## Headers your pages get Every file is served with a Content Security Policy whose floor you cannot remove: `default-src 'self'`, scripts from your own origin only (no inline script, no `unsafe-eval`), `connect-src 'self' https://api.witbitz.chat` plus the https origins your app record adds (to `connect-src`, `img-src`, `media-src`, `font-src`, `frame-src`; Witbitz sets them on request — an upload cannot), and no framing at all (`frame-ancestors 'none'`) unless your record names the sites that may. Also `nosniff`, HSTS and `Cross-Origin-Opener-Policy: same-origin`. Files under `/b//` are cached briefly and revalidated, so a withdrawal reaches browsers. ## Anyone can check a version ``` node witbitz-app.mjs verify https://acme-notes.witbitz.app/ [--files] ``` It checks, against what anyone can fetch: 1. the page's own entry (`/.well-known/witbitz-release.json`); 2. that entry in the app's **public log**, still standing — not withdrawn, not taken down; 3. the **build enclave's signed verdict** for it: the attestation to a published build-enclave image, the signature, and its Rekor transparency-log entry — and that it measured this app, this build and this version; 4. the **manifest** (`/.well-known/witbitz-manifest.json`): its SHA-256 is the build; 5. **the page at the URL you gave**: its bytes are the manifest's file; 6. with `--files`, every other file too. It accepts only addresses Witbitz serves — on `witbitz.app`, or [your own domain](#your-domain) once the app's log names it: there Witbitz answers every path, so the entry and the bytes are what Witbitz serves for that address. On your own domain the DNS is yours, so what it checks is what this fetch received. Two labels: **served as uploaded** (your exact bytes) and **rebuilt from source** (reproduced from a commit by the builder enclave). For a rebuilt version it also checks that the verdict is the builder enclave's, and that the source it was rebuilt from is public at the hash the log names. ## Your own domain {#your-domain} Your app can also be served at your own domain — `app.acme.com` — from the same releases, channels and log. On your domain it is a site of its own: no other builder's app shares its cookies or its reputation. ```sh node witbitz-app.mjs domain add com.acme.notes app.acme.com --wait ``` 1. It prints the records to add at your DNS provider: `app.acme.com CNAME custom.witbitz.app` (and a `TXT` record when asked), and waits. 2. Once your DNS points here, Witbitz gets a certificate for the name, and your app is live there — usually within minutes. The app's public log records it (`app-domain`), and `GET /v1/domains/app.acme.com` names your app. 3. Add the domain to your tenant's origins (`admin.origins.declare([...])`, [Your page origins](./sdk-builder.md#origins)) — the Witbitz services check the page's origin. `domain list ` shows each domain's state; `domain remove ` stops serving it. Up to 5 domains per app. Your DNS stays yours: Witbitz checks every 10 minutes that it still serves the name, and if it no longer does (you pointed it elsewhere), the log says so and the name is not served until it points here again. The headers are the same as on `witbitz.app`, except HSTS, which covers that one name (your subdomains are yours to decide). ## Takedowns You can withdraw your own versions at any time. Witbitz withdraws a version for abuse, legal or security reasons; that withdrawal is public in the log with its reason, blocks that build and the files it names for good, and is mailed to your contact. To report an app on witbitz.app: reports@witbitz.chat. ## The API The CLI is a thin client of `/v1/apps` ([API reference](./api-reference.md)): create an app, reserve an upload, submit it, follow the release, withdraw a version, manage your domains (`POST` / `GET /v1/apps/{app}/domains`, `DELETE /v1/apps/{app}/domains/{host}` — your secret key), publish again a released version whose publish failed (`POST /v1/apps/{app}/releases/{id}/publish` — your secret key), and three public reads — `GET /v1/apps/{app}/log` (the release log), `GET /v1/apps/{app}/verdicts?hash=` (a released version's signed verdict) and `GET /v1/domains/{host}` (which app a domain serves).