@valiron/sdk 1.0.1 → 1.1.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/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, 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,57 @@ 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
+
74
146
  ## Trust Tiers
75
147
 
76
148
  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 +161,7 @@ Valiron assigns Moody's-style credit tiers: AAA (highest trust) through C (lowes
89
161
 
90
162
  ## Key Behaviors That Affect Trust
91
163
 
92
- - Respect 429 rate limits (critical)
164
+ - Respect 429 rate limits
93
165
  - Honor Retry-After headers
94
166
  - Use exponential backoff
95
167
  - Don't retry 401/403 auth errors
@@ -114,6 +186,41 @@ Valiron assigns Moody's-style credit tiers: AAA (highest trust) through C (lowes
114
186
 
115
187
  ethereum, monad, arbitrum, base, avalanche, celo, polygon, linea, abstract, bsc, gnosis, goat, mantle, megaeth, metis, optimism, scroll, skale_base, soneium, taiko, xlayer, solana
116
188
 
189
+ ## Plans & Limits
190
+
191
+ 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).
192
+
193
+ ## Proxy Gateway (Pro)
194
+
195
+ 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? })`.
196
+
197
+ ## Key-Based Agents
198
+
199
+ 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.
200
+
201
+ 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.
202
+
203
+ ## World ID Methods
204
+
205
+ - verifyWorldId(agentId, proof) — Submit World ID proof
206
+ - getWorldIdStatus(agentId) — Check verification status
207
+ - getWorldIdProfile(agentId) — Full World ID profile
208
+
209
+ ## Self Methods
210
+
211
+ - createSelfSession(agentId, request?) — Create a Self Enterprise verification session and redirect the user to `verificationUrl`
212
+ - getSelfStatus(agentId) — Check whether the agent has a verified Self eligible-human link
213
+ - getSelfProfile(agentId) — Full Self eligible-human and optional Agent ID profile
214
+ - verifySelf(agentId, proof) — Trusted-payload ingestion for local/internal tests only; production uses session creation plus signed Self webhooks
215
+
216
+ ## Telemetry
217
+
218
+ Opt-in anonymous usage metrics. Disable with `telemetry: { enabled: false }`. Supports custom sampleRate (0–1) and custom handler function.
219
+
220
+ ## Middleware Error Responses
221
+
222
+ All middleware returns: 401 (no agent ID), 403 (denied by trust gate), 503 (service unavailable). Fail-closed: never allows unverified agents through.
223
+
117
224
  ## Solana Notes
118
225
 
119
226
  - Use chain: "solana" in SDK or ?chain=solana query parameter
@@ -126,9 +233,11 @@ ethereum, monad, arbitrum, base, avalanche, celo, polygon, linea, abstract, bsc,
126
233
 
127
234
  ## Documentation
128
235
 
129
- - [Full documentation (llms-full.txt)](https://valiron.co/llms-full.txt) — Complete AI-optimized documentation in a single file
236
+ - [Full documentation (llms-full.txt)](https://www.valiron.co/llms-full.txt) — Complete AI-optimized documentation in a single file
237
+ - [auth.md](https://www.valiron.co/auth.md) — Agent identity skill (create keypair, authenticate, manage sessions)
130
238
  - docs/agents/README.md — Index
131
239
  - docs/agents/QUICKSTART.md — Get started
240
+ - docs/agents/AGENT-READY-APIS.md — Hosted x402/MPP wrappers for existing APIs
132
241
  - docs/agents/DASHBOARD.md — Operator Dashboard (manage endpoints, keys, analytics, playground)
133
242
  - docs/agents/API-REFERENCE.md — HTTP API reference
134
243
  - docs/agents/SDK-REFERENCE.md — TypeScript SDK reference
@@ -140,7 +249,7 @@ ethereum, monad, arbitrum, base, avalanche, celo, polygon, linea, abstract, bsc,
140
249
 
141
250
  ## Operator Dashboard
142
251
 
143
- Dashboard URL: https://valiron.co/dashboard (JWT-authenticated)
252
+ Dashboard URL: https://www.valiron.co/dashboard (JWT-authenticated)
144
253
 
145
254
  ### Dashboard Features
146
255
  - Overview: revenue, calls, agents, latency stats + quick start guide
@@ -148,7 +257,7 @@ Dashboard URL: https://valiron.co/dashboard (JWT-authenticated)
148
257
  - Analytics: revenue charts (7/30/90 days), top endpoints, today's stats
149
258
  - Call Logs: paginated log with time/agent/chain/endpoint/status/cost/latency filters
150
259
  - 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
260
+ - Make API Agent-Ready: create hosted wrappers with upstream base URL, price, x402/MPP protocol, optional trust, rate limit, upstream auth
152
261
  - Playground: test how agents at different trust levels are evaluated (dry-run or live)
153
262
  - Settings: update name, view plan and fee rate
154
263
  - Admin (admin-only): platform stats, all operators
@@ -172,9 +281,12 @@ DELETE /operator/keys/{keyId}
172
281
 
173
282
  GET /operator/endpoints
174
283
  POST /operator/endpoints
175
- Body: { "path": "/api/v1/weather", "method": "GET", "pricePerCall": 0.05, "description": "...", "rateLimit": 60, "targetUrl": "https://myapi.com" }
284
+ 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
285
  DELETE /operator/endpoints/{endpointId}
177
286
 
287
+ Public wrapper call:
288
+ ALL /wrap/{operatorId}/{path}
289
+
178
290
  GET /operator/analytics/stats
179
291
  GET /operator/analytics/revenue?days=30
180
292
  GET /operator/analytics/top-endpoints?limit=10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valiron/sdk",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
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": [