@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.
- package/README.md +5 -154
- package/dist/clients.d.ts +6 -6
- package/dist/clients.js +33 -26
- 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 +5 -10
- package/dist/index.js +4 -10
- 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 +14 -4
- package/docs/AGENT-READY-APIS.md +3 -181
- package/docs/API-REFERENCE.md +88 -546
- 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 +19 -13
- package/docs/ERRORS.md +27 -19
- package/docs/IDENTITY.md +16 -14
- package/docs/PROVIDER-IDENTITY.md +15 -5
- package/docs/QUICKSTART.md +34 -24
- package/docs/README.md +15 -4
- package/docs/SANDBOX.md +7 -1
- package/docs/SDK-REFERENCE.md +70 -52
- package/docs/SECURITY-UPGRADE-2026-10-31.md +98 -0
- package/docs/TRUST-MODEL.md +14 -11
- package/docs/llms.txt +65 -307
- package/package.json +3 -3
- package/docs/MCP.md +0 -50
package/README.md
CHANGED
|
@@ -1,157 +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. Sandbox runs require an operator API key. Pro trust signals, enriched profiles, proxy calls, webhooks, and `getWalletRisk()` require a Pro operator 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
|
-
For a verified key-based agent, a Pro operator can read private Icebreaker
|
|
53
|
-
human-owner context with `getKeyAgentIcebreaker()`:
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
const { icebreaker } = await valiron.getKeyAgentIcebreaker("0xAgentAddress");
|
|
57
|
-
if (icebreaker.attested) {
|
|
58
|
-
console.log(icebreaker.owner, icebreaker.verifiedHandles);
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
The public key-agent profile redacts this context. The API seller decides
|
|
63
|
-
whether to require the attestation for an action; it does not automatically
|
|
64
|
-
change the Web2 behavioral score or provide social connections or mutuals.
|
|
65
|
-
|
|
66
|
-
Provider-backed identities such as ANS use signed `x-valiron-identity-*`
|
|
67
|
-
headers. SDK 1.3 provides `createAgentIdentityProof()` for agents,
|
|
68
|
-
`verifyAgentIdentity()` for low-level verification, and dedicated Express,
|
|
69
|
-
Fastify, Next.js, and generic identity gates. Valiron hosts the ANS credentials
|
|
70
|
-
and trusted CA bundle; SDK users do not configure them. See the
|
|
71
|
-
[provider-backed identity guide](https://valiron.co/docs/agents/PROVIDER-IDENTITY.md)
|
|
72
|
-
for the signing and middleware quickstart.
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
import {
|
|
76
|
-
agentIdentityProofHeaders,
|
|
77
|
-
createAgentIdentityProof,
|
|
78
|
-
createValironIdentityGate,
|
|
79
|
-
} from "@valiron/sdk";
|
|
80
|
-
|
|
81
|
-
// Agent: sign the exact bytes it will send.
|
|
82
|
-
const body = JSON.stringify({ operation: "quote" });
|
|
83
|
-
const proof = await createAgentIdentityProof({
|
|
84
|
-
provider: "ans",
|
|
85
|
-
agentId: "ans://v1.0.0.sales-agent.acme.com",
|
|
86
|
-
body,
|
|
87
|
-
sign: (payload) => agentKey.sign(payload),
|
|
88
|
-
});
|
|
89
|
-
await fetch(apiUrl, { method: "POST", body, headers: agentIdentityProofHeaders(proof) });
|
|
90
|
-
|
|
91
|
-
// API owner: capture raw bytes, then enforce the returned identity policy.
|
|
92
|
-
app.use(express.json({ verify: (req: any, _res, bytes) => { req.rawBody = Buffer.from(bytes); } }));
|
|
93
|
-
app.post("/quote", createValironIdentityGate({
|
|
94
|
-
sdk: valiron,
|
|
95
|
-
policy: { anonymous: "challenge", claimed: "block", verified: "allow" },
|
|
96
|
-
}), handler);
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Error diagnostics
|
|
100
|
-
|
|
101
|
-
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.
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
import { ValironError } from "@valiron/sdk";
|
|
105
|
-
|
|
106
|
-
try {
|
|
107
|
-
await valiron.getAgentProfile("AGENT_ID");
|
|
108
|
-
} catch (error) {
|
|
109
|
-
if (error instanceof ValironError) {
|
|
110
|
-
console.error(error.code, error.message, error.details?.action);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
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.
|
|
116
|
-
|
|
117
|
-
### Additional Features
|
|
118
|
-
|
|
119
|
-
- **Auto-Sandbox** — Middleware automatically evaluates new agents (on-chain and key-based) on their first gated request
|
|
120
|
-
- **Predictive Risk** — Dashboard/API forecasts whether an observed agent is improving, stable, or becoming riskier before the next action
|
|
121
|
-
- **Proxy Gateway** (Pro) — Forward requests through Valiron's edge proxy with SSRF protection
|
|
122
|
-
- **Key-Based Agents** — Support Web2 agents via EIP-191 challenge-response (auto-detected, auto-sandboxed)
|
|
123
|
-
- **World ID** — Verify agent-human linkage via Worldcoin proof-of-personhood
|
|
124
|
-
- **Self** — Create Self Enterprise sessions and store signed eligible-human webhook results
|
|
125
|
-
- **Wallet Intelligence** (Pro) — Score bounded Alchemy/Helius wallet history with confidence and explainable reasons
|
|
126
|
-
- **Telemetry** — Optional anonymous usage metrics (disable with `telemetry: { enabled: false }`)
|
|
127
|
-
|
|
128
|
-
### Cleanup
|
|
129
|
-
|
|
130
|
-
Call `dispose()` when shutting down long-running servers:
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
await valiron.dispose();
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## Documentation
|
|
137
|
-
|
|
138
|
-
Full SDK reference, API docs, trust model, and integration guides:
|
|
139
|
-
|
|
140
|
-
- **[valiron.co/docs](https://valiron.co/docs)** — interactive documentation
|
|
141
|
-
- **[SDK Reference](https://valiron.co/docs/agents/SDK-REFERENCE.md)** — all methods, options, and response types
|
|
142
|
-
- **[API Reference](https://valiron.co/docs/agents/API-REFERENCE.md)** — HTTP endpoints
|
|
143
|
-
- **[Quickstart](https://valiron.co/docs/agents/QUICKSTART.md)** — get started in 2 minutes
|
|
144
|
-
- **[End-to-End Middleware Integration](https://valiron.co/docs/agents/E2E-MIDDLEWARE-INTEGRATION.md)** — identity, trust signals, downstream policy, and testing
|
|
145
|
-
- **[Provider-Backed Identity](https://valiron.co/docs/agents/PROVIDER-IDENTITY.md)** — resolver foundation, proof format, replay handling, policy actions, and ANS adapter status
|
|
146
|
-
- **[Error Guide](https://valiron.co/docs#error-handling)** — codes, recovery actions, retries, and wrapper diagnostics
|
|
147
|
-
- **[llms.txt](https://valiron.co/llms.txt)** — compact reference for LLM/agent integration
|
|
148
|
-
- **Install agent skill**: `npx @valiron/skill`
|
|
149
|
-
|
|
150
|
-
## Support
|
|
151
|
-
|
|
152
|
-
- **Email**: founders@valiron.co
|
|
153
|
-
- **Telegram**: https://t.me/valirongrade
|
|
154
|
-
|
|
155
|
-
## License
|
|
156
|
-
|
|
157
|
-
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
|
@@ -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.
|
|
@@ -131,6 +132,7 @@ export declare class ValironClient {
|
|
|
131
132
|
merkle_root: string;
|
|
132
133
|
nullifier_hash: string;
|
|
133
134
|
verification_level: "orb" | "device" | "phone";
|
|
135
|
+
idkit_result?: unknown;
|
|
134
136
|
}, options?: CallOptions): Promise<{
|
|
135
137
|
ok: boolean;
|
|
136
138
|
agentId: string;
|
|
@@ -160,11 +162,9 @@ export declare class ValironClient {
|
|
|
160
162
|
*/
|
|
161
163
|
createSelfSession(agentId: string, request?: SelfSessionRequest, options?: CallOptions): Promise<SelfSessionResponse>;
|
|
162
164
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* `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.
|
|
168
168
|
*/
|
|
169
169
|
verifySelf(agentId: string, proof: SelfProofPayload, options?: CallOptions): Promise<{
|
|
170
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,10 +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)}`);
|
|
202
203
|
}
|
|
203
204
|
async getKeyAgentIcebreaker(agentAddress) {
|
|
204
|
-
return this.get(`/operator/key/${agentAddress}/icebreaker`);
|
|
205
|
+
return this.get(`/operator/key/${safeIdentifier(agentAddress)}/icebreaker`);
|
|
205
206
|
}
|
|
206
207
|
// ─── World ID (Proof-of-Personhood) ───────────────────────────────────
|
|
207
208
|
/**
|
|
@@ -210,7 +211,7 @@ class ValironClient {
|
|
|
210
211
|
* `POST /operator/world-id/verify/:agentId`
|
|
211
212
|
*/
|
|
212
213
|
async verifyWorldId(agentId, proof, options) {
|
|
213
|
-
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));
|
|
214
215
|
}
|
|
215
216
|
/**
|
|
216
217
|
* Get World ID verification status for an agent.
|
|
@@ -218,7 +219,7 @@ class ValironClient {
|
|
|
218
219
|
* `GET /operator/world-id/status/:agentId`
|
|
219
220
|
*/
|
|
220
221
|
async getWorldIdStatus(agentId, options) {
|
|
221
|
-
return this.get(`/operator/world-id/status/${agentId}`, this.resolveChain(options));
|
|
222
|
+
return this.get(`/operator/world-id/status/${safeIdentifier(agentId)}`, this.resolveChain(options));
|
|
222
223
|
}
|
|
223
224
|
/**
|
|
224
225
|
* Get enriched human-agent trust profile (World ID + Icebreaker).
|
|
@@ -226,7 +227,7 @@ class ValironClient {
|
|
|
226
227
|
* `GET /operator/world-id/profile/:agentId`
|
|
227
228
|
*/
|
|
228
229
|
async getWorldIdProfile(agentId, options) {
|
|
229
|
-
return this.get(`/operator/world-id/profile/${agentId}`, this.resolveChain(options));
|
|
230
|
+
return this.get(`/operator/world-id/profile/${safeIdentifier(agentId)}`, this.resolveChain(options));
|
|
230
231
|
}
|
|
231
232
|
// ─── Self (Eligible Human + Agent ID) ─────────────────────────────────
|
|
232
233
|
/**
|
|
@@ -235,17 +236,15 @@ class ValironClient {
|
|
|
235
236
|
* `POST /operator/self/session/:agentId`
|
|
236
237
|
*/
|
|
237
238
|
async createSelfSession(agentId, request = {}, options) {
|
|
238
|
-
return this.post(`/operator/self/session/${agentId}`, request, this.resolveChain(options));
|
|
239
|
+
return this.post(`/operator/self/session/${safeIdentifier(agentId)}`, request, this.resolveChain(options));
|
|
239
240
|
}
|
|
240
241
|
/**
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* `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.
|
|
246
245
|
*/
|
|
247
246
|
async verifySelf(agentId, proof, options) {
|
|
248
|
-
return this.post(`/operator/self/verify/${agentId}`, proof, this.resolveChain(options));
|
|
247
|
+
return this.post(`/operator/self/verify/${safeIdentifier(agentId)}`, proof, this.resolveChain(options));
|
|
249
248
|
}
|
|
250
249
|
/**
|
|
251
250
|
* Get Self verification status for an agent.
|
|
@@ -253,7 +252,7 @@ class ValironClient {
|
|
|
253
252
|
* `GET /operator/self/status/:agentId`
|
|
254
253
|
*/
|
|
255
254
|
async getSelfStatus(agentId, options) {
|
|
256
|
-
return this.get(`/operator/self/status/${agentId}`, this.resolveChain(options));
|
|
255
|
+
return this.get(`/operator/self/status/${safeIdentifier(agentId)}`, this.resolveChain(options));
|
|
257
256
|
}
|
|
258
257
|
/**
|
|
259
258
|
* Get Self eligible-human / Agent ID profile for an agent.
|
|
@@ -261,7 +260,7 @@ class ValironClient {
|
|
|
261
260
|
* `GET /operator/self/profile/:agentId`
|
|
262
261
|
*/
|
|
263
262
|
async getSelfProfile(agentId, options) {
|
|
264
|
-
return this.get(`/operator/self/profile/${agentId}`, this.resolveChain(options));
|
|
263
|
+
return this.get(`/operator/self/profile/${safeIdentifier(agentId)}`, this.resolveChain(options));
|
|
265
264
|
}
|
|
266
265
|
/** Verify a provider-backed identity proof and evaluate the supplied policy. */
|
|
267
266
|
async verifyAgentIdentity(proof = {}, policy) {
|
|
@@ -321,6 +320,7 @@ class ValironClient {
|
|
|
321
320
|
method: "GET",
|
|
322
321
|
headers: this.buildHeaders(),
|
|
323
322
|
signal: controller.signal,
|
|
323
|
+
redirect: "error",
|
|
324
324
|
});
|
|
325
325
|
responseStatus = response.status;
|
|
326
326
|
const methodName = this.extractMethodName(path);
|
|
@@ -408,13 +408,14 @@ class ValironClient {
|
|
|
408
408
|
if (this.debug) {
|
|
409
409
|
console.log(`[Valiron SDK] POST ${url.toString()}`, body);
|
|
410
410
|
}
|
|
411
|
+
const signedHeaders = this.requestSigner ? await this.requestSigner({ method: "POST", url: url.toString(), body: body == null ? "" : JSON.stringify(body), chain }) : {};
|
|
411
412
|
const controller = new AbortController();
|
|
412
413
|
const timeoutMs = this.getTimeoutForPath(path);
|
|
413
414
|
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
414
415
|
const start = performance.now();
|
|
415
416
|
let responseStatus;
|
|
416
417
|
try {
|
|
417
|
-
const headers = this.buildHeaders();
|
|
418
|
+
const headers = { ...this.buildHeaders(), ...signedHeaders };
|
|
418
419
|
const hasBody = body !== undefined && body !== null;
|
|
419
420
|
if (!hasBody)
|
|
420
421
|
delete headers["Content-Type"];
|
|
@@ -423,6 +424,7 @@ class ValironClient {
|
|
|
423
424
|
headers,
|
|
424
425
|
body: hasBody ? JSON.stringify(body) : undefined,
|
|
425
426
|
signal: controller.signal,
|
|
427
|
+
redirect: "error",
|
|
426
428
|
});
|
|
427
429
|
responseStatus = response.status;
|
|
428
430
|
const methodName = this.extractMethodName(path);
|
|
@@ -551,3 +553,8 @@ class ValironClient {
|
|
|
551
553
|
}
|
|
552
554
|
}
|
|
553
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
|
@@ -281,7 +281,7 @@ 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. Icebreaker ownership is redacted from this
|
|
284
|
+
* Returns behavioral score. Icebreaker ownership is redacted from this authenticated summary.
|
|
285
285
|
* Use getKeyAgentIcebreaker() with a Pro operator key for the owner context.
|
|
286
286
|
* The agent must have been verified via challenge-response at least once.
|
|
287
287
|
*
|
|
@@ -319,6 +319,7 @@ export declare class ValironSDK {
|
|
|
319
319
|
merkle_root: string;
|
|
320
320
|
nullifier_hash: string;
|
|
321
321
|
verification_level: "orb" | "device" | "phone";
|
|
322
|
+
idkit_result?: unknown;
|
|
322
323
|
}, options?: CallOptions): Promise<{
|
|
323
324
|
ok: boolean;
|
|
324
325
|
agentId: string;
|
|
@@ -377,15 +378,9 @@ export declare class ValironSDK {
|
|
|
377
378
|
*/
|
|
378
379
|
createSelfSession(agentId: string, request?: SelfSessionRequest, options?: CallOptions): Promise<SelfSessionResponse>;
|
|
379
380
|
/**
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
* Self webhook. This method is only useful when the server explicitly allows
|
|
384
|
-
* trusted payload ingestion for local or internal tests.
|
|
385
|
-
*
|
|
386
|
-
* @param agentId - The ERC-8004 agent ID
|
|
387
|
-
* @param proof - Verified Self proof predicates and optional Agent ID link
|
|
388
|
-
* @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.
|
|
389
384
|
*/
|
|
390
385
|
verifySelf(agentId: string, proof: SelfProofPayload, options?: CallOptions): Promise<{
|
|
391
386
|
ok: boolean;
|
package/dist/index.js
CHANGED
|
@@ -322,7 +322,7 @@ class ValironSDK {
|
|
|
322
322
|
/**
|
|
323
323
|
* Get trust profile for a key-based agent by its Ethereum address.
|
|
324
324
|
*
|
|
325
|
-
* Returns behavioral score. Icebreaker ownership is redacted from this
|
|
325
|
+
* Returns behavioral score. Icebreaker ownership is redacted from this authenticated summary.
|
|
326
326
|
* Use getKeyAgentIcebreaker() with a Pro operator key for the owner context.
|
|
327
327
|
* The agent must have been verified via challenge-response at least once.
|
|
328
328
|
*
|
|
@@ -418,15 +418,9 @@ class ValironSDK {
|
|
|
418
418
|
return this.client.createSelfSession(agentId, request, options);
|
|
419
419
|
}
|
|
420
420
|
/**
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
* Self webhook. This method is only useful when the server explicitly allows
|
|
425
|
-
* trusted payload ingestion for local or internal tests.
|
|
426
|
-
*
|
|
427
|
-
* @param agentId - The ERC-8004 agent ID
|
|
428
|
-
* @param proof - Verified Self proof predicates and optional Agent ID link
|
|
429
|
-
* @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.
|
|
430
424
|
*/
|
|
431
425
|
async verifySelf(agentId, proof, options) {
|
|
432
426
|
return this.client.verifySelf(agentId, proof, options);
|