@pacspace-io/check 0.5.5 → 0.6.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/CHANGELOG.md +27 -1
- package/README.md +36 -2
- package/dist/check.d.ts +6 -1
- package/dist/cli.d.ts +5 -1
- package/dist/cli.js +2496 -380
- package/dist/index.js +518 -91
- package/dist/inputs.txt +12 -0
- package/dist/open-io.d.ts +38 -0
- package/dist/open.d.ts +16 -15
- package/dist/records-crypto-types/records/flag-threads-v1.d.ts +53 -0
- package/dist/records-crypto-types/records/labels.d.ts +37 -0
- package/dist/records-crypto-types/records/link-handle-v1.d.ts +16 -0
- package/dist/records-crypto-types/records/reader-crypto-v1.d.ts +198 -0
- package/dist/records-crypto-types/records/reader-link-v1.d.ts +164 -0
- package/dist/records-crypto-types/records/shared-record-ack-v2.d.ts +72 -0
- package/dist/records-crypto-types/records/trail-index-v1.d.ts +89 -0
- package/dist/records-crypto-types/records/trail-rule.d.ts +54 -0
- package/dist/records-crypto-types/records-crypto/asymmetric/ack-flag-notes-v1.d.ts +57 -0
- package/dist/records-crypto-types/records-crypto/asymmetric/flag-notes-v1.d.ts +55 -0
- package/dist/records-crypto-types/records-crypto/asymmetric/index.d.ts +3 -0
- package/dist/records-crypto-types/records-crypto/asymmetric/reader-wraps-v1.d.ts +83 -0
- package/dist/records-crypto-types/records-crypto/disclosure-envelope-v1.d.ts +1 -1
- package/dist/records-crypto-types/records-crypto/index.d.ts +1 -1
- package/dist/records-crypto-types/records-crypto/records-encryption-v1.d.ts +1 -0
- package/dist/records-crypto.js +547 -66
- package/dist/report.d.ts +20 -1
- package/dist/shared-record-link.d.ts +121 -0
- package/dist/shared-record-words.d.ts +97 -0
- package/package.json +1 -1
package/dist/report.d.ts
CHANGED
|
@@ -113,7 +113,11 @@ export interface CheckReport {
|
|
|
113
113
|
/** Entry numbers (1-based) that do not match what was committed. */
|
|
114
114
|
unmatched: number[];
|
|
115
115
|
};
|
|
116
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* True only when this report's `exitCode` is 0: the check passed as asked. False when the proof layer was not
|
|
118
|
+
* read (exit code 3) and when anything asked for did not match (exit code 1): an entry, the proof layer, a
|
|
119
|
+
* daily statement under `--full`, the statement fingerprint given, or the file you hold.
|
|
120
|
+
*/
|
|
117
121
|
passed: boolean;
|
|
118
122
|
file: {
|
|
119
123
|
/** The history's fingerprint as the file carries it, or as recomputed when the file carries none. */
|
|
@@ -252,7 +256,20 @@ export declare const FILE_CHANGED_SENTENCE = "This file has been changed since i
|
|
|
252
256
|
export declare function fingerprintSentence(intact: boolean, given: CheckReport['statementFingerprint']): string | null;
|
|
253
257
|
/** W-C4, W-C5 or W-C8, then W-C9 when the ledger was not read. */
|
|
254
258
|
export declare function heldFileSentences(held: HeldFileOutcome): string[];
|
|
259
|
+
/**
|
|
260
|
+
* A report with the narrower fact the checker's own commands read: whether every entry the record has is in the
|
|
261
|
+
* file and matches what was committed, and the proof layer, where it was compared, agrees. It says nothing of a
|
|
262
|
+
* daily statement, a statement fingerprint or a held file, and it is true beside a proof layer that was not read.
|
|
263
|
+
* Internal: `release`, `evidence` and the lookup of where entries were committed read `entriesMatch`; the
|
|
264
|
+
* package exports only the report, whose `passed` follows its exit code.
|
|
265
|
+
*/
|
|
266
|
+
export interface ReportWithFacts {
|
|
267
|
+
report: CheckReport;
|
|
268
|
+
entriesMatch: boolean;
|
|
269
|
+
}
|
|
255
270
|
export declare function buildReport(input: ReportInput): CheckReport;
|
|
271
|
+
/** Internal; see `ReportWithFacts`. */
|
|
272
|
+
export declare function buildReportWithFacts(input: ReportInput): ReportWithFacts;
|
|
256
273
|
export interface SealsReportInput {
|
|
257
274
|
checker: {
|
|
258
275
|
name: string;
|
|
@@ -274,6 +291,8 @@ export interface SealsReportInput {
|
|
|
274
291
|
}
|
|
275
292
|
/** A seal history's report, alone or in a kept copy, with any disclosure checked against it. */
|
|
276
293
|
export declare function buildSealsReport(input: SealsReportInput): CheckReport;
|
|
294
|
+
/** Internal; see `ReportWithFacts`. Here `entriesMatch` also needs any disclosure to have verified. */
|
|
295
|
+
export declare function buildSealsReportWithFacts(input: SealsReportInput): ReportWithFacts;
|
|
277
296
|
export declare const WRITES_HEADING = "Where each entry was committed on the proof layer:";
|
|
278
297
|
export declare const WRITES_NOT_READ_SENTENCE = "Where each entry was committed could not be read from the proof layer this time. The check above does not depend on it.";
|
|
279
298
|
/** The text report lists at most this many writes; `--json` lists all. */
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { type SharedRecordAddressV1, type SharedRecordCheckV1, type SharedRecordCopyV1, type SharedRecordPaceOptionsV1, type SharedRecordProofLayerV1 } from '@pacspace/shared';
|
|
2
|
+
import { type CheckOptions } from './check';
|
|
3
|
+
import type { CliIo } from './cli';
|
|
4
|
+
/**
|
|
5
|
+
* A Shared Record link with a list of records (ADR 0021), read from its host and checked by the one check the
|
|
6
|
+
* Shared Record page runs (`checkSharedRecordV1`), and a kept copy of one checked again.
|
|
7
|
+
*
|
|
8
|
+
* Every request for a link goes to one origin, and no redirect is followed. The code goes to that origin's open
|
|
9
|
+
* route once: a code it refuses is never sent again, because five wrong codes stop the link's code for everyone.
|
|
10
|
+
* The session it answers with is a bearer token kept in memory, sent only to that origin, and signed out when the
|
|
11
|
+
* run ends. The part of the address after `#` never leaves this machine.
|
|
12
|
+
*/
|
|
13
|
+
/** The key host serves files only, so its links are read from the app host: the one pair built in. Production's. */
|
|
14
|
+
export declare const KEY_HOST = "records.pacspace.io";
|
|
15
|
+
export declare const KEY_HOST_READS_FROM = "https://app.pacspace.io";
|
|
16
|
+
export interface LinkOrigin {
|
|
17
|
+
/** The host in the address the reader gave. */
|
|
18
|
+
addressHost: string;
|
|
19
|
+
/** The origin every request goes to. */
|
|
20
|
+
origin: string;
|
|
21
|
+
host: string;
|
|
22
|
+
/** Whether that origin is PacSpace's. Any other is named as not PacSpace's before the code and beside the result. */
|
|
23
|
+
pacspace: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function linkOriginOf(address: Pick<SharedRecordAddressV1, 'host' | 'origin'>): LinkOrigin;
|
|
26
|
+
export interface ProofLayerOptions {
|
|
27
|
+
source: CheckOptions['source'];
|
|
28
|
+
full: boolean;
|
|
29
|
+
timeoutMs: number | undefined;
|
|
30
|
+
fetchImpl: typeof fetch | undefined;
|
|
31
|
+
/** The pace's clock and wait, when the run is given its own. */
|
|
32
|
+
pace?: Pick<SharedRecordPaceOptionsV1, 'now' | 'sleep'>;
|
|
33
|
+
}
|
|
34
|
+
/** The pace's clock and wait as a run's `io` gives them: timers and the machine's clock unless it does. */
|
|
35
|
+
export declare const paceOf: (io: Pick<CliIo, "now" | "sleep">) => ProofLayerOptions["pace"];
|
|
36
|
+
/**
|
|
37
|
+
* The reader for a row's network and contract, or null when the checker has no source for that network.
|
|
38
|
+
*
|
|
39
|
+
* Every mirror reader of a run asks through one paced `fetch`, so the run starts no more than the check's pace of
|
|
40
|
+
* requests a second to one source, whichever contract or record asked. An RPC endpoint is the reader's own, named
|
|
41
|
+
* with `--rpc`, and is asked as its answers come.
|
|
42
|
+
*/
|
|
43
|
+
export declare function proofLayerFor(options: ProofLayerOptions): (chain: {
|
|
44
|
+
chainId: number;
|
|
45
|
+
contractAddress: string;
|
|
46
|
+
}) => SharedRecordProofLayerV1 | null;
|
|
47
|
+
/** One answer of the link's host is read no further than this: twice the most a link's reveals come to. */
|
|
48
|
+
export declare const LINK_ANSWER_MAX_BYTES: number;
|
|
49
|
+
/** Everything a run reads from the link's host: what a kept copy may hold. */
|
|
50
|
+
export declare const LINK_RUN_MAX_BYTES = 67108864;
|
|
51
|
+
/** At most four requests a second to the link's host, under its limit of 300 a minute. */
|
|
52
|
+
export declare const LINK_GAP_MS = 250;
|
|
53
|
+
/** A 429 from the link's host is waited out this many times for one read, each wait no longer than a minute. */
|
|
54
|
+
export declare const LINK_WAITS = 3;
|
|
55
|
+
export declare const LINK_WAIT_MAX_MS = 60000;
|
|
56
|
+
/** A read of the link's host, when `--timeout` is not given: a page of reveals is megabytes. */
|
|
57
|
+
export declare const LINK_TIMEOUT_MS = 30000;
|
|
58
|
+
export declare const LINK_REPORT_SCHEMA: "pacspace-check-link-report/v1";
|
|
59
|
+
export interface LinkReport {
|
|
60
|
+
schema: typeof LINK_REPORT_SCHEMA;
|
|
61
|
+
checker: {
|
|
62
|
+
name: string;
|
|
63
|
+
version: string;
|
|
64
|
+
};
|
|
65
|
+
/** Where the link was read from; null for a kept copy, which is read from its file. */
|
|
66
|
+
link: {
|
|
67
|
+
host: string;
|
|
68
|
+
readFrom: string;
|
|
69
|
+
pacspace: boolean;
|
|
70
|
+
} | null;
|
|
71
|
+
/** True only when `exitCode` is 0: the list is the address's, or a copy's was not compared, and every record matches. */
|
|
72
|
+
passed: boolean;
|
|
73
|
+
check: Omit<SharedRecordCheckV1, 'kept'>;
|
|
74
|
+
sentences: string[];
|
|
75
|
+
/** 0 every record matches; 1 the link or a record fails; 3 the link or a record was not checked and none fails. */
|
|
76
|
+
exitCode: 0 | 1 | 3;
|
|
77
|
+
}
|
|
78
|
+
/** At most this many records are listed under each heading of the text report; `--json` lists all. */
|
|
79
|
+
export declare const RECORDS_LISTED_MAX = 25;
|
|
80
|
+
/** The sentences of a link's check, in the order a report says them. */
|
|
81
|
+
export declare function linkSentences(check: SharedRecordCheckV1, link: LinkReport['link'], copy: boolean): string[];
|
|
82
|
+
export declare function buildLinkReport(check: SharedRecordCheckV1, link: LinkReport['link'], copy: boolean): LinkReport;
|
|
83
|
+
/** The report as the terminal prints it: labeled facts in a column, the sentences, each entry's time, then the fields. */
|
|
84
|
+
export declare function renderLinkReport(report: LinkReport): string;
|
|
85
|
+
/** The report as one page with no script and no network: the facts, the sentences, each entry's time and the fields. */
|
|
86
|
+
export declare function renderLinkHtml(input: {
|
|
87
|
+
report: LinkReport;
|
|
88
|
+
version: string;
|
|
89
|
+
now: Date;
|
|
90
|
+
}): string;
|
|
91
|
+
export interface LinkRunArgs {
|
|
92
|
+
accessCodeFile: string | null;
|
|
93
|
+
copy: string | null;
|
|
94
|
+
html: string | null;
|
|
95
|
+
source: CheckOptions['source'];
|
|
96
|
+
full: boolean;
|
|
97
|
+
timeoutMs: number | undefined;
|
|
98
|
+
json: boolean;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Opens a link with a list of records and checks it. The caller has read the address, named the origin it asks,
|
|
102
|
+
* and been answered that the handle is a trail link's. `askCode` is called once, after the link is known to serve.
|
|
103
|
+
*/
|
|
104
|
+
export declare function runSharedRecordLink(input: {
|
|
105
|
+
address: SharedRecordAddressV1;
|
|
106
|
+
origin: LinkOrigin;
|
|
107
|
+
args: LinkRunArgs;
|
|
108
|
+
io: CliIo;
|
|
109
|
+
askCode: (notice: string) => Promise<string | null>;
|
|
110
|
+
}): Promise<number>;
|
|
111
|
+
/**
|
|
112
|
+
* Checks a kept copy of a link again: every record against the proof layer, and the list against the link's
|
|
113
|
+
* address only when the address is given again. Nothing is asked of the link's host.
|
|
114
|
+
*/
|
|
115
|
+
export declare function runSharedRecordCopy(input: {
|
|
116
|
+
copy: SharedRecordCopyV1;
|
|
117
|
+
/** The address given again, already read; null when none was. */
|
|
118
|
+
address: SharedRecordAddressV1 | null;
|
|
119
|
+
args: Pick<LinkRunArgs, 'source' | 'full' | 'timeoutMs' | 'json'>;
|
|
120
|
+
io: CliIo;
|
|
121
|
+
}): Promise<number>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every new sentence the checker says about a Shared Record link with a list of records and about a kept copy of
|
|
3
|
+
* one (ADR 0021, the one check). They are in one file so the words card of the change that adds them, and any
|
|
4
|
+
* change to them after it, is this file and nothing else. Pure: no I/O.
|
|
5
|
+
*
|
|
6
|
+
* Sentences already registered are said from where they live and are not repeated here: the link and code
|
|
7
|
+
* prompts and the key sentences (`open.ts`), the boundary of a check of seals and the line for the proof layer
|
|
8
|
+
* (`report.ts`).
|
|
9
|
+
*
|
|
10
|
+
* A handle, a code, a key and a session are never part of a sentence. A host is: the reader chose to open it.
|
|
11
|
+
*/
|
|
12
|
+
import type { SharedRecordLinkCodeV1, SharedRecordRecordCodeV1 } from '@pacspace/shared';
|
|
13
|
+
export declare const SHARED_RECORD_WORDS: {
|
|
14
|
+
/** The origin every request of this run goes to. */
|
|
15
|
+
readonly readingFrom: (origin: string) => string;
|
|
16
|
+
/** Said before the code is asked for and again beside the result, when the origin is not one of PacSpace's. */
|
|
17
|
+
readonly notPacSpace: (origin: string) => string;
|
|
18
|
+
/** Said with the code prompt. A refused code is never sent again by this run. */
|
|
19
|
+
readonly codeOnce: (host: string) => string;
|
|
20
|
+
/** No code was typed or found in the file given. Nothing was sent. */
|
|
21
|
+
readonly noCode: "No code was given, so the link was not opened.";
|
|
22
|
+
/** The link's host answered 429 to opening it. */
|
|
23
|
+
readonly openLimited: (host: string, seconds: number | null) => string;
|
|
24
|
+
/** A `csl1_` address that its host answers as any other kind of link. Exit code 1. */
|
|
25
|
+
readonly notAListLink: "This address names a list of records, and its host answered it as another kind of link. It fails the check.";
|
|
26
|
+
/** A trail link made before lists. Exit code 3; no code is asked for. */
|
|
27
|
+
readonly noList: "This link was made before links carried a list of their records, so there is no list to check its records against. It was not checked.";
|
|
28
|
+
/** `--full` over JSON-RPC. */
|
|
29
|
+
readonly fullNeedsMirror: "--full reads a contract's whole log from a mirror. Use it without --rpc.";
|
|
30
|
+
/** `open --full` on a link to one record. */
|
|
31
|
+
readonly fullOnlyForList: "With open, --full is used only with a link to a list of records.";
|
|
32
|
+
/** `--html` beside `--json`'s own report is fine; `--copy` when the link gave nothing to keep. */
|
|
33
|
+
readonly copyNotSaved: "No copy was saved, because the link did not serve a list that could be kept.";
|
|
34
|
+
/** A kept copy of a link with `--offline`. */
|
|
35
|
+
readonly copyOffline: "A copy of a link is checked against the proof layer, so it was not checked offline. Run this again without --offline.";
|
|
36
|
+
readonly copyNotRead: "This is not a copy of a link this version can read.";
|
|
37
|
+
/** `--link-file` given with a copy, and the address in it does not name a list of records. */
|
|
38
|
+
readonly copyAddress: "The link given with this copy is not the address of a link with a list of records.";
|
|
39
|
+
/** An option of a single record's file given with a copy of a link. */
|
|
40
|
+
readonly copyOption: (flag: string) => string;
|
|
41
|
+
/** `--link-file` with a file that is not a copy of a link. */
|
|
42
|
+
readonly linkFileOnlyForCopy: "--link-file is used with open, or with a copy of a link.";
|
|
43
|
+
readonly savedCopy: (path: string) => string;
|
|
44
|
+
readonly savedCopyNoFields: (path: string) => string;
|
|
45
|
+
readonly progress: (done: number, of: number) => string;
|
|
46
|
+
readonly title: "PacSpace link check";
|
|
47
|
+
readonly labels: {
|
|
48
|
+
readonly host: "Link host";
|
|
49
|
+
readonly readFrom: "Read from";
|
|
50
|
+
readonly reference: "Reference";
|
|
51
|
+
readonly sharedBy: "Shared by";
|
|
52
|
+
readonly sharedOn: "Shared on";
|
|
53
|
+
readonly records: "Records";
|
|
54
|
+
readonly proofLayer: "Proof layer";
|
|
55
|
+
};
|
|
56
|
+
/** The cover is PacSpace's report: nothing in it is held to the address. */
|
|
57
|
+
readonly coverNote: "The reference, who shared this link and when are as its host reports them. The check does not cover them.";
|
|
58
|
+
readonly proofLayerLine: (chainId: number, contract: string, source: string | null) => string;
|
|
59
|
+
readonly listMatches: (n: number) => string;
|
|
60
|
+
readonly listNotCompared: (n: number) => string;
|
|
61
|
+
readonly allMatch: (n: number) => string;
|
|
62
|
+
readonly someFail: (failed: number, n: number) => string;
|
|
63
|
+
/** No record fails and at least one was not checked. */
|
|
64
|
+
readonly someNotChecked: (matched: number, notChecked: number, n: number) => string;
|
|
65
|
+
/** At least one record fails and at least one was not checked: a list of two or more. */
|
|
66
|
+
readonly failedAndNotChecked: (failed: number, notChecked: number, n: number) => string;
|
|
67
|
+
/** The default check's stated limit, said with a result that passed without `--full`. */
|
|
68
|
+
readonly spanLimit: "Each record's writes were read back to its first write. A record that was set back to empty and written again before that first write is shown only by --full, which reads the contract's whole log.";
|
|
69
|
+
readonly recordFails: (number: number, why: string) => string;
|
|
70
|
+
readonly recordNotChecked: (number: number, why: string) => string;
|
|
71
|
+
/** A record that moved on after it was served. Reported, never a failure. */
|
|
72
|
+
readonly changedSince: (number: number, later: number) => string;
|
|
73
|
+
readonly afterClose: (number: number, entries: number) => string;
|
|
74
|
+
readonly committingAfterClose: (number: number, entries: number) => string;
|
|
75
|
+
readonly recordsNotListed: (count: number) => string;
|
|
76
|
+
/** Each entry's time on the proof layer. */
|
|
77
|
+
readonly committedHeading: "When each entry was committed on the proof layer:";
|
|
78
|
+
readonly committedLine: (number: number, entry: number, when: string) => string;
|
|
79
|
+
readonly committedNotListed: (count: number) => string;
|
|
80
|
+
/** A copy kept when the fields were not opened. */
|
|
81
|
+
readonly copyFieldsNotKept: "This link reveals fields, and this copy was kept without them.";
|
|
82
|
+
readonly fieldsNotRead: "This link reveals fields, and they could not be read from the link's host, so none are shown.";
|
|
83
|
+
readonly fieldsOpened: (n: number) => string;
|
|
84
|
+
readonly revealedHeading: (number: number) => string;
|
|
85
|
+
};
|
|
86
|
+
/** Why a link failed or was not checked, by its code. */
|
|
87
|
+
export declare const LINK_CODE_WORDS: Record<SharedRecordLinkCodeV1, string>;
|
|
88
|
+
/**
|
|
89
|
+
* Why one record failed or was not checked, by its code. `entry` is the entry the code names, counted from 1;
|
|
90
|
+
* `requests` is what the record itself asked of the proof layer, which tells a record that lived past its own
|
|
91
|
+
* budget from one the run had nothing left for.
|
|
92
|
+
*/
|
|
93
|
+
export declare function recordCodeWords(code: SharedRecordRecordCodeV1, entry: number | null, context: {
|
|
94
|
+
chainId: number;
|
|
95
|
+
full: boolean;
|
|
96
|
+
requests: number;
|
|
97
|
+
}): string;
|
package/package.json
CHANGED