@valiron/sdk 1.0.2 → 1.1.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/docs/llms.txt CHANGED
@@ -2,7 +2,13 @@
2
2
 
3
3
  > Protect your API endpoints from bad or malicious AI agents.
4
4
 
5
- Valiron is trust and reputation middleware for API sellers. It evaluates incoming AI agents using on-chain identity (ERC-8004), behavioral sandbox testing, and Moody's-style credit ratings (AAA to C). Trustworthy agents get production access. Risky agents are throttled, sandboxed, or blocked — automatically.
5
+ Valiron is trust and reputation middleware for API sellers. It evaluates incoming AI agents using on-chain identity (ERC-8004/Solana), key-based identity for local/Web2/non-ERC-8004 agents, behavioral sandbox testing, predictive risk forecasts, and Moody's-style credit ratings (AAA to C). Trustworthy agents get production access. Risky agents are throttled, sandboxed, or blocked — automatically.
6
+
7
+ ## Identity Paths
8
+
9
+ On-chain agents use x-agent-id and GET /operator/agent/{agentId}. The agentId is an ERC-8004 token ID, Solana Metaplex Core asset pubkey, or supported indexed Solana ID.
10
+
11
+ Local, Web2, and non-ERC-8004 agents use x-agent-address plus challenge-response auth. Do not send a local agent name to /operator/agent/{agentId}. Generate or reuse a persistent Ethereum-style keypair, request POST /operator/key/{agentAddress}/challenge, sign the challenge, verify with POST /operator/key/verify, then use x-agent-address and x-agent-session on gated requests. Agents can follow https://www.valiron.co/auth.md.
6
12
 
7
13
  ## API
8
14
 
@@ -14,8 +20,10 @@ GET /operator/agent/{agentId}?chain={chain}
14
20
  ### Lookup by wallet
15
21
  GET /operator/wallet/{wallet}?chain={chain}
16
22
 
17
- ### Resolve wallet to agent
23
+ ### Resolve wallet to agent ID
18
24
  GET /operator/resolve-wallet/{wallet}?chain={chain}
25
+ Returns: { wallet, agentId, source, chainId?, agentName?, timestamp }
26
+ Resolution: Redis → in-memory cache → Agent0 subgraph → null
19
27
 
20
28
  ### Run sandbox test (on-chain agent)
21
29
  POST /operator/trigger-sandbox/{agentId}
@@ -23,6 +31,15 @@ POST /operator/trigger-sandbox/{agentId}
23
31
  ### Run sandbox test (key-based agent)
24
32
  POST /operator/trigger-sandbox-key/{agentAddress}
25
33
 
34
+ ### Key-based agent challenge
35
+ POST /operator/key/{agentAddress}/challenge
36
+
37
+ ### Verify key-based agent
38
+ POST /operator/key/verify
39
+
40
+ ### Key-based agent profile
41
+ GET /operator/key/{agentAddress}
42
+
26
43
  ### Trust gate (allow/deny)
27
44
  POST /operator/gate/{agentId}
28
45
  Body: { "ttlMs": 86400000 }
@@ -55,6 +72,10 @@ const route = await valiron.checkAgent("AGENT_ID");
55
72
  // Full profile
56
73
  const profile = await valiron.getAgentProfile("AGENT_ID");
57
74
 
75
+ // Resolve wallet → agentId (lightweight)
76
+ const res = await valiron.resolveWallet("0x...");
77
+ // Returns: { agentId, source: "redis"|"subgraph"|"cache"|"none" }
78
+
58
79
  // Trust gate (allow/deny for payments)
59
80
  const gate = await valiron.gate("AGENT_ID");
60
81
  if (gate.allow) { /* proceed */ }
@@ -71,6 +92,59 @@ console.log(keyResult.tier); // "A"
71
92
 
72
93
  Auto-sandbox: Middleware automatically triggers sandbox evaluation for new agents (on-chain with totalFeedback=0, or key-based with no score). Returns 403 with { error: "Agent pending evaluation", retryAfterMs: 30000 }.
73
94
 
95
+ ## API Scaffolding
96
+
97
+ Valiron's core product is middleware deployed within the API seller's backend. API Scaffolding is a separate product for organizations that require a hosted, agent-facing wrapper URL for an existing HTTPS API. It can serve as an evaluation path before adopting a first-party backend integration protected by Valiron middleware. Operators create wrappers in the dashboard under Make API Agent-Ready or via POST /operator/endpoints. Agents call:
98
+
99
+ GET/POST/etc /wrap/{operatorId}/{path}
100
+
101
+ Wrapper config fields: path, method, targetUrl (upstream API base URL), pricePerCall, paymentProtocol ("x402" or "mpp"), paymentNetwork ("eip155:8453", "eip155:84532", "tempo:4217", or "tempo:42431"), payoutAddress, trustEnabled, rateLimit, upstreamAuthType, upstreamAuthHeader, upstreamAuthSecret.
102
+
103
+ Free wrappers (pricePerCall=0) forward directly to targetUrl. x402 paid wrappers return 402 with x402 payment challenge and require retry with X-PAYMENT. MPP paid wrappers return 402 with WWW-Authenticate: Payment and require retry with Authorization: Payment. Trust-enabled wrappers require x-agent-id or x-agent-address/session headers and deny untrusted agents before forwarding.
104
+
105
+ ## Operator SDK (ValironOperator)
106
+
107
+ For API sellers who want to monetize endpoints. Requires a `val_op_` API key from the dashboard.
108
+
109
+ ```typescript
110
+ import { ValironOperator } from '@valiron/sdk';
111
+
112
+ const operator = new ValironOperator({ apiKey: 'val_op_xxxx' });
113
+
114
+ // Express: one line to monetize an endpoint
115
+ app.use('/api/inference', operator.paywall({
116
+ pricePerCall: 0.05,
117
+ minTrustScore: 45,
118
+ }));
119
+
120
+ // Fastify: register as plugin
121
+ app.register(operator.fastifyPaywall({
122
+ pricePerCall: 0.10,
123
+ prefix: '/api',
124
+ }));
125
+
126
+ // req.valiron is populated with gate result + pricing
127
+ app.post('/api/inference', (req, res) => {
128
+ console.log(req.valiron.tier); // 'AAA'
129
+ console.log(req.valiron.pricePerCall); // 0.05
130
+ res.json({ result: 'output' });
131
+ });
132
+ ```
133
+
134
+ PaywallConfig options: pricePerCall (number, required), minTrustScore (number, default 45), ttlMs (number, default 86400000), onDeny (callback), onAllow (callback).
135
+
136
+ ## Trust Model
137
+
138
+ Valiron evaluates agents using five independent trust signals:
139
+
140
+ 1. **On-Chain Reputation (ERC-8004)** — Feedback from other agents/operators (0-100 per review).
141
+ 2. **Behavioral Sandbox** — Simulated API interactions testing rate-limit compliance, auth behavior, payment handling, injection safety, PII handling, session isolation, and task completion. Exact weights are proprietary.
142
+ 3. **World ID** — Proof-of-personhood via Worldcoin. Verification levels: orb (biometric, highest boost), device (passkey), phone (SMS).
143
+ 4. **Self** — Self Enterprise eligible-human proof via signed session webhooks, with optional Self Agent ID binding.
144
+ 5. **Icebreaker** — Human attestation via Ethereum Attestation Service (EAS) on Base. A human attests this is their "designated agent."
145
+
146
+ Predictive risk is available in the dashboard/API for observed agents. It forecasts the next score, pass probability, trend, confidence, recommended policy, suggested tests, and reasons from recent sandbox evaluations, behavioral fingerprints, and operator call logs. It does not replace the trust gate; low-confidence forecasts mean more evaluation data is needed.
147
+
74
148
  ## Trust Tiers
75
149
 
76
150
  Valiron assigns Moody's-style credit tiers: AAA (highest trust) through C (lowest trust). Higher tiers route to production, lower tiers are sandboxed or blocked. Exact score ranges are not disclosed.
@@ -89,7 +163,7 @@ Valiron assigns Moody's-style credit tiers: AAA (highest trust) through C (lowes
89
163
 
90
164
  ## Key Behaviors That Affect Trust
91
165
 
92
- - Respect 429 rate limits (critical)
166
+ - Respect 429 rate limits
93
167
  - Honor Retry-After headers
94
168
  - Use exponential backoff
95
169
  - Don't retry 401/403 auth errors
@@ -114,6 +188,41 @@ Valiron assigns Moody's-style credit tiers: AAA (highest trust) through C (lowes
114
188
 
115
189
  ethereum, monad, arbitrum, base, avalanche, celo, polygon, linea, abstract, bsc, gnosis, goat, mantle, megaeth, metis, optimism, scroll, skale_base, soneium, taiko, xlayer, solana
116
190
 
191
+ ## Plans & Limits
192
+
193
+ Free: 3 gated endpoints, 5 sandbox tests/day. Pro: unlimited endpoints, unlimited sandbox, webhooks, proxy gateway, analytics, evaluation history, custom tier thresholds. Pro requires operator API key (val_op_ prefix).
194
+
195
+ ## Proxy Gateway (Pro)
196
+
197
+ Forward requests through Valiron's edge proxy with automatic trust gating, logging, and SSRF protection (blocks private IPs, metadata endpoints). Use `valiron.proxy({ agentId, targetUrl, method?, headers?, body? })`.
198
+
199
+ ## Key-Based Agents
200
+
201
+ Web2 agents without on-chain identity use EIP-191 challenge-response via `x-agent-address` header. SDK auto-detects. Returns KeyAgentProfile with agentAddress, verified, score, tier, riskLevel, route, icebreaker, reasons, timestamp.
202
+
203
+ New key agents are automatically sandbox-evaluated on first gated request. Middleware allows key agents when verified and score >= minScore. Use `triggerKeyAgentSandbox(address)` or `POST /operator/trigger-sandbox-key/{address}` to trigger manually.
204
+
205
+ ## World ID Methods
206
+
207
+ - verifyWorldId(agentId, proof) — Submit World ID proof
208
+ - getWorldIdStatus(agentId) — Check verification status
209
+ - getWorldIdProfile(agentId) — Full World ID profile
210
+
211
+ ## Self Methods
212
+
213
+ - createSelfSession(agentId, request?) — Create a Self Enterprise verification session and redirect the user to `verificationUrl`
214
+ - getSelfStatus(agentId) — Check whether the agent has a verified Self eligible-human link
215
+ - getSelfProfile(agentId) — Full Self eligible-human and optional Agent ID profile
216
+ - verifySelf(agentId, proof) — Trusted-payload ingestion for local/internal tests only; production uses session creation plus signed Self webhooks
217
+
218
+ ## Telemetry
219
+
220
+ Opt-in anonymous usage metrics. Disable with `telemetry: { enabled: false }`. Supports custom sampleRate (0–1) and custom handler function.
221
+
222
+ ## Middleware Error Responses
223
+
224
+ All middleware returns: 401 (no agent ID), 403 (denied by trust gate), 503 (service unavailable). Fail-closed: never allows unverified agents through.
225
+
117
226
  ## Solana Notes
118
227
 
119
228
  - Use chain: "solana" in SDK or ?chain=solana query parameter
@@ -126,9 +235,11 @@ ethereum, monad, arbitrum, base, avalanche, celo, polygon, linea, abstract, bsc,
126
235
 
127
236
  ## Documentation
128
237
 
129
- - [Full documentation (llms-full.txt)](https://valiron.co/llms-full.txt) — Complete AI-optimized documentation in a single file
238
+ - [Full documentation (llms-full.txt)](https://www.valiron.co/llms-full.txt) — Complete AI-optimized documentation in a single file
239
+ - [auth.md](https://www.valiron.co/auth.md) — Agent identity skill (create keypair, authenticate, manage sessions)
130
240
  - docs/agents/README.md — Index
131
241
  - docs/agents/QUICKSTART.md — Get started
242
+ - docs/agents/AGENT-READY-APIS.md — Hosted x402/MPP wrappers for existing APIs
132
243
  - docs/agents/DASHBOARD.md — Operator Dashboard (manage endpoints, keys, analytics, playground)
133
244
  - docs/agents/API-REFERENCE.md — HTTP API reference
134
245
  - docs/agents/SDK-REFERENCE.md — TypeScript SDK reference
@@ -140,15 +251,15 @@ ethereum, monad, arbitrum, base, avalanche, celo, polygon, linea, abstract, bsc,
140
251
 
141
252
  ## Operator Dashboard
142
253
 
143
- Dashboard URL: https://valiron.co/dashboard (JWT-authenticated)
254
+ Dashboard URL: https://www.valiron.co/dashboard (JWT-authenticated)
144
255
 
145
256
  ### Dashboard Features
146
257
  - Overview: revenue, calls, agents, latency stats + quick start guide
147
- - Agents: view every agent that called your API, drill into per-agent detail
258
+ - Agents: view every agent that called your API, drill into per-agent detail with predictive risk
148
259
  - Analytics: revenue charts (7/30/90 days), top endpoints, today's stats
149
260
  - Call Logs: paginated log with time/agent/chain/endpoint/status/cost/latency filters
150
261
  - API Keys: generate, copy, and revoke operator API keys (val_op_ prefix)
151
- - Endpoints: register API paths with method, price per call, rate limit, description
262
+ - Make API Agent-Ready: create hosted wrappers with upstream base URL, price, x402/MPP protocol, optional trust, rate limit, upstream auth
152
263
  - Playground: test how agents at different trust levels are evaluated (dry-run or live)
153
264
  - Settings: update name, view plan and fee rate
154
265
  - Admin (admin-only): platform stats, all operators
@@ -172,14 +283,18 @@ DELETE /operator/keys/{keyId}
172
283
 
173
284
  GET /operator/endpoints
174
285
  POST /operator/endpoints
175
- Body: { "path": "/api/v1/weather", "method": "GET", "pricePerCall": 0.05, "description": "...", "rateLimit": 60, "targetUrl": "https://myapi.com" }
286
+ Body: { "path": "/weather", "method": "GET", "pricePerCall": 0.001, "description": "...", "rateLimit": 60, "targetUrl": "https://api.example.com", "paymentProtocol": "x402", "paymentNetwork": "eip155:8453", "payoutAddress": "0x...", "trustEnabled": false }
176
287
  DELETE /operator/endpoints/{endpointId}
177
288
 
289
+ Public wrapper call:
290
+ ALL /wrap/{operatorId}/{path}
291
+
178
292
  GET /operator/analytics/stats
179
293
  GET /operator/analytics/revenue?days=30
180
294
  GET /operator/analytics/top-endpoints?limit=10
181
295
  GET /operator/analytics/agents?sortBy=lastSeen&limit=50&offset=0
182
296
  GET /operator/analytics/agents/{agentId}
297
+ GET /operator/analytics/agents/{agentId}/prediction
183
298
  GET /operator/analytics/logs?limit=50&offset=0&days=7
184
299
 
185
300
  POST /operator/playground
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valiron/sdk",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "description": "Official TypeScript SDK for Valiron — Trust & Reputation Middleware for API Protection",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  "clean": "node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true});\"",
21
21
  "build": "pnpm clean && tsc",
22
22
  "dev": "tsc --watch",
23
- "test": "node test/validate.mjs && node test/validate-examples.mjs && npx tsx test/test-identity.ts",
23
+ "test": "node test/validate.mjs && node test/validate-examples.mjs && tsx test/test-identity.ts",
24
24
  "prepublishOnly": "pnpm build"
25
25
  },
26
26
  "keywords": [