@verax-ai/body 0.8.2 → 0.10.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 +9 -6
- package/dist/anchor-cli.d.ts +48 -3
- package/dist/anchor-cli.js +256 -17
- package/dist/auth.d.ts +14 -1
- package/dist/auth.js +25 -4
- package/dist/canary-cli.d.ts +5 -0
- package/dist/canary-cli.js +213 -0
- package/dist/cli.js +93 -6
- package/dist/config.d.ts +6 -0
- package/dist/config.js +1 -0
- package/dist/demo.js +3 -0
- package/dist/doctor.d.ts +11 -0
- package/dist/doctor.js +88 -2
- package/dist/downstream-pin.js +11 -1
- package/dist/downstream.d.ts +51 -0
- package/dist/downstream.js +329 -4
- package/dist/explain-cli.d.ts +5 -0
- package/dist/explain-cli.js +132 -0
- package/dist/init-local.d.ts +5 -0
- package/dist/init-local.js +1 -0
- package/dist/install.js +1 -1
- package/dist/policy-cli.d.ts +8 -0
- package/dist/policy-cli.js +169 -0
- package/dist/policy-rehearsal.d.ts +39 -0
- package/dist/policy-rehearsal.js +512 -0
- package/dist/report-cli.d.ts +163 -0
- package/dist/report-cli.js +1101 -0
- package/dist/server.js +43 -6
- package/dist/taint-cli.d.ts +5 -0
- package/dist/taint-cli.js +80 -0
- package/dist/verify-cli.d.ts +40 -0
- package/dist/verify-cli.js +131 -58
- package/dist/webauthn-verify.d.ts +3 -1
- package/dist/webauthn-verify.js +97 -4
- package/dist/wiring.d.ts +5 -0
- package/dist/wiring.js +2 -0
- package/dist/witness.d.ts +16 -5
- package/dist/witness.js +67 -8
- package/package.json +9 -9
package/dist/witness.d.ts
CHANGED
|
@@ -10,16 +10,27 @@ export type WitnessListen = {
|
|
|
10
10
|
/** The Transparency Service this witness registers each checkpoint with, or absent. */
|
|
11
11
|
anchorService?: string;
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Where `verax witness` sends each checkpoint it signs, read once at start.
|
|
15
|
+
* With `chainPem` the witness registers each checkpoint over SCRAPI as a
|
|
16
|
+
* Signed Statement it signs as the Issuer that chain names. With `token` every
|
|
17
|
+
* request to the service carries that bearer token; the token is not written
|
|
18
|
+
* to listen or status files.
|
|
19
|
+
*/
|
|
14
20
|
export type WitnessAnchor = {
|
|
15
21
|
serviceName: string;
|
|
16
22
|
serviceKey: string | null;
|
|
23
|
+
chainPem: string | null;
|
|
24
|
+
token: string | null;
|
|
17
25
|
};
|
|
18
26
|
/**
|
|
19
|
-
* `VERAX_ANCHOR_SERVICE` names the service (https; http only on loopback)
|
|
20
|
-
* `VERAX_ANCHOR_SERVICE_KEY` a file holding its public key
|
|
21
|
-
*
|
|
22
|
-
*
|
|
27
|
+
* `VERAX_ANCHOR_SERVICE` names the service (https; http only on loopback),
|
|
28
|
+
* `VERAX_ANCHOR_SERVICE_KEY` a file holding its public key,
|
|
29
|
+
* `VERAX_ANCHOR_X5CHAIN` a PEM file holding the witness certificate chain,
|
|
30
|
+
* leaf first, which selects SCRAPI, and `VERAX_ANCHOR_TOKEN_FILE` a file
|
|
31
|
+
* holding the bearer token the service requires. None set is no anchoring. A
|
|
32
|
+
* value that is set but unusable is an error, so a witness the operator meant
|
|
33
|
+
* to anchor does not start without anchoring.
|
|
23
34
|
*/
|
|
24
35
|
export declare function witnessAnchorFromEnv(env?: NodeJS.ProcessEnv): {
|
|
25
36
|
ok: true;
|
package/dist/witness.js
CHANGED
|
@@ -7,26 +7,53 @@ import { buildCheckpointClaims, checkpointHash, signCheckpoint, totalsFromDecisi
|
|
|
7
7
|
import { canonical, decisionRecordHash } from "@cedulon/core";
|
|
8
8
|
import { coseFromHex, decodeCoseSign1, verifyCoseSign1 } from "@cedulon/cose";
|
|
9
9
|
import { verifyEffectExtract } from "@cedulon/effect-extract";
|
|
10
|
-
import { appendAnchor, checkpointsPath, listPieceFiles, signEffectAttestation } from "@verax-ai/proxy";
|
|
11
|
-
import { pendingAnchors, registerCheckpoint, serviceNameOf, serviceUrl } from "./anchor-cli.js";
|
|
10
|
+
import { appendAnchor, checkpointStatement, checkpointsPath, listPieceFiles, readIssuerChain, signEffectAttestation, } from "@verax-ai/proxy";
|
|
11
|
+
import { pendingAnchors, readAnchorTokenFile, registerCheckpoint, registerStatement, serviceNameOf, serviceUrl, statementIssuer, } from "./anchor-cli.js";
|
|
12
12
|
import { assertEd25519PublicKey } from "./keys.js";
|
|
13
13
|
import { lockHolderAlive } from "@verax-ai/proxy";
|
|
14
14
|
import { pidAlive } from "./unlock.js";
|
|
15
15
|
const WITNESS_CLASS = "same-org";
|
|
16
16
|
/**
|
|
17
|
-
* `VERAX_ANCHOR_SERVICE` names the service (https; http only on loopback)
|
|
18
|
-
* `VERAX_ANCHOR_SERVICE_KEY` a file holding its public key
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* `VERAX_ANCHOR_SERVICE` names the service (https; http only on loopback),
|
|
18
|
+
* `VERAX_ANCHOR_SERVICE_KEY` a file holding its public key,
|
|
19
|
+
* `VERAX_ANCHOR_X5CHAIN` a PEM file holding the witness certificate chain,
|
|
20
|
+
* leaf first, which selects SCRAPI, and `VERAX_ANCHOR_TOKEN_FILE` a file
|
|
21
|
+
* holding the bearer token the service requires. None set is no anchoring. A
|
|
22
|
+
* value that is set but unusable is an error, so a witness the operator meant
|
|
23
|
+
* to anchor does not start without anchoring.
|
|
21
24
|
*/
|
|
22
25
|
export function witnessAnchorFromEnv(env = process.env) {
|
|
23
26
|
const raw = env.VERAX_ANCHOR_SERVICE?.trim() ?? "";
|
|
24
27
|
const keyPath = env.VERAX_ANCHOR_SERVICE_KEY?.trim() ?? "";
|
|
28
|
+
const chainPath = env.VERAX_ANCHOR_X5CHAIN?.trim() ?? "";
|
|
29
|
+
const tokenPath = env.VERAX_ANCHOR_TOKEN_FILE?.trim() ?? "";
|
|
25
30
|
if (raw === "") {
|
|
26
31
|
if (keyPath !== "")
|
|
27
32
|
return { ok: false, reason: "VERAX_ANCHOR_SERVICE_KEY is set without VERAX_ANCHOR_SERVICE" };
|
|
33
|
+
if (chainPath !== "")
|
|
34
|
+
return { ok: false, reason: "VERAX_ANCHOR_X5CHAIN is set without VERAX_ANCHOR_SERVICE" };
|
|
35
|
+
if (tokenPath !== "")
|
|
36
|
+
return { ok: false, reason: "VERAX_ANCHOR_TOKEN_FILE is set without VERAX_ANCHOR_SERVICE" };
|
|
28
37
|
return { ok: true, anchor: null };
|
|
29
38
|
}
|
|
39
|
+
let chainPem = null;
|
|
40
|
+
if (chainPath !== "") {
|
|
41
|
+
try {
|
|
42
|
+
chainPem = readFileSync(chainPath, "utf8");
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return { ok: false, reason: `cannot read VERAX_ANCHOR_X5CHAIN file ${chainPath}` };
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
readIssuerChain(chainPem);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return {
|
|
52
|
+
ok: false,
|
|
53
|
+
reason: `VERAX_ANCHOR_X5CHAIN file ${chainPath} must hold the witness certificate and at least one CA certificate, leaf first`,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
30
57
|
const url = serviceUrl(raw);
|
|
31
58
|
if (!url) {
|
|
32
59
|
return {
|
|
@@ -53,7 +80,14 @@ export function witnessAnchorFromEnv(env = process.env) {
|
|
|
53
80
|
return { ok: false, reason: `VERAX_ANCHOR_SERVICE_KEY file ${keyPath} is not a public key` };
|
|
54
81
|
}
|
|
55
82
|
}
|
|
56
|
-
|
|
83
|
+
let token = null;
|
|
84
|
+
if (tokenPath !== "") {
|
|
85
|
+
const got = readAnchorTokenFile(tokenPath);
|
|
86
|
+
if (!got.ok)
|
|
87
|
+
return { ok: false, reason: `VERAX_ANCHOR_TOKEN_FILE: ${got.reason}` };
|
|
88
|
+
token = got.token;
|
|
89
|
+
}
|
|
90
|
+
return { ok: true, anchor: { serviceName: serviceNameOf(url), serviceKey, chainPem, token } };
|
|
57
91
|
}
|
|
58
92
|
/**
|
|
59
93
|
* Registers every checkpoint in `stateDir` not yet anchored at the service,
|
|
@@ -72,8 +106,24 @@ export async function anchorPendingCheckpoints(stateDir, anchor, fetchImpl = fet
|
|
|
72
106
|
});
|
|
73
107
|
return;
|
|
74
108
|
}
|
|
109
|
+
let issuer = null;
|
|
110
|
+
if (anchor.chainPem !== null) {
|
|
111
|
+
const found = statementIssuer(stateDir, anchor.chainPem);
|
|
112
|
+
if (!found.ok) {
|
|
113
|
+
appendStatus(stateDir, {
|
|
114
|
+
atMs: Date.now(),
|
|
115
|
+
result: "anchor-failed",
|
|
116
|
+
service: anchor.serviceName,
|
|
117
|
+
reason: "issuer",
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
issuer = found.issuer;
|
|
122
|
+
}
|
|
75
123
|
for (const hash of pending) {
|
|
76
|
-
const got =
|
|
124
|
+
const got = issuer
|
|
125
|
+
? await registerStatement(anchor.serviceName, hash, checkpointStatement(hash, issuer.chain, issuer.keys), anchor.serviceKey, fetchImpl, Date.now, undefined, anchor.token)
|
|
126
|
+
: await registerCheckpoint(anchor.serviceName, hash, anchor.serviceKey, fetchImpl, Date.now, anchor.token);
|
|
77
127
|
if (!got.ok) {
|
|
78
128
|
appendStatus(stateDir, {
|
|
79
129
|
atMs: Date.now(),
|
|
@@ -500,6 +550,15 @@ export async function runWitness(stateDir) {
|
|
|
500
550
|
}))
|
|
501
551
|
: () => undefined;
|
|
502
552
|
const keys = loadOrCreateWitnessKeys(stateDir);
|
|
553
|
+
if (anchor?.chainPem) {
|
|
554
|
+
// A chain for another key would start a witness whose every statement the
|
|
555
|
+
// service refuses; the operator hears it here instead.
|
|
556
|
+
const issuer = statementIssuer(stateDir, anchor.chainPem);
|
|
557
|
+
if (!issuer.ok) {
|
|
558
|
+
process.stderr.write(`witness-anchor-config: ${issuer.reason}\n`);
|
|
559
|
+
process.exit(64);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
503
562
|
const token = randomBytes(16).toString("hex");
|
|
504
563
|
const server = createServer((req, res) => {
|
|
505
564
|
void (async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verax-ai/body",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@cedulon/checkpoint": "0.
|
|
25
|
-
"@cedulon/core": "0.
|
|
26
|
-
"@cedulon/cose": "0.
|
|
27
|
-
"@cedulon/effect-extract": "0.
|
|
28
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
29
|
-
"@verax-ai/inventory": "^0.
|
|
30
|
-
"@verax-ai/proxy": "^0.
|
|
31
|
-
"jose": "^6.2.
|
|
24
|
+
"@cedulon/checkpoint": "0.16.0",
|
|
25
|
+
"@cedulon/core": "0.16.0",
|
|
26
|
+
"@cedulon/cose": "0.16.0",
|
|
27
|
+
"@cedulon/effect-extract": "0.16.0",
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
29
|
+
"@verax-ai/inventory": "^0.10.0",
|
|
30
|
+
"@verax-ai/proxy": "^0.10.0",
|
|
31
|
+
"jose": "^6.2.13"
|
|
32
32
|
},
|
|
33
33
|
"description": "VERAX body: an MCP server that decides, records and proves what an agent did.",
|
|
34
34
|
"homepage": "https://verax-ai.com",
|