@action-state-group/capsule-viewer 0.0.0 → 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/LICENSE +201 -0
- package/LICENSE-BSD-3-Clause +28 -0
- package/README.md +23 -1
- package/dist/browser.d.ts +4 -0
- package/dist/browser.js +11 -0
- package/dist/browser.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 +8 -0
- package/dist/compliance-styles.js +66 -0
- package/dist/compliance-styles.js.map +1 -0
- package/dist/compliance-view.d.ts +6 -0
- package/dist/compliance-view.js +394 -0
- package/dist/compliance-view.js.map +1 -0
- package/dist/compliance.d.ts +92 -0
- package/dist/compliance.js +333 -0
- package/dist/compliance.js.map +1 -0
- package/dist/composed-view.d.ts +24 -0
- package/dist/composed-view.js +179 -0
- package/dist/composed-view.js.map +1 -0
- package/dist/emitter-shell.html +136 -0
- package/dist/emitter.d.ts +69 -0
- package/dist/emitter.js +266 -0
- package/dist/emitter.js.map +1 -0
- package/dist/evidence-graph-view.d.ts +96 -0
- package/dist/evidence-graph-view.js +1480 -0
- package/dist/evidence-graph-view.js.map +1 -0
- package/dist/evidence-graph.iife.js +11373 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/outcome-report-styles.d.ts +16 -0
- package/dist/outcome-report-styles.js +225 -0
- package/dist/outcome-report-styles.js.map +1 -0
- package/dist/outcome-report-view.d.ts +5 -0
- package/dist/outcome-report-view.js +885 -0
- package/dist/outcome-report-view.js.map +1 -0
- package/dist/presentation-builder.d.ts +247 -0
- package/dist/presentation-builder.js +552 -0
- package/dist/presentation-builder.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/package.json +47 -4
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
import { buildVerifiedBundleContext, isVerifiedBundleContext, } from "@action-state-group/agent-action-capsule";
|
|
3
|
+
import { DEFAULT_EVIDENCE_GRAPH_BOOTSTRAP, emitEvidenceGraphHtml, emitStaticEvidenceGraphHtml, escapeJsonForHtmlScript, } from "./emitter.js";
|
|
4
|
+
import { createPresentationRegistry, renderEvidenceGraph, } from "./evidence-graph-view.js";
|
|
5
|
+
import { isHex64, jcs, sha256Hex, } from "@action-state-group/agent-action-capsule";
|
|
6
|
+
import { bundleVerified, manifestProblems, PresentationAmbiguityError, presentationRefusalReason, PresentationRegistry, REFERENCE_PRESENTATION_RUNTIME, } from "@action-state-group/agent-action-capsule";
|
|
7
|
+
import { decodePresentationFragment, encodePresentationFragment, FRAGMENT_TOKEN_DEFAULT_BUDGET, FragmentTooLargeError, PRESENTATION_DEPTHS, PRESENTATION_FRAGMENT_VERSION, scopeDisclosures, } from "@action-state-group/agent-action-capsule";
|
|
8
|
+
import { mountPresentation } from "./presentation-mount.js";
|
|
9
|
+
/**
|
|
10
|
+
* One builder, four packagings (spec/presentation-builder-v0.md):
|
|
11
|
+
* `buildPresentation(context, {presentation, audience, format})` scopes the
|
|
12
|
+
* bundle for the audience, resolves the one module the registry selects,
|
|
13
|
+
* and packages the same scoped bundle and settings as
|
|
14
|
+
*
|
|
15
|
+
* - `html`: one self-contained offline file with its per-page CSP;
|
|
16
|
+
* - `fragment`: a permalink token for the URL fragment, which a browser
|
|
17
|
+
* never sends; the offline file is rebuilt from it byte for byte by
|
|
18
|
+
* {@link offlineHtmlFromFragment};
|
|
19
|
+
* - `embedded`: a mount function for a host element;
|
|
20
|
+
* - `static`: the page rendered at build time into HTML that runs no
|
|
21
|
+
* script at all, and says it is not self-verifying.
|
|
22
|
+
*
|
|
23
|
+
* A packaging can be unavailable for a bundle (a fragment over the link
|
|
24
|
+
* budget, for one); {@link availablePackagings} reports which, and why,
|
|
25
|
+
* without packaging anything. For one (bundle, audience) every SUPPORTED
|
|
26
|
+
* packaging shows the same module, the same verified content and the same
|
|
27
|
+
* verification state (contract I4).
|
|
28
|
+
*/
|
|
29
|
+
export class PresentationBuildError extends Error {
|
|
30
|
+
constructor(message) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "PresentationBuildError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const PACKAGING_TARGETS = Object.freeze([
|
|
36
|
+
"html",
|
|
37
|
+
"fragment",
|
|
38
|
+
"embedded",
|
|
39
|
+
"static",
|
|
40
|
+
]);
|
|
41
|
+
/**
|
|
42
|
+
* A direct build of a packaging that is unavailable. (A fragment over the
|
|
43
|
+
* budget keeps throwing {@link FragmentTooLargeError}, as it always has.)
|
|
44
|
+
*/
|
|
45
|
+
export class PackagingUnavailableError extends PresentationBuildError {
|
|
46
|
+
reason;
|
|
47
|
+
constructor(reason) {
|
|
48
|
+
super(reason.message);
|
|
49
|
+
this.name = "PackagingUnavailableError";
|
|
50
|
+
this.reason = reason;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* What the static page says, word for word. It runs no code, so it shows
|
|
55
|
+
* the verification result the builder computed and cannot re-verify.
|
|
56
|
+
*/
|
|
57
|
+
export const STATIC_NOT_SELF_VERIFYING = "Not self-verifying; verify the bundle separately.";
|
|
58
|
+
/** The static page's second statement, before the build-time result. */
|
|
59
|
+
export const STATIC_BUILD_TIME_STATEMENT = "This page runs no code. It shows the verification result computed when it was built and cannot re-verify anything in your browser.";
|
|
60
|
+
/**
|
|
61
|
+
* A module's manifest pins other stylesheets than the module carries
|
|
62
|
+
* (contract section 5.1). No page is written; the error names both lists.
|
|
63
|
+
*/
|
|
64
|
+
export class PresentationStylePinsError extends PresentationBuildError {
|
|
65
|
+
module;
|
|
66
|
+
/** The manifest's `executable.style_sha256`, as given (absent: empty). */
|
|
67
|
+
manifestStyleSha256;
|
|
68
|
+
/** The module's `styleSha256`, as given (absent: empty). */
|
|
69
|
+
moduleStyleSha256;
|
|
70
|
+
constructor(module, manifestStyleSha256, moduleStyleSha256) {
|
|
71
|
+
super(`module manifest ${module} style_sha256 [${manifestStyleSha256.join(", ")}] does not equal the module's style pins [${moduleStyleSha256.join(", ")}] as a set; no page is written`);
|
|
72
|
+
this.name = "PresentationStylePinsError";
|
|
73
|
+
this.module = module;
|
|
74
|
+
this.manifestStyleSha256 = Object.freeze([...manifestStyleSha256]);
|
|
75
|
+
this.moduleStyleSha256 = Object.freeze([...moduleStyleSha256]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Contract section 5.1: the stylesheets a module inserts are the ones its
|
|
79
|
+
// manifest pins, compared as sets (order and repetition decide nothing).
|
|
80
|
+
function checkStylePins(script) {
|
|
81
|
+
const manifest = script.manifest;
|
|
82
|
+
if (manifest === undefined)
|
|
83
|
+
return;
|
|
84
|
+
const declared = manifest.executable?.style_sha256 ?? [];
|
|
85
|
+
const carried = script.styleSha256 ?? [];
|
|
86
|
+
const a = new Set(declared);
|
|
87
|
+
const b = new Set(carried);
|
|
88
|
+
if (a.size !== b.size || [...a].some((pin) => !b.has(pin)))
|
|
89
|
+
throw new PresentationStylePinsError(manifest.id, declared, carried);
|
|
90
|
+
}
|
|
91
|
+
// What the emitter is given for each module: its code and pins, script and
|
|
92
|
+
// stylesheets alike. The manifest stays with the builder.
|
|
93
|
+
function emitterModules(modules) {
|
|
94
|
+
return modules.map((m) => ({
|
|
95
|
+
code: m.code,
|
|
96
|
+
sha256: m.sha256,
|
|
97
|
+
...(m.styleSha256 === undefined ? {} : { styleSha256: m.styleSha256 }),
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The builder was asked to put into a page a module the page's runtime
|
|
102
|
+
* would refuse (contract section 3.2). No page is written; the error names
|
|
103
|
+
* both sides: the module (id, `presentation_api`, `runtime_min`) and the
|
|
104
|
+
* runtime's declaration.
|
|
105
|
+
*/
|
|
106
|
+
export class PresentationModuleRefusedError extends PresentationBuildError {
|
|
107
|
+
module;
|
|
108
|
+
reason;
|
|
109
|
+
runtime;
|
|
110
|
+
constructor(module, reason, runtime) {
|
|
111
|
+
const apis = runtime.presentationApis.length === 0
|
|
112
|
+
? "no presentation API"
|
|
113
|
+
: runtime.presentationApis.join(", ");
|
|
114
|
+
super(`presentation module ${module.id} (presentation_api ${module.presentation_api}, runtime_min ${module.runtime_min}) would be refused by the page's runtime (implements ${apis}; runtime version ${runtime.runtimeVersion}): ${reason}; no page is written`);
|
|
115
|
+
this.name = "PresentationModuleRefusedError";
|
|
116
|
+
this.module = Object.freeze({
|
|
117
|
+
id: module.id,
|
|
118
|
+
presentation_api: module.presentation_api,
|
|
119
|
+
runtime_min: module.runtime_min,
|
|
120
|
+
});
|
|
121
|
+
this.reason = reason;
|
|
122
|
+
this.runtime = runtime;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** The wording key the builder reads for the page title. */
|
|
126
|
+
export const WORDING_TITLE_KEY = "page.title";
|
|
127
|
+
const WORDING_PACK_VERSION = "aac.wording-pack/v0";
|
|
128
|
+
const WORDING_KEY = /^[a-z0-9][a-z0-9._-]*$/u;
|
|
129
|
+
const LOCALE = /^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$/u;
|
|
130
|
+
/**
|
|
131
|
+
* Check a wording pack against its digest and its shape (contract 7.4) and
|
|
132
|
+
* return its entries. The bytes are hashed exactly as given.
|
|
133
|
+
*/
|
|
134
|
+
export async function checkWordingPack(wording) {
|
|
135
|
+
if (!isHex64(wording.sha256))
|
|
136
|
+
throw new PresentationBuildError("wording sha256 is not a lowercase hex SHA-256");
|
|
137
|
+
const digest = await sha256Hex(new TextEncoder().encode(wording.pack));
|
|
138
|
+
if (digest !== wording.sha256)
|
|
139
|
+
throw new PresentationBuildError("wording pack bytes do not hash to its wording_sha256");
|
|
140
|
+
let pack;
|
|
141
|
+
try {
|
|
142
|
+
pack = JSON.parse(wording.pack);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
throw new PresentationBuildError("wording pack is not JSON");
|
|
146
|
+
}
|
|
147
|
+
const p = pack;
|
|
148
|
+
const entries = p?.entries;
|
|
149
|
+
if (pack === null ||
|
|
150
|
+
typeof pack !== "object" ||
|
|
151
|
+
Array.isArray(pack) ||
|
|
152
|
+
Object.keys(p).some((k) => !["wording_pack_version", "id", "locale", "entries"].includes(k)) ||
|
|
153
|
+
p.wording_pack_version !== WORDING_PACK_VERSION ||
|
|
154
|
+
typeof p.id !== "string" ||
|
|
155
|
+
typeof p.locale !== "string" ||
|
|
156
|
+
!LOCALE.test(p.locale) ||
|
|
157
|
+
entries === null ||
|
|
158
|
+
typeof entries !== "object" ||
|
|
159
|
+
Array.isArray(entries) ||
|
|
160
|
+
Object.keys(entries).length === 0 ||
|
|
161
|
+
Object.entries(entries).some(([k, v]) => !WORDING_KEY.test(k) || typeof v !== "string" || v === ""))
|
|
162
|
+
throw new PresentationBuildError(`wording pack is not an ${WORDING_PACK_VERSION} object`);
|
|
163
|
+
return entries;
|
|
164
|
+
}
|
|
165
|
+
// The one offline packager: the direct path and the fragment hand-back both
|
|
166
|
+
// end here, so equal settings give equal bytes. The default settings
|
|
167
|
+
// (audience "*", nothing else) give exactly emitEvidenceGraphHtml's page.
|
|
168
|
+
async function packageOffline(settings, runtime, modules) {
|
|
169
|
+
const entries = settings.wording === undefined
|
|
170
|
+
? undefined
|
|
171
|
+
: await checkWordingPack(settings.wording);
|
|
172
|
+
const title = settings.title !== undefined && settings.title !== ""
|
|
173
|
+
? settings.title
|
|
174
|
+
: entries?.[WORDING_TITLE_KEY];
|
|
175
|
+
const isDefault = settings.audience === "*" &&
|
|
176
|
+
settings.depth === undefined &&
|
|
177
|
+
settings.wording === undefined;
|
|
178
|
+
const renderOptions = {
|
|
179
|
+
audience: settings.audience,
|
|
180
|
+
format: "html",
|
|
181
|
+
};
|
|
182
|
+
if (settings.depth !== undefined)
|
|
183
|
+
renderOptions.depth = settings.depth;
|
|
184
|
+
if (settings.wording !== undefined)
|
|
185
|
+
renderOptions.wording = {
|
|
186
|
+
pack: settings.wording.pack,
|
|
187
|
+
sha256: settings.wording.sha256,
|
|
188
|
+
};
|
|
189
|
+
const bootstrap = isDefault
|
|
190
|
+
? DEFAULT_EVIDENCE_GRAPH_BOOTSTRAP
|
|
191
|
+
: `renderEvidenceGraph(window.__BUNDLE__, document.getElementById("app"), undefined, ${escapeJsonForHtmlScript(new TextDecoder().decode(jcs(renderOptions)))});`;
|
|
192
|
+
return emitEvidenceGraphHtml(settings.bundle, runtime.code, {
|
|
193
|
+
...(title === undefined ? {} : { title }),
|
|
194
|
+
...(settings.themeCss === undefined ? {} : { themeCss: settings.themeCss }),
|
|
195
|
+
...(runtime.sha256 === undefined
|
|
196
|
+
? {}
|
|
197
|
+
: { coreRuntimeSha256: runtime.sha256 }),
|
|
198
|
+
modules,
|
|
199
|
+
bootstrap,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function requireRuntime(runtime, format) {
|
|
203
|
+
if (runtime === undefined)
|
|
204
|
+
throw new PackagingUnavailableError({
|
|
205
|
+
code: "runtime-missing",
|
|
206
|
+
message: `format ${format} needs the core runtime`,
|
|
207
|
+
});
|
|
208
|
+
return runtime;
|
|
209
|
+
}
|
|
210
|
+
// Check the settings, then scope and verify the scoped bundle: once for
|
|
211
|
+
// every packaging.
|
|
212
|
+
async function scopeAndVerify(input, options) {
|
|
213
|
+
const { audience } = options;
|
|
214
|
+
if (typeof audience !== "string" || audience === "")
|
|
215
|
+
throw new PresentationBuildError("audience is required");
|
|
216
|
+
if (options.depth !== undefined &&
|
|
217
|
+
!PRESENTATION_DEPTHS.includes(options.depth))
|
|
218
|
+
throw new PresentationBuildError("depth is not L0, L1 or L2");
|
|
219
|
+
if (options.wording !== undefined)
|
|
220
|
+
await checkWordingPack(options.wording);
|
|
221
|
+
const given = isVerifiedBundleContext(input)
|
|
222
|
+
? input
|
|
223
|
+
: await buildVerifiedBundleContext(input);
|
|
224
|
+
if (options.disclose === undefined)
|
|
225
|
+
return given;
|
|
226
|
+
if (!bundleVerified(given.verification))
|
|
227
|
+
throw new PresentationBuildError("refusing to scope a bundle that did not verify: removing a disclosure could hide the failure");
|
|
228
|
+
return buildVerifiedBundleContext(scopeDisclosures(given.bundle, options.disclose), given.countersigners === undefined
|
|
229
|
+
? {}
|
|
230
|
+
: { countersigners: given.countersigners });
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The page's runtime declaration (contract section 3.2): the registry's,
|
|
234
|
+
* when the builder resolves with a PresentationRegistry (the default one is
|
|
235
|
+
* the reference runtime, which the core runtime script also is); otherwise
|
|
236
|
+
* the reference runtime's.
|
|
237
|
+
*/
|
|
238
|
+
function pageRuntime(registry) {
|
|
239
|
+
return registry instanceof PresentationRegistry
|
|
240
|
+
? registry.runtime
|
|
241
|
+
: REFERENCE_PRESENTATION_RUNTIME;
|
|
242
|
+
}
|
|
243
|
+
// Contract section 3.2: a builder asked to put into a page a module the
|
|
244
|
+
// page's runtime would refuse writes no page and names both sides. Two ways
|
|
245
|
+
// to ask: inline a module-slot script whose manifest the runtime refuses,
|
|
246
|
+
// or request by id a module the registry holds as refused (or that matched
|
|
247
|
+
// this resolution and was refused).
|
|
248
|
+
function refuseRefusedModules(options, registry, resolution) {
|
|
249
|
+
const runtime = pageRuntime(registry);
|
|
250
|
+
for (const script of options.modules ?? []) {
|
|
251
|
+
const manifest = script.manifest;
|
|
252
|
+
if (manifest === undefined)
|
|
253
|
+
continue;
|
|
254
|
+
const problems = manifestProblems(manifest);
|
|
255
|
+
if (problems.length > 0)
|
|
256
|
+
throw new PresentationBuildError(`module manifest ${JSON.stringify(manifest.id)} is malformed: ${problems.join("; ")}`);
|
|
257
|
+
if (manifest.executable?.carrier !== "module-slot" ||
|
|
258
|
+
manifest.executable.script_sha256 !== script.sha256)
|
|
259
|
+
throw new PresentationBuildError(`module manifest ${manifest.id} does not pin this module-slot script (sha256 ${script.sha256})`);
|
|
260
|
+
checkStylePins(script);
|
|
261
|
+
const reason = presentationRefusalReason(manifest, runtime);
|
|
262
|
+
if (reason !== undefined)
|
|
263
|
+
throw new PresentationModuleRefusedError(manifest, reason, runtime);
|
|
264
|
+
}
|
|
265
|
+
if (options.presentation === "auto")
|
|
266
|
+
return;
|
|
267
|
+
const refused = [
|
|
268
|
+
...(resolution.kind === "refusal" ? [] : resolution.refused),
|
|
269
|
+
...(registry instanceof PresentationRegistry ? registry.refused() : []),
|
|
270
|
+
].find((refusal) => refusal.id === options.presentation);
|
|
271
|
+
if (refused !== undefined)
|
|
272
|
+
throw new PresentationModuleRefusedError(refused, refused.reason, runtime);
|
|
273
|
+
}
|
|
274
|
+
// Resolve for one contract format. The static page is the html page
|
|
275
|
+
// rendered at build time, so it is resolved, and rendered, as html.
|
|
276
|
+
async function resolveFor(context, options, format) {
|
|
277
|
+
const { audience } = options;
|
|
278
|
+
const registry = options.registry ?? createPresentationRegistry();
|
|
279
|
+
let resolution;
|
|
280
|
+
try {
|
|
281
|
+
resolution = await registry.resolve(context, audience, format);
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
if (err instanceof PresentationAmbiguityError)
|
|
285
|
+
throw new PresentationBuildError(`presentation is ambiguous for this bundle: ${err.ids.join(", ")}`);
|
|
286
|
+
throw err;
|
|
287
|
+
}
|
|
288
|
+
refuseRefusedModules(options, registry, resolution);
|
|
289
|
+
const module = resolution.kind === "module" ? resolution.module.manifest.id : null;
|
|
290
|
+
if (options.presentation !== "auto" && options.presentation !== module)
|
|
291
|
+
throw new PresentationBuildError(`presentation ${options.presentation} was requested but the registry selected ${module ?? resolution.kind} for audience ${audience} and format ${format}`);
|
|
292
|
+
return {
|
|
293
|
+
common: {
|
|
294
|
+
audience,
|
|
295
|
+
module,
|
|
296
|
+
resolution: resolution.kind,
|
|
297
|
+
bundle: context.bundle,
|
|
298
|
+
},
|
|
299
|
+
context,
|
|
300
|
+
registry,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
const contractFormat = (target) => target === "static" ? "html" : target;
|
|
304
|
+
/**
|
|
305
|
+
* Build one presentation of a bundle for one audience in one packaging.
|
|
306
|
+
* `input` is a verified context or a bundle (verified here).
|
|
307
|
+
*
|
|
308
|
+
* Steps, in order: scope the bundle for the audience (only when `disclose`
|
|
309
|
+
* is given, and never for a bundle that did not verify, since removing a
|
|
310
|
+
* disclosure could hide the failure); verify the scoped bundle; resolve the
|
|
311
|
+
* module through the registry (an ambiguity is an error; an explicit
|
|
312
|
+
* `presentation` that the registry does not select is an error); package.
|
|
313
|
+
*
|
|
314
|
+
* A packaging that is unavailable throws: {@link FragmentTooLargeError} for
|
|
315
|
+
* a fragment over its budget, {@link PackagingUnavailableError} otherwise.
|
|
316
|
+
* Ask {@link availablePackagings} first to learn which are available.
|
|
317
|
+
*/
|
|
318
|
+
export async function buildPresentation(input, options) {
|
|
319
|
+
const { format } = options;
|
|
320
|
+
if (!PACKAGING_TARGETS.includes(format))
|
|
321
|
+
throw new PresentationBuildError(`format ${JSON.stringify(format)} is not html, fragment, embedded or static`);
|
|
322
|
+
const context = await scopeAndVerify(input, options);
|
|
323
|
+
const prepared = await resolveFor(context, options, contractFormat(format));
|
|
324
|
+
return packageAs(prepared, format, options);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Report, for one (bundle, audience) and these settings, which packaging
|
|
328
|
+
* targets are available and why each other one is not, without returning
|
|
329
|
+
* any packaging: an unusable link is never handed out. Errors of the
|
|
330
|
+
* request itself (no audience, a bad wording pack, an ambiguous registry,
|
|
331
|
+
* scoping a bundle that did not verify) are thrown as buildPresentation
|
|
332
|
+
* throws them, since no packaging of it exists.
|
|
333
|
+
*
|
|
334
|
+
* Available here means buildPresentation succeeds for that target with the
|
|
335
|
+
* same settings: every target is packaged and the result discarded.
|
|
336
|
+
*/
|
|
337
|
+
export async function availablePackagings(input, options) {
|
|
338
|
+
const context = await scopeAndVerify(input, options);
|
|
339
|
+
const out = [];
|
|
340
|
+
for (const target of PACKAGING_TARGETS) {
|
|
341
|
+
const prepared = await resolveFor(context, options, contractFormat(target));
|
|
342
|
+
try {
|
|
343
|
+
await packageAs(prepared, target, options);
|
|
344
|
+
out.push({ target, available: true });
|
|
345
|
+
}
|
|
346
|
+
catch (err) {
|
|
347
|
+
if (err instanceof FragmentTooLargeError)
|
|
348
|
+
out.push({
|
|
349
|
+
target,
|
|
350
|
+
available: false,
|
|
351
|
+
reason: {
|
|
352
|
+
code: "fragment-too-large",
|
|
353
|
+
subject: err.subject,
|
|
354
|
+
length: err.length,
|
|
355
|
+
limit: err.maxLength,
|
|
356
|
+
message: err.message,
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
else if (err instanceof PackagingUnavailableError)
|
|
360
|
+
out.push({ target, available: false, reason: err.reason });
|
|
361
|
+
else
|
|
362
|
+
throw err;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return out;
|
|
366
|
+
}
|
|
367
|
+
async function packageAs(prepared, format, options) {
|
|
368
|
+
const { common, registry } = prepared;
|
|
369
|
+
const { audience, bundle } = common;
|
|
370
|
+
const modules = emitterModules(options.modules ?? []);
|
|
371
|
+
if (format === "html") {
|
|
372
|
+
const html = await packageOffline({
|
|
373
|
+
bundle,
|
|
374
|
+
audience,
|
|
375
|
+
depth: options.depth,
|
|
376
|
+
title: options.title,
|
|
377
|
+
themeCss: options.themeCss,
|
|
378
|
+
wording: options.wording,
|
|
379
|
+
}, requireRuntime(options.runtime, format), modules);
|
|
380
|
+
return { ...common, format, html };
|
|
381
|
+
}
|
|
382
|
+
if (format === "fragment") {
|
|
383
|
+
const runtime = requireRuntime(options.runtime, format);
|
|
384
|
+
const runtimePin = await sha256Hex(new TextEncoder().encode(runtime.code));
|
|
385
|
+
if (runtime.sha256 !== undefined && runtime.sha256 !== runtimePin)
|
|
386
|
+
throw new PresentationBuildError("browser IIFE does not match its SHA-256 pin");
|
|
387
|
+
const payload = {
|
|
388
|
+
fragment_version: PRESENTATION_FRAGMENT_VERSION,
|
|
389
|
+
audience,
|
|
390
|
+
presentation: common.module ?? "auto",
|
|
391
|
+
...(options.depth === undefined ? {} : { depth: options.depth }),
|
|
392
|
+
...(options.title === undefined ? {} : { title: options.title }),
|
|
393
|
+
...(options.themeCss === undefined
|
|
394
|
+
? {}
|
|
395
|
+
: { theme_css: options.themeCss }),
|
|
396
|
+
...(options.wording === undefined
|
|
397
|
+
? {}
|
|
398
|
+
: {
|
|
399
|
+
wording: {
|
|
400
|
+
pack: options.wording.pack,
|
|
401
|
+
sha256: options.wording.sha256,
|
|
402
|
+
},
|
|
403
|
+
}),
|
|
404
|
+
core_runtime_sha256: runtimePin,
|
|
405
|
+
module_sha256: modules.map((m) => m.sha256),
|
|
406
|
+
bundle,
|
|
407
|
+
};
|
|
408
|
+
const encoded = encodePresentationFragment(payload, {
|
|
409
|
+
maxLength: options.maxFragmentLength ?? FRAGMENT_TOKEN_DEFAULT_BUDGET,
|
|
410
|
+
...(options.viewerUrl === undefined
|
|
411
|
+
? {}
|
|
412
|
+
: { viewerUrl: options.viewerUrl }),
|
|
413
|
+
});
|
|
414
|
+
return {
|
|
415
|
+
...common,
|
|
416
|
+
format,
|
|
417
|
+
fragment: encoded.fragment,
|
|
418
|
+
...(encoded.url === undefined ? {} : { url: encoded.url }),
|
|
419
|
+
payload,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
if (format === "static") {
|
|
423
|
+
const page = await packageStatic(prepared, options);
|
|
424
|
+
return { ...common, format, ...page };
|
|
425
|
+
}
|
|
426
|
+
return {
|
|
427
|
+
...common,
|
|
428
|
+
format,
|
|
429
|
+
mount: (element) => mountPresentation(element, {
|
|
430
|
+
bundle,
|
|
431
|
+
audience,
|
|
432
|
+
format: "embedded",
|
|
433
|
+
...(options.depth === undefined ? {} : { depth: options.depth }),
|
|
434
|
+
...(options.wording === undefined ? {} : { wording: options.wording }),
|
|
435
|
+
registry,
|
|
436
|
+
}),
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
const escapeText = (value) => value
|
|
440
|
+
.replaceAll("&", "&")
|
|
441
|
+
.replaceAll("<", "<")
|
|
442
|
+
.replaceAll(">", ">")
|
|
443
|
+
.replaceAll('"', """);
|
|
444
|
+
/**
|
|
445
|
+
* The static page: render the scoped bundle at build time exactly as the
|
|
446
|
+
* offline file renders it in the reader's browser (same bundle, audience,
|
|
447
|
+
* html format, depth, wording and registry), then write the markup with no
|
|
448
|
+
* script. The page states that it is not self-verifying and gives the
|
|
449
|
+
* verification result the builder computed.
|
|
450
|
+
*/
|
|
451
|
+
async function packageStatic(prepared, options) {
|
|
452
|
+
if (typeof document === "undefined")
|
|
453
|
+
throw new PackagingUnavailableError({
|
|
454
|
+
code: "no-document",
|
|
455
|
+
message: "format static renders at build time and needs a DOM document (in node, a jsdom document as globalThis.document)",
|
|
456
|
+
});
|
|
457
|
+
const { common, context, registry } = prepared;
|
|
458
|
+
const root = document.createElement("div");
|
|
459
|
+
// From the bundle, as the offline file does: the page there verifies the
|
|
460
|
+
// bundle it carries and names no countersigner, so this does the same.
|
|
461
|
+
await renderEvidenceGraph(common.bundle, root, undefined, {
|
|
462
|
+
audience: common.audience,
|
|
463
|
+
format: "html",
|
|
464
|
+
...(options.depth === undefined ? {} : { depth: options.depth }),
|
|
465
|
+
...(options.wording === undefined ? {} : { wording: options.wording }),
|
|
466
|
+
registry,
|
|
467
|
+
});
|
|
468
|
+
const verification = bundleVerified(context.verification)
|
|
469
|
+
? "verified"
|
|
470
|
+
: "failed";
|
|
471
|
+
const shown = [...root.querySelectorAll("[data-verify]")].map((e) => e.getAttribute("data-verify"));
|
|
472
|
+
if (shown.length !== 1 || shown[0] !== verification)
|
|
473
|
+
throw new Error("the rendered verification state differs from the builder's");
|
|
474
|
+
const all = [...root.querySelectorAll("*")];
|
|
475
|
+
if (all.some((e) => e.localName === "script" ||
|
|
476
|
+
[...e.attributes].some((a) => a.name.toLowerCase().startsWith("on"))))
|
|
477
|
+
throw new PackagingUnavailableError({
|
|
478
|
+
code: "static-carries-script",
|
|
479
|
+
message: "the rendered page carries a script element or an event-handler attribute, so it cannot be packaged as static",
|
|
480
|
+
});
|
|
481
|
+
const appStyles = all
|
|
482
|
+
.filter((e) => e.localName === "style")
|
|
483
|
+
.map((e) => e.textContent ?? "");
|
|
484
|
+
const appStyleAttributes = all
|
|
485
|
+
.map((e) => e.getAttribute("style"))
|
|
486
|
+
.filter((v) => v !== null);
|
|
487
|
+
const entries = options.wording === undefined
|
|
488
|
+
? undefined
|
|
489
|
+
: await checkWordingPack(options.wording);
|
|
490
|
+
const title = options.title !== undefined && options.title !== ""
|
|
491
|
+
? options.title
|
|
492
|
+
: entries?.[WORDING_TITLE_KEY];
|
|
493
|
+
const noticeHtml = `<aside class="aac-static-notice" data-static-notice="not-self-verifying" data-built-verification="${verification}">` +
|
|
494
|
+
`<p><strong>${escapeText(STATIC_NOT_SELF_VERIFYING)}</strong></p>` +
|
|
495
|
+
`<p>${escapeText(STATIC_BUILD_TIME_STATEMENT)}</p>` +
|
|
496
|
+
`<p>Verification result when this page was built: <strong>${verification === "verified" ? "verified" : "did not verify"}</strong>.</p>` +
|
|
497
|
+
`</aside>`;
|
|
498
|
+
const html = emitStaticEvidenceGraphHtml({ appHtml: root.innerHTML, appStyles, appStyleAttributes, noticeHtml }, {
|
|
499
|
+
...(title === undefined ? {} : { title }),
|
|
500
|
+
...(options.themeCss === undefined ? {} : { themeCss: options.themeCss }),
|
|
501
|
+
});
|
|
502
|
+
return { html, verification };
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* The hand-back: rebuild the exact offline .html a fragment was made from.
|
|
506
|
+
* The fragment carries pins, not code; the runtime and modules given here
|
|
507
|
+
* must match them, or this refuses rather than build a different file.
|
|
508
|
+
* A module given with its manifest has its stylesheet pins checked against
|
|
509
|
+
* it, as {@link buildPresentation} checks them.
|
|
510
|
+
* It never scopes: the fragment's bundle was scoped before encoding.
|
|
511
|
+
*/
|
|
512
|
+
export async function offlineHtmlFromFragment(token, runtime, modules = [], maxLength) {
|
|
513
|
+
const payload = decodePresentationFragment(token, maxLength);
|
|
514
|
+
modules.forEach(checkStylePins);
|
|
515
|
+
const runtimePin = await sha256Hex(new TextEncoder().encode(runtime.code));
|
|
516
|
+
if (runtimePin !== payload.core_runtime_sha256)
|
|
517
|
+
throw new PresentationBuildError("this runtime is not the one the fragment was built with");
|
|
518
|
+
const pins = modules.map((m) => m.sha256);
|
|
519
|
+
if (pins.length !== payload.module_sha256.length ||
|
|
520
|
+
pins.some((pin, i) => pin !== payload.module_sha256[i]))
|
|
521
|
+
throw new PresentationBuildError("these modules are not the ones the fragment was built with");
|
|
522
|
+
return packageOffline({
|
|
523
|
+
bundle: payload.bundle,
|
|
524
|
+
audience: payload.audience,
|
|
525
|
+
depth: payload.depth,
|
|
526
|
+
title: payload.title,
|
|
527
|
+
themeCss: payload.theme_css,
|
|
528
|
+
wording: payload.wording,
|
|
529
|
+
}, { code: runtime.code, sha256: runtimePin }, emitterModules(modules));
|
|
530
|
+
}
|
|
531
|
+
const FRAGMENT_VIEWER_MARKER = {
|
|
532
|
+
aac_fragment_viewer: PRESENTATION_FRAGMENT_VERSION,
|
|
533
|
+
};
|
|
534
|
+
/** The fragment viewer's bootstrap. */
|
|
535
|
+
export const FRAGMENT_VIEWER_BOOTSTRAP = 'EvidenceGraph.mountPresentationFragment(location.hash, document.getElementById("app"));';
|
|
536
|
+
/**
|
|
537
|
+
* A serverless fragment viewer: an offline page, with the same shell and
|
|
538
|
+
* CSP, whose data is the URL fragment it is opened with. Open it as
|
|
539
|
+
* `viewer.html#<token>`; nothing is fetched. It applies no theme CSS from
|
|
540
|
+
* the fragment (its CSP admits only the styles hashed into it); the theme
|
|
541
|
+
* comes back in the offline file {@link offlineHtmlFromFragment} rebuilds.
|
|
542
|
+
*/
|
|
543
|
+
export function buildFragmentViewerHtml(runtime, modules = []) {
|
|
544
|
+
return emitEvidenceGraphHtml(FRAGMENT_VIEWER_MARKER, runtime.code, {
|
|
545
|
+
...(runtime.sha256 === undefined
|
|
546
|
+
? {}
|
|
547
|
+
: { coreRuntimeSha256: runtime.sha256 }),
|
|
548
|
+
modules,
|
|
549
|
+
bootstrap: FRAGMENT_VIEWER_BOOTSTRAP,
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
//# sourceMappingURL=presentation-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-builder.js","sourceRoot":"","sources":["../src/presentation-builder.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GAExB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,gCAAgC,EAChC,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,GAExB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,OAAO,EACP,GAAG,EACH,SAAS,GACV,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,0BAA0B,EAC1B,yBAAyB,EACzB,oBAAoB,EACpB,8BAA8B,GAO/B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,6BAA6B,EAC7B,qBAAqB,EACrB,mBAAmB,EACnB,6BAA6B,EAC7B,gBAAgB,GAKjB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAID,MAAM,CAAC,MAAM,iBAAiB,GAA+B,MAAM,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AI,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAEvD,MAAM,IAAI,sBAAsB,CAC9B,4DAA4D,CAC7D,CAAC;IACJ,OAAO,cAAc,CACnB;QACE,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,QAAQ,EAAE,OAAO,CAAC,SAAS;QAC3B,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,EACD,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,EAC1C,cAAc,CAAC,OAAO,CAAC,CACxB,CAAC;AACJ,CAAC;AAED,MAAM,sBAAsB,GAAG;IAC7B,mBAAmB,EAAE,6BAA6B;CACnD,CAAC;AACF,uCAAuC;AACvC,MAAM,CAAC,MAAM,yBAAyB,GACpC,yFAAyF,CAAC;AAE5F;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAA0B,EAC1B,OAAO,GAA6B,EAAE;IAEtC,OAAO,qBAAqB,CAAC,sBAAsB,EAAE,OAAO,CAAC,IAAI,EAAE;QACjE,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS;YAC9B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,iBAAiB,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;QAC1C,OAAO;QACP,SAAS,EAAE,yBAAyB;KACrC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PresentationFormat, PresentationResolver } from "@action-state-group/agent-action-capsule";
|
|
2
|
+
import { type PresentationDepth, type WordingPackInput } from "@action-state-group/agent-action-capsule";
|
|
3
|
+
/** What a host element is given: an already scoped bundle and its settings. */
|
|
4
|
+
export interface MountPresentationInput {
|
|
5
|
+
readonly bundle: unknown;
|
|
6
|
+
readonly audience: string;
|
|
7
|
+
readonly format: PresentationFormat;
|
|
8
|
+
readonly depth?: PresentationDepth;
|
|
9
|
+
readonly wording?: WordingPackInput;
|
|
10
|
+
/** The host's registry; the default registry when omitted. */
|
|
11
|
+
readonly registry?: PresentationResolver;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Render a scoped bundle into a host element (the `embedded` packaging, and
|
|
15
|
+
* the body of the fragment viewer). Verification, resolution and the
|
|
16
|
+
* refusal are renderEvidenceGraph's; this only forwards the settings. It
|
|
17
|
+
* never scopes: what the element shows is the bundle it was given.
|
|
18
|
+
*/
|
|
19
|
+
export declare function mountPresentation(element: HTMLElement, input: MountPresentationInput): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* The fragment viewer: read a presentation fragment (`location.hash`) and
|
|
22
|
+
* render it into `element` as the `fragment` format. A fragment that cannot
|
|
23
|
+
* be read shows a fixed statement and nothing else. The fragment is never
|
|
24
|
+
* sent anywhere: this reads it in the page.
|
|
25
|
+
*/
|
|
26
|
+
export declare function mountPresentationFragment(hash: string, element: HTMLElement, maxLength?: number): Promise<void>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { renderEvidenceGraph } from "./evidence-graph-view.js";
|
|
2
|
+
import { decodePresentationFragment, FRAGMENT_TOKEN_MAX_LENGTH, } from "@action-state-group/agent-action-capsule";
|
|
3
|
+
/**
|
|
4
|
+
* Render a scoped bundle into a host element (the `embedded` packaging, and
|
|
5
|
+
* the body of the fragment viewer). Verification, resolution and the
|
|
6
|
+
* refusal are renderEvidenceGraph's; this only forwards the settings. It
|
|
7
|
+
* never scopes: what the element shows is the bundle it was given.
|
|
8
|
+
*/
|
|
9
|
+
export function mountPresentation(element, input) {
|
|
10
|
+
return renderEvidenceGraph(input.bundle, element, undefined, {
|
|
11
|
+
audience: input.audience,
|
|
12
|
+
format: input.format,
|
|
13
|
+
...(input.depth === undefined ? {} : { depth: input.depth }),
|
|
14
|
+
...(input.wording === undefined ? {} : { wording: input.wording }),
|
|
15
|
+
...(input.registry === undefined ? {} : { registry: input.registry }),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The fragment viewer: read a presentation fragment (`location.hash`) and
|
|
20
|
+
* render it into `element` as the `fragment` format. A fragment that cannot
|
|
21
|
+
* be read shows a fixed statement and nothing else. The fragment is never
|
|
22
|
+
* sent anywhere: this reads it in the page.
|
|
23
|
+
*/
|
|
24
|
+
export async function mountPresentationFragment(hash, element, maxLength = FRAGMENT_TOKEN_MAX_LENGTH) {
|
|
25
|
+
let payload;
|
|
26
|
+
try {
|
|
27
|
+
payload = decodePresentationFragment(hash, maxLength);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
const note = document.createElement("p");
|
|
31
|
+
note.dataset.refusal = "fragment-unreadable";
|
|
32
|
+
note.textContent =
|
|
33
|
+
`This link's fragment could not be read, so nothing is shown. ${err instanceof Error ? err.message : ""}`.trim();
|
|
34
|
+
element.replaceChildren(note);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
await mountPresentation(element, {
|
|
38
|
+
bundle: payload.bundle,
|
|
39
|
+
audience: payload.audience,
|
|
40
|
+
format: "fragment",
|
|
41
|
+
...(payload.depth === undefined ? {} : { depth: payload.depth }),
|
|
42
|
+
...(payload.wording === undefined ? {} : { wording: payload.wording }),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=presentation-mount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-mount.js","sourceRoot":"","sources":["../src/presentation-mount.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,GAG1B,MAAM,0CAA0C,CAAC;AAalD;;;;;GAKG;AACH,MAAM,UA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