Skip to content

Tablications โ€‹

A tablication is a sidebar tab app. You ship static files (HTML, JS, CSS, images). Canopi:

  • serves them from apps.canopi.live/<content hash>/
  • runs them in a sandboxed frame
  • gives them one narrow channel to Canopi: the canopi.tab bridge

The reference app is modules/page-notes in the SDK. It keeps private notes per page, shares public page notes and lists them.

json
{
  "manifestVersion": 2,
  "kind": "tablication",
  "id": "live.canopi.page-notes",
  "name": "Page notes",
  "version": "1.1.0",
  "description": "Private notes for the page you are on, and public page notes.",
  "author": { "name": "Canopi" },
  "permissions": ["page:context", "user:profile", "storage:module", "ui:badge", "tags:compose", "tags:read:page-note"],
  "tablication": {
    "tab": { "id": "page-notes-tab", "title": "Notes", "icon": "๐Ÿ“", "order": 60 },
    "entry": { "html": "index.html" },
    "contains": ["page-note"]
  }
}

The bundle โ€‹

  • Files:
    • Up to 50 files and 1.5 MB in total.
    • Paths use a-z A-Z 0-9 _ - / and an extension. No ...
    • Types: html, js, mjs, css, json, txt, svg, png, jpg, webp, woff2.
  • Content address: Canopi computes the bundle's sha256 from the files. The same files always give the same address, and a published bundle never changes.
  • Content policy on every file:
    default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:;
    font-src 'self'; connect-src <https:// + each network.connect host, or 'none'>; base-uri 'none';
    form-action 'none'; object-src 'none'
    Every response also starts with sandbox allow-scripts, so a bundle gets an opaque origin however it is opened. That rules out inline scripts and third-party scripts, and limits network access to the hosts you declared.
  • Availability: only published, enabled bundles are served. A disabled module's files answer 404.

The sandbox โ€‹

The frame has sandbox="allow-scripts", without allow-same-origin, plus referrerpolicy="no-referrer". It gets an opaque origin:

  • No Canopi access: no Canopi cookies, localStorage, session, or parent page DOM, and no credentials on any request.
  • Blocked navigation: top.location and parent.document throw.
  • Label: Canopi draws "<name> ยท App by <author>" above the frame.
  • Navigation closes the app: the bridge is handed to the frame's first document only. If the frame navigates away, Canopi closes the app; the person reopens the tab to start it again.
  • Kill switch: when the app is switched off, open frames are closed at once and every bridge call answers MODULE_DISABLED.

The bridge โ€‹

js
import { connect } from './tab-bridge.js'; // @canopi-sdk/tab-bridge; build-module.mjs copies it in

const canopi = await connect();               // waits for Canopi's init and private MessagePort
const me = await canopi.user.getProfile();    // { handle, name, avatarUrl } or null
const page = await canopi.page.getContext();  // { url, title } (cleaned URL)
canopi.page.onContextChange((ctx) => render(ctx));
await canopi.storage.set('draft', { text: 'hi' });
await canopi.tags.compose('page-note', { kind: 'note', note: 'Looks wrong' }); // opens the composer
const notes = await canopi.tags.list('page-note', { limit: 20, where: { kind: 'question' } });

Permissions โ€‹

CallNeeds
page.getContext(), page.onContextChange(cb)page:context
user.getProfile()user:profile (handle, name and avatar only)
storage.get(key?), storage.set(key, value)storage:module: JSON values, per module, 100 KB in total. set(key, null) deletes.
theme.get(), theme.onChange(cb)nothing
ui.setBadge(text | null)ui:badge (at most 4 characters on your tab)
ui.openTab(tabId)ui:openTab
tags.compose(tagType, data)tags:compose, and tagType must be in tablication.contains. Call it from a click or key press in your app (otherwise USER_ACTION_REQUIRED); BUSY while a composer is already open. It opens the Canopi composer pre-filled, and the person posts: the composer says where it posts, Post works only after a short delay, and Enter doesn't submit. Returns { opened: true }.
tags.list(tagType, { scope, where, orderBy, order, limit })tags:read:<tagType>. Runs as the viewer. scope is page (the default, the current page) or all. where takes up to 3 indexed fields. limit โ‰ค 50.

Failures reject with a BridgeError whose code is one of:

CodeMeaning
PERMISSION_DENIEDThe manifest doesn't grant the permission
BAD_REQUESTBad arguments
UNKNOWN_METHODNo such call
TOO_LARGEA message over 64 KB
QUOTA_EXCEEDEDStorage over 100 KB
RATE_LIMITEDMore than 50 calls per second
NOT_AVAILABLEThe host doesn't offer this call
USER_ACTION_REQUIREDtags.compose without a recent click or key press
BUSYA composer is already open
MODULE_DISABLEDThe app was switched off
HOST_ERRORCanopi couldn't complete the call; no details are given

The bridge never passes tokens, cookies or credentials. To call your own server, declare it in network.connect and use your own authentication.

Canopi โ€” Metaweb coordination layer for community-aware presence and messaging.