@action-state-group/capsule-viewer 0.1.0 → 0.4.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 +74 -2
- 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 +5 -2
- package/dist/browser.js +19 -5
- package/dist/browser.js.map +1 -1
- 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/chart-dataset.d.ts +23 -0
- package/dist/chart-dataset.js +191 -0
- package/dist/chart-dataset.js.map +1 -0
- package/dist/chart-spec.d.ts +130 -0
- package/dist/chart-spec.js +638 -0
- package/dist/chart-spec.js.map +1 -0
- package/dist/chart-view.d.ts +27 -0
- package/dist/chart-view.js +374 -0
- package/dist/chart-view.js.map +1 -0
- package/dist/compliance-styles.d.ts +1 -8
- package/dist/compliance-styles.js +40 -3
- package/dist/compliance-styles.js.map +1 -1
- package/dist/compliance-view.d.ts +41 -1
- package/dist/compliance-view.js +773 -303
- package/dist/compliance-view.js.map +1 -1
- package/dist/compliance.d.ts +33 -4
- package/dist/compliance.js +92 -13
- package/dist/compliance.js.map +1 -1
- 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 +1 -1
- package/dist/composed-view.js +9 -2
- package/dist/composed-view.js.map +1 -1
- package/dist/contract-report-wording.d.ts +195 -0
- package/dist/contract-report-wording.js +1177 -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/core-strip.d.ts +38 -0
- package/dist/core-strip.js +183 -0
- package/dist/core-strip.js.map +1 -0
- package/dist/emitter-shell.html +181 -3
- package/dist/emitter.d.ts +36 -0
- package/dist/emitter.js +77 -4
- package/dist/emitter.js.map +1 -1
- package/dist/evidence-graph-view.d.ts +66 -7
- package/dist/evidence-graph-view.js +1483 -127
- package/dist/evidence-graph-view.js.map +1 -1
- package/dist/evidence-graph.iife.js +17741 -6812
- 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 +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- 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 -16
- package/dist/outcome-report-styles.js +48 -45
- package/dist/outcome-report-styles.js.map +1 -1
- package/dist/outcome-report-view.d.ts +75 -2
- package/dist/outcome-report-view.js +1063 -436
- package/dist/outcome-report-view.js.map +1 -1
- package/dist/presentation-builder.d.ts +70 -6
- package/dist/presentation-builder.js +198 -70
- package/dist/presentation-builder.js.map +1 -1
- 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 +4 -2
- package/dist/presentation-mount.js +2 -1
- package/dist/presentation-mount.js.map +1 -1
- 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 +43 -0
- package/dist/report-front-styles.js.map +1 -0
- package/dist/report-front.d.ts +56 -0
- package/dist/report-front.js +140 -0
- package/dist/report-front.js.map +1 -0
- package/dist/report-levels.d.ts +238 -0
- package/dist/report-levels.js +874 -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 +319 -0
- package/dist/wording/contract-report-outcomes.en.json +418 -0
- package/package.json +6 -3
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
-
import { buildVerifiedBundleContext, disclosureOf, isVerifiedBundleContext, withCountersigners, } from "@action-state-group/agent-action-capsule";
|
|
3
|
-
import { BUILTIN_MANIFEST_COMPOSED, BUILTIN_MANIFEST_EVALUATION_SUMMARY_GRAPH, BUILTIN_MANIFEST_NO_AGGREGATE, BUILTIN_MANIFEST_REPORT_ROWS, BUILTIN_MANIFEST_RESULT, BUILTIN_MANIFEST_RESULT_COMPLIANCE, BUILTIN_MANIFEST_RESULT_OUTCOME_REPORT, } from "
|
|
2
|
+
import { AGENT_INPUT_ORIGINALS_EXTENSION, BOOK_PAYLOADS_EXTENSION, buildVerifiedBundleContext, carriedCapsuleCommitment, committedDigest, disclosureOf, logCoordinates, PUBLISHED_CAPSULE_RECORD_TYPE, recordTimes, resolveCarriedInput, isVerifiedBundleContext, REQUIREMENT_CLAIM, readOutcomeReportTerms, withCountersigners, } from "@action-state-group/agent-action-capsule";
|
|
3
|
+
import { BUILTIN_MANIFEST_COMPOSED, BUILTIN_MANIFEST_EVALUATION_SUMMARY_GRAPH, BUILTIN_MANIFEST_NO_AGGREGATE, BUILTIN_MANIFEST_REPORT_ROWS, BUILTIN_MANIFEST_RESULT, BUILTIN_MANIFEST_RESULT_COMPLIANCE, BUILTIN_MANIFEST_RESULT_CONTRACT_REPORT, BUILTIN_MANIFEST_RESULT_OUTCOME_REPORT, } from "./builtin-manifests.js";
|
|
4
4
|
import { classifyCountersignatures, declaredProducerKeys, } from "@action-state-group/agent-action-capsule";
|
|
5
5
|
import { buildEvidenceGraph, EvidenceGraphError, zoneStatement, } from "@action-state-group/agent-action-capsule";
|
|
6
|
-
import { digestCapability } from "@action-state-group/agent-action-capsule";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { digestCapability, JcsFloatError, JcsUnsafeIntegerError, jsonDigest, } from "@action-state-group/agent-action-capsule";
|
|
7
|
+
import { chartDatasetOf } from "./chart-dataset.js";
|
|
8
|
+
import { ChartRefusal, checkChart } from "./chart-spec.js";
|
|
9
|
+
import { renderChart, renderChartRefused, renderCharts } from "./chart-view.js";
|
|
10
|
+
import { citesOneContract, renderContractReport, } from "./contract-report.js";
|
|
11
|
+
import { readOutcomeReportPresentation, } from "./outcome-report-presentation.js";
|
|
10
12
|
import { composedSectionModule } from "./composed-view.js";
|
|
13
|
+
import { DEFAULT_WORDS, contractReportWords, } from "./contract-report-wording.js";
|
|
14
|
+
import { CORE_STRIP_ATTRIBUTE, coreStripModel, renderCoreStrip, } from "./core-strip.js";
|
|
15
|
+
import { RECORD_CONTENT_CSS, renderContent } from "./record-content.js";
|
|
16
|
+
import { deferBody, recordAddress, revealRecord, revealRecordsByHash, } from "./report-levels.js";
|
|
11
17
|
import { readCompliancePresentation, } from "./compliance-presentation.js";
|
|
12
18
|
import { readPresentationBlock } from "@action-state-group/agent-action-capsule";
|
|
13
|
-
import { bundleVerified, PresentationAmbiguityError, PresentationRegistry, } from "
|
|
19
|
+
import { bundleVerified, PresentationAmbiguityError, PresentationRegistry, presentationExtensionRows, presentationRefusalNotices, } from "./presentation-registry.js";
|
|
20
|
+
import { aacInterpreters, aliasExtensionRows, } from "./alias-interpreters.js";
|
|
14
21
|
import { buildReportRows, } from "@action-state-group/agent-action-capsule";
|
|
15
22
|
import { buildResultRoot, isResultRoot, UNVERIFIED_KEY_LABEL, } from "@action-state-group/agent-action-capsule";
|
|
16
|
-
import { buildVerificationPageModel, CHECKED_ON_THIS_PAGE, CHECKS_SCOPE_LINE, FAILED_ON_THIS_PAGE, FULL_VERIFIER_LINE, NOT_CHECKED_ON_THIS_PAGE, RECEIPT_GRADE_DISPLAY,
|
|
23
|
+
import { buildVerificationPageModel, CHECKED_ON_THIS_PAGE, CHECKS_SCOPE_LINE, FAILED_ON_THIS_PAGE, FULL_VERIFIER_LINE, NOT_CHECKED_ON_THIS_PAGE, RECEIPT_GRADE_DISPLAY, VERIFICATION_BANNER_LINES, verificationBanner, verificationCheckWords, } from "@action-state-group/agent-action-capsule";
|
|
17
24
|
function element(tag, text) {
|
|
18
25
|
const value = document.createElement(tag);
|
|
19
26
|
if (text !== undefined)
|
|
@@ -59,30 +66,89 @@ function appendTime(parent, label, value, absent) {
|
|
|
59
66
|
parent.append(cell);
|
|
60
67
|
}
|
|
61
68
|
const recordsWord = (count) => `${count} ${count === 1 ? "record" : "records"}`;
|
|
62
|
-
// The banner is drawn from
|
|
63
|
-
// row in the DOM;
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
// The banner is drawn from AAC's banner model alone (presentation contract
|
|
70
|
+
// section 6.2) and precedes every row in the DOM; a bundle that fails the
|
|
71
|
+
// page's own checks gets the refusal line here and no rows at all, so a
|
|
72
|
+
// reader never meets a payload before the verdict on the bundle that carries
|
|
73
|
+
// it. It is a pill in the page's top bar: `data-verify` is the state the
|
|
74
|
+
// reader is told (`verified` only for a `valid` verdict), `data-verdict` the
|
|
75
|
+
// strict verdict and `data-checkpoint` what became of the checkpoint
|
|
76
|
+
// signature. Its line is the core's fixed text for the state; the details
|
|
77
|
+
// line under the bar names the findings. The bar also says, from the
|
|
78
|
+
// verification section, how many checks passed, and links down to it.
|
|
79
|
+
function renderVerificationBanner(root, model, coverage) {
|
|
80
|
+
const bar = element("div");
|
|
81
|
+
// A failed bundle's bar is a callout on every page, with or without a
|
|
82
|
+
// report's frame (the shell's .cv-failed); in a report's frame an
|
|
83
|
+
// incomplete one takes its own colours (.cv-incomplete). data-verify
|
|
84
|
+
// stays the banner's.
|
|
85
|
+
bar.className =
|
|
86
|
+
model.state === "failed"
|
|
87
|
+
? "cv-shell-bar cv-failed"
|
|
88
|
+
: model.state === "incomplete"
|
|
89
|
+
? "cv-shell-bar cv-incomplete"
|
|
90
|
+
: "cv-shell-bar";
|
|
91
|
+
const banner = element("span", model.line);
|
|
92
|
+
banner.className = "cv-pill";
|
|
93
|
+
banner.dataset.verify = model.state;
|
|
94
|
+
banner.dataset.verdict = model.verdict;
|
|
95
|
+
banner.dataset.checkpoint = model.checkpoint;
|
|
96
|
+
banner.dataset.uncheckpointed = String(model.uncheckpointed);
|
|
97
|
+
bar.append(banner);
|
|
98
|
+
// The verification section's own summary line, filled in once that
|
|
99
|
+
// section is drawn (at the end of renderEvidenceGraph), and a link down
|
|
100
|
+
// to the section.
|
|
101
|
+
const summary = element("span");
|
|
102
|
+
summary.className = "cv-shell-detail";
|
|
103
|
+
summary.dataset.verifySummary = "";
|
|
104
|
+
bar.append(summary);
|
|
105
|
+
if (model.refusal === undefined && coverage.uncheckpointed > 0) {
|
|
106
|
+
const note = element("span", `${coverage.uncheckpointed} of ${recordsWord(coverage.total)} not in the checkpoint`);
|
|
107
|
+
note.className = "cv-shell-note";
|
|
108
|
+
note.dataset.uncheckpointedNote = "";
|
|
109
|
+
bar.append(note);
|
|
110
|
+
}
|
|
111
|
+
const link = element("a", CHECKED_SECTION_TITLE);
|
|
112
|
+
link.className = "cv-shell-link";
|
|
113
|
+
link.setAttribute("href", `#${CHECKED_SECTION_ID}`);
|
|
114
|
+
link.addEventListener("click", () => {
|
|
115
|
+
const section = root.ownerDocument.getElementById(CHECKED_SECTION_ID);
|
|
116
|
+
if (section instanceof root.ownerDocument.defaultView.HTMLDetailsElement)
|
|
117
|
+
section.open = true;
|
|
118
|
+
});
|
|
119
|
+
bar.append(link);
|
|
120
|
+
root.append(bar);
|
|
121
|
+
if (model.detail !== "") {
|
|
122
|
+
const detail = element("p", model.detail);
|
|
123
|
+
detail.className = "cv-banner-detail";
|
|
124
|
+
detail.dataset.bannerDetail = "";
|
|
125
|
+
root.append(detail);
|
|
126
|
+
}
|
|
127
|
+
if (model.refusal === undefined)
|
|
128
|
+
return bar;
|
|
129
|
+
const refusal = element("p", model.refusal);
|
|
79
130
|
refusal.dataset.refusal = "unverified-bundle";
|
|
80
131
|
root.append(refusal);
|
|
81
|
-
return
|
|
132
|
+
return bar;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Draw the `checking` state into `root`, replacing what it held: the
|
|
136
|
+
* banner alone, with no verdict and no row, until the checks finish
|
|
137
|
+
* (presentation contract section 6.2). Returns that banner's bar.
|
|
138
|
+
*/
|
|
139
|
+
export function renderChecking(root) {
|
|
140
|
+
const bar = element("div");
|
|
141
|
+
bar.className = "cv-shell-bar";
|
|
142
|
+
const banner = element("span", VERIFICATION_BANNER_LINES.checking);
|
|
143
|
+
banner.className = "cv-pill";
|
|
144
|
+
banner.dataset.verify = "checking";
|
|
145
|
+
bar.append(banner);
|
|
146
|
+
root.replaceChildren(bar);
|
|
147
|
+
return bar;
|
|
82
148
|
}
|
|
83
149
|
/** The words a page says when this viewer cannot verify the bundle at all. */
|
|
84
150
|
export const UNABLE_TO_VERIFY_LINES = {
|
|
85
|
-
banner:
|
|
151
|
+
banner: VERIFICATION_BANNER_LINES.unable,
|
|
86
152
|
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.",
|
|
87
153
|
command: "To check this file, run:",
|
|
88
154
|
noCommand: "To check this file, open it from a secure (https) page, or check it with a verifier outside this viewer.",
|
|
@@ -112,12 +178,74 @@ export function renderUnableToVerify(root, options = {}) {
|
|
|
112
178
|
block.append(command);
|
|
113
179
|
root.append(element("p", UNABLE_TO_VERIFY_LINES.command), block);
|
|
114
180
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
181
|
+
/**
|
|
182
|
+
* The one line a closed "How this page was checked" section shows, so what
|
|
183
|
+
* this page did not check stays in view with it folded: how many of the
|
|
184
|
+
* checks passed (or failed), how many records the file carries, and the
|
|
185
|
+
* signatures or other checks this page did not run.
|
|
186
|
+
*/
|
|
187
|
+
export function checkedSummaryLine(verified, model) {
|
|
188
|
+
const total = model.checks.length;
|
|
189
|
+
const failed = model.checks.filter((c) => c.status === "fail").length;
|
|
190
|
+
const passed = model.checks.filter((c) => c.status === "pass").length;
|
|
191
|
+
const notRun = total - failed - passed;
|
|
192
|
+
// A failure can sit outside the numbered checks (a disclosure that does not
|
|
193
|
+
// match its digest, say, or a provenance error outside both counts): a
|
|
194
|
+
// bundle that did not verify never reads as passed.
|
|
195
|
+
// The page's own lists repeat the numbered checks' ground (digests,
|
|
196
|
+
// record rules, closure, range, membership); a failure there is counted
|
|
197
|
+
// only once, as the numbered check it shows up in.
|
|
198
|
+
const pageFailed = model.checkLists.failed.filter((id) => !NUMBERED_CHECK_GROUND.has(id)).length;
|
|
199
|
+
// Numbered checks that did not run are always said, so none reads as
|
|
200
|
+
// passed or failed.
|
|
201
|
+
const notRunNote = notRun > 0 ? `, ${notRun} not run` : "";
|
|
202
|
+
const leads = [];
|
|
203
|
+
if (failed > 0)
|
|
204
|
+
leads.push(`${failed} of ${total} checks failed${notRunNote}`);
|
|
205
|
+
if (pageFailed > 0)
|
|
206
|
+
leads.push(`${pageFailed} ${pageFailed === 1 ? "check" : "checks"} on this page failed`);
|
|
207
|
+
if (failed === 0 && pageFailed === 0)
|
|
208
|
+
leads.push(verified
|
|
209
|
+
? `${passed} of ${total} checks passed${notRunNote}`
|
|
210
|
+
: SUMMARY_NOT_VERIFIED);
|
|
211
|
+
if (failed === 0 && (pageFailed > 0 || !verified) && notRun > 0)
|
|
212
|
+
leads.push(`${notRun} of ${total} checks not run`);
|
|
213
|
+
const parts = [...leads, recordsWord(model.records.length)];
|
|
214
|
+
// Only the signature checks that are in the not-checked list are named, each
|
|
215
|
+
// by its own words: a signature check that ran (or failed) is never said to
|
|
216
|
+
// be unchecked, so the summary cannot contradict the lists under it.
|
|
217
|
+
const signatures = model.checkLists.notChecked.flatMap((id) => {
|
|
218
|
+
const words = SIGNATURE_CHECKS.get(id);
|
|
219
|
+
return words === undefined ? [] : [words];
|
|
220
|
+
});
|
|
221
|
+
const others = model.checkLists.notChecked.length - signatures.length;
|
|
222
|
+
if (signatures.length > 0)
|
|
223
|
+
parts.push(`${signatures.length === 1
|
|
224
|
+
? signatures[0]
|
|
225
|
+
: `${signatures.slice(0, -1).join(", ")} and ${signatures.at(-1)}`} not checked here`);
|
|
226
|
+
if (others > 0)
|
|
227
|
+
parts.push(`${others} other ${others === 1 ? "check" : "checks"} not run here`);
|
|
228
|
+
return parts.join(" · ");
|
|
120
229
|
}
|
|
230
|
+
/** The summary's lead for a bundle that failed outside every counted check. */
|
|
231
|
+
export const SUMMARY_NOT_VERIFIED = "the bundle did not verify";
|
|
232
|
+
const NUMBERED_CHECK_GROUND = new Set([
|
|
233
|
+
"record-digests",
|
|
234
|
+
"record-rules",
|
|
235
|
+
"closure",
|
|
236
|
+
"range",
|
|
237
|
+
"membership",
|
|
238
|
+
]);
|
|
239
|
+
const SIGNATURE_CHECKS = new Map([
|
|
240
|
+
["checkpoint-signature", "checkpoint signature"],
|
|
241
|
+
["producer-signatures", "producer signatures"],
|
|
242
|
+
["cited-signers", "cited signers' signatures"],
|
|
243
|
+
["countersignatures", "countersignatures"],
|
|
244
|
+
]);
|
|
245
|
+
/** The folded verification section's heading. */
|
|
246
|
+
export const CHECKED_SECTION_TITLE = "How this page was checked";
|
|
247
|
+
/** The folded verification section's id, the banner link's target. */
|
|
248
|
+
const CHECKED_SECTION_ID = "cv-checked";
|
|
121
249
|
// presentation/v1 is rendered here, in the header only, and nowhere else in
|
|
122
250
|
// this module. Only readPresentationBlock's three known fields ever reach
|
|
123
251
|
// the DOM -- the chrome rule holds structurally, not by a rendering-site
|
|
@@ -228,8 +356,10 @@ const COVERAGE_LABEL = Object.freeze({
|
|
|
228
356
|
// stated in words above the list. When it did not, the line says so and
|
|
229
357
|
// names the verifier's reason -- never "0 records uncheckpointed" on a
|
|
230
358
|
// bundle whose memberships were never verified -- and when the claim was
|
|
231
|
-
// withheld (no checkpoint to stand under) there
|
|
232
|
-
|
|
359
|
+
// withheld (no checkpoint to stand under) there are no counts by status.
|
|
360
|
+
// The records list follows either way: it is where every link to a record
|
|
361
|
+
// lands.
|
|
362
|
+
function renderCheckpointCoverage(host, records, uncheckpointed, coverage, entries, depth) {
|
|
233
363
|
host.append(element("h4", "Checkpoint coverage"));
|
|
234
364
|
if (coverage.status === "established") {
|
|
235
365
|
const count = element("p", `${recordsWord(uncheckpointed)} uncheckpointed of ${recordsWord(records.length)} supplied`);
|
|
@@ -242,27 +372,204 @@ function renderCheckpointCoverage(host, records, uncheckpointed, coverage) {
|
|
|
242
372
|
line.dataset.coverage = "not-established";
|
|
243
373
|
line.dataset.claim = coverage.status;
|
|
244
374
|
host.append(line);
|
|
245
|
-
if (coverage.status === "withheld")
|
|
246
|
-
return;
|
|
247
375
|
}
|
|
248
|
-
|
|
249
|
-
|
|
376
|
+
if (coverage.status !== "withheld")
|
|
377
|
+
host.append(renderCoverageStatusCounts(records));
|
|
378
|
+
host.append(renderRecordsList(records, entries, depth));
|
|
379
|
+
}
|
|
380
|
+
// Records in this bundle: one entry per capsule id, each with its own address
|
|
381
|
+
// (`record-<capsule id>`, from the id alone, so every packaging of the page
|
|
382
|
+
// gives the same one), and, for an evidence-book record, a second address
|
|
383
|
+
// under the id of the capsule it carries, so a link by either id lands
|
|
384
|
+
// here. An id the bundle repeats is one entry with one address. The address sits
|
|
385
|
+
// inside the entry, not on it: a browser following a link opens every
|
|
386
|
+
// closed <details> around its target, so the entry itself opens too, with
|
|
387
|
+
// no script (and, where script runs, its body is built on that toggle).
|
|
388
|
+
// Closed until a link lands on it or the reader opens it; its body is built
|
|
389
|
+
// when it opens, or before a static page is written. At depth L2 the list
|
|
390
|
+
// is open, but not its entries: there are hundreds, and each opens when a
|
|
391
|
+
// link lands on it or the reader opens it. Other parts of the page link
|
|
392
|
+
// here and never draw a record themselves. For a bundle that did not
|
|
393
|
+
// verify, the list names each record, its kind and its standing, and draws
|
|
394
|
+
// no content.
|
|
395
|
+
function renderRecordsList(records, entries, depth) {
|
|
396
|
+
const details = document.createElement("details");
|
|
250
397
|
details.dataset.records = "coverage-detail";
|
|
251
|
-
|
|
398
|
+
details.open = depth === "L2";
|
|
399
|
+
// One entry per capsule id, in first-listed order: a repeated id is one
|
|
400
|
+
// record listed more than once, so it gets one entry, one address and a
|
|
401
|
+
// note of how many times the bundle lists it, with each listing's status.
|
|
402
|
+
const listings = new Map();
|
|
403
|
+
for (const record of records)
|
|
404
|
+
listings.set(record.capsuleId, [
|
|
405
|
+
...(listings.get(record.capsuleId) ?? []),
|
|
406
|
+
record,
|
|
407
|
+
]);
|
|
408
|
+
const count = listings.size === records.length
|
|
409
|
+
? recordsWord(listings.size)
|
|
410
|
+
: `${recordsWord(listings.size)} (${records.length} listings)`;
|
|
411
|
+
const summary = element("summary", `Records in this bundle: ${count}, by capsule id`);
|
|
252
412
|
details.append(summary);
|
|
413
|
+
if (!entries.verified) {
|
|
414
|
+
const note = element("p", "Record content is not shown: this bundle did not verify.");
|
|
415
|
+
note.dataset.records = "not-shown";
|
|
416
|
+
details.append(note);
|
|
417
|
+
}
|
|
253
418
|
const list = element("ul");
|
|
254
419
|
list.dataset.records = "coverage";
|
|
420
|
+
// Addresses in two passes, as AAC's Result reader resolves ids: every
|
|
421
|
+
// record's own id first, then a carried capsule's id only where no record
|
|
422
|
+
// has that id (and only once), so a book record listed before the capsule
|
|
423
|
+
// it carries never takes that capsule's address.
|
|
424
|
+
const owners = new Map();
|
|
425
|
+
for (const record of records)
|
|
426
|
+
if (entries.verified && entries.read.has(record.capsuleId))
|
|
427
|
+
if (!owners.has(record.capsuleId))
|
|
428
|
+
owners.set(record.capsuleId, record.capsuleId);
|
|
429
|
+
const own = new Set(records.map((record) => record.capsuleId));
|
|
255
430
|
for (const record of records) {
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
431
|
+
const carried = entries.read.get(record.capsuleId)?.carriedCapsuleId;
|
|
432
|
+
if (entries.verified &&
|
|
433
|
+
carried !== undefined &&
|
|
434
|
+
!own.has(carried) &&
|
|
435
|
+
!owners.has(carried))
|
|
436
|
+
owners.set(carried, record.capsuleId);
|
|
437
|
+
}
|
|
438
|
+
const used = new Set();
|
|
439
|
+
const address = (id, holder) => {
|
|
440
|
+
const name = recordAddress(id);
|
|
441
|
+
if (owners.get(id) !== holder || used.has(name))
|
|
442
|
+
return undefined;
|
|
443
|
+
used.add(name);
|
|
444
|
+
const anchor = element("span");
|
|
445
|
+
anchor.className = "cv-record-anchor";
|
|
446
|
+
anchor.id = name;
|
|
447
|
+
return anchor;
|
|
448
|
+
};
|
|
449
|
+
for (const [capsuleId, listed] of listings) {
|
|
450
|
+
const record = listed[0];
|
|
451
|
+
const item = element("li");
|
|
452
|
+
item.dataset.capsuleId = capsuleId;
|
|
453
|
+
const kind = entries.kind(capsuleId);
|
|
454
|
+
const status = element("span");
|
|
455
|
+
listed.forEach((one, i) => {
|
|
456
|
+
if (i > 0)
|
|
457
|
+
status.append(" / ");
|
|
458
|
+
const word = element("span", COVERAGE_LABEL[one.status]);
|
|
459
|
+
word.dataset.recordStatus = one.status;
|
|
460
|
+
word.className = `seal-${one.status}`;
|
|
461
|
+
status.append(word);
|
|
462
|
+
});
|
|
463
|
+
if (listed.length > 1) {
|
|
464
|
+
item.dataset.listed = String(listed.length);
|
|
465
|
+
status.append(` · listed ${listed.length} times in this bundle`);
|
|
466
|
+
}
|
|
467
|
+
const label = `${capsuleId} · ${kind ?? "kind not stated"} · `;
|
|
468
|
+
const read = entries.read.get(capsuleId);
|
|
469
|
+
if (!entries.verified || read === undefined) {
|
|
470
|
+
item.append(document.createTextNode(label), status);
|
|
471
|
+
list.append(item);
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
const fold = document.createElement("details");
|
|
475
|
+
fold.className = "cv-record";
|
|
476
|
+
fold.dataset.record = record.capsuleId;
|
|
477
|
+
const head = element("summary", label);
|
|
478
|
+
head.append(status);
|
|
479
|
+
fold.append(head);
|
|
480
|
+
const anchors = [record.capsuleId, read.carriedCapsuleId]
|
|
481
|
+
.filter((id) => id !== undefined)
|
|
482
|
+
.map((id) => address(id, record.capsuleId))
|
|
483
|
+
.filter((a) => a !== undefined);
|
|
484
|
+
fold.append(...anchors);
|
|
485
|
+
deferBody(fold, () => entries.build(record.capsuleId, read));
|
|
486
|
+
// Where script runs, the body is built after the browser scrolled to
|
|
487
|
+
// the address; bring it back into view once the body is in place.
|
|
488
|
+
fold.addEventListener("toggle", () => {
|
|
489
|
+
const hash = fold.ownerDocument.defaultView?.location?.hash;
|
|
490
|
+
const target = anchors.find((a) => hash === `#${a.id}`);
|
|
491
|
+
if (fold.open && target !== undefined)
|
|
492
|
+
target.scrollIntoView?.();
|
|
493
|
+
});
|
|
494
|
+
item.append(fold);
|
|
262
495
|
list.append(item);
|
|
263
496
|
}
|
|
264
497
|
details.append(list);
|
|
265
|
-
|
|
498
|
+
return details;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Each record's reading for the records list, from the verifier's resolved
|
|
502
|
+
* context: the Result's reading where a claim reaches the record, otherwise
|
|
503
|
+
* the record's own times, log position, committed digests and disclosed
|
|
504
|
+
* members, and, for an evidence-book record, the capsule it carries,
|
|
505
|
+
* checked as the Result reader checks it (`carriedCapsuleCommitment`,
|
|
506
|
+
* `resolveCarriedInput`).
|
|
507
|
+
*/
|
|
508
|
+
async function recordEntries(context, result) {
|
|
509
|
+
const read = new Map();
|
|
510
|
+
for (const record of result?.records.values() ?? []) {
|
|
511
|
+
const id = record.bookRecordId ?? record.capsuleId;
|
|
512
|
+
if (!read.has(id))
|
|
513
|
+
read.set(id, record);
|
|
514
|
+
}
|
|
515
|
+
const bundle = object(context.bundle);
|
|
516
|
+
const memberships = context.completeness.memberships;
|
|
517
|
+
const extensions = object(bundle.extensions);
|
|
518
|
+
const payloads = object(extensions[BOOK_PAYLOADS_EXTENSION]);
|
|
519
|
+
const originals = object(extensions[AGENT_INPUT_ORIGINALS_EXTENSION]);
|
|
520
|
+
for (const raw of context.records) {
|
|
521
|
+
const id = raw.capsule_id;
|
|
522
|
+
if (read.has(id))
|
|
523
|
+
continue;
|
|
524
|
+
const agentInput = disclosureOf(context, id, "agent_input");
|
|
525
|
+
const header = agentInput.state === "disclosed" &&
|
|
526
|
+
object(agentInput.payload).record_type === PUBLISHED_CAPSULE_RECORD_TYPE
|
|
527
|
+
? agentInput.payload
|
|
528
|
+
: undefined;
|
|
529
|
+
const carried = header === undefined
|
|
530
|
+
? undefined
|
|
531
|
+
: await carriedCapsuleCommitment(header, payloads);
|
|
532
|
+
const carriedInput = header === undefined
|
|
533
|
+
? undefined
|
|
534
|
+
: await resolveCarriedInput(header, payloads, originals);
|
|
535
|
+
const references = Array.isArray(raw.references) ? raw.references : [];
|
|
536
|
+
const agentInputDigest = committedDigest(raw, "agent_input");
|
|
537
|
+
const agentOutputDigest = committedDigest(raw, "agent_output");
|
|
538
|
+
const coordinates = logCoordinates(memberships, id);
|
|
539
|
+
read.set(id, {
|
|
540
|
+
...recordTimes(raw),
|
|
541
|
+
capsuleId: id,
|
|
542
|
+
agentInput,
|
|
543
|
+
agentOutput: disclosureOf(context, id, "agent_output"),
|
|
544
|
+
...(agentInputDigest === undefined ? {} : { agentInputDigest }),
|
|
545
|
+
...(agentOutputDigest === undefined ? {} : { agentOutputDigest }),
|
|
546
|
+
...(coordinates === undefined ? {} : { logCoordinates: coordinates }),
|
|
547
|
+
...(carriedInput === undefined ? {} : { carriedInput }),
|
|
548
|
+
...(carried === undefined
|
|
549
|
+
? {}
|
|
550
|
+
: {
|
|
551
|
+
carriedCapsuleId: carried.capsuleId,
|
|
552
|
+
carriedInputDigest: carried.inputDigest,
|
|
553
|
+
}),
|
|
554
|
+
cites: references.flatMap((ref) => {
|
|
555
|
+
const r = object(ref);
|
|
556
|
+
return r.citation_purpose === "acted_on" && typeof r.digest === "string"
|
|
557
|
+
? [r.digest]
|
|
558
|
+
: [];
|
|
559
|
+
}),
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
return read;
|
|
563
|
+
}
|
|
564
|
+
/** A record's kind: its disclosed book header's `record_type`, else its own `action_type`. */
|
|
565
|
+
function recordKind(raw, read) {
|
|
566
|
+
const header = read?.agentInput.state === "disclosed"
|
|
567
|
+
? object(read.agentInput.payload).record_type
|
|
568
|
+
: undefined;
|
|
569
|
+
if (typeof header === "string")
|
|
570
|
+
return header;
|
|
571
|
+
const own = object(raw).action_type;
|
|
572
|
+
return typeof own === "string" ? own : undefined;
|
|
266
573
|
}
|
|
267
574
|
// Counts by seal status -- the line a reader actually needs (how many of
|
|
268
575
|
// each) without scrolling a list that is one row per record (500+ rows on a
|
|
@@ -347,6 +654,9 @@ function renderExtensionTable(host, rows) {
|
|
|
347
654
|
: row.interpreter === undefined
|
|
348
655
|
? "uninterpreted"
|
|
349
656
|
: "interpreted";
|
|
657
|
+
// The interpreter that showed the block, as AAC's renderer wrote it.
|
|
658
|
+
if (row.interpreter !== undefined)
|
|
659
|
+
tr.dataset.interpreter = row.interpreter;
|
|
350
660
|
if (row.refusal !== undefined) {
|
|
351
661
|
tr.dataset.refusedModule = row.refusal.id;
|
|
352
662
|
tr.dataset.refusal = row.refusal.reason;
|
|
@@ -410,8 +720,8 @@ function renderCheckLists(host, lists, verifierHint) {
|
|
|
410
720
|
// `applied` is the set of extension interpreters this rendering ran; an
|
|
411
721
|
// extension row says "interpreted by" only for one of them. `refused` is
|
|
412
722
|
// every module this runtime refused that matched (page, then section).
|
|
413
|
-
async function renderVerificationPage(root, context, styled, applied, refused, citedSigners, verifierHint) {
|
|
414
|
-
const { bundle, verification: verified
|
|
723
|
+
async function renderVerificationPage(root, context, styled, applied, refused, citedSigners, verifierHint, depth, stamps, charts) {
|
|
724
|
+
const { bundle, verification: verified } = context;
|
|
415
725
|
const section = element("section");
|
|
416
726
|
section.dataset.page = "verification";
|
|
417
727
|
let page = section;
|
|
@@ -422,15 +732,28 @@ async function renderVerificationPage(root, context, styled, applied, refused, c
|
|
|
422
732
|
section.append(page);
|
|
423
733
|
}
|
|
424
734
|
page.append(element("h2", "Verification"));
|
|
425
|
-
|
|
426
|
-
|
|
735
|
+
// The strict result too, so these lists are the ones the banner's line
|
|
736
|
+
// points at (verificationBanner reads the same lists).
|
|
737
|
+
const model = buildVerificationPageModel(bundle, verified, aacInterpreters(applied), {
|
|
427
738
|
stamps,
|
|
428
739
|
citedSigners,
|
|
740
|
+
...(context.strict === undefined ? {} : { strict: context.strict }),
|
|
429
741
|
});
|
|
742
|
+
// AAC's page model carries no presentation refusals: this registry lays
|
|
743
|
+
// its refusal rows over AAC's extension rows (the integrity words from
|
|
744
|
+
// each row's own integrity) and adds a notice for each refused module
|
|
745
|
+
// with no row (presentation contract section 3.2). The deprecated cards'
|
|
746
|
+
// interpreters, which AAC 0.8.0 no longer reports, are applied first.
|
|
747
|
+
const extensions = presentationExtensionRows(aliasExtensionRows(bundle, model.extensions, applied), refused);
|
|
430
748
|
const summary = element("dl");
|
|
431
749
|
appendValue(summary, "bundle digest", model.bundleDigest ?? "uncomputable");
|
|
432
750
|
appendValue(summary, "checkpoint root", model.checkpointRoot ?? "absent");
|
|
433
751
|
appendValue(summary, "checkpoint size", model.checkpointSize ?? "absent");
|
|
752
|
+
// Each chart spec the page was built with, by the SHA-256 of its JCS, and
|
|
753
|
+
// whether it was drawn (docs/design/chart-spec.md section 1).
|
|
754
|
+
charts.forEach((chart, i) => appendValue(summary, `chart spec ${i + 1} sha256`, chart.refused === undefined
|
|
755
|
+
? chart.sha256
|
|
756
|
+
: `${chart.sha256} (not drawn: ${chart.refused})`));
|
|
434
757
|
page.append(summary);
|
|
435
758
|
renderReceipts(page, model.receipts);
|
|
436
759
|
if (model.selfWitnessed) {
|
|
@@ -440,14 +763,54 @@ async function renderVerificationPage(root, context, styled, applied, refused, c
|
|
|
440
763
|
witness.dataset.witness = "self";
|
|
441
764
|
page.append(witness);
|
|
442
765
|
}
|
|
443
|
-
|
|
766
|
+
// The content block's own styles: the records list is the core's, inside
|
|
767
|
+
// no module's frame (record-content.ts RECORD_CONTENT_CSS).
|
|
768
|
+
const contentStyle = element("style");
|
|
769
|
+
contentStyle.textContent = RECORD_CONTENT_CSS;
|
|
770
|
+
page.append(contentStyle);
|
|
771
|
+
let result;
|
|
772
|
+
try {
|
|
773
|
+
result = bundleVerified(verified) ? await resultRootOf(context) : undefined;
|
|
774
|
+
}
|
|
775
|
+
catch {
|
|
776
|
+
result = undefined;
|
|
777
|
+
}
|
|
778
|
+
const read = bundleVerified(verified)
|
|
779
|
+
? await recordEntries(context, result)
|
|
780
|
+
: new Map();
|
|
781
|
+
const rawRecords = new Map();
|
|
782
|
+
for (const raw of Array.isArray(object(bundle).records)
|
|
783
|
+
? object(bundle).records
|
|
784
|
+
: [])
|
|
785
|
+
if (typeof object(raw).capsule_id === "string")
|
|
786
|
+
rawRecords.set(object(raw).capsule_id, raw);
|
|
787
|
+
renderCheckpointCoverage(page, model.records, model.uncheckpointedCount, model.coverage, {
|
|
788
|
+
verified: bundleVerified(verified),
|
|
789
|
+
read,
|
|
790
|
+
kind: (id) => recordKind(rawRecords.get(id), read.get(id)),
|
|
791
|
+
build: (id, record) => renderRecordEntry(id, record),
|
|
792
|
+
}, depth);
|
|
444
793
|
renderStamps(page, stamps);
|
|
445
794
|
renderCompletenessStatement(page, model.completeness);
|
|
446
795
|
renderChecks(page, model.checks);
|
|
447
|
-
renderExtensions(page,
|
|
796
|
+
renderExtensions(page, extensions, presentationRefusalNotices(refused));
|
|
448
797
|
renderCheckLists(page, model.checkLists, verifierHint);
|
|
449
798
|
page.append(element("p", model.verifyIndependentlyLine));
|
|
450
|
-
|
|
799
|
+
// Folded into one section, closed for a bundle that verified; its summary
|
|
800
|
+
// line keeps the counts and what was not checked in view.
|
|
801
|
+
const folded = document.createElement("details");
|
|
802
|
+
folded.className = "cv-checked";
|
|
803
|
+
folded.id = CHECKED_SECTION_ID;
|
|
804
|
+
folded.dataset.checked = "";
|
|
805
|
+
// Open when the bundle did not verify, and at depth L2, where everything
|
|
806
|
+
// is open (presentation contract section 9.1).
|
|
807
|
+
folded.open = !bundleVerified(verified) || depth === "L2";
|
|
808
|
+
const line = checkedSummaryLine(bundleVerified(verified), model);
|
|
809
|
+
const heading = element("summary");
|
|
810
|
+
heading.append(element("strong", CHECKED_SECTION_TITLE), document.createTextNode(` · ${line}`));
|
|
811
|
+
folded.append(heading, section);
|
|
812
|
+
root.append(folded);
|
|
813
|
+
return line;
|
|
451
814
|
}
|
|
452
815
|
function metRate(report) {
|
|
453
816
|
const required = report.outcomes.filter((outcome) => outcome.role === "required");
|
|
@@ -669,18 +1032,28 @@ function renderReportRowsTable(reportRows, root) {
|
|
|
669
1032
|
// each committed member as disclosed or as `withheld · <digest>`, and the
|
|
670
1033
|
// records it cites in turn -- so aggregate → daily → case → act is a walk
|
|
671
1034
|
// over citations, never report-specific markup.
|
|
672
|
-
function renderCitedMember(host, field, resolution, committed) {
|
|
673
|
-
|
|
1035
|
+
function renderCitedMember(host, field, resolution, committed, label = field) {
|
|
1036
|
+
// A value that does not match its commitment is always noted, even where
|
|
1037
|
+
// the caller has no committed digest to name (a record no claim reaches).
|
|
1038
|
+
if (resolution.state !== "disclosed" &&
|
|
1039
|
+
resolution.state !== "disclosure_mismatch" &&
|
|
1040
|
+
committed === undefined)
|
|
674
1041
|
return;
|
|
675
|
-
host.append(element("h5",
|
|
1042
|
+
host.append(element("h5", label));
|
|
676
1043
|
if (resolution.state === "disclosed") {
|
|
677
|
-
|
|
1044
|
+
// The core states what it established, once, beside the block; the
|
|
1045
|
+
// content module only draws the content (presentation contract 6.1).
|
|
1046
|
+
const checked = element("p", "The content shown matches the digest the record commits to.");
|
|
1047
|
+
checked.dataset.contentCheck = "digest";
|
|
1048
|
+
host.append(checked, renderContent(resolution.payload, DEFAULT_WORDS.lines));
|
|
678
1049
|
return;
|
|
679
1050
|
}
|
|
680
1051
|
// A withheld member shows the digest the record committed to; a supplied
|
|
681
1052
|
// value that does not hash to it is never shown, only noted.
|
|
682
1053
|
const note = element("p", resolution.state === "disclosure_mismatch"
|
|
683
|
-
?
|
|
1054
|
+
? committed === undefined
|
|
1055
|
+
? "withheld: the disclosed value does not match the committed digest"
|
|
1056
|
+
: `withheld · ${committed}: the disclosed value does not match the committed digest`
|
|
684
1057
|
: `withheld · ${committed}`);
|
|
685
1058
|
note.dataset.disclosure = resolution.state;
|
|
686
1059
|
host.append(note);
|
|
@@ -691,12 +1064,46 @@ function renderCitedRecord(record, records, host) {
|
|
|
691
1064
|
section.append(renderProvenance(record.capsuleId, record.logCoordinates, record));
|
|
692
1065
|
renderCitedMember(section, "agent_input", record.agentInput, record.agentInputDigest);
|
|
693
1066
|
renderCitedMember(section, "agent_output", record.agentOutput, record.agentOutputDigest);
|
|
1067
|
+
renderCarriedInput(section, record);
|
|
694
1068
|
if (record.cites.length > 0) {
|
|
695
1069
|
section.append(element("h5", "Cites"));
|
|
696
1070
|
renderCitationList(record.cites, records, section);
|
|
697
1071
|
}
|
|
698
1072
|
host.append(section);
|
|
699
1073
|
}
|
|
1074
|
+
// An evidence-book record's agent_input is the book's header; what the
|
|
1075
|
+
// capsule it carries sealed is the carried input, drawn the same way.
|
|
1076
|
+
function renderCarriedInput(host, record) {
|
|
1077
|
+
if (record.carriedInput === undefined)
|
|
1078
|
+
return;
|
|
1079
|
+
renderCitedMember(host, "agent_input", record.carriedInput, record.carriedInputDigest, "agent_input of the capsule it carries");
|
|
1080
|
+
}
|
|
1081
|
+
// A record's entry in the records section: its provenance (times, seal
|
|
1082
|
+
// status, log position), each committed member as disclosed or withheld,
|
|
1083
|
+
// the capsule it carries, and the records it cites as links to their
|
|
1084
|
+
// entries.
|
|
1085
|
+
function renderRecordEntry(capsuleId, record) {
|
|
1086
|
+
const body = element("div");
|
|
1087
|
+
body.className = "cv-record-body";
|
|
1088
|
+
body.append(renderProvenance(capsuleId, record.logCoordinates, record));
|
|
1089
|
+
renderCitedMember(body, "agent_input", record.agentInput, record.agentInputDigest);
|
|
1090
|
+
renderCitedMember(body, "agent_output", record.agentOutput, record.agentOutputDigest);
|
|
1091
|
+
renderCarriedInput(body, record);
|
|
1092
|
+
if (record.cites.length > 0) {
|
|
1093
|
+
body.append(element("h5", "Cites"));
|
|
1094
|
+
const list = element("ul");
|
|
1095
|
+
for (const id of record.cites) {
|
|
1096
|
+
const item = element("li");
|
|
1097
|
+
const link = element("a", id);
|
|
1098
|
+
link.setAttribute("href", `#${recordAddress(id)}`);
|
|
1099
|
+
link.addEventListener("click", () => revealRecord(link, id));
|
|
1100
|
+
item.append(link);
|
|
1101
|
+
list.append(item);
|
|
1102
|
+
}
|
|
1103
|
+
body.append(list);
|
|
1104
|
+
}
|
|
1105
|
+
return body;
|
|
1106
|
+
}
|
|
700
1107
|
// One row per cited id, in citation order: a record supplied in this bundle
|
|
701
1108
|
// opens under the list on click; one that is not says so and stays.
|
|
702
1109
|
function renderCitationList(ids, records, host) {
|
|
@@ -838,15 +1245,24 @@ function renderClose(close, result, host) {
|
|
|
838
1245
|
// `failed` -- never `met`, never its stated verdict, which is kept on
|
|
839
1246
|
// `data-stated-verdict` only. Otherwise an unresolved citation reads
|
|
840
1247
|
// `unsupported`. The row stays in every case.
|
|
841
|
-
|
|
842
|
-
|
|
1248
|
+
// The verdict a reader may see: never the producer's word for a claim that
|
|
1249
|
+
// failed verification or whose evidence is not in the bundle.
|
|
1250
|
+
function shownVerdict(claim) {
|
|
1251
|
+
return claim.failed
|
|
843
1252
|
? "failed"
|
|
844
1253
|
: claim.support === "supported"
|
|
845
1254
|
? claim.verdict
|
|
846
1255
|
: "unsupported";
|
|
847
|
-
|
|
1256
|
+
}
|
|
1257
|
+
function appendVerdict(parent, claim) {
|
|
1258
|
+
const shown = shownVerdict(claim);
|
|
1259
|
+
// A later claim's verdict is readiness only (ER section 4.3): never read
|
|
1260
|
+
// as a result that counts.
|
|
1261
|
+
const cell = element(parent.tagName === "TR" ? "td" : "dd", claim.later ? `${shown} (readiness)` : shown);
|
|
848
1262
|
cell.dataset.verdict = shown;
|
|
849
1263
|
cell.dataset.support = claim.support;
|
|
1264
|
+
if (claim.later)
|
|
1265
|
+
cell.dataset.later = "true";
|
|
850
1266
|
if (claim.failed) {
|
|
851
1267
|
cell.dataset.statedVerdict = claim.verdict;
|
|
852
1268
|
cell.className = "claim-failed";
|
|
@@ -943,53 +1359,48 @@ function renderClaim(claim, result, host) {
|
|
|
943
1359
|
}
|
|
944
1360
|
}
|
|
945
1361
|
const BUCKETS = [
|
|
946
|
-
["met", "met"],
|
|
947
|
-
["notMet", "not met"],
|
|
948
|
-
["notEvaluable", "not evaluable"],
|
|
1362
|
+
["met", "met", "buckets.met"],
|
|
1363
|
+
["notMet", "not met", "buckets.not_met"],
|
|
1364
|
+
["notEvaluable", "not evaluable", "buckets.not_evaluable"],
|
|
1365
|
+
// ER section 4.2: drawn only when the Result carries the fourth bucket.
|
|
1366
|
+
["outOfScope", "out of scope", "buckets.out_of_scope"],
|
|
949
1367
|
];
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
//
|
|
1368
|
+
/**
|
|
1369
|
+
* The marks the core puts on a Result's counts: the strip, the bucket tallies
|
|
1370
|
+
* and lists, and the count-mismatch markers. A page whose root is no Result
|
|
1371
|
+
* shows none of them; a module that draws one there is discarded for the
|
|
1372
|
+
* refusal (renderVerifiedContext).
|
|
1373
|
+
*/
|
|
1374
|
+
const RESULT_COUNT_MARKS = `[${CORE_STRIP_ATTRIBUTE}], .cv-strip, [data-bucket], [data-bucket-count], [data-count-mismatch]`;
|
|
1375
|
+
/** Said above the generic Result page when a Result opted into a card whose layout cannot hold its claims (`claimsFitCard`). */
|
|
1376
|
+
export const CARD_UNFIT_NOTE = "This Result's claims don't fit the report layout, so every claim is listed below instead.";
|
|
1377
|
+
// The Result page lists the claims by verdict, after the core strip, which
|
|
1378
|
+
// draws coverage first and then the buckets, never a single figure
|
|
1379
|
+
// (core-strip.ts). Every count drawn here is the recomputed one
|
|
1380
|
+
// (`result.bucketCounts`); a producer figure the claims do not bear out
|
|
1381
|
+
// shows as a `count mismatch` marker beside it. Each claim keeps its own
|
|
1382
|
+
// tier and grade on its row.
|
|
960
1383
|
function renderResultPage(result, root) {
|
|
961
1384
|
const section = element("section");
|
|
962
1385
|
section.dataset.page = "result";
|
|
963
1386
|
section.append(element("h1", "Evidence result"));
|
|
964
|
-
const
|
|
965
|
-
coverage.append(`coverage: ${result.coverage.evaluatedPopulation} requirements evaluated`);
|
|
966
|
-
const evaluatedMarker = countMismatchMarker(result, "evaluated_population");
|
|
967
|
-
if (evaluatedMarker !== undefined)
|
|
968
|
-
coverage.append(" ", evaluatedMarker);
|
|
969
|
-
coverage.append(` · ${result.coverage.excludedNotApplicable} excluded as not applicable · ${result.coverage.unknownCount} unresolved`);
|
|
970
|
-
const unknownMarker = countMismatchMarker(result, "unknown_count");
|
|
971
|
-
if (unknownMarker !== undefined)
|
|
972
|
-
coverage.append(" ", unknownMarker);
|
|
973
|
-
coverage.dataset.coverage = "result";
|
|
974
|
-
coverage.dataset.evaluated = String(result.coverage.evaluatedPopulation);
|
|
975
|
-
coverage.dataset.excluded = String(result.coverage.excludedNotApplicable);
|
|
976
|
-
coverage.dataset.excludedBasis = "stated";
|
|
977
|
-
coverage.dataset.unknown = String(result.coverage.unknownCount);
|
|
978
|
-
section.append(coverage);
|
|
1387
|
+
const later = result.claims.filter((claim) => claim.later);
|
|
979
1388
|
const byId = new Map(result.claims.map((claim) => [claim.id, claim]));
|
|
980
1389
|
const buckets = element("section");
|
|
981
1390
|
buckets.dataset.buckets = "verdict";
|
|
982
1391
|
buckets.append(element("h2", "Claims by verdict"));
|
|
983
|
-
for (const [key, label] of BUCKETS) {
|
|
984
|
-
const
|
|
1392
|
+
for (const [key, label, field] of BUCKETS) {
|
|
1393
|
+
const ids = result.buckets[key];
|
|
1394
|
+
if (ids === undefined)
|
|
1395
|
+
continue;
|
|
1396
|
+
const count = result.bucketCounts[key] ?? 0;
|
|
985
1397
|
const heading = element("h3", `${label}: ${count === 0 ? "none" : count}`);
|
|
986
1398
|
heading.dataset.bucketCount = String(count);
|
|
987
1399
|
heading.dataset.bucketOf = key;
|
|
988
|
-
const marker = countMismatchMarker(result,
|
|
1400
|
+
const marker = countMismatchMarker(result, field);
|
|
989
1401
|
if (marker !== undefined)
|
|
990
1402
|
heading.append(" ", marker);
|
|
991
1403
|
buckets.append(heading);
|
|
992
|
-
const ids = result.buckets[key];
|
|
993
1404
|
if (ids.length === 0) {
|
|
994
1405
|
buckets.append(element("p", "none"));
|
|
995
1406
|
continue;
|
|
@@ -1012,7 +1423,7 @@ function renderResultPage(result, root) {
|
|
|
1012
1423
|
}
|
|
1013
1424
|
buckets.append(list);
|
|
1014
1425
|
}
|
|
1015
|
-
// The verifier's own state, after the producer's
|
|
1426
|
+
// The verifier's own state, after the producer's buckets: claims
|
|
1016
1427
|
// that failed verification (a close state the links contradict). Drawn
|
|
1017
1428
|
// always, `none` when empty, so a reader never has to infer from an
|
|
1018
1429
|
// absent heading that nothing failed. Not a verdict bucket: a failed
|
|
@@ -1038,6 +1449,26 @@ function renderResultPage(result, root) {
|
|
|
1038
1449
|
}
|
|
1039
1450
|
buckets.append(list);
|
|
1040
1451
|
}
|
|
1452
|
+
// ER section 4.3: claims not yet in force, their verdicts readiness only,
|
|
1453
|
+
// in no bucket above.
|
|
1454
|
+
if (later.length > 0) {
|
|
1455
|
+
const heading = element("h3", `not yet in force: ${later.length}`);
|
|
1456
|
+
heading.dataset.bucketOf = "notYetInForce";
|
|
1457
|
+
heading.dataset.bucketCount = String(later.length);
|
|
1458
|
+
buckets.append(heading);
|
|
1459
|
+
const list = element("ul");
|
|
1460
|
+
list.dataset.bucket = "notYetInForce";
|
|
1461
|
+
for (const claim of later) {
|
|
1462
|
+
const item = element("li", `${claim.id} · applies from ${claim.appliesFrom ?? ""} · readiness: ${shownVerdict(claim)}`);
|
|
1463
|
+
item.dataset.claimRef = claim.id;
|
|
1464
|
+
if (claim.failed)
|
|
1465
|
+
item.className = "claim-failed";
|
|
1466
|
+
else if (claim.support === "unsupported")
|
|
1467
|
+
item.className = "claim-unsupported";
|
|
1468
|
+
list.append(item);
|
|
1469
|
+
}
|
|
1470
|
+
buckets.append(list);
|
|
1471
|
+
}
|
|
1041
1472
|
section.append(buckets);
|
|
1042
1473
|
const table = document.createElement("table");
|
|
1043
1474
|
table.dataset.claims = "rows";
|
|
@@ -1151,6 +1582,17 @@ const reportRowsModule = {
|
|
|
1151
1582
|
buildModel: async (context) => defined(await reportRowsOf(context), BUILTIN_MANIFEST_REPORT_ROWS.id),
|
|
1152
1583
|
render: (model, host) => renderReportRowsTable(model, host.L1),
|
|
1153
1584
|
};
|
|
1585
|
+
/**
|
|
1586
|
+
* The context's verification with AAC's strict result in its `strict`
|
|
1587
|
+
* member, where this runtime reached one: the contract report's "Witnessed
|
|
1588
|
+
* by" line reads AAC's witness status from it (report-provenance.ts), the
|
|
1589
|
+
* same result the banner reads.
|
|
1590
|
+
*/
|
|
1591
|
+
function withStrict(context) {
|
|
1592
|
+
return context.strict === undefined
|
|
1593
|
+
? context.verification
|
|
1594
|
+
: { ...context.verification, strict: context.strict };
|
|
1595
|
+
}
|
|
1154
1596
|
const resultOutcomeReportModule = {
|
|
1155
1597
|
manifest: BUILTIN_MANIFEST_RESULT_OUTCOME_REPORT,
|
|
1156
1598
|
canRender: async (context) => readOutcomeReportPresentation(context.bundle) !== undefined &&
|
|
@@ -1159,12 +1601,12 @@ const resultOutcomeReportModule = {
|
|
|
1159
1601
|
result: defined(await resultRootOf(context), BUILTIN_MANIFEST_RESULT_OUTCOME_REPORT.id),
|
|
1160
1602
|
card: defined(readOutcomeReportPresentation(context.bundle), BUILTIN_MANIFEST_RESULT_OUTCOME_REPORT.id),
|
|
1161
1603
|
bundle: context.bundle,
|
|
1162
|
-
verification: context
|
|
1604
|
+
verification: withStrict(context),
|
|
1163
1605
|
}),
|
|
1164
1606
|
render: async (model, host) => {
|
|
1165
1607
|
// The banner and the verification page take the card's look.
|
|
1166
1608
|
host.setChromeClass("oi");
|
|
1167
|
-
await
|
|
1609
|
+
await renderContractReport(model.result, { grouping: "lines", options: model.card }, model.bundle, model.verification, { L0: host.L0, L1: host.L1, L2: host.L2, depth: host.depth }, host.wording);
|
|
1168
1610
|
},
|
|
1169
1611
|
};
|
|
1170
1612
|
const resultComplianceModule = {
|
|
@@ -1175,9 +1617,130 @@ const resultComplianceModule = {
|
|
|
1175
1617
|
result: defined(await resultRootOf(context), BUILTIN_MANIFEST_RESULT_COMPLIANCE.id),
|
|
1176
1618
|
card: defined(readCompliancePresentation(context.bundle), BUILTIN_MANIFEST_RESULT_COMPLIANCE.id),
|
|
1177
1619
|
bundle: context.bundle,
|
|
1178
|
-
verification: context
|
|
1620
|
+
verification: withStrict(context),
|
|
1179
1621
|
}),
|
|
1180
|
-
render: (model, host) =>
|
|
1622
|
+
render: async (model, host) => {
|
|
1623
|
+
// The card draws its own frame inside the page.
|
|
1624
|
+
host.setChromeClass(COMPLIANCE_CHROME);
|
|
1625
|
+
await renderContractReport(model.result, { grouping: "groups", presentation: model.card }, model.bundle, model.verification, { L0: host.L0, L1: host.L1, L2: host.L2, depth: host.depth }, host.wording);
|
|
1626
|
+
},
|
|
1627
|
+
};
|
|
1628
|
+
/**
|
|
1629
|
+
* The contract-report module's manifest (agent-action-capsule
|
|
1630
|
+
* spec/contract-report-v1.md section 4): the same match as
|
|
1631
|
+
* `aac.builtin.result-contract-report/v0`, which it replaces in this
|
|
1632
|
+
* registry. Registering both would be an ambiguity error (presentation
|
|
1633
|
+
* contract section 4.5). It carries no `executable.wording_sha256`: the pack
|
|
1634
|
+
* is a builder input, recorded as provenance.
|
|
1635
|
+
*/
|
|
1636
|
+
export const CONTRACT_REPORT_MANIFEST = Object.freeze({
|
|
1637
|
+
...BUILTIN_MANIFEST_RESULT_CONTRACT_REPORT,
|
|
1638
|
+
id: "capsuleviewer.contract-report/v0",
|
|
1639
|
+
});
|
|
1640
|
+
/**
|
|
1641
|
+
* The data a contract report draws from, beside the empty
|
|
1642
|
+
* `contract-report/v1` block: an earlier kind's block, read by its own
|
|
1643
|
+
* reader (section 5), the outcome block first, as the built-in manifests'
|
|
1644
|
+
* precedence has it (the compliance card forbids `outcome-report/v1`).
|
|
1645
|
+
*/
|
|
1646
|
+
/** The grouping the contract-report module draws for `bundle`, or undefined when it draws the generic Result page. */
|
|
1647
|
+
export function contractReportGroupingOf(bundle) {
|
|
1648
|
+
return contractReportInput(bundle)?.grouping;
|
|
1649
|
+
}
|
|
1650
|
+
function contractReportInput(bundle) {
|
|
1651
|
+
const options = readOutcomeReportPresentation(bundle);
|
|
1652
|
+
if (options !== undefined)
|
|
1653
|
+
return { grouping: "lines", options };
|
|
1654
|
+
const presentation = readCompliancePresentation(bundle);
|
|
1655
|
+
if (presentation !== undefined)
|
|
1656
|
+
return { grouping: "groups", presentation };
|
|
1657
|
+
return undefined;
|
|
1658
|
+
}
|
|
1659
|
+
/**
|
|
1660
|
+
* The contract-report module (contract-report.ts), resolved on
|
|
1661
|
+
* `contract-report/v1`. `canRender` is the generic Result page's, whatever
|
|
1662
|
+
* the pack or the number of contracts (section 4), so every Result root that
|
|
1663
|
+
* opts in reaches it. A Result that carries neither grouping's data draws
|
|
1664
|
+
* the generic Result page, exactly as the built-in it replaces.
|
|
1665
|
+
*/
|
|
1666
|
+
/**
|
|
1667
|
+
* Whether every claim has a place of its own on the outcome or EU card. The
|
|
1668
|
+
* cards lay a Result out one conversation by one requirement, so they can
|
|
1669
|
+
* show a claim only when it is a requirement claim whose id names its
|
|
1670
|
+
* conversation (`<conversation>::…`), no two claims share a conversation
|
|
1671
|
+
* and a requirement (a re-judged requirement), and all cite one contract.
|
|
1672
|
+
* The EU card also needs a grouped requirement (`<group>.<test>`); the
|
|
1673
|
+
* Outcomes card needs one of the terms' check and criterion pairs
|
|
1674
|
+
* (`readOutcomeReportTerms`), since agent-action-capsule's outcome model
|
|
1675
|
+
* leaves out any other. Any other Result is drawn as the generic Result
|
|
1676
|
+
* page, which lists every claim: a card never merges a claim into another
|
|
1677
|
+
* or leaves one out (contract-report/v1 section 2).
|
|
1678
|
+
*/
|
|
1679
|
+
function claimsFitCard(result, grouping) {
|
|
1680
|
+
if (new Set(result.claims.map((c) => c.contractRef)).size > 1)
|
|
1681
|
+
return false;
|
|
1682
|
+
const placed = grouping === "lines"
|
|
1683
|
+
? new Set(readOutcomeReportTerms(result).checks.flatMap((check) => check.criteria.map((criterion) => `${check.id}.${criterion.id}`)))
|
|
1684
|
+
: undefined;
|
|
1685
|
+
const seen = new Set();
|
|
1686
|
+
for (const claim of result.claims) {
|
|
1687
|
+
if (claim.type !== REQUIREMENT_CLAIM)
|
|
1688
|
+
return false;
|
|
1689
|
+
const sep = claim.id.indexOf("::");
|
|
1690
|
+
if (sep <= 0)
|
|
1691
|
+
return false;
|
|
1692
|
+
if (placed !== undefined && !placed.has(claim.requirementRef))
|
|
1693
|
+
return false;
|
|
1694
|
+
if (grouping === "groups") {
|
|
1695
|
+
const dot = claim.requirementRef.indexOf(".");
|
|
1696
|
+
if (dot <= 0 || dot === claim.requirementRef.length - 1)
|
|
1697
|
+
return false;
|
|
1698
|
+
}
|
|
1699
|
+
const key = JSON.stringify([claim.id.slice(0, sep), claim.requirementRef]);
|
|
1700
|
+
if (seen.has(key))
|
|
1701
|
+
return false;
|
|
1702
|
+
seen.add(key);
|
|
1703
|
+
}
|
|
1704
|
+
return true;
|
|
1705
|
+
}
|
|
1706
|
+
/** Which interpreters a contract-report render ran, by the bundle it drew: set when its model is built. */
|
|
1707
|
+
const contractReportDrawn = new WeakMap();
|
|
1708
|
+
const contractReportModule = {
|
|
1709
|
+
manifest: CONTRACT_REPORT_MANIFEST,
|
|
1710
|
+
canRender: (context) => isResultRoot(context),
|
|
1711
|
+
buildModel: async (context) => {
|
|
1712
|
+
const result = defined(await resultRootOf(context), CONTRACT_REPORT_MANIFEST.id);
|
|
1713
|
+
const supported = contractReportInput(context.bundle);
|
|
1714
|
+
const input = supported !== undefined && claimsFitCard(result, supported.grouping)
|
|
1715
|
+
? supported
|
|
1716
|
+
: undefined;
|
|
1717
|
+
if (typeof context.bundle === "object" && context.bundle !== null)
|
|
1718
|
+
contractReportDrawn.set(context.bundle, input ?? null);
|
|
1719
|
+
return {
|
|
1720
|
+
result,
|
|
1721
|
+
...(input === undefined ? {} : { input }),
|
|
1722
|
+
...(supported !== undefined && input === undefined
|
|
1723
|
+
? { unfit: true }
|
|
1724
|
+
: {}),
|
|
1725
|
+
bundle: context.bundle,
|
|
1726
|
+
verification: withStrict(context),
|
|
1727
|
+
};
|
|
1728
|
+
},
|
|
1729
|
+
render: async (model, host) => {
|
|
1730
|
+
if (model.input === undefined) {
|
|
1731
|
+
if (model.unfit === true) {
|
|
1732
|
+
const note = element("p", CARD_UNFIT_NOTE);
|
|
1733
|
+
note.dataset.notice = "card-unfit";
|
|
1734
|
+
host.L1.append(note);
|
|
1735
|
+
}
|
|
1736
|
+
renderResultPage(model.result, host.L1);
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
// The report's banner takes its frame's look (a callout at the top);
|
|
1740
|
+
// the outcome report's verification page takes its look too.
|
|
1741
|
+
host.setChromeClass(model.input.grouping === "lines" ? OUTCOME_CHROME : COMPLIANCE_CHROME);
|
|
1742
|
+
await renderContractReport(model.result, model.input, model.bundle, model.verification, { L0: host.L0, L1: host.L1, L2: host.L2, depth: host.depth }, host.wording);
|
|
1743
|
+
},
|
|
1181
1744
|
};
|
|
1182
1745
|
const resultModule = {
|
|
1183
1746
|
manifest: BUILTIN_MANIFEST_RESULT,
|
|
@@ -1224,16 +1787,46 @@ const BUILTIN_MODULE_INTERPRETERS = Object.freeze({
|
|
|
1224
1787
|
[BUILTIN_MANIFEST_RESULT.id]: ["result-root"],
|
|
1225
1788
|
[BUILTIN_MANIFEST_COMPOSED.id]: ["aac.builtin.composed/v0"],
|
|
1226
1789
|
});
|
|
1227
|
-
/**
|
|
1790
|
+
/**
|
|
1791
|
+
* The extension interpreters a module ran on `bundle`. The contract-report
|
|
1792
|
+
* module applies the `contract-report/v1` block it resolved on
|
|
1793
|
+
* (contract-report/v1 section 4) and runs the Result reader, plus the one
|
|
1794
|
+
* earlier kind's reader whose data it drew (contractReportInput), never both:
|
|
1795
|
+
* until their removal, earlier blocks are read by their own readers (section 5).
|
|
1796
|
+
*/
|
|
1797
|
+
function moduleInterpreters(id, bundle) {
|
|
1798
|
+
if (id === CONTRACT_REPORT_MANIFEST.id) {
|
|
1799
|
+
const drawn = typeof bundle === "object" && bundle !== null
|
|
1800
|
+
? contractReportDrawn.get(bundle)
|
|
1801
|
+
: undefined;
|
|
1802
|
+
const input = drawn === undefined ? contractReportInput(bundle) : (drawn ?? undefined);
|
|
1803
|
+
return input === undefined
|
|
1804
|
+
? ["contract-report", "result-root"]
|
|
1805
|
+
: [
|
|
1806
|
+
"contract-report",
|
|
1807
|
+
"result-root",
|
|
1808
|
+
input.grouping === "lines"
|
|
1809
|
+
? "outcome-report-card"
|
|
1810
|
+
: "compliance-card",
|
|
1811
|
+
];
|
|
1812
|
+
}
|
|
1813
|
+
return BUILTIN_MODULE_INTERPRETERS[id] ?? [];
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* The seven built-in modules, registered by default: agent-action-capsule's
|
|
1817
|
+
* seven built-in shapes, with the contract-report module in place of
|
|
1818
|
+
* `aac.builtin.result-contract-report/v0` (contract-report/v1 section 4).
|
|
1819
|
+
*/
|
|
1228
1820
|
export const BUILTIN_PRESENTATIONS = Object.freeze([
|
|
1229
1821
|
reportRowsModule,
|
|
1822
|
+
contractReportModule,
|
|
1230
1823
|
resultOutcomeReportModule,
|
|
1231
1824
|
resultComplianceModule,
|
|
1232
1825
|
resultModule,
|
|
1233
1826
|
evaluationSummaryGraphModule,
|
|
1234
1827
|
noAggregateModule,
|
|
1235
1828
|
]);
|
|
1236
|
-
/** A fresh registry holding the
|
|
1829
|
+
/** A fresh registry holding the seven built-in modules. */
|
|
1237
1830
|
export function createPresentationRegistry() {
|
|
1238
1831
|
const registry = new PresentationRegistry();
|
|
1239
1832
|
for (const module of BUILTIN_PRESENTATIONS)
|
|
@@ -1280,6 +1873,55 @@ export function resolvePresentation(context, audience = DEFAULT_AUDIENCE, format
|
|
|
1280
1873
|
/** `"*"`: no particular audience, so only modules serving every audience. */
|
|
1281
1874
|
const DEFAULT_AUDIENCE = "*";
|
|
1282
1875
|
const DEFAULT_FORMAT = "html";
|
|
1876
|
+
async function chartDigestsOf(charts) {
|
|
1877
|
+
const out = [];
|
|
1878
|
+
for (const spec of charts ?? []) {
|
|
1879
|
+
try {
|
|
1880
|
+
out.push({ sha256: await jsonDigest(spec) });
|
|
1881
|
+
}
|
|
1882
|
+
catch (err) {
|
|
1883
|
+
// A number JCS has no form for: the checker refuses that spec, and the
|
|
1884
|
+
// page goes on with the rest.
|
|
1885
|
+
if (!(err instanceof JcsFloatError || err instanceof JcsUnsafeIntegerError))
|
|
1886
|
+
throw err;
|
|
1887
|
+
out.push({ sha256: "uncomputable" });
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
return out;
|
|
1891
|
+
}
|
|
1892
|
+
/**
|
|
1893
|
+
* Check every chart against the Result's dataset and draw it, or the core's
|
|
1894
|
+
* notice for a chart that fails (chart-spec.ts). The page runtime checks
|
|
1895
|
+
* again here even when the builder already did: a page that reaches a reader
|
|
1896
|
+
* with a mismatch never shows the chart.
|
|
1897
|
+
*/
|
|
1898
|
+
async function drawCharts(context, result, charts, digests, words) {
|
|
1899
|
+
let dataset;
|
|
1900
|
+
let invalid;
|
|
1901
|
+
try {
|
|
1902
|
+
dataset =
|
|
1903
|
+
result === undefined ? undefined : await chartDatasetOf(context, result);
|
|
1904
|
+
}
|
|
1905
|
+
catch (err) {
|
|
1906
|
+
if (!(err instanceof ChartRefusal))
|
|
1907
|
+
throw err;
|
|
1908
|
+
invalid = err;
|
|
1909
|
+
}
|
|
1910
|
+
const parts = charts.map((spec, i) => {
|
|
1911
|
+
try {
|
|
1912
|
+
if (invalid !== undefined)
|
|
1913
|
+
throw invalid;
|
|
1914
|
+
return renderChart(checkChart(spec, dataset), i, digests[i].sha256, words);
|
|
1915
|
+
}
|
|
1916
|
+
catch (err) {
|
|
1917
|
+
if (!(err instanceof ChartRefusal))
|
|
1918
|
+
throw err;
|
|
1919
|
+
digests[i].refused = err.reason;
|
|
1920
|
+
return renderChartRefused(i, err.reason, words);
|
|
1921
|
+
}
|
|
1922
|
+
});
|
|
1923
|
+
return renderCharts(parts);
|
|
1924
|
+
}
|
|
1283
1925
|
/**
|
|
1284
1926
|
* True when the rendered page module checked the producer signature of the
|
|
1285
1927
|
* records it cites as signers: the built-in Result page, on a Close (or a
|
|
@@ -1293,6 +1935,7 @@ function citesCheckedSigners(selected) {
|
|
|
1293
1935
|
[...claim.close.links, ...claim.close.ignored].some((link) => link.keyId !== undefined)));
|
|
1294
1936
|
}
|
|
1295
1937
|
const OUTCOME_CHROME = "oi";
|
|
1938
|
+
const COMPLIANCE_CHROME = "cc";
|
|
1296
1939
|
function presentationServices(context) {
|
|
1297
1940
|
return Object.freeze({
|
|
1298
1941
|
details(summary, open = false) {
|
|
@@ -1327,15 +1970,352 @@ export async function renderEvidenceGraph(input, root, countersigners, options =
|
|
|
1327
1970
|
: { verifyCommand: options.verifyCommand });
|
|
1328
1971
|
return;
|
|
1329
1972
|
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
const context = isVerifiedBundleContext(input)
|
|
1333
|
-
? countersigners === undefined
|
|
1973
|
+
if (isVerifiedBundleContext(input))
|
|
1974
|
+
return renderVerifiedContext(countersigners === undefined
|
|
1334
1975
|
? input
|
|
1335
|
-
: withCountersigners(input, countersigners)
|
|
1336
|
-
|
|
1976
|
+
: withCountersigners(input, countersigners), root, options);
|
|
1977
|
+
// Verify first. Until the verification result is in hand the page shows
|
|
1978
|
+
// `checking` and nothing else, and no module is consulted for a bundle
|
|
1979
|
+
// that did not verify. A render that rejects while its own `checking` is
|
|
1980
|
+
// still shown puts back what `root` held before the first of the renders
|
|
1981
|
+
// still checking on it began, so it still draws nothing. When another
|
|
1982
|
+
// render on the same root is still checking, its `checking` is put back
|
|
1983
|
+
// instead; another render's `checking` that has ended never is.
|
|
1984
|
+
const group = checkingRenders.get(root) ?? {
|
|
1985
|
+
before: [...root.childNodes],
|
|
1986
|
+
active: new Set(),
|
|
1987
|
+
};
|
|
1988
|
+
checkingRenders.set(root, group);
|
|
1989
|
+
const { active } = group;
|
|
1990
|
+
const checking = renderChecking(root);
|
|
1991
|
+
active.add(checking);
|
|
1992
|
+
try {
|
|
1993
|
+
await renderVerifiedContext(await buildVerifiedBundleContext(input, {
|
|
1337
1994
|
...(countersigners === undefined ? {} : { countersigners }),
|
|
1338
|
-
});
|
|
1995
|
+
}), root, options);
|
|
1996
|
+
}
|
|
1997
|
+
catch (err) {
|
|
1998
|
+
if (checking.parentNode === root) {
|
|
1999
|
+
const other = [...active].find((node) => node !== checking);
|
|
2000
|
+
if (other !== undefined)
|
|
2001
|
+
root.replaceChildren(other);
|
|
2002
|
+
else
|
|
2003
|
+
root.replaceChildren(...group.before);
|
|
2004
|
+
}
|
|
2005
|
+
throw err;
|
|
2006
|
+
}
|
|
2007
|
+
finally {
|
|
2008
|
+
active.delete(checking);
|
|
2009
|
+
if (active.size === 0)
|
|
2010
|
+
checkingRenders.delete(root);
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
// The side margins are not in FRAME_LOOK: the shell centres the page root and
|
|
2014
|
+
// the bar with `auto` margins, and a computed `auto` margin is its used
|
|
2015
|
+
// width, which moves by half a classic scrollbar when a module's content
|
|
2016
|
+
// makes the page scroll. They are compared to within SIDE_MARGIN_SLACK
|
|
2017
|
+
// instead, a constant no module's stylesheet can change: a module that moves
|
|
2018
|
+
// the banner by more is still caught. It assumes a classic scrollbar of up to
|
|
2019
|
+
// 18 CSS px (a native 17px at zoom 100%); at a very low page zoom the
|
|
2020
|
+
// scrollbar is wider in CSS px, and an honest module that makes the page
|
|
2021
|
+
// scroll is then discarded, which fails closed.
|
|
2022
|
+
const SIDE_MARGINS = ["margin-left", "margin-right"];
|
|
2023
|
+
const SIDE_MARGIN_SLACK = 9;
|
|
2024
|
+
// The paddings and border widths: a module that widens them pushes the words
|
|
2025
|
+
// inside out of view.
|
|
2026
|
+
const BOX_EDGES = ["top", "right", "bottom", "left"].flatMap((side) => [
|
|
2027
|
+
`padding-${side}`,
|
|
2028
|
+
`border-${side}-width`,
|
|
2029
|
+
]);
|
|
2030
|
+
// On the root's ancestors, which in the embedded format are the host page's
|
|
2031
|
+
// own elements, the offsets, paddings, border widths and a transform's
|
|
2032
|
+
// translation are compared to within the same slack: a host that places its
|
|
2033
|
+
// widget with `left: 50%`, `translateX(-50%)` or a percentage margin or
|
|
2034
|
+
// padding resolves them to used px that move with the scrollbar too. A
|
|
2035
|
+
// positioned element's `top` and `left` resolve to where it is, whichever of
|
|
2036
|
+
// its offsets set that, so they stand for `right` and `bottom`, whose used px
|
|
2037
|
+
// follow the height of the module's content and are not compared. A module can
|
|
2038
|
+
// therefore still shift the banner by up to SIDE_MARGIN_SLACK per offset of
|
|
2039
|
+
// each ancestor; `position` and a transform that was `none` are compared
|
|
2040
|
+
// exactly. Those shifts add up, so where the bar sits in the document is
|
|
2041
|
+
// bounded too: it may not rise by more than SIDE_MARGIN_SLACK, nor move
|
|
2042
|
+
// sideways by more than one assumed classic scrollbar, twice
|
|
2043
|
+
// SIDE_MARGIN_SLACK (a widget a host floats right moves by all of it).
|
|
2044
|
+
// Downward is left to the per-ancestor caps, since a scrollbar only narrows
|
|
2045
|
+
// the page and so pushes reflowing host content above the widget down; the
|
|
2046
|
+
// caps keep a module from pushing the banner off the first screen, under
|
|
2047
|
+
// fixed content of its own, through an ancestor. A host that centres a
|
|
2048
|
+
// growing widget vertically lifts the banner by itself; an honest module there
|
|
2049
|
+
// is discarded, which fails closed.
|
|
2050
|
+
const ANCESTOR_OFFSETS = [
|
|
2051
|
+
"top",
|
|
2052
|
+
"left",
|
|
2053
|
+
"margin-top",
|
|
2054
|
+
"margin-bottom",
|
|
2055
|
+
...BOX_EDGES,
|
|
2056
|
+
];
|
|
2057
|
+
const ANCESTOR_UNCOMPARED = ["right", "bottom"];
|
|
2058
|
+
// `a` is the frame now, `b` as it was before the module rendered. Words a
|
|
2059
|
+
// reader sees where the page is now must not be covered or clipped (see
|
|
2060
|
+
// readable), unless they already were before the module rendered: a host
|
|
2061
|
+
// that covered or clipped the widget itself is no module's doing.
|
|
2062
|
+
const sameLook = (a, b) => a.look === b.look &&
|
|
2063
|
+
(a.readable !== "no" || b.readable === "no") &&
|
|
2064
|
+
a.clips.length === b.clips.length &&
|
|
2065
|
+
a.clips.every((box, i) => box.width >= b.clips[i].width - 2 * SIDE_MARGIN_SLACK &&
|
|
2066
|
+
box.height >=
|
|
2067
|
+
b.clips[i].height - Math.max(0, box.bar - b.clips[i].bar) - 1) &&
|
|
2068
|
+
Math.abs(a.place[0] - b.place[0]) <= 2 * SIDE_MARGIN_SLACK &&
|
|
2069
|
+
Math.abs(a.below - b.below) <= SIDE_MARGIN_SLACK &&
|
|
2070
|
+
a.place[1] - b.place[1] >= -SIDE_MARGIN_SLACK &&
|
|
2071
|
+
a.offsets.length === b.offsets.length &&
|
|
2072
|
+
a.offsets.every((m, i) => Math.abs(m - b.offsets[i]) <= SIDE_MARGIN_SLACK);
|
|
2073
|
+
// The computed properties of the banner frame a module's stylesheet must not
|
|
2074
|
+
// change (see looks in renderVerifiedContext): what decides whether the
|
|
2075
|
+
// banner and its details line are shown, where, and whether their words can
|
|
2076
|
+
// be read. Layout sizes are left out, since a module's content can change
|
|
2077
|
+
// them without touching the frame.
|
|
2078
|
+
const FRAME_LOOK = [
|
|
2079
|
+
"display",
|
|
2080
|
+
"visibility",
|
|
2081
|
+
"opacity",
|
|
2082
|
+
"color",
|
|
2083
|
+
"background-color",
|
|
2084
|
+
"background-image",
|
|
2085
|
+
"font-size",
|
|
2086
|
+
"text-indent",
|
|
2087
|
+
"position",
|
|
2088
|
+
"top",
|
|
2089
|
+
"left",
|
|
2090
|
+
"right",
|
|
2091
|
+
"bottom",
|
|
2092
|
+
"transform",
|
|
2093
|
+
"scale",
|
|
2094
|
+
"translate",
|
|
2095
|
+
"rotate",
|
|
2096
|
+
"zoom",
|
|
2097
|
+
"margin-top",
|
|
2098
|
+
"margin-bottom",
|
|
2099
|
+
...BOX_EDGES,
|
|
2100
|
+
"font-family",
|
|
2101
|
+
"-webkit-text-fill-color",
|
|
2102
|
+
"clip",
|
|
2103
|
+
"clip-path",
|
|
2104
|
+
"mask-image",
|
|
2105
|
+
"-webkit-mask-image",
|
|
2106
|
+
"filter",
|
|
2107
|
+
"mix-blend-mode",
|
|
2108
|
+
"overflow",
|
|
2109
|
+
"max-height",
|
|
2110
|
+
"max-width",
|
|
2111
|
+
"z-index",
|
|
2112
|
+
"content-visibility",
|
|
2113
|
+
"contain",
|
|
2114
|
+
];
|
|
2115
|
+
const ANCESTOR_LOOK = FRAME_LOOK.filter((name) => name !== "transform" &&
|
|
2116
|
+
!ANCESTOR_OFFSETS.includes(name) &&
|
|
2117
|
+
!ANCESTOR_UNCOMPARED.includes(name));
|
|
2118
|
+
// A computed transform split into its linear part, compared exactly, and its
|
|
2119
|
+
// translation in px, compared within the slack. Anything else (`none`) is
|
|
2120
|
+
// compared whole.
|
|
2121
|
+
function splitTransform(value) {
|
|
2122
|
+
const m = /^matrix(3d)?\((.*)\)$/.exec(value);
|
|
2123
|
+
if (m === null)
|
|
2124
|
+
return [value, []];
|
|
2125
|
+
const n = m[2].split(",").map(Number);
|
|
2126
|
+
const moves = m[1] === undefined ? [4, 5] : [12, 13, 14];
|
|
2127
|
+
return [
|
|
2128
|
+
`matrix${m[1] ?? ""}(${n.filter((_, i) => !moves.includes(i)).join(",")})`,
|
|
2129
|
+
moves.map((i) => n[i]),
|
|
2130
|
+
];
|
|
2131
|
+
}
|
|
2132
|
+
// Whether a reader sees every word of each part where the page is now: for
|
|
2133
|
+
// each character other than white space whose box is in the viewport, the
|
|
2134
|
+
// elements a hit test finds at the box's centre (`elementsFromPoint`) reach
|
|
2135
|
+
// the character's own element before anything of the root's or in <head>
|
|
2136
|
+
// that paints over it (see seeThrough): a module's content, or a module's
|
|
2137
|
+
// rule laying out <head> or <style>. Nothing is scrolled to look. A
|
|
2138
|
+
// character clipped where the page is now (a hit on an element around it
|
|
2139
|
+
// first) is passed over: a reader may have scrolled it out of a scrolling
|
|
2140
|
+
// host, and a module that shrinks a clipping box is caught by its size (see
|
|
2141
|
+
// clips in looks). The host's other elements are passed over too, so a
|
|
2142
|
+
// host's own fixed header a reader scrolls under is no module's doing. A set
|
|
2143
|
+
// of parts none of whose words is seen is "unseen", as is any off a
|
|
2144
|
+
// laid-out document (jsdom). For the test's duration a
|
|
2145
|
+
// constructed stylesheet in a layer, which adds no element a module's rule
|
|
2146
|
+
// could show, makes everything hit-testable, so an overlay with
|
|
2147
|
+
// `pointer-events: none` is still found, even with an unlayered `!important`;
|
|
2148
|
+
// one set important inline, or in the module's own layer, is not. Paint the
|
|
2149
|
+
// browser does not hit-test (an outline, a shadow, a reflection) is not
|
|
2150
|
+
// found either; see #125 for why this check targets a module's mistakes and
|
|
2151
|
+
// not a module that sets out to hide the banner.
|
|
2152
|
+
function readable(parts, root) {
|
|
2153
|
+
const doc = root.ownerDocument;
|
|
2154
|
+
const view = doc.defaultView;
|
|
2155
|
+
if (view === null || view.navigator.userAgent.includes("jsdom"))
|
|
2156
|
+
return "unseen";
|
|
2157
|
+
const tree = root.getRootNode();
|
|
2158
|
+
const scope = tree === doc ? [doc] : [doc, tree];
|
|
2159
|
+
const sheet = new view.CSSStyleSheet();
|
|
2160
|
+
sheet.replaceSync("@layer cv-hit-test{*,*::before,*::after{pointer-events:auto!important}}");
|
|
2161
|
+
for (const at of scope)
|
|
2162
|
+
at.adoptedStyleSheets = [...at.adoptedStyleSheets, sheet];
|
|
2163
|
+
// The viewport less its scrollbars: a point under a scrollbar hits nothing.
|
|
2164
|
+
const port = doc.scrollingElement ?? doc.documentElement;
|
|
2165
|
+
const [width, height] = [port.clientWidth, port.clientHeight];
|
|
2166
|
+
const range = doc.createRange();
|
|
2167
|
+
let seen = 0;
|
|
2168
|
+
try {
|
|
2169
|
+
for (const part of parts) {
|
|
2170
|
+
const text = doc.createTreeWalker(part, view.NodeFilter.SHOW_TEXT);
|
|
2171
|
+
for (let node = text.nextNode(); node !== null; node = text.nextNode()) {
|
|
2172
|
+
const own = node.parentElement;
|
|
2173
|
+
let i = 0;
|
|
2174
|
+
for (const char of node.textContent ?? "") {
|
|
2175
|
+
range.setStart(node, i);
|
|
2176
|
+
i += char.length;
|
|
2177
|
+
range.setEnd(node, i);
|
|
2178
|
+
if (/\s/.test(char))
|
|
2179
|
+
continue;
|
|
2180
|
+
for (const box of range.getClientRects()) {
|
|
2181
|
+
const x = box.left + box.width / 2;
|
|
2182
|
+
const y = box.top + box.height / 2;
|
|
2183
|
+
if (box.width <= 0 || box.height <= 0)
|
|
2184
|
+
continue;
|
|
2185
|
+
if (x < 0 || y < 0 || x >= width || y >= height)
|
|
2186
|
+
continue;
|
|
2187
|
+
let shown = false;
|
|
2188
|
+
for (const hit of tree.elementsFromPoint(x, y)) {
|
|
2189
|
+
if (own.contains(hit)) {
|
|
2190
|
+
shown = true;
|
|
2191
|
+
break;
|
|
2192
|
+
}
|
|
2193
|
+
// Clipped where it is now, by the host or inside the banner:
|
|
2194
|
+
// see clips in looks.
|
|
2195
|
+
if (hit.contains(own))
|
|
2196
|
+
break;
|
|
2197
|
+
if ((root.contains(hit) || doc.head?.contains(hit) === true) &&
|
|
2198
|
+
!seeThrough(hit, view))
|
|
2199
|
+
return "no";
|
|
2200
|
+
}
|
|
2201
|
+
if (shown)
|
|
2202
|
+
seen++;
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
finally {
|
|
2209
|
+
for (const at of scope)
|
|
2210
|
+
at.adoptedStyleSheets = at.adoptedStyleSheets.filter((other) => other !== sheet);
|
|
2211
|
+
}
|
|
2212
|
+
return seen > 0 ? "yes" : "unseen";
|
|
2213
|
+
}
|
|
2214
|
+
// Whether a hit-tested element paints nothing of its own over what is under
|
|
2215
|
+
// it: it is transparent (opacity 0, on it or an ancestor), or it has no
|
|
2216
|
+
// background, border, shadow, backdrop filter, text of its own or generated
|
|
2217
|
+
// content and is not replaced content, like a module's empty full-page
|
|
2218
|
+
// container for toasts. A child that does paint is hit-tested on its own.
|
|
2219
|
+
function seeThrough(element, view) {
|
|
2220
|
+
for (let at = element; at !== null; at = at.parentElement)
|
|
2221
|
+
if (view.getComputedStyle(at).opacity === "0")
|
|
2222
|
+
return true;
|
|
2223
|
+
const style = view.getComputedStyle(element);
|
|
2224
|
+
const clear = (color) => color === "transparent" || /^rgba\(.*,\s*0\)$/.test(color);
|
|
2225
|
+
return (clear(style.backgroundColor) &&
|
|
2226
|
+
style.backgroundImage === "none" &&
|
|
2227
|
+
style.boxShadow === "none" &&
|
|
2228
|
+
style.backdropFilter === "none" &&
|
|
2229
|
+
["top", "right", "bottom", "left"].every((side) => style.getPropertyValue(`border-${side}-width`) === "0px") &&
|
|
2230
|
+
!REPLACED.has(element.localName) &&
|
|
2231
|
+
![...element.childNodes].some((child) => child.nodeType === 3 && (child.textContent ?? "").trim() !== "") &&
|
|
2232
|
+
["::before", "::after"].every((pseudo) => ["none", "normal"].includes(view.getComputedStyle(element, pseudo).content)));
|
|
2233
|
+
}
|
|
2234
|
+
const REPLACED = new Set([
|
|
2235
|
+
"img",
|
|
2236
|
+
"video",
|
|
2237
|
+
"canvas",
|
|
2238
|
+
"iframe",
|
|
2239
|
+
"object",
|
|
2240
|
+
"embed",
|
|
2241
|
+
"svg",
|
|
2242
|
+
"input",
|
|
2243
|
+
"textarea",
|
|
2244
|
+
"select",
|
|
2245
|
+
"button",
|
|
2246
|
+
"meter",
|
|
2247
|
+
"progress",
|
|
2248
|
+
]);
|
|
2249
|
+
// The linear part of the transforms applied to `element`'s content in the
|
|
2250
|
+
// viewport: its own and every ancestor's `transform`, `rotate`, `scale` and
|
|
2251
|
+
// `zoom`. A scroll offset is in its container's own px; this maps it into the
|
|
2252
|
+
// viewport px the bar's box is in. Every one of these properties is compared
|
|
2253
|
+
// exactly on the root's ancestors (see looks), so no module can change it.
|
|
2254
|
+
function linearTransform(element, view) {
|
|
2255
|
+
let matrix = new DOMMatrix();
|
|
2256
|
+
for (let at = element; at !== null; at = at.parentElement) {
|
|
2257
|
+
const style = view.getComputedStyle(at);
|
|
2258
|
+
const zoom = Number.parseFloat(style.zoom) || 1;
|
|
2259
|
+
const rotate = style.rotate === "none" ? "" : rotateFunction(style.rotate);
|
|
2260
|
+
const scale = style.scale === "none" ? "" : `scale3d(${scaleArgs(style.scale)})`;
|
|
2261
|
+
const transform = style.transform === "none" ? "" : style.transform;
|
|
2262
|
+
const local = new DOMMatrix(`${rotate} ${scale} ${transform}`.trim() || "none").scale(zoom, zoom);
|
|
2263
|
+
local.m41 = local.m42 = local.m43 = 0;
|
|
2264
|
+
matrix = local.multiply(matrix);
|
|
2265
|
+
}
|
|
2266
|
+
return matrix;
|
|
2267
|
+
}
|
|
2268
|
+
function rotateFunction(value) {
|
|
2269
|
+
const parts = value.split(/\s+/);
|
|
2270
|
+
if (parts.length === 1)
|
|
2271
|
+
return `rotate(${value})`;
|
|
2272
|
+
const angle = parts.pop();
|
|
2273
|
+
const axis = parts.length === 1
|
|
2274
|
+
? ({ x: "1 0 0", y: "0 1 0", z: "0 0 1" }[parts[0]] ?? parts[0])
|
|
2275
|
+
: parts.join(" ");
|
|
2276
|
+
return `rotate3d(${axis.split(" ").join(",")},${angle})`;
|
|
2277
|
+
}
|
|
2278
|
+
function scaleArgs(value) {
|
|
2279
|
+
const [x, y = x, z = "1"] = value.split(/\s+/);
|
|
2280
|
+
return `${x},${y},${z}`;
|
|
2281
|
+
}
|
|
2282
|
+
// Whether a box is the containing block of a `position: fixed` box inside
|
|
2283
|
+
// it, in place of the viewport.
|
|
2284
|
+
function holdsFixed(style) {
|
|
2285
|
+
return (style.transform !== "none" ||
|
|
2286
|
+
style.translate !== "none" ||
|
|
2287
|
+
style.rotate !== "none" ||
|
|
2288
|
+
style.scale !== "none" ||
|
|
2289
|
+
style.perspective !== "none" ||
|
|
2290
|
+
style.filter !== "none" ||
|
|
2291
|
+
style.backdropFilter !== "none" ||
|
|
2292
|
+
/paint|layout|strict|content/.test(style.contain) ||
|
|
2293
|
+
/transform|perspective|filter/.test(style.willChange) ||
|
|
2294
|
+
style.containerType !== "normal" ||
|
|
2295
|
+
style.contentVisibility === "auto");
|
|
2296
|
+
}
|
|
2297
|
+
// Resolves after the next frame and then the timers already due. A page
|
|
2298
|
+
// that is not shown draws no frames, so a timer stands in for the frame
|
|
2299
|
+
// there.
|
|
2300
|
+
function settled(view) {
|
|
2301
|
+
return new Promise((done) => {
|
|
2302
|
+
let waiting = true;
|
|
2303
|
+
const next = () => {
|
|
2304
|
+
if (!waiting)
|
|
2305
|
+
return;
|
|
2306
|
+
waiting = false;
|
|
2307
|
+
view.setTimeout(done, 0);
|
|
2308
|
+
};
|
|
2309
|
+
view.requestAnimationFrame(next);
|
|
2310
|
+
view.setTimeout(next, SETTLE_MS);
|
|
2311
|
+
});
|
|
2312
|
+
}
|
|
2313
|
+
// The longest the settle waits for a frame.
|
|
2314
|
+
const SETTLE_MS = 100;
|
|
2315
|
+
// By root, the renders still verifying on it: their `checking` bars, and
|
|
2316
|
+
// what the root held before the first of them began.
|
|
2317
|
+
const checkingRenders = new WeakMap();
|
|
2318
|
+
async function renderVerifiedContext(context, root, options) {
|
|
1339
2319
|
const { bundle, verification } = context;
|
|
1340
2320
|
const verified = bundleVerified(verification);
|
|
1341
2321
|
const registry = options.registry ?? defaultRegistry;
|
|
@@ -1393,17 +2373,318 @@ export async function renderEvidenceGraph(input, root, countersigners, options =
|
|
|
1393
2373
|
model: await sectionResolution.module.buildModel(context),
|
|
1394
2374
|
};
|
|
1395
2375
|
}
|
|
2376
|
+
const stamps = await classifyCountersignatures(context.countersignatures.map((entry) => entry.value), verification.bundleDigest, declaredProducerKeys(bundle), context.countersigners);
|
|
2377
|
+
const bannerModel = verificationBanner(context, stamps);
|
|
1396
2378
|
const records = object(bundle).records;
|
|
1397
2379
|
const coverage = {
|
|
1398
|
-
uncheckpointed:
|
|
2380
|
+
uncheckpointed: bannerModel.uncheckpointed,
|
|
1399
2381
|
total: Array.isArray(records) ? records.length : 0,
|
|
1400
2382
|
};
|
|
2383
|
+
// The core's strip opens L0 on a verified bundle whose root is an
|
|
2384
|
+
// Evidence Result (core-strip.ts; presentation contract section 9.1). Its
|
|
2385
|
+
// words are the contract report's, in the grouping the module draws and
|
|
2386
|
+
// the page's wording pack; a page with no Result draws no strip.
|
|
2387
|
+
let strip;
|
|
2388
|
+
let chartsNode;
|
|
2389
|
+
const chartDigests = await chartDigestsOf(options.charts);
|
|
2390
|
+
const charted = options.charts !== undefined && options.charts.length > 0;
|
|
2391
|
+
if (verified) {
|
|
2392
|
+
const result = await resultRootOf(context);
|
|
2393
|
+
const grouping = contractReportGroupingOf(bundle) ?? "lines";
|
|
2394
|
+
const words = result === undefined && !charted
|
|
2395
|
+
? undefined
|
|
2396
|
+
: await contractReportWords(grouping, options.wording, {
|
|
2397
|
+
singleContract: result !== undefined && citesOneContract(result),
|
|
2398
|
+
});
|
|
2399
|
+
if (result !== undefined)
|
|
2400
|
+
strip = await coreStripModel(result, words);
|
|
2401
|
+
// With no Result there is no dataset: each chart shows its notice
|
|
2402
|
+
// (chart-no-dataset), never nothing.
|
|
2403
|
+
if (charted)
|
|
2404
|
+
chartsNode = await drawCharts(context, result, options.charts, chartDigests, words);
|
|
2405
|
+
}
|
|
2406
|
+
else
|
|
2407
|
+
// A failed bundle has no L1 (contract I1); the verification page says
|
|
2408
|
+
// why no chart was drawn.
|
|
2409
|
+
for (const digest of chartDigests)
|
|
2410
|
+
digest.refused = "the bundle did not verify";
|
|
2411
|
+
// The host's three regions, in order after the banner and the header
|
|
2412
|
+
// (presentation contract section 9.1). L2 opens with the core's
|
|
2413
|
+
// verification section, drawn last but placed first; a module's L2 detail
|
|
2414
|
+
// follows it.
|
|
2415
|
+
const depth = options.depth ?? "L0";
|
|
2416
|
+
const region = (name) => {
|
|
2417
|
+
const node = document.createElement("div");
|
|
2418
|
+
node.dataset.region = name;
|
|
2419
|
+
return node;
|
|
2420
|
+
};
|
|
2421
|
+
let regions = {
|
|
2422
|
+
L0: root,
|
|
2423
|
+
L1: root,
|
|
2424
|
+
L2: root,
|
|
2425
|
+
core: root,
|
|
2426
|
+
};
|
|
2427
|
+
let bar;
|
|
2428
|
+
let stripNode;
|
|
1401
2429
|
const drawFrame = () => {
|
|
1402
2430
|
root.replaceChildren();
|
|
2431
|
+
root.classList.remove("cv-shell-chrome");
|
|
1403
2432
|
renderPresentationHeader(root, bundle);
|
|
1404
|
-
|
|
2433
|
+
bar = renderVerificationBanner(root, bannerModel, coverage);
|
|
2434
|
+
const L2 = region("L2");
|
|
2435
|
+
const core = region("L2-core");
|
|
2436
|
+
const L2module = region("L2-module");
|
|
2437
|
+
L2.append(core, L2module);
|
|
2438
|
+
// On a failed bundle L0 and L1 are not created (presentation contract
|
|
2439
|
+
// section 9.1, I1): no module renders, and a notice goes before L2.
|
|
2440
|
+
if (verified) {
|
|
2441
|
+
regions = { L0: region("L0"), L1: region("L1"), L2: L2module, core };
|
|
2442
|
+
stripNode = strip === undefined ? undefined : renderCoreStrip(strip);
|
|
2443
|
+
if (stripNode !== undefined)
|
|
2444
|
+
regions.L0.append(stripNode);
|
|
2445
|
+
// The charts open L1, in the order the build gave them (chart-view.ts).
|
|
2446
|
+
if (chartsNode !== undefined)
|
|
2447
|
+
regions.L1.append(chartsNode);
|
|
2448
|
+
root.append(regions.L0, regions.L1, L2);
|
|
2449
|
+
}
|
|
2450
|
+
else {
|
|
2451
|
+
regions = { L0: root, L1: root, L2: L2module, core };
|
|
2452
|
+
root.append(L2);
|
|
2453
|
+
}
|
|
2454
|
+
};
|
|
2455
|
+
/** A page-level notice: first in L1, or before L2 on a failed bundle. */
|
|
2456
|
+
const notice = (note) => {
|
|
2457
|
+
if (verified)
|
|
2458
|
+
regions.L1.append(note);
|
|
2459
|
+
else
|
|
2460
|
+
root.insertBefore(note, regions.core.parentElement);
|
|
2461
|
+
};
|
|
2462
|
+
drawFrame();
|
|
2463
|
+
// The banner and its details line are the core's (contract sections 3 and
|
|
2464
|
+
// 6.2). A module that, while it renders, changes their words, structure or
|
|
2465
|
+
// attributes, hides or moves them, puts anything before them but the
|
|
2466
|
+
// core's own header, or draws a second banner, is discarded for the
|
|
2467
|
+
// refusal like one that throws. The bar's summary line is empty until the
|
|
2468
|
+
// verification section fills it, after every module has rendered. These
|
|
2469
|
+
// checks catch a module's mistakes; they do not hold against module code
|
|
2470
|
+
// written to hide the banner, which the builder's pin governs (#125).
|
|
2471
|
+
const snapshot = (parts) => JSON.stringify(parts.map((part) => part.outerHTML));
|
|
2472
|
+
// How the frame looks: the computed properties that decide whether its
|
|
2473
|
+
// words can be read, for every element of each part, the root and the
|
|
2474
|
+
// root's ancestors, with the root's chrome class as given (the one
|
|
2475
|
+
// restyling a module may ask for, setChromeClass). A stylesheet a module adds that changes any of
|
|
2476
|
+
// them, hiding the banner included, is caught by comparing with this as it
|
|
2477
|
+
// was before the module rendered, so a host that was already hidden (an
|
|
2478
|
+
// inactive tab) is no module's doing. Empty off a document, where no
|
|
2479
|
+
// styles apply; the static builder renders on a root in its document for
|
|
2480
|
+
// this reason.
|
|
2481
|
+
const looks = (parts, chromed) => {
|
|
2482
|
+
const view = root.ownerDocument.defaultView;
|
|
2483
|
+
if (!root.isConnected || view === null)
|
|
2484
|
+
return {
|
|
2485
|
+
look: "",
|
|
2486
|
+
offsets: [],
|
|
2487
|
+
place: [0, 0],
|
|
2488
|
+
below: 0,
|
|
2489
|
+
readable: "unseen",
|
|
2490
|
+
clips: [],
|
|
2491
|
+
};
|
|
2492
|
+
const had = root.classList.contains("cv-shell-chrome");
|
|
2493
|
+
root.classList.toggle("cv-shell-chrome", chromed);
|
|
2494
|
+
// The root's ancestors too, up to <html>: a transform, opacity, filter,
|
|
2495
|
+
// clip or offset on any of them scales, hides or moves the banner while
|
|
2496
|
+
// every value on the banner itself stays the same.
|
|
2497
|
+
const ancestors = [];
|
|
2498
|
+
for (let at = root.parentElement; at !== null; at = at.parentElement)
|
|
2499
|
+
ancestors.push(at);
|
|
2500
|
+
// The L0 region's own box too, but not what a module writes in it: a
|
|
2501
|
+
// module that hides or moves the region hides the strip.
|
|
2502
|
+
const elements = [
|
|
2503
|
+
...ancestors,
|
|
2504
|
+
root,
|
|
2505
|
+
...(stripNode === undefined ? [] : [regions.L0]),
|
|
2506
|
+
...parts.flatMap((part) => [part, ...part.querySelectorAll("*")]),
|
|
2507
|
+
];
|
|
2508
|
+
// A browser also computes each element's ::before and ::after, whose
|
|
2509
|
+
// content can add words to the banner; jsdom computes no pseudo-element.
|
|
2510
|
+
const jsdom = view.navigator.userAgent.includes("jsdom");
|
|
2511
|
+
const pseudos = jsdom ? [null] : [null, "::before", "::after"];
|
|
2512
|
+
const offsets = [];
|
|
2513
|
+
const seen = JSON.stringify(elements.flatMap((element, at) => pseudos.map((pseudo) => {
|
|
2514
|
+
const style = view.getComputedStyle(element, pseudo);
|
|
2515
|
+
const ancestor = at < ancestors.length;
|
|
2516
|
+
const [transform, moves] = ancestor
|
|
2517
|
+
? splitTransform(style.getPropertyValue("transform"))
|
|
2518
|
+
: [undefined, []];
|
|
2519
|
+
offsets.push(...moves);
|
|
2520
|
+
return [
|
|
2521
|
+
...(ancestor ? ANCESTOR_LOOK : FRAME_LOOK).map((name) => style.getPropertyValue(name)),
|
|
2522
|
+
...(transform === undefined ? [] : [transform]),
|
|
2523
|
+
...[...SIDE_MARGINS, ...(ancestor ? ANCESTOR_OFFSETS : [])].flatMap((name) => {
|
|
2524
|
+
const value = style.getPropertyValue(name);
|
|
2525
|
+
const px = Number.parseFloat(value);
|
|
2526
|
+
offsets.push(Number.isNaN(px) ? 0 : px);
|
|
2527
|
+
return Number.isNaN(px) ? [value] : [];
|
|
2528
|
+
}),
|
|
2529
|
+
...(pseudo === null ? [] : [style.getPropertyValue("content")]),
|
|
2530
|
+
];
|
|
2531
|
+
})));
|
|
2532
|
+
// Where the bar sits in the document: its box plus every scroll offset
|
|
2533
|
+
// above it, so a reader's scrolling moves nothing. A scroll offset is in
|
|
2534
|
+
// its container's own px, mapped into viewport px by the transforms on
|
|
2535
|
+
// and above the container (linearTransform), which no module can
|
|
2536
|
+
// change; the viewport's own is in viewport px already.
|
|
2537
|
+
const box = parts[0].getBoundingClientRect();
|
|
2538
|
+
const place = [box.left, box.top];
|
|
2539
|
+
// A box with `position: fixed` stays put while the boxes between it and
|
|
2540
|
+
// its containing block scroll (the viewport, or the nearest ancestor that
|
|
2541
|
+
// makes one for it), so their offsets are left out.
|
|
2542
|
+
let fixed = false;
|
|
2543
|
+
for (let at = parts[0].parentElement; at !== null; at = at.parentElement) {
|
|
2544
|
+
const style = jsdom ? undefined : view.getComputedStyle(at);
|
|
2545
|
+
if (fixed && style !== undefined && holdsFixed(style))
|
|
2546
|
+
fixed = false;
|
|
2547
|
+
if (!fixed && (at.scrollLeft !== 0 || at.scrollTop !== 0)) {
|
|
2548
|
+
const move = at === root.ownerDocument.scrollingElement || jsdom
|
|
2549
|
+
? { x: at.scrollLeft, y: at.scrollTop }
|
|
2550
|
+
: linearTransform(at, view).transformPoint({
|
|
2551
|
+
x: at.scrollLeft,
|
|
2552
|
+
y: at.scrollTop,
|
|
2553
|
+
});
|
|
2554
|
+
place[0] += move.x;
|
|
2555
|
+
place[1] += move.y;
|
|
2556
|
+
}
|
|
2557
|
+
if (style?.position === "fixed")
|
|
2558
|
+
fixed = true;
|
|
2559
|
+
}
|
|
2560
|
+
// Every word of the banner and the strip: a module's content laid over
|
|
2561
|
+
// the strip is caught as one laid over the banner is.
|
|
2562
|
+
const words = readable(parts, root);
|
|
2563
|
+
// The strip stays where the banner puts it: nothing a module draws, laid
|
|
2564
|
+
// out ahead of it (a flex or grid `order`, a float), pushes it down.
|
|
2565
|
+
const strip = parts.length > 0 ? parts[parts.length - 1] : undefined;
|
|
2566
|
+
const below = jsdom || strip === undefined || strip !== stripNode
|
|
2567
|
+
? 0
|
|
2568
|
+
: strip.getBoundingClientRect().top - box.top;
|
|
2569
|
+
// The visible size of every box that clips the banner, from <html> down
|
|
2570
|
+
// to the banner's own elements: a module that shrinks one (a scrolling
|
|
2571
|
+
// host's height set to 0) clips the banner wherever the reader has
|
|
2572
|
+
// scrolled. Which boxes clip is compared exactly (`overflow` and
|
|
2573
|
+
// `contain` are in the looks). A width may shrink by one assumed classic
|
|
2574
|
+
// scrollbar, as when the page or the box itself grows one, and a height
|
|
2575
|
+
// by as much as the box's own scrollbar across its bottom grew. The size is
|
|
2576
|
+
// mapped into viewport px through the transforms on and above the box,
|
|
2577
|
+
// which no module can change.
|
|
2578
|
+
const clips = jsdom
|
|
2579
|
+
? []
|
|
2580
|
+
: elements.flatMap((element) => {
|
|
2581
|
+
const style = view.getComputedStyle(element);
|
|
2582
|
+
if (style.overflowX === "visible" &&
|
|
2583
|
+
style.overflowY === "visible" &&
|
|
2584
|
+
!/paint|strict|content/.test(style.contain) &&
|
|
2585
|
+
style.contentVisibility !== "auto")
|
|
2586
|
+
return [];
|
|
2587
|
+
// In viewport px, as the slack is: under a page zoom a scrollbar
|
|
2588
|
+
// takes more of a box's own px.
|
|
2589
|
+
const matrix = linearTransform(element, view);
|
|
2590
|
+
const across = matrix.transformPoint({ x: element.clientWidth });
|
|
2591
|
+
const down = matrix.transformPoint({ y: element.clientHeight });
|
|
2592
|
+
// The scrollbar across the box's bottom, in viewport px: the box's
|
|
2593
|
+
// height may shrink by only as much as that grows. A page's own
|
|
2594
|
+
// scrollbar leaves any other height alone. The viewport's is what
|
|
2595
|
+
// its height lacks of the window's.
|
|
2596
|
+
// The viewport's size is in viewport px already, as its scroll
|
|
2597
|
+
// offsets are.
|
|
2598
|
+
const viewport = element === root.ownerDocument.scrollingElement;
|
|
2599
|
+
const width = viewport
|
|
2600
|
+
? element.clientWidth
|
|
2601
|
+
: Math.hypot(across.x, across.y);
|
|
2602
|
+
const height = viewport
|
|
2603
|
+
? element.clientHeight
|
|
2604
|
+
: Math.hypot(down.x, down.y);
|
|
2605
|
+
const own = matrix.transformPoint({
|
|
2606
|
+
y: element instanceof view.HTMLElement && !viewport
|
|
2607
|
+
? Math.max(0, element.offsetHeight -
|
|
2608
|
+
element.clientHeight -
|
|
2609
|
+
Number.parseFloat(style.borderTopWidth) -
|
|
2610
|
+
Number.parseFloat(style.borderBottomWidth))
|
|
2611
|
+
: 0,
|
|
2612
|
+
});
|
|
2613
|
+
const bar = viewport
|
|
2614
|
+
? Math.max(0, view.innerHeight - height)
|
|
2615
|
+
: Math.hypot(own.x, own.y);
|
|
2616
|
+
return [
|
|
2617
|
+
{
|
|
2618
|
+
width,
|
|
2619
|
+
height,
|
|
2620
|
+
bar,
|
|
2621
|
+
},
|
|
2622
|
+
];
|
|
2623
|
+
});
|
|
2624
|
+
root.classList.toggle("cv-shell-chrome", had);
|
|
2625
|
+
return { look: seen, offsets, place, below, readable: words, clips };
|
|
2626
|
+
};
|
|
2627
|
+
// The core strip (core-strip.ts) is held to the same rules as the
|
|
2628
|
+
// banner: its words, structure and look are the core's, and it stays the
|
|
2629
|
+
// first thing in L0, right after the banner.
|
|
2630
|
+
const frameOf = () => {
|
|
2631
|
+
const detail = bar.nextElementSibling;
|
|
2632
|
+
const parts = [
|
|
2633
|
+
bar,
|
|
2634
|
+
...(detail?.hasAttribute("data-banner-detail") ? [detail] : []),
|
|
2635
|
+
];
|
|
2636
|
+
const held = [...parts, ...(stripNode === undefined ? [] : [stripNode])];
|
|
2637
|
+
return {
|
|
2638
|
+
parts,
|
|
2639
|
+
held,
|
|
2640
|
+
header: bar.previousElementSibling,
|
|
2641
|
+
words: snapshot(held),
|
|
2642
|
+
looks: {
|
|
2643
|
+
plain: looks(held, false),
|
|
2644
|
+
chrome: looks(held, true),
|
|
2645
|
+
},
|
|
2646
|
+
};
|
|
2647
|
+
};
|
|
2648
|
+
// Measured only when a module will render: it lays out the page.
|
|
2649
|
+
let frame = selected !== undefined || section !== undefined ? frameOf() : undefined;
|
|
2650
|
+
// The strip is L0's first node and L0 follows the banner directly; no
|
|
2651
|
+
// other node on the page carries the strip's marker. On a page with no
|
|
2652
|
+
// Result, nothing on it may carry the marks of the Result's counts
|
|
2653
|
+
// (RESULT_COUNT_MARKS): a module or layout there draws no claim counts,
|
|
2654
|
+
// tallies or coverage (the 2026-10-25 ruling on #81, condition 2).
|
|
2655
|
+
const stripIntact = (last) => {
|
|
2656
|
+
if (stripNode === undefined)
|
|
2657
|
+
return root.querySelector(RESULT_COUNT_MARKS) === null;
|
|
2658
|
+
return (regions.L0.parentNode === root &&
|
|
2659
|
+
regions.L0.previousSibling === last &&
|
|
2660
|
+
regions.L0.firstChild === stripNode &&
|
|
2661
|
+
!stripNode.hidden &&
|
|
2662
|
+
root.querySelectorAll(`[${CORE_STRIP_ATTRIBUTE}], .cv-strip`).length === 1);
|
|
2663
|
+
};
|
|
2664
|
+
const assertFrameIntact = () => {
|
|
2665
|
+
const at = frame;
|
|
2666
|
+
const [top, detail] = at.parts;
|
|
2667
|
+
const pill = top.querySelector("[data-verify]");
|
|
2668
|
+
const banners = root.querySelectorAll("[data-verify], [data-banner-detail]");
|
|
2669
|
+
const expected = [pill, ...(detail === undefined ? [] : [detail])];
|
|
2670
|
+
if (pill === null ||
|
|
2671
|
+
banners.length !== expected.length ||
|
|
2672
|
+
expected.some((part, i) => banners[i] !== part) ||
|
|
2673
|
+
// Nodes, not elements: a bare text node before the banner is words
|
|
2674
|
+
// too. The core draws no text node at the root.
|
|
2675
|
+
root.firstChild !== (at.header ?? top) ||
|
|
2676
|
+
top.previousSibling !== at.header ||
|
|
2677
|
+
(at.header !== null && at.header.parentNode !== root) ||
|
|
2678
|
+
(detail !== undefined && detail.previousElementSibling !== top) ||
|
|
2679
|
+
top.parentNode !== root ||
|
|
2680
|
+
top.hidden ||
|
|
2681
|
+
!stripIntact(detail ?? top) ||
|
|
2682
|
+
snapshot(at.held) !== at.words ||
|
|
2683
|
+
!sameLook(looks(at.held, root.classList.contains("cv-shell-chrome")), root.classList.contains("cv-shell-chrome")
|
|
2684
|
+
? at.looks.chrome
|
|
2685
|
+
: at.looks.plain))
|
|
2686
|
+
throw new Error("a module altered the verification banner");
|
|
1405
2687
|
};
|
|
1406
|
-
let banner = drawFrame();
|
|
1407
2688
|
if (refused.length > 0)
|
|
1408
2689
|
root.dataset.presentationRefused = refused.map((r) => r.id).join(" ");
|
|
1409
2690
|
else
|
|
@@ -1411,56 +2692,83 @@ export async function renderEvidenceGraph(input, root, countersigners, options =
|
|
|
1411
2692
|
let chrome;
|
|
1412
2693
|
if (selected !== undefined) {
|
|
1413
2694
|
const host = {
|
|
1414
|
-
L0:
|
|
1415
|
-
L1:
|
|
1416
|
-
L2:
|
|
1417
|
-
depth
|
|
2695
|
+
L0: regions.L0,
|
|
2696
|
+
L1: regions.L1,
|
|
2697
|
+
L2: regions.L2,
|
|
2698
|
+
depth,
|
|
2699
|
+
...(options.wording === undefined ? {} : { wording: options.wording }),
|
|
1418
2700
|
setChromeClass(name) {
|
|
1419
|
-
if (name !== OUTCOME_CHROME)
|
|
2701
|
+
if (name !== OUTCOME_CHROME && name !== COMPLIANCE_CHROME)
|
|
1420
2702
|
throw new Error(`unknown chrome class ${JSON.stringify(name)}`);
|
|
1421
2703
|
chrome = name;
|
|
1422
|
-
|
|
2704
|
+
// The card keeps its own frame; the pill keeps its look.
|
|
2705
|
+
root.classList.add("cv-shell-chrome");
|
|
1423
2706
|
},
|
|
1424
2707
|
};
|
|
1425
2708
|
try {
|
|
1426
2709
|
await selected.module.render(selected.model, host, presentationServices(context));
|
|
2710
|
+
assertFrameIntact();
|
|
1427
2711
|
}
|
|
1428
2712
|
catch {
|
|
1429
2713
|
// Everything the module wrote is discarded; no other module is tried.
|
|
1430
2714
|
chrome = undefined;
|
|
1431
|
-
|
|
2715
|
+
drawFrame();
|
|
2716
|
+
frame = frameOf();
|
|
1432
2717
|
refusal = "presentation-failed";
|
|
1433
2718
|
}
|
|
1434
2719
|
}
|
|
1435
2720
|
if (refusal === undefined && resolution.kind === "no-presentation") {
|
|
1436
2721
|
const note = element("p", "No presentation is available for this bundle, audience and format. The records and their verification are below.");
|
|
1437
2722
|
note.dataset.notice = "no-presentation";
|
|
1438
|
-
|
|
2723
|
+
notice(note);
|
|
1439
2724
|
}
|
|
1440
2725
|
// The section renders after the page module, into the same regions. If it
|
|
1441
2726
|
// throws, everything any module wrote is discarded for the refusal.
|
|
1442
2727
|
if (section !== undefined && refusal === undefined) {
|
|
1443
2728
|
try {
|
|
1444
2729
|
await section.module.render(section.model, {
|
|
1445
|
-
L0:
|
|
1446
|
-
L1:
|
|
1447
|
-
L2:
|
|
1448
|
-
depth
|
|
2730
|
+
L0: regions.L0,
|
|
2731
|
+
L1: regions.L1,
|
|
2732
|
+
L2: regions.L2,
|
|
2733
|
+
depth,
|
|
1449
2734
|
setChromeClass() {
|
|
1450
2735
|
throw new Error("a section has no chrome");
|
|
1451
2736
|
},
|
|
1452
2737
|
}, presentationServices(context));
|
|
2738
|
+
assertFrameIntact();
|
|
1453
2739
|
}
|
|
1454
2740
|
catch {
|
|
1455
2741
|
chrome = undefined;
|
|
1456
|
-
|
|
2742
|
+
drawFrame();
|
|
2743
|
+
refusal = "presentation-failed";
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
// A module may still draw once its render has returned, from a timer or
|
|
2747
|
+
// the next frame: a toolbar or a modal it opens when its data is in. The
|
|
2748
|
+
// frame is checked again after the page settles, after the next frame and
|
|
2749
|
+
// then the timers already due. Anything a module draws later is out of
|
|
2750
|
+
// reach (#125). jsdom lays nothing out, so there the checks above are the
|
|
2751
|
+
// last.
|
|
2752
|
+
const view = root.ownerDocument.defaultView;
|
|
2753
|
+
if (refusal === undefined &&
|
|
2754
|
+
(selected !== undefined || section !== undefined) &&
|
|
2755
|
+
root.isConnected &&
|
|
2756
|
+
view !== null &&
|
|
2757
|
+
!view.navigator.userAgent.includes("jsdom")) {
|
|
2758
|
+
await settled(view);
|
|
2759
|
+
try {
|
|
2760
|
+
assertFrameIntact();
|
|
2761
|
+
}
|
|
2762
|
+
catch {
|
|
2763
|
+
chrome = undefined;
|
|
2764
|
+
drawFrame();
|
|
1457
2765
|
refusal = "presentation-failed";
|
|
1458
2766
|
}
|
|
1459
2767
|
}
|
|
1460
2768
|
if (refusal !== undefined) {
|
|
1461
2769
|
const note = element("p", PRESENTATION_REFUSALS[refusal]);
|
|
1462
2770
|
note.dataset.refusal = refusal;
|
|
1463
|
-
|
|
2771
|
+
notice(note);
|
|
1464
2772
|
}
|
|
1465
2773
|
// The interpreters this rendering actually ran (see extension-interpreters.ts):
|
|
1466
2774
|
// the presentation header and the countersignature stamp always run; a
|
|
@@ -1472,9 +2780,57 @@ export async function renderEvidenceGraph(input, root, countersigners, options =
|
|
|
1472
2780
|
if (refusal === undefined)
|
|
1473
2781
|
for (const ran of [selected, section])
|
|
1474
2782
|
if (ran !== undefined)
|
|
1475
|
-
for (const id of
|
|
1476
|
-
[])
|
|
2783
|
+
for (const id of moduleInterpreters(ran.module.manifest.id, context.bundle))
|
|
1477
2784
|
applied.add(id);
|
|
1478
|
-
await renderVerificationPage(
|
|
2785
|
+
const checkedLine = await renderVerificationPage(regions.core, context, chrome === OUTCOME_CHROME, applied, refused, refusal === undefined && citesCheckedSigners(selected), options.verifierHint, depth, stamps, chartDigests);
|
|
2786
|
+
// The banner says the same counts as the section it links to.
|
|
2787
|
+
const summary = root.querySelector("[data-verify-summary]");
|
|
2788
|
+
if (summary !== null)
|
|
2789
|
+
summary.textContent = checkedLine;
|
|
2790
|
+
linkCitedBy(root);
|
|
2791
|
+
// A page opened at a record's address shows that record.
|
|
2792
|
+
revealRecordsByHash(root.ownerDocument);
|
|
2793
|
+
}
|
|
2794
|
+
// "Cited by" (capsule-viewer#83): each record a number on the page counts
|
|
2795
|
+
// links back to that number. The numbers say what they count themselves
|
|
2796
|
+
// (report-levels.ts `evidenceAction`: `data-cites`, the digests their claims
|
|
2797
|
+
// cite that this bundle carries, and `data-evidence-name`); this reads them
|
|
2798
|
+
// back once the module and the records section are drawn, and infers no
|
|
2799
|
+
// citation. The list sits in the record's entry beside its address, outside
|
|
2800
|
+
// the entry's lazily built body, so a page that runs no script carries it.
|
|
2801
|
+
function linkCitedBy(root) {
|
|
2802
|
+
const anchors = new Map();
|
|
2803
|
+
for (const anchor of root.querySelectorAll(".cv-record-anchor"))
|
|
2804
|
+
anchors.set(anchor.id, anchor);
|
|
2805
|
+
const citing = new Map();
|
|
2806
|
+
for (const action of root.querySelectorAll("details.cv-ev[data-cites]"))
|
|
2807
|
+
for (const digest of (action.dataset.cites ?? "").split(" ")) {
|
|
2808
|
+
// One entry may hold two addresses (a book record and the capsule it
|
|
2809
|
+
// carries): its list is one, under the entry's last address.
|
|
2810
|
+
const entry = anchors
|
|
2811
|
+
.get(recordAddress(digest))
|
|
2812
|
+
?.closest("details.cv-record");
|
|
2813
|
+
if (entry === undefined || entry === null)
|
|
2814
|
+
continue;
|
|
2815
|
+
const list = citing.get(entry) ?? [];
|
|
2816
|
+
if (!list.includes(action))
|
|
2817
|
+
list.push(action);
|
|
2818
|
+
citing.set(entry, list);
|
|
2819
|
+
}
|
|
2820
|
+
for (const [entry, actions] of citing) {
|
|
2821
|
+
const own = entry.querySelectorAll(":scope > .cv-record-anchor");
|
|
2822
|
+
const anchor = own[own.length - 1];
|
|
2823
|
+
const line = element("p", "Cited by: ");
|
|
2824
|
+
line.className = "cv-cited-by";
|
|
2825
|
+
line.dataset.citedBy = actions.map((a) => a.id).join(" ");
|
|
2826
|
+
actions.forEach((action, i) => {
|
|
2827
|
+
if (i > 0)
|
|
2828
|
+
line.append(" · ");
|
|
2829
|
+
const link = element("a", action.dataset.evidenceName ?? action.id);
|
|
2830
|
+
link.setAttribute("href", `#${action.id}`);
|
|
2831
|
+
line.append(link);
|
|
2832
|
+
});
|
|
2833
|
+
anchor.after(line);
|
|
2834
|
+
}
|
|
1479
2835
|
}
|
|
1480
2836
|
//# sourceMappingURL=evidence-graph-view.js.map
|