@action-state-group/capsule-viewer 0.0.0 → 0.3.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/LICENSE +201 -0
- package/LICENSE-BSD-3-Clause +28 -0
- package/README.md +94 -1
- package/dist/alias-interpreters.d.ts +18 -0
- package/dist/alias-interpreters.js +50 -0
- package/dist/alias-interpreters.js.map +1 -0
- package/dist/browser.d.ts +7 -0
- package/dist/browser.js +25 -0
- package/dist/browser.js.map +1 -0
- package/dist/builtin-manifests.d.ts +51 -0
- package/dist/builtin-manifests.js +196 -0
- package/dist/builtin-manifests.js.map +1 -0
- package/dist/compliance-presentation.d.ts +51 -0
- package/dist/compliance-presentation.js +140 -0
- package/dist/compliance-presentation.js.map +1 -0
- package/dist/compliance-styles.d.ts +1 -0
- package/dist/compliance-styles.js +104 -0
- package/dist/compliance-styles.js.map +1 -0
- package/dist/compliance-view.d.ts +46 -0
- package/dist/compliance-view.js +828 -0
- package/dist/compliance-view.js.map +1 -0
- package/dist/compliance.d.ts +121 -0
- package/dist/compliance.js +412 -0
- package/dist/compliance.js.map +1 -0
- package/dist/composed-styles.d.ts +12 -0
- package/dist/composed-styles.js +20 -0
- package/dist/composed-styles.js.map +1 -0
- package/dist/composed-view.d.ts +24 -0
- package/dist/composed-view.js +186 -0
- package/dist/composed-view.js.map +1 -0
- package/dist/contract-report-wording.d.ts +195 -0
- package/dist/contract-report-wording.js +1141 -0
- package/dist/contract-report-wording.js.map +1 -0
- package/dist/contract-report.d.ts +92 -0
- package/dist/contract-report.js +63 -0
- package/dist/contract-report.js.map +1 -0
- package/dist/emitter-shell.html +310 -0
- package/dist/emitter.d.ts +105 -0
- package/dist/emitter.js +329 -0
- package/dist/emitter.js.map +1 -0
- package/dist/evidence-graph-view.d.ts +149 -0
- package/dist/evidence-graph-view.js +2718 -0
- package/dist/evidence-graph-view.js.map +1 -0
- package/dist/evidence-graph.iife.js +18159 -0
- package/dist/frame-tokens.generated.d.ts +3 -0
- package/dist/frame-tokens.generated.js +5 -0
- package/dist/frame-tokens.generated.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/outcome-report-presentation.d.ts +48 -0
- package/dist/outcome-report-presentation.js +90 -0
- package/dist/outcome-report-presentation.js.map +1 -0
- package/dist/outcome-report-styles.d.ts +1 -0
- package/dist/outcome-report-styles.js +228 -0
- package/dist/outcome-report-styles.js.map +1 -0
- package/dist/outcome-report-view.d.ts +78 -0
- package/dist/outcome-report-view.js +1488 -0
- package/dist/outcome-report-view.js.map +1 -0
- package/dist/presentation-builder.d.ts +296 -0
- package/dist/presentation-builder.js +646 -0
- package/dist/presentation-builder.js.map +1 -0
- package/dist/presentation-fragment.d.ts +129 -0
- package/dist/presentation-fragment.js +213 -0
- package/dist/presentation-fragment.js.map +1 -0
- package/dist/presentation-mount.d.ts +26 -0
- package/dist/presentation-mount.js +45 -0
- package/dist/presentation-mount.js.map +1 -0
- package/dist/presentation-registry.d.ts +277 -0
- package/dist/presentation-registry.js +416 -0
- package/dist/presentation-registry.js.map +1 -0
- package/dist/record-content.d.ts +68 -0
- package/dist/record-content.js +153 -0
- package/dist/record-content.js.map +1 -0
- package/dist/record-dating.d.ts +10 -0
- package/dist/record-dating.js +76 -0
- package/dist/record-dating.js.map +1 -0
- package/dist/report-front-styles.d.ts +9 -0
- package/dist/report-front-styles.js +55 -0
- package/dist/report-front-styles.js.map +1 -0
- package/dist/report-front.d.ts +78 -0
- package/dist/report-front.js +274 -0
- package/dist/report-front.js.map +1 -0
- package/dist/report-levels.d.ts +206 -0
- package/dist/report-levels.js +739 -0
- package/dist/report-levels.js.map +1 -0
- package/dist/report-provenance.d.ts +111 -0
- package/dist/report-provenance.js +535 -0
- package/dist/report-provenance.js.map +1 -0
- package/dist/viewer-build.d.ts +37 -0
- package/dist/viewer-build.js +29 -0
- package/dist/viewer-build.js.map +1 -0
- package/dist/wording/contract-report-eu-ai-act.en.json +295 -0
- package/dist/wording/contract-report-outcomes.en.json +394 -0
- package/package.json +48 -4
package/dist/emitter.js
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { COMPLIANCE_CSS } from "./compliance-styles.js";
|
|
5
|
+
import { COMPOSED_CSS } from "./composed-styles.js";
|
|
6
|
+
import { jcs } from "@action-state-group/agent-action-capsule";
|
|
7
|
+
import { OUTCOME_REPORT_CSS } from "./outcome-report-styles.js";
|
|
8
|
+
import { RECORD_CONTENT_CSS } from "./record-content.js";
|
|
9
|
+
const cspSlot = "__CSP_SLOT__";
|
|
10
|
+
const titleSlot = "__TITLE_SLOT__";
|
|
11
|
+
const themeSlot = "__THEME_SLOT__";
|
|
12
|
+
const bundleSlot = "__BUNDLE_SLOT__";
|
|
13
|
+
const coreRuntimeSlot = "__CORE_RUNTIME_SLOT__";
|
|
14
|
+
const moduleSlot = "__MODULE_SLOT__";
|
|
15
|
+
const bootstrapSlot = "__BOOTSTRAP_SLOT__";
|
|
16
|
+
const slots = [
|
|
17
|
+
cspSlot,
|
|
18
|
+
titleSlot,
|
|
19
|
+
themeSlot,
|
|
20
|
+
bundleSlot,
|
|
21
|
+
coreRuntimeSlot,
|
|
22
|
+
moduleSlot,
|
|
23
|
+
bootstrapSlot,
|
|
24
|
+
];
|
|
25
|
+
/** The page title used when the caller supplies none. */
|
|
26
|
+
export const DEFAULT_EVIDENCE_GRAPH_TITLE = "Evidence Graph";
|
|
27
|
+
/** The bootstrap script used when the caller supplies none. */
|
|
28
|
+
export const DEFAULT_EVIDENCE_GRAPH_BOOTSTRAP = 'renderEvidenceGraph(window.__BUNDLE__, document.getElementById("app"));';
|
|
29
|
+
/**
|
|
30
|
+
* The stylesheets the reference core runtime inserts as `<style>` elements
|
|
31
|
+
* at render time. They are not inline in the emitted bytes, so the CSP lists
|
|
32
|
+
* their hashes explicitly; go/emitter/runtime-style-hashes.txt carries the
|
|
33
|
+
* same list for the Go emitter (a test keeps the two equal).
|
|
34
|
+
*/
|
|
35
|
+
export const CORE_RUNTIME_STYLES = [
|
|
36
|
+
OUTCOME_REPORT_CSS,
|
|
37
|
+
COMPLIANCE_CSS,
|
|
38
|
+
RECORD_CONTENT_CSS,
|
|
39
|
+
COMPOSED_CSS,
|
|
40
|
+
];
|
|
41
|
+
const shell = readFileSync(new URL("./emitter-shell.html", import.meta.url), "utf8");
|
|
42
|
+
function replaceSingle(template, placeholder, value) {
|
|
43
|
+
const parts = template.split(placeholder);
|
|
44
|
+
if (parts.length !== 2) {
|
|
45
|
+
throw new Error(`emitter shell must contain exactly one ${placeholder} slot`);
|
|
46
|
+
}
|
|
47
|
+
return `${parts[0]}${value}${parts[1]}`;
|
|
48
|
+
}
|
|
49
|
+
/** JSON embedded in a script element must not be able to terminate that element. */
|
|
50
|
+
export function escapeJsonForHtmlScript(json) {
|
|
51
|
+
return json
|
|
52
|
+
.replaceAll("<", "\\u003c")
|
|
53
|
+
.replaceAll(">", "\\u003e")
|
|
54
|
+
.replaceAll("&", "\\u0026")
|
|
55
|
+
.replaceAll("\u2028", "\\u2028")
|
|
56
|
+
.replaceAll("\u2029", "\\u2029");
|
|
57
|
+
}
|
|
58
|
+
/** A value for a double-quoted HTML attribute. */
|
|
59
|
+
function escapeAttribute(value) {
|
|
60
|
+
return value
|
|
61
|
+
.replaceAll("&", "&")
|
|
62
|
+
.replaceAll('"', """)
|
|
63
|
+
.replaceAll("<", "<");
|
|
64
|
+
}
|
|
65
|
+
function escapeHtmlText(value) {
|
|
66
|
+
return value
|
|
67
|
+
.replaceAll("&", "&")
|
|
68
|
+
.replaceAll("<", "<")
|
|
69
|
+
.replaceAll(">", ">")
|
|
70
|
+
.replaceAll('"', """)
|
|
71
|
+
.replaceAll("'", "'");
|
|
72
|
+
}
|
|
73
|
+
function sha256(value) {
|
|
74
|
+
return createHash("sha256").update(value, "utf8").digest();
|
|
75
|
+
}
|
|
76
|
+
/** The CSP hash source for a lowercase hex SHA-256 digest (a `.sha256` pin). */
|
|
77
|
+
export function cspHashSourceFromHex(hex) {
|
|
78
|
+
if (!/^[0-9a-f]{64}$/u.test(hex)) {
|
|
79
|
+
throw new Error("SHA-256 pin must be 64 lowercase hex characters");
|
|
80
|
+
}
|
|
81
|
+
return `'sha256-${Buffer.from(hex, "hex").toString("base64")}'`;
|
|
82
|
+
}
|
|
83
|
+
function cspHashSource(value) {
|
|
84
|
+
return `'sha256-${sha256(value).toString("base64")}'`;
|
|
85
|
+
}
|
|
86
|
+
// Inline content must reach the browser as the exact bytes hashed: no end
|
|
87
|
+
// tag or comment opener that changes where the element ends, and no CR or
|
|
88
|
+
// NUL that the HTML parser rewrites before the CSP check hashes the text.
|
|
89
|
+
function checkInline(name, value, endTag) {
|
|
90
|
+
const lower = value.toLowerCase();
|
|
91
|
+
if (lower.includes(endTag) || lower.includes("<!--")) {
|
|
92
|
+
throw new Error(`${name} must not contain ${endTag} or <!--`);
|
|
93
|
+
}
|
|
94
|
+
if (value.includes("\r") || value.includes("\0")) {
|
|
95
|
+
throw new Error(`${name} must not contain CR or NUL characters`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Collect the text of every <script> and <style> element in document order.
|
|
99
|
+
// The shell writes both start tags bare, and checkInline guarantees each
|
|
100
|
+
// element's text runs to the first matching end tag.
|
|
101
|
+
function inlineElements(html) {
|
|
102
|
+
const found = { script: [], style: [] };
|
|
103
|
+
let offset = 0;
|
|
104
|
+
for (;;) {
|
|
105
|
+
const script = html.indexOf("<script>", offset);
|
|
106
|
+
const style = html.indexOf("<style>", offset);
|
|
107
|
+
if (script === -1 && style === -1)
|
|
108
|
+
return found;
|
|
109
|
+
const kind = style === -1 || (script !== -1 && script < style) ? "script" : "style";
|
|
110
|
+
const start = (kind === "script" ? script : style) + kind.length + 2;
|
|
111
|
+
const end = html.indexOf(`</${kind}>`, start);
|
|
112
|
+
if (end === -1)
|
|
113
|
+
throw new Error(`unterminated ${kind} element`);
|
|
114
|
+
found[kind].push(html.slice(start, end));
|
|
115
|
+
offset = end + kind.length + 3;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function unique(values) {
|
|
119
|
+
return [...new Set(values)];
|
|
120
|
+
}
|
|
121
|
+
export function emitEvidenceGraphHtml(bundle, browserIIFE, options = {}) {
|
|
122
|
+
const bundleJson = new TextDecoder().decode(jcs(bundle));
|
|
123
|
+
const title = options.title === undefined || options.title === ""
|
|
124
|
+
? DEFAULT_EVIDENCE_GRAPH_TITLE
|
|
125
|
+
: options.title;
|
|
126
|
+
const themeCss = options.themeCss ?? "";
|
|
127
|
+
const modules = options.modules ?? [];
|
|
128
|
+
const bootstrap = options.bootstrap === undefined || options.bootstrap === ""
|
|
129
|
+
? DEFAULT_EVIDENCE_GRAPH_BOOTSTRAP
|
|
130
|
+
: options.bootstrap;
|
|
131
|
+
const inputs = [
|
|
132
|
+
["bundle JSON", bundleJson],
|
|
133
|
+
["browser IIFE", browserIIFE],
|
|
134
|
+
["title", title],
|
|
135
|
+
["theme CSS", themeCss],
|
|
136
|
+
["bootstrap", bootstrap],
|
|
137
|
+
...modules.map((module, index) => [
|
|
138
|
+
`module ${index}`,
|
|
139
|
+
module.code,
|
|
140
|
+
]),
|
|
141
|
+
];
|
|
142
|
+
for (const [name, value] of inputs) {
|
|
143
|
+
if (slots.some((slot) => value.includes(slot))) {
|
|
144
|
+
throw new Error(`${name} must not contain emitter placeholders`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
checkInline("browser IIFE", browserIIFE, "</script");
|
|
148
|
+
checkInline("bootstrap", bootstrap, "</script");
|
|
149
|
+
checkInline("theme CSS", themeCss, "</style");
|
|
150
|
+
if (options.coreRuntimeSha256 !== undefined &&
|
|
151
|
+
cspHashSourceFromHex(options.coreRuntimeSha256) !==
|
|
152
|
+
cspHashSource(browserIIFE)) {
|
|
153
|
+
throw new Error("browser IIFE does not match its SHA-256 pin");
|
|
154
|
+
}
|
|
155
|
+
const moduleStyleSources = [];
|
|
156
|
+
modules.forEach((module, index) => {
|
|
157
|
+
checkInline(`module ${index}`, module.code, "</script");
|
|
158
|
+
if (cspHashSourceFromHex(module.sha256) !== cspHashSource(module.code)) {
|
|
159
|
+
throw new Error(`module ${index} does not match its SHA-256 pin`);
|
|
160
|
+
}
|
|
161
|
+
(module.styleSha256 ?? []).forEach((pin, styleIndex) => {
|
|
162
|
+
try {
|
|
163
|
+
moduleStyleSources.push(cspHashSourceFromHex(pin));
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
throw new Error(`module ${index} style ${styleIndex}: ${error.message}`);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
const embeddedBundleJson = escapeJsonForHtmlScript(bundleJson);
|
|
171
|
+
let html = replaceSingle(shell, titleSlot, escapeHtmlText(title));
|
|
172
|
+
html = replaceSingle(html, themeSlot, themeCss);
|
|
173
|
+
html = replaceSingle(html, bundleSlot, embeddedBundleJson);
|
|
174
|
+
html = replaceSingle(html, coreRuntimeSlot, browserIIFE);
|
|
175
|
+
html = replaceSingle(html, moduleSlot, modules.map((module) => `<script>${module.code}</script>`).join("\n "));
|
|
176
|
+
html = replaceSingle(html, bootstrapSlot, bootstrap);
|
|
177
|
+
const inline = inlineElements(html);
|
|
178
|
+
const scriptSources = unique(inline.script.map(cspHashSource));
|
|
179
|
+
const styleSources = unique([
|
|
180
|
+
...inline.style.map(cspHashSource),
|
|
181
|
+
...CORE_RUNTIME_STYLES.map(cspHashSource),
|
|
182
|
+
...moduleStyleSources,
|
|
183
|
+
]);
|
|
184
|
+
const csp = [
|
|
185
|
+
"default-src 'none'",
|
|
186
|
+
`script-src ${scriptSources.join(" ")}`,
|
|
187
|
+
`style-src ${styleSources.join(" ")}`,
|
|
188
|
+
"img-src data:",
|
|
189
|
+
"connect-src 'none'",
|
|
190
|
+
"base-uri 'none'",
|
|
191
|
+
"form-action 'none'",
|
|
192
|
+
].join("; ");
|
|
193
|
+
html = replaceSingle(html, cspSlot, csp);
|
|
194
|
+
const bundleOffset = html.indexOf(embeddedBundleJson);
|
|
195
|
+
if (slots.some((slot) => html.includes(slot)) ||
|
|
196
|
+
bundleOffset === -1 ||
|
|
197
|
+
html.indexOf(embeddedBundleJson, bundleOffset + embeddedBundleJson.length) !== -1) {
|
|
198
|
+
throw new Error("emitter shell embed invariant failed");
|
|
199
|
+
}
|
|
200
|
+
return html;
|
|
201
|
+
}
|
|
202
|
+
/** The attribute that marks the host element of an embedded snippet. */
|
|
203
|
+
export const EMBEDDED_HOST_ATTRIBUTE = "data-aac-embedded";
|
|
204
|
+
/**
|
|
205
|
+
* The embedded snippet (spec/presentation-builder-v0.md section 2.3) a host
|
|
206
|
+
* page inlines where the presentation goes: the core runtime and each
|
|
207
|
+
* module as inline scripts, the host element, the bundle as a JSON data
|
|
208
|
+
* element (read with JSON.parse, so every member stays data), and a
|
|
209
|
+
* bootstrap that renders into the host element. It carries no CSP; the
|
|
210
|
+
* host's must allow the returned sources. go/emitter's BuildEmbeddedHTML
|
|
211
|
+
* writes the same bytes.
|
|
212
|
+
*/
|
|
213
|
+
export function emitEmbeddedHtml(bundle, browserIIFE, options) {
|
|
214
|
+
const bundleJson = escapeJsonForHtmlScript(new TextDecoder().decode(jcs(bundle)));
|
|
215
|
+
const modules = options.modules ?? [];
|
|
216
|
+
const bootstrap = `(function (data) { renderEvidenceGraph(JSON.parse(data.textContent), data.previousElementSibling, undefined, ${escapeJsonForHtmlScript(options.renderOptions)}); })(document.currentScript.previousElementSibling);`;
|
|
217
|
+
checkInline("browser IIFE", browserIIFE, "</script");
|
|
218
|
+
checkInline("bundle JSON", bundleJson, "</script");
|
|
219
|
+
checkInline("bootstrap", bootstrap, "</script");
|
|
220
|
+
if (options.coreRuntimeSha256 !== undefined &&
|
|
221
|
+
cspHashSourceFromHex(options.coreRuntimeSha256) !==
|
|
222
|
+
cspHashSource(browserIIFE)) {
|
|
223
|
+
throw new Error("browser IIFE does not match its SHA-256 pin");
|
|
224
|
+
}
|
|
225
|
+
const styleSources = CORE_RUNTIME_STYLES.map(cspHashSource);
|
|
226
|
+
modules.forEach((module, index) => {
|
|
227
|
+
checkInline(`module ${index}`, module.code, "</script");
|
|
228
|
+
if (cspHashSourceFromHex(module.sha256) !== cspHashSource(module.code)) {
|
|
229
|
+
throw new Error(`module ${index} does not match its SHA-256 pin`);
|
|
230
|
+
}
|
|
231
|
+
(module.styleSha256 ?? []).forEach((pin, styleIndex) => {
|
|
232
|
+
try {
|
|
233
|
+
styleSources.push(cspHashSourceFromHex(pin));
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
throw new Error(`module ${index} style ${styleIndex}: ${error.message}`);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
const scripts = [browserIIFE, ...modules.map((m) => m.code)];
|
|
241
|
+
const html = [
|
|
242
|
+
...scripts.map((script) => `<script>${script}</script>`),
|
|
243
|
+
`<div ${EMBEDDED_HOST_ATTRIBUTE}></div>`,
|
|
244
|
+
`<script type="application/json">${bundleJson}</script>`,
|
|
245
|
+
`<script>${bootstrap}</script>`,
|
|
246
|
+
"",
|
|
247
|
+
].join("\n");
|
|
248
|
+
return {
|
|
249
|
+
html,
|
|
250
|
+
scriptSources: unique([...scripts, bootstrap].map(cspHashSource)),
|
|
251
|
+
styleSources: unique(styleSources),
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* The stylesheet of the static page's notice (the statement that the page
|
|
256
|
+
* is not self-verifying). Hashed into the static page's CSP like the shell's
|
|
257
|
+
* own stylesheet.
|
|
258
|
+
*/
|
|
259
|
+
export const STATIC_NOTICE_CSS = ":where(.aac-static-notice){display:block;margin:0 0 1rem;padding:0.75rem 1rem;border:1px solid var(--aac-line);border-radius:var(--aac-radius);color:var(--aac-warn);background:var(--aac-warn-bg)}:where(.aac-static-notice p){margin:0.25rem 0}";
|
|
260
|
+
/**
|
|
261
|
+
* Write a static page: the same shell, base stylesheet, title and theme as
|
|
262
|
+
* {@link emitEvidenceGraphHtml}, with already rendered markup in `#app` and
|
|
263
|
+
* no script at all: no bundle element, no runtime, no module, no bootstrap.
|
|
264
|
+
* The CSP allows no script (`script-src 'none'`) and lists every style it
|
|
265
|
+
* carries by hash (style attributes through `'unsafe-hashes'`).
|
|
266
|
+
*
|
|
267
|
+
* The caller guarantees the markup has no script element and no event
|
|
268
|
+
* handler attribute; the CSP would block either anyway.
|
|
269
|
+
*/
|
|
270
|
+
export function emitStaticEvidenceGraphHtml(input, options = {}) {
|
|
271
|
+
const title = options.title === undefined || options.title === ""
|
|
272
|
+
? DEFAULT_EVIDENCE_GRAPH_TITLE
|
|
273
|
+
: options.title;
|
|
274
|
+
const themeCss = options.themeCss ?? "";
|
|
275
|
+
for (const [name, value] of [
|
|
276
|
+
["title", title],
|
|
277
|
+
["theme CSS", themeCss],
|
|
278
|
+
]) {
|
|
279
|
+
if (slots.some((slot) => value.includes(slot))) {
|
|
280
|
+
throw new Error(`${name} must not contain emitter placeholders`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
checkInline("theme CSS", themeCss, "</style");
|
|
284
|
+
input.appStyles.forEach((style, index) => checkInline(`static style ${index}`, style, "</style"));
|
|
285
|
+
// The head is the shell's, with the notice stylesheet added; the body is
|
|
286
|
+
// replaced whole, so none of the shell's script elements is written. The
|
|
287
|
+
// rendered markup is spliced in last, after every slot is filled, so text
|
|
288
|
+
// in it is never read as a slot.
|
|
289
|
+
let page = replaceSingle(shell, titleSlot, escapeHtmlText(title));
|
|
290
|
+
page = replaceSingle(page, themeSlot, themeCss);
|
|
291
|
+
const headEnd = page.indexOf("</head>");
|
|
292
|
+
const bodyStart = page.indexOf("<body>");
|
|
293
|
+
const bodyEnd = page.lastIndexOf("</body>");
|
|
294
|
+
if (headEnd === -1 || bodyStart < headEnd || bodyEnd < bodyStart) {
|
|
295
|
+
throw new Error("emitter shell has no head or body");
|
|
296
|
+
}
|
|
297
|
+
let head = `${page.slice(0, headEnd)} <style>${STATIC_NOTICE_CSS}</style>\n ${page.slice(headEnd, bodyStart)}`;
|
|
298
|
+
const inline = inlineElements(head);
|
|
299
|
+
if (inline.script.length > 0) {
|
|
300
|
+
throw new Error("static page head must carry no script");
|
|
301
|
+
}
|
|
302
|
+
const styleSources = unique([
|
|
303
|
+
...inline.style.map(cspHashSource),
|
|
304
|
+
...input.appStyles.map(cspHashSource),
|
|
305
|
+
]);
|
|
306
|
+
const attributeSources = unique(input.appStyleAttributes.map(cspHashSource));
|
|
307
|
+
const csp = [
|
|
308
|
+
"default-src 'none'",
|
|
309
|
+
"script-src 'none'",
|
|
310
|
+
`style-src ${[
|
|
311
|
+
...styleSources,
|
|
312
|
+
...(attributeSources.length === 0
|
|
313
|
+
? []
|
|
314
|
+
: ["'unsafe-hashes'", ...attributeSources]),
|
|
315
|
+
].join(" ")}`,
|
|
316
|
+
"img-src data:",
|
|
317
|
+
"connect-src 'none'",
|
|
318
|
+
"base-uri 'none'",
|
|
319
|
+
"form-action 'none'",
|
|
320
|
+
].join("; ");
|
|
321
|
+
head = replaceSingle(head, cspSlot, csp);
|
|
322
|
+
if (slots.some((slot) => head.includes(slot))) {
|
|
323
|
+
throw new Error("emitter shell embed invariant failed");
|
|
324
|
+
}
|
|
325
|
+
const html = `${head}<body>\n ${input.noticeHtml}\n ` +
|
|
326
|
+
`<div id="app"${input.appClass ? ` class="${escapeAttribute(input.appClass)}"` : ""}>${input.appHtml}</div>\n ${page.slice(bodyEnd)}`;
|
|
327
|
+
return html;
|
|
328
|
+
}
|
|
329
|
+
//# sourceMappingURL=emitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../src/emitter.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa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,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,IAAI,GACR,GAAG,IAAI,eAAe,KAAK,CAAC,UAAU,QAAQ;QAC9C,gBAAgB,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,OAAO,aAAa,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;IACzI,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { type VerifiedBundleContext } from "@action-state-group/agent-action-capsule";
|
|
2
|
+
import type { PresentationManifest } from "./presentation-registry.js";
|
|
3
|
+
import { type CountersignerSource } from "@action-state-group/agent-action-capsule";
|
|
4
|
+
import { type ContractReportInput } from "./contract-report.js";
|
|
5
|
+
import type { PresentationDepth, WordingPackInput } from "./presentation-fragment.js";
|
|
6
|
+
import { PresentationRegistry, type PresentationFormat, type PresentationModule, type PresentationRegistration, type PresentationResolution, type PresentationResolver, type PresentationRuntime } from "./presentation-registry.js";
|
|
7
|
+
/**
|
|
8
|
+
* Draw the `checking` state into `root`, replacing what it held: the
|
|
9
|
+
* banner alone, with no verdict and no row, until the checks finish
|
|
10
|
+
* (presentation contract section 6.2). Returns that banner's bar.
|
|
11
|
+
*/
|
|
12
|
+
export declare function renderChecking(root: HTMLElement): HTMLElement;
|
|
13
|
+
/** The words a page says when this viewer cannot verify the bundle at all. */
|
|
14
|
+
export declare const UNABLE_TO_VERIFY_LINES: {
|
|
15
|
+
readonly banner: "Couldn't check this page here: check it with a full verifier";
|
|
16
|
+
readonly reason: "This viewer cannot compute the SHA-256 digests the checks need, so nothing was checked and no records are shown. This is not a failed check: the file may well be valid.";
|
|
17
|
+
readonly command: "To check this file, run:";
|
|
18
|
+
readonly noCommand: "To check this file, open it from a secure (https) page, or check it with a verifier outside this viewer.";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Render the "unable to verify in this viewer" state into `root`: drawn,
|
|
22
|
+
* in place of any verification result, when this runtime has no SHA-256
|
|
23
|
+
* (`digestCapability() === "none"`). It never says the bundle failed, and
|
|
24
|
+
* it shows no record. `verifyCommand` is the exact command a reader runs
|
|
25
|
+
* to check the file elsewhere; without one, the page says where to check
|
|
26
|
+
* it instead.
|
|
27
|
+
*/
|
|
28
|
+
export declare function renderUnableToVerify(root: HTMLElement, options?: {
|
|
29
|
+
readonly verifyCommand?: string;
|
|
30
|
+
}): void;
|
|
31
|
+
/**
|
|
32
|
+
* The one line a closed "How this page was checked" section shows, so what
|
|
33
|
+
* this page did not check stays in view with it folded: how many of the
|
|
34
|
+
* checks passed (or failed), how many records the file carries, and the
|
|
35
|
+
* signatures or other checks this page did not run.
|
|
36
|
+
*/
|
|
37
|
+
export declare function checkedSummaryLine(verified: boolean, model: {
|
|
38
|
+
readonly checks: readonly {
|
|
39
|
+
readonly status: string;
|
|
40
|
+
}[];
|
|
41
|
+
readonly records: readonly unknown[];
|
|
42
|
+
readonly checkLists: {
|
|
43
|
+
readonly failed: readonly string[];
|
|
44
|
+
readonly notChecked: readonly string[];
|
|
45
|
+
};
|
|
46
|
+
}): string;
|
|
47
|
+
/** The summary's lead for a bundle that failed outside every counted check. */
|
|
48
|
+
export declare const SUMMARY_NOT_VERIFIED = "the bundle did not verify";
|
|
49
|
+
/** The folded verification section's heading. */
|
|
50
|
+
export declare const CHECKED_SECTION_TITLE = "How this page was checked";
|
|
51
|
+
/** Said above the generic Result page when a Result opted into a card whose layout cannot hold its claims (`claimsFitCard`). */
|
|
52
|
+
export declare const CARD_UNFIT_NOTE = "This Result's claims don't fit the report layout, so every claim is listed below instead.";
|
|
53
|
+
/**
|
|
54
|
+
* The contract-report module's manifest (agent-action-capsule
|
|
55
|
+
* spec/contract-report-v1.md section 4): the same match as
|
|
56
|
+
* `aac.builtin.result-contract-report/v0`, which it replaces in this
|
|
57
|
+
* registry. Registering both would be an ambiguity error (presentation
|
|
58
|
+
* contract section 4.5). It carries no `executable.wording_sha256`: the pack
|
|
59
|
+
* is a builder input, recorded as provenance.
|
|
60
|
+
*/
|
|
61
|
+
export declare const CONTRACT_REPORT_MANIFEST: PresentationManifest;
|
|
62
|
+
/**
|
|
63
|
+
* The data a contract report draws from, beside the empty
|
|
64
|
+
* `contract-report/v1` block: an earlier kind's block, read by its own
|
|
65
|
+
* reader (section 5), the outcome block first, as the built-in manifests'
|
|
66
|
+
* precedence has it (the compliance card forbids `outcome-report/v1`).
|
|
67
|
+
*/
|
|
68
|
+
/** The grouping the contract-report module draws for `bundle`, or undefined when it draws the generic Result page. */
|
|
69
|
+
export declare function contractReportGroupingOf(bundle: unknown): ContractReportInput["grouping"] | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* The seven built-in modules, registered by default: agent-action-capsule's
|
|
72
|
+
* seven built-in shapes, with the contract-report module in place of
|
|
73
|
+
* `aac.builtin.result-contract-report/v0` (contract-report/v1 section 4).
|
|
74
|
+
*/
|
|
75
|
+
export declare const BUILTIN_PRESENTATIONS: readonly PresentationModule[];
|
|
76
|
+
/** A fresh registry holding the seven built-in modules. */
|
|
77
|
+
export declare function createPresentationRegistry(): PresentationRegistry;
|
|
78
|
+
/**
|
|
79
|
+
* The built-in sections: modules resolved after the page module, in their
|
|
80
|
+
* own registry, and rendered after its content. One today, the composition
|
|
81
|
+
* section; see BUILTIN_MANIFEST_COMPOSED for why it is not a page module.
|
|
82
|
+
*/
|
|
83
|
+
export declare const BUILTIN_SECTIONS: readonly PresentationModule[];
|
|
84
|
+
/**
|
|
85
|
+
* A fresh section registry holding the built-in sections. The section
|
|
86
|
+
* registry applies the presentation ABI as the page registry does: under a
|
|
87
|
+
* `runtime` that refuses a section, the section is registered as refused,
|
|
88
|
+
* never drawn, and every page it matches names it.
|
|
89
|
+
*/
|
|
90
|
+
export declare function createSectionRegistry(runtime?: PresentationRuntime): PresentationRegistry;
|
|
91
|
+
/**
|
|
92
|
+
* Register a module with the registry `renderEvidenceGraph` uses by default
|
|
93
|
+
* (the module-slot entry point). Throws when its manifest is malformed,
|
|
94
|
+
* dead, a duplicate, or co-matchable with a registered module of its tier.
|
|
95
|
+
* A module whose `presentation_api` this runtime does not implement (or
|
|
96
|
+
* whose `runtime_min` it does not meet) is registered as refused: it is
|
|
97
|
+
* never selected, and every page it would have rendered names it.
|
|
98
|
+
*/
|
|
99
|
+
export declare function registerPresentation(module: PresentationModule): PresentationRegistration;
|
|
100
|
+
/** Resolve over the default registry (spec section 4.3). */
|
|
101
|
+
export declare function resolvePresentation(context: VerifiedBundleContext, audience?: string, format?: PresentationFormat): Promise<PresentationResolution>;
|
|
102
|
+
export interface RenderEvidenceGraphOptions {
|
|
103
|
+
/** Resolves the presentation; the default registry when omitted. */
|
|
104
|
+
readonly registry?: PresentationResolver;
|
|
105
|
+
/** Resolves the section after the page; the built-in sections when omitted. */
|
|
106
|
+
readonly sections?: PresentationResolver;
|
|
107
|
+
readonly audience?: string;
|
|
108
|
+
readonly format?: PresentationFormat;
|
|
109
|
+
/** The opening depth handed to the module's host; "L0" when omitted. */
|
|
110
|
+
readonly depth?: PresentationDepth;
|
|
111
|
+
/**
|
|
112
|
+
* The wording pack the page was built with, carried so the page holds
|
|
113
|
+
* the exact words it was built with (presentation only; contract I3).
|
|
114
|
+
* The contract-report module (the outcome and EU AI Act reports) draws
|
|
115
|
+
* its words from it, over its default pack; the other built-in modules
|
|
116
|
+
* use the core's own labels and do not read it.
|
|
117
|
+
*/
|
|
118
|
+
readonly wording?: WordingPackInput;
|
|
119
|
+
/**
|
|
120
|
+
* The exact command that checks this file outside the page, shown when
|
|
121
|
+
* this viewer cannot verify it (see {@link renderUnableToVerify}).
|
|
122
|
+
*/
|
|
123
|
+
readonly verifyCommand?: string;
|
|
124
|
+
/**
|
|
125
|
+
* The host's own text for running a full verifier (for example its
|
|
126
|
+
* command line), shown as plain text under the verification page's
|
|
127
|
+
* not-checked list, after the core's neutral pointer. Presentation only:
|
|
128
|
+
* it changes no list and no result. Omitted, only the pointer is shown.
|
|
129
|
+
*/
|
|
130
|
+
readonly verifierHint?: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Render a bundle into `root`. `countersigners` is the stamp's countersigner
|
|
134
|
+
* source: the only way a verified, independent countersignature gets a name.
|
|
135
|
+
* Omitted, the context's own source is used (see
|
|
136
|
+
* `buildVerifiedBundleContext`); with neither, every independent signer
|
|
137
|
+
* renders as unlisted. The emitted report.html shell passes a bare bundle
|
|
138
|
+
* and no list; a host page that holds a list passes it here or builds the
|
|
139
|
+
* context with it (see `pinnedCountersignerSource` to load one against a
|
|
140
|
+
* pinned digest).
|
|
141
|
+
*
|
|
142
|
+
* Given a bundle, it is verified once here; given a context, its one
|
|
143
|
+
* verification run is reused. The page shape comes from the presentation
|
|
144
|
+
* registry: `resolve(context, audience, format)` picks one module by its
|
|
145
|
+
* manifest, and the page is the header, the banner, that module's content
|
|
146
|
+
* and the verification page.
|
|
147
|
+
*/
|
|
148
|
+
export declare function renderEvidenceGraph(context: VerifiedBundleContext, root: HTMLElement, countersigners?: CountersignerSource, options?: RenderEvidenceGraphOptions): Promise<void>;
|
|
149
|
+
export declare function renderEvidenceGraph(bundle: unknown, root: HTMLElement, countersigners?: CountersignerSource, options?: RenderEvidenceGraphOptions): Promise<void>;
|