@crawlcheck/sdk 0.0.0-stage → 1.0.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 +58 -2
- package/dist/gen/openapi.d.ts +3233 -0
- package/dist/gen/openapi.js +5 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.js +128 -0
- package/dist/verify.d.ts +27 -0
- package/dist/verify.js +345 -0
- package/package.json +43 -4
- package/test/sdk.test.js +45 -0
package/README.md
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @crawlcheck/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A typed client for the CrawlCheck API and the offline verifier for its evidence, in one package with no dependencies.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm i @crawlcheck/sdk
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Read a record
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { CrawlCheck } from "@crawlcheck/sdk";
|
|
13
|
+
const cc = new CrawlCheck(); // { key: "cc_…" } for licence-gated fields
|
|
14
|
+
const mr = await cc.machineRecord({ domain: "example.com" });
|
|
15
|
+
mr.findings; // gated exactly like the website: the top finding without a licence
|
|
16
|
+
mr.score_ledger; // what each row and finding does to the grade
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Every request and response type is generated from https://crawlcheck.io/openapi.json. Any documented route is callable with types checked against the contract:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
await cc.get("/api/explain", { domain: "example.com", code: "NO_LLMS_TXT" });
|
|
23
|
+
await cc.get("/api/explain", { website: "x" }); // compile error: not a parameter of this operation
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Do not trust the API: check the evidence yourself
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
const v = await cc.verifyOffline(mr.subject.report_id); // downloads the bundle, verifies it HERE
|
|
30
|
+
v.checks; // manifest hash, Ed25519 signature, key id, record digest, Merkle path to the day's root,
|
|
31
|
+
// OpenTimestamps proof (Bitcoin), sealed roots over fetches, decisions and facts
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`ok: true` passed, `ok: false` failed, `ok: null` could not run and `why` says why. A null is never a pass.
|
|
35
|
+
|
|
36
|
+
Remediation receipts (before, declared fix, deployment, after, verdict, signed):
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
import { verifyReceipt } from "@crawlcheck/sdk";
|
|
40
|
+
const rc = await cc.receipt("rc1:…");
|
|
41
|
+
const r = await verifyReceipt(rc); // hash, key id, signature, order
|
|
42
|
+
const ours = (await cc.publishedKeyIds()).includes(rc.signature.kid); // the one check offline cannot do
|
|
43
|
+
const accept = r.verified && ours;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Prove the verifier
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
const suite = await cc.conformance(); // 19 real bundles and receipts, valid and tampered, with expected outputs
|
|
50
|
+
suite.ok; // every fixture gave exactly its expected checks and verdict
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`npm test` in the installed package runs the conformance suite and live checks against crawlcheck.io.
|
|
54
|
+
|
|
55
|
+
## Errors
|
|
56
|
+
|
|
57
|
+
A refused request throws `CrawlCheckError` with `status`, `body` and `locked` (true for "this needs a licence for the domain").
|
|
58
|
+
|
|
59
|
+
Requires Node 20+ or any current browser (WebCrypto Ed25519).
|