@superbee/view-host 0.0.0-stage → 0.1.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 CHANGED
@@ -1,3 +1,62 @@
1
- # Temporary Holding Version
1
+ # Superbee View host
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The browser-safe host side of the Superbee View protocol (`docs/VIEW-PROTOCOL.md`), for a page
4
+ that runs a View in a sandboxed frame. Its one runtime dependency is `@superbee/core`.
5
+
6
+ | Entry | What it holds |
7
+ | --- | --- |
8
+ | `@superbee/view-host/view-bridge-host` | `createViewBridgeHost`: maps each View request onto a named operation that the page's `execute` callback runs |
9
+ | `@superbee/view-host/action-bridge` | The v1 View action contract: message parsing and replies |
10
+ | `@superbee/view-host/action-preparation` | `prepareViewDocumentAction`: the host-neutral proposal policy over Core |
11
+ | `@superbee/view-host/view-frame` | `viewFrameHeaders` and `viewFramePolicy`: the response headers a View entry is served with |
12
+ | `@superbee/view-host` | The host and the frame headers together |
13
+
14
+ ```ts
15
+ import { createViewBridgeHost } from "@superbee/view-host";
16
+
17
+ const host = createViewBridgeHost(frame.contentWindow, { id: bundleId, name: bundleTitle }, execute, {
18
+ operations: ["documents.read.v1", "documents.query.v1", "documents.relationships.v1", "documents.edges.v1"],
19
+ invalidate: () => frame.remove(),
20
+ });
21
+ window.addEventListener("message", (event) => void host.receive(event));
22
+ ```
23
+
24
+ | Request | Operation |
25
+ | --- | --- |
26
+ | `query` | `documents.query.v1` |
27
+ | `read`, `read-versioned`, `render-document` | `documents.read.v1` |
28
+ | `relationships` | `documents.relationships.v1` |
29
+ | `edges` | `documents.edges.v1` |
30
+ | `graph` | `bundles.graph.v1` |
31
+ | `action.propose` (v1) | the page's `proposeAction` |
32
+
33
+ `execute(operation, input, signal)` runs the operation on the person's behalf and answers its
34
+ result envelope, `{ ok: true, data }` or `{ ok: false, error: { code, message } }`. Every input
35
+ carries the host's fixed `bundleId`. The host declares in `hello` only the requests whose
36
+ operation the page offers and refuses the rest with `FORBIDDEN`. The page owns the frame, the
37
+ data source, authorization and any confirmation; the host owns parsing, limits, queuing and the
38
+ protocol's replies. It admits messages only from the frame it was given, at the opaque origin a
39
+ `sandbox="allow-scripts"` frame has.
40
+
41
+ ## What the page must do itself
42
+
43
+ The host trusts the frame it was given, not what is loaded in it. A page that embeds a View is
44
+ safe only if it also does these:
45
+
46
+ - **Keep the frame on the View.** Send the embedding page with a `Content-Security-Policy` whose
47
+ `frame-src` (and `child-src`) allow only the page's own origin. Without it a View can navigate
48
+ its frame to another site, and that site then receives every answer and has the network.
49
+ - **Sandbox the frame with scripts only.** Embed the entry in `<iframe sandbox="allow-scripts">`.
50
+ Never add `allow-same-origin`, `allow-popups` or `allow-top-navigation`.
51
+ - **Serve the entry with `viewFrameHeaders(pageOrigin)`.** Take `pageOrigin` from the page's own
52
+ configuration, never from a request header.
53
+ - **Authorize in `execute`.** Check who is asking on every call; the host passes requests
54
+ through and does not know the viewer. Enforce the query and edges row ceilings there too: the
55
+ host declares them in `hello` but answers whatever `execute` returns, up to its reply size cap.
56
+
57
+ Install one `@superbee/core`. The package takes a Core range so a page's own Core satisfies it;
58
+ `prepareViewDocumentAction` passes Core's typed errors through, and callers classify them by
59
+ class, which needs a single copy.
60
+
61
+ This package is published by hand from a reviewed tarball, as `packages/browser-local/RELEASING.md`
62
+ describes; its workspace `prepublishOnly` refuses a direct publish.
@@ -0,0 +1,52 @@
1
+ export declare const ACTION_BRIDGE_PROTOCOL = "v1";
2
+ export declare const MAX_ACTION_BODY_BYTES: number;
3
+ export type ActionScalar = string | number | boolean;
4
+ export interface DocumentSetFieldAction {
5
+ kind: "document.set-field";
6
+ docId: string;
7
+ field: string;
8
+ value: ActionScalar;
9
+ expectedVersion: string;
10
+ }
11
+ export interface DocumentSetBodyAction {
12
+ kind: "document.set-body";
13
+ docId: string;
14
+ field: "body";
15
+ value: string;
16
+ expectedVersion: string;
17
+ }
18
+ export interface DocumentUpdateAction {
19
+ kind: "document.update";
20
+ docId: string;
21
+ field: "document";
22
+ value: {
23
+ fields: Record<string, ActionScalar>;
24
+ body: string;
25
+ };
26
+ expectedVersion: string;
27
+ }
28
+ export type DocumentAction = DocumentSetFieldAction | DocumentSetBodyAction | DocumentUpdateAction;
29
+ export declare function parseDocumentAction(value: unknown): DocumentAction;
30
+ export type ActionBridgeMessage = {
31
+ bridge: "v1";
32
+ type: "read-versioned";
33
+ id: string;
34
+ docId: string;
35
+ } | {
36
+ bridge: "v1";
37
+ type: "action.propose";
38
+ requestId: string;
39
+ action: DocumentAction;
40
+ };
41
+ export declare function parseDocumentSetFieldAction(value: unknown): DocumentSetFieldAction;
42
+ /** Validate the complete structured-clone message before any shell work or confirmation UI. */
43
+ export declare function parseActionBridgeMessage(value: unknown): {
44
+ ok: true;
45
+ message: ActionBridgeMessage;
46
+ } | {
47
+ ok: false;
48
+ message: string;
49
+ } | null;
50
+ export declare function actionReply(requestId: string, result: unknown): Record<string, unknown>;
51
+ export declare function actionError(id: string | undefined, message: string): Record<string, unknown>;
52
+ //# sourceMappingURL=action-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-bridge.d.ts","sourceRoot":"","sources":["../src/action-bridge.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C,eAAO,MAAM,qBAAqB,QAAY,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAErD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KA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,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE5F"}
@@ -0,0 +1,125 @@
1
+ export const ACTION_BRIDGE_PROTOCOL = "v1";
2
+ const MAX_MESSAGE_BYTES = 512 * 1024;
3
+ export const MAX_ACTION_BODY_BYTES = 64 * 1024;
4
+ export function parseDocumentAction(value) {
5
+ if (isPlainRecord(value) && value.kind === "document.update") {
6
+ if (!exactKeys(value, ["kind", "docId", "field", "value", "expectedVersion"]) || value.field !== "document" ||
7
+ !isPlainRecord(value.value) || !exactKeys(value.value, ["fields", "body"]) || !isPlainRecord(value.value.fields))
8
+ throw new Error("document update requires exact fields and body");
9
+ const body = parseDocumentAction({ ...value, kind: "document.set-body", field: "body", value: value.value.body });
10
+ const entries = Object.entries(value.value.fields);
11
+ if (entries.length < 1 || entries.length > 8)
12
+ throw new Error("document update requires one to eight scalar fields");
13
+ for (const [field, scalar] of entries) {
14
+ const parsed = parseDocumentSetFieldAction({ kind: "document.set-field", docId: body.docId, field, value: scalar, expectedVersion: body.expectedVersion });
15
+ if (parsed.field !== field)
16
+ throw new Error("field names must be canonical");
17
+ }
18
+ return { kind: "document.update", docId: body.docId, field: "document", value: { fields: Object.fromEntries(entries), body: body.value }, expectedVersion: body.expectedVersion };
19
+ }
20
+ if (!isPlainRecord(value) || value.kind !== "document.set-body")
21
+ return parseDocumentSetFieldAction(value);
22
+ if (!exactKeys(value, ["kind", "docId", "field", "value", "expectedVersion"]) ||
23
+ !safeDocId(value.docId) || value.field !== "body" || typeof value.value !== "string" ||
24
+ byteLength(value.value) > MAX_ACTION_BODY_BYTES || typeof value.expectedVersion !== "string" ||
25
+ !value.expectedVersion.trim() || value.expectedVersion.length > 256)
26
+ throw new Error("body action requires a safe docId, field body, text of at most 64 KiB, and expectedVersion");
27
+ return { kind: "document.set-body", docId: value.docId, field: "body", value: value.value, expectedVersion: value.expectedVersion.trim() };
28
+ }
29
+ function isPlainRecord(value) {
30
+ if (typeof value !== "object" || value === null || Array.isArray(value))
31
+ return false;
32
+ const prototype = Object.getPrototypeOf(value);
33
+ return prototype === Object.prototype || prototype === null;
34
+ }
35
+ function exactKeys(record, expected) {
36
+ const actual = Object.keys(record).sort();
37
+ const sortedExpected = [...expected].sort();
38
+ return actual.length === sortedExpected.length && actual.every((key, index) => key === sortedExpected[index]);
39
+ }
40
+ function byteLength(value) {
41
+ return new TextEncoder().encode(value).byteLength;
42
+ }
43
+ function safeDocId(value) {
44
+ if (typeof value !== "string" || value.trim() === "" || value.startsWith("/") || value.includes("\\"))
45
+ return false;
46
+ const segments = value.split("/");
47
+ return (!segments.some((segment) => segment === "" || segment === "." || segment === "..") &&
48
+ !segments.slice(0, -1).some((segment) => segment.toLowerCase().endsWith(".md")));
49
+ }
50
+ function safeScalar(value) {
51
+ if (typeof value === "string")
52
+ return byteLength(value) <= 4096;
53
+ if (typeof value === "number")
54
+ return Number.isFinite(value);
55
+ return typeof value === "boolean";
56
+ }
57
+ function jsonSize(value) {
58
+ try {
59
+ return byteLength(JSON.stringify(value));
60
+ }
61
+ catch {
62
+ return null;
63
+ }
64
+ }
65
+ export function parseDocumentSetFieldAction(value) {
66
+ if (!isPlainRecord(value) || !exactKeys(value, ["kind", "docId", "field", "value", "expectedVersion"])) {
67
+ throw new Error("action must contain exactly kind, docId, field, value, and expectedVersion");
68
+ }
69
+ if (value.kind !== "document.set-field")
70
+ throw new Error("unsupported action kind");
71
+ if (!safeDocId(value.docId))
72
+ throw new Error("docId must be one canonical bundle-relative concept id");
73
+ const field = typeof value.field === "string" ? value.field.trim() : "";
74
+ if (!field || byteLength(field) > 128)
75
+ throw new Error("field must be a non-empty string of at most 128 bytes");
76
+ const expectedVersion = typeof value.expectedVersion === "string" ? value.expectedVersion.trim() : "";
77
+ if (!expectedVersion || expectedVersion.length > 256) {
78
+ throw new Error("expectedVersion must be a non-empty string of at most 256 characters");
79
+ }
80
+ if (!safeScalar(value.value)) {
81
+ throw new Error("value must be a string (at most 4 KiB), finite number, or boolean");
82
+ }
83
+ return {
84
+ kind: "document.set-field",
85
+ docId: value.docId,
86
+ field,
87
+ value: value.value,
88
+ expectedVersion,
89
+ };
90
+ }
91
+ /** Validate the complete structured-clone message before any shell work or confirmation UI. */
92
+ export function parseActionBridgeMessage(value) {
93
+ if (!isPlainRecord(value) || value.bridge !== ACTION_BRIDGE_PROTOCOL || typeof value.type !== "string")
94
+ return null;
95
+ const size = jsonSize(value);
96
+ const limit = value.type === "action.propose" && isPlainRecord(value.action) && ["document.set-body", "document.update"].includes(String(value.action.kind)) ? MAX_MESSAGE_BYTES : 8 * 1024;
97
+ if (size === null || size > limit)
98
+ return { ok: false, message: `action bridge message must be acyclic JSON of at most ${limit / 1024} KiB` };
99
+ if (value.type === "read-versioned") {
100
+ if (!exactKeys(value, ["bridge", "type", "id", "docId"]) || typeof value.id !== "string" || !value.id || value.id.length > 64 || !safeDocId(value.docId)) {
101
+ return { ok: false, message: "read-versioned requires exact bridge, type, id, and safe docId fields" };
102
+ }
103
+ return { ok: true, message: value };
104
+ }
105
+ if (value.type === "action.propose") {
106
+ if (!exactKeys(value, ["bridge", "type", "requestId", "action"]) || typeof value.requestId !== "string" || !value.requestId || value.requestId.length > 64) {
107
+ return { ok: false, message: "action.propose requires an exact non-empty requestId of at most 64 characters" };
108
+ }
109
+ try {
110
+ const action = parseDocumentAction(value.action);
111
+ return { ok: true, message: { bridge: ACTION_BRIDGE_PROTOCOL, type: "action.propose", requestId: value.requestId, action } };
112
+ }
113
+ catch {
114
+ return { ok: false, message: "action.propose requires one valid document.set-field or document.set-body action" };
115
+ }
116
+ }
117
+ return { ok: false, message: `unknown action bridge request '${value.type}'` };
118
+ }
119
+ export function actionReply(requestId, result) {
120
+ return { bridge: ACTION_BRIDGE_PROTOCOL, requestId, type: "action.result", result };
121
+ }
122
+ export function actionError(id, message) {
123
+ return { bridge: ACTION_BRIDGE_PROTOCOL, id, type: "error", error: { code: "REJECTED", message } };
124
+ }
125
+ //# sourceMappingURL=action-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-bridge.js","sourceRoot":"","sources":["../src/action-bridge.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAC3C,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,CAAC;AACrC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,CAAC;AA4B/C,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,KAAK,UAAU;YACvG,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;YAClH,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACpE,MAAM,IAAI,GAAG,mBAAmB,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAA0B,CAAC;QAC3I,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QAC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C,MAAM,GAAG,EAAE,EAAE,CAAC;YAC3J,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,+EAA+E,EAAE,CAAC;QACjH,CAAC;QACD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACjD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;QAC/H,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,kFAAkF,EAAE,CAAC;QACpH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,kCAAkC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,MAAe;IAC5D,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,EAAsB,EAAE,OAAe;IACjE,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;AACrG,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { type KindRegistry } from "@superbee/core/kinds";
2
+ import type { OkfDocument } from "@superbee/core/storage";
3
+ import { type ActionScalar } from "./action-bridge.js";
4
+ export interface ViewActionPreparationContext {
5
+ registry: KindRegistry;
6
+ okfVersion: string | undefined;
7
+ actor: string;
8
+ producer?: string;
9
+ timestamp: string;
10
+ }
11
+ /** Host-neutral proposal policy. Hosts retain authority, confirmation, and final CAS. */
12
+ export declare function prepareViewDocumentAction(doc: OkfDocument, rawAction: unknown, options: ViewActionPreparationContext): {
13
+ action: import("./action-bridge.js").DocumentAction;
14
+ kind: import("@superbee/core/kinds").KindConvention;
15
+ storageField: string;
16
+ storageFields: {
17
+ [k: string]: string;
18
+ };
19
+ before: ActionScalar | null;
20
+ after: ActionScalar;
21
+ candidate: import("@superbee/core/document-mutation").DocumentMutationCandidate;
22
+ changed: boolean;
23
+ warnings: import("@superbee/core/kinds").ValidationWarning[];
24
+ guidance: import("@superbee/core/kinds").KindValueGuidance[];
25
+ };
26
+ //# sourceMappingURL=action-preparation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-preparation.d.ts","sourceRoot":"","sources":["../src/action-preparation.ts"],"names":[],"mappings":"AAGA,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAA8C,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEnG,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,YAAY,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAMD,yFAAyF;AACzF,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,4BAA4B;;;;;;;;;;;;;EAiEpH"}
@@ -0,0 +1,83 @@
1
+ import { parseLinksFromDoc } from "@superbee/core/links";
2
+ import { prepareDocumentFieldAction } from "@superbee/core/document-field-actions";
3
+ import { prepareDocumentMutationCandidate } from "@superbee/core/document-mutation";
4
+ import { resolveKindFieldCoordinate } from "@superbee/core/kinds";
5
+ import { parseDocumentAction, MAX_ACTION_BODY_BYTES } from "./action-bridge.js";
6
+ function isActionScalar(value) {
7
+ return typeof value === "string" || typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value));
8
+ }
9
+ /** Host-neutral proposal policy. Hosts retain authority, confirmation, and final CAS. */
10
+ export function prepareViewDocumentAction(doc, rawAction, options) {
11
+ const action = parseDocumentAction(rawAction);
12
+ const { registry, okfVersion, timestamp } = options;
13
+ const actor = options.actor.trim();
14
+ if (!actor)
15
+ throw new Error("set an action actor for this View host before proposing writes");
16
+ if (doc.id !== action.docId)
17
+ throw new Error("the action target does not match the loaded document");
18
+ if (["type", "timestamp", "actor"].includes(action.field))
19
+ throw new Error(`field '${action.field}' is shell-managed and cannot be proposed`);
20
+ const targetType = String(doc.frontmatter.type ?? "");
21
+ const kind = registry.kinds.get(targetType);
22
+ if (!kind)
23
+ throw new Error(`document '${action.docId}' is not governed by a declared Kind`);
24
+ const update = action.kind === "document.update";
25
+ const bodyAction = action.kind !== "document.set-field";
26
+ const proposedBody = action.kind === "document.update" ? action.value.body : bodyAction ? action.value : doc.body;
27
+ const updates = action.kind === "document.update" ? Object.entries(action.value.fields) : [];
28
+ const beforeFields = {};
29
+ const mapped = new Set();
30
+ for (const [field] of updates) {
31
+ const coordinate = resolveKindFieldCoordinate(okfVersion, kind, field);
32
+ if (["type", "timestamp", "actor"].includes(field) || !coordinate || mapped.has(coordinate.storageField))
33
+ throw new Error("update fields must be distinct declared scalar fields, not shell-managed fields");
34
+ mapped.add(coordinate.storageField);
35
+ const prior = doc.frontmatter[coordinate.storageField];
36
+ if (prior != null && (!isActionScalar(prior) || (typeof prior === "string" && new TextEncoder().encode(prior).byteLength > 4096)))
37
+ throw new Error("updates cannot replace non-scalar fields");
38
+ beforeFields[field] = prior == null ? null : prior;
39
+ }
40
+ const fieldCoordinate = bodyAction ? { storageField: action.field } : resolveKindFieldCoordinate(okfVersion, kind, action.field);
41
+ if (!fieldCoordinate) {
42
+ throw new Error(`field '${action.field}' is not declared by the '${kind.governs}' Kind`);
43
+ }
44
+ if (bodyAction && new TextEncoder().encode(doc.body).byteLength > MAX_ACTION_BODY_BYTES)
45
+ throw new Error("the existing body exceeds the 64 KiB confirmation limit");
46
+ if (bodyAction) {
47
+ const proposed = new Set(parseLinksFromDoc({ ...doc, body: proposedBody }).map(link => JSON.stringify([link.to, link.text])));
48
+ if (parseLinksFromDoc(doc).some(link => !proposed.has(JSON.stringify([link.to, link.text]))))
49
+ throw new Error("body proposals must preserve existing cross-links; use the canonical link tools to change relationships");
50
+ }
51
+ const beforeRaw = update ? JSON.stringify({ fields: beforeFields, body: doc.body }, null, 2) : bodyAction ? doc.body : doc.frontmatter[fieldCoordinate.storageField];
52
+ let before;
53
+ if (beforeRaw === undefined || beforeRaw === null) {
54
+ before = null;
55
+ }
56
+ else if (!isActionScalar(beforeRaw)) {
57
+ throw new Error(`field '${action.field}' currently contains a non-scalar value; trusted scalar actions cannot replace it`);
58
+ }
59
+ else {
60
+ before = beforeRaw;
61
+ }
62
+ let prepared;
63
+ {
64
+ if (okfVersion !== undefined && okfVersion !== "0.1" && okfVersion !== "0.2") {
65
+ throw new Error(`unsupported bundle OKF edition '${okfVersion}'`);
66
+ }
67
+ const context = { registry, okfVersion: okfVersion ?? "0.1", now: () => timestamp };
68
+ let candidate = action.kind === "document.set-field"
69
+ ? prepareDocumentFieldAction(doc, { action: "set", field: action.field, value: action.value }, context).candidate
70
+ : { frontmatter: doc.frontmatter, body: proposedBody };
71
+ for (const [field, value] of updates)
72
+ candidate = prepareDocumentFieldAction({ ...doc, ...candidate }, { action: "set", field, value }, context).candidate;
73
+ prepared = prepareDocumentMutationCandidate(doc, candidate, {
74
+ ...context, id: action.docId, strict: true, actor, producer: options.producer, persistActor: true,
75
+ });
76
+ }
77
+ const storageFields = Object.fromEntries(updates.map(([field]) => [field, resolveKindFieldCoordinate(okfVersion, kind, field).storageField]));
78
+ return {
79
+ ...prepared, action, kind, storageField: fieldCoordinate.storageField, storageFields, before,
80
+ after: action.kind === "document.update" ? JSON.stringify({ fields: action.value.fields, body: prepared.candidate.body }, null, 2) : bodyAction ? prepared.candidate.body : action.value,
81
+ };
82
+ }
83
+ //# sourceMappingURL=action-preparation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-preparation.js","sourceRoot":"","sources":["../src/action-preparation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAqB,MAAM,sBAAsB,CAAC;AAErF,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAqB,MAAM,oBAAoB,CAAC;AAUnG,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1H,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,yBAAyB,CAAC,GAAgB,EAAE,SAAkB,EAAE,OAAqC;IACnH,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC9C,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACpD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACnC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IAC9F,IAAI,GAAG,CAAC,EAAE,KAAK,MAAM,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IACrG,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM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Aa,EAAE,MAAM;QAC5F,KAAK,EAAE,MAAM,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAqB;KACzM,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./view-bridge-host.js";
2
+ export { viewFrameHeaders, viewFramePolicy } from "./view-frame.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./view-bridge-host.js";
2
+ export { viewFrameHeaders, viewFramePolicy } from "./view-frame.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** A read adapter's own refusal, apart from any schemas that raise it, so a module that only
2
+ * recognizes it (the View bridge host) loads no schema library. An adapter that checks the shape of
3
+ * an operation's result throws this class, so the host tells a malformed result (`RUNTIME`) from a
4
+ * result-size ceiling (`TOO_LARGE`), which throws a plain `Error("invalid_response")`. */
5
+ export declare class ReadAdapterError extends Error {
6
+ readonly code: "invalid_input" | "invalid_response";
7
+ constructor(code: "invalid_input" | "invalid_response");
8
+ }
9
+ //# sourceMappingURL=read-adapter-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-adapter-error.d.ts","sourceRoot":"","sources":["../src/read-adapter-error.ts"],"names":[],"mappings":"AAAA;;;0FAG0F;AAC1F,qBAAa,gBAAiB,SAAQ,KAAK;IAC7B,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,kBAAkB;gBAA1C,IAAI,EAAE,eAAe,GAAG,kBAAkB;CAGhE"}
@@ -0,0 +1,12 @@
1
+ /** A read adapter's own refusal, apart from any schemas that raise it, so a module that only
2
+ * recognizes it (the View bridge host) loads no schema library. An adapter that checks the shape of
3
+ * an operation's result throws this class, so the host tells a malformed result (`RUNTIME`) from a
4
+ * result-size ceiling (`TOO_LARGE`), which throws a plain `Error("invalid_response")`. */
5
+ export class ReadAdapterError extends Error {
6
+ code;
7
+ constructor(code) {
8
+ super(code);
9
+ this.code = code;
10
+ }
11
+ }
12
+ //# sourceMappingURL=read-adapter-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-adapter-error.js","sourceRoot":"","sources":["../src/read-adapter-error.ts"],"names":[],"mappings":"AAAA;;;0FAG0F;AAC1F,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACpB;IAArB,YAAqB,IAA0C;QAC7D,KAAK,CAAC,IAAI,CAAC,CAAC;QADO,SAAI,GAAJ,IAAI,CAAsC;IAE/D,CAAC;CACF"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * An operation-mapped View bridge host: the parent-page half of the View protocol
3
+ * (`docs/VIEW-PROTOCOL.md`, bridge `v0` and the v1 `read-versioned` and `action.propose`), for a
4
+ * page that runs a View in a sandboxed frame. It parses what the View's frame posts, maps each data
5
+ * request onto one named operation that the page's `execute` callback runs on the person's behalf,
6
+ * and answers in the protocol's vocabulary. It has no data semantics of its own:
7
+ *
8
+ * | request | operation |
9
+ * | --- | --- |
10
+ * | `query` | `documents.query.v1` |
11
+ * | `read`, `read-versioned`, `render-document` | `documents.read.v1` |
12
+ * | `relationships` | `documents.relationships.v1` |
13
+ * | `edges` | `documents.edges.v1` |
14
+ * | `graph` | `bundles.graph.v1` |
15
+ * | `action.propose` (v1) | the page's `proposeAction` (`documents.update.v1` behind its confirmation) |
16
+ *
17
+ * A request whose operation the caller does not offer is not declared in `hello` and is refused
18
+ * with `FORBIDDEN`. A query feature the operations cannot answer yet (`query.field-or`, `query.open`,
19
+ * `query.kind-projection`, `query.count`) is declared absent, and the query that needs it is refused
20
+ * with `USAGE` instead of being answered with less: a `field` with more than one value, `open: true`,
21
+ * and a `field` on the logical `progress_status`. A capped `query` says `more: true`.
22
+ *
23
+ * The bundle is fixed when the host is made: every operation input carries that `bundleId` and a
24
+ * View cannot name another. Nothing here builds an address: `hello.bundle` is `{ root: null, name }`,
25
+ * and `open-page` asks the page's own resolver.
26
+ *
27
+ * A host that stops answering must remove the frame. The protocol's reference client never times a
28
+ * request out, so a frame whose requests go unanswered waits forever: when `admitted()` turns false
29
+ * the host calls `invalidate()` and answers nothing more, and when `stop()` runs waiting requests are
30
+ * dropped. In both cases the page removes the View's frame (`invalidate` is where it does so).
31
+ */
32
+ import { ACTION_BRIDGE_PROTOCOL, type DocumentAction } from "./action-bridge.js";
33
+ export { ReadAdapterError } from "./read-adapter-error.js";
34
+ /** The row orders `documents.query.v1` answers: canonical id (the default) or newest first. */
35
+ export declare const QUERY_ORDERS: readonly ["id", "newest"];
36
+ /** `bundles.graph.v1`'s ceilings, which equal the protocol's `graph` ceilings. */
37
+ export declare const GRAPH_MAX_DOCUMENTS = 1000;
38
+ export declare const GRAPH_MAX_RELATIONSHIPS = 10000;
39
+ export declare const BRIDGE_PROTOCOL = "v0";
40
+ export { ACTION_BRIDGE_PROTOCOL };
41
+ /** The operations a View's requests map onto, by the names the caller's `execute` runs them under. */
42
+ export declare const VIEW_BRIDGE_OPERATIONS: readonly ["documents.read.v1", "documents.query.v1", "documents.relationships.v1", "documents.edges.v1", "bundles.graph.v1", "documents.update.v1"];
43
+ export type ViewBridgeOperation = (typeof VIEW_BRIDGE_OPERATIONS)[number];
44
+ /** The ceilings this host enforces where the caller offers the request; `bridgeLimits` zeroes the
45
+ * ones it does not offer, which is how the protocol expresses "not offered". */
46
+ export declare const BRIDGE_LIMITS: Readonly<{
47
+ query: 100;
48
+ edges: 1000;
49
+ graphDocuments: 1000;
50
+ graphRelationships: 10000;
51
+ replyBytes: number;
52
+ }>;
53
+ export type BridgeErrorCode = "USAGE" | "FORBIDDEN" | "REVOKED" | "TOO_LARGE" | "RUNTIME" | "NOT_FOUND";
54
+ /** What the page's reader answers for `record.open`. */
55
+ export type ViewBridgeUiResult = {
56
+ ok: true;
57
+ } | {
58
+ ok: false;
59
+ code: "unsupported" | "invalid_input" | "not_found" | "denied" | "unavailable" | "cancelled" | "busy";
60
+ };
61
+ /** The View's frame window as the host uses it: where replies are posted. */
62
+ export interface ViewBridgeFrame {
63
+ postMessage(message: unknown, targetOrigin: string): void;
64
+ }
65
+ /** A `message` event the page received, as the host reads it. */
66
+ export interface ViewBridgeMessage {
67
+ readonly source: unknown;
68
+ readonly origin: string;
69
+ readonly data: unknown;
70
+ }
71
+ /** The one bundle the View reads: its id (sent with every operation) and the name the page shows
72
+ * for it (`hello.bundle.name`, never an internal id). */
73
+ export interface ViewBridgeBundle {
74
+ readonly id: string;
75
+ readonly name: string;
76
+ }
77
+ /** Runs one operation on the person's behalf, as the caller runs it, with the host's input (the fixed
78
+ * `bundleId` included) and answers the operation's result envelope. */
79
+ export type ViewBridgeExecute = (operation: ViewBridgeOperation, input: unknown, signal: AbortSignal) => Promise<unknown>;
80
+ /** Everything else the host is given, in one object so later options are added without changing
81
+ * the call. */
82
+ export interface ViewBridgeHostOptions {
83
+ /** The operations the caller runs on the person's behalf for this View; a request mapped to any
84
+ * other is not declared in `hello` and is refused with FORBIDDEN. */
85
+ readonly operations: readonly ViewBridgeOperation[];
86
+ /** Whether the View may still be answered (the page's binding, grant or lifetime). Checked before
87
+ * and after every operation; when false the host calls `invalidate` and answers nothing. */
88
+ admitted?(): boolean;
89
+ /** The page removes the View's frame (and stops this host). */
90
+ invalidate?(): void;
91
+ /** Called once, on the first bridge request of any type: a View need not send `hello`. */
92
+ onReady?(): void;
93
+ /** `render-document`: the shared inert Markdown renderer (`@superbee/markdown-renderer/static`'s
94
+ * `renderDocumentToStaticHtml`), so a View receives the same markup on every host. Absent, the
95
+ * request is not offered. */
96
+ renderDocument?(document: {
97
+ id: string;
98
+ body: string;
99
+ }): {
100
+ html: string;
101
+ bounded: boolean;
102
+ };
103
+ /** v1 `action.propose`, behind the page's own confirmation; offered only with `documents.read.v1`
104
+ * and `documents.update.v1` in `operations`. */
105
+ proposeAction?(action: DocumentAction, signal: AbortSignal): Promise<unknown>;
106
+ /** `host` capability `record.open`: the page opens its own reader for one document. */
107
+ recordAvailable?(): boolean;
108
+ openRecord?(documentId: string, signal: AbortSignal): Promise<ViewBridgeUiResult>;
109
+ /** The page owns the frame's presentation: `hello.host.frame` tells the View so, `theme` carries
110
+ * the page's tokens, and `frame.resize` lets the View report its content height. `resize` returns
111
+ * the height the frame now draws at, within the page's bounds; `maxHeight` is the largest. */
112
+ frame?: {
113
+ resize(height: number): number;
114
+ readonly maxHeight: number;
115
+ readonly theme?: Readonly<Record<string, string>>;
116
+ };
117
+ /** `open-page`: the page opens the View its bundle registers as `registryId` (a sibling of this
118
+ * View in the same bundle), resolving it from what the page already knows, never from the
119
+ * request, and answers whether it did. Absent, `open-page` is not offered. */
120
+ openPage?(registryId: string): boolean;
121
+ }
122
+ /** The registry capabilities this host declares for `operations` and the page's services, sorted as
123
+ * the protocol requires. Of the `query.*` capabilities only `query.newest` is declared:
124
+ * `documents.query.v1` orders by newest meaningful change, and it has no OR of field values, no
125
+ * terminal filter, no Kind projection and no total count yet, so `query.field-or`, `query.open`,
126
+ * `query.kind-projection` and `query.count` are absent (and refused as `USAGE` where a query needs
127
+ * them). Whether `query` is offered at all is `limits.query`, not a capability. */
128
+ export declare function bridgeCapabilities(operations: ReadonlySet<ViewBridgeOperation>, services?: {
129
+ renderDocument?: boolean;
130
+ recordOpen?: boolean;
131
+ frameResize?: boolean;
132
+ openPage?: boolean;
133
+ }): string[];
134
+ /** The declared ceilings: `0` for a request the caller does not offer. */
135
+ export declare function bridgeLimits(operations: ReadonlySet<ViewBridgeOperation>): {
136
+ query: number;
137
+ edges: number;
138
+ graphDocuments: number;
139
+ graphRelationships: number;
140
+ replyBytes: number;
141
+ };
142
+ /** The host for one View frame. `frame` is the frame's window (the only source whose messages are
143
+ * admitted, and only from the opaque origin `"null"` a `sandbox="allow-scripts"` frame has);
144
+ * `bundle` is fixed for the host's life; `execute` runs an operation on the person's behalf. The
145
+ * page forwards every `message` event to `receive`, calls `refresh` when its data may have
146
+ * changed, and `stop` when it removes the frame. */
147
+ export declare function createViewBridgeHost(frame: ViewBridgeFrame, bundle: ViewBridgeBundle, execute: ViewBridgeExecute, options: ViewBridgeHostOptions): {
148
+ /** An empty `change` after `subscribe`: the refresh signal a host without deltas may send. */
149
+ refresh(): void;
150
+ /** The frame is gone, or about to be: nothing waiting is answered and nothing more is read. */
151
+ stop(): void;
152
+ receive(event: ViewBridgeMessage): Promise<void>;
153
+ };
154
+ export type ViewBridgeHost = ReturnType<typeof createViewBridgeHost>;
155
+ //# sourceMappingURL=view-bridge-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-bridge-host.d.ts","sourceRoot":"","sources":["../src/view-bridge-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,sBAAsB,EAAyC,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAQxH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,+FAA+F;AAC/F,eAAO,MAAM,YAAY,2BAA4B,CAAC;AACtD,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,OAAO,CAAC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