@w-r-l/verify 0.3.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 +16 -11
- package/lib/format-legal.js +23 -1
- package/lib/format.js +40 -0
- package/lib/verify.js +32 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @w-r-l/verify
|
|
2
2
|
|
|
3
|
-
Verify the cryptographic integrity of [WRL](https://github.com/benpeter/web-resource-ledger) WACZ capture bundles
|
|
3
|
+
Verify the cryptographic integrity of [WRL](https://github.com/benpeter/web-resource-ledger) WACZ capture bundles: offline, zero-install.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npx @w-r-l/verify capture.wacz --origin https://api.webresourceledger.com
|
|
@@ -26,7 +26,7 @@ Exit code `0` means all applicable checks passed. Exit code `1` means one or mor
|
|
|
26
26
|
npx @w-r-l/verify "https://api.webresourceledger.com/v1/captures/cap_abc123def456..."
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
The signing key is fetched from the server automatically. Individual captures are publicly accessible
|
|
29
|
+
The signing key is fetched from the server automatically. Individual captures are publicly accessible; no authentication or tokens are needed.
|
|
30
30
|
|
|
31
31
|
### Remote capture via server-side verify endpoint
|
|
32
32
|
|
|
@@ -37,8 +37,8 @@ npx @w-r-l/verify https://api.webresourceledger.com/v1/verify/cap_abc123def456..
|
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
The distinction:
|
|
40
|
-
- `/v1/captures/cap_<id
|
|
41
|
-
- `/v1/verify/cap_<id
|
|
40
|
+
- `/v1/captures/cap_<id>`: CLI downloads the WACZ and verifies it locally (cryptographic proof)
|
|
41
|
+
- `/v1/verify/cap_<id>`: server returns its own verification result (JSON or HTML)
|
|
42
42
|
|
|
43
43
|
### Local file
|
|
44
44
|
|
|
@@ -53,7 +53,7 @@ npx @w-r-l/verify capture.wacz --key <base64-encoded-public-key>
|
|
|
53
53
|
npx @w-r-l/verify capture.wacz --key-file signing-key.pub
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
Local files require an explicit key source. The WACZ embeds a public key, but using it would be insecure
|
|
56
|
+
Local files require an explicit key source. The WACZ embeds a public key, but using it would be insecure: an attacker who modifies the capture can also replace the embedded key.
|
|
57
57
|
|
|
58
58
|
### Self-consistency check
|
|
59
59
|
|
|
@@ -69,11 +69,11 @@ Uses the key embedded in the WACZ. This proves the archive is internally consist
|
|
|
69
69
|
npx @w-r-l/verify capture.wacz --origin https://api.webresourceledger.com --legal
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
Produces a structured plain-text report designed for use in legal proceedings or formal documentation. No ANSI color codes are written
|
|
72
|
+
Produces a structured plain-text report designed for use in legal proceedings or formal documentation. No ANSI color codes are written, so the output is safe to redirect to a file or attach as a document.
|
|
73
73
|
|
|
74
|
-
The report is organized into seven sections: a plain-language summary, a description of the subject (captured
|
|
74
|
+
The report is organized into seven sections: a plain-language summary, a description of the subject (the captured page, when it was captured and signed, its bundle hash, and what the capture service recorded about a partial render, a cut-off screenshot or an error answer from the site), per-check explanations in non-technical terms, a chain of custody narrative, applicable legal standards (FRE 901(b)(9) and eIDAS Art. 41), a methodology description, and full technical details with untruncated cryptographic values. The format version is WRL-LEGAL-1.0, which appears in the report header.
|
|
75
75
|
|
|
76
|
-
Standard and qualified timestamps are reported separately when both are present. A standard RFC 3161 timestamp (DigiCert) is included
|
|
76
|
+
Standard and qualified timestamps are reported separately when both are present. A standard RFC 3161 timestamp (DigiCert) is included whenever the timestamp authority answered at capture time; the report says so when a capture has none. An eIDAS-qualified timestamp appears only when the capturing account has opted into a qualified Trust Service Provider; the report identifies which tier applies and what legal weight it carries.
|
|
77
77
|
|
|
78
78
|
```bash
|
|
79
79
|
# Machine-readable version of the same report
|
|
@@ -107,6 +107,9 @@ Outputs a single JSON object to stdout. All human messages go to stderr in JSON
|
|
|
107
107
|
"signature": "...",
|
|
108
108
|
"embeddedPublicKey": "...",
|
|
109
109
|
"signedAt": "2026-03-16T14:22:07Z",
|
|
110
|
+
"url": "https://example.com/terms",
|
|
111
|
+
"capturedAt": "2026-03-16T14:22:05Z",
|
|
112
|
+
"quality": { "renderQuality": "full", "waitUntilReached": "load", "timedOut": false, "httpStatus": 200 },
|
|
110
113
|
"timestamp": { "genTime": "2026-03-16T14:22:08Z", "tsa": "DigiCert Timestamp Authority" }
|
|
111
114
|
},
|
|
112
115
|
"keyResolution": {
|
|
@@ -120,6 +123,8 @@ Outputs a single JSON object to stdout. All human messages go to stderr in JSON
|
|
|
120
123
|
}
|
|
121
124
|
```
|
|
122
125
|
|
|
126
|
+
`capture.quality` is the capture service's record of how the page loaded, read from `datapackage.json` and so covered by the signature: whether the render was `full` or `partial` and why (`timedOut`, `subresourceLimitReached`), whether the screenshot shows the whole page (`screenshotClipped`, `pageHeight`, `screenshotHeight`), and the HTTP status the site answered with (`httpStatus`). It is `null` for archives that record none; older captures have only some of the fields. The standard output and the legal report turn it into a note when the capture is partial, the screenshot is cut off, or the status is 400 or higher, for example `Note The site answered with HTTP 403; the capture shows that answer, which can be an error page or a block page`.
|
|
127
|
+
|
|
123
128
|
On errors, `verified` is `null` (not `false`) and an `error` field is present:
|
|
124
129
|
|
|
125
130
|
```json
|
|
@@ -151,7 +156,7 @@ The tool bundles the DigiCert Trusted Root G4 certificate. Use `--trust-root` to
|
|
|
151
156
|
|
|
152
157
|
`--origin`, `--key`, `--key-file`, and `--trust-embedded` are mutually exclusive.
|
|
153
158
|
|
|
154
|
-
`--legal` can be combined with `--json` for a machine-readable version of the same report. `--legal` implies `--no-color
|
|
159
|
+
`--legal` can be combined with `--json` for a machine-readable version of the same report. `--legal` implies `--no-color`; ANSI codes are never written in legal mode.
|
|
155
160
|
|
|
156
161
|
## Requirements
|
|
157
162
|
|
|
@@ -178,9 +183,9 @@ Releases are published to npm automatically when a `verify/v*` tag is pushed.
|
|
|
178
183
|
git push origin main --follow-tags
|
|
179
184
|
```
|
|
180
185
|
|
|
181
|
-
The CI workflow runs tests and publishes to npm with provenance attestation.
|
|
186
|
+
The CI workflow (`.github/workflows/publish-verify.yml`, on a `verify/v*` tag) runs the tests and publishes to npm with provenance attestation. It needs no npm token: npm trusts this repository's workflow as a trusted publisher (OpenID Connect), set up in the package's settings on npmjs.com.
|
|
182
187
|
If the version already exists on npm, the publish step exits cleanly.
|
|
183
188
|
|
|
184
189
|
## License
|
|
185
190
|
|
|
186
|
-
[PolyForm Shield 1.0.0](../../LICENSE)
|
|
191
|
+
[Apache 2.0](LICENSE). The verifier is under a permissive license so that anyone (a court, an opposing expert, another archive) can run, copy and build it into their own tools. The rest of WRL is under [PolyForm Shield 1.0.0](../../LICENSE).
|
package/lib/format-legal.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* formatLegalJson() -- machine-readable JSON for document assembly
|
|
11
11
|
*/ // tva
|
|
12
12
|
|
|
13
|
-
import { checkLabel } from './format.js';
|
|
13
|
+
import { checkLabel, captureQualityNotes } from './format.js';
|
|
14
14
|
|
|
15
15
|
// ---------------------------------------------------------------------------
|
|
16
16
|
// Report format version -- bumped when report structure changes
|
|
@@ -268,6 +268,9 @@ export function formatLegal(result, opts = {}) {
|
|
|
268
268
|
));
|
|
269
269
|
}
|
|
270
270
|
out.push('');
|
|
271
|
+
if (result.capture?.url) {
|
|
272
|
+
out.push(`Page: ${result.capture.url}`);
|
|
273
|
+
}
|
|
271
274
|
out.push(`Source: ${result.source ?? 'unknown'}`);
|
|
272
275
|
out.push(`Verified: ${verifiedAt}`);
|
|
273
276
|
out.push('');
|
|
@@ -288,6 +291,12 @@ export function formatLegal(result, opts = {}) {
|
|
|
288
291
|
out.push('');
|
|
289
292
|
|
|
290
293
|
const capture = result.capture ?? {};
|
|
294
|
+
if (capture.url) {
|
|
295
|
+
out.push(`Captured page: ${capture.url}`);
|
|
296
|
+
}
|
|
297
|
+
if (capture.capturedAt) {
|
|
298
|
+
out.push(`Captured at: ${capture.capturedAt}`);
|
|
299
|
+
}
|
|
291
300
|
out.push(`Source: ${result.source ?? 'unknown'}`);
|
|
292
301
|
if (capture.signedAt) {
|
|
293
302
|
out.push(`Created: ${capture.signedAt}`);
|
|
@@ -297,6 +306,15 @@ export function formatLegal(result, opts = {}) {
|
|
|
297
306
|
}
|
|
298
307
|
out.push('');
|
|
299
308
|
|
|
309
|
+
const qualityNotes = captureQualityNotes(capture.quality);
|
|
310
|
+
if (qualityNotes.length > 0) {
|
|
311
|
+
out.push('Recorded by the capture service and covered by the signature:');
|
|
312
|
+
for (const note of qualityNotes) {
|
|
313
|
+
out.push(wrap(`- ${note}.`));
|
|
314
|
+
}
|
|
315
|
+
out.push('');
|
|
316
|
+
}
|
|
317
|
+
|
|
300
318
|
// Section 3: Verification Checks Performed
|
|
301
319
|
out.push('3. VERIFICATION CHECKS PERFORMED');
|
|
302
320
|
out.push(LINE);
|
|
@@ -670,6 +688,7 @@ export function formatLegalJson(result, opts = {}) {
|
|
|
670
688
|
statement: summaryStatement,
|
|
671
689
|
verified: result.verified ?? null,
|
|
672
690
|
source: result.source ?? null,
|
|
691
|
+
capturedUrl: capture.url ?? null,
|
|
673
692
|
captureDate: capture.signedAt ?? null,
|
|
674
693
|
},
|
|
675
694
|
checks: enrichedChecks,
|
|
@@ -678,6 +697,9 @@ export function formatLegalJson(result, opts = {}) {
|
|
|
678
697
|
signature: capture.signature ?? null,
|
|
679
698
|
embeddedPublicKey: capture.publicKey ?? null,
|
|
680
699
|
signedAt: capture.signedAt ?? null,
|
|
700
|
+
url: capture.url ?? null,
|
|
701
|
+
capturedAt: capture.capturedAt ?? null,
|
|
702
|
+
quality: capture.quality ?? null,
|
|
681
703
|
},
|
|
682
704
|
timestamps,
|
|
683
705
|
keyResolution: {
|
package/lib/format.js
CHANGED
|
@@ -136,6 +136,36 @@ function mergeTimestampChecks(checks) {
|
|
|
136
136
|
return result;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
// Capture quality notes
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* What a reader should know about the capture before relying on it, from the
|
|
145
|
+
* capture service's signed record: a partial render, a screenshot that shows
|
|
146
|
+
* only the top of the page, an error answer from the site. Empty for a full
|
|
147
|
+
* capture of a page that answered normally.
|
|
148
|
+
*
|
|
149
|
+
* @param {object|null|undefined} quality result.capture.quality
|
|
150
|
+
* @returns {string[]} sentences without a full stop
|
|
151
|
+
*/
|
|
152
|
+
export function captureQualityNotes(quality) {
|
|
153
|
+
if (!quality) return [];
|
|
154
|
+
const notes = [];
|
|
155
|
+
if (quality.renderQuality === 'partial') {
|
|
156
|
+
notes.push(quality.subresourceLimitReached && !quality.timedOut
|
|
157
|
+
? 'Partial capture: the page made more requests than the capture service allows, so content that loads late may be missing'
|
|
158
|
+
: 'Partial capture: the page had not finished loading, so content that loads late may be missing');
|
|
159
|
+
}
|
|
160
|
+
if (quality.screenshotClipped && quality.screenshotHeight && quality.pageHeight) {
|
|
161
|
+
notes.push(`The screenshot shows the top ${quality.screenshotHeight} px of a ${quality.pageHeight} px page; the HTML has the whole page`);
|
|
162
|
+
}
|
|
163
|
+
if (quality.httpStatus >= 400) {
|
|
164
|
+
notes.push(`The site answered with HTTP ${quality.httpStatus}; the capture shows that answer, which can be an error page or a block page`);
|
|
165
|
+
}
|
|
166
|
+
return notes;
|
|
167
|
+
}
|
|
168
|
+
|
|
139
169
|
// ---------------------------------------------------------------------------
|
|
140
170
|
// Human-readable formatter
|
|
141
171
|
// ---------------------------------------------------------------------------
|
|
@@ -151,6 +181,7 @@ function mergeTimestampChecks(checks) {
|
|
|
151
181
|
* signature?: string,
|
|
152
182
|
* publicKey?: string,
|
|
153
183
|
* signedAt?: string,
|
|
184
|
+
* quality?: object|null,
|
|
154
185
|
* timestamp?: { genTime: string, tsa: string },
|
|
155
186
|
* qualifiedTimestamp?: { genTime: string, tsa: string }
|
|
156
187
|
* },
|
|
@@ -211,6 +242,15 @@ export function formatHuman(result, opts = {}) {
|
|
|
211
242
|
// Metadata block
|
|
212
243
|
process.stdout.write('\n');
|
|
213
244
|
|
|
245
|
+
const pageUrl = result.capture?.url;
|
|
246
|
+
if (pageUrl) {
|
|
247
|
+
process.stdout.write(` Page ${pageUrl}\n`);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
for (const note of captureQualityNotes(result.capture?.quality)) {
|
|
251
|
+
process.stdout.write(` Note ${note}\n`);
|
|
252
|
+
}
|
|
253
|
+
|
|
214
254
|
const signedAt = result.capture?.signedAt;
|
|
215
255
|
if (signedAt) {
|
|
216
256
|
process.stdout.write(` Signed ${signedAt}\n`);
|
package/lib/verify.js
CHANGED
|
@@ -34,6 +34,33 @@ const MAX_DECOMPRESSED = 100 * 1024 * 1024; // 100 MB
|
|
|
34
34
|
// Public API
|
|
35
35
|
// ---------------------------------------------------------------------------
|
|
36
36
|
|
|
37
|
+
const WAIT_MILESTONES = ['domcontentloaded', 'load', 'networkidle'];
|
|
38
|
+
const QUALITY_FLAGS = ['timedOut', 'subresourceLimitReached', 'screenshotClipped'];
|
|
39
|
+
const QUALITY_NUMBERS = ['pageHeight', 'screenshotHeight', 'httpStatus'];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Reads the captureQuality record of datapackage.json: how far the page got,
|
|
43
|
+
* how much of it the screenshot shows, what status the site answered with.
|
|
44
|
+
* Keeps only the fields this tool knows, each with the type it expects, so
|
|
45
|
+
* nothing else from the archive reaches the output.
|
|
46
|
+
*
|
|
47
|
+
* @param {*} raw datapackage.captureQuality
|
|
48
|
+
* @returns {object|null} null when the archive records none
|
|
49
|
+
*/
|
|
50
|
+
function readCaptureQuality(raw) {
|
|
51
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) return null;
|
|
52
|
+
const quality = {};
|
|
53
|
+
if (raw.renderQuality === 'full' || raw.renderQuality === 'partial') quality.renderQuality = raw.renderQuality;
|
|
54
|
+
if (WAIT_MILESTONES.includes(raw.waitUntilReached)) quality.waitUntilReached = raw.waitUntilReached;
|
|
55
|
+
for (const name of QUALITY_FLAGS) {
|
|
56
|
+
if (typeof raw[name] === 'boolean') quality[name] = raw[name];
|
|
57
|
+
}
|
|
58
|
+
for (const name of QUALITY_NUMBERS) {
|
|
59
|
+
if (Number.isInteger(raw[name])) quality[name] = raw[name];
|
|
60
|
+
}
|
|
61
|
+
return Object.keys(quality).length > 0 ? quality : null;
|
|
62
|
+
}
|
|
63
|
+
|
|
37
64
|
/**
|
|
38
65
|
* Verifies a WACZ file against a trusted Ed25519 public key.
|
|
39
66
|
*
|
|
@@ -300,6 +327,11 @@ export async function verifyWacz(waczBytes, publicKeyBytes, options = {}) {
|
|
|
300
327
|
signature: selfSig?.signature ?? null,
|
|
301
328
|
publicKey: selfSig?.publicKey ?? null, // informational only -- NOT used for verification
|
|
302
329
|
signedAt: signedData.created ?? null,
|
|
330
|
+
// The captured page, from datapackage.json: covered by the bundle hash
|
|
331
|
+
url: typeof datapackage.mainPageUrl === 'string' ? datapackage.mainPageUrl : null,
|
|
332
|
+
capturedAt: typeof datapackage.mainPageDate === 'string' ? datapackage.mainPageDate : null,
|
|
333
|
+
// How the page loaded, as the capture service recorded it: also in datapackage.json
|
|
334
|
+
quality: readCaptureQuality(datapackage.captureQuality),
|
|
303
335
|
};
|
|
304
336
|
if (timestampData) {
|
|
305
337
|
result.capture.timestamp = timestampData;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w-r-l/verify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Verify cryptographic integrity of WRL WACZ web capture bundles",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"author": "Ben Peter <bp@ben-peter.com>",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"LICENSE"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"fflate": "^0.8.
|
|
42
|
+
"fflate": "^0.8.3",
|
|
43
43
|
"pkijs": "3.3.3",
|
|
44
44
|
"asn1js": "3.0.5",
|
|
45
45
|
"pvutils": "1.1.3"
|