verdifax 0.2.11 → 1.0.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 +158 -5
- package/dist/index.d.mts +443 -9
- package/dist/index.d.ts +443 -9
- package/dist/index.js +542 -23
- package/dist/index.mjs +535 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,15 +49,131 @@ if (v.verified) {
|
|
|
49
49
|
| --- | --- | --- |
|
|
50
50
|
| `client.health()` | `GET /health` | none |
|
|
51
51
|
| `client.version()` | `GET /version` | none |
|
|
52
|
+
| `client.getOpenAPI()` | `GET /openapi.json` | none |
|
|
53
|
+
| `client.getStats()` | `GET /stats` | required |
|
|
52
54
|
| `client.execute(req)` | `POST /execute` | required |
|
|
55
|
+
| `client.attest(req)` | `POST /execute` | required |
|
|
56
|
+
| `client.attestClaudeResponse(args)` | `POST /execute` | required |
|
|
57
|
+
| `client.attestOpenAIResponse(args)` | `POST /execute` | required |
|
|
58
|
+
| `client.executeBatch(runs)` | `POST /execute/batch` | required |
|
|
59
|
+
| `client.verifyDeterminism(req)` | `POST /execute/verify-determinism` | required |
|
|
53
60
|
| `client.getRun(id)` | `GET /runs/{id}` | required |
|
|
54
61
|
| `client.verifyRun(id)` | `GET /runs/{id}/verify` | required |
|
|
62
|
+
| `client.listRuns(params)` | `GET /runs` | required |
|
|
63
|
+
| `client.searchRuns(params)` | `GET /runs/search` | required |
|
|
64
|
+
| `client.exportRuns(params)` | `GET /runs/export` | required |
|
|
65
|
+
| `client.exportRunsCSV(params)` | `GET /runs/export?format=csv` | required |
|
|
66
|
+
| `client.getRunArtifacts(id)` | `GET /runs/{id}/artifacts` | required |
|
|
67
|
+
| `client.getRunReport(id)` | `GET /runs/{id}/report` | required |
|
|
68
|
+
| `client.downloadAuditPDF(id, format)` | `GET /runs/{id}/report.pdf` | required |
|
|
69
|
+
| `client.getAllowToken(id)` | `GET /runs/{id}/allow-token` | required |
|
|
70
|
+
| `client.getDenyReceipt(id)` | `GET /runs/{id}/deny-receipt` | required |
|
|
71
|
+
| `client.getCCVHaltReceipt(id)` | `GET /runs/{id}/ccv-halt-receipt` | required |
|
|
72
|
+
| `client.getMACCHaltReceipt(id)` | `GET /runs/{id}/macc-halt-receipt` | required |
|
|
73
|
+
| `client.getAivpT4HaltReceipt(id)` | `GET /runs/{id}/aivp-t4-halt-receipt` | required |
|
|
74
|
+
| `client.getAttestationGapReceipt(id)` | `GET /runs/{id}/attestation-gap-receipt` | required |
|
|
75
|
+
| `client.getCESAuditRecord(id)` | `GET /runs/{id}/ces-audit-record` | required |
|
|
76
|
+
| `client.listDeletionReceipts(id)` | `GET /runs/{id}/deletion-receipts` | required |
|
|
77
|
+
| `client.listAttestations(params)` | `GET /attestations` | required |
|
|
78
|
+
| `client.getAttestation(id)` | `GET /attestations/{id}` | required |
|
|
79
|
+
| `client.getPublicBundle(id)` | `GET /runs/{id}/bundle.json` | none |
|
|
80
|
+
| `client.getPublicBundleByToken(token)` | `GET /public/runs/{token}/bundle.json` | none |
|
|
81
|
+
| `client.dcaeVerify(bundle)` | `POST /dcae/verify` | none |
|
|
82
|
+
| `client.registerRequestKey()` | `POST /keys/request-key` | required |
|
|
83
|
+
| `client.clearRequestKey()` | `DELETE /keys/request-key` | required |
|
|
84
|
+
| `client.adminCreateKey(name)` | `POST /admin/keys` | admin |
|
|
85
|
+
| `client.adminListKeys()` | `GET /admin/keys` | admin |
|
|
86
|
+
| `client.adminRevokeKey(id)` | `DELETE /admin/keys/{id}` | admin |
|
|
87
|
+
| `client.adminErase(req)` | `POST /admin/erase` | admin |
|
|
55
88
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
89
|
+
These functions make no request: `captureEnvironment`, `formatProviderPayload`, `signRequest`, `requestKeyRegistrationBody`, `requestSignaturePreimage`, `generateRequestKeyPair`, `validateHex64`, `validateRouteId`, `dseDispatchHash`, `dcaeClosureHash` and `cresReceiptHash`. `RUN_STATUSES` lists every run status the server uses.
|
|
90
|
+
|
|
91
|
+
`getRunArtifacts`, `getPublicBundle` and `getPublicBundleByToken` return the exact JSON text the server sent, so you can save it and check it with `verdifax-verify`.
|
|
92
|
+
|
|
93
|
+
## Versioning
|
|
94
|
+
|
|
95
|
+
From 1.0, a breaking change needs a new major version.
|
|
96
|
+
|
|
97
|
+
## Settings
|
|
98
|
+
|
|
99
|
+
`new VerdifaxClient(config)` takes these options. `fromEnv()` reads the same settings from the environment.
|
|
100
|
+
|
|
101
|
+
| Setting | Option | Environment variable | Default |
|
|
102
|
+
| --- | --- | --- | --- |
|
|
103
|
+
| Base URL | `baseURL` | `VERDIFAX_BASE_URL`, then `VERDIFAX_API_URL` | `https://api.verdifax.com` |
|
|
104
|
+
| API key | `apiKey` | `VERDIFAX_API_KEY` | none |
|
|
105
|
+
| Timeout | `timeoutMs` | `VERDIFAX_TIMEOUT_MS` | 90 seconds |
|
|
106
|
+
| User agent | `userAgent` | `VERDIFAX_USER_AGENT` | `verdifax-sdk-node/<version>` |
|
|
107
|
+
| Retries | `maxRetries` | `VERDIFAX_MAX_RETRIES` | 3 |
|
|
108
|
+
| First retry delay | `retryBaseDelayMs` | none | 200 ms |
|
|
109
|
+
|
|
110
|
+
GET, HEAD and OPTIONS requests are retried after a network failure or an HTTP 429, 502, 503 or 504, with exponential backoff and full jitter. POST is never retried.
|
|
111
|
+
|
|
112
|
+
## Batch runs
|
|
113
|
+
|
|
114
|
+
`executeBatch(runs)` sends up to 1,000 runs in one request and refuses more before sending anything. A row that fails comes back in `results` with `ok: false`, so the call does not throw for it.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
const batch = await client.executeBatch([
|
|
118
|
+
{ program_id, route_id, registry_record_hash, payload_text: "first" },
|
|
119
|
+
{ program_id, route_id, registry_record_hash, payload_text: "second" },
|
|
120
|
+
]);
|
|
121
|
+
|
|
122
|
+
for (const row of batch.results) {
|
|
123
|
+
console.log(row.index, row.ok, row.ok ? row.run_id : row.error);
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The client's timeout covers the whole batch, so raise `timeoutMs` for a large one. A batch is one POST and it is never retried. After a timeout the server may have run some or all of the rows, so list your runs before you send them again.
|
|
128
|
+
|
|
129
|
+
## Evidence export
|
|
130
|
+
|
|
131
|
+
`exportRuns` lists the runs the server holds for your key in a period, failures included, with up to 10,000 rows per export. `exportRunsCSV` returns the same rows as raw CSV text.
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
const period = { from: "2026-11-01T00:00:00Z", to: "2026-12-01T00:00:00Z" };
|
|
135
|
+
|
|
136
|
+
const evidence = await client.exportRuns(period);
|
|
137
|
+
console.log(evidence.total, evidence.truncated, evidence.by_status);
|
|
138
|
+
|
|
139
|
+
const { csv, total, truncated } = await client.exportRunsCSV(period);
|
|
140
|
+
if (truncated) {
|
|
141
|
+
console.log(`The CSV holds part of ${total} runs. Use a narrower period.`);
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The export states what the server stored, not a verdict. A call that never reached Verdifax cannot appear in it. Both forms say when a period holds more rows than the export returned: check `truncated`. `exportRunsCSV` reads `total` and `truncated` from the `X-Verdifax-Total` and `X-Verdifax-Truncated` response headers, and throws if the server does not send them. In the CSV, a `route_id` that a spreadsheet could read as a formula gets a leading `'`.
|
|
146
|
+
|
|
147
|
+
## Provider helpers
|
|
148
|
+
|
|
149
|
+
`attestClaudeResponse` and `attestOpenAIResponse` attest a prompt and response as one payload: canonical JSON, exactly `{"prompt":...,"provider":...,"response":...}` with sorted keys and no extra whitespace, UTF-8, with `provider` set to `anthropic` or `openai`. `formatProviderPayload` builds that text. All four Verdifax SDKs produce the same bytes. A helper call from an earlier version used a different payload, so it gave a different hash for the same text; records already stored are not touched.
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
await client.attestClaudeResponse({
|
|
153
|
+
program_id,
|
|
154
|
+
route_id,
|
|
155
|
+
registry_record_hash,
|
|
156
|
+
prompt: "What is the boiling point of water?",
|
|
157
|
+
response: "100 C at sea level.",
|
|
158
|
+
govern: true,
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
`govern` is false by default, which changes earlier behavior. Set `govern: true` to also send the response text as `ai_output_text` for the AIVP review, which runs on Anthropic in production. Without it, the AI output text is not sent for review.
|
|
163
|
+
|
|
164
|
+
## Optional execute fields
|
|
165
|
+
|
|
166
|
+
`execute`, `attest`, `executeBatch` and `verifyDeterminism` accept `attested_context`, `reproducibility_context`, `request_substance`, `authorization_chain`, `regulatory_scaffolding` and `causal_graph`. Each is recorded as supplied and Verdifax does not check it. The client derives `attested` and `declared` from the fields you provide. Leave out `request_substance.origin.source_ip_hash` and `user_agent_hash`: the server computes them. `execute`, `attest` and `verifyDeterminism` refuse them before sending, and a batch row that sets them fails in `results`.
|
|
167
|
+
|
|
168
|
+
`execute`, `attest` and `verifyDeterminism` check that `program_id` and `registry_record_hash` are 64 lowercase hex characters and that `route_id` is 1 to 256 printable ASCII characters.
|
|
169
|
+
|
|
170
|
+
## Environment capture
|
|
171
|
+
|
|
172
|
+
`captureEnvironment()` records the Node version, the platform, the packages under `node_modules`, the git commit and any seeds you declare. Pass the result as `reproducibility_context` on `execute`, `attest`, `executeBatch` or `verifyDeterminism`. Detection is best effort, and a value it cannot read is left out. The server records these values as given and does not check them.
|
|
173
|
+
|
|
174
|
+
## Determinism check
|
|
175
|
+
|
|
176
|
+
`verifyDeterminism(req)` runs one payload twice on the server and compares the manifest hashes. `deterministic` is true when both runs ended `ok` and the two hashes match. Both runs are recorded, with the status `probe`.
|
|
61
177
|
|
|
62
178
|
## Authentication
|
|
63
179
|
|
|
@@ -96,6 +212,43 @@ try {
|
|
|
96
212
|
}
|
|
97
213
|
```
|
|
98
214
|
|
|
215
|
+
## Request signing
|
|
216
|
+
|
|
217
|
+
Request signing is optional. A client with no signing key sends the same requests as before.
|
|
218
|
+
|
|
219
|
+
You can register an Ed25519 public key on your API key, so that each run must also be signed with a private key that only you hold. The key pair is created on your machine, and Verdifax receives only the public key.
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
import { VerdifaxClient, generateRequestKeyPair } from "verdifax";
|
|
223
|
+
|
|
224
|
+
// Run once, then store privateKey as a secret.
|
|
225
|
+
const { privateKey } = generateRequestKeyPair();
|
|
226
|
+
|
|
227
|
+
const client = new VerdifaxClient({
|
|
228
|
+
apiKey: process.env.VERDIFAX_API_KEY!,
|
|
229
|
+
signingKey: privateKey, // the 32 raw bytes, as a Buffer or Uint8Array
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
await client.registerRequestKey(); // sends the public key with its proof
|
|
233
|
+
|
|
234
|
+
// execute, attest, attestClaudeResponse, attestOpenAIResponse, executeBatch
|
|
235
|
+
// and verifyDeterminism now sign.
|
|
236
|
+
await client.execute({
|
|
237
|
+
program_id: "1111111111111111111111111111111111111111111111111111111111111111",
|
|
238
|
+
route_id: "demo-attestation",
|
|
239
|
+
registry_record_hash: "2222222222222222222222222222222222222222222222222222222222222222",
|
|
240
|
+
payload_text: "first signed attestation",
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
await client.clearRequestKey(); // stops requiring signatures on this API key
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Registering a key changes that API key for every client that uses it: the server then refuses a run without a valid signature, so every caller on the key needs the private key. Each request carries the time and a fresh random nonce. The server refuses a repeated nonce and a time more than five minutes from its own clock.
|
|
247
|
+
|
|
248
|
+
In a batch each row carries its own signature and nonce, and the server checks them as it reaches that row. A row refused for its signature comes back in `results`, so a repeated batch returns HTTP 200 with failed rows, and a row reached more than five minutes after it was signed fails the same way. A determinism check uses one signature for the request, and repeating it returns HTTP 403.
|
|
249
|
+
|
|
250
|
+
The signature shows the holder of the key requested the run. It does not show the key holder accepted the outcome.
|
|
251
|
+
|
|
99
252
|
## Trust model
|
|
100
253
|
|
|
101
254
|
This SDK only mediates HTTP I/O, it does NOT verify sealed
|