@crawlcheck/sdk 1.8.0 → 1.9.1
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 +4 -0
- package/dist/log.d.ts +1 -0
- package/dist/log.js +28 -5
- package/dist/verify.js +4 -1
- package/package.json +1 -1
- package/test/fixtures/key-policy.json +390 -221
- package/test/split-view.test.js +14 -0
package/README.md
CHANGED
|
@@ -18,6 +18,10 @@ const { proceed, receipt } = await cc.guard("example.com", "read", { agent: "MyA
|
|
|
18
18
|
|
|
19
19
|
Every verification returns `integrity_valid`, `issuer_trusted` and `accepted`. Act on `accepted`: it needs the signing key to be one CrawlCheck publishes, so a document someone signed with their own key is `verified` offline but never `accepted`. The client methods (`verifyDocument`, `verifyOffline`, `verifyReceiptOffline`, `guard`) check the published key directory for you.
|
|
20
20
|
|
|
21
|
+
Since 1.9.1 a key the rotation record lists as retired still counts for its own signing window when the expected purpose is worked out: after a decision-key rotation, receipts the old decision key signed inside its window verify, and no other key may sign a decision made while that key was live (key-policy suite cases retired-decision-key-*).
|
|
22
|
+
|
|
23
|
+
Since 1.9.0 `logCheck` reads the chain of signed heads 200 per request (`/api/v1/log/sths`) instead of one per batch, so a first check on a client holding no heads takes one or two requests; an older server is still walked one head per request.
|
|
24
|
+
|
|
21
25
|
Since 1.8.0 an MCP connect decision names the server and, with a lockfile, its approved `tools_sha256` (`preflight(domain, "connect", { mcp: { url, tools_sha256 } })`; `withPreflight` sends it for you). CrawlCheck reads the live tools from its own network: a changed tool list comes back as `block`, and the signed receipt's `assessed` block says exactly which endpoint and tool state it covered.
|
|
22
26
|
|
|
23
27
|
Since 1.8.0 they also apply the signing policy (https://crawlcheck.io/keys#policy): which key purpose may sign which object at which time (decision receipts move to the decision key at 2026-11-09 17:00 UTC), retired keys (valid only for documents signed before they stopped) and compromised keys (never valid on their signature alone). The result carries `key_policy_valid`, and `accepted` needs it. Offline, build the same input from copies you saved: `keyPolicyFrom(savedDirectory, savedRotationRecord)`, then `applyKeyPolicy(result, doc, kp)` or `guard(domain, action, { onlineKeys: false, keyPolicy })`. A saved copy cannot know a key retired or compromised after you saved it.
|
package/dist/log.d.ts
CHANGED
|
@@ -110,6 +110,7 @@ export function verifyWitnessToken(token: any, sthSha256: any, jwks: any): Promi
|
|
|
110
110
|
* holds (at most opts.maxWalk batches), observing every link, so any head this client was shown that the witness's
|
|
111
111
|
* chain does not contain surfaces as a fork. Heads newer than the witnessed one are listed as unwitnessed.
|
|
112
112
|
*/
|
|
113
|
+
export function walkHeads(get: any, hi: any, lo: any): Promise<any[]>;
|
|
113
114
|
export function logCheck(store: any, get: any, opts?: {}): Promise<{
|
|
114
115
|
consistent: boolean;
|
|
115
116
|
forks: any;
|
package/dist/log.js
CHANGED
|
@@ -146,6 +146,32 @@ export async function verifyWitnessToken(token, sthSha256, jwks) {
|
|
|
146
146
|
* holds (at most opts.maxWalk batches), observing every link, so any head this client was shown that the witness's
|
|
147
147
|
* chain does not contain surfaces as a fork. Heads newer than the witnessed one are listed as unwitnessed.
|
|
148
148
|
*/
|
|
149
|
+
// Signed heads for batches hi down to lo, newest first. Since 1.9.0 one request per 200 batches (/api/v1/log/sths);
|
|
150
|
+
// a server without that route is walked one head per request as before.
|
|
151
|
+
export async function walkHeads(get, hi, lo) {
|
|
152
|
+
const out = [];
|
|
153
|
+
let k = hi;
|
|
154
|
+
while (k >= lo) {
|
|
155
|
+
const n = Math.min(200, k - lo + 1);
|
|
156
|
+
const d = await get("/api/v1/log/sths?to=" + k + "&n=" + n).catch(() => null);
|
|
157
|
+
if (!d || !Array.isArray(d.sths))
|
|
158
|
+
break;
|
|
159
|
+
const got = {};
|
|
160
|
+
for (const s of d.sths)
|
|
161
|
+
if (s && Number.isInteger(s.batch))
|
|
162
|
+
got[s.batch] = s;
|
|
163
|
+
for (let b = k; b > k - n; b--)
|
|
164
|
+
if (got[b])
|
|
165
|
+
out.push(got[b]);
|
|
166
|
+
k -= n;
|
|
167
|
+
}
|
|
168
|
+
for (; k >= lo; k--) {
|
|
169
|
+
const d = await get("/api/v1/log/sth/" + k).catch(() => null);
|
|
170
|
+
if (d && d.sth)
|
|
171
|
+
out.push(d.sth);
|
|
172
|
+
}
|
|
173
|
+
return out;
|
|
174
|
+
}
|
|
149
175
|
export async function logCheck(store, get, opts = {}) {
|
|
150
176
|
const before = store.forks.length, o = { publishedKids: opts.publishedKids };
|
|
151
177
|
const log = await get("/api/v1/log");
|
|
@@ -166,11 +192,8 @@ export async function logCheck(store, get, opts = {}) {
|
|
|
166
192
|
store.witnessed = { batch: w.batch, sha256: sth.sha256, at: witnessed.at, run_id: witnessed.run_id };
|
|
167
193
|
const held = Object.keys(store.heads).map(Number).filter((k) => k < w.batch);
|
|
168
194
|
const lo = held.length ? Math.max(Math.min(...held), w.batch - (opts.maxWalk || 200)) : w.batch;
|
|
169
|
-
for (
|
|
170
|
-
|
|
171
|
-
if (d && d.sth)
|
|
172
|
-
await logObserve(store, d.sth, o);
|
|
173
|
-
}
|
|
195
|
+
for (const s of await walkHeads(get, w.batch - 1, lo))
|
|
196
|
+
await logObserve(store, s, o);
|
|
174
197
|
}
|
|
175
198
|
const wb = store.witnessed ? store.witnessed.batch : -1, now = Date.now(), maxAge = (opts.maxUnwitnessedMinutes || 120) * 60000;
|
|
176
199
|
const unwitnessed = Object.keys(store.heads).map(Number).filter((k) => k > wb).sort((a, b) => a - b).map((k) => ({ batch: k, sha256: store.heads[k].sha256, created_at: store.heads[k].created_at }));
|
package/dist/verify.js
CHANGED
|
@@ -775,7 +775,7 @@ export async function keyPolicyFrom(directory, rotation) {
|
|
|
775
775
|
}
|
|
776
776
|
for (const r of (rotation && rotation.retired) || [])
|
|
777
777
|
if (r && r.thumbprint)
|
|
778
|
-
retired[r.thumbprint] = { purpose: kpPurpose(r.purpose), stopped: kpMs(r.stopped_signing_at) ?? kpMs(r.retired_at) };
|
|
778
|
+
retired[r.thumbprint] = { purpose: kpPurpose(r.purpose), start: kpMs(r.crawlcheck_signs_from) ?? kpMs(r.not_before) ?? kpMs(KEY_POLICY.starts[kpPurpose(r.purpose)]), stopped: kpMs(r.stopped_signing_at) ?? kpMs(r.retired_at) }; // conf3: a retired key keeps its signing window
|
|
779
779
|
for (const c of (rotation && rotation.compromised) || [])
|
|
780
780
|
if (c && c.thumbprint)
|
|
781
781
|
compromised[c.thumbprint] = kpMs(c.compromised_since) ?? 0;
|
|
@@ -823,6 +823,9 @@ function kpExpected(objPurpose, t, kp) {
|
|
|
823
823
|
return p;
|
|
824
824
|
if (Object.keys(kp.keys).some((kid) => kp.keys[kid].purpose === p && kp.compromised[kid] === undefined && (t === null || kp.keys[kid].start === null || kp.keys[kid].start <= t)))
|
|
825
825
|
return p;
|
|
826
|
+
// conf3: a key retired since still covered its own signing window: a decision made while a decision key was live expects that purpose
|
|
827
|
+
if (t !== null && Object.keys(kp.retired || {}).some((kid) => { const r = kp.retired[kid]; return r.purpose === p && kp.compromised[kid] === undefined && (r.start === null || r.start === undefined || r.start <= t) && r.stopped !== null && t <= r.stopped; }))
|
|
828
|
+
return p;
|
|
826
829
|
}
|
|
827
830
|
return "requests";
|
|
828
831
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlcheck/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "Typed client for the CrawlCheck API (generated from its OpenAPI document) and the zero-dependency offline verifier for evidence bundles and remediation receipts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|