@sanning/proof 0.19.0 → 0.20.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 +30 -29
- package/dist/agent-record.d.ts +62 -0
- package/dist/agent-record.js +527 -0
- package/dist/agent-schemas.generated.d.ts +15 -0
- package/dist/agent-schemas.generated.js +5759 -0
- package/dist/case-file.d.ts +32 -89
- package/dist/case-file.js +41 -93
- package/dist/case.d.ts +343 -810
- package/dist/case.js +693 -1151
- package/dist/chain.d.ts +19 -47
- package/dist/chain.js +78 -205
- package/dist/claims.d.ts +211 -0
- package/dist/claims.js +1081 -0
- package/dist/cli.d.ts +45 -68
- package/dist/cli.js +618 -1022
- package/dist/compose.js +23 -65
- package/dist/crypto.d.ts +7 -8
- package/dist/crypto.js +60 -147
- package/dist/declaration.d.ts +68 -194
- package/dist/declaration.js +175 -518
- package/dist/environment.d.ts +9 -30
- package/dist/environment.js +17 -66
- package/dist/evidence.d.ts +119 -160
- package/dist/evidence.js +744 -1103
- package/dist/exit-codes.d.ts +11 -27
- package/dist/exit-codes.js +24 -59
- package/dist/file-match.d.ts +33 -79
- package/dist/file-match.js +33 -69
- package/dist/grading.d.ts +98 -135
- package/dist/grading.js +224 -380
- package/dist/handoff.d.ts +62 -160
- package/dist/handoff.js +153 -393
- package/dist/index.d.ts +14 -10
- package/dist/index.js +60 -167
- package/dist/json-schema.d.ts +29 -0
- package/dist/json-schema.js +298 -0
- package/dist/merkle.js +16 -28
- package/dist/message-parts.d.ts +56 -212
- package/dist/message-parts.js +142 -502
- package/dist/side-content.d.ts +11 -22
- package/dist/side-content.js +22 -65
- package/dist/types.d.ts +17 -0
- package/dist/types.js +19 -5
- package/dist/verifier.d.ts +40 -114
- package/dist/verifier.js +196 -535
- package/dist/witness-cache.d.ts +24 -45
- package/dist/witness-cache.js +38 -81
- package/dist/witness-lookup.d.ts +36 -57
- package/dist/witness-lookup.js +89 -139
- package/dist/zip-reader.d.ts +18 -33
- package/dist/zip-reader.js +19 -34
- package/package.json +11 -3
- package/src/agent-record.ts +608 -0
- package/src/agent-schemas.generated.ts +5764 -0
- package/src/case-file.ts +45 -109
- package/src/case.ts +848 -1322
- package/src/chain.ts +85 -224
- package/src/claims.ts +1253 -0
- package/src/cli.ts +714 -1176
- package/src/compose.ts +33 -79
- package/src/crypto.ts +60 -147
- package/src/declaration.ts +219 -656
- package/src/environment.ts +17 -65
- package/src/evidence.ts +958 -1381
- package/src/exit-codes.ts +24 -63
- package/src/file-match.ts +40 -89
- package/src/grading.ts +287 -421
- package/src/handoff.ts +175 -427
- package/src/index.ts +132 -177
- package/src/json-schema.ts +295 -0
- package/src/merkle.ts +16 -28
- package/src/message-parts.ts +155 -533
- package/src/side-content.ts +25 -68
- package/src/types.ts +55 -36
- package/src/verifier.ts +202 -526
- package/src/witness-cache.ts +45 -94
- package/src/witness-lookup.ts +107 -177
- package/src/zip-reader.ts +20 -38
- package/vectors/README.md +52 -34
- package/vectors/agent-record.json +2175 -0
- package/vectors/case-file-index.json +1 -1
- package/vectors/case-split.json +2 -2
- package/vectors/chain-reading.json +3 -3
- package/vectors/file-match.json +285 -148
- package/vectors/jcs-reader.json +6 -6
- package/vectors/pack-grading.json +102 -25
- package/vectors/sandbox-evidence.json +597 -580
- package/vectors/stamp-on-chain.json +18 -18
- package/vectors/witness-cache.json +49 -49
- package/dist/agent-proof.d.ts +0 -28
- package/dist/agent-proof.js +0 -226
- package/dist/run-adapters.d.ts +0 -10
- package/dist/run-adapters.js +0 -35
- package/dist/run.d.ts +0 -209
- package/dist/run.js +0 -1405
- package/src/agent-proof.ts +0 -264
- package/src/run-adapters.ts +0 -44
- package/src/run.ts +0 -1598
package/dist/witness-cache.d.ts
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
*
|
|
4
|
-
* reader cannot print, and reads as none.
|
|
2
|
+
* The largest printable block time, 9999-12-31T23:59:59Z. A larger value reads
|
|
3
|
+
* as no entry.
|
|
5
4
|
*/
|
|
6
5
|
export declare const MAX_BLOCK_TIME = 253402300799;
|
|
7
|
-
/** The file's name, beside `bundle.json`
|
|
6
|
+
/** The file's name, beside `bundle.json` (§5.6.1). */
|
|
8
7
|
export declare const WITNESS_CACHE_NAME = "witness-cache.json";
|
|
9
|
-
/**
|
|
10
|
-
* The dispatch key: a file whose `cache_version` is absent or any other value
|
|
11
|
-
* reads as no cache.
|
|
12
|
-
*/
|
|
8
|
+
/** Any other or absent `cache_version` reads as no cache. */
|
|
13
9
|
export declare const WITNESS_CACHE_VERSION = "sanning.witness-cache/v1";
|
|
14
|
-
/**
|
|
15
|
-
* How deep `[` and `{` may nest in the file before it is refused unread: the
|
|
16
|
-
* limit `bundle.json` and `contents.json` are read under.
|
|
17
|
-
*/
|
|
10
|
+
/** Nesting limit for the file, the same as for `bundle.json` and `contents.json`. */
|
|
18
11
|
export declare const MAX_WITNESS_CACHE_DEPTH = 512;
|
|
19
12
|
/**
|
|
20
|
-
* One `cache.witnessed[]` entry
|
|
21
|
-
* `
|
|
22
|
-
*
|
|
23
|
-
* says WHICH witness it is about.
|
|
13
|
+
* One readable `cache.witnessed[]` entry joined to its stamp. `witnessKind` and
|
|
14
|
+
* `witnessId` come from the signed body, never the cache: the cache says when,
|
|
15
|
+
* the body alone says which witness.
|
|
24
16
|
*/
|
|
25
17
|
export interface CachedWitnessTime {
|
|
26
18
|
stampRef: string;
|
|
@@ -30,11 +22,8 @@ export interface CachedWitnessTime {
|
|
|
30
22
|
witnessId: string;
|
|
31
23
|
}
|
|
32
24
|
/**
|
|
33
|
-
* One gateway's answer for one cached time. `
|
|
34
|
-
*
|
|
35
|
-
* block is not the cached one. `unreachable`: it named no block (a transport
|
|
36
|
-
* failure, a refusal, an answer that is not one, or a witness not yet in a
|
|
37
|
-
* block).
|
|
25
|
+
* One gateway's answer for one cached time. `unreachable` means it named no
|
|
26
|
+
* block: transport failure, refusal, malformed answer, or not yet mined.
|
|
38
27
|
*/
|
|
39
28
|
export interface WitnessTimeAnswer {
|
|
40
29
|
gateway: string;
|
|
@@ -43,10 +32,8 @@ export interface WitnessTimeAnswer {
|
|
|
43
32
|
blockTime: number | null;
|
|
44
33
|
}
|
|
45
34
|
/**
|
|
46
|
-
* One cached time
|
|
47
|
-
*
|
|
48
|
-
* named the cached one, otherwise `not_checked`. The same worst-answer-wins
|
|
49
|
-
* order as the byte lookup.
|
|
35
|
+
* One cached time and the public record's answer: `differs` if any gateway
|
|
36
|
+
* named another block, else `matches` if any named this one, else `not_checked`.
|
|
50
37
|
*/
|
|
51
38
|
export interface WitnessTimeCheck {
|
|
52
39
|
cached: CachedWitnessTime;
|
|
@@ -54,32 +41,24 @@ export interface WitnessTimeCheck {
|
|
|
54
41
|
answers: WitnessTimeAnswer[];
|
|
55
42
|
}
|
|
56
43
|
/**
|
|
57
|
-
* The cached witness times
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* reads only
|
|
61
|
-
* `
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* `block_height` is a non-negative safe integer, and whose `block_time` is a
|
|
65
|
-
* whole number of seconds since 1970-01-01T00:00:00Z from 0 to
|
|
66
|
-
* `MAX_BLOCK_TIME`. A `stamp_ref` two entries name reads for neither.
|
|
67
|
-
* Everything else reads as no cache for the stamp it would have spoken for.
|
|
44
|
+
* The cached witness times `raw` gives for the signed `bundle`, in file order.
|
|
45
|
+
* `raw` is `null` where the pack has no cache file. Pure; never throws.
|
|
46
|
+
*
|
|
47
|
+
* An entry reads only if its `stamp_ref` names exactly one signed stamp with an
|
|
48
|
+
* `anchor_ref`, `block_height` is a non-negative safe integer, and `block_time`
|
|
49
|
+
* is Unix seconds from 0 to `MAX_BLOCK_TIME`. A `stamp_ref` named twice reads
|
|
50
|
+
* for neither.
|
|
68
51
|
*/
|
|
69
52
|
export declare function readWitnessCache(bundle: unknown, raw: Uint8Array | null | undefined): CachedWitnessTime[];
|
|
70
|
-
/** A block time as RFC 3339 UTC to the second
|
|
53
|
+
/** A block time as RFC 3339 UTC to the second: `2026-09-08T12:10:07Z`. */
|
|
71
54
|
export declare function formatBlockTime(seconds: number): string;
|
|
72
55
|
/** `block 1996701 at 2026-09-08T12:10:07Z`. */
|
|
73
56
|
export declare function renderWitnessTime(blockHeight: number, blockTime: number): string;
|
|
74
|
-
/**
|
|
75
|
-
* The request body the lookup sends: one GraphQL query for one transaction's
|
|
76
|
-
* block, as JCS, so both kernels send the same bytes.
|
|
77
|
-
*/
|
|
57
|
+
/** The lookup's request body: one GraphQL query as JCS, so the bytes are fixed. */
|
|
78
58
|
export declare function witnessTimeQuery(witnessId: string): string;
|
|
79
59
|
/**
|
|
80
|
-
*
|
|
81
|
-
* `fetchImpl`,
|
|
82
|
-
*
|
|
83
|
-
* transaction id, is never looked up.
|
|
60
|
+
* Looks each cached time up on every gateway, in order. With no gateways or no
|
|
61
|
+
* `fetchImpl`, every time is `not_checked`. Only `arweave` witnesses with a
|
|
62
|
+
* 43-character base64url id are looked up.
|
|
84
63
|
*/
|
|
85
64
|
export declare function checkWitnessCache(cached: readonly CachedWitnessTime[], gateways: readonly string[], fetchImpl: typeof fetch | undefined): Promise<WitnessTimeCheck[]>;
|
package/dist/witness-cache.js
CHANGED
|
@@ -1,77 +1,44 @@
|
|
|
1
|
-
// The witnessed-time cache
|
|
2
|
-
//
|
|
1
|
+
// The witnessed-time cache (evidence-bundle.md §5.6.6): `witness-cache.json`
|
|
2
|
+
// beside a pack's `bundle.json`, giving the block height and time of each
|
|
3
|
+
// stamp's witness transaction as the pack builder fetched them. Nobody signs it
|
|
4
|
+
// and anyone can edit it, so every member is unverified.
|
|
3
5
|
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
6
|
+
// Trust rules:
|
|
7
|
+
// - `readWitnessCache` is never an input to the bundle verdict, the pack grade
|
|
8
|
+
// or the case reading.
|
|
9
|
+
// - `checkWitnessCache` asks the public record. A different block is a finding
|
|
10
|
+
// (`differs`); an unsettled lookup leaves the value `not_checked`.
|
|
11
|
+
// - Nothing here returns a time a reader may rely on. A gateway is named, never
|
|
12
|
+
// trusted.
|
|
7
13
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// `witnessed`, gives for each stamp the block height and block time of the
|
|
11
|
-
// witness transaction, as the builder of the pack fetched them. Nobody signs
|
|
12
|
-
// it, and anyone holding the pack can edit it. EVERY MEMBER OF THE FILE IS
|
|
13
|
-
// UNVERIFIED BY CONSTRUCTION, and the name carries that warning to every field
|
|
14
|
-
// added to it later.
|
|
15
|
-
//
|
|
16
|
-
// Because it is a separate file, a reader before v1.25 never opens it: it lists
|
|
17
|
-
// it as a file outside every pack and reads the pack exactly as it would
|
|
18
|
-
// without it. A `cache` member written INSIDE `bundle.json` is an unknown
|
|
19
|
-
// wrapper field, counted in the signed scope by every reader, this one
|
|
20
|
-
// included.
|
|
21
|
-
//
|
|
22
|
-
// WHAT THIS MODULE DOES, AND WHAT IT MUST NEVER DO.
|
|
23
|
-
//
|
|
24
|
-
// - `readWitnessCache` reads the file's bytes against the signed bundle beside
|
|
25
|
-
// it. It is pure, and it is never an input to the bundle verdict, the pack
|
|
26
|
-
// grade or the case reading: neither `verifyEvidenceBundle` nor `readCase` is
|
|
27
|
-
// ever handed the file.
|
|
28
|
-
// - `checkWitnessCache` looks each cached time up on the public record, where a
|
|
29
|
-
// caller asked for a lookup. A lookup that answers with a different block is
|
|
30
|
-
// a finding, reported on the witness line as `differs`. A lookup that does
|
|
31
|
-
// not settle leaves the cached value labelled not checked.
|
|
32
|
-
// - Nothing here returns a time a reader may rely on. The only time this module
|
|
33
|
-
// ever reports as the public record's is one a gateway returned, and a
|
|
34
|
-
// gateway is named, never trusted (6).
|
|
35
|
-
//
|
|
36
|
-
// A file that is absent, that is not JSON under the reader's rule, whose
|
|
37
|
-
// `cache_version` is not `WITNESS_CACHE_VERSION`, whose `witnessed` is not a
|
|
38
|
-
// list, or whose entry is not well formed, reads as no cache for what it could
|
|
39
|
-
// not say. It is never a finding and never moves anything.
|
|
14
|
+
// A file that is absent, malformed, of another `cache_version`, or with a bad
|
|
15
|
+
// entry reads as no cache for what it could not say. It is never a finding.
|
|
40
16
|
import { jsonDepthExceeds } from "./case-file.js";
|
|
41
17
|
import { jcs, jcsParse } from "./verifier.js";
|
|
42
18
|
/**
|
|
43
|
-
* The
|
|
44
|
-
*
|
|
45
|
-
* reader cannot print, and reads as none.
|
|
19
|
+
* The largest printable block time, 9999-12-31T23:59:59Z. A larger value reads
|
|
20
|
+
* as no entry.
|
|
46
21
|
*/
|
|
47
22
|
export const MAX_BLOCK_TIME = 253402300799;
|
|
48
|
-
/** The file's name, beside `bundle.json`
|
|
23
|
+
/** The file's name, beside `bundle.json` (§5.6.1). */
|
|
49
24
|
export const WITNESS_CACHE_NAME = "witness-cache.json";
|
|
50
|
-
/**
|
|
51
|
-
* The dispatch key: a file whose `cache_version` is absent or any other value
|
|
52
|
-
* reads as no cache.
|
|
53
|
-
*/
|
|
25
|
+
/** Any other or absent `cache_version` reads as no cache. */
|
|
54
26
|
export const WITNESS_CACHE_VERSION = "sanning.witness-cache/v1";
|
|
55
|
-
/**
|
|
56
|
-
* How deep `[` and `{` may nest in the file before it is refused unread: the
|
|
57
|
-
* limit `bundle.json` and `contents.json` are read under.
|
|
58
|
-
*/
|
|
27
|
+
/** Nesting limit for the file, the same as for `bundle.json` and `contents.json`. */
|
|
59
28
|
export const MAX_WITNESS_CACHE_DEPTH = 512;
|
|
60
29
|
// The bodies that carry `stamps[]`, the only witnesses the cache speaks for.
|
|
61
30
|
const STAMP_BODIES = new Set(["sanning.stamp.trace/v1", "sanning.stamp.evidence/v2"]);
|
|
62
31
|
const STAMP_REF = /^[0-9a-f]{64}$/;
|
|
63
|
-
// The
|
|
64
|
-
//
|
|
32
|
+
// The only witness kind and id shape a lookup sends, as for the byte lookup
|
|
33
|
+
// (evidence-bundle §5.1.1).
|
|
65
34
|
const ADAPTER_KIND = "arweave";
|
|
66
35
|
const ARWEAVE_ID = /^[A-Za-z0-9_-]{43}$/;
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
// the two kernels on one reading of it.
|
|
36
|
+
// An answer for one transaction is a few hundred bytes. Refusing a deeper one
|
|
37
|
+
// before parsing keeps every reader on the same result.
|
|
70
38
|
const MAX_ANSWER_DEPTH = 16;
|
|
71
39
|
function isObject(v) {
|
|
72
40
|
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
73
41
|
}
|
|
74
|
-
// A member the object itself holds, never one inherited from its prototype.
|
|
75
42
|
function own(o, key) {
|
|
76
43
|
return Object.prototype.hasOwnProperty.call(o, key) ? o[key] : undefined;
|
|
77
44
|
}
|
|
@@ -82,8 +49,8 @@ function blockNumber(value, upper) {
|
|
|
82
49
|
return null;
|
|
83
50
|
return value;
|
|
84
51
|
}
|
|
85
|
-
// `stamp_ref` to `[kind, id]` for
|
|
86
|
-
//
|
|
52
|
+
// `stamp_ref` to `[kind, id]` for each signed stamp that names a witness. A
|
|
53
|
+
// `stamp_ref` on two stamps names neither.
|
|
87
54
|
function stampWitnesses(bundle) {
|
|
88
55
|
const out = new Map();
|
|
89
56
|
if (typeof bundle.body_type !== "string" || !STAMP_BODIES.has(bundle.body_type))
|
|
@@ -113,10 +80,8 @@ function stampWitnesses(bundle) {
|
|
|
113
80
|
}
|
|
114
81
|
return out;
|
|
115
82
|
}
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
// twice, and nothing nested past `MAX_WITNESS_CACHE_DEPTH`. `undefined` for
|
|
119
|
-
// anything else.
|
|
83
|
+
// Strict JSON as for `contents.json` (§5.6.2), within `MAX_WITNESS_CACHE_DEPTH`.
|
|
84
|
+
// `undefined` for anything else.
|
|
120
85
|
function readFile(raw) {
|
|
121
86
|
if (!(raw instanceof Uint8Array))
|
|
122
87
|
return undefined;
|
|
@@ -130,17 +95,13 @@ function readFile(raw) {
|
|
|
130
95
|
}
|
|
131
96
|
}
|
|
132
97
|
/**
|
|
133
|
-
* The cached witness times
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* reads only
|
|
137
|
-
* `
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* `block_height` is a non-negative safe integer, and whose `block_time` is a
|
|
141
|
-
* whole number of seconds since 1970-01-01T00:00:00Z from 0 to
|
|
142
|
-
* `MAX_BLOCK_TIME`. A `stamp_ref` two entries name reads for neither.
|
|
143
|
-
* Everything else reads as no cache for the stamp it would have spoken for.
|
|
98
|
+
* The cached witness times `raw` gives for the signed `bundle`, in file order.
|
|
99
|
+
* `raw` is `null` where the pack has no cache file. Pure; never throws.
|
|
100
|
+
*
|
|
101
|
+
* An entry reads only if its `stamp_ref` names exactly one signed stamp with an
|
|
102
|
+
* `anchor_ref`, `block_height` is a non-negative safe integer, and `block_time`
|
|
103
|
+
* is Unix seconds from 0 to `MAX_BLOCK_TIME`. A `stamp_ref` named twice reads
|
|
104
|
+
* for neither.
|
|
144
105
|
*/
|
|
145
106
|
export function readWitnessCache(bundle, raw) {
|
|
146
107
|
if (!isObject(bundle))
|
|
@@ -172,7 +133,7 @@ export function readWitnessCache(bundle, raw) {
|
|
|
172
133
|
}
|
|
173
134
|
return read.filter((c) => named.get(c.stampRef) === 1);
|
|
174
135
|
}
|
|
175
|
-
/** A block time as RFC 3339 UTC to the second
|
|
136
|
+
/** A block time as RFC 3339 UTC to the second: `2026-09-08T12:10:07Z`. */
|
|
176
137
|
export function formatBlockTime(seconds) {
|
|
177
138
|
return new Date(seconds * 1000).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
178
139
|
}
|
|
@@ -180,10 +141,7 @@ export function formatBlockTime(seconds) {
|
|
|
180
141
|
export function renderWitnessTime(blockHeight, blockTime) {
|
|
181
142
|
return `block ${blockHeight} at ${formatBlockTime(blockTime)}`;
|
|
182
143
|
}
|
|
183
|
-
/**
|
|
184
|
-
* The request body the lookup sends: one GraphQL query for one transaction's
|
|
185
|
-
* block, as JCS, so both kernels send the same bytes.
|
|
186
|
-
*/
|
|
144
|
+
/** The lookup's request body: one GraphQL query as JCS, so the bytes are fixed. */
|
|
187
145
|
export function witnessTimeQuery(witnessId) {
|
|
188
146
|
return jcs({ query: `query{transaction(id:"${witnessId}"){block{height timestamp}}}` });
|
|
189
147
|
}
|
|
@@ -235,10 +193,9 @@ async function ask(cached, gateway, fetchImpl) {
|
|
|
235
193
|
return { gateway, outcome: same ? "matches" : "differs", blockHeight: height, blockTime: time };
|
|
236
194
|
}
|
|
237
195
|
/**
|
|
238
|
-
*
|
|
239
|
-
* `fetchImpl`,
|
|
240
|
-
*
|
|
241
|
-
* transaction id, is never looked up.
|
|
196
|
+
* Looks each cached time up on every gateway, in order. With no gateways or no
|
|
197
|
+
* `fetchImpl`, every time is `not_checked`. Only `arweave` witnesses with a
|
|
198
|
+
* 43-character base64url id are looked up.
|
|
242
199
|
*/
|
|
243
200
|
export async function checkWitnessCache(cached, gateways, fetchImpl) {
|
|
244
201
|
const out = [];
|
package/dist/witness-lookup.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { EvidenceBundleResult } from "./evidence.js";
|
|
1
2
|
import type { WitnessLine, WitnessState } from "./case.js";
|
|
2
3
|
import { type CachedWitnessTime, type WitnessTimeAnswer, type WitnessTimeCheck } from "./witness-cache.js";
|
|
3
|
-
/** The seam every network call
|
|
4
|
+
/** The seam every network call goes through: the caller's `fetch` if given, else the ambient global. */
|
|
4
5
|
export interface WitnessLookupOptions {
|
|
5
6
|
fetchImpl?: typeof fetch;
|
|
6
7
|
}
|
|
@@ -11,13 +12,9 @@ export interface OnChainRow {
|
|
|
11
12
|
mismatched: number;
|
|
12
13
|
unreachable: number;
|
|
13
14
|
not_checked: number;
|
|
14
|
-
/**
|
|
15
|
-
* How many of the `not_checked` witnesses are simulated: a sandbox plane's
|
|
16
|
-
* stand-in for a chain, never looked up. Present only where there
|
|
17
|
-
* is one, so a production pack's row is unchanged.
|
|
18
|
-
*/
|
|
15
|
+
/** How many of the `not_checked` witnesses are simulated (a sandbox plane's stand-in for a chain, never looked up). Present only where there is one. */
|
|
19
16
|
simulated?: number;
|
|
20
|
-
/** Present only where the pack caches a witness time (5.6.6
|
|
17
|
+
/** Present only where the pack caches a witness time (5.6.6). */
|
|
21
18
|
witness_times?: WitnessTimeRow[];
|
|
22
19
|
}
|
|
23
20
|
export interface WitnessTimeRow {
|
|
@@ -40,46 +37,37 @@ export interface OnChainHalf {
|
|
|
40
37
|
checked: boolean;
|
|
41
38
|
gateways: string[];
|
|
42
39
|
packs: OnChainRow[];
|
|
43
|
-
verdict: "not_checked" | "confirmed" | "
|
|
40
|
+
verdict: "not_checked" | "confirmed" | "differs" | "not_settled";
|
|
44
41
|
}
|
|
42
|
+
/** One pack's witnesses as a lookup left them: how many, and each one's rollup. */
|
|
43
|
+
export declare function onChainRow(ref: string, result: EvidenceBundleResult): {
|
|
44
|
+
row: OnChainRow;
|
|
45
|
+
answered: Set<string>;
|
|
46
|
+
};
|
|
45
47
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* does the verify page's case reading, so the case verdict stays the one both
|
|
49
|
-
* surfaces compute. This adds the half the reading names as not checked.
|
|
50
|
-
*
|
|
51
|
-
* Moved from `cli.ts` unchanged, apart from taking `fetchImpl` directly
|
|
52
|
-
* instead of a `Cli` stream (`io.fetchImpl ?? fetch`, the same fallback the
|
|
53
|
-
* CLI already applied at its own call site).
|
|
48
|
+
* `differs` where a lookup found other bytes or another time, `not_settled` where one
|
|
49
|
+
* did not settle, `confirmed` otherwise. Only `differs` moves a verdict.
|
|
54
50
|
*/
|
|
55
|
-
export declare function
|
|
51
|
+
export declare function onChainOutcome(rows: readonly OnChainRow[]): "differs" | "not_settled" | "confirmed";
|
|
56
52
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
53
|
+
* Each pack's witnesses, re-fetched through `verifyEvidenceBundle`. Outside the
|
|
54
|
+
* case reading on purpose: `readCase` makes no network call, so the case verdict
|
|
55
|
+
* is the same on every surface. This adds the half the reading names as not checked.
|
|
60
56
|
*/
|
|
61
|
-
|
|
57
|
+
export declare function onChainHalf(packs: readonly (readonly [string, unknown, readonly CachedWitnessTime[]])[], gateways: readonly string[], options?: WitnessLookupOptions): Promise<OnChainHalf>;
|
|
62
58
|
/**
|
|
63
|
-
* `cached` is every witness time the packs cache (5.6.6
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* Moved from `cli.ts` unchanged: same inputs, same three states
|
|
70
|
-
* (`WitnessState`), same rendering. The CLI's `case` command still calls this
|
|
71
|
-
* exact function, so its witness line is unchanged.
|
|
59
|
+
* `cached` is every witness time the packs cache (5.6.6). Where no lookup ran,
|
|
60
|
+
* each is printed labelled not checked. Where one ran, each time the public
|
|
61
|
+
* record matched is printed as the record's, each time no lookup settled stays
|
|
62
|
+
* labelled not checked, and a time the record contradicts makes the line read
|
|
63
|
+
* `differs`.
|
|
72
64
|
*/
|
|
73
65
|
export declare function witnessLine(onChain: OnChainHalf, cached?: readonly CachedWitnessTime[]): WitnessLine;
|
|
74
|
-
/** The
|
|
66
|
+
/** The states a lookup can carry: the CLI's `WitnessState` plus `no_public_record`. */
|
|
75
67
|
export type PublicRecordState = WitnessState | "no_public_record";
|
|
76
68
|
/**
|
|
77
|
-
* One pack
|
|
78
|
-
*
|
|
79
|
-
* of the pack, per proof#200's acceptance criteria, rather than as a
|
|
80
|
-
* separately-loaded side file. `null` and `undefined` both mean "this pack has
|
|
81
|
-
* no witness-cache.json", the same reading `readWitnessCache` gives a missing
|
|
82
|
-
* file.
|
|
69
|
+
* One pack: the parsed `bundle.json` and, where it has one, the raw bytes of its
|
|
70
|
+
* `witness-cache.json`. `null` and `undefined` both mean no cache file.
|
|
83
71
|
*/
|
|
84
72
|
export interface PublicRecordPack {
|
|
85
73
|
/** How this pack is named in the result; carries no meaning beyond that. */
|
|
@@ -91,34 +79,25 @@ export interface PublicRecordResult {
|
|
|
91
79
|
state: PublicRecordState;
|
|
92
80
|
reasons: string[];
|
|
93
81
|
services: string[];
|
|
94
|
-
/** Witness times a pack caches that no lookup settled (5.6.6
|
|
82
|
+
/** Witness times a pack caches that no lookup settled (5.6.6). */
|
|
95
83
|
cached?: [number, number][];
|
|
96
84
|
/** Witness times the public record returned that matched a pack's cache. */
|
|
97
85
|
recorded?: [number, number][];
|
|
98
|
-
/** The line as
|
|
86
|
+
/** The line as the CLI and a page print it. */
|
|
99
87
|
rendered: string;
|
|
100
88
|
}
|
|
101
89
|
/**
|
|
102
|
-
* The public-record lookup the CLI runs with `--gateways`,
|
|
103
|
-
* consumer that is not the CLI can run the SAME lookup rather than copy it
|
|
104
|
-
* (proof#200; the copy this closes is verify-page#70's `src/lib/verify.ts`).
|
|
90
|
+
* The public-record lookup the CLI runs with `--gateways`, for non-CLI callers.
|
|
105
91
|
*
|
|
106
|
-
* `packs` is every pack in the drop
|
|
107
|
-
*
|
|
108
|
-
* `not_checked` or `no_public_record`. `options.fetchImpl` is the one seam a
|
|
109
|
-
* network call goes through, a browser page supplies its own `fetchImpl`;
|
|
110
|
-
* with none given this falls back to the ambient global `fetch`, so a
|
|
111
|
-
* browser page and a test can each supply their own and Node's `fetch` is
|
|
112
|
-
* never assumed where a caller passed something else.
|
|
92
|
+
* `packs` is every pack in the drop; `gateways` is empty for an offline reading,
|
|
93
|
+
* which makes no network call and answers `not_checked` or `no_public_record`.
|
|
113
94
|
*
|
|
114
|
-
* `state` is `confirmed` only about the
|
|
115
|
-
* pack names. It says nothing about whether the pack itself verifies
|
|
116
|
-
*
|
|
117
|
-
* `confirmed` apart from the pack's own verdict (proof#201).
|
|
95
|
+
* `state` is `confirmed` only about the bytes: the public record holds what a
|
|
96
|
+
* pack names. It says nothing about whether the pack itself verifies, so a
|
|
97
|
+
* caller must never show `confirmed` apart from the pack's own verdict.
|
|
118
98
|
*
|
|
119
|
-
* Never throws. Every input
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* `not_checked` rather than escape as an exception.
|
|
99
|
+
* Never throws. Every input (a malformed pack, a non-string gateway, a
|
|
100
|
+
* misbehaving `fetchImpl`) is untrusted, and anything it cannot make sense of
|
|
101
|
+
* settles as `not_checked`.
|
|
123
102
|
*/
|
|
124
103
|
export declare function lookupPublicRecord(packs: readonly PublicRecordPack[], gateways: readonly string[], options?: WitnessLookupOptions): Promise<PublicRecordResult>;
|