@valiron/sdk 1.1.1 → 1.2.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/README.md +28 -4
- package/dist/clients.d.ts +5 -1
- package/dist/clients.js +32 -6
- package/dist/index.d.ts +6 -1
- package/dist/index.js +7 -0
- package/dist/middleware.d.ts +4 -4
- package/dist/middleware.js +81 -67
- package/dist/operatorSdk.d.ts +1 -1
- package/dist/operatorSdk.js +1 -0
- package/dist/types.d.ts +54 -3
- package/dist/types.js +2 -2
- package/docs/API-REFERENCE.md +71 -2
- package/docs/CHAINS.md +24 -0
- package/docs/E2E-MIDDLEWARE-INTEGRATION.md +213 -0
- package/docs/ERRORS.md +86 -10
- package/docs/IDENTITY.md +6 -0
- package/docs/QUICKSTART.md +16 -0
- package/docs/README.md +3 -1
- package/docs/SDK-REFERENCE.md +60 -8
- package/docs/TRUST-MODEL.md +29 -0
- package/docs/llms.txt +15 -4
- package/package.json +1 -1
package/docs/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## What is Valiron?
|
|
6
6
|
|
|
7
|
-
Valiron is trust infrastructure for API sellers. It evaluates AI agents using on-chain identity (ERC-8004 or Solana), key-based identity for non-ERC-8004 agents, behavioral sandbox testing, and a Moody's-style credit rating system — so you can allow trusted agents and block risky ones automatically.
|
|
7
|
+
Valiron is trust infrastructure for API sellers. It evaluates AI agents using on-chain identity (ERC-8004 or Solana), key-based identity for non-ERC-8004 agents, behavioral sandbox testing, optional wallet-history intelligence, and a Moody's-style credit rating system — so you can allow trusted agents and block risky ones automatically.
|
|
8
8
|
|
|
9
9
|
**If you sell APIs**, Valiron's core product is middleware deployed within the API backend through the SDK. It provides direct control over trust checks, routing, sandboxing, payment gating, and analytics before requests reach application handlers.
|
|
10
10
|
|
|
@@ -15,6 +15,7 @@ Valiron also provides **API Scaffolding** as a separate product for organization
|
|
|
15
15
|
| File | Purpose |
|
|
16
16
|
|------|---------|
|
|
17
17
|
| [QUICKSTART.md](./QUICKSTART.md) | Get started in under 2 minutes — install the SDK, gate your first endpoint |
|
|
18
|
+
| [E2E-MIDDLEWARE-INTEGRATION.md](./E2E-MIDDLEWARE-INTEGRATION.md) | End-to-end middleware integration — identity, trust signals, downstream policy, and testing |
|
|
18
19
|
| [AGENT-READY-APIS.md](./AGENT-READY-APIS.md) | API Scaffolding — hosted x402/MPP wrappers for existing APIs |
|
|
19
20
|
| [DASHBOARD.md](./DASHBOARD.md) | Operator Dashboard — manage endpoints, keys, analytics, and playground |
|
|
20
21
|
| [API-REFERENCE.md](./API-REFERENCE.md) | Complete HTTP API reference with request/response schemas |
|
|
@@ -36,6 +37,7 @@ Valiron also provides **API Scaffolding** as a separate product for organization
|
|
|
36
37
|
- **API Scaffolding**: A separate hosted Valiron wrapper product at `/wrap/{operatorId}/{path}` that can collect x402/MPP payments, optionally gate by trust, and forward to an upstream API.
|
|
37
38
|
- **Payment Protocol**: `x402` for Base/USDC HTTP payments or `mpp` for Machine Payment Protocol payments through Tempo.
|
|
38
39
|
- **Sandbox**: An isolated test environment where Valiron evaluates agent behavior before granting production access.
|
|
40
|
+
- **Wallet Intelligence**: A Pro trust signal that converts bounded Alchemy or Helius wallet history into an explainable score, risk level, confidence, and reasons.
|
|
39
41
|
- **Liveness** (Solana only): Endpoint health probe via `isItAlive()`. See [API-REFERENCE.md](./API-REFERENCE.md#solana-support).
|
|
40
42
|
|
|
41
43
|
## Which Identity Path Should I Use?
|
package/docs/SDK-REFERENCE.md
CHANGED
|
@@ -22,7 +22,7 @@ const valiron = new ValironSDK(config?: ValironConfig);
|
|
|
22
22
|
|
|
23
23
|
| Field | Type | Default | Description |
|
|
24
24
|
|-------|------|---------|-------------|
|
|
25
|
-
| `apiKey` | string | — | API key
|
|
25
|
+
| `apiKey` | string | — | Operator API key. Optional for basic reads; required for Pro trust signals and `getWalletRisk()` |
|
|
26
26
|
| `endpoint` | string | `https://valiron-edge-proxy.onrender.com` | API base URL |
|
|
27
27
|
| `chain` | SupportedChain | `"ethereum"` | Default blockchain network |
|
|
28
28
|
| `timeout` | number | method-aware | Request timeout in milliseconds. Defaults are 10s generally, 15s for `gate()`/`proxy()`, and 30s for sandbox triggers. If set, this value overrides all method-aware defaults. |
|
|
@@ -158,6 +158,29 @@ const profile = await valiron.getWalletProfile("VSAnVX4MQjEXreHc92iHxWuXPQZ1tjwi
|
|
|
158
158
|
|
|
159
159
|
---
|
|
160
160
|
|
|
161
|
+
### getWalletRisk(wallet, options?)
|
|
162
|
+
|
|
163
|
+
Return an explainable wallet-history assessment. This is a Pro feature and requires an operator API key.
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
const valiron = new ValironSDK({ apiKey: process.env.VALIRON_API_KEY });
|
|
167
|
+
const assessment = await valiron.getWalletRisk("0x52ce...", { chain: "base" });
|
|
168
|
+
|
|
169
|
+
if (assessment.available) {
|
|
170
|
+
console.log(assessment.score); // 0-100 trust score; higher is better
|
|
171
|
+
console.log(assessment.risk); // 100 - score
|
|
172
|
+
console.log(assessment.riskLevel); // "LOW" | "MEDIUM" | "HIGH" | "CRITICAL"
|
|
173
|
+
console.log(assessment.confidence); // 0-1 history coverage confidence
|
|
174
|
+
console.log(assessment.reasons);
|
|
175
|
+
} else {
|
|
176
|
+
console.log(assessment.error); // missing key, unsupported network, timeout, etc.
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Supported history networks are Ethereum, Base, Arbitrum, Optimism, Polygon, and Solana. EVM uses Alchemy; Solana uses Helius. The assessment uses bounded samples rather than complete transaction history. It does not provide sanctions, mixer, scam, or criminal attribution without an additional intelligence provider.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
161
184
|
### resolveWallet(wallet, options?)
|
|
162
185
|
|
|
163
186
|
Lightweight wallet → agentId resolution without the full trust profile. Useful when you only need to know which agent owns a wallet (e.g. after extracting a wallet from an x402 payment header).
|
|
@@ -273,7 +296,9 @@ Trust gate — single call for allow/deny decisions. Combines on-chain reputatio
|
|
|
273
296
|
|
|
274
297
|
```typescript
|
|
275
298
|
const result = await valiron.gate(agentId: string, options?: {
|
|
299
|
+
minScore?: number; // default: 65
|
|
276
300
|
ttlMs?: number; // default: 86400000 (24h)
|
|
301
|
+
trustSignals?: Array<"8004" | "sandbox" | "world" | "self" | "icebreaker" | "wallet">;
|
|
277
302
|
chain?: SupportedChain;
|
|
278
303
|
}): Promise<GateResult>;
|
|
279
304
|
```
|
|
@@ -292,6 +317,7 @@ interface GateResult {
|
|
|
292
317
|
chain: ChainContext;
|
|
293
318
|
sandboxRan: boolean;
|
|
294
319
|
cached: boolean;
|
|
320
|
+
walletRisk?: WalletRiskSnapshot;
|
|
295
321
|
}
|
|
296
322
|
```
|
|
297
323
|
|
|
@@ -360,7 +386,7 @@ import { ValironSDK, createValironGate } from "@valiron/sdk";
|
|
|
360
386
|
const gate = createValironGate(config: {
|
|
361
387
|
sdk: ValironSDK;
|
|
362
388
|
minScore?: number; // default: 65
|
|
363
|
-
trustSignals?: Array<"8004" | "sandbox" | "world" | "self" | "icebreaker">;
|
|
389
|
+
trustSignals?: Array<"8004" | "sandbox" | "world" | "self" | "icebreaker" | "wallet">;
|
|
364
390
|
cacheTtlMs?: number; // default: 30000 (30s client-side cache)
|
|
365
391
|
extractAgentId?: (req: Request) => string | null;
|
|
366
392
|
extractAgentAddress?: (req: Request) => string | null;
|
|
@@ -704,14 +730,14 @@ caching for that middleware instance. `createValironNextMiddleware` and
|
|
|
704
730
|
|
|
705
731
|
### Middleware Error Responses
|
|
706
732
|
|
|
707
|
-
All middleware variants return consistent error responses
|
|
733
|
+
All middleware variants return consistent error responses. Each body includes a stable `code`, a human-readable `message`, an `action`, and a `docsUrl` in addition to the trust result fields.
|
|
708
734
|
|
|
709
|
-
| Status |
|
|
735
|
+
| Status | Code | When |
|
|
710
736
|
|--------|------|------|
|
|
711
|
-
| 401 | No agent
|
|
712
|
-
| 403 | Agent denied by trust gate
|
|
713
|
-
| 403 |
|
|
714
|
-
| 503 | Valiron service unavailable
|
|
737
|
+
| 401 | `MISSING_AGENT_IDENTITY` | No agent identity found in request |
|
|
738
|
+
| 403 | `TRUST_GATE_DENIED` | Agent denied by trust gate; inspect `score`, `tier`, `route`, and `reasons` |
|
|
739
|
+
| 403 | `AGENT_EVALUATION_PENDING` | New agent pending evaluation; retry after `retryAfterMs` |
|
|
740
|
+
| 503 | `TRUST_GATE_UNAVAILABLE` | Valiron service unavailable; fail closed and retry shortly |
|
|
715
741
|
|
|
716
742
|
> **Fail-closed:** When the Valiron service is unreachable, middleware returns 503 — it never fails open and never allows unverified agents through.
|
|
717
743
|
|
|
@@ -735,6 +761,29 @@ Returned by `gate()` and middleware.
|
|
|
735
761
|
| `chain` | object | Chain context |
|
|
736
762
|
| `sandboxRan` | boolean | Whether sandbox was executed |
|
|
737
763
|
| `cached` | boolean | Whether the result was served from cache |
|
|
764
|
+
| `walletRisk` | WalletRiskSnapshot? | Wallet assessment when the `wallet` signal was requested |
|
|
765
|
+
|
|
766
|
+
### WalletRiskSnapshot
|
|
767
|
+
|
|
768
|
+
Returned by `getWalletRisk()` and optionally included in agent profiles and gate results.
|
|
769
|
+
|
|
770
|
+
| Field | Type | Description |
|
|
771
|
+
|-------|------|-------------|
|
|
772
|
+
| `available` | boolean | Whether provider-backed history was available |
|
|
773
|
+
| `wallet` | string | Normalized wallet address |
|
|
774
|
+
| `network` | SupportedChain | Evaluated network |
|
|
775
|
+
| `provider` | `alchemy` \| `helius` \| `none` | History provider used |
|
|
776
|
+
| `score` | number | Confidence-damped trust score, 0-100; higher is better |
|
|
777
|
+
| `rawScore` | number | Score before confidence damping |
|
|
778
|
+
| `risk` | number | `100 - score` |
|
|
779
|
+
| `confidence` | number | History-coverage confidence from 0-1 |
|
|
780
|
+
| `riskLevel` | string | LOW / MEDIUM / HIGH / CRITICAL |
|
|
781
|
+
| `reasons` | string[] | Explainable scoring reasons |
|
|
782
|
+
| `hardFlags` | string[] | Hard-risk flags; any populated flag forces `sandbox_only` in gates |
|
|
783
|
+
| `features` | WalletHistoryFeatures | Normalized history measurements |
|
|
784
|
+
| `observedAt` | string | ISO observation timestamp |
|
|
785
|
+
| `expiresAt` | string | ISO cache-expiry timestamp |
|
|
786
|
+
| `error` | string? | Provider/configuration failure when unavailable |
|
|
738
787
|
|
|
739
788
|
### AgentProfile
|
|
740
789
|
|
|
@@ -774,6 +823,8 @@ import {
|
|
|
774
823
|
valironGateCheck,
|
|
775
824
|
isValidAddress,
|
|
776
825
|
generateChallenge,
|
|
826
|
+
type WalletRiskSnapshot,
|
|
827
|
+
type WalletRiskLevel,
|
|
777
828
|
} from "@valiron/sdk";
|
|
778
829
|
```
|
|
779
830
|
|
|
@@ -790,5 +841,6 @@ import {
|
|
|
790
841
|
| Analytics & logs | — | ✓ |
|
|
791
842
|
| Evaluation history | — | ✓ |
|
|
792
843
|
| Custom tier thresholds | — | ✓ |
|
|
844
|
+
| Wallet intelligence | — | ✓ |
|
|
793
845
|
|
|
794
846
|
Pro plan requires an operator API key (`val_op_` prefix) from the [Operator Dashboard](./DASHBOARD.md).
|
package/docs/TRUST-MODEL.md
CHANGED
|
@@ -31,6 +31,7 @@ Supported signals:
|
|
|
31
31
|
| `world` | World ID human-agent link | Pro |
|
|
32
32
|
| `self` | Self eligible-human proof and optional Self Agent ID link | Pro |
|
|
33
33
|
| `icebreaker` | Icebreaker human/background attestation | Pro |
|
|
34
|
+
| `wallet` | Explainable wallet-history activity and risk signal | Pro |
|
|
34
35
|
|
|
35
36
|
When multiple signals are selected, Valiron computes each signal on a `0-100` scale and normalizes the configured weights across only those selected signals. The default weights are:
|
|
36
37
|
|
|
@@ -41,9 +42,37 @@ When multiple signals are selected, Valiron computes each signal on a `0-100` sc
|
|
|
41
42
|
| `world` | 15 |
|
|
42
43
|
| `self` | 15 |
|
|
43
44
|
| `icebreaker` | 5 |
|
|
45
|
+
| `wallet` | 15 |
|
|
44
46
|
|
|
45
47
|
If no signals are specified, Valiron uses the plug-and-play default: sandbox plus any other available trust signals.
|
|
46
48
|
|
|
49
|
+
## Wallet Intelligence
|
|
50
|
+
|
|
51
|
+
The optional `wallet` signal evaluates the history of the wallet Valiron resolves for an incoming agent. EVM history is read through Alchemy on Ethereum, Base, Arbitrum, Optimism, and Polygon. Solana history is read through Helius.
|
|
52
|
+
|
|
53
|
+
The assessment returns a `0-100` trust score where higher is better, `risk = 100 - score`, a `LOW` / `MEDIUM` / `HIGH` / `CRITICAL` risk level, a confidence value, explainable reasons, and the normalized history features used by the scorer. Current features include transaction count, active days, wallet age, unique counterparties on EVM, failed transaction rate on Solana, and recent activity spikes when enough timestamps are available.
|
|
54
|
+
|
|
55
|
+
Confidence dampens sparse assessments toward a neutral score. If a provider key is missing, the network is unsupported, or the provider times out, wallet intelligence is marked unavailable and excluded from the composite score rather than being treated as malicious. A populated hard-risk flag forces `sandbox_only`, but the current history providers do not independently supply sanctions or malicious-address attribution.
|
|
56
|
+
|
|
57
|
+
Wallet history is bounded, not exhaustive: EVM uses up to 100 recent incoming and 100 recent outgoing transfers plus oldest-transfer lookups; Solana uses up to 1,000 recent signatures. The signal should not be described as AML, sanctions compliance, mixer detection, or complete fund tracing without an additional blockchain-intelligence provider.
|
|
58
|
+
|
|
59
|
+
Request wallet intelligence directly:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const assessment = await valiron.getWalletRisk("0x52ce...", { chain: "base" });
|
|
63
|
+
console.log(assessment.score, assessment.riskLevel, assessment.confidence);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Or include it in an endpoint policy:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
app.use("/api/high-trust", createValironGate({
|
|
70
|
+
sdk: valiron,
|
|
71
|
+
trustSignals: ["8004", "sandbox", "wallet"],
|
|
72
|
+
minScore: 80,
|
|
73
|
+
}));
|
|
74
|
+
```
|
|
75
|
+
|
|
47
76
|
## Behavioral Factors
|
|
48
77
|
|
|
49
78
|
Valiron evaluates agents across multiple behavioral dimensions. The behavioral evaluation is holistic — no single sandbox behavior determines the outcome. The specific factors evaluated and their weights are proprietary and not disclosed.
|
package/docs/llms.txt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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/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.
|
|
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, optional wallet-history intelligence, 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
6
|
|
|
7
7
|
## Identity Paths
|
|
8
8
|
|
|
@@ -20,6 +20,11 @@ GET /operator/agent/{agentId}?chain={chain}
|
|
|
20
20
|
### Lookup by wallet
|
|
21
21
|
GET /operator/wallet/{wallet}?chain={chain}
|
|
22
22
|
|
|
23
|
+
### Wallet-history risk (Pro)
|
|
24
|
+
GET /operator/wallet-risk/{wallet}?chain={chain}
|
|
25
|
+
Requires: Authorization: Bearer val_op_...
|
|
26
|
+
Returns: { available, wallet, network, provider, score, rawScore, risk, confidence, riskLevel, reasons, hardFlags, features, observedAt, expiresAt, error? }
|
|
27
|
+
|
|
23
28
|
### Resolve wallet to agent ID
|
|
24
29
|
GET /operator/resolve-wallet/{wallet}?chain={chain}
|
|
25
30
|
Returns: { wallet, agentId, source, chainId?, agentName?, timestamp }
|
|
@@ -72,6 +77,9 @@ const route = await valiron.checkAgent("AGENT_ID");
|
|
|
72
77
|
// Full profile
|
|
73
78
|
const profile = await valiron.getAgentProfile("AGENT_ID");
|
|
74
79
|
|
|
80
|
+
// Pro wallet-history assessment
|
|
81
|
+
const walletRisk = await valiron.getWalletRisk("0x...", { chain: "base" });
|
|
82
|
+
|
|
75
83
|
// Resolve wallet → agentId (lightweight)
|
|
76
84
|
const res = await valiron.resolveWallet("0x...");
|
|
77
85
|
// Returns: { agentId, source: "redis"|"subgraph"|"cache"|"none" }
|
|
@@ -100,7 +108,7 @@ GET/POST/etc /wrap/{operatorId}/{path}
|
|
|
100
108
|
|
|
101
109
|
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
110
|
|
|
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
|
|
111
|
+
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 and deny untrusted agents before forwarding. Use SDK middleware in your own backend when you need to support x-agent-address.
|
|
104
112
|
|
|
105
113
|
## Operator SDK (ValironOperator)
|
|
106
114
|
|
|
@@ -135,13 +143,16 @@ PaywallConfig options: pricePerCall (number, required), minTrustScore (number, d
|
|
|
135
143
|
|
|
136
144
|
## Trust Model
|
|
137
145
|
|
|
138
|
-
Valiron evaluates agents using
|
|
146
|
+
Valiron evaluates agents using six independent trust signals:
|
|
139
147
|
|
|
140
148
|
1. **On-Chain Reputation (ERC-8004)** — Feedback from other agents/operators (0-100 per review).
|
|
141
149
|
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
150
|
3. **World ID** — Proof-of-personhood via Worldcoin. Verification levels: orb (biometric, highest boost), device (passkey), phone (SMS).
|
|
143
151
|
4. **Self** — Self Enterprise eligible-human proof via signed session webhooks, with optional Self Agent ID binding.
|
|
144
152
|
5. **Icebreaker** — Human attestation via Ethereum Attestation Service (EAS) on Base. A human attests this is their "designated agent."
|
|
153
|
+
6. **Wallet Intelligence** (Pro) — Bounded Alchemy history on Ethereum/Base/Arbitrum/Optimism/Polygon or Helius signature history on Solana. Returns a trust score, inverse risk, confidence, reasons, hard flags, and normalized activity features.
|
|
154
|
+
|
|
155
|
+
Wallet intelligence is confidence-damped toward neutral when history is sparse. Provider failures are excluded from composite scoring. Current adapters do not provide sanctions, mixer, scam, or criminal attribution and do not trace complete transaction history.
|
|
145
156
|
|
|
146
157
|
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
158
|
|
|
@@ -221,7 +232,7 @@ Opt-in anonymous usage metrics. Disable with `telemetry: { enabled: false }`. Su
|
|
|
221
232
|
|
|
222
233
|
## Middleware Error Responses
|
|
223
234
|
|
|
224
|
-
All middleware returns:
|
|
235
|
+
All middleware returns actionable JSON. Use the stable `code` for program logic and read `message`, `action`, and `docsUrl` for recovery. Codes: `MISSING_AGENT_IDENTITY` (401), `TRUST_GATE_DENIED` (403), `AGENT_EVALUATION_PENDING` (403; honor `retryAfterMs`), and `TRUST_GATE_UNAVAILABLE` (503, fail-closed). SDK `ValironError` instances preserve the same server code plus `details.action`, `details.requestId`, `details.docsUrl`, and `details.retryAfterMs`.
|
|
225
236
|
|
|
226
237
|
## Solana Notes
|
|
227
238
|
|