@sanning/proof 0.12.0 → 0.13.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.
Files changed (48) hide show
  1. package/README.md +25 -12
  2. package/dist/agent-proof.d.ts +2 -2
  3. package/dist/agent-proof.js +4 -4
  4. package/dist/case-file.d.ts +126 -0
  5. package/dist/case-file.js +349 -0
  6. package/dist/case.d.ts +173 -26
  7. package/dist/case.js +469 -123
  8. package/dist/cli.d.ts +38 -5
  9. package/dist/cli.js +557 -208
  10. package/dist/crypto.d.ts +1 -1
  11. package/dist/crypto.js +5 -1
  12. package/dist/declaration.d.ts +58 -52
  13. package/dist/declaration.js +256 -33
  14. package/dist/evidence.d.ts +2 -0
  15. package/dist/evidence.js +134 -19
  16. package/dist/exit-codes.d.ts +17 -0
  17. package/dist/exit-codes.js +50 -0
  18. package/dist/grading.d.ts +28 -13
  19. package/dist/grading.js +90 -31
  20. package/dist/index.d.ts +10 -7
  21. package/dist/index.js +13 -6
  22. package/dist/message-parts.d.ts +11 -9
  23. package/dist/message-parts.js +11 -9
  24. package/dist/types.d.ts +1 -0
  25. package/dist/verifier.d.ts +9 -2
  26. package/dist/verifier.js +28 -12
  27. package/dist/zip-reader.d.ts +50 -0
  28. package/dist/zip-reader.js +220 -0
  29. package/package.json +2 -2
  30. package/src/agent-proof.ts +4 -4
  31. package/src/case-file.ts +419 -0
  32. package/src/case.ts +586 -132
  33. package/src/cli.ts +651 -206
  34. package/src/crypto.ts +5 -1
  35. package/src/declaration.ts +248 -52
  36. package/src/evidence.ts +142 -21
  37. package/src/exit-codes.ts +54 -0
  38. package/src/grading.ts +109 -52
  39. package/src/index.ts +58 -2
  40. package/src/message-parts.ts +11 -9
  41. package/src/types.ts +5 -0
  42. package/src/verifier.ts +35 -13
  43. package/src/zip-reader.ts +229 -0
  44. package/vectors/README.md +23 -5
  45. package/vectors/case-file-index.json +668 -0
  46. package/vectors/case-split.json +218 -9
  47. package/vectors/pack-grading.json +68 -4
  48. package/vectors/stamp-on-chain.json +3 -3
package/dist/cli.d.ts CHANGED
@@ -1,10 +1,15 @@
1
1
  #!/usr/bin/env node
2
+ import { type WitnessLine } from "./case.js";
2
3
  interface Cli {
3
4
  out: (s: string) => void;
4
5
  err: (s: string) => void;
5
6
  fetchImpl?: typeof fetch;
6
7
  }
7
- export declare function runCli(argv: string[], io: Cli): Promise<number>;
8
+ /** Each control character in `text` as a visible escape: `\x1b` for ESC,
9
+ * `\u202e` for RIGHT-TO-LEFT OVERRIDE. Every other character is unchanged, a
10
+ * backslash included, so a line with none is printed as it was. */
11
+ export declare function escapeControl(text: string): string;
12
+ export declare function runCli(argv: string[], stream: Cli): Promise<number>;
8
13
  /** The error text for an input with no pack in it, word for word the page's. */
9
14
  export declare const NO_BUNDLE = "No bundle.json found. An evidence pack contains bundle.json plus logs/.";
10
15
  /** A directory nested deeper than this below an argument refuses the input. */
@@ -64,9 +69,15 @@ export interface SplitCase {
64
69
  }
65
70
  /** One name the walk found that is not a directory. */
66
71
  export interface TreeEntry {
72
+ /** Where it sits on disk. Empty for an entry read out of a case-file `.zip`. */
67
73
  fsPath: string;
68
- /** `true` for a regular file; `false` for a link or anything else. */
74
+ /**
75
+ * `true` for a regular file; `false` for a link or anything else, including a
76
+ * `.zip` entry the reader refused.
77
+ */
69
78
  regular: boolean;
79
+ /** The bytes of an entry read out of a case-file `.zip`. */
80
+ data?: Uint8Array | null;
70
81
  }
71
82
  /**
72
83
  * The page's `splitCase` followed by its `assemble` per pack, over the walk's
@@ -88,8 +99,30 @@ export declare function readFileEntry(entry: TreeEntry, key: string): Promise<Ui
88
99
  * with the way through.
89
100
  */
90
101
  export declare function treeFromArguments(paths: readonly string[]): Promise<Map<string, TreeEntry>>;
91
- export declare const CASE_EXIT_CODES: Readonly<Record<string, number>>;
92
- export declare const CASE_USAGE = "sanning-proof case -- one verdict over several evidence packs, offline\n\n sanning-proof case <folder>... [--gateways <url,url>] [--json]\n\n <folder> a pack folder (bundle.json plus logs/), or a folder that holds\n several packs, such as an unpacked decision file. case reads\n folders only: given a .zip, it exits 2 and says to unzip it\n first (for example, unzip file.zip -d case/) and pass the folder.\n Packs are found by the verify page's splitting rule: every\n bundle.json is a pack, a file belongs to the deepest pack whose\n bundle.json or logs/ it sits in, and every other file is listed\n as outside every pack and never opened. A .zip inside a folder is\n a file like any other. A symbolic link is never followed: it is\n listed as outside and not read, even under a pack's logs/.\n Several folders are read as one folder holding them, each under\n its own name. A folder nested more than 32 levels deep, more than\n 50000 files and folders in all, or a name that is not valid UTF-8\n exits 2.\n --gateways comma-separated gateway URLs. Each pack's witnesses are then\n re-fetched on chain, pack by pack, and reported beside the case\n reading. Without it the on-chain half is NOT checked, and the\n output says so.\n --json the full reading as JSON: the verdict, every exception with its\n rendered line, every record, every contribution, the packs, the\n files outside them, and the on-chain half.\n\nEach pack's bundle.json is read as verify reads it, so the two commands\nclassify one bundle the same way.\n\nWhat a case reading establishes: every pack is verified offline by this\nkernel; every record every pack supplied is read, in one pile, under the\nhand-off rules of envelope-spec section 4.1; a hand-off record with no\ncounterpart among the case's records is always named, and when a pack signed by\nthe key it names is in the case, the reading says that pack holds none, unless\nevery candidate it had was accounted for by another record (A20), which reads\nas no counterpart and names no pack.\n\nWhat it does not establish: that the case is complete (a party can decline to\nhand over a pack); that a party which presented no pack under the named key\nrecorded nothing; that two organizations are independent of each other; or\nthat any witness was re-fetched on chain, which the reading never does.\n\nExit codes: 0 verified \u00B7 1 failed \u00B7 2 malformed, usage, an input that cannot\nbe read as a case, or an unexpected error in this command \u00B7 3 incomplete or\npartial (undetermined, not failed) \u00B7 4 mixed (more than one outcome: read the\nexceptions). With --gateways, a witness that does not match on chain exits 1,\nand an on-chain half that could not be settled turns 0 into 3.";
102
+ export declare const CASE_USAGE: string;
103
+ interface OnChainRow {
104
+ ref: string;
105
+ witnesses: number;
106
+ confirmed: number;
107
+ mismatched: number;
108
+ unreachable: number;
109
+ not_checked: number;
110
+ }
111
+ interface OnChainHalf {
112
+ /** Present only where a lookup ran: each gateway that answered, in the order given. */
113
+ answered?: string[];
114
+ checked: boolean;
115
+ gateways: string[];
116
+ packs: OnChainRow[];
117
+ verdict: "not_checked" | "confirmed" | "failed" | "undetermined";
118
+ }
119
+ /**
120
+ * The witness line (evidence-bundle 5.5.6 v1.20, A24, D7) from the on-chain
121
+ * half: `confirmed` is `confirmed`, `not_checked` and `undetermined` are
122
+ * `not_checked` with the reason, and `failed` is `differs`. It never moves the
123
+ * headline.
124
+ */
125
+ export declare function witnessLine(onChain: OnChainHalf): WitnessLine;
93
126
  /**
94
127
  * The case verdict's code, moved only by an on-chain half that was asked for:
95
128
  * a witness that does not match is a failure whatever the reading said, and an
@@ -102,5 +135,5 @@ export declare function caseExitCode(verdict: string, onChainVerdict: string): n
102
135
  * never 1, because 1 would name the evidence failed over a defect in this
103
136
  * command.
104
137
  */
105
- export declare function runCase(argv: readonly string[], io: Cli): Promise<number>;
138
+ export declare function runCase(argv: readonly string[], stream: Cli): Promise<number>;
106
139
  export {};