@valiron/sdk 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Official TypeScript SDK for **Valiron** — Trust & Reputation Middleware for API Protection
4
4
 
5
- Protect your API endpoints from bad or malicious AI agents. Valiron evaluates incoming agents using on-chain identity (ERC-8004), behavioral sandbox testing, and Moody's-style credit ratings — so you can allow trusted agents and block risky ones automatically.
5
+ Protect your API endpoints from bad or malicious AI agents. Valiron evaluates incoming agents using on-chain identity (ERC-8004/Solana), key-based identity for local/Web2 agents, behavioral sandbox testing, and Moody's-style credit ratings — so you can allow trusted agents and block risky ones automatically.
6
6
 
7
7
  ## Installation
8
8
 
@@ -17,10 +17,14 @@ import { ValironSDK, createValironGate } from "@valiron/sdk";
17
17
 
18
18
  const valiron = new ValironSDK({ chain: "ethereum" });
19
19
 
20
- // Check if an agent is trusted
20
+ // Check if an on-chain agent is trusted
21
21
  const route = await valiron.checkAgent("AGENT_ID");
22
22
  // Returns: "prod" | "prod_throttled" | "sandbox" | "sandbox_only"
23
23
 
24
+ // Check a local/Web2/non-ERC-8004 agent by persistent key address
25
+ const keyProfile = await valiron.getKeyAgentProfile("0xAgentAddress");
26
+ console.log(keyProfile.route);
27
+
24
28
  // Gate an agent — allow/deny decision
25
29
  const gate = await valiron.gate("AGENT_ID");
26
30
  if (gate.allow) { /* serve the request */ }
@@ -28,18 +32,27 @@ if (gate.allow) { /* serve the request */ }
28
32
  // One-line Express middleware — blocks untrusted agents automatically
29
33
  app.use("/api/paid", createValironGate({ sdk: valiron }));
30
34
 
35
+ // Optional: choose endpoint-specific trust signals
36
+ app.use("/api/paid", createValironGate({
37
+ sdk: valiron,
38
+ trustSignals: ["8004", "sandbox"], // Pro can add "world", "self", and "icebreaker"
39
+ }));
40
+
31
41
  // Fastify, Next.js, and generic middleware also available
32
42
  // See SDK Reference for valironFastifyPlugin, createValironNextMiddleware, valironGateCheck
33
43
  ```
34
44
 
35
45
  No API key required for read operations.
36
46
 
47
+ 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.
48
+
37
49
  ### Additional Features
38
50
 
39
51
  - **Auto-Sandbox** — Middleware automatically evaluates new agents (on-chain and key-based) on their first gated request
40
52
  - **Proxy Gateway** (Pro) — Forward requests through Valiron's edge proxy with SSRF protection
41
53
  - **Key-Based Agents** — Support Web2 agents via EIP-191 challenge-response (auto-detected, auto-sandboxed)
42
54
  - **World ID** — Verify agent-human linkage via Worldcoin proof-of-personhood
55
+ - **Self** — Create Self Enterprise sessions and store signed eligible-human webhook results
43
56
  - **Telemetry** — Optional anonymous usage metrics (disable with `telemetry: { enabled: false }`)
44
57
 
45
58
  ### Cleanup
package/dist/clients.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ValironConfig, AgentProfile, AgentSnapshotSummary, WalletProfile, WalletResolution, SandboxResult, KeyAgentSandboxResult, GateResult, GateOptions, CallOptions, KeyAgentChallenge, KeyAgentProfile, WorldIdStatus, WorldIdAgentProfile, ProxyRequest, ProxyResponse } from "./types";
1
+ import { ValironConfig, AgentProfile, AgentSnapshotSummary, WalletProfile, WalletResolution, SandboxResult, KeyAgentSandboxResult, GateResult, GateOptions, CallOptions, KeyAgentChallenge, KeyAgentProfile, WorldIdStatus, WorldIdAgentProfile, SelfAgentProfile, SelfProofPayload, SelfSessionRequest, SelfSessionResponse, SelfStatus, ProxyRequest, ProxyResponse } from "./types";
2
2
  /**
3
3
  * HTTP client for the Valiron Operator API.
4
4
  *
@@ -10,6 +10,7 @@ export declare class ValironClient {
10
10
  private apiKey?;
11
11
  private defaultChain?;
12
12
  private timeout;
13
+ private timeoutConfigured;
13
14
  private debug;
14
15
  private telemetry;
15
16
  constructor(config?: ValironConfig);
@@ -149,10 +150,48 @@ export declare class ValironClient {
149
150
  * `GET /operator/world-id/profile/:agentId`
150
151
  */
151
152
  getWorldIdProfile(agentId: string, options?: CallOptions): Promise<WorldIdAgentProfile>;
153
+ /**
154
+ * Create a Self Enterprise verification session for an agent.
155
+ *
156
+ * `POST /operator/self/session/:agentId`
157
+ */
158
+ createSelfSession(agentId: string, request?: SelfSessionRequest, options?: CallOptions): Promise<SelfSessionResponse>;
159
+ /**
160
+ * Store a Self verified eligible-human proof and optional Self Agent ID link.
161
+ * Production integrations should prefer `createSelfSession()` plus the
162
+ * signed Self webhook.
163
+ *
164
+ * `POST /operator/self/verify/:agentId`
165
+ */
166
+ verifySelf(agentId: string, proof: SelfProofPayload, options?: CallOptions): Promise<{
167
+ ok: boolean;
168
+ agentId: string;
169
+ self: SelfStatus;
170
+ timestamp: string;
171
+ }>;
172
+ /**
173
+ * Get Self verification status for an agent.
174
+ *
175
+ * `GET /operator/self/status/:agentId`
176
+ */
177
+ getSelfStatus(agentId: string, options?: CallOptions): Promise<{
178
+ agentId: string;
179
+ self: SelfStatus;
180
+ timestamp: string;
181
+ }>;
182
+ /**
183
+ * Get Self eligible-human / Agent ID profile for an agent.
184
+ *
185
+ * `GET /operator/self/profile/:agentId`
186
+ */
187
+ getSelfProfile(agentId: string, options?: CallOptions): Promise<SelfAgentProfile>;
152
188
  /** Flush any pending telemetry events and clean up resources. */
153
189
  dispose(): Promise<void>;
190
+ /** Emit an SDK telemetry event from higher-level helpers. */
191
+ emitTelemetry(event: string, payload: Record<string, unknown>): void;
154
192
  private buildHeaders;
155
193
  private get;
156
194
  private post;
157
195
  private extractMethodName;
196
+ private getTimeoutForPath;
158
197
  }
package/dist/clients.js CHANGED
@@ -15,7 +15,8 @@ class ValironClient {
15
15
  config.endpoint || "https://valiron-edge-proxy.onrender.com";
16
16
  this.apiKey = config.apiKey;
17
17
  this.defaultChain = config.chain;
18
- this.timeout = config.timeout || 5000;
18
+ this.timeoutConfigured = config.timeout !== undefined;
19
+ this.timeout = config.timeout ?? 10000;
19
20
  this.debug = config.debug || false;
20
21
  this.telemetry = new telemetry_1.TelemetryClient(config.telemetry, this.endpoint);
21
22
  }
@@ -34,7 +35,10 @@ class ValironClient {
34
35
  */
35
36
  async getAgentProfile(agentId, options) {
36
37
  const chain = this.resolveChain(options);
37
- const profile = await this.get(`/operator/agent/${agentId}`, chain);
38
+ const query = options?.trustSignals?.length
39
+ ? `?trustSignals=${encodeURIComponent([...options.trustSignals].sort().join(","))}`
40
+ : "";
41
+ const profile = await this.get(`/operator/agent/${agentId}${query}`, chain);
38
42
  // Strip internal fields that the API returns but SDK consumers should not see
39
43
  if (profile?.localReputation) {
40
44
  delete profile.localReputation.metrics;
@@ -51,6 +55,11 @@ class ValironClient {
51
55
  has_onchain_feedback: totalFeedback > 0,
52
56
  feedback_count_bucket: feedbackBucket,
53
57
  avg_score_bucket: avgScoreBucket,
58
+ trust_signals: options?.trustSignals ? [...options.trustSignals].sort().join(",") : undefined,
59
+ trust_signal_count: options?.trustSignals?.length,
60
+ world_included: options?.trustSignals?.includes("world"),
61
+ icebreaker_included: options?.trustSignals?.includes("icebreaker"),
62
+ self_included: options?.trustSignals?.includes("self"),
54
63
  });
55
64
  return profile;
56
65
  }
@@ -211,10 +220,49 @@ class ValironClient {
211
220
  async getWorldIdProfile(agentId, options) {
212
221
  return this.get(`/operator/world-id/profile/${agentId}`, this.resolveChain(options));
213
222
  }
223
+ // ─── Self (Eligible Human + Agent ID) ─────────────────────────────────
224
+ /**
225
+ * Create a Self Enterprise verification session for an agent.
226
+ *
227
+ * `POST /operator/self/session/:agentId`
228
+ */
229
+ async createSelfSession(agentId, request = {}, options) {
230
+ return this.post(`/operator/self/session/${agentId}`, request, this.resolveChain(options));
231
+ }
232
+ /**
233
+ * Store a Self verified eligible-human proof and optional Self Agent ID link.
234
+ * Production integrations should prefer `createSelfSession()` plus the
235
+ * signed Self webhook.
236
+ *
237
+ * `POST /operator/self/verify/:agentId`
238
+ */
239
+ async verifySelf(agentId, proof, options) {
240
+ return this.post(`/operator/self/verify/${agentId}`, proof, this.resolveChain(options));
241
+ }
242
+ /**
243
+ * Get Self verification status for an agent.
244
+ *
245
+ * `GET /operator/self/status/:agentId`
246
+ */
247
+ async getSelfStatus(agentId, options) {
248
+ return this.get(`/operator/self/status/${agentId}`, this.resolveChain(options));
249
+ }
250
+ /**
251
+ * Get Self eligible-human / Agent ID profile for an agent.
252
+ *
253
+ * `GET /operator/self/profile/:agentId`
254
+ */
255
+ async getSelfProfile(agentId, options) {
256
+ return this.get(`/operator/self/profile/${agentId}`, this.resolveChain(options));
257
+ }
214
258
  /** Flush any pending telemetry events and clean up resources. */
215
259
  async dispose() {
216
260
  await this.telemetry.dispose();
217
261
  }
262
+ /** Emit an SDK telemetry event from higher-level helpers. */
263
+ emitTelemetry(event, payload) {
264
+ this.telemetry.emit(event, payload);
265
+ }
218
266
  // ─── HTTP helpers ───────────────────────────────────────────────────────
219
267
  buildHeaders() {
220
268
  const headers = {
@@ -233,7 +281,8 @@ class ValironClient {
233
281
  console.log(`[Valiron SDK] GET ${url.toString()}`);
234
282
  }
235
283
  const controller = new AbortController();
236
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
284
+ const timeoutMs = this.getTimeoutForPath(path);
285
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
237
286
  const start = Date.now();
238
287
  try {
239
288
  const response = await fetch(url.toString(), {
@@ -292,9 +341,10 @@ class ValironClient {
292
341
  retries: 0,
293
342
  timeout_count: 1,
294
343
  abort_count: 1,
344
+ timeout_ms: timeoutMs,
295
345
  });
296
346
  this.telemetry.recordLatency(methodName, chain || "server_default", durationMs);
297
- throw new types_1.ValironError(`Request timeout after ${this.timeout}ms`, "TIMEOUT_ERROR");
347
+ throw new types_1.ValironError(`Request timeout after ${timeoutMs}ms`, "TIMEOUT_ERROR");
298
348
  }
299
349
  if (error instanceof types_1.ValironError)
300
350
  throw error;
@@ -320,7 +370,8 @@ class ValironClient {
320
370
  console.log(`[Valiron SDK] POST ${url.toString()}`, body);
321
371
  }
322
372
  const controller = new AbortController();
323
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
373
+ const timeoutMs = this.getTimeoutForPath(path);
374
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
324
375
  const start = Date.now();
325
376
  try {
326
377
  const headers = this.buildHeaders();
@@ -384,9 +435,10 @@ class ValironClient {
384
435
  retries: 0,
385
436
  timeout_count: 1,
386
437
  abort_count: 1,
438
+ timeout_ms: timeoutMs,
387
439
  });
388
440
  this.telemetry.recordLatency(methodName, chain || "server_default", durationMs);
389
- throw new types_1.ValironError(`Request timeout after ${this.timeout}ms`, "TIMEOUT_ERROR");
441
+ throw new types_1.ValironError(`Request timeout after ${timeoutMs}ms`, "TIMEOUT_ERROR");
390
442
  }
391
443
  if (error instanceof types_1.ValironError)
392
444
  throw error;
@@ -425,5 +477,16 @@ class ValironClient {
425
477
  return "keyAgent";
426
478
  return "unknown";
427
479
  }
480
+ getTimeoutForPath(path) {
481
+ if (this.timeoutConfigured)
482
+ return this.timeout;
483
+ if (path.startsWith("/operator/trigger-sandbox/"))
484
+ return 30000;
485
+ if (path.startsWith("/operator/gate/"))
486
+ return 15000;
487
+ if (path.startsWith("/proxy/"))
488
+ return 15000;
489
+ return this.timeout;
490
+ }
428
491
  }
429
492
  exports.ValironClient = ValironClient;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ValironConfig, CallOptions, AgentProfile, AgentSnapshotSummary, WalletProfile, WalletResolution, SandboxResult, KeyAgentSandboxResult, GateResult, GateOptions, RouteDecision, KeyAgentProfile, KeyAgentChallenge, WorldIdStatus, WorldIdAgentProfile, ProxyRequest, ProxyResponse } from "./types";
1
+ import { ValironConfig, CallOptions, AgentProfile, AgentSnapshotSummary, WalletProfile, WalletResolution, SandboxResult, KeyAgentSandboxResult, GateResult, GateOptions, RouteDecision, KeyAgentProfile, KeyAgentChallenge, WorldIdStatus, WorldIdAgentProfile, SelfAgentProfile, SelfProofPayload, SelfSessionRequest, SelfSessionResponse, SelfStatus, ProxyRequest, ProxyResponse } from "./types";
2
2
  /**
3
3
  * Valiron SDK – Official TypeScript SDK for the Trust Layer for Agentic Economy
4
4
  *
@@ -356,6 +356,53 @@ export declare class ValironSDK {
356
356
  * ```
357
357
  */
358
358
  getWorldIdProfile(agentId: string, options?: CallOptions): Promise<WorldIdAgentProfile>;
359
+ /**
360
+ * Create a Self Enterprise verification session for an agent.
361
+ *
362
+ * The returned `verificationUrl` is a hosted Self URL. After the user
363
+ * completes the flow, Self calls Valiron's signed webhook and Valiron stores
364
+ * the verified `self` trust signal.
365
+ *
366
+ * @param agentId - The ERC-8004 agent ID
367
+ * @param request - Optional redirect URLs, metadata, and Self Agent ID fields
368
+ * @param options - Optional overrides (e.g. `{ chain: 'base' }`)
369
+ */
370
+ createSelfSession(agentId: string, request?: SelfSessionRequest, options?: CallOptions): Promise<SelfSessionResponse>;
371
+ /**
372
+ * Store a Self verified eligible-human proof and optional Self Agent ID link.
373
+ *
374
+ * Production integrations should use `createSelfSession()` and the signed
375
+ * Self webhook. This method is only useful when the server explicitly allows
376
+ * trusted payload ingestion for local or internal tests.
377
+ *
378
+ * @param agentId - The ERC-8004 agent ID
379
+ * @param proof - Verified Self proof predicates and optional Agent ID link
380
+ * @param options - Optional overrides (e.g. `{ chain: 'base' }`)
381
+ */
382
+ verifySelf(agentId: string, proof: SelfProofPayload, options?: CallOptions): Promise<{
383
+ ok: boolean;
384
+ agentId: string;
385
+ self: SelfStatus;
386
+ timestamp: string;
387
+ }>;
388
+ /**
389
+ * Get Self verification status for an agent.
390
+ *
391
+ * @param agentId - The ERC-8004 agent ID
392
+ * @param options - Optional overrides (e.g. `{ chain: 'base' }`)
393
+ */
394
+ getSelfStatus(agentId: string, options?: CallOptions): Promise<{
395
+ agentId: string;
396
+ self: SelfStatus;
397
+ timestamp: string;
398
+ }>;
399
+ /**
400
+ * Get Self eligible-human / Agent ID profile for an agent.
401
+ *
402
+ * @param agentId - The ERC-8004 agent ID
403
+ * @param options - Optional overrides (e.g. `{ chain: 'base' }`)
404
+ */
405
+ getSelfProfile(agentId: string, options?: CallOptions): Promise<SelfAgentProfile>;
359
406
  /**
360
407
  * Flush any pending telemetry events and release resources.
361
408
  *
@@ -375,6 +422,8 @@ export declare class ValironSDK {
375
422
  * ```
376
423
  */
377
424
  dispose(): Promise<void>;
425
+ /** @internal Emit Valiron SDK telemetry from helper modules. */
426
+ emitTelemetry(event: string, payload: Record<string, unknown>): void;
378
427
  }
379
428
  export * from "./types";
380
429
  export { ValironClient } from "./clients";
package/dist/index.js CHANGED
@@ -390,6 +390,53 @@ class ValironSDK {
390
390
  async getWorldIdProfile(agentId, options) {
391
391
  return this.client.getWorldIdProfile(agentId, options);
392
392
  }
393
+ // ─── Self (Eligible Human + Agent ID) ─────────────────────────────────
394
+ /**
395
+ * Create a Self Enterprise verification session for an agent.
396
+ *
397
+ * The returned `verificationUrl` is a hosted Self URL. After the user
398
+ * completes the flow, Self calls Valiron's signed webhook and Valiron stores
399
+ * the verified `self` trust signal.
400
+ *
401
+ * @param agentId - The ERC-8004 agent ID
402
+ * @param request - Optional redirect URLs, metadata, and Self Agent ID fields
403
+ * @param options - Optional overrides (e.g. `{ chain: 'base' }`)
404
+ */
405
+ async createSelfSession(agentId, request = {}, options) {
406
+ return this.client.createSelfSession(agentId, request, options);
407
+ }
408
+ /**
409
+ * Store a Self verified eligible-human proof and optional Self Agent ID link.
410
+ *
411
+ * Production integrations should use `createSelfSession()` and the signed
412
+ * Self webhook. This method is only useful when the server explicitly allows
413
+ * trusted payload ingestion for local or internal tests.
414
+ *
415
+ * @param agentId - The ERC-8004 agent ID
416
+ * @param proof - Verified Self proof predicates and optional Agent ID link
417
+ * @param options - Optional overrides (e.g. `{ chain: 'base' }`)
418
+ */
419
+ async verifySelf(agentId, proof, options) {
420
+ return this.client.verifySelf(agentId, proof, options);
421
+ }
422
+ /**
423
+ * Get Self verification status for an agent.
424
+ *
425
+ * @param agentId - The ERC-8004 agent ID
426
+ * @param options - Optional overrides (e.g. `{ chain: 'base' }`)
427
+ */
428
+ async getSelfStatus(agentId, options) {
429
+ return this.client.getSelfStatus(agentId, options);
430
+ }
431
+ /**
432
+ * Get Self eligible-human / Agent ID profile for an agent.
433
+ *
434
+ * @param agentId - The ERC-8004 agent ID
435
+ * @param options - Optional overrides (e.g. `{ chain: 'base' }`)
436
+ */
437
+ async getSelfProfile(agentId, options) {
438
+ return this.client.getSelfProfile(agentId, options);
439
+ }
393
440
  /**
394
441
  * Flush any pending telemetry events and release resources.
395
442
  *
@@ -411,6 +458,10 @@ class ValironSDK {
411
458
  dispose() {
412
459
  return this.client.dispose();
413
460
  }
461
+ /** @internal Emit Valiron SDK telemetry from helper modules. */
462
+ emitTelemetry(event, payload) {
463
+ this.client.emitTelemetry(event, payload);
464
+ }
414
465
  }
415
466
  exports.ValironSDK = ValironSDK;
416
467
  // Re-export everything
@@ -1,5 +1,5 @@
1
1
  import type { ValironSDK } from "./index";
2
- import type { GateResult } from "./types";
2
+ import type { GateResult, TrustSignal } from "./types";
3
3
  /**
4
4
  * Configuration for the Valiron trust gate middleware.
5
5
  *
@@ -23,6 +23,8 @@ export interface ValironGateConfig {
23
23
  extractAgentAddress?: (req: any) => string | null;
24
24
  /** Minimum Valiron score to allow (default: 65). */
25
25
  minScore?: number;
26
+ /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+self+icebreaker. */
27
+ trustSignals?: TrustSignal[];
26
28
  /**
27
29
  * Client-side profile cache TTL in ms.
28
30
  *
@@ -89,6 +91,8 @@ export interface ValironFastifyConfig {
89
91
  extractAgentAddress?: (req: any) => string | null;
90
92
  /** Minimum Valiron score to allow (default: 65). */
91
93
  minScore?: number;
94
+ /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+self+icebreaker. */
95
+ trustSignals?: TrustSignal[];
92
96
  /**
93
97
  * Client-side profile cache TTL in ms (default: 30000).
94
98
  * Set to `0` to disable.
@@ -150,6 +154,8 @@ export interface ValironNextConfig {
150
154
  extractAgentAddress?: (req: Request) => string | null;
151
155
  /** Minimum Valiron score to allow (default: 65). */
152
156
  minScore?: number;
157
+ /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+self+icebreaker. */
158
+ trustSignals?: TrustSignal[];
153
159
  /**
154
160
  * Client-side profile cache TTL in ms (default: 30000).
155
161
  * Set to `0` to disable.
@@ -264,6 +270,8 @@ export declare function valironGateCheck(sdk: ValironSDK, opts: {
264
270
  /** Key-based agent hash (web2). Checked if agentId is not provided. */
265
271
  agentAddress?: string | null;
266
272
  minScore?: number;
273
+ /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+self+icebreaker. */
274
+ trustSignals?: TrustSignal[];
267
275
  /**
268
276
  * Client-side profile cache TTL in ms (default: 30000).
269
277
  * Set to `0` to disable.