@valiron/sdk 1.3.1 → 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.
- package/README.md +5 -140
- package/dist/clients.d.ts +8 -7
- package/dist/clients.js +35 -25
- package/dist/identity.d.ts +6 -0
- package/dist/identity.js +6 -1
- package/dist/identityMiddleware.d.ts +8 -0
- package/dist/identityMiddleware.js +12 -4
- package/dist/index.d.ts +10 -12
- package/dist/index.js +10 -11
- package/dist/middleware.d.ts +18 -9
- package/dist/middleware.js +41 -16
- package/dist/operatorSdk.d.ts +11 -2
- package/dist/operatorSdk.js +13 -7
- package/dist/types.d.ts +38 -18
- package/docs/AGENT-READY-APIS.md +3 -181
- package/docs/API-REFERENCE.md +160 -563
- package/docs/CHAINS.md +3 -3
- package/docs/CRAWLER-PROTECTION.md +376 -0
- package/docs/DASHBOARD.md +39 -23
- package/docs/E2E-MIDDLEWARE-INTEGRATION.md +20 -14
- package/docs/ERRORS.md +36 -17
- package/docs/IDENTITY.md +31 -19
- package/docs/PROVIDER-IDENTITY.md +19 -24
- package/docs/QUICKSTART.md +38 -26
- package/docs/README.md +20 -3
- package/docs/SANDBOX.md +12 -8
- package/docs/SDK-REFERENCE.md +87 -55
- package/docs/SECURITY-UPGRADE-2026-10-31.md +98 -0
- package/docs/TRUST-MODEL.md +17 -23
- package/docs/llms.txt +65 -292
- package/package.json +21 -5
package/README.md
CHANGED
|
@@ -1,143 +1,8 @@
|
|
|
1
1
|
# @valiron/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Valiron verifies AI agent identity and enforces access policies at your API.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install @valiron/sdk
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Quick Start
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
import { ValironSDK, createValironGate } from "@valiron/sdk";
|
|
17
|
-
|
|
18
|
-
const valiron = new ValironSDK({
|
|
19
|
-
chain: "ethereum",
|
|
20
|
-
apiKey: process.env.VALIRON_API_KEY, // required for Pro signals
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Check if an on-chain agent is trusted
|
|
24
|
-
const route = await valiron.checkAgent("AGENT_ID");
|
|
25
|
-
// Returns: "prod" | "prod_throttled" | "sandbox" | "sandbox_only"
|
|
26
|
-
|
|
27
|
-
// Check a local/Web2/non-ERC-8004 agent by persistent key address
|
|
28
|
-
const keyProfile = await valiron.getKeyAgentProfile("0xAgentAddress");
|
|
29
|
-
console.log(keyProfile.route);
|
|
30
|
-
|
|
31
|
-
// Gate an agent — allow/deny decision
|
|
32
|
-
const gate = await valiron.gate("AGENT_ID");
|
|
33
|
-
if (gate.allow) { /* serve the request */ }
|
|
34
|
-
|
|
35
|
-
// One-line Express middleware — blocks untrusted agents automatically
|
|
36
|
-
app.use("/api/paid", createValironGate({ sdk: valiron }));
|
|
37
|
-
|
|
38
|
-
// Optional: choose endpoint-specific trust signals
|
|
39
|
-
app.use("/api/paid", createValironGate({
|
|
40
|
-
sdk: valiron,
|
|
41
|
-
trustSignals: ["8004", "sandbox"], // Pro can add "world", "self", "icebreaker", and "wallet"
|
|
42
|
-
}));
|
|
43
|
-
|
|
44
|
-
// Fastify, Next.js, and generic middleware also available
|
|
45
|
-
// See SDK Reference for valironFastifyPlugin, createValironNextMiddleware, valironGateCheck
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
No API key is required for basic read operations. Pro trust signals and `getWalletRisk()` require an operator API key.
|
|
49
|
-
|
|
50
|
-
Use `x-agent-id` for ERC-8004/Solana agents. Use `x-agent-address` plus Valiron challenge-response for local, Web2, or non-ERC-8004 agents. Agents can follow the hosted identity skill at https://www.valiron.co/auth.md.
|
|
51
|
-
|
|
52
|
-
Provider-backed identities such as ANS use signed `x-valiron-identity-*`
|
|
53
|
-
headers. SDK 1.3 provides `createAgentIdentityProof()` for agents,
|
|
54
|
-
`verifyAgentIdentity()` for low-level verification, and dedicated Express,
|
|
55
|
-
Fastify, Next.js, and generic identity gates. Valiron hosts the ANS credentials
|
|
56
|
-
and trusted CA bundle; SDK users do not configure them. See the
|
|
57
|
-
[provider-backed identity guide](https://valiron.co/docs/agents/PROVIDER-IDENTITY.md)
|
|
58
|
-
for the signing and middleware quickstart.
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
import {
|
|
62
|
-
agentIdentityProofHeaders,
|
|
63
|
-
createAgentIdentityProof,
|
|
64
|
-
createValironIdentityGate,
|
|
65
|
-
} from "@valiron/sdk";
|
|
66
|
-
|
|
67
|
-
// Agent: sign the exact bytes it will send.
|
|
68
|
-
const body = JSON.stringify({ operation: "quote" });
|
|
69
|
-
const proof = await createAgentIdentityProof({
|
|
70
|
-
provider: "ans",
|
|
71
|
-
agentId: "ans://v1.0.0.sales-agent.acme.com",
|
|
72
|
-
body,
|
|
73
|
-
sign: (payload) => agentKey.sign(payload),
|
|
74
|
-
});
|
|
75
|
-
await fetch(apiUrl, { method: "POST", body, headers: agentIdentityProofHeaders(proof) });
|
|
76
|
-
|
|
77
|
-
// API owner: capture raw bytes, then enforce the returned identity policy.
|
|
78
|
-
app.use(express.json({ verify: (req: any, _res, bytes) => { req.rawBody = Buffer.from(bytes); } }));
|
|
79
|
-
app.post("/quote", createValironIdentityGate({
|
|
80
|
-
sdk: valiron,
|
|
81
|
-
policy: { anonymous: "challenge", claimed: "block", verified: "allow" },
|
|
82
|
-
}), handler);
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## Error diagnostics
|
|
86
|
-
|
|
87
|
-
SDK failures are `ValironError` instances. Handle the stable `code` programmatically and log `details.action`, `details.requestId`, `details.docsUrl`, and `details.retryAfterMs` to make recovery explicit.
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
import { ValironError } from "@valiron/sdk";
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
await valiron.getAgentProfile("AGENT_ID");
|
|
94
|
-
} catch (error) {
|
|
95
|
-
if (error instanceof ValironError) {
|
|
96
|
-
console.error(error.code, error.message, error.details?.action);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Trust middleware returns the same fields in JSON responses. Its primary codes are `MISSING_AGENT_IDENTITY`, `TRUST_GATE_DENIED`, `AGENT_EVALUATION_PENDING`, and `TRUST_GATE_UNAVAILABLE`. See the [error guide](https://valiron.co/docs#error-handling) for retry rules and hosted-wrapper diagnostics.
|
|
102
|
-
|
|
103
|
-
### Additional Features
|
|
104
|
-
|
|
105
|
-
- **Auto-Sandbox** — Middleware automatically evaluates new agents (on-chain and key-based) on their first gated request
|
|
106
|
-
- **Predictive Risk** — Dashboard/API forecasts whether an observed agent is improving, stable, or becoming riskier before the next action
|
|
107
|
-
- **Proxy Gateway** (Pro) — Forward requests through Valiron's edge proxy with SSRF protection
|
|
108
|
-
- **Key-Based Agents** — Support Web2 agents via EIP-191 challenge-response (auto-detected, auto-sandboxed)
|
|
109
|
-
- **World ID** — Verify agent-human linkage via Worldcoin proof-of-personhood
|
|
110
|
-
- **Self** — Create Self Enterprise sessions and store signed eligible-human webhook results
|
|
111
|
-
- **Wallet Intelligence** (Pro) — Score bounded Alchemy/Helius wallet history with confidence and explainable reasons
|
|
112
|
-
- **Telemetry** — Optional anonymous usage metrics (disable with `telemetry: { enabled: false }`)
|
|
113
|
-
|
|
114
|
-
### Cleanup
|
|
115
|
-
|
|
116
|
-
Call `dispose()` when shutting down long-running servers:
|
|
117
|
-
|
|
118
|
-
```typescript
|
|
119
|
-
await valiron.dispose();
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Documentation
|
|
123
|
-
|
|
124
|
-
Full SDK reference, API docs, trust model, and integration guides:
|
|
125
|
-
|
|
126
|
-
- **[valiron.co/docs](https://valiron.co/docs)** — interactive documentation
|
|
127
|
-
- **[SDK Reference](https://valiron.co/docs/agents/SDK-REFERENCE.md)** — all methods, options, and response types
|
|
128
|
-
- **[API Reference](https://valiron.co/docs/agents/API-REFERENCE.md)** — HTTP endpoints
|
|
129
|
-
- **[Quickstart](https://valiron.co/docs/agents/QUICKSTART.md)** — get started in 2 minutes
|
|
130
|
-
- **[End-to-End Middleware Integration](https://valiron.co/docs/agents/E2E-MIDDLEWARE-INTEGRATION.md)** — identity, trust signals, downstream policy, and testing
|
|
131
|
-
- **[Provider-Backed Identity](https://valiron.co/docs/agents/PROVIDER-IDENTITY.md)** — resolver foundation, proof format, replay handling, policy actions, and ANS adapter status
|
|
132
|
-
- **[Error Guide](https://valiron.co/docs#error-handling)** — codes, recovery actions, retries, and wrapper diagnostics
|
|
133
|
-
- **[llms.txt](https://valiron.co/llms.txt)** — compact reference for LLM/agent integration
|
|
134
|
-
- **Install agent skill**: `npx @valiron/skill`
|
|
135
|
-
|
|
136
|
-
## Support
|
|
137
|
-
|
|
138
|
-
- **Email**: founders@valiron.co
|
|
139
|
-
- **Telegram**: https://t.me/valirongrade
|
|
140
|
-
|
|
141
|
-
## License
|
|
142
|
-
|
|
143
|
-
MIT © Valiron
|
|
5
|
+
- [Documentation](https://www.valiron.co/docs)
|
|
6
|
+
- [Agent docs](https://www.valiron.co/llms-full.txt)
|
|
7
|
+
- [Website](https://www.valiron.co)
|
|
8
|
+
- [founders@valiron.co](mailto:founders@valiron.co)
|
package/dist/clients.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValironConfig, AgentProfile, AgentSnapshotSummary, WalletProfile, WalletResolution, WalletRiskSnapshot, SandboxResult, KeyAgentSandboxResult, GateResult, GateOptions, CallOptions, KeyAgentChallenge, KeyAgentProfile, WorldIdStatus, WorldIdAgentProfile, SelfAgentProfile, SelfProofPayload, SelfSessionRequest, SelfSessionResponse, SelfStatus, AgentIdentityProof, AgentIdentityPolicy, AgentIdentityVerificationResult, ProxyRequest, ProxyResponse } from "./types";
|
|
1
|
+
import { ValironConfig, AgentProfile, AgentSnapshotSummary, WalletProfile, WalletResolution, WalletRiskSnapshot, SandboxResult, KeyAgentSandboxResult, GateResult, GateOptions, CallOptions, KeyAgentChallenge, KeyAgentProfile, KeyAgentIcebreakerProfile, WorldIdStatus, WorldIdAgentProfile, SelfAgentProfile, SelfProofPayload, SelfSessionRequest, SelfSessionResponse, SelfStatus, AgentIdentityProof, AgentIdentityPolicy, AgentIdentityVerificationResult, ProxyRequest, ProxyResponse } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* HTTP client for the Valiron Operator API.
|
|
4
4
|
*
|
|
@@ -13,6 +13,7 @@ export declare class ValironClient {
|
|
|
13
13
|
private timeoutConfigured;
|
|
14
14
|
private debug;
|
|
15
15
|
private telemetry;
|
|
16
|
+
private requestSigner?;
|
|
16
17
|
constructor(config?: ValironConfig);
|
|
17
18
|
/** Resolve the effective chain: per-call override > constructor default > undefined (server default). */
|
|
18
19
|
private resolveChain;
|
|
@@ -34,7 +35,7 @@ export declare class ValironClient {
|
|
|
34
35
|
* `GET /operator/wallet/:wallet`
|
|
35
36
|
*/
|
|
36
37
|
getWalletProfile(wallet: string, options?: CallOptions): Promise<WalletProfile>;
|
|
37
|
-
/** Get an explainable wallet-history risk assessment.
|
|
38
|
+
/** Get an explainable wallet-history risk assessment. Available on Free with an operator API key. */
|
|
38
39
|
getWalletRisk(wallet: string, options?: CallOptions): Promise<WalletRiskSnapshot>;
|
|
39
40
|
/**
|
|
40
41
|
* Resolve a wallet address to an ERC-8004 agent ID.
|
|
@@ -120,6 +121,7 @@ export declare class ValironClient {
|
|
|
120
121
|
* `GET /operator/key/:agentAddress`
|
|
121
122
|
*/
|
|
122
123
|
getKeyAgentProfile(agentAddress: string): Promise<KeyAgentProfile>;
|
|
124
|
+
getKeyAgentIcebreaker(agentAddress: string): Promise<KeyAgentIcebreakerProfile>;
|
|
123
125
|
/**
|
|
124
126
|
* Verify a World ID proof linking a human to an agent.
|
|
125
127
|
*
|
|
@@ -130,6 +132,7 @@ export declare class ValironClient {
|
|
|
130
132
|
merkle_root: string;
|
|
131
133
|
nullifier_hash: string;
|
|
132
134
|
verification_level: "orb" | "device" | "phone";
|
|
135
|
+
idkit_result?: unknown;
|
|
133
136
|
}, options?: CallOptions): Promise<{
|
|
134
137
|
ok: boolean;
|
|
135
138
|
agentId: string;
|
|
@@ -159,11 +162,9 @@ export declare class ValironClient {
|
|
|
159
162
|
*/
|
|
160
163
|
createSelfSession(agentId: string, request?: SelfSessionRequest, options?: CallOptions): Promise<SelfSessionResponse>;
|
|
161
164
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* `POST /operator/self/verify/:agentId`
|
|
165
|
+
* @deprecated Not supported for hosted customer integrations. Use
|
|
166
|
+
* `createSelfSession()` and `getSelfStatus()`. Retained for compatibility;
|
|
167
|
+
* scheduled for removal in the next major SDK release.
|
|
167
168
|
*/
|
|
168
169
|
verifySelf(agentId: string, proof: SelfProofPayload, options?: CallOptions): Promise<{
|
|
169
170
|
ok: boolean;
|
package/dist/clients.js
CHANGED
|
@@ -14,6 +14,7 @@ class ValironClient {
|
|
|
14
14
|
this.endpoint =
|
|
15
15
|
config.endpoint || "https://valiron-edge-proxy.onrender.com";
|
|
16
16
|
this.apiKey = config.apiKey;
|
|
17
|
+
this.requestSigner = config.signRequest;
|
|
17
18
|
this.defaultChain = config.chain;
|
|
18
19
|
this.timeoutConfigured = config.timeout !== undefined;
|
|
19
20
|
this.timeout = config.timeout ?? 10000;
|
|
@@ -38,7 +39,7 @@ class ValironClient {
|
|
|
38
39
|
const query = options?.trustSignals?.length
|
|
39
40
|
? `?trustSignals=${encodeURIComponent([...options.trustSignals].sort().join(","))}`
|
|
40
41
|
: "";
|
|
41
|
-
const profile = await this.get(`/operator/agent/${agentId}${query}`, chain);
|
|
42
|
+
const profile = await this.get(`/operator/agent/${safeIdentifier(agentId)}${query}`, chain);
|
|
42
43
|
// Strip internal fields that the API returns but SDK consumers should not see
|
|
43
44
|
if (profile?.localReputation) {
|
|
44
45
|
delete profile.localReputation.metrics;
|
|
@@ -73,7 +74,7 @@ class ValironClient {
|
|
|
73
74
|
* `GET /operator/wallet/:wallet`
|
|
74
75
|
*/
|
|
75
76
|
async getWalletProfile(wallet, options) {
|
|
76
|
-
const profile = await this.get(`/operator/wallet/${wallet}`, this.resolveChain(options));
|
|
77
|
+
const profile = await this.get(`/operator/wallet/${safeIdentifier(wallet)}`, this.resolveChain(options));
|
|
77
78
|
// Strip internal fields from local reputation
|
|
78
79
|
if (profile?.localReputation) {
|
|
79
80
|
delete profile.localReputation.metrics;
|
|
@@ -81,9 +82,9 @@ class ValironClient {
|
|
|
81
82
|
}
|
|
82
83
|
return profile;
|
|
83
84
|
}
|
|
84
|
-
/** Get an explainable wallet-history risk assessment.
|
|
85
|
+
/** Get an explainable wallet-history risk assessment. Available on Free with an operator API key. */
|
|
85
86
|
async getWalletRisk(wallet, options) {
|
|
86
|
-
return this.get(`/operator/wallet-risk/${wallet}`, this.resolveChain(options));
|
|
87
|
+
return this.get(`/operator/wallet-risk/${safeIdentifier(wallet)}`, this.resolveChain(options));
|
|
87
88
|
}
|
|
88
89
|
/**
|
|
89
90
|
* Resolve a wallet address to an ERC-8004 agent ID.
|
|
@@ -95,7 +96,7 @@ class ValironClient {
|
|
|
95
96
|
* `GET /operator/resolve-wallet/:wallet`
|
|
96
97
|
*/
|
|
97
98
|
async resolveWallet(wallet, options) {
|
|
98
|
-
return this.get(`/operator/resolve-wallet/${wallet}`, this.resolveChain(options));
|
|
99
|
+
return this.get(`/operator/resolve-wallet/${safeIdentifier(wallet)}`, this.resolveChain(options));
|
|
99
100
|
}
|
|
100
101
|
/**
|
|
101
102
|
* Get the latest behavioral snapshot hash for an agent.
|
|
@@ -107,7 +108,7 @@ class ValironClient {
|
|
|
107
108
|
* `GET /operator/agent/:agentId/snapshot`
|
|
108
109
|
*/
|
|
109
110
|
async getAgentSnapshot(agentId, options) {
|
|
110
|
-
return this.get(`/operator/agent/${agentId}/snapshot`, this.resolveChain(options));
|
|
111
|
+
return this.get(`/operator/agent/${safeIdentifier(agentId)}/snapshot`, this.resolveChain(options));
|
|
111
112
|
}
|
|
112
113
|
/**
|
|
113
114
|
* Trigger real sandbox testing for an agent.
|
|
@@ -119,7 +120,7 @@ class ValironClient {
|
|
|
119
120
|
* `POST /operator/trigger-sandbox/:agentId`
|
|
120
121
|
*/
|
|
121
122
|
async triggerSandboxTest(agentId, options) {
|
|
122
|
-
const result = await this.post(`/operator/trigger-sandbox/${agentId}`, undefined, this.resolveChain(options));
|
|
123
|
+
const result = await this.post(`/operator/trigger-sandbox/${safeIdentifier(agentId)}`, undefined, this.resolveChain(options));
|
|
123
124
|
// Strip internal behavioral metrics and execution details from sandbox response
|
|
124
125
|
delete result.metrics;
|
|
125
126
|
delete result.testSummary;
|
|
@@ -137,7 +138,7 @@ class ValironClient {
|
|
|
137
138
|
* `POST /operator/trigger-sandbox-key/:agentAddress`
|
|
138
139
|
*/
|
|
139
140
|
async triggerKeyAgentSandbox(agentAddress) {
|
|
140
|
-
const result = await this.post(`/operator/trigger-sandbox-key/${agentAddress}`);
|
|
141
|
+
const result = await this.post(`/operator/trigger-sandbox-key/${safeIdentifier(agentAddress)}`);
|
|
141
142
|
// Strip internal behavioral metrics and execution details
|
|
142
143
|
delete result.metrics;
|
|
143
144
|
delete result.testSummary;
|
|
@@ -155,7 +156,7 @@ class ValironClient {
|
|
|
155
156
|
*/
|
|
156
157
|
async gate(agentId, options) {
|
|
157
158
|
const { chain, ...body } = options || {};
|
|
158
|
-
const result = await this.post(`/operator/gate/${agentId}`, Object.keys(body).length > 0 ? body : undefined, chain ?? this.defaultChain);
|
|
159
|
+
const result = await this.post(`/operator/gate/${safeIdentifier(agentId)}`, Object.keys(body).length > 0 ? body : undefined, chain ?? this.defaultChain);
|
|
159
160
|
// Strip detailed scoring reasons — SDK consumers get allow/deny + tier only
|
|
160
161
|
delete result.reasons;
|
|
161
162
|
return result;
|
|
@@ -173,7 +174,7 @@ class ValironClient {
|
|
|
173
174
|
*/
|
|
174
175
|
async proxy(agentId, request, options) {
|
|
175
176
|
const chain = this.resolveChain(options);
|
|
176
|
-
return this.post(`/proxy/${agentId}`, request, chain);
|
|
177
|
+
return this.post(`/proxy/${safeIdentifier(agentId)}`, request, chain);
|
|
177
178
|
}
|
|
178
179
|
// ─── Key-Based Agent Identity (Web2 Agents) ─────────────────────────────
|
|
179
180
|
/**
|
|
@@ -182,7 +183,7 @@ class ValironClient {
|
|
|
182
183
|
* `POST /operator/key/:agentAddress/challenge`
|
|
183
184
|
*/
|
|
184
185
|
async getKeyAgentChallenge(agentAddress) {
|
|
185
|
-
return this.post(`/operator/key/${agentAddress}/challenge`);
|
|
186
|
+
return this.post(`/operator/key/${safeIdentifier(agentAddress)}/challenge`);
|
|
186
187
|
}
|
|
187
188
|
/**
|
|
188
189
|
* Verify a key-based agent via challenge-response signature.
|
|
@@ -198,7 +199,10 @@ class ValironClient {
|
|
|
198
199
|
* `GET /operator/key/:agentAddress`
|
|
199
200
|
*/
|
|
200
201
|
async getKeyAgentProfile(agentAddress) {
|
|
201
|
-
return this.get(`/operator/key/${agentAddress}`);
|
|
202
|
+
return this.get(`/operator/key/${safeIdentifier(agentAddress)}`);
|
|
203
|
+
}
|
|
204
|
+
async getKeyAgentIcebreaker(agentAddress) {
|
|
205
|
+
return this.get(`/operator/key/${safeIdentifier(agentAddress)}/icebreaker`);
|
|
202
206
|
}
|
|
203
207
|
// ─── World ID (Proof-of-Personhood) ───────────────────────────────────
|
|
204
208
|
/**
|
|
@@ -207,7 +211,7 @@ class ValironClient {
|
|
|
207
211
|
* `POST /operator/world-id/verify/:agentId`
|
|
208
212
|
*/
|
|
209
213
|
async verifyWorldId(agentId, proof, options) {
|
|
210
|
-
return this.post(`/operator/world-id/verify/${agentId}`, proof, this.resolveChain(options));
|
|
214
|
+
return this.post(`/operator/world-id/verify/${safeIdentifier(agentId)}`, proof, this.resolveChain(options));
|
|
211
215
|
}
|
|
212
216
|
/**
|
|
213
217
|
* Get World ID verification status for an agent.
|
|
@@ -215,7 +219,7 @@ class ValironClient {
|
|
|
215
219
|
* `GET /operator/world-id/status/:agentId`
|
|
216
220
|
*/
|
|
217
221
|
async getWorldIdStatus(agentId, options) {
|
|
218
|
-
return this.get(`/operator/world-id/status/${agentId}`, this.resolveChain(options));
|
|
222
|
+
return this.get(`/operator/world-id/status/${safeIdentifier(agentId)}`, this.resolveChain(options));
|
|
219
223
|
}
|
|
220
224
|
/**
|
|
221
225
|
* Get enriched human-agent trust profile (World ID + Icebreaker).
|
|
@@ -223,7 +227,7 @@ class ValironClient {
|
|
|
223
227
|
* `GET /operator/world-id/profile/:agentId`
|
|
224
228
|
*/
|
|
225
229
|
async getWorldIdProfile(agentId, options) {
|
|
226
|
-
return this.get(`/operator/world-id/profile/${agentId}`, this.resolveChain(options));
|
|
230
|
+
return this.get(`/operator/world-id/profile/${safeIdentifier(agentId)}`, this.resolveChain(options));
|
|
227
231
|
}
|
|
228
232
|
// ─── Self (Eligible Human + Agent ID) ─────────────────────────────────
|
|
229
233
|
/**
|
|
@@ -232,17 +236,15 @@ class ValironClient {
|
|
|
232
236
|
* `POST /operator/self/session/:agentId`
|
|
233
237
|
*/
|
|
234
238
|
async createSelfSession(agentId, request = {}, options) {
|
|
235
|
-
return this.post(`/operator/self/session/${agentId}`, request, this.resolveChain(options));
|
|
239
|
+
return this.post(`/operator/self/session/${safeIdentifier(agentId)}`, request, this.resolveChain(options));
|
|
236
240
|
}
|
|
237
241
|
/**
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* `POST /operator/self/verify/:agentId`
|
|
242
|
+
* @deprecated Not supported for hosted customer integrations. Use
|
|
243
|
+
* `createSelfSession()` and `getSelfStatus()`. Retained for compatibility;
|
|
244
|
+
* scheduled for removal in the next major SDK release.
|
|
243
245
|
*/
|
|
244
246
|
async verifySelf(agentId, proof, options) {
|
|
245
|
-
return this.post(`/operator/self/verify/${agentId}`, proof, this.resolveChain(options));
|
|
247
|
+
return this.post(`/operator/self/verify/${safeIdentifier(agentId)}`, proof, this.resolveChain(options));
|
|
246
248
|
}
|
|
247
249
|
/**
|
|
248
250
|
* Get Self verification status for an agent.
|
|
@@ -250,7 +252,7 @@ class ValironClient {
|
|
|
250
252
|
* `GET /operator/self/status/:agentId`
|
|
251
253
|
*/
|
|
252
254
|
async getSelfStatus(agentId, options) {
|
|
253
|
-
return this.get(`/operator/self/status/${agentId}`, this.resolveChain(options));
|
|
255
|
+
return this.get(`/operator/self/status/${safeIdentifier(agentId)}`, this.resolveChain(options));
|
|
254
256
|
}
|
|
255
257
|
/**
|
|
256
258
|
* Get Self eligible-human / Agent ID profile for an agent.
|
|
@@ -258,7 +260,7 @@ class ValironClient {
|
|
|
258
260
|
* `GET /operator/self/profile/:agentId`
|
|
259
261
|
*/
|
|
260
262
|
async getSelfProfile(agentId, options) {
|
|
261
|
-
return this.get(`/operator/self/profile/${agentId}`, this.resolveChain(options));
|
|
263
|
+
return this.get(`/operator/self/profile/${safeIdentifier(agentId)}`, this.resolveChain(options));
|
|
262
264
|
}
|
|
263
265
|
/** Verify a provider-backed identity proof and evaluate the supplied policy. */
|
|
264
266
|
async verifyAgentIdentity(proof = {}, policy) {
|
|
@@ -318,6 +320,7 @@ class ValironClient {
|
|
|
318
320
|
method: "GET",
|
|
319
321
|
headers: this.buildHeaders(),
|
|
320
322
|
signal: controller.signal,
|
|
323
|
+
redirect: "error",
|
|
321
324
|
});
|
|
322
325
|
responseStatus = response.status;
|
|
323
326
|
const methodName = this.extractMethodName(path);
|
|
@@ -405,13 +408,14 @@ class ValironClient {
|
|
|
405
408
|
if (this.debug) {
|
|
406
409
|
console.log(`[Valiron SDK] POST ${url.toString()}`, body);
|
|
407
410
|
}
|
|
411
|
+
const signedHeaders = this.requestSigner ? await this.requestSigner({ method: "POST", url: url.toString(), body: body == null ? "" : JSON.stringify(body), chain }) : {};
|
|
408
412
|
const controller = new AbortController();
|
|
409
413
|
const timeoutMs = this.getTimeoutForPath(path);
|
|
410
414
|
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
411
415
|
const start = performance.now();
|
|
412
416
|
let responseStatus;
|
|
413
417
|
try {
|
|
414
|
-
const headers = this.buildHeaders();
|
|
418
|
+
const headers = { ...this.buildHeaders(), ...signedHeaders };
|
|
415
419
|
const hasBody = body !== undefined && body !== null;
|
|
416
420
|
if (!hasBody)
|
|
417
421
|
delete headers["Content-Type"];
|
|
@@ -420,6 +424,7 @@ class ValironClient {
|
|
|
420
424
|
headers,
|
|
421
425
|
body: hasBody ? JSON.stringify(body) : undefined,
|
|
422
426
|
signal: controller.signal,
|
|
427
|
+
redirect: "error",
|
|
423
428
|
});
|
|
424
429
|
responseStatus = response.status;
|
|
425
430
|
const methodName = this.extractMethodName(path);
|
|
@@ -548,3 +553,8 @@ class ValironClient {
|
|
|
548
553
|
}
|
|
549
554
|
}
|
|
550
555
|
exports.ValironClient = ValironClient;
|
|
556
|
+
function safeIdentifier(value) {
|
|
557
|
+
if (typeof value !== "string" || !/^[A-Za-z0-9:_-]{1,256}$/.test(value) || value === "." || value === "..")
|
|
558
|
+
throw new types_1.ValironError("Invalid identifier", "INVALID_IDENTIFIER");
|
|
559
|
+
return encodeURIComponent(value);
|
|
560
|
+
}
|
package/dist/identity.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ export interface CreateAgentIdentityProofInput {
|
|
|
12
12
|
provider: string;
|
|
13
13
|
agentId: string;
|
|
14
14
|
body?: AgentIdentityBody;
|
|
15
|
+
audience?: string;
|
|
16
|
+
method?: string;
|
|
17
|
+
url?: string;
|
|
15
18
|
/** Sign the exact UTF-8 payload with the private key bound to the provider identity. */
|
|
16
19
|
sign: (payload: string) => string | Uint8Array | Promise<string | Uint8Array>;
|
|
17
20
|
timestamp?: string;
|
|
@@ -42,6 +45,9 @@ export declare function buildAgentIdentitySigningPayload(input: {
|
|
|
42
45
|
timestamp: string;
|
|
43
46
|
nonce: string;
|
|
44
47
|
requestDigest: string;
|
|
48
|
+
audience?: string;
|
|
49
|
+
method?: string;
|
|
50
|
+
url?: string;
|
|
45
51
|
}): string;
|
|
46
52
|
/** Create a signed proof for one exact request body. Private keys remain with the agent. */
|
|
47
53
|
export declare function createAgentIdentityProof(input: CreateAgentIdentityProofInput): Promise<AgentIdentityProof>;
|
package/dist/identity.js
CHANGED
|
@@ -45,7 +45,10 @@ function sha256RequestDigest(body) {
|
|
|
45
45
|
/** Build the canonical payload understood by Valiron's provider identity verifier. */
|
|
46
46
|
function buildAgentIdentitySigningPayload(input) {
|
|
47
47
|
return [
|
|
48
|
-
"valiron-agent-request-
|
|
48
|
+
"valiron-agent-request-v2",
|
|
49
|
+
`audience:${input.audience || ""}`,
|
|
50
|
+
`method:${input.method?.toUpperCase() || ""}`,
|
|
51
|
+
`url:${input.url || ""}`,
|
|
49
52
|
`agent-id:${input.agentId}`,
|
|
50
53
|
`timestamp:${input.timestamp}`,
|
|
51
54
|
`nonce:${input.nonce}`,
|
|
@@ -62,6 +65,7 @@ async function createAgentIdentityProof(input) {
|
|
|
62
65
|
timestamp,
|
|
63
66
|
nonce,
|
|
64
67
|
requestDigest,
|
|
68
|
+
audience: input.audience, method: input.method, url: input.url,
|
|
65
69
|
}));
|
|
66
70
|
const signature = typeof signed === "string" ? signed : Buffer.from(signed).toString("base64url");
|
|
67
71
|
return {
|
|
@@ -71,6 +75,7 @@ async function createAgentIdentityProof(input) {
|
|
|
71
75
|
timestamp,
|
|
72
76
|
nonce,
|
|
73
77
|
requestDigest,
|
|
78
|
+
audience: input.audience, method: input.method, url: input.url,
|
|
74
79
|
...(input.keyId ? { keyId: input.keyId } : {}),
|
|
75
80
|
};
|
|
76
81
|
}
|
|
@@ -3,6 +3,9 @@ import { type AgentIdentityBody } from "./identity";
|
|
|
3
3
|
import type { AgentIdentityPolicy, AgentIdentityPolicyAction, AgentIdentityTransportProof, AgentIdentityVerificationResult } from "./types";
|
|
4
4
|
type MaybePromise<T> = T | Promise<T>;
|
|
5
5
|
export interface ValironIdentityGateConfig {
|
|
6
|
+
/** Trusted API origin and audience, configured by the API owner. */
|
|
7
|
+
audience?: string;
|
|
8
|
+
origin?: string;
|
|
6
9
|
sdk: ValironSDK;
|
|
7
10
|
/** Policy evaluated by Valiron after identity and reputation checks. */
|
|
8
11
|
policy?: AgentIdentityPolicy;
|
|
@@ -21,6 +24,8 @@ export interface ValironIdentityFastifyConfig extends ValironIdentityGateConfig
|
|
|
21
24
|
prefix?: string;
|
|
22
25
|
}
|
|
23
26
|
export interface ValironIdentityNextConfig {
|
|
27
|
+
audience?: string;
|
|
28
|
+
origin?: string;
|
|
24
29
|
sdk: ValironSDK;
|
|
25
30
|
policy?: AgentIdentityPolicy;
|
|
26
31
|
paths?: string[];
|
|
@@ -40,6 +45,9 @@ export declare function valironIdentityGateCheck(sdk: ValironSDK, input?: {
|
|
|
40
45
|
proof?: AgentIdentityTransportProof;
|
|
41
46
|
body?: AgentIdentityBody;
|
|
42
47
|
policy?: AgentIdentityPolicy;
|
|
48
|
+
audience?: string;
|
|
49
|
+
method?: string;
|
|
50
|
+
url?: string;
|
|
43
51
|
}): Promise<ValironIdentityGateCheckResult>;
|
|
44
52
|
/** Express/Connect middleware for ANS and other provider-backed identities. */
|
|
45
53
|
export declare function createValironIdentityGate(config: ValironIdentityGateConfig): (request: any, response: any, next: any) => void;
|
|
@@ -74,7 +74,9 @@ async function valironIdentityGateCheck(sdk, input = {}) {
|
|
|
74
74
|
const proof = input.proof ?? {};
|
|
75
75
|
const hasClaim = hasIdentityClaim(proof);
|
|
76
76
|
try {
|
|
77
|
-
|
|
77
|
+
if (!input.audience || !input.method || !input.url)
|
|
78
|
+
throw new Error("Trusted request context required");
|
|
79
|
+
const identity = await sdk.verifyAgentIdentity({ ...proof, requestDigest: (0, identity_1.sha256RequestDigest)(input.body), audience: input.audience, method: input.method.toUpperCase(), url: input.url }, input.policy);
|
|
78
80
|
const action = identity.policyDecision.action;
|
|
79
81
|
const allow = action === "allow";
|
|
80
82
|
return {
|
|
@@ -150,7 +152,7 @@ function createValironIdentityGate(config) {
|
|
|
150
152
|
}
|
|
151
153
|
throw error;
|
|
152
154
|
}
|
|
153
|
-
const gate = await valironIdentityGateCheck(frozen.sdk, { proof, body, policy: frozen.policy });
|
|
155
|
+
const gate = await valironIdentityGateCheck(frozen.sdk, { proof, body, policy: frozen.policy, audience: frozen.audience, method: request.method, url: boundUrl(request, frozen.origin) });
|
|
154
156
|
if (gate.allow && gate.identity) {
|
|
155
157
|
request.valironIdentity = gate.identity;
|
|
156
158
|
frozen.onAllow?.(request, gate.identity);
|
|
@@ -195,7 +197,7 @@ async function valironIdentityFastifyPlugin(fastify, opts) {
|
|
|
195
197
|
}
|
|
196
198
|
throw error;
|
|
197
199
|
}
|
|
198
|
-
const gate = await valironIdentityGateCheck(opts.sdk, { proof, body, policy: opts.policy });
|
|
200
|
+
const gate = await valironIdentityGateCheck(opts.sdk, { proof, body, policy: opts.policy, audience: opts.audience, method: request.method, url: boundUrl(request, opts.origin) });
|
|
199
201
|
if (gate.allow && gate.identity) {
|
|
200
202
|
request.valironIdentity = gate.identity;
|
|
201
203
|
opts.onAllow?.(request, gate.identity);
|
|
@@ -224,7 +226,7 @@ function createValironIdentityNextMiddleware(config) {
|
|
|
224
226
|
const body = method === "GET" || method === "HEAD"
|
|
225
227
|
? undefined
|
|
226
228
|
: new Uint8Array(await request.clone().arrayBuffer());
|
|
227
|
-
gate = await valironIdentityGateCheck(frozen.sdk, { proof, body, policy: frozen.policy });
|
|
229
|
+
gate = await valironIdentityGateCheck(frozen.sdk, { proof, body, policy: frozen.policy, audience: frozen.audience, method: request.method, url: boundUrl(request, frozen.origin) });
|
|
228
230
|
}
|
|
229
231
|
catch (error) {
|
|
230
232
|
gate = {
|
|
@@ -245,3 +247,9 @@ function createValironIdentityNextMiddleware(config) {
|
|
|
245
247
|
return new Response(JSON.stringify(gate.body), { status: gate.status, headers });
|
|
246
248
|
};
|
|
247
249
|
}
|
|
250
|
+
function boundUrl(request, origin) {
|
|
251
|
+
if (!origin)
|
|
252
|
+
return undefined;
|
|
253
|
+
const url = new URL(request.originalUrl || request.url, origin);
|
|
254
|
+
return url.origin === new URL(origin).origin ? url.toString() : undefined;
|
|
255
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValironConfig, CallOptions, AgentProfile, AgentSnapshotSummary, WalletProfile, WalletResolution, WalletRiskSnapshot, SandboxResult, KeyAgentSandboxResult, GateResult, GateOptions, RouteDecision, KeyAgentProfile, KeyAgentChallenge, WorldIdStatus, WorldIdAgentProfile, SelfAgentProfile, SelfProofPayload, SelfSessionRequest, SelfSessionResponse, SelfStatus, AgentIdentityProof, AgentIdentityPolicy, AgentIdentityVerificationResult, ProxyRequest, ProxyResponse } from "./types";
|
|
1
|
+
import { ValironConfig, CallOptions, AgentProfile, AgentSnapshotSummary, WalletProfile, WalletResolution, WalletRiskSnapshot, SandboxResult, KeyAgentSandboxResult, GateResult, GateOptions, RouteDecision, KeyAgentProfile, KeyAgentIcebreakerProfile, KeyAgentChallenge, WorldIdStatus, WorldIdAgentProfile, SelfAgentProfile, SelfProofPayload, SelfSessionRequest, SelfSessionResponse, SelfStatus, AgentIdentityProof, AgentIdentityPolicy, AgentIdentityVerificationResult, ProxyRequest, ProxyResponse } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Valiron SDK – Official TypeScript SDK for the Trust Layer for Agentic Economy
|
|
4
4
|
*
|
|
@@ -271,7 +271,7 @@ export declare class ValironSDK {
|
|
|
271
271
|
* trust profile.
|
|
272
272
|
*
|
|
273
273
|
* @param params - Challenge response with EIP-191 signature and address
|
|
274
|
-
* @returns
|
|
274
|
+
* @returns Public agent profile (behavioral score if available; Icebreaker context redacted)
|
|
275
275
|
*/
|
|
276
276
|
verifyKeyAgent(params: {
|
|
277
277
|
challenge: string;
|
|
@@ -281,13 +281,16 @@ export declare class ValironSDK {
|
|
|
281
281
|
/**
|
|
282
282
|
* Get trust profile for a key-based agent by its Ethereum address.
|
|
283
283
|
*
|
|
284
|
-
* Returns behavioral score
|
|
284
|
+
* Returns behavioral score. Icebreaker ownership is redacted from this authenticated summary.
|
|
285
|
+
* Use getKeyAgentIcebreaker() with a Pro operator key for the owner context.
|
|
285
286
|
* The agent must have been verified via challenge-response at least once.
|
|
286
287
|
*
|
|
287
288
|
* @param agentAddress - Ethereum address (keccak256-derived from secp256k1 public key)
|
|
288
289
|
* @returns Agent trust profile
|
|
289
290
|
*/
|
|
290
291
|
getKeyAgentProfile(agentAddress: string): Promise<KeyAgentProfile>;
|
|
292
|
+
/** Get private Icebreaker owner context for a verified Web2 agent. Requires a Pro operator key. */
|
|
293
|
+
getKeyAgentIcebreaker(agentAddress: string): Promise<KeyAgentIcebreakerProfile>;
|
|
291
294
|
/**
|
|
292
295
|
* Verify a World ID proof linking a human to an agent.
|
|
293
296
|
*
|
|
@@ -316,6 +319,7 @@ export declare class ValironSDK {
|
|
|
316
319
|
merkle_root: string;
|
|
317
320
|
nullifier_hash: string;
|
|
318
321
|
verification_level: "orb" | "device" | "phone";
|
|
322
|
+
idkit_result?: unknown;
|
|
319
323
|
}, options?: CallOptions): Promise<{
|
|
320
324
|
ok: boolean;
|
|
321
325
|
agentId: string;
|
|
@@ -374,15 +378,9 @@ export declare class ValironSDK {
|
|
|
374
378
|
*/
|
|
375
379
|
createSelfSession(agentId: string, request?: SelfSessionRequest, options?: CallOptions): Promise<SelfSessionResponse>;
|
|
376
380
|
/**
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
* Self webhook. This method is only useful when the server explicitly allows
|
|
381
|
-
* trusted payload ingestion for local or internal tests.
|
|
382
|
-
*
|
|
383
|
-
* @param agentId - The ERC-8004 agent ID
|
|
384
|
-
* @param proof - Verified Self proof predicates and optional Agent ID link
|
|
385
|
-
* @param options - Optional overrides (e.g. `{ chain: 'base' }`)
|
|
381
|
+
* @deprecated Not supported for hosted customer integrations. Use
|
|
382
|
+
* `createSelfSession()` and `getSelfStatus()`. Retained for compatibility;
|
|
383
|
+
* scheduled for removal in the next major SDK release.
|
|
386
384
|
*/
|
|
387
385
|
verifySelf(agentId: string, proof: SelfProofPayload, options?: CallOptions): Promise<{
|
|
388
386
|
ok: boolean;
|
package/dist/index.js
CHANGED
|
@@ -314,7 +314,7 @@ class ValironSDK {
|
|
|
314
314
|
* trust profile.
|
|
315
315
|
*
|
|
316
316
|
* @param params - Challenge response with EIP-191 signature and address
|
|
317
|
-
* @returns
|
|
317
|
+
* @returns Public agent profile (behavioral score if available; Icebreaker context redacted)
|
|
318
318
|
*/
|
|
319
319
|
async verifyKeyAgent(params) {
|
|
320
320
|
return this.client.verifyKeyAgent(params);
|
|
@@ -322,7 +322,8 @@ class ValironSDK {
|
|
|
322
322
|
/**
|
|
323
323
|
* Get trust profile for a key-based agent by its Ethereum address.
|
|
324
324
|
*
|
|
325
|
-
* Returns behavioral score
|
|
325
|
+
* Returns behavioral score. Icebreaker ownership is redacted from this authenticated summary.
|
|
326
|
+
* Use getKeyAgentIcebreaker() with a Pro operator key for the owner context.
|
|
326
327
|
* The agent must have been verified via challenge-response at least once.
|
|
327
328
|
*
|
|
328
329
|
* @param agentAddress - Ethereum address (keccak256-derived from secp256k1 public key)
|
|
@@ -331,6 +332,10 @@ class ValironSDK {
|
|
|
331
332
|
async getKeyAgentProfile(agentAddress) {
|
|
332
333
|
return this.client.getKeyAgentProfile(agentAddress);
|
|
333
334
|
}
|
|
335
|
+
/** Get private Icebreaker owner context for a verified Web2 agent. Requires a Pro operator key. */
|
|
336
|
+
async getKeyAgentIcebreaker(agentAddress) {
|
|
337
|
+
return this.client.getKeyAgentIcebreaker(agentAddress);
|
|
338
|
+
}
|
|
334
339
|
// ─── World ID (Proof-of-Personhood) ─────────────────────────────────
|
|
335
340
|
/**
|
|
336
341
|
* Verify a World ID proof linking a human to an agent.
|
|
@@ -413,15 +418,9 @@ class ValironSDK {
|
|
|
413
418
|
return this.client.createSelfSession(agentId, request, options);
|
|
414
419
|
}
|
|
415
420
|
/**
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
* Self webhook. This method is only useful when the server explicitly allows
|
|
420
|
-
* trusted payload ingestion for local or internal tests.
|
|
421
|
-
*
|
|
422
|
-
* @param agentId - The ERC-8004 agent ID
|
|
423
|
-
* @param proof - Verified Self proof predicates and optional Agent ID link
|
|
424
|
-
* @param options - Optional overrides (e.g. `{ chain: 'base' }`)
|
|
421
|
+
* @deprecated Not supported for hosted customer integrations. Use
|
|
422
|
+
* `createSelfSession()` and `getSelfStatus()`. Retained for compatibility;
|
|
423
|
+
* scheduled for removal in the next major SDK release.
|
|
425
424
|
*/
|
|
426
425
|
async verifySelf(agentId, proof, options) {
|
|
427
426
|
return this.client.verifySelf(agentId, proof, options);
|