@botiverse/porthole 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -2
- package/THIRD_PARTY_NOTICES.md +421 -0
- package/dist/bridge/bounded-text.d.ts +34 -0
- package/dist/bridge/bounded-text.js +188 -0
- package/dist/bridge/bridge.d.ts +38 -5
- package/dist/bridge/bridge.js +469 -39
- package/dist/bridge/json-data.d.ts +28 -0
- package/dist/bridge/json-data.js +86 -0
- package/dist/bridge/navigation.d.ts +5 -0
- package/dist/bridge/navigation.js +7 -0
- package/dist/bridge/refusal.d.ts +5 -1
- package/dist/bridge/refusal.js +17 -0
- package/dist/bridge/types.d.ts +73 -5
- package/dist/check/check.d.ts +7 -0
- package/dist/check/check.js +1 -0
- package/dist/check/instrument.d.ts +3 -0
- package/dist/check/lint.js +4 -2
- package/dist/check/page-source.js +1 -1
- package/dist/check/page.js +16 -0
- package/dist/check/tools.js +2 -3
- package/dist/compile/compile.d.ts +6 -0
- package/dist/compile/compile.js +3 -1
- package/dist/compile/policy.d.ts +55 -0
- package/dist/compile/policy.js +157 -0
- package/dist/config/capabilities.d.ts +85 -7
- package/dist/config/capabilities.js +32 -2
- package/dist/config/schema.d.ts +35 -0
- package/dist/config/validate.d.ts +9 -3
- package/dist/config/validate.js +92 -8
- package/dist/config/warnings.d.ts +20 -0
- package/dist/config/warnings.js +25 -0
- package/dist/conformance/behavior.js +46 -1
- package/dist/conformance/cookies.d.ts +15 -0
- package/dist/conformance/cookies.js +80 -0
- package/dist/conformance/harness/page.d.ts +1 -0
- package/dist/conformance/harness/page.js +9 -2
- package/dist/conformance/harness-source.js +1 -1
- package/dist/conformance/host-kit.js +5 -1
- package/dist/conformance/index.d.ts +11 -0
- package/dist/conformance/index.js +2 -0
- package/dist/conformance/limits.js +38 -1
- package/dist/conformance/runtime.d.ts +58 -0
- package/dist/conformance/runtime.js +324 -0
- package/dist/conformance/served.d.ts +2 -0
- package/dist/conformance/served.js +737 -4
- package/dist/files/paths.js +4 -0
- package/dist/guide/gates.d.ts +9 -0
- package/dist/guide/gates.js +31 -0
- package/dist/guide/guide.d.ts +2 -0
- package/dist/guide/guide.js +35 -33
- package/dist/guide/limits.js +4 -4
- package/dist/guide/runtime.d.ts +13 -0
- package/dist/guide/runtime.js +210 -0
- package/dist/host/create-host.js +73 -37
- package/dist/host/locate.js +8 -0
- package/dist/host/locator.js +7 -0
- package/dist/host/pages-of-set.d.ts +43 -0
- package/dist/host/pages-of-set.js +196 -0
- package/dist/host/types.d.ts +26 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.js +11 -2
- package/dist/isolation/types.d.ts +8 -0
- package/dist/mcp/adapter.js +11 -15
- package/dist/node/index.d.ts +36 -4
- package/dist/node/index.js +402 -101
- package/dist/presets/presets.d.ts +22 -8
- package/dist/presets/presets.js +40 -8
- package/dist/protocol/live-data.d.ts +6 -2
- package/dist/protocol/live-data.js +20 -1
- package/dist/protocol/mcp-apps.d.ts +13 -2
- package/dist/protocol/mcp-apps.js +10 -2
- package/dist/protocol/message-text.d.ts +8 -0
- package/dist/protocol/message-text.js +29 -0
- package/dist/protocol/runtime-calls.d.ts +28 -0
- package/dist/protocol/runtime-calls.js +116 -0
- package/dist/protocol/shell-adapter.js +64 -25
- package/dist/react/context-notice.d.ts +32 -0
- package/dist/react/context-notice.js +28 -0
- package/dist/react/dialog.js +91 -16
- package/dist/react/frame.d.ts +25 -1
- package/dist/react/frame.js +85 -2
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/runtime/contract.d.ts +201 -0
- package/dist/runtime/contract.js +245 -0
- package/dist/runtime/db.d.ts +188 -0
- package/dist/runtime/db.js +502 -0
- package/dist/runtime/declaration.d.ts +100 -0
- package/dist/runtime/declaration.js +363 -0
- package/dist/runtime/levels.d.ts +33 -0
- package/dist/runtime/levels.js +41 -0
- package/dist/runtime/requests.d.ts +125 -0
- package/dist/runtime/requests.js +215 -0
- package/dist/runtime/segments.d.ts +8 -0
- package/dist/runtime/segments.js +14 -0
- package/dist/runtime/types.generated.d.ts +1 -0
- package/dist/runtime/types.generated.js +19 -0
- package/dist/server/files.d.ts +19 -1
- package/dist/server/files.js +115 -6
- package/dist/server/host.d.ts +24 -2
- package/dist/server/host.js +137 -2
- package/dist/server/index.d.ts +3 -2
- package/dist/server/index.js +2 -1
- package/dist/server/peer.d.ts +4 -0
- package/dist/server/peer.js +19 -0
- package/dist/server/proxy.d.ts +6 -0
- package/dist/server/proxy.js +12 -3
- package/dist/server/pseudonym.d.ts +9 -0
- package/dist/server/pseudonym.js +20 -0
- package/dist/server/server.d.ts +0 -5
- package/dist/server/server.js +318 -52
- package/dist/server/types.d.ts +74 -2
- package/dist/shell/document.d.ts +16 -0
- package/dist/shell/document.js +19 -2
- package/dist/shell/legacy.d.ts +21 -0
- package/dist/shell/legacy.js +63 -0
- package/dist/shell/plan.d.ts +17 -1
- package/dist/shell/plan.js +13 -2
- package/dist/shell/runtime.js +390 -56
- package/dist/shell/use.d.ts +15 -0
- package/dist/shell/use.js +235 -0
- package/docs/ADOPTING.md +205 -15
- package/docs/ARCHITECTURE.md +34 -5
- package/docs/DECISIONS.md +1867 -11
- package/docs/DESIGN.md +137 -17
- package/docs/THREAT_MODEL.md +616 -0
- package/package.json +16 -3
- package/src/bridge/bounded-text.ts +240 -0
- package/src/bridge/bridge.ts +601 -51
- package/src/bridge/json-data.ts +95 -0
- package/src/bridge/navigation.ts +10 -0
- package/src/bridge/refusal.ts +17 -0
- package/src/bridge/types.ts +76 -5
- package/src/check/check.ts +8 -0
- package/src/check/instrument.ts +3 -0
- package/src/check/lint.ts +4 -2
- package/src/check/page.ts +16 -0
- package/src/check/tools.ts +2 -3
- package/src/compile/compile.ts +9 -1
- package/src/compile/policy.ts +177 -0
- package/src/config/capabilities.ts +71 -5
- package/src/config/schema.ts +35 -0
- package/src/config/validate.ts +141 -8
- package/src/config/warnings.ts +42 -0
- package/src/conformance/behavior.ts +54 -1
- package/src/conformance/cookies.ts +93 -0
- package/src/conformance/harness/page.ts +11 -2
- package/src/conformance/host-kit.ts +10 -1
- package/src/conformance/index.ts +17 -0
- package/src/conformance/limits.ts +39 -1
- package/src/conformance/runtime.ts +594 -0
- package/src/conformance/served.ts +888 -4
- package/src/files/paths.ts +4 -0
- package/src/guide/gates.ts +37 -0
- package/src/guide/guide.ts +61 -55
- package/src/guide/limits.ts +4 -4
- package/src/guide/runtime.ts +253 -0
- package/src/host/create-host.ts +88 -36
- package/src/host/locate.ts +10 -0
- package/src/host/locator.ts +11 -0
- package/src/host/pages-of-set.ts +226 -0
- package/src/host/types.ts +33 -1
- package/src/index.ts +94 -0
- package/src/isolation/types.ts +8 -0
- package/src/mcp/adapter.ts +16 -20
- package/src/node/index.ts +507 -116
- package/src/presets/presets.ts +67 -17
- package/src/protocol/live-data.ts +31 -3
- package/src/protocol/mcp-apps.ts +11 -2
- package/src/protocol/message-text.ts +36 -0
- package/src/protocol/runtime-calls.ts +141 -0
- package/src/protocol/shell-adapter.ts +79 -26
- package/src/react/context-notice.tsx +95 -0
- package/src/react/dialog.tsx +108 -15
- package/src/react/frame.tsx +120 -0
- package/src/react/index.ts +8 -1
- package/src/runtime/contract.ts +339 -0
- package/src/runtime/db.ts +650 -0
- package/src/runtime/declaration.ts +516 -0
- package/src/runtime/levels.ts +69 -0
- package/src/runtime/requests.ts +355 -0
- package/src/runtime/segments.ts +17 -0
- package/src/runtime/types.generated.ts +19 -0
- package/src/server/files.ts +138 -7
- package/src/server/host.ts +170 -3
- package/src/server/index.ts +4 -0
- package/src/server/peer.ts +21 -0
- package/src/server/proxy.ts +13 -3
- package/src/server/pseudonym.ts +21 -0
- package/src/server/server.ts +370 -57
- package/src/server/types.ts +73 -2
- package/src/shell/document.ts +29 -4
- package/src/shell/legacy.ts +64 -0
- package/src/shell/plan.ts +37 -3
- package/src/shell/runtime.ts +390 -56
- package/src/shell/use.ts +235 -0
- package/types/runtime/v1/artifact.d.ts +50 -0
- package/types/runtime/v1/assets.d.ts +43 -0
- package/types/runtime/v1/chat.d.ts +13 -0
- package/types/runtime/v1/clipboard.d.ts +14 -0
- package/types/runtime/v1/comments.d.ts +24 -0
- package/types/runtime/v1/context.d.ts +27 -0
- package/types/runtime/v1/data.d.ts +29 -0
- package/types/runtime/v1/db.d.ts +110 -0
- package/types/runtime/v1/downloads.d.ts +22 -0
- package/types/runtime/v1/links.d.ts +13 -0
- package/types/runtime/v1/porthole.d.ts +44 -0
- package/types/runtime/v1/user.d.ts +19 -0
package/src/shell/use.ts
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The capability runtime in the frame (P085), spliced into the shell's runtime (`__RUNTIME__`)
|
|
3
|
+
* where the config has one (`config.runtime`). Content gets one global, `porthole`, whose only
|
|
4
|
+
* member is `use(name)`: a promise of a frozen namespace of the capability's methods, or null when
|
|
5
|
+
* the capability isn't there for this page (not offered, not declared, no host): the reasons are
|
|
6
|
+
* indistinguishable. Permission problems come at call time, as a rejected promise whose error has
|
|
7
|
+
* a stable `code` (P080, P087) and a sentence to show.
|
|
8
|
+
*
|
|
9
|
+
* The host's offer comes in the handshake (MCP Apps' experimental host capabilities,
|
|
10
|
+
* `porthole/runtime`): which capabilities, which methods. Calls go as `porthole/call` (own-prefixed,
|
|
11
|
+
* P002), `data.read` and `data.subscribe` as MCP's own resource requests (the cache and the
|
|
12
|
+
* subscriptions of P079); a watch's updates come as `porthole/event`. The host's bridge decides
|
|
13
|
+
* every call: nothing here is a wall, since it shares the content's realm.
|
|
14
|
+
*/
|
|
15
|
+
export const USE_RUNTIME = String.raw`
|
|
16
|
+
// The capability runtime (P085): porthole.use(name) -> a frozen namespace, or null.
|
|
17
|
+
// The host's offer: undefined until the handshake says (or gives up: null). A late answer is
|
|
18
|
+
// still taken, for the calls to use after it (after the review).
|
|
19
|
+
let offered = undefined;
|
|
20
|
+
const waiting = new Set();
|
|
21
|
+
runtimeOffer = (given) => {
|
|
22
|
+
const capabilities = given !== null && typeof given === "object" && given.capabilities !== null && typeof given.capabilities === "object" ? given.capabilities : null;
|
|
23
|
+
if (capabilities !== null || offered === undefined) {
|
|
24
|
+
offered = capabilities;
|
|
25
|
+
}
|
|
26
|
+
for (const wake of Array.from(waiting)) {
|
|
27
|
+
wake();
|
|
28
|
+
}
|
|
29
|
+
waiting.clear();
|
|
30
|
+
};
|
|
31
|
+
// A use waits for the handshake a few seconds at most, then is null (no host is answering).
|
|
32
|
+
const ready = () =>
|
|
33
|
+
offered !== undefined
|
|
34
|
+
? Promise.resolve()
|
|
35
|
+
: new Promise((resolve) => {
|
|
36
|
+
waiting.add(resolve);
|
|
37
|
+
setTimeout(resolve, 3000);
|
|
38
|
+
});
|
|
39
|
+
// Framed by a page that isn't one of this frame's hosts: nothing will answer (where the engine
|
|
40
|
+
// says who framed it).
|
|
41
|
+
const framedByHost = () => {
|
|
42
|
+
const ancestors = location.ancestorOrigins;
|
|
43
|
+
// "null": the engine masks it (a no-referrer frame): unknown, not a stranger.
|
|
44
|
+
return !ancestors || ancestors.length === 0 || ancestors[0] === "null" || plan.origins.indexOf(ancestors[0]) !== -1;
|
|
45
|
+
};
|
|
46
|
+
const NativeBlob = typeof Blob === "function" ? Blob : null;
|
|
47
|
+
const NativeArrayBuffer = ArrayBuffer;
|
|
48
|
+
const coded = (code, message) => {
|
|
49
|
+
const error = new Error(message);
|
|
50
|
+
error.code = code;
|
|
51
|
+
return error;
|
|
52
|
+
};
|
|
53
|
+
// A call through the host; its value, or a rejection with the refusal's code.
|
|
54
|
+
const call = (capability, method, args) =>
|
|
55
|
+
request("porthole/call", { capability, method, args }).then((result) =>
|
|
56
|
+
result !== null && typeof result === "object" ? result.value : undefined,
|
|
57
|
+
);
|
|
58
|
+
// What needs a click, refused here before it goes (the host checks again: P021).
|
|
59
|
+
const clicked = (serves, what) => (gestured(serves) ? null : Promise.reject(coded("not_allowed", what + " needs a click: call it from a button's handler")));
|
|
60
|
+
// Bytes as base64, for what crosses the frame as JSON.
|
|
61
|
+
const bytesOf = (data) => {
|
|
62
|
+
if (NativeBlob !== null && data instanceof NativeBlob) {
|
|
63
|
+
return data.arrayBuffer().then((buffer) => new Uint8Array(buffer));
|
|
64
|
+
}
|
|
65
|
+
if (data instanceof NativeArrayBuffer) {
|
|
66
|
+
return Promise.resolve(new Uint8Array(data));
|
|
67
|
+
}
|
|
68
|
+
if (ArrayBuffer.isView(data)) {
|
|
69
|
+
return Promise.resolve(new Uint8Array(data.buffer, data.byteOffset, data.byteLength));
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
};
|
|
73
|
+
const base64Of = (bytes) => {
|
|
74
|
+
let text = "";
|
|
75
|
+
for (let at = 0; at < bytes.length; at += 32768) {
|
|
76
|
+
text += String.fromCharCode.apply(null, Array.from(bytes.subarray(at, at + 32768)));
|
|
77
|
+
}
|
|
78
|
+
return btoa(text);
|
|
79
|
+
};
|
|
80
|
+
// A file's content: text as it is, bytes as base64, null as null (a removal).
|
|
81
|
+
const fileOf = (value) => {
|
|
82
|
+
if (value === null || typeof value === "string") {
|
|
83
|
+
return Promise.resolve(value === null ? null : { text: value });
|
|
84
|
+
}
|
|
85
|
+
const bytes = bytesOf(value);
|
|
86
|
+
return bytes === null ? Promise.reject(coded("not_allowed", "A file is text, a Blob, an ArrayBuffer or bytes")) : bytes.then((each) => ({ base64: base64Of(each) }));
|
|
87
|
+
};
|
|
88
|
+
const record = (value) => (value !== null && typeof value === "object" ? value : {});
|
|
89
|
+
// Watches (db.onSnapshot): by the id this frame gives each, its listener.
|
|
90
|
+
const watchers = new Map();
|
|
91
|
+
// A watch's id is this page's own, at random: a page that follows another on the same
|
|
92
|
+
// transport can't be handed its watches (after the review).
|
|
93
|
+
const watchId = () => {
|
|
94
|
+
const bytes = new Uint8Array(8);
|
|
95
|
+
crypto.getRandomValues(bytes);
|
|
96
|
+
return "w" + Array.from(bytes, (each) => each.toString(16).padStart(2, "0")).join("");
|
|
97
|
+
};
|
|
98
|
+
runtimeEvent = (params) => {
|
|
99
|
+
const watcher = typeof params.watch === "string" ? watchers.get(params.watch) : undefined;
|
|
100
|
+
if (watcher === undefined) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
watcher.onData(params.data);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
later(error);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const watch = (capability, method, args, onData, onError) => {
|
|
110
|
+
if (typeof onData !== "function") {
|
|
111
|
+
throw new TypeError(capability + "." + method + ": onData must be a function");
|
|
112
|
+
}
|
|
113
|
+
const id = watchId();
|
|
114
|
+
watchers.set(id, { onData });
|
|
115
|
+
request("porthole/call", { capability, method, args, watch: id }).catch((error) => {
|
|
116
|
+
watchers.delete(id);
|
|
117
|
+
if (typeof onError === "function") {
|
|
118
|
+
try {
|
|
119
|
+
onError(error);
|
|
120
|
+
} catch (thrown) {
|
|
121
|
+
later(thrown);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return () => {
|
|
126
|
+
if (watchers.delete(id)) {
|
|
127
|
+
notify("porthole/unwatch", { watch: id });
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
const METHODS = {
|
|
132
|
+
user: { get: () => call("user", "get", {}) },
|
|
133
|
+
comments: {
|
|
134
|
+
open: (anchor) => clicked("comments", "comments.open") || call("comments", "open", { anchor: typeof anchor === "string" ? { name: anchor } : record(anchor) }),
|
|
135
|
+
},
|
|
136
|
+
clipboard: { copy: (text) => clicked("copyText", "clipboard.copy") || call("clipboard", "copy", { text: String(text) }) },
|
|
137
|
+
links: { open: (url) => clicked("openLink", "links.open") || call("links", "open", { url: String(url) }) },
|
|
138
|
+
downloads: {
|
|
139
|
+
save: (file) => {
|
|
140
|
+
const given = record(file);
|
|
141
|
+
const waiting = clicked("downloadFile", "downloads.save");
|
|
142
|
+
if (waiting !== null) {
|
|
143
|
+
return waiting;
|
|
144
|
+
}
|
|
145
|
+
const content = given.data !== undefined ? given.data : given.text !== undefined ? String(given.text) : null;
|
|
146
|
+
return fileOf(content).then((body) => call("downloads", "save", { file: Object.assign({ name: given.name, type: given.type }, record(body)) }));
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
chat: { send: (text) => clicked("sendPrompt", "chat.send") || call("chat", "send", { text: String(text) }) },
|
|
150
|
+
data: {
|
|
151
|
+
read: (uri) => readValue(uri),
|
|
152
|
+
subscribe: (uri, onData, onError) => (follow === null ? null : follow(uri, onData, onError)),
|
|
153
|
+
call: (name, args) => call("data", "call", { name: String(name), arguments: args === undefined ? {} : args }),
|
|
154
|
+
},
|
|
155
|
+
context: { set: (update) => call("context", "set", record(update)) },
|
|
156
|
+
artifact: {
|
|
157
|
+
get: () => call("artifact", "get", {}),
|
|
158
|
+
publish: (change) => {
|
|
159
|
+
const given = record(change);
|
|
160
|
+
const files = record(given.files);
|
|
161
|
+
const names = Object.keys(files);
|
|
162
|
+
return Promise.all(names.map((name) => fileOf(files[name]))).then((bodies) => {
|
|
163
|
+
const out = {};
|
|
164
|
+
names.forEach((name, index) => {
|
|
165
|
+
out[name] = bodies[index];
|
|
166
|
+
});
|
|
167
|
+
return call("artifact", "publish", { base: given.base, files: out, entry: given.entry, label: given.label, note: given.note });
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
assets: {
|
|
172
|
+
list: () => call("assets", "list", {}),
|
|
173
|
+
upload: (file, options) => {
|
|
174
|
+
const name = record(options).name !== undefined ? record(options).name : file && typeof file.name === "string" ? file.name : undefined;
|
|
175
|
+
const bytes = bytesOf(file);
|
|
176
|
+
return bytes === null ? Promise.reject(coded("not_allowed", "assets.upload takes a File, a Blob or bytes")) : bytes.then((each) => call("assets", "upload", { name, base64: base64Of(each) }));
|
|
177
|
+
},
|
|
178
|
+
delete: (id) => call("assets", "delete", { id: String(id) }),
|
|
179
|
+
// The address that loads an asset in this page now (P091): in a frame, under its own sealed
|
|
180
|
+
// files' address, which every engine sends; elsewhere /_blob/<id>. Never stored: it carries
|
|
181
|
+
// this page's access.
|
|
182
|
+
url: (id) => {
|
|
183
|
+
const asset = String(id);
|
|
184
|
+
if (!/^[0-9a-f]{32}$/.test(asset)) {
|
|
185
|
+
throw new TypeError("assets.url(id): an asset's id is 32 lowercase hex characters");
|
|
186
|
+
}
|
|
187
|
+
return filesBase !== null && filesBase.indexOf("/__porthole/f/") !== -1 ? filesBase + "__porthole/blob/" + asset : "/_blob/" + asset;
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
db: {
|
|
191
|
+
get: (path) => call("db", "get", { path }),
|
|
192
|
+
set: (path, data, options) => call("db", "set", { path, data, ifVersion: record(options).ifVersion }),
|
|
193
|
+
update: (path, data, options) => call("db", "update", { path, data, ifVersion: record(options).ifVersion }),
|
|
194
|
+
delete: (path, options) => call("db", "delete", { path, ifVersion: record(options).ifVersion }),
|
|
195
|
+
query: (collection, query) => call("db", "query", Object.assign({ collection }, record(query))),
|
|
196
|
+
batch: (writes) => call("db", "batch", { writes }),
|
|
197
|
+
onSnapshot: (path, onData, onError) => watch("db", "watch", { path }, onData, onError),
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
// A runtime method's name in the namespace, where it differs from the contract's.
|
|
201
|
+
const RENAMED = { db: { watch: "onSnapshot" } };
|
|
202
|
+
const namespaces = new Map();
|
|
203
|
+
const use = (name) => {
|
|
204
|
+
if (window.parent === window || !framedByHost() || typeof name !== "string" || !Object.prototype.hasOwnProperty.call(METHODS, name)) {
|
|
205
|
+
return Promise.resolve(null);
|
|
206
|
+
}
|
|
207
|
+
return ready().then(() => {
|
|
208
|
+
const methods = offered !== undefined && offered !== null && Array.isArray(offered[name]) ? offered[name] : null;
|
|
209
|
+
if (methods === null) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
if (!namespaces.has(name)) {
|
|
213
|
+
const space = {};
|
|
214
|
+
const renamed = RENAMED[name] || {};
|
|
215
|
+
for (const each of methods) {
|
|
216
|
+
const key = Object.prototype.hasOwnProperty.call(renamed, each) ? renamed[each] : each;
|
|
217
|
+
if (typeof each === "string" && Object.prototype.hasOwnProperty.call(METHODS[name], key)) {
|
|
218
|
+
const call = METHODS[name][key];
|
|
219
|
+
// A method whose own gates want a gesture (after the review): refused here without one.
|
|
220
|
+
const gated = Array.isArray(plan.methodActivation) && plan.methodActivation.indexOf(name + "." + each) !== -1;
|
|
221
|
+
space[key] = gated
|
|
222
|
+
? function () {
|
|
223
|
+
const activation = navigator.userActivation;
|
|
224
|
+
return activation && !activation.isActive ? Promise.reject(coded("not_allowed", name + "." + key + " needs a click: call it from a button's handler")) : call.apply(null, arguments);
|
|
225
|
+
}
|
|
226
|
+
: call;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
namespaces.set(name, Object.freeze(space));
|
|
230
|
+
}
|
|
231
|
+
return namespaces.get(name);
|
|
232
|
+
}, () => null);
|
|
233
|
+
};
|
|
234
|
+
lock(window, "porthole", Object.freeze({ use }));
|
|
235
|
+
`;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Porthole capability runtime, contract 1: artifact (this artifact itself). Declare it: { artifact: {} }.
|
|
2
|
+
// Use it when the page is the record: a checklist, a plan, a document someone edits in place.
|
|
3
|
+
|
|
4
|
+
interface PortholeArtifactFile {
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly size: number;
|
|
7
|
+
readonly sha256: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface PortholeArtifactVersion {
|
|
11
|
+
/** The version's id: what a publish names as its base. */
|
|
12
|
+
readonly version: string;
|
|
13
|
+
readonly number?: number;
|
|
14
|
+
/** The page it opens at ("index.html"). */
|
|
15
|
+
readonly entry: string;
|
|
16
|
+
readonly files: readonly PortholeArtifactFile[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface PortholeArtifactPublish {
|
|
20
|
+
/** The version you read and changed (from get()). If it moved, publish rejects with conflict. */
|
|
21
|
+
readonly base: string;
|
|
22
|
+
/**
|
|
23
|
+
* A patch on base's files, by path: text, bytes (a Blob, an ArrayBuffer, a typed array), or
|
|
24
|
+
* null to remove one; files not named are kept. A page sends its whole document, as it should
|
|
25
|
+
* be served. At most 255 files.
|
|
26
|
+
*/
|
|
27
|
+
readonly files: Readonly<Record<string, string | Blob | ArrayBuffer | ArrayBufferView | null>>;
|
|
28
|
+
readonly entry?: string;
|
|
29
|
+
/** At most 60 characters. */
|
|
30
|
+
readonly label?: string;
|
|
31
|
+
/** At most 500 characters. */
|
|
32
|
+
readonly note?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface PortholeArtifact {
|
|
36
|
+
/** The current version and its files (fetch a file by its relative path). Level: view. */
|
|
37
|
+
get(): Promise<PortholeArtifactVersion>;
|
|
38
|
+
/**
|
|
39
|
+
* Publishes a new version of this artifact, from a click; the app asks the person first. The
|
|
40
|
+
* page can't change what it declares. On conflict: get() again, merge, publish again. Level:
|
|
41
|
+
* admin.
|
|
42
|
+
*/
|
|
43
|
+
publish(
|
|
44
|
+
change: PortholeArtifactPublish,
|
|
45
|
+
): Promise<{ readonly version: string; readonly number?: number }>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface PortholeCapabilities {
|
|
49
|
+
artifact: PortholeArtifact;
|
|
50
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Porthole capability runtime, contract 1: assets (the artifact's asset library). Declare it: { assets: {} }.
|
|
2
|
+
// Assets live outside every version, at "/_blob/<id>" on the page's own origin: keep that url (or
|
|
3
|
+
// the id) in your data, and show it with assets.url(id). Images, media and fonts load; scripts and
|
|
4
|
+
// stylesheets only where the app lets only admins upload, and only those an admin added. Not for
|
|
5
|
+
// files that version with the page: publish those with it.
|
|
6
|
+
|
|
7
|
+
interface PortholeAsset {
|
|
8
|
+
/** 32 hex characters. */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
/** "/_blob/<id>": use it as given. */
|
|
11
|
+
readonly url: string;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
/** Porthole's type for the name's extension. */
|
|
14
|
+
readonly type: string;
|
|
15
|
+
readonly size: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface PortholeAssets {
|
|
19
|
+
/** The library, people's uploads through the page included. Level: view. */
|
|
20
|
+
list(): Promise<readonly PortholeAsset[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Adds a file (a File from an <input type="file">, a Blob, bytes) under its name (a File's own,
|
|
23
|
+
* or options.name): an image, media, a font, a PDF, text or data, never HTML; a script or a
|
|
24
|
+
* stylesheet only where uploads are the admins'. The app may ask the person first. Level: admin,
|
|
25
|
+
* unless the app lets people who interact upload.
|
|
26
|
+
*/
|
|
27
|
+
upload(
|
|
28
|
+
file: Blob | ArrayBuffer | ArrayBufferView,
|
|
29
|
+
options?: { readonly name?: string },
|
|
30
|
+
): Promise<PortholeAsset>;
|
|
31
|
+
/**
|
|
32
|
+
* The address that loads an asset in this page now: put it in src or href when you show it.
|
|
33
|
+
* Store the id (or "/_blob/<id>"), never this: it carries this page's access. A "/_blob/<id>"
|
|
34
|
+
* written in the page loads too, except in some browsers' frames (Safari's); this always does.
|
|
35
|
+
*/
|
|
36
|
+
url(id: string): string;
|
|
37
|
+
/** Removes one, from a click; the app asks the person first. Level: admin. */
|
|
38
|
+
delete(id: string): Promise<boolean>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface PortholeCapabilities {
|
|
42
|
+
assets: PortholeAssets;
|
|
43
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Porthole capability runtime, contract 1: chat. Declare it: { chat: {} }.
|
|
2
|
+
|
|
3
|
+
interface PortholeChat {
|
|
4
|
+
/**
|
|
5
|
+
* Sends text to the agent as the person's message ("explain this point"). Call it from a click.
|
|
6
|
+
* Resolves true if it was sent. Level: interact.
|
|
7
|
+
*/
|
|
8
|
+
send(text: string): Promise<boolean>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface PortholeCapabilities {
|
|
12
|
+
chat: PortholeChat;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Porthole capability runtime, contract 1: clipboard. Built in: never declare it.
|
|
2
|
+
|
|
3
|
+
interface PortholeClipboard {
|
|
4
|
+
/**
|
|
5
|
+
* Copies text to the person's clipboard (at most 20,000 characters); the app shows them what
|
|
6
|
+
* was copied. Nothing else in the page can write the clipboard. Call it from a click.
|
|
7
|
+
* Resolves true if it was copied. Level: view.
|
|
8
|
+
*/
|
|
9
|
+
copy(text: string): Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface PortholeCapabilities {
|
|
13
|
+
clipboard: PortholeClipboard;
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Porthole capability runtime, contract 1: comments. Built in: never declare it.
|
|
2
|
+
|
|
3
|
+
/** Where a comment goes, in the page's own words. */
|
|
4
|
+
interface PortholeCommentAnchor {
|
|
5
|
+
/** A stable name the page chose: "slide-3", "refs/a.md#L12" (at most 256 characters). */
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/** What the app shows for it (at most 200). */
|
|
8
|
+
readonly label?: string;
|
|
9
|
+
/** The text the comment is about (at most 2,000). */
|
|
10
|
+
readonly quote?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface PortholeComments {
|
|
14
|
+
/**
|
|
15
|
+
* Opens the app's comment composer at the anchor (a name alone is { name }). The person writes
|
|
16
|
+
* and posts it in the app. Resolves true if the composer opened. Write-only: a page never reads
|
|
17
|
+
* comments. Call it from a click. Level: view.
|
|
18
|
+
*/
|
|
19
|
+
open(anchor: PortholeCommentAnchor | string): Promise<boolean>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface PortholeCapabilities {
|
|
23
|
+
comments: PortholeComments;
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Porthole capability runtime, contract 1: context. Declare it: { context: {} }.
|
|
2
|
+
|
|
3
|
+
interface PortholeContextUpdate {
|
|
4
|
+
/**
|
|
5
|
+
* MCP text blocks only: [{ type: "text", text: "…" }]. Visible characters only, here and in
|
|
6
|
+
* structuredContent: no zero-width or bidi controls, variation selectors, tag or private-use
|
|
7
|
+
* characters, or controls other than new lines and tabs (refused), but the selectors and
|
|
8
|
+
* joiners inside real emoji (☀️, 👨👩👧, 1️⃣), and a joiner or non-joiner between two letters of
|
|
9
|
+
* a script it shapes (Arabic, Persian, the Indic scripts, Myanmar…).
|
|
10
|
+
*/
|
|
11
|
+
readonly content?: readonly unknown[];
|
|
12
|
+
/** Plain JSON. With the text, at most 20,000 characters. */
|
|
13
|
+
readonly structuredContent?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface PortholeContext {
|
|
17
|
+
/**
|
|
18
|
+
* Tells the agent, at its next turns, what the page says the person is looking at (replaces the
|
|
19
|
+
* last). The agent reads it as the page's words, unconfirmed by the person; the app shows the
|
|
20
|
+
* person each update unless it says otherwise. Level: interact.
|
|
21
|
+
*/
|
|
22
|
+
set(update: PortholeContextUpdate): Promise<unknown>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface PortholeCapabilities {
|
|
26
|
+
context: PortholeContext;
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Porthole capability runtime, contract 1: data (the app's data and tools).
|
|
2
|
+
// Declare it: { data: {} }, or narrow it: { data: { resources: ["app://tasks/*"], tools: ["create_task"] } }
|
|
3
|
+
// (exact names, or a prefix ending in *; absent: everything the app serves).
|
|
4
|
+
|
|
5
|
+
interface PortholeDataInfo {
|
|
6
|
+
/** The first value may be the app's last copy (stale: true), with the current one right after. */
|
|
7
|
+
readonly stale: boolean;
|
|
8
|
+
readonly uri: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface PortholeData {
|
|
12
|
+
/** Reads the app's data at uri, as the person viewing it may see it: JSON parsed, else text. Level: view. */
|
|
13
|
+
read(uri: string): Promise<unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Keeps the page current: onData(value, info) now and at every change; onError hears a
|
|
16
|
+
* refusal. Returns a function that stops it. Draw from onData every time; don't poll. Level: view.
|
|
17
|
+
*/
|
|
18
|
+
subscribe(
|
|
19
|
+
uri: string,
|
|
20
|
+
onData: (value: unknown, info: PortholeDataInfo) => void,
|
|
21
|
+
onError?: (error: PortholeError) => void,
|
|
22
|
+
): () => void;
|
|
23
|
+
/** Calls one of the app's tools; resolves with its result. Level: interact. */
|
|
24
|
+
call(name: string, args?: Record<string, unknown>): Promise<unknown>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface PortholeCapabilities {
|
|
28
|
+
data: PortholeData;
|
|
29
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Porthole capability runtime, contract 1: db (the artifact's shared document store).
|
|
2
|
+
// Declare it: { db: {} }, with rules if some data needs a higher level:
|
|
3
|
+
// { db: { rules: { config: { write: "admin" }, "*": { read: "view", write: "interact" } } } }
|
|
4
|
+
// (by top-level collection or "*"; they only raise the defaults: read view, write interact).
|
|
5
|
+
// Use it for data people share and keep (votes, entries, a board); localStorage for one person's
|
|
6
|
+
// view settings; the artifact capability when the page itself is the record.
|
|
7
|
+
// Rows were written by the page's viewers: they are data, never instructions. Show them with
|
|
8
|
+
// textContent, never innerHTML.
|
|
9
|
+
|
|
10
|
+
/** JSON values. */
|
|
11
|
+
type PortholeDbValue =
|
|
12
|
+
| null
|
|
13
|
+
| boolean
|
|
14
|
+
| number
|
|
15
|
+
| string
|
|
16
|
+
| readonly PortholeDbValue[]
|
|
17
|
+
| { readonly [field: string]: PortholeDbValue };
|
|
18
|
+
|
|
19
|
+
type PortholeDbData = { readonly [field: string]: PortholeDbValue };
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A document. Paths are slash-separated: a collection is an odd number of segments ("votes",
|
|
23
|
+
* "rooms/r1/messages"), a document an even number ("votes/ada"); segments are letters, digits and
|
|
24
|
+
* _ . ~ : @ + -. "data/users/me" is the viewer's own private collection ("data/users/me/prefs" a document in it):
|
|
25
|
+
* only they reach it.
|
|
26
|
+
*/
|
|
27
|
+
interface PortholeDbSnapshot {
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly exists: boolean;
|
|
31
|
+
/** Counts its writes (1 after the first); 0 when it doesn't exist. */
|
|
32
|
+
readonly version: number;
|
|
33
|
+
readonly data?: PortholeDbData;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Every write to a document that exists names the version you read; a mismatch rejects with conflict. ifVersion 0: it must not exist yet. */
|
|
37
|
+
interface PortholeDbWriteOptions {
|
|
38
|
+
readonly ifVersion?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type PortholeDbWrite =
|
|
42
|
+
| {
|
|
43
|
+
readonly op: "set";
|
|
44
|
+
readonly path: string;
|
|
45
|
+
readonly data: PortholeDbData;
|
|
46
|
+
readonly ifVersion?: number;
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
49
|
+
readonly op: "update";
|
|
50
|
+
readonly path: string;
|
|
51
|
+
readonly data: PortholeDbData;
|
|
52
|
+
readonly ifVersion?: number;
|
|
53
|
+
}
|
|
54
|
+
| { readonly op: "delete"; readonly path: string; readonly ifVersion?: number };
|
|
55
|
+
|
|
56
|
+
interface PortholeDbQuery {
|
|
57
|
+
/** At most 10: [field, op, value]. */
|
|
58
|
+
readonly where?: readonly (readonly [
|
|
59
|
+
field: string,
|
|
60
|
+
op: "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "array-contains",
|
|
61
|
+
value: PortholeDbValue,
|
|
62
|
+
])[];
|
|
63
|
+
readonly orderBy?: { readonly field: string; readonly direction?: "asc" | "desc" };
|
|
64
|
+
/** 1 to 500. */
|
|
65
|
+
readonly limit?: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface PortholeDb {
|
|
69
|
+
/** Level: view. */
|
|
70
|
+
get(path: string): Promise<PortholeDbSnapshot>;
|
|
71
|
+
/** A collection's documents. Level: view. */
|
|
72
|
+
query(
|
|
73
|
+
collection: string,
|
|
74
|
+
query?: PortholeDbQuery,
|
|
75
|
+
): Promise<{ readonly docs: readonly PortholeDbSnapshot[] }>;
|
|
76
|
+
/** Writes a whole document (at most 1 MiB of JSON). Level: interact. */
|
|
77
|
+
set(
|
|
78
|
+
path: string,
|
|
79
|
+
data: PortholeDbData,
|
|
80
|
+
options?: PortholeDbWriteOptions,
|
|
81
|
+
): Promise<{ readonly version: number }>;
|
|
82
|
+
/** Merges fields over a document's. Level: interact. */
|
|
83
|
+
update(
|
|
84
|
+
path: string,
|
|
85
|
+
data: PortholeDbData,
|
|
86
|
+
options?: PortholeDbWriteOptions,
|
|
87
|
+
): Promise<{ readonly version: number }>;
|
|
88
|
+
/** Level: interact. */
|
|
89
|
+
delete(path: string, options?: PortholeDbWriteOptions): Promise<null>;
|
|
90
|
+
/**
|
|
91
|
+
* Up to 50 writes to different documents, all or none. Each write's new version (null for a
|
|
92
|
+
* delete). Each write at its own level.
|
|
93
|
+
*/
|
|
94
|
+
batch(
|
|
95
|
+
writes: readonly PortholeDbWrite[],
|
|
96
|
+
): Promise<{ readonly versions: readonly (number | null)[] }>;
|
|
97
|
+
/**
|
|
98
|
+
* Follows a document (a snapshot) or a collection ({ docs }) now and at every change. Returns a
|
|
99
|
+
* function that stops it. Draw from onData; don't poll. Level: view.
|
|
100
|
+
*/
|
|
101
|
+
onSnapshot(
|
|
102
|
+
path: string,
|
|
103
|
+
onData: (state: PortholeDbSnapshot | { readonly docs: readonly PortholeDbSnapshot[] }) => void,
|
|
104
|
+
onError?: (error: PortholeError) => void,
|
|
105
|
+
): () => void;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface PortholeCapabilities {
|
|
109
|
+
db: PortholeDb;
|
|
110
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Porthole capability runtime, contract 1: downloads. Built in: never declare it.
|
|
2
|
+
|
|
3
|
+
/** A file to hand the person: its name, and its text or bytes. */
|
|
4
|
+
interface PortholeDownload {
|
|
5
|
+
/** A file name, no slashes: "report.csv". Its extension gives its type unless `type` says. */
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly type?: string;
|
|
8
|
+
readonly text?: string;
|
|
9
|
+
readonly data?: Blob | ArrayBuffer | ArrayBufferView;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface PortholeDownloads {
|
|
13
|
+
/**
|
|
14
|
+
* Hands the person a file to save (<a download> and script-driven saves don't work here).
|
|
15
|
+
* Call it from a click. Resolves true if the download started. Level: view.
|
|
16
|
+
*/
|
|
17
|
+
save(file: PortholeDownload): Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface PortholeCapabilities {
|
|
21
|
+
downloads: PortholeDownloads;
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Porthole capability runtime, contract 1: links. Built in: never declare it.
|
|
2
|
+
|
|
3
|
+
interface PortholeLinks {
|
|
4
|
+
/**
|
|
5
|
+
* Opens an http(s) link outside the page (a click on an <a href> does the same). Call it from
|
|
6
|
+
* a click. Resolves true if it opened. Level: view.
|
|
7
|
+
*/
|
|
8
|
+
open(url: string): Promise<boolean>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface PortholeCapabilities {
|
|
12
|
+
links: PortholeLinks;
|
|
13
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Porthole capability runtime, contract 1: the call contract (how a page reaches any capability).
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Why a call was refused: branch on it; show `message` (a sentence for the person) where the
|
|
5
|
+
* result would be. Never retry in a loop.
|
|
6
|
+
* - consent_required: the person hasn't allowed it yet.
|
|
7
|
+
* - denied: the person said no.
|
|
8
|
+
* - rate_limited: too many calls this minute.
|
|
9
|
+
* - not_allowed: not available here (some places show the page without it).
|
|
10
|
+
* - failed: the app tried and couldn't.
|
|
11
|
+
* - forbidden: this person may see the page but not do this (their level).
|
|
12
|
+
* - conflict: what you change moved since you read it: read it again, then write.
|
|
13
|
+
* - too_large: past a limit.
|
|
14
|
+
*/
|
|
15
|
+
type PortholeErrorCode =
|
|
16
|
+
| "consent_required"
|
|
17
|
+
| "denied"
|
|
18
|
+
| "rate_limited"
|
|
19
|
+
| "not_allowed"
|
|
20
|
+
| "failed"
|
|
21
|
+
| "forbidden"
|
|
22
|
+
| "conflict"
|
|
23
|
+
| "too_large";
|
|
24
|
+
|
|
25
|
+
/** What every capability method rejects with. */
|
|
26
|
+
interface PortholeError extends Error {
|
|
27
|
+
readonly code: PortholeErrorCode;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Each capability's namespace, by the name `use` takes (each capability's own file adds its own). */
|
|
31
|
+
interface PortholeCapabilities {}
|
|
32
|
+
|
|
33
|
+
interface PortholeRuntime {
|
|
34
|
+
/**
|
|
35
|
+
* The capability's namespace, frozen; or null when it isn't there for this page: the app
|
|
36
|
+
* doesn't offer it, the page didn't declare it, or no app is showing the page (a tab, a
|
|
37
|
+
* preview). The reasons are indistinguishable: draw the page without it. `use` never rejects;
|
|
38
|
+
* permission problems come when you call a method (a rejected promise, `PortholeError`).
|
|
39
|
+
*/
|
|
40
|
+
use<N extends keyof PortholeCapabilities>(name: N): Promise<PortholeCapabilities[N] | null>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The page's one global. Nothing else is added to `window`. */
|
|
44
|
+
declare const porthole: PortholeRuntime;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Porthole capability runtime, contract 1: user. Declare it: { user: {} }.
|
|
2
|
+
|
|
3
|
+
/** Who is viewing, as the app says. */
|
|
4
|
+
interface PortholeUserInfo {
|
|
5
|
+
/** The app's id for this person (whose data "data/users/me" is), or null if it gives none. */
|
|
6
|
+
readonly id: string | null;
|
|
7
|
+
readonly name: string | null;
|
|
8
|
+
/** What they may do here: view < interact < admin < owner. */
|
|
9
|
+
readonly level: "view" | "interact" | "admin" | "owner";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface PortholeUser {
|
|
13
|
+
/** Level: view. */
|
|
14
|
+
get(): Promise<PortholeUserInfo>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface PortholeCapabilities {
|
|
18
|
+
user: PortholeUser;
|
|
19
|
+
}
|