@valiron/sdk 1.4.0 → 2.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.
@@ -1,5 +1,7 @@
1
1
  # End-to-End Valiron Middleware Integration
2
2
 
3
+ > **Request verification:** Examples using `verifyAgentRequest` assume an application-owned verifier imported from your own module, not an SDK export. It must verify a fresh signature against the claimed identity, bind method, full URL and body, and atomically reject replayed nonces. See the [request-proof upgrade guide](https://www.valiron.co/docs/agents/SECURITY-UPGRADE-2026-10-31.md). Missing or invalid proofs return 401 before profile-cache lookup.
4
+
3
5
  This guide helps API teams integrate Valiron middleware from the first incoming
4
6
  agent request through the downstream action they want to take. Start with the
5
7
  agent identity, choose the trust signals that match your policy, then use the
@@ -18,8 +20,8 @@ Incoming request
18
20
  ## Before you start
19
21
 
20
22
  1. Create an operator account in the [Dashboard](./DASHBOARD.md).
21
- 2. Copy an operator API key (`val_op_...`) if you will use Pro trust signals,
22
- operator usage logging, or hosted products.
23
+ 2. Copy an operator API key (`val_op_...`) for profile reads, gates, sandbox runs,
24
+ operator usage logging, or hosted products on Free or paid plans.
23
25
  3. Install the SDK:
24
26
 
25
27
  ```bash
@@ -65,10 +67,10 @@ protecting.
65
67
  | --- | --- | --- |
66
68
  | `8004` | Registry-backed on-chain identity and reputation | All plans |
67
69
  | `sandbox` | Behavioral evaluation and route readiness | All plans |
68
- | `world` | World ID proof-of-personhood linkage | Pro |
69
- | `self` | Self eligible-human verification | Pro |
70
+ | `world` | World ID proof-of-personhood linkage | Free |
71
+ | `self` | Self eligible-human verification | Free |
70
72
  | `icebreaker` | Human-to-agent attestation | Pro |
71
- | `wallet` | Explainable wallet-history risk, confidence, and hard flags | Pro |
73
+ | `wallet` | Explainable wallet-history risk, confidence, and hard flags | Free |
72
74
 
73
75
  For example, a high-value endpoint might require on-chain reputation,
74
76
  behavioral evidence, and wallet intelligence:
@@ -82,6 +84,7 @@ const valiron = new ValironSDK({
82
84
  });
83
85
 
84
86
  const trustGate = createValironGate({
87
+ verifyRequest: verifyAgentRequest,
85
88
  sdk: valiron,
86
89
  trustSignals: ["8004", "sandbox", "wallet"],
87
90
  minScore: 80,
@@ -108,7 +111,7 @@ Choose the behavior that fits the endpoint:
108
111
  | Trust-aware pricing | Read the result in your handler and apply your own price or entitlement policy |
109
112
  | Monetized endpoint logging | Use `ValironOperator.paywall()` to gate access, attach a configured per-call price, and record usage |
110
113
  | Agent profile lookup | Retrieve a profile when your product needs to display or review trust evidence |
111
- | Predictive risk | Use dashboard/API forecasts as an additional operational signal; do not replace the runtime gate with a forecast |
114
+ | Predictive risk | Use dashboard forecasts as an additional operational signal; do not replace the runtime gate with a forecast |
112
115
  | Audit and operations | Capture the result in your logs or use authenticated dashboard call logs |
113
116
 
114
117
  Valiron does not itself settle a payment or choose a dynamic price table. It
@@ -117,7 +120,9 @@ can use.
117
120
 
118
121
  ## 4. Put the gate in front of your handler
119
122
 
120
- Here is a complete Express example that supports both agent identity paths and
123
+ Import `verifyAgentRequest` from your application-owned signature verifier. It must bind the identity, method, full URL and body, enforce freshness, and atomically claim nonces before returning true; see the [upgrade guide](./SECURITY-UPGRADE-2026-10-31.md).
124
+
125
+ Here is an Express example that supports both agent identity paths and
121
126
  uses the route decision for graduated access:
122
127
 
123
128
  ```typescript
@@ -131,6 +136,7 @@ const valiron = new ValironSDK({
131
136
  });
132
137
 
133
138
  app.use("/api/research", createValironGate({
139
+ verifyRequest: verifyAgentRequest,
134
140
  sdk: valiron,
135
141
  trustSignals: ["8004", "sandbox", "wallet"],
136
142
  minScore: 65,
@@ -147,9 +153,8 @@ app.get("/api/research", (req, res) => {
147
153
  res.set("X-Rate-Limit-Policy", "reduced");
148
154
  }
149
155
 
150
- if (trust.route === "sandbox") {
151
- return res.json({ mode: "sandbox", results: [] });
152
- }
156
+ // Denied and pending agents never reach this handler. Use a separate,
157
+ // explicitly scoped route if your product offers sandbox data.
153
158
 
154
159
  return res.json({
155
160
  mode: "production",
@@ -182,6 +187,7 @@ const operator = new ValironOperator({
182
187
  });
183
188
 
184
189
  app.use("/api/premium", operator.paywall({
190
+ verifyRequest: verifyAgentRequest,
185
191
  pricePerCall: 0.05,
186
192
  minTrustScore: 65,
187
193
  trustSignals: ["8004", "sandbox", "wallet"],
@@ -197,9 +203,9 @@ to reach it.
197
203
 
198
204
  Test each case before production:
199
205
 
200
- 1. A registered agent using `x-agent-id`.
201
- 2. A verified key-based agent using `x-agent-address`.
202
- 3. A request without either identity header.
206
+ 1. A registered agent using `x-agent-id` plus a fresh valid request proof.
207
+ 2. An enrolled key-based agent using `x-agent-address` plus a fresh valid request proof.
208
+ 3. Missing headers, a forged identity claim, a replayed nonce and a signature for a different method/URL/body; all must deny access.
203
209
  4. An agent below your `minScore`.
204
210
  5. A new agent pending sandbox evaluation.
205
211
  6. A production-eligible agent on every protected route.
package/docs/ERRORS.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Common error scenarios, status codes, and guidance on how to handle them.
4
4
 
5
+ The separate Crawler Protection product uses `AdmissionError` and adapter codes `CRAWLER_LIMIT` (429), `CRAWLER_UNAVAILABLE` (503), and `CRAWLER_BLOCK` (403 for an enforced crawler deny rule or application-defined block). These are not `ValironError` failures from `@valiron/sdk`. See [crawler decisions and recovery](./CRAWLER-PROTECTION.md#decisions-and-recovery); rate/capacity rejections must not execute protected work. The standalone gateway adds proxy errors such as 413 for oversized requests, 503 for exhausted origin capacity and 504 for an origin timeout. The private work API uses 401/403 for service/capability failures and 503 for unavailable work. Do not automatically retry an ambiguous acquisition or release capacity because an HTTP timeout elapsed; query settlement must be confirmed.
6
+
5
7
  ## Read an error before retrying
6
8
 
7
9
  Every SDK failure is a `ValironError`. Its stable `code` is for program logic; its `message` is safe to show in developer logs; and `details` provides the recovery information that was available from the API.
@@ -61,7 +63,7 @@ The SDK throws typed errors that you can catch:
61
63
  ```typescript
62
64
  import { ValironSDK } from "@valiron/sdk";
63
65
 
64
- const valiron = new ValironSDK();
66
+ const valiron = new ValironSDK({ apiKey: process.env.VALIRON_API_KEY });
65
67
 
66
68
  try {
67
69
  const profile = await valiron.getAgentProfile("99999");
@@ -128,14 +130,14 @@ await valiron.triggerSandboxTest("YOUR_AGENT_ID");
128
130
 
129
131
  ### Provisional scores
130
132
 
131
- First-time agents that haven't been sandbox-tested yet receive provisional scores. Provisional evaluations use a higher trust threshold — meaning the agent must prove itself more thoroughly on its first interaction. After the first sandbox run completes, future gate() calls use the standard threshold.
133
+ New agents remain denied while their real sandbox evaluation is pending. Provisional or synthetic scores cannot authorize production access and cannot overwrite definitive evaluation results. Retry with the same identity and a fresh request proof after the indicated delay.
132
134
 
133
135
  ### Timeout errors
134
136
 
135
137
  The SDK uses method-aware default timeouts: 10 seconds generally, 15 seconds for `gate()`/`proxy()`, and 30 seconds for sandbox triggers. To force a single timeout for all calls, configure it explicitly:
136
138
 
137
139
  ```typescript
138
- const valiron = new ValironSDK({ timeout: 30000 }); // 30 seconds
140
+ const valiron = new ValironSDK({ apiKey: process.env.VALIRON_API_KEY, timeout: 30000 }); // 30 seconds
139
141
  ```
140
142
 
141
143
  ### Chain mismatch
@@ -143,7 +145,7 @@ const valiron = new ValironSDK({ timeout: 30000 }); // 30 seconds
143
145
  If the agent is registered on Monad but you query Ethereum (the default), it will return 404. Always specify the correct chain:
144
146
 
145
147
  ```typescript
146
- const valiron = new ValironSDK({ chain: "monad" });
148
+ const valiron = new ValironSDK({ apiKey: process.env.VALIRON_API_KEY, chain: "monad" });
147
149
  ```
148
150
 
149
151
  ### Wallet intelligence unavailable
@@ -157,15 +159,17 @@ const valiron = new ValironSDK({ chain: "monad" });
157
159
 
158
160
  Unavailable wallet intelligence is excluded from profile and gate composite scoring. Retry provider failures according to your policy; do not reinterpret an unavailable assessment as malicious activity.
159
161
 
160
- ### Wallet intelligence requires Pro
162
+ ### Social Graph requires Pro
163
+
164
+ Wallet intelligence is included with Free, but requires an authenticated operator key. Missing or invalid credentials return HTTP 401 before provider work.
161
165
 
162
- Direct wallet-risk requests and policies containing `trustSignals: ["wallet"]` require a valid Pro or Enterprise operator key. A Free or unauthenticated request returns:
166
+ Policies containing `trustSignals: ["icebreaker"]` require Pro or Enterprise. An authenticated Free request returns HTTP 403:
163
167
 
164
168
  ```json
165
169
  {
166
170
  "error": "upgrade_required",
167
- "feature": "enriched_profiles",
168
- "message": "World ID, Self, Icebreaker, and wallet intelligence signals require a Pro plan. Free plans can use ERC-8004 and sandbox signals."
171
+ "feature": "social_graph",
172
+ "message": "Social Graph (Icebreaker) requires a Pro plan. ERC-8004, sandbox, World ID, Self, and wallet intelligence are included with Free."
169
173
  }
170
174
  ```
171
175
 
@@ -218,11 +222,12 @@ All Valiron middleware (Express, Fastify, Next.js, generic) returns consistent e
218
222
  | Status | Code | When | What to do |
219
223
  |--------|------|------|
220
224
  | 401 | `MISSING_AGENT_IDENTITY` | No identity header | Send one supported identity header: `x-agent-id` or `x-agent-address` |
225
+ | 401 | `AGENT_OWNERSHIP_REQUIRED` | Missing verifier, invalid owner proof, stale timestamp, wrong request binding or replay | Configure the verifier/signer; generate a fresh nonce and sign the actual identity, chain, method, URL and body |
221
226
  | 403 | `TRUST_GATE_DENIED` | Agent did not meet the configured policy | Inspect `score`, `tier`, `route`, and `reasons`; do not blindly retry |
222
227
  | 403 | `AGENT_EVALUATION_PENDING` | New identity is sandbox-evaluating | Keep the same identity and retry after `retryAfterMs` |
223
228
  | 503 | `TRUST_GATE_UNAVAILABLE` | Trust evaluation could not complete | Fail closed; retry shortly and inspect the logged `cause` |
224
229
 
225
- Each response includes `message`, `action`, and `docsUrl`; denials retain the trust result fields so an application can make a deliberate fallback decision.
230
+ Standard missing-identity, trust-denial, pending and unavailable responses include recovery fields such as `message`, `action`, and `docsUrl`. Ownership-proof rejections may contain only `code` and `error`; handle the stable code without assuming those optional fields exist.
226
231
 
227
232
  > **Fail-closed:** When the Valiron service is unreachable, middleware returns 503 — it never fails open and never allows unverified agents through.
228
233
 
@@ -241,8 +246,8 @@ its exact bytes. `IDENTITY_GATE_UNAVAILABLE` is a fail-closed HTTP 503.
241
246
  | Failure reason | Meaning | Action |
242
247
  | --- | --- | --- |
243
248
  | `provider_missing` | An agent ID was supplied without a provider | Send the resolver provider name |
244
- | `resolver_unavailable` | No adapter is registered for the provider | For ANS, configure credentials and a trusted CA bundle; never treat the claim as verified |
245
- | `proof_incomplete` | Signature, timestamp, nonce, or digest is missing | Construct and sign the complete proof |
249
+ | `resolver_unavailable` | No adapter is registered for the provider | For hosted ANS, retry or contact support; never treat an unavailable resolver as verified |
250
+ | `proof_incomplete` | Signature, timestamp, nonce, digest, audience, method or URL is missing | Construct and sign the complete proof |
246
251
  | `request_digest_invalid` | Digest is not `sha256:` plus 64 hex characters | Recalculate and format the SHA-256 digest |
247
252
  | `nonce_invalid` | Nonce is shorter than 16 characters or contains unsupported characters | Generate a 16–256 character URL-safe nonce |
248
253
  | `timestamp_invalid` | Timestamp cannot be parsed | Send an ISO-8601 timestamp |
@@ -291,25 +296,28 @@ store or other safe-verification failure returns HTTP 503 with
291
296
 
292
297
  | Status | When | Action |
293
298
  |--------|------|--------|
294
- | 400 | Invalid or malformed proof | Verify your World ID proof payload fields |
295
- | 404 | Agent has no World ID verification | The agent hasn't completed World ID verification yet |
296
- | 409 | Nullifier hash already used | This World ID proof has already been submitted |
299
+ | 401 | Missing operator credentials or owner proof | Authenticate the operator and sign this exact enrollment request |
300
+ | 400 | Missing/unsupported IDKit result, failed server verification or proof bound to another agent | Submit the complete production result for the configured action; partial proofs and caller-selected strength are insufficient |
301
+ | 404 | Agent not found on-chain | Use an existing registry agent; an unverified status lookup normally returns `verified: false` |
297
302
 
298
303
  ## Self Errors
299
304
 
305
+ Session creation requires an operator key and fresh owner signature. Missing/invalid ownership returns 401; an unsupported return origin returns 400. Older sessions without owner-verification provenance cannot establish a new trusted link.
306
+
300
307
  | Status | When | Action |
301
308
  |--------|------|--------|
302
- | 400 | Raw webhook body unavailable or Self webhook signature invalid | Configure Self to call `/operator/self/webhook` and keep the endpoint's `whsec_...` value in `SELF_TEST_WEBHOOK_SECRET` or `SELF_LIVE_WEBHOOK_SECRET` |
309
+ | 400 | Raw webhook body unavailable or Self webhook signature invalid | Valiron manages the provider callback. Check session status and contact support if verification remains pending after completing the Self flow |
303
310
  | 400 | Self webhook cannot be mapped to a Valiron session | Create sessions through `createSelfSession()` or `POST /operator/self/session/:agentId` so `externalUuid` is stored before the webhook arrives |
304
- | 403 | Trusted Self payload ingestion is disabled | Use the production session + signed webhook flow, or set `SELF_ALLOW_TRUSTED_PAYLOADS=true` only for local/internal tests |
311
+ | 403 | Trusted Self payload ingestion is disabled | Use `createSelfSession()` and check `getSelfStatus()`; direct proof ingestion is not supported for hosted customer integrations |
305
312
  | 404 | Agent not found on-chain | Use an existing ERC-8004 agent ID or a supported Solana agent ID before creating a Self session |
306
313
  | 409 | Agent already has a verified Self link | Self links are immutable once verified |
307
314
 
308
315
  ## Monthly request allowance
309
316
 
310
- `429 MONTHLY_REQUEST_LIMIT_EXCEEDED` means the account has used its 100,000
311
- Free requests for the UTC calendar month. Upgrade to Pro or wait until
312
- `resetsAt`; use `Retry-After` rather than retrying continuously. This allowance
317
+ `429 MONTHLY_REQUEST_LIMIT_EXCEEDED` means the account has used its monthly
318
+ allowance (10,000 on Free or 100,000 on Pro) for the UTC calendar month.
319
+ Agent and bot protection allowances are separate. Upgrade Free to Pro, email
320
+ founders@valiron.co for Enterprise, or wait until `resetsAt`; use `Retry-After` rather than retrying continuously. This allowance
313
321
  is shared across API keys and hosted endpoints.
314
322
 
315
323
  `503 MONTHLY_USAGE_UNAVAILABLE` means request usage could not be checked.
package/docs/IDENTITY.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Agent Identity: On-Chain, Key-Based, and Provider-Backed Agents
2
2
 
3
+ Ordinary website crawlers use a separate [Valiron Crawler Protection source-verification path](./CRAWLER-PROTECTION.md). They need not register an agent key, wallet or on-chain identity. IP/DNS or authenticated verified-WAF evidence establishes network provenance, not signed agent possession or human identity; work budgets remain necessary even for a verified crawler.
4
+
3
5
  Valiron supports on-chain, key-based, and provider-backed middleware identity
4
6
  paths:
5
7
 
@@ -14,7 +16,7 @@ Use `/operator/agent/:agentId` only for registry-backed on-chain agents. Local a
14
16
 
15
17
  The provider-backed framework normalizes identity into `anonymous`, `claimed`,
16
18
  or `verified`, performs freshness and replay checks, and can return an
17
- `allow`, `limit`, `challenge`, or `block` policy action. SDK 1.3 includes
19
+ `allow`, `limit`, `challenge`, or `block` policy action. The SDK includes
18
20
  signing helpers and dedicated provider identity gates; Valiron hosts the ANS
19
21
  credentials and trusted CA bundle. See
20
22
  [Provider-Backed Agent Identity](./PROVIDER-IDENTITY.md) for the exact request,
@@ -22,7 +24,7 @@ signature payload, SDK integration, response, and current ANS boundary.
22
24
 
23
25
  ## Wallet as a Trust Input
24
26
 
25
- When a Pro policy selects `trustSignals: ["wallet"]`, Valiron evaluates the wallet associated with the chosen identity path. ERC-8004 and Solana agents use the wallet resolved from their registry identity; key-based agents use their verified persistent agent address. Wallet intelligence does not establish identity by itself—it is an additional economic-history signal applied after Valiron has a wallet address.
27
+ When a Free or paid policy selects `trustSignals: ["wallet"]`, Valiron evaluates the wallet associated with the chosen identity path. ERC-8004 and Solana agents use the wallet resolved from their registry identity; key-based agents use their verified persistent agent address. Wallet intelligence does not establish identity by itself—it is an additional economic-history signal applied after Valiron has a wallet address.
26
28
 
27
29
  Use `getWalletProfile()` to resolve a wallet to an agent profile. Use `getWalletRisk()` when you need only the explainable wallet-history assessment. See [TRUST-MODEL.md](./TRUST-MODEL.md#wallet-intelligence) for supported networks and limitations.
28
30
 
@@ -123,7 +125,7 @@ const tokenUri = await client.readContract({
123
125
  ```typescript
124
126
  import { ValironSDK } from "@valiron/sdk";
125
127
 
126
- const valiron = new ValironSDK();
128
+ const valiron = new ValironSDK({ apiKey: process.env.VALIRON_API_KEY });
127
129
  const profile = await valiron.getAgentProfile("25459");
128
130
 
129
131
  console.log(profile.identity.name);
@@ -186,7 +188,7 @@ Not every agent has an on-chain ERC-8004 identity. For local, Web2, and non-ERC-
186
188
  3. Agent signs the nonce with their private key (EIP-191 personal sign)
187
189
  4. Valiron verifies the signature and creates a `KeyAgentProfile`
188
190
 
189
- The SDK and middleware auto-detect key-based agents from the `x-agent-address` header. The standard trust gate reads a previously verified profile; the header alone is not a fresh proof of possession. API sellers should bind it to their authenticated caller before a sensitive action.
191
+ The middleware detects key-based claims from `x-agent-address`, then requires `verifyRequest` to verify a fresh request-bound signature and reject replay. The header or a previously enrolled profile is insufficient. See the [request-proof upgrade guide](./SECURITY-UPGRADE-2026-10-31.md).
190
192
 
191
193
  Agents can follow the hosted identity skill at [https://www.valiron.co/auth.md](https://www.valiron.co/auth.md) to generate an identifier, request a challenge, sign it, and cache the returned session token.
192
194
 
@@ -214,8 +216,8 @@ action-specific policy for Icebreaker context.
214
216
  | `tier` | string \| null | Moody's-style trust tier once scored |
215
217
  | `riskLevel` | string \| null | GREEN / YELLOW / RED once scored |
216
218
  | `route` | string \| null | Route decision once scored |
217
- | `icebreaker` | object \| null | Redacted to `null` on the public endpoint; use `getKeyAgentIcebreaker()` with a Pro key |
218
- | `reasons` | string[] | Redacted to `[]` on the public endpoint |
219
+ | `icebreaker` | object \| null | Redacted to `null` on the authenticated summary endpoint; use `getKeyAgentIcebreaker()` with a Pro key |
220
+ | `reasons` | string[] | Redacted to `[]` on the authenticated summary endpoint |
219
221
  | `timestamp` | string | ISO timestamp for the profile response |
220
222
 
221
223
  ### Key-Based vs On-Chain Agents
@@ -240,9 +242,9 @@ World ID verifies that an agent is linked to a real human via Worldcoin's zero-k
240
242
 
241
243
  ### How It Works
242
244
 
243
- 1. Agent owner completes World ID verification (orb or device level)
244
- 2. The proof is submitted to Valiron via `verifyWorldId()` or the API endpoint
245
- 3. Valiron stores the verification status and includes it in trust evaluation
245
+ 1. The current registry owner authorizes enrollment with a fresh signed request, and an authenticated operator submits it.
246
+ 2. The complete production IDKit result is submitted unchanged as `idkit_result`; current enrollment accepts proof-of-human credentials.
247
+ 3. Valiron verifies the configured RP/action server-side, derives credential strength from verified evidence, and stores the link. Legacy records without server-verification provenance require re-verification.
246
248
 
247
249
  ### SDK Methods
248
250
 
@@ -252,7 +254,7 @@ await valiron.verifyWorldId("25459", proof);
252
254
 
253
255
  // Check verification status
254
256
  const status = await valiron.getWorldIdStatus("25459");
255
- // { verified: true, verifiedAt: "...", level: "orb" }
257
+ // status.worldId: { verified: true, verificationLevel: "orb" }
256
258
 
257
259
  // Get full profile
258
260
  const profile = await valiron.getWorldIdProfile("25459");
@@ -272,7 +274,7 @@ Self Agent ID can be supplied when creating a session. When present and confirme
272
274
 
273
275
  ### How It Works
274
276
 
275
- 1. Valiron creates a Self Enterprise session with `createSelfSession()` or `POST /operator/self/session/:agentId`
277
+ 1. An authenticated operator submits a fresh registry-owner proof; Valiron creates an owner-authorized Self Enterprise session with `createSelfSession()` or `POST /operator/self/session/:agentId`
276
278
  2. The user opens the returned `verificationUrl` and completes the Self flow
277
279
  3. Self sends a signed `verification.completed` webhook to `/operator/self/webhook`
278
280
  4. Valiron verifies the raw webhook body with Self's webhook verifier and stores the Self status
@@ -348,10 +350,10 @@ Both work interchangeably in Valiron's API:
348
350
 
349
351
  ```bash
350
352
  # By asset pubkey
351
- curl "https://valiron-edge-proxy.onrender.com/operator/agent/DFknts...?chain=solana"
353
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" "https://valiron-edge-proxy.onrender.com/operator/agent/DFknts...?chain=solana"
352
354
 
353
355
  # By sequential ID
354
- curl "https://valiron-edge-proxy.onrender.com/operator/agent/1226?chain=solana"
356
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" "https://valiron-edge-proxy.onrender.com/operator/agent/1226?chain=solana"
355
357
  ```
356
358
 
357
359
  ### Reading Solana Identity
@@ -359,7 +361,7 @@ curl "https://valiron-edge-proxy.onrender.com/operator/agent/1226?chain=solana"
359
361
  ```typescript
360
362
  import { ValironSDK } from "@valiron/sdk";
361
363
 
362
- const valiron = new ValironSDK({ chain: "solana" });
364
+ const valiron = new ValironSDK({ apiKey: process.env.VALIRON_API_KEY, chain: "solana" });
363
365
  const profile = await valiron.getAgentProfile("1226"); // sequential ID
364
366
 
365
367
  console.log(profile.identity.name); // "NoahScout_Bot.noah"
@@ -3,11 +3,11 @@
3
3
  Valiron now has a provider-independent verification foundation for identities
4
4
  resolved through ANS, DNS, DIDs, API keys, and future standards. An ANS REST
5
5
  resolver adapter is implemented and is registered at service startup when its
6
- credentials and trusted CA bundle are configured. SDK 1.3 adds signing helpers,
6
+ credentials and trusted CA bundle are configured. The SDK provides signing helpers,
7
7
  a typed verification method, and dedicated identity gates for Express, Fastify,
8
8
  Next.js, and framework-independent runtimes.
9
9
 
10
- Verification calls require your operator API key and count toward your account’s monthly request allowance. Free includes 100,000 metered requests per UTC calendar month; Pro has no monthly request cap.
10
+ Verification calls require your operator API key and count toward your account’s monthly request allowance. Free includes 10,000 metered agent requests per UTC calendar month; Pro includes 100,000. Bot protection has a separate allowance at the same limits. Enterprise: email founders@valiron.co.
11
11
 
12
12
  ## Responsibility boundary
13
13
 
@@ -63,6 +63,9 @@ const proof = await createAgentIdentityProof({
63
63
  provider: "ans",
64
64
  agentId: "ans://v1.0.0.sales-agent.acme.com",
65
65
  body,
66
+ audience: "https://api.example.com",
67
+ method: "POST",
68
+ url: "https://api.example.com/quote",
66
69
  sign: (payload) => agentKey.sign(payload),
67
70
  });
68
71
 
@@ -116,6 +119,8 @@ const valiron = new ValironSDK({ apiKey: process.env.VALIRON_API_KEY });
116
119
 
117
120
  app.post("/quote", createValironIdentityGate({
118
121
  sdk: valiron,
122
+ audience: "https://api.example.com",
123
+ origin: "https://api.example.com",
119
124
  policy: {
120
125
  anonymous: "challenge",
121
126
  claimed: "block",
@@ -165,7 +170,10 @@ Equivalent exports are `valironIdentityFastifyPlugin`,
165
170
  The signature covers the UTF-8 bytes of this exact payload:
166
171
 
167
172
  ```text
168
- valiron-agent-request-v1
173
+ valiron-agent-request-v2
174
+ audience:<API-owner-configured-audience>
175
+ method:<UPPERCASE-HTTP-method>
176
+ url:<absolute-request-URL>
169
177
  agent-id:<provider-canonical-agent-id>
170
178
  timestamp:<timestamp-as-submitted>
171
179
  nonce:<nonce-as-submitted>
@@ -176,6 +184,8 @@ The request digest must use `sha256:` followed by 64 hexadecimal characters.
176
184
  The nonce must contain 16–256 URL-safe characters. The default timestamp window
177
185
  is five minutes, and nonce claims are retained for ten minutes.
178
186
 
187
+ The receiving API must derive the audience, method, URL and `requestDigest` from its own trusted configuration and the actual protected request. It must not copy these fields from caller-supplied headers.
188
+
179
189
  The caller must calculate `requestDigest` from the protected request bytes and
180
190
  apply the returned decision to that same request. This standalone verification
181
191
  endpoint cannot infer the bytes of a separate downstream request.
@@ -211,7 +221,7 @@ machine-readable `failureReason`. See [Errors](./ERRORS.md#provider-backed-ident
211
221
 
212
222
  ## Replay and storage behavior
213
223
 
214
- Nonce claims use an atomic Redis write. Verification returns HTTP 503 when the
224
+ Each request nonce can be accepted only once. Verification returns HTTP 503 when the
215
225
  replay store is unavailable, so the flow cannot fail open. Only verified
216
226
  requests update the stable identity activity record. Failed claims cannot write
217
227
  activity or reputation against the identity they attempted to impersonate.
@@ -238,7 +248,7 @@ For an ANS claim, the adapter:
238
248
  6. loads the current Transparency Log record, requires `ACTIVE` or `WARNING`, and matches its identity-certificate fingerprint; and
239
249
  7. extracts the certificate public key for the Valiron request proof.
240
250
 
241
- The timestamp, nonce, request digest, and `valiron-agent-request-v1` payload are
251
+ The timestamp, nonce, request digest, and `valiron-agent-request-v2` payload are
242
252
  a Valiron transport-proof envelope. They are not presented as an ANS-native HTTP
243
253
  signature standard.
244
254
 
@@ -1,11 +1,17 @@
1
1
  # Quickstart
2
2
 
3
- > Estimated integration time: under 2 minutes.
3
+ > **Request verification:** Examples using `verifyAgentRequest` assume an application-owned verifier imported from your own module, not an SDK export. It must verify a fresh signature against the claimed identity, bind method, full URL and body, and atomically reject replayed nonces. See the [request-proof upgrade guide](https://www.valiron.co/docs/agents/SECURITY-UPGRADE-2026-10-31.md). Missing or invalid proofs return 401 before profile-cache lookup.
4
+
5
+ Configure identity verification before opening a protected endpoint. Existing integrations should follow the [request-proof upgrade guide](./SECURITY-UPGRADE-2026-10-31.md).
6
+
7
+ This quickstart documents the hardened agent identity/trust SDK contract in this source tree. Verify your installed npm version supports `verifyRequest`, `signRequest` and provider request proofs v2 before upgrading a live integration; source changes do not publish a package. For ordinary website crawlers, see [controlled crawler access](./CRAWLER-PROTECTION.md): a separate integration package with a standalone HTTP gateway for other website stacks, in-process Node/Nuxt adapters, shared budgets and a private language-neutral work API. Node.js is required for the gateway service, not for the website behind it. Query-level limits require operation integration; Python/SQLite and Node/Nuxt/MariaDB are tested. It is not installed by `npm install @valiron/sdk` and does not require crawler agent registration.
8
+
9
+ SDK 0.2.0+ requires a Free/Pro/Enterprise operator API key and account-bound activation via `activateCrawlerProtection()` before constructing its runtime. Activation uses a short-lived local lease, refreshed in the background. Each protected HTTP request requires hosted monthly quota admission; database operations are not counted again. See the crawler guide for revocation, outage and recovery behavior.
4
10
 
5
11
  ## Prerequisites
6
12
 
7
13
  1. **Create an account** with email/password, Google, or GitHub on the [Operator Dashboard](./DASHBOARD.md) at [valiron.co/dashboard](https://www.valiron.co/dashboard)
8
- 2. **Complete the guided setup** — every sign-up method enters the same resumable onboarding flow
14
+ 2. **Verify your email for password signup**, then **complete the guided setup** — every sign-up method enters the same resumable onboarding flow
9
15
  3. **Copy your API key** when it is shown; returning incomplete accounts can generate a dedicated setup key
10
16
  4. Add the SDK middleware below to the backend routes agents call. Choose registered, key-based, or ANS/provider-backed identity in the wizard.
11
17
 
@@ -25,13 +31,14 @@ npm install @valiron/sdk
25
31
  import { ValironSDK } from "@valiron/sdk";
26
32
 
27
33
  const valiron = new ValironSDK({
34
+ apiKey: process.env.VALIRON_API_KEY,
28
35
  endpoint: "https://valiron-edge-proxy.onrender.com",
29
36
  chain: "ethereum", // or: monad, arbitrum, base, polygon, solana, etc.
30
37
  timeout: 5000,
31
38
  });
32
39
  ```
33
40
 
34
- No API key is required for read operations.
41
+ Get an operator API key from https://www.valiron.co/dashboard and configure it server-side for profile reads, trust gates, and sandbox runs. Pro is required only for Social Graph (Icebreaker); other capabilities are Free within usage limits.
35
42
 
36
43
  > **Solana agents:** Use `chain: "solana"` and pass the agent's Metaplex Core asset
37
44
  > pubkey (base-58) as the agent ID instead of a numeric token ID.
@@ -78,7 +85,6 @@ For an on-chain agent:
78
85
  const profile = await valiron.getAgentProfile("INCOMING_AGENT_ID");
79
86
 
80
87
  console.log(profile.routing.finalRoute); // "prod"
81
- console.log(profile.routing.meetsThreshold); // true
82
88
  console.log(profile.onchainReputation.averageScore); // 92.5
83
89
  ```
84
90
 
@@ -99,17 +105,18 @@ The fastest way to protect your API — add Valiron as Express middleware:
99
105
  ```typescript
100
106
  import { createValironGate } from "@valiron/sdk";
101
107
 
102
- app.use("/api/paid", createValironGate({ sdk: valiron }));
108
+ app.use("/api/paid", createValironGate({ verifyRequest: verifyAgentRequest, sdk: valiron }));
103
109
  ```
104
110
 
105
- This checks `x-agent-id` first for on-chain agents, then falls back to `x-agent-address` for key-based agents. It returns 403 for untrusted agents, is safe with Express 4 (async errors are handled), and includes a 30-second client-side cache for x402 compatibility.
111
+ The gate identifies the claimed subject from `x-agent-id` or `x-agent-address`, then calls your verifier before every decision, including cache hits. Missing/invalid proofs return 401; denied or pending evaluations return 403; unavailable evaluation returns 503. The 30-second cache stores reputation decisions, never proof authorization.
106
112
 
107
- Pro operators can include wallet history in an endpoint policy:
113
+ Free and paid operators can include wallet history in an endpoint policy:
108
114
 
109
115
  ```typescript
110
116
  const valiron = new ValironSDK({ apiKey: process.env.VALIRON_API_KEY });
111
117
 
112
118
  app.use("/api/high-trust", createValironGate({
119
+ verifyRequest: verifyAgentRequest,
113
120
  sdk: valiron,
114
121
  trustSignals: ["8004", "sandbox", "wallet"],
115
122
  minScore: 80,
@@ -123,20 +130,22 @@ Or use `getAgentProfile()` directly for on-chain custom logic:
123
130
  ```typescript
124
131
  const profile = await valiron.getAgentProfile("INCOMING_AGENT_ID");
125
132
  const { finalRoute, decision } = profile.routing;
126
- if (finalRoute === "prod" || finalRoute === "prod_throttled") {
133
+ if (await verifyAgentRequest(request, "INCOMING_AGENT_ID") &&
134
+ (finalRoute === "prod" || finalRoute === "prod_throttled")) {
127
135
  // Serve the request — agent is trusted
128
136
  } else {
129
137
  // Block — agent is untrusted (tier: profile.localReputation?.tier)
130
138
  }
131
139
  ```
132
140
 
133
- > **Note**: The `gate()` method calls a protected endpoint that requires agent challenge-response auth. Use the middleware (`createValironGate`) or `getAgentProfile()` for server-side trust checks.
141
+ > **Hosted calls:** `gate()`, `proxy()`, `verifyWorldId()` and `createSelfSession()` need operator credentials plus a fresh owner-signed request. Configure `signRequest` as described in the [upgrade guide](./SECURITY-UPGRADE-2026-10-31.md). Key-registration challenges or legacy agent sessions do not replace that proof. Profile reads are authenticated evidence lookups, not caller authentication.
134
142
 
135
143
  For key-based agents, use `getKeyAgentProfile()` directly:
136
144
 
137
145
  ```typescript
138
146
  const profile = await valiron.getKeyAgentProfile("0xAgentAddress");
139
- if (profile.verified && (profile.score ?? 0) >= 65) {
147
+ if (await verifyAgentRequest(request, "0xAgentAddress") &&
148
+ profile.verified && (profile.score ?? 0) >= 65) {
140
149
  // Serve the request
141
150
  } else {
142
151
  // Block or ask the agent to complete https://www.valiron.co/auth.md
@@ -195,10 +204,10 @@ Once your integration is live, use the [Operator Dashboard](./DASHBOARD.md) to:
195
204
 
196
205
  ```bash
197
206
  # Check an agent's trust profile
198
- curl https://valiron-edge-proxy.onrender.com/operator/agent/AGENT_ID
207
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" https://valiron-edge-proxy.onrender.com/operator/agent/AGENT_ID
199
208
 
200
209
  # Check a key-based agent profile
201
- curl https://valiron-edge-proxy.onrender.com/operator/key/0x1234...abcd
210
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" https://valiron-edge-proxy.onrender.com/operator/key/0x1234...abcd
202
211
 
203
212
  # Get a key-based identity challenge
204
213
  curl -X POST https://valiron-edge-proxy.onrender.com/operator/key/0x1234...abcd/challenge
@@ -210,10 +219,10 @@ curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/AG
210
219
  curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox-key/0x1234...abcd -H "Authorization: Bearer $VALIRON_API_KEY"
211
220
 
212
221
  # Gate decision (allow/deny)
213
- curl -X POST https://valiron-edge-proxy.onrender.com/operator/gate/AGENT_ID
222
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" -X POST https://valiron-edge-proxy.onrender.com/operator/gate/AGENT_ID
214
223
 
215
224
  # Behavioral snapshot hash
216
- curl https://valiron-edge-proxy.onrender.com/operator/agent/AGENT_ID/snapshot
225
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" https://valiron-edge-proxy.onrender.com/operator/agent/AGENT_ID/snapshot
217
226
 
218
227
  # Register webhook
219
228
  curl -X POST https://valiron-edge-proxy.onrender.com/operator/webhooks/register \
@@ -227,7 +236,7 @@ curl -X POST https://valiron-edge-proxy.onrender.com/operator/webhooks/register
227
236
  Valiron middleware is the primary backend integration. API Scaffolding is a separate product for exposing an existing HTTPS API through a Valiron-hosted, agent-facing URL.
228
237
 
229
238
  1. Open [valiron.co/dashboard](https://www.valiron.co/dashboard).
230
- 2. Go to **Make API Agent-Ready**.
239
+ 2. Choose **API Scaffolding → Endpoints & testing**.
231
240
  3. Enter your public path, upstream API base URL, price, payment protocol, and optional trust settings.
232
241
  4. Distribute the generated wrapper URL to agent clients:
233
242
 
@@ -255,12 +264,12 @@ process.on("SIGTERM", async () => {
255
264
  ## What's next?
256
265
 
257
266
  - **[End-to-End Middleware Integration](./E2E-MIDDLEWARE-INTEGRATION.md)** — Choose identity, trust signals, and a downstream policy for a production integration
258
- - **[Proxy Gateway](./SDK-REFERENCE.md#proxy-gateway-pro)** — Forward requests through Valiron's edge proxy (Pro)
267
+ - **[Proxy Gateway](./SDK-REFERENCE.md#proxy-gateway)** — Forward requests through Valiron's edge proxy (Free)
259
268
  - **[API Scaffolding](./AGENT-READY-APIS.md)** — Create hosted x402/MPP wrappers for existing APIs
260
269
  - **[Key-Based Agents](./SDK-REFERENCE.md#key-based-agents)** — Support Web2 agents without on-chain identity
261
270
  - **[World ID](./SDK-REFERENCE.md#world-id-methods)** — Verify agent-human linkage
262
271
  - **[Self](./SDK-REFERENCE.md#self-methods)** — Create Self Enterprise sessions and verify eligible-human linkage
263
- - **[Wallet Intelligence](./TRUST-MODEL.md#wallet-intelligence)** — Add explainable wallet-history risk to Pro endpoint policies
272
+ - **[Wallet Intelligence](./TRUST-MODEL.md#wallet-intelligence)** — Add explainable wallet-history risk to endpoint policies on Free or paid accounts
264
273
  - **[Fastify / Next.js / Hono middleware](./SDK-REFERENCE.md#middleware)** — Framework-specific middleware
265
274
  - **[Plans & Limits](./SDK-REFERENCE.md#plans--limits)** — Free vs Pro feature comparison
266
275
 
@@ -276,6 +285,7 @@ Solana agents use a different registry ([QuantuLabs 8004-solana](https://8004.qn
276
285
  import { ValironSDK } from "@valiron/sdk";
277
286
 
278
287
  const valiron = new ValironSDK({
288
+ apiKey: process.env.VALIRON_API_KEY,
279
289
  endpoint: "https://valiron-edge-proxy.onrender.com",
280
290
  chain: "solana",
281
291
  });
@@ -301,7 +311,7 @@ console.log(profile.onchainReputation.solana?.trustTier); // "trusted"
301
311
  Solana agents support a liveness probe that pings their declared service endpoints:
302
312
 
303
313
  ```bash
304
- curl "https://valiron-edge-proxy.onrender.com/operator/agent/1226/liveness?chain=solana"
314
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" "https://valiron-edge-proxy.onrender.com/operator/agent/1226/liveness?chain=solana"
305
315
  ```
306
316
 
307
317
  ### Step 4 — Gate decision (same as EVM)
@@ -317,20 +327,20 @@ if (gate.allow) {
317
327
 
318
328
  ```bash
319
329
  # Get agent profile (sequential ID)
320
- curl "https://valiron-edge-proxy.onrender.com/operator/agent/1226?chain=solana"
330
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" "https://valiron-edge-proxy.onrender.com/operator/agent/1226?chain=solana"
321
331
 
322
332
  # Get agent profile (asset pubkey)
323
- curl "https://valiron-edge-proxy.onrender.com/operator/agent/DFkntsJ9aTCHkK88m6...?chain=solana"
333
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" "https://valiron-edge-proxy.onrender.com/operator/agent/DFkntsJ9aTCHkK88m6...?chain=solana"
324
334
 
325
335
  # Resolve wallet to agent
326
- curl "https://valiron-edge-proxy.onrender.com/operator/resolve-wallet/VSAnVX4MQjEXreHc92iHxWuXPQZ1tjwiKccpFLCgLM9?chain=solana"
336
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" "https://valiron-edge-proxy.onrender.com/operator/resolve-wallet/VSAnVX4MQjEXreHc92iHxWuXPQZ1tjwiKccpFLCgLM9?chain=solana"
327
337
 
328
338
  # Trigger sandbox
329
- curl -X POST "https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/1226?chain=solana"
339
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" -X POST "https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/1226?chain=solana"
330
340
 
331
341
  # Trust gate
332
- curl -X POST "https://valiron-edge-proxy.onrender.com/operator/gate/1226?chain=solana"
342
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" -X POST "https://valiron-edge-proxy.onrender.com/operator/gate/1226?chain=solana"
333
343
 
334
344
  # Liveness check
335
- curl "https://valiron-edge-proxy.onrender.com/operator/agent/1226/liveness?chain=solana"
345
+ curl -H "Authorization: Bearer $VALIRON_API_KEY" "https://valiron-edge-proxy.onrender.com/operator/agent/1226/liveness?chain=solana"
336
346
  ```