@action-state-group/capsule-viewer 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -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/compliance-styles.d.ts +1 -8
- package/dist/compliance-styles.js +41 -3
- package/dist/compliance-styles.js.map +1 -1
- package/dist/compliance-view.d.ts +41 -1
- package/dist/compliance-view.js +737 -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 +1141 -0
- package/dist/contract-report-wording.js.map +1 -0
- package/dist/contract-report.d.ts +92 -0
- package/dist/contract-report.js +63 -0
- package/dist/contract-report.js.map +1 -0
- package/dist/emitter-shell.html +176 -2
- package/dist/emitter.d.ts +36 -0
- package/dist/emitter.js +64 -1
- package/dist/emitter.js.map +1 -1
- package/dist/evidence-graph-view.d.ts +60 -7
- package/dist/evidence-graph-view.js +1344 -106
- package/dist/evidence-graph-view.js.map +1 -1
- package/dist/evidence-graph.iife.js +12410 -5624
- 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 +1039 -436
- package/dist/outcome-report-view.js.map +1 -1
- package/dist/presentation-builder.d.ts +55 -6
- package/dist/presentation-builder.js +163 -69
- 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 +2 -2
- package/dist/presentation-mount.js +1 -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 +55 -0
- package/dist/report-front-styles.js.map +1 -0
- package/dist/report-front.d.ts +78 -0
- package/dist/report-front.js +274 -0
- package/dist/report-front.js.map +1 -0
- package/dist/report-levels.d.ts +206 -0
- package/dist/report-levels.js +739 -0
- package/dist/report-levels.js.map +1 -0
- package/dist/report-provenance.d.ts +111 -0
- package/dist/report-provenance.js +535 -0
- package/dist/report-provenance.js.map +1 -0
- package/dist/viewer-build.d.ts +37 -0
- package/dist/viewer-build.js +29 -0
- package/dist/viewer-build.js.map +1 -0
- package/dist/wording/contract-report-eu-ai-act.en.json +295 -0
- package/dist/wording/contract-report-outcomes.en.json +394 -0
- package/package.json +3 -2
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
// Moved from agent-action-capsule ts/src/presentation-fragment.ts at 60a5b11
|
|
3
|
+
// (agent-action-capsule#379), unchanged except imports: AAC verification
|
|
4
|
+
// and its extension readers come from @action-state-group/agent-action-capsule.
|
|
5
|
+
import { decodeFragment, encodeFragment, } from "@action-state-group/agent-action-capsule";
|
|
6
|
+
import { isHex64 } from "@action-state-group/agent-action-capsule";
|
|
7
|
+
/**
|
|
8
|
+
* The presentation fragment payload and the share-side scoping step
|
|
9
|
+
* (spec/presentation-builder-v0.md). No DOM, no network: it runs the same
|
|
10
|
+
* in a builder and in a viewer page.
|
|
11
|
+
*
|
|
12
|
+
* The token is base64url (no padding) of the payload's JSON text, the same
|
|
13
|
+
* model as capsule-viewer's fragment codec and the Evidence Bundle
|
|
14
|
+
* permalink codec it reuses. A browser never sends the fragment to a
|
|
15
|
+
* server, so the link needs no host to hold the data. The encoding is NOT a
|
|
16
|
+
* security mechanism: the payload is encoded, not encrypted, and anyone
|
|
17
|
+
* holding the link can read all of it. What an audience may see is decided
|
|
18
|
+
* by {@link scopeDisclosures} before encoding.
|
|
19
|
+
*/
|
|
20
|
+
export const PRESENTATION_FRAGMENT_VERSION = "aac.presentation-fragment/v0";
|
|
21
|
+
/**
|
|
22
|
+
* The longest URL this codec plans for: 1 MiB, the smallest limit among the
|
|
23
|
+
* major browsers' documented URL limits (Chromium allows 2 MiB). A link
|
|
24
|
+
* pasted into chat or email is often cut far shorter; pass a lower
|
|
25
|
+
* `maxLength` for those.
|
|
26
|
+
*/
|
|
27
|
+
export const FRAGMENT_URL_MAX_LENGTH = 1_048_576;
|
|
28
|
+
/** Characters kept free for the viewer's address and the `#`. */
|
|
29
|
+
export const FRAGMENT_ADDRESS_ALLOWANCE = 2_048;
|
|
30
|
+
/** The longest token encoded or decoded: the URL limit less the allowance. */
|
|
31
|
+
export const FRAGMENT_TOKEN_MAX_LENGTH = FRAGMENT_URL_MAX_LENGTH - FRAGMENT_ADDRESS_ALLOWANCE;
|
|
32
|
+
/**
|
|
33
|
+
* The presentation builder's default token budget: the longest link it
|
|
34
|
+
* offers without being asked for more. A token this long still fits a chat
|
|
35
|
+
* message or an email; a report of a few hundred kilobytes does not, and is
|
|
36
|
+
* reported unavailable as a link rather than packaged as one nobody can
|
|
37
|
+
* paste. A caller MAY raise it up to {@link FRAGMENT_TOKEN_MAX_LENGTH}.
|
|
38
|
+
* The codec's own default (and every decoder's) stays the maximum.
|
|
39
|
+
*/
|
|
40
|
+
export const FRAGMENT_TOKEN_DEFAULT_BUDGET = 65_536;
|
|
41
|
+
export class FragmentTooLargeError extends Error {
|
|
42
|
+
length;
|
|
43
|
+
maxLength;
|
|
44
|
+
/** What was too long: `"fragment token"` or `"permalink URL"`. */
|
|
45
|
+
subject;
|
|
46
|
+
constructor(length, maxLength, what = "fragment token") {
|
|
47
|
+
super(`${what} is ${length} characters, over the ${maxLength}-character maximum; it is refused, never truncated. Share the offline .html instead.`);
|
|
48
|
+
this.name = "FragmentTooLargeError";
|
|
49
|
+
this.length = length;
|
|
50
|
+
this.maxLength = maxLength;
|
|
51
|
+
this.subject = what;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export class FragmentDecodeError extends Error {
|
|
55
|
+
constructor(message) {
|
|
56
|
+
super(message);
|
|
57
|
+
this.name = "FragmentDecodeError";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Encode a JSON value as a fragment token with the Evidence Bundle
|
|
62
|
+
* permalink codec (`encodeFragment` in bundle.ts; the "Fragment Codec"
|
|
63
|
+
* section of draft-mih-zhang-agent-disclosure-bundle): the RFC 8785 JCS
|
|
64
|
+
* text, UTF-8, base64url without padding. capsule-viewer's
|
|
65
|
+
* `encode_fragment` writes the same token for the same JSON object read in
|
|
66
|
+
* JCS member order whenever the JSON text is ASCII; for non-ASCII text it
|
|
67
|
+
* writes `\uXXXX` escapes (Python's `ensure_ascii`) where this writes UTF-8.
|
|
68
|
+
* Each decoder reads the other's tokens.
|
|
69
|
+
*/
|
|
70
|
+
export function encodeFragmentToken(value) {
|
|
71
|
+
return encodeFragment(value);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Decode a fragment token (with or without its leading `#`) to the JSON
|
|
75
|
+
* value it carries. A token over `maxLength` is refused before decoding.
|
|
76
|
+
* Stricter than capsule-viewer's `decode_fragment` in one way: a character
|
|
77
|
+
* outside the base64url alphabet is an error, where Python's lenient
|
|
78
|
+
* decoder drops it.
|
|
79
|
+
*/
|
|
80
|
+
export function decodeFragmentToken(token, maxLength = FRAGMENT_TOKEN_MAX_LENGTH) {
|
|
81
|
+
const body = token.replace(/^#+/u, "");
|
|
82
|
+
if (body.length > maxLength)
|
|
83
|
+
throw new FragmentTooLargeError(body.length, maxLength);
|
|
84
|
+
try {
|
|
85
|
+
return decodeFragment(body);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
throw new FragmentDecodeError(err instanceof Error && err.message === "fragment base64url"
|
|
89
|
+
? "fragment token has a character outside the base64url alphabet"
|
|
90
|
+
: "fragment token is not UTF-8 JSON");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export const PRESENTATION_DEPTHS = [
|
|
94
|
+
"L0",
|
|
95
|
+
"L1",
|
|
96
|
+
"L2",
|
|
97
|
+
];
|
|
98
|
+
const FRAGMENT_MEMBERS = new Set([
|
|
99
|
+
"fragment_version",
|
|
100
|
+
"audience",
|
|
101
|
+
"presentation",
|
|
102
|
+
"depth",
|
|
103
|
+
"title",
|
|
104
|
+
"theme_css",
|
|
105
|
+
"wording",
|
|
106
|
+
"core_runtime_sha256",
|
|
107
|
+
"module_sha256",
|
|
108
|
+
"bundle",
|
|
109
|
+
]);
|
|
110
|
+
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
111
|
+
/** Throws unless `value` is a well-formed presentation fragment payload. */
|
|
112
|
+
export function checkPresentationFragment(value) {
|
|
113
|
+
const fail = (why) => {
|
|
114
|
+
throw new FragmentDecodeError(`presentation fragment: ${why}`);
|
|
115
|
+
};
|
|
116
|
+
if (!isObject(value))
|
|
117
|
+
fail("not a JSON object");
|
|
118
|
+
const v = value;
|
|
119
|
+
for (const key of Object.keys(v))
|
|
120
|
+
if (!FRAGMENT_MEMBERS.has(key))
|
|
121
|
+
fail(`unknown member ${JSON.stringify(key)}`);
|
|
122
|
+
if (v.fragment_version !== PRESENTATION_FRAGMENT_VERSION)
|
|
123
|
+
fail(`fragment_version is not ${PRESENTATION_FRAGMENT_VERSION}`);
|
|
124
|
+
if (typeof v.audience !== "string" || v.audience === "")
|
|
125
|
+
fail("audience is not a non-empty string");
|
|
126
|
+
if (typeof v.presentation !== "string" || v.presentation === "")
|
|
127
|
+
fail("presentation is not a non-empty string");
|
|
128
|
+
if (v.depth !== undefined &&
|
|
129
|
+
!PRESENTATION_DEPTHS.includes(v.depth))
|
|
130
|
+
fail("depth is not L0, L1 or L2");
|
|
131
|
+
if (v.title !== undefined && typeof v.title !== "string")
|
|
132
|
+
fail("title is not a string");
|
|
133
|
+
if (v.theme_css !== undefined && typeof v.theme_css !== "string")
|
|
134
|
+
fail("theme_css is not a string");
|
|
135
|
+
if (v.wording !== undefined) {
|
|
136
|
+
const w = v.wording;
|
|
137
|
+
if (!isObject(w) ||
|
|
138
|
+
Object.keys(w).some((k) => k !== "pack" && k !== "sha256") ||
|
|
139
|
+
typeof w.pack !== "string" ||
|
|
140
|
+
!isHex64(w.sha256))
|
|
141
|
+
fail("wording is not {pack, sha256}");
|
|
142
|
+
}
|
|
143
|
+
if (!isHex64(v.core_runtime_sha256))
|
|
144
|
+
fail("core_runtime_sha256 is not a lowercase hex SHA-256");
|
|
145
|
+
if (!Array.isArray(v.module_sha256) ||
|
|
146
|
+
!v.module_sha256.every((pin) => isHex64(pin)))
|
|
147
|
+
fail("module_sha256 is not a list of lowercase hex SHA-256 pins");
|
|
148
|
+
if (!("bundle" in v))
|
|
149
|
+
fail("bundle is missing");
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Encode a presentation fragment payload. Refuses a token longer than
|
|
153
|
+
* `maxLength` (at most {@link FRAGMENT_TOKEN_MAX_LENGTH}); with a
|
|
154
|
+
* `viewerUrl`, also refuses a whole URL longer than
|
|
155
|
+
* {@link FRAGMENT_URL_MAX_LENGTH}. Nothing is ever truncated.
|
|
156
|
+
*/
|
|
157
|
+
export function encodePresentationFragment(payload, options = {}) {
|
|
158
|
+
checkPresentationFragment(payload);
|
|
159
|
+
const maxLength = options.maxLength ?? FRAGMENT_TOKEN_MAX_LENGTH;
|
|
160
|
+
if (!Number.isInteger(maxLength) ||
|
|
161
|
+
maxLength < 1 ||
|
|
162
|
+
maxLength > FRAGMENT_TOKEN_MAX_LENGTH)
|
|
163
|
+
throw new RangeError(`maxLength must be an integer from 1 to ${FRAGMENT_TOKEN_MAX_LENGTH}`);
|
|
164
|
+
const fragment = encodeFragmentToken(payload);
|
|
165
|
+
if (fragment.length > maxLength)
|
|
166
|
+
throw new FragmentTooLargeError(fragment.length, maxLength);
|
|
167
|
+
if (options.viewerUrl === undefined)
|
|
168
|
+
return { fragment };
|
|
169
|
+
if (options.viewerUrl.includes("#"))
|
|
170
|
+
throw new Error("viewerUrl must not already carry a fragment");
|
|
171
|
+
const url = `${options.viewerUrl}#${fragment}`;
|
|
172
|
+
if (url.length > FRAGMENT_URL_MAX_LENGTH)
|
|
173
|
+
throw new FragmentTooLargeError(url.length, FRAGMENT_URL_MAX_LENGTH, "permalink URL");
|
|
174
|
+
return { fragment, url };
|
|
175
|
+
}
|
|
176
|
+
/** Decode and check a presentation fragment (leading `#` allowed). */
|
|
177
|
+
export function decodePresentationFragment(token, maxLength = FRAGMENT_TOKEN_MAX_LENGTH) {
|
|
178
|
+
const value = decodeFragmentToken(token, maxLength);
|
|
179
|
+
checkPresentationFragment(value);
|
|
180
|
+
return value;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The bundle with every disclosure outside `scope` removed. Scoping only
|
|
184
|
+
* removes: it never adds, rewrites or reorders anything, and the records,
|
|
185
|
+
* checkpoints and proofs are untouched, so the result verifies wherever the
|
|
186
|
+
* input did, with the removed members reported as withheld.
|
|
187
|
+
*
|
|
188
|
+
* This is the share builder's step, done before encoding. A viewer never
|
|
189
|
+
* scopes: it shows the bundle it was given. Scoping is not a security
|
|
190
|
+
* mechanism either; it decides what is put in the artifact, and whoever
|
|
191
|
+
* holds the artifact can read everything in it.
|
|
192
|
+
*/
|
|
193
|
+
export function scopeDisclosures(bundle, scope) {
|
|
194
|
+
if (!isObject(bundle))
|
|
195
|
+
return bundle;
|
|
196
|
+
const supplied = bundle.disclosures;
|
|
197
|
+
if (!isObject(supplied))
|
|
198
|
+
return { ...bundle };
|
|
199
|
+
const kept = {};
|
|
200
|
+
for (const [id, members] of Object.entries(supplied)) {
|
|
201
|
+
const allowed = Object.hasOwn(scope, id) ? scope[id] : [];
|
|
202
|
+
if (!isObject(members) || allowed.length === 0)
|
|
203
|
+
continue;
|
|
204
|
+
const entry = {};
|
|
205
|
+
for (const [member, value] of Object.entries(members))
|
|
206
|
+
if (allowed.includes(member))
|
|
207
|
+
entry[member] = value;
|
|
208
|
+
if (Object.keys(entry).length > 0)
|
|
209
|
+
kept[id] = entry;
|
|
210
|
+
}
|
|
211
|
+
return { ...bundle, disclosures: kept };
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=presentation-fragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-fragment.js","sourceRoot":"","sources":["../src/presentation-fragment.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,6EAA6E;AAC7E,yEAAyE;AACzE,gFAAgF;AAChF,OAAO,EACL,cAAc,EACd,cAAc,GACf,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,0CAA0C,CAAC;AAEnE;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,6BAA6B,GAAG,8BAA8B,CAAC;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,CAAC;QAC1E,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;IACtD,CAAC;IACD,OAAO,EAAE,GAAG,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PresentationFormat, PresentationResolver } from "
|
|
2
|
-
import { type PresentationDepth, type WordingPackInput } from "
|
|
1
|
+
import type { PresentationFormat, PresentationResolver } from "./presentation-registry.js";
|
|
2
|
+
import { type PresentationDepth, type WordingPackInput } from "./presentation-fragment.js";
|
|
3
3
|
/** What a host element is given: an already scoped bundle and its settings. */
|
|
4
4
|
export interface MountPresentationInput {
|
|
5
5
|
readonly bundle: unknown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { renderEvidenceGraph } from "./evidence-graph-view.js";
|
|
2
|
-
import { decodePresentationFragment, FRAGMENT_TOKEN_MAX_LENGTH, } from "
|
|
2
|
+
import { decodePresentationFragment, FRAGMENT_TOKEN_MAX_LENGTH, } from "./presentation-fragment.js";
|
|
3
3
|
/**
|
|
4
4
|
* Render a scoped bundle into a host element (the `embedded` packaging, and
|
|
5
5
|
* the body of the fragment viewer). Verification, resolution and the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-mount.js","sourceRoot":"","sources":["../src/presentation-mount.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,GAG1B,MAAM,
|
|
1
|
+
{"version":3,"file":"presentation-mount.js","sourceRoot":"","sources":["../src/presentation-mount.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,GAG1B,MAAM,4B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C,IAAI,CAAC,CAAC;QAC9B,OAAO;IACT,CAAC;IACD,MAAM,iBAAiB,CAAC,OAAO,EAAE;QAC/B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,MAAM,EAAE,UAAU;QAClB,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;QAChE,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;KACvE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import type { VerifiedBundleContext } from "@action-state-group/agent-action-capsule";
|
|
2
|
+
import { bundleVerified } from "@action-state-group/agent-action-capsule";
|
|
3
|
+
import type { DisclosureState } from "@action-state-group/agent-action-capsule";
|
|
4
|
+
/**
|
|
5
|
+
* The presentation registry of spec/presentation-contract-v0.md: module
|
|
6
|
+
* manifests (`aac.presentation-manifest/v0`), the resolution descriptor a
|
|
7
|
+
* verified bundle context yields (section 4.2), the static ambiguity test
|
|
8
|
+
* applied at registration (section 4.5) and `resolve` (section 4.3).
|
|
9
|
+
*
|
|
10
|
+
* Precedence lives in the manifests: a registry never orders two modules of
|
|
11
|
+
* one tier. Two that can match one descriptor are rejected when the second
|
|
12
|
+
* is registered, and a runtime tie (only reachable by a resolver that skipped
|
|
13
|
+
* that test) raises {@link PresentationAmbiguityError}, never first-wins.
|
|
14
|
+
*
|
|
15
|
+
* The registry also applies the presentation ABI (section 3.2): a runtime
|
|
16
|
+
* declares the `presentation_api` versions it implements and its runtime
|
|
17
|
+
* version, and a module whose manifest asks for an API it does not implement
|
|
18
|
+
* (or a newer runtime) is registered as REFUSED. A refused module is never
|
|
19
|
+
* selected and none of its methods is called; it still counts for ambiguity,
|
|
20
|
+
* so nothing silently takes its place, and every resolution it would have
|
|
21
|
+
* taken part in carries the refusal.
|
|
22
|
+
*/
|
|
23
|
+
export declare const PRESENTATION_MANIFEST_VERSION = "aac.presentation-manifest/v0";
|
|
24
|
+
/** The presentation ABI this runtime implements (spec section 3.2). */
|
|
25
|
+
export declare const PRESENTATION_API_V0 = "aac.presentation-api/v0";
|
|
26
|
+
/** What a presentation runtime implements (spec section 3.2). */
|
|
27
|
+
export interface PresentationRuntime {
|
|
28
|
+
/** Every `presentation_api` value the runtime implements. */
|
|
29
|
+
readonly presentationApis: readonly string[];
|
|
30
|
+
/** The runtime's own version, `MAJOR.MINOR.PATCH`. */
|
|
31
|
+
readonly runtimeVersion: string;
|
|
32
|
+
}
|
|
33
|
+
/** This repository's runtime: exactly `aac.presentation-api/v0`, version 0.1.0. */
|
|
34
|
+
export declare const REFERENCE_PRESENTATION_RUNTIME: PresentationRuntime;
|
|
35
|
+
export type PresentationFormat = "html" | "fragment" | "embedded";
|
|
36
|
+
export declare const PRESENTATION_FORMATS: readonly PresentationFormat[];
|
|
37
|
+
export interface PresentationManifest {
|
|
38
|
+
readonly spec_version: typeof PRESENTATION_MANIFEST_VERSION;
|
|
39
|
+
/** The module id: one identity for the module and its manifest. */
|
|
40
|
+
readonly id: string;
|
|
41
|
+
/** The presentation ABI the module is written against. */
|
|
42
|
+
readonly presentation_api: string;
|
|
43
|
+
/** The lowest runtime version the module needs, `MAJOR.MINOR.PATCH`. */
|
|
44
|
+
readonly runtime_min: string;
|
|
45
|
+
readonly trust_class: "trusted-executable" | "declarative";
|
|
46
|
+
readonly requires: {
|
|
47
|
+
readonly bundle_kind: string;
|
|
48
|
+
readonly profiles?: readonly string[];
|
|
49
|
+
readonly extensions?: {
|
|
50
|
+
readonly required: readonly string[];
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
readonly forbids?: {
|
|
54
|
+
readonly profiles?: readonly string[];
|
|
55
|
+
readonly extensions?: readonly string[];
|
|
56
|
+
};
|
|
57
|
+
readonly audiences: readonly string[];
|
|
58
|
+
readonly formats: readonly PresentationFormat[];
|
|
59
|
+
readonly fallback: boolean;
|
|
60
|
+
readonly priority?: number;
|
|
61
|
+
readonly executable?: {
|
|
62
|
+
readonly carrier: "core-runtime" | "module-slot";
|
|
63
|
+
readonly script_sha256?: string;
|
|
64
|
+
readonly style_sha256?: readonly string[];
|
|
65
|
+
readonly wording_sha256?: string;
|
|
66
|
+
};
|
|
67
|
+
readonly declarative?: {
|
|
68
|
+
readonly renderer: string;
|
|
69
|
+
readonly wording_sha256: string;
|
|
70
|
+
readonly fields: readonly unknown[];
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* What a module writes into. The depth regions are, for now, one element:
|
|
75
|
+
* the built-in modules are whole report applications that predate the
|
|
76
|
+
* depth levels, and the core writes its verification section after them.
|
|
77
|
+
*/
|
|
78
|
+
export interface PresentationHost {
|
|
79
|
+
readonly L0: HTMLElement;
|
|
80
|
+
readonly L1: HTMLElement;
|
|
81
|
+
readonly L2: HTMLElement;
|
|
82
|
+
readonly depth: "L0" | "L1" | "L2";
|
|
83
|
+
/**
|
|
84
|
+
* Restyle the banner and the verification section by class only. The one
|
|
85
|
+
* chrome class the core knows is `"oi"` (the outcome-report look); any
|
|
86
|
+
* other name is an error. Words, order and data attributes never change.
|
|
87
|
+
*/
|
|
88
|
+
setChromeClass(name: string): void;
|
|
89
|
+
}
|
|
90
|
+
/** The closed badge vocabulary the core owns; a module cannot add a state. */
|
|
91
|
+
export type PresentationBadgeState = "verified" | "failed" | "withheld" | "mismatch" | "producer-asserted";
|
|
92
|
+
/**
|
|
93
|
+
* DOM primitives a module may use. Not a router: no navigation, no fetch, no
|
|
94
|
+
* timers. Section, citation, formatting, countersigner naming and wording
|
|
95
|
+
* arrive with wording packs and the depth regions.
|
|
96
|
+
*/
|
|
97
|
+
export interface PresentationServices {
|
|
98
|
+
/** A native `<details>`/`<summary>` disclosure. */
|
|
99
|
+
details(summary: string, open?: boolean): HTMLDetailsElement;
|
|
100
|
+
/** A state badge from the core's closed vocabulary. */
|
|
101
|
+
badge(state: PresentationBadgeState): HTMLElement;
|
|
102
|
+
/** A member's disclosure state as the verifier resolved it. */
|
|
103
|
+
disclosure(capsuleId: string, member: "agent_input" | "agent_output"): DisclosureState;
|
|
104
|
+
}
|
|
105
|
+
export interface PresentationModule<Model = unknown> {
|
|
106
|
+
readonly manifest: PresentationManifest;
|
|
107
|
+
/**
|
|
108
|
+
* Pure. True exactly when `buildModel(context)` would produce a model.
|
|
109
|
+
* Called only on a verified context whose descriptor the manifest matched.
|
|
110
|
+
* May be asynchronous: building a model can need a digest.
|
|
111
|
+
*/
|
|
112
|
+
canRender(context: VerifiedBundleContext): boolean | Promise<boolean>;
|
|
113
|
+
buildModel(context: VerifiedBundleContext): Model | Promise<Model>;
|
|
114
|
+
render(model: Model, host: PresentationHost, services: PresentationServices): void | Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
/** The resolution inputs (spec section 4.2); never the audience or format. */
|
|
117
|
+
export interface PresentationDescriptor {
|
|
118
|
+
readonly verified: boolean;
|
|
119
|
+
readonly bundle_kind: string | undefined;
|
|
120
|
+
readonly profiles: ReadonlySet<string>;
|
|
121
|
+
readonly extensions: ReadonlySet<string>;
|
|
122
|
+
}
|
|
123
|
+
/** Why a runtime refused a module (spec section 3.2), in order of precedence. */
|
|
124
|
+
export type PresentationRefusalReason = "presentation_api_unsupported" | "runtime_too_old";
|
|
125
|
+
/** A refused module, as the page reports it. */
|
|
126
|
+
export interface PresentationRefusal {
|
|
127
|
+
readonly id: string;
|
|
128
|
+
readonly presentation_api: string;
|
|
129
|
+
readonly runtime_min: string;
|
|
130
|
+
readonly reason: PresentationRefusalReason;
|
|
131
|
+
/** The extension kinds the module requires: the rows that name it. */
|
|
132
|
+
readonly extensions: readonly string[];
|
|
133
|
+
/** The refusing runtime's version, for the `runtime_too_old` wording. */
|
|
134
|
+
readonly runtimeVersion: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* `module` and `no-presentation` carry every refusal recorded while
|
|
138
|
+
* resolving (section 4.3): modules that matched but that this runtime
|
|
139
|
+
* refused. A non-empty list is never silent: the page names each one.
|
|
140
|
+
*/
|
|
141
|
+
export type PresentationResolution<Model = unknown> = {
|
|
142
|
+
readonly kind: "refusal";
|
|
143
|
+
} | {
|
|
144
|
+
readonly kind: "no-presentation";
|
|
145
|
+
readonly refused: readonly PresentationRefusal[];
|
|
146
|
+
} | {
|
|
147
|
+
readonly kind: "module";
|
|
148
|
+
readonly module: PresentationModule<Model>;
|
|
149
|
+
readonly refused: readonly PresentationRefusal[];
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* The semantics cell of the row of an extension a refused module requires
|
|
153
|
+
* (spec section 3.2), exactly. `covered` is whether the bundle digest covers
|
|
154
|
+
* the block.
|
|
155
|
+
*/
|
|
156
|
+
export declare function presentationRefusalRow(refusal: PresentationRefusal, covered: boolean): string;
|
|
157
|
+
/** The line for a refused module that requires no extension (section 3.2). */
|
|
158
|
+
export declare function presentationRefusalLine(refusal: PresentationRefusal): string;
|
|
159
|
+
/**
|
|
160
|
+
* An extension row as this viewer's verification page draws it: AAC's row
|
|
161
|
+
* (`ExtensionRow`), or the refusal row of section 3.2 in its place. AAC's
|
|
162
|
+
* page model carries no refusals; this registry adds them on top of it.
|
|
163
|
+
*/
|
|
164
|
+
export interface PresentationExtensionRow {
|
|
165
|
+
readonly id: string;
|
|
166
|
+
readonly integrity: "covered" | "not covered";
|
|
167
|
+
/** The interpreter that applied the block; never set on a refusal row. */
|
|
168
|
+
readonly interpreter?: string;
|
|
169
|
+
/**
|
|
170
|
+
* Set when a presentation module that requires this extension matched and
|
|
171
|
+
* this runtime refused it (section 3.2). It takes precedence over
|
|
172
|
+
* `interpreter`: the refused module never ran.
|
|
173
|
+
*/
|
|
174
|
+
readonly refusal?: PresentationRefusal;
|
|
175
|
+
/** AAC's semantics cell, or `presentationRefusalRow` exactly. */
|
|
176
|
+
readonly semantics: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The extension rows with the refusals laid over them: the first refused
|
|
180
|
+
* module (in resolution order) that requires a row's kind replaces that row
|
|
181
|
+
* with its refusal row, whose integrity words follow the row's own
|
|
182
|
+
* `integrity`. Every other row is returned unchanged.
|
|
183
|
+
*/
|
|
184
|
+
export declare function presentationExtensionRows(rows: readonly PresentationExtensionRow[], refused: readonly PresentationRefusal[]): readonly PresentationExtensionRow[];
|
|
185
|
+
/**
|
|
186
|
+
* A refused presentation module that requires no extension, so has no row
|
|
187
|
+
* of its own: the verification page shows `line` after the extension rows
|
|
188
|
+
* (section 3.2).
|
|
189
|
+
*/
|
|
190
|
+
export interface PresentationRefusalNotice {
|
|
191
|
+
readonly id: string;
|
|
192
|
+
readonly reason: PresentationRefusalReason;
|
|
193
|
+
/** `presentationRefusalLine`, exactly. */
|
|
194
|
+
readonly line: string;
|
|
195
|
+
}
|
|
196
|
+
/** The refused modules that have no extension row (section 3.2). */
|
|
197
|
+
export declare function presentationRefusalNotices(refused: readonly PresentationRefusal[]): readonly PresentationRefusalNotice[];
|
|
198
|
+
/** Section 3.2: why `runtime` refuses `manifest`, or undefined. */
|
|
199
|
+
export declare function presentationRefusalReason(manifest: PresentationManifest, runtime?: PresentationRuntime): PresentationRefusalReason | undefined;
|
|
200
|
+
/** Something that resolves a context to one presentation. */
|
|
201
|
+
export interface PresentationResolver {
|
|
202
|
+
resolve(context: VerifiedBundleContext, audience: string, format: PresentationFormat): Promise<PresentationResolution>;
|
|
203
|
+
}
|
|
204
|
+
export declare class PresentationAmbiguityError extends Error {
|
|
205
|
+
readonly ids: readonly string[];
|
|
206
|
+
constructor(ids: readonly string[], message?: string);
|
|
207
|
+
}
|
|
208
|
+
export declare class PresentationRegistrationError extends Error {
|
|
209
|
+
constructor(message: string);
|
|
210
|
+
}
|
|
211
|
+
export { bundleVerified };
|
|
212
|
+
/**
|
|
213
|
+
* The descriptor of spec section 4.2, derived from the context alone. It is
|
|
214
|
+
* a helper, not a context field: the context stays the one verification
|
|
215
|
+
* run, and resolution reads it through this function.
|
|
216
|
+
*
|
|
217
|
+
* - `profiles`: `spec_version:<v>` when the root's `agent_input` is disclosed
|
|
218
|
+
* and carries a string `spec_version`; `result_version:evidence-result-v0`
|
|
219
|
+
* when the root carries an Evidence Result v0 in a disclosed member (the
|
|
220
|
+
* same test `isResultRoot` runs).
|
|
221
|
+
* - `extensions`: every member of the bundle's `extensions` object that the
|
|
222
|
+
* core's reader accepts; a present block its reader declines is absent.
|
|
223
|
+
*/
|
|
224
|
+
export declare function describeContext(context: VerifiedBundleContext): PresentationDescriptor;
|
|
225
|
+
/** Section 4.3 step 2: the declarative match, nothing else. */
|
|
226
|
+
export declare function manifestMatches(manifest: PresentationManifest, descriptor: PresentationDescriptor, audience: string, format: PresentationFormat): boolean;
|
|
227
|
+
/**
|
|
228
|
+
* Section 4.5: true exactly when some descriptor matches both manifests,
|
|
229
|
+
* whatever their tiers (the caller compares tiers).
|
|
230
|
+
*/
|
|
231
|
+
export declare function manifestsCoMatchable(a: PresentationManifest, b: PresentationManifest): boolean;
|
|
232
|
+
/**
|
|
233
|
+
* The structural rules of `$defs/PresentationManifest` a registry relies on,
|
|
234
|
+
* plus the dead-manifest rule of section 4.5. The JSON Schema stays the full
|
|
235
|
+
* definition; this refuses what would make resolution wrong.
|
|
236
|
+
*/
|
|
237
|
+
export declare function manifestProblems(manifest: PresentationManifest): string[];
|
|
238
|
+
/**
|
|
239
|
+
* Section 4.3 over an explicit module list, exactly. Exported so the
|
|
240
|
+
* algorithm can be exercised without a registry's registration test.
|
|
241
|
+
*/
|
|
242
|
+
export declare function resolveModules(modules: readonly PresentationModule[], descriptor: PresentationDescriptor, audience: string, format: PresentationFormat, canRender: (module: PresentationModule) => boolean | Promise<boolean>, refuse?: (module: PresentationModule) => PresentationRefusal | undefined): Promise<PresentationResolution>;
|
|
243
|
+
/** The outcome of {@link PresentationRegistry.register}. */
|
|
244
|
+
export type PresentationRegistration = {
|
|
245
|
+
readonly status: "registered";
|
|
246
|
+
} | {
|
|
247
|
+
readonly status: "refused";
|
|
248
|
+
readonly refusal: PresentationRefusal;
|
|
249
|
+
};
|
|
250
|
+
export declare class PresentationRegistry implements PresentationResolver {
|
|
251
|
+
#private;
|
|
252
|
+
/** `runtime` is what this registry's runtime implements (section 3.2). */
|
|
253
|
+
constructor(runtime?: PresentationRuntime);
|
|
254
|
+
/** The runtime declaration this registry applies. */
|
|
255
|
+
get runtime(): PresentationRuntime;
|
|
256
|
+
/**
|
|
257
|
+
* Register a module. Throws on a malformed or dead manifest (a missing
|
|
258
|
+
* `presentation_api` included), a duplicate id, and any module whose
|
|
259
|
+
* manifest some descriptor could match together with an already
|
|
260
|
+
* registered module of the same tier (section 4.5), refused or not.
|
|
261
|
+
*
|
|
262
|
+
* A well-formed manifest whose `presentation_api` this runtime does not
|
|
263
|
+
* implement, or whose `runtime_min` it does not meet, is registered as
|
|
264
|
+
* refused (section 3.2): never selected, reported by every resolution it
|
|
265
|
+
* matches, and listed by {@link refused}.
|
|
266
|
+
*/
|
|
267
|
+
register(module: PresentationModule): PresentationRegistration;
|
|
268
|
+
/**
|
|
269
|
+
* Every module this registry can select, in registration order (which
|
|
270
|
+
* decides nothing). Refused modules are not here; see {@link refused}.
|
|
271
|
+
*/
|
|
272
|
+
list(): readonly PresentationModule[];
|
|
273
|
+
/** Every module this runtime refused, with the reason. */
|
|
274
|
+
refused(): readonly PresentationRefusal[];
|
|
275
|
+
/** Section 4.3: the one module for this context, audience and format. */
|
|
276
|
+
resolve(context: VerifiedBundleContext, audience: string, format: PresentationFormat): Promise<PresentationResolution>;
|
|
277
|
+
}
|