@valiron/sdk 1.0.2 → 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 */ }
@@ -31,7 +35,7 @@ app.use("/api/paid", createValironGate({ sdk: valiron }));
31
35
  // Optional: choose endpoint-specific trust signals
32
36
  app.use("/api/paid", createValironGate({
33
37
  sdk: valiron,
34
- trustSignals: ["8004", "sandbox"], // Pro can add "world" and "icebreaker"
38
+ trustSignals: ["8004", "sandbox"], // Pro can add "world", "self", and "icebreaker"
35
39
  }));
36
40
 
37
41
  // Fastify, Next.js, and generic middleware also available
@@ -40,12 +44,15 @@ app.use("/api/paid", createValironGate({
40
44
 
41
45
  No API key required for read operations.
42
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
+
43
49
  ### Additional Features
44
50
 
45
51
  - **Auto-Sandbox** — Middleware automatically evaluates new agents (on-chain and key-based) on their first gated request
46
52
  - **Proxy Gateway** (Pro) — Forward requests through Valiron's edge proxy with SSRF protection
47
53
  - **Key-Based Agents** — Support Web2 agents via EIP-191 challenge-response (auto-detected, auto-sandboxed)
48
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
49
56
  - **Telemetry** — Optional anonymous usage metrics (disable with `telemetry: { enabled: false }`)
50
57
 
51
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
  *
@@ -150,6 +150,41 @@ export declare class ValironClient {
150
150
  * `GET /operator/world-id/profile/:agentId`
151
151
  */
152
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>;
153
188
  /** Flush any pending telemetry events and clean up resources. */
154
189
  dispose(): Promise<void>;
155
190
  /** Emit an SDK telemetry event from higher-level helpers. */
package/dist/clients.js CHANGED
@@ -59,6 +59,7 @@ class ValironClient {
59
59
  trust_signal_count: options?.trustSignals?.length,
60
60
  world_included: options?.trustSignals?.includes("world"),
61
61
  icebreaker_included: options?.trustSignals?.includes("icebreaker"),
62
+ self_included: options?.trustSignals?.includes("self"),
62
63
  });
63
64
  return profile;
64
65
  }
@@ -219,6 +220,41 @@ class ValironClient {
219
220
  async getWorldIdProfile(agentId, options) {
220
221
  return this.get(`/operator/world-id/profile/${agentId}`, this.resolveChain(options));
221
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
+ }
222
258
  /** Flush any pending telemetry events and clean up resources. */
223
259
  async dispose() {
224
260
  await this.telemetry.dispose();
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
  *
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
  *
@@ -23,7 +23,7 @@ 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+icebreaker. */
26
+ /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+self+icebreaker. */
27
27
  trustSignals?: TrustSignal[];
28
28
  /**
29
29
  * Client-side profile cache TTL in ms.
@@ -91,7 +91,7 @@ export interface ValironFastifyConfig {
91
91
  extractAgentAddress?: (req: any) => string | null;
92
92
  /** Minimum Valiron score to allow (default: 65). */
93
93
  minScore?: number;
94
- /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+icebreaker. */
94
+ /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+self+icebreaker. */
95
95
  trustSignals?: TrustSignal[];
96
96
  /**
97
97
  * Client-side profile cache TTL in ms (default: 30000).
@@ -154,7 +154,7 @@ export interface ValironNextConfig {
154
154
  extractAgentAddress?: (req: Request) => string | null;
155
155
  /** Minimum Valiron score to allow (default: 65). */
156
156
  minScore?: number;
157
- /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+icebreaker. */
157
+ /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+self+icebreaker. */
158
158
  trustSignals?: TrustSignal[];
159
159
  /**
160
160
  * Client-side profile cache TTL in ms (default: 30000).
@@ -270,7 +270,7 @@ export declare function valironGateCheck(sdk: ValironSDK, opts: {
270
270
  /** Key-based agent hash (web2). Checked if agentId is not provided. */
271
271
  agentAddress?: string | null;
272
272
  minScore?: number;
273
- /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+icebreaker. */
273
+ /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+self+icebreaker. */
274
274
  trustSignals?: TrustSignal[];
275
275
  /**
276
276
  * Client-side profile cache TTL in ms (default: 30000).
@@ -176,6 +176,7 @@ function emitGateTelemetry(sdk, payload) {
176
176
  trust_signal_count: signals?.length,
177
177
  world_included: signals?.includes("world"),
178
178
  icebreaker_included: signals?.includes("icebreaker"),
179
+ self_included: signals?.includes("self"),
179
180
  status: payload.status || "ok",
180
181
  latency_ms: payload.latencyMs,
181
182
  });
@@ -23,7 +23,7 @@ export interface PaywallConfig {
23
23
  pricePerCall: number;
24
24
  /** Minimum trust score to allow (default: 45). */
25
25
  minTrustScore?: number;
26
- /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+icebreaker. */
26
+ /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+self+icebreaker. */
27
27
  trustSignals?: TrustSignal[];
28
28
  /**
29
29
  * Server-side gate result TTL in ms (default: 86400000 = 24h).
@@ -65,6 +65,7 @@ class ValironOperator {
65
65
  sandbox_included: trustSignals.includes("sandbox"),
66
66
  world_included: trustSignals.includes("world"),
67
67
  icebreaker_included: trustSignals.includes("icebreaker"),
68
+ self_included: trustSignals.includes("self"),
68
69
  };
69
70
  void fetch(this.buildAnalyticsUrl(), {
70
71
  method: "POST",
package/dist/types.d.ts CHANGED
@@ -9,7 +9,7 @@ export type SupportedChain = "ethereum" | "monad" | "arbitrum" | "base" | "avala
9
9
  export type RouteDecision = "prod" | "prod_throttled" | "sandbox" | "sandbox_only";
10
10
  export type RiskLevel = "GREEN" | "YELLOW" | "RED";
11
11
  export type MoodysRating = "AAA" | "AA" | "A" | "BAA" | "BA" | "B" | "CAA" | "CA" | "C";
12
- export type TrustSignal = "8004" | "sandbox" | "world" | "icebreaker";
12
+ export type TrustSignal = "8004" | "sandbox" | "world" | "icebreaker" | "self";
13
13
  export interface AgentIdentity {
14
14
  agentId: string;
15
15
  wallet: string;
@@ -193,7 +193,7 @@ export interface GateOptions {
193
193
  minScore?: number;
194
194
  /** TTL in ms for cached sandbox results. Stale results trigger re-testing (default: 86400000 = 24 h). */
195
195
  ttlMs?: number;
196
- /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+icebreaker. */
196
+ /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+self+icebreaker. */
197
197
  trustSignals?: TrustSignal[];
198
198
  /** Override the blockchain network for this call. */
199
199
  chain?: SupportedChain;
@@ -328,6 +328,98 @@ export interface WorldIdAgentProfile {
328
328
  reasons: string[];
329
329
  timestamp: string;
330
330
  }
331
+ export interface SelfProofPayload {
332
+ /** Self nullifier hash, unique to the configured disclosure/action scope */
333
+ nullifier_hash: string;
334
+ /** Optional Self verification/session identifier */
335
+ verification_id?: string;
336
+ /** Selective disclosure predicates returned by Self */
337
+ credential_subject?: Record<string, unknown>;
338
+ /** Minimum age proven by Self, when requested */
339
+ minimum_age?: number;
340
+ /** Whether Self returned an OFAC-clear predicate */
341
+ ofac_clear?: boolean;
342
+ /** Whether Self returned a country/nationality eligibility predicate */
343
+ country_allowed?: boolean;
344
+ /** Self Agent ID, when present */
345
+ self_agent_id?: string;
346
+ /** Registry or contract address/source used for the Self Agent ID */
347
+ self_agent_registry?: string;
348
+ /** Whether the Self Agent ID is bound to this human/agent pair */
349
+ self_agent_linked?: boolean;
350
+ }
351
+ export interface SelfSessionRequest {
352
+ /** Optional Self Agent ID to bind to this verified human */
353
+ selfAgentId?: string;
354
+ /** Optional registry or source for the Self Agent ID */
355
+ selfAgentRegistry?: string;
356
+ /** Extra metadata stored on the Self session */
357
+ metadata?: Record<string, unknown>;
358
+ /** Redirect URL after successful Self verification */
359
+ successUrl?: string;
360
+ /** Redirect URL after failed/cancelled Self verification */
361
+ failureUrl?: string;
362
+ /** Session TTL in seconds */
363
+ expiresInSeconds?: number;
364
+ }
365
+ export interface SelfSessionResponse {
366
+ ok: boolean;
367
+ agentId: string;
368
+ self: {
369
+ sessionId: string;
370
+ externalUuid: string;
371
+ verificationUrl: string;
372
+ status: "pending";
373
+ expiresAt: string;
374
+ };
375
+ timestamp: string;
376
+ }
377
+ export interface SelfStatus {
378
+ /** Whether the agent has a verified Self human eligibility link */
379
+ verified: boolean;
380
+ /** Nullifier hash from Self, unique to the configured disclosure/action scope */
381
+ nullifierHash?: string;
382
+ /** Optional Self verification/session identifier */
383
+ verificationId?: string;
384
+ /** The agent ID this verification is linked to */
385
+ agentId?: string;
386
+ /** Network this verification is scoped to */
387
+ network?: string;
388
+ /** Selective disclosure predicates returned by Self */
389
+ credentialSubject?: Record<string, unknown>;
390
+ /** Minimum age proven by Self, when requested */
391
+ minimumAge?: number;
392
+ /** Whether Self returned an OFAC-clear predicate */
393
+ ofacClear?: boolean;
394
+ /** Whether Self returned a country/nationality eligibility predicate */
395
+ countryAllowed?: boolean;
396
+ /** Self Agent ID, when the agent is linked through Self's Agent ID product */
397
+ selfAgentId?: string;
398
+ /** Registry or contract address/source used for the Self Agent ID */
399
+ selfAgentRegistry?: string;
400
+ /** Whether Self Agent ID confirms this agent is linked to the verified human */
401
+ selfAgentLinked?: boolean;
402
+ /** ISO 8601 timestamp of when verification occurred */
403
+ verifiedAt?: string;
404
+ }
405
+ export interface SelfAgentProfile {
406
+ agentId: string;
407
+ /** Self eligible-human and Agent ID status */
408
+ self: SelfStatus;
409
+ /** On-chain identity summary */
410
+ identity: {
411
+ wallet: string;
412
+ name: string;
413
+ } | null;
414
+ /** Aggregated Self human trust signals */
415
+ humanTrust: {
416
+ hasHumanLink: boolean;
417
+ hasEligibleHuman: boolean;
418
+ hasAgentBinding: boolean;
419
+ };
420
+ reasons: string[];
421
+ timestamp: string;
422
+ }
331
423
  /**
332
424
  * Icebreaker ownership attestation linked to an agent key hash.
333
425
  */