@verax-ai/proxy 0.9.0 → 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/dist/approvals.js +2 -0
- package/dist/canary.d.ts +118 -0
- package/dist/canary.js +755 -0
- package/dist/explain.js +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/inputs.d.ts +5 -0
- package/dist/inputs.js +38 -0
- package/dist/ledger.js +17 -1
- package/dist/policy.d.ts +9 -1
- package/dist/policy.js +38 -1
- package/dist/proxy.js +274 -26
- package/dist/session-taint.d.ts +92 -0
- package/dist/session-taint.js +343 -0
- package/dist/tool-labels.d.ts +43 -0
- package/dist/tool-labels.js +94 -0
- package/dist/types.d.ts +82 -1
- package/dist/verify-ledger.js +28 -11
- package/package.json +1 -1
package/dist/verify-ledger.js
CHANGED
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
* its recorded `effectHash` equals the row's `effectHash`, and
|
|
15
15
|
* the row carries an attestation and a witness receipt that both
|
|
16
16
|
* verify under one effect key. The signed COSE payload is
|
|
17
|
-
* `{ ref, effectHash, witnessClass, resultHash }`,
|
|
18
|
-
*
|
|
17
|
+
* `{ ref, effectHash, witnessClass, resultHash }`, plus `session`
|
|
18
|
+
* and `sessionId` when the row carries `receivingSession`, compared
|
|
19
|
+
* after decode, and the receipt's effect (`body.effects[0]`, every
|
|
19
20
|
* field the writer put there) must be that same row. A
|
|
20
21
|
* `third-party` row instead needs a one-row receipt verified
|
|
21
22
|
* under `thirdPartyPublicKeyPems` supplied by the reader, equal
|
|
@@ -90,8 +91,10 @@
|
|
|
90
91
|
*
|
|
91
92
|
* Control records are a further statement. An allow whose subject is
|
|
92
93
|
* `verax.halt` opens a halt window; an allow whose subject is `verax.resume`
|
|
93
|
-
* closes it. An allow whose subject
|
|
94
|
-
*
|
|
94
|
+
* closes it. An allow whose subject is `verax.taint-clear` is the operator
|
|
95
|
+
* clearing a session taint: it does not open or close a window, and it is
|
|
96
|
+
* not `allow-while-halted`. Any other allow while a window is open is
|
|
97
|
+
* `allow-while-halted <ref>` and `ok` is false. A deny
|
|
95
98
|
* whose reason is `halted` and which sits outside every window is the
|
|
96
99
|
* warning `halted-deny-without-halt-record <ref>` and does not change `ok`.
|
|
97
100
|
* A ledger with no control record says so, and that sentence is not a violation.
|
|
@@ -277,9 +280,10 @@ function noteEd25519(pem, problems) {
|
|
|
277
280
|
}
|
|
278
281
|
/**
|
|
279
282
|
* The writer signs `{ ref, effectHash, witnessClass, resultHash }` as COSE
|
|
280
|
-
* Sign1 and a one-row extract.
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
+
* Sign1 and a one-row extract. When the row carries `receivingSession`, the
|
|
284
|
+
* payload also has `session` and `sessionId`. A row with either signature
|
|
285
|
+
* missing is not bound. Both must verify under the key the caller settled
|
|
286
|
+
* on for this row's witness class — never a key this row brought by itself.
|
|
283
287
|
*/
|
|
284
288
|
function effectSignatureCoversRow(effect, effectKey) {
|
|
285
289
|
const coseHex = effect.attestation?.coseHex;
|
|
@@ -295,11 +299,20 @@ function effectSignatureCoversRow(effect, effectKey) {
|
|
|
295
299
|
if (typeof ref !== "string" || typeof effectHash !== "string" || typeof witnessClass !== "string") {
|
|
296
300
|
return false;
|
|
297
301
|
}
|
|
302
|
+
const receiving = effect.receivingSession;
|
|
303
|
+
const sessionBound = receiving &&
|
|
304
|
+
typeof receiving.jti === "string" &&
|
|
305
|
+
receiving.jti !== "" &&
|
|
306
|
+
typeof receiving.sessionId === "string" &&
|
|
307
|
+
receiving.sessionId !== ""
|
|
308
|
+
? { session: receiving.jti, sessionId: receiving.sessionId }
|
|
309
|
+
: null;
|
|
298
310
|
const expected = canonical({
|
|
299
311
|
ref,
|
|
300
312
|
effectHash,
|
|
301
313
|
witnessClass,
|
|
302
314
|
resultHash: typeof effect.resultHash === "string" ? effect.resultHash : null,
|
|
315
|
+
...(sessionBound ?? {}),
|
|
303
316
|
});
|
|
304
317
|
let decodedPayload;
|
|
305
318
|
try {
|
|
@@ -1038,14 +1051,18 @@ function controlStatement(records) {
|
|
|
1038
1051
|
const decision = record.claims?.decision;
|
|
1039
1052
|
const reason = record.claims?.reasonCode;
|
|
1040
1053
|
const ref = typeof record.claims?.ref === "string" ? record.claims.ref : "?";
|
|
1041
|
-
//
|
|
1042
|
-
//
|
|
1043
|
-
//
|
|
1054
|
+
// Halt and resume open or close a window. A taint clear is a control
|
|
1055
|
+
// allow and is not a tool that ran during the halt. Any other allow
|
|
1056
|
+
// inside a window is a violation, including a downstream tool whose
|
|
1057
|
+
// prefix happens to be "verax".
|
|
1044
1058
|
const control = record.claims?.effectClass === "verax.control";
|
|
1045
1059
|
const halt = control && decision === "allow" && subject === "verax.halt";
|
|
1046
1060
|
const resume = control && decision === "allow" && subject === "verax.resume";
|
|
1047
|
-
|
|
1061
|
+
const taintClear = control && decision === "allow" && subject === "verax.taint-clear";
|
|
1062
|
+
if (halt || resume || taintClear)
|
|
1048
1063
|
controlRecords += 1;
|
|
1064
|
+
if (taintClear)
|
|
1065
|
+
continue;
|
|
1049
1066
|
if (halt) {
|
|
1050
1067
|
if (!open)
|
|
1051
1068
|
windows += 1;
|