@valiron/sdk 1.2.1 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,9 +4,10 @@
4
4
 
5
5
  ## Prerequisites
6
6
 
7
- 1. **Create an account** on the [Operator Dashboard](./DASHBOARD.md) at [valiron.co/dashboard](https://www.valiron.co/dashboard)
8
- 2. **Copy your API key** from the Keys page
9
- 3. Add the SDK middleware below to the backend routes agents call.
7
+ 1. **Create an account** with email/password, Google, or GitHub on the [Operator Dashboard](./DASHBOARD.md) at [valiron.co/dashboard](https://www.valiron.co/dashboard)
8
+ 2. **Complete the guided setup** — every sign-up method enters the same resumable onboarding flow
9
+ 3. **Copy your API key** when it is shown; returning incomplete accounts can generate a dedicated setup key
10
+ 4. Add the SDK middleware below to the backend routes agents call. Choose registered, key-based, or ANS/provider-backed identity in the wizard.
10
11
 
11
12
  > **Tip:** Before writing any code, try the [API Playground](./DASHBOARD.md#api-playground) to see how Valiron evaluates agents at different trust levels against your endpoints.
12
13
 
@@ -45,9 +46,16 @@ First identify which kind of agent is calling your API:
45
46
  |------------|--------|--------------|
46
47
  | ERC-8004 / Solana agent | `x-agent-id` | `getAgentProfile()` / `/operator/agent/:agentId` |
47
48
  | Local, Web2, or non-ERC-8004 agent | `x-agent-address` | `getKeyAgentProfile()` / `/operator/key/:agentAddress` |
49
+ | Provider-backed identity (ANS and future adapters) | `x-valiron-identity-*` proof headers | `createValironIdentityGate()` / `verifyAgentIdentity()` |
48
50
 
49
51
  Do not pass a local agent name such as `my-agent` to `/operator/agent/:agentId`. That endpoint expects an on-chain ERC-8004 token ID or Solana agent identifier. Non-ERC-8004 agents should use the key-based identity flow from [auth.md](https://www.valiron.co/auth.md).
50
52
 
53
+ For a provider-backed identity, use `createAgentIdentityProof()` in the agent
54
+ runtime and `createValironIdentityGate()` in the API. The receiving gate hashes
55
+ the exact request body, verifies the signature through Valiron, prevents replay,
56
+ and enforces `allow`, `limit`, `challenge`, or `block`. See
57
+ [Provider-Backed Agent Identity](./PROVIDER-IDENTITY.md).
58
+
51
59
  For an on-chain agent, check their trust route:
52
60
 
53
61
  ```typescript
package/docs/README.md CHANGED
@@ -22,6 +22,7 @@ Valiron also provides **API Scaffolding** as a separate product for organization
22
22
  | [SDK-REFERENCE.md](./SDK-REFERENCE.md) | TypeScript SDK methods, signatures, and usage examples |
23
23
  | [TRUST-MODEL.md](./TRUST-MODEL.md) | How agents are scored, what behaviors are penalized, tier assignments |
24
24
  | [IDENTITY.md](./IDENTITY.md) | Agent identity — ERC-8004/Solana agents and key-based Web2 agents |
25
+ | [PROVIDER-IDENTITY.md](./PROVIDER-IDENTITY.md) | Provider-backed identity — SDK signing helpers and gates, normalized proofs, replay protection, policies, and ANS |
25
26
  | [SANDBOX.md](./SANDBOX.md) | How the sandbox evaluates agents and determines production readiness |
26
27
  | [CHAINS.md](./CHAINS.md) | Supported blockchain networks and contract addresses |
27
28
  | [ERRORS.md](./ERRORS.md) | Error codes, troubleshooting, and retry guidance |
@@ -30,6 +31,7 @@ Valiron also provides **API Scaffolding** as a separate product for organization
30
31
 
31
32
  - **Agent ID**: An agent's ERC-8004 token ID (EVM) or Metaplex Core asset pubkey (Solana) — their on-chain identity. Use this with `x-agent-id` and `/operator/agent/:agentId`.
32
33
  - **Key-Based Agent Address**: A persistent Ethereum-style address for a local, Web2, or non-ERC-8004 agent. Use this with `x-agent-address` and `/operator/key/:agentAddress`.
34
+ - **Provider-Backed Identity**: An ANS or future provider identity verified through `ValironSDK.verifyAgentIdentity()`. SDK 1.3 includes signing helpers and dedicated Express, Fastify, Next.js, and generic identity gates. Valiron hosts the ANS credentials and CA configuration.
33
35
  - **Sequential ID** (Solana only): A convenience integer (1, 2, 42…) assigned by the QuantuLabs indexer. Maps to an asset pubkey.
34
36
  - **Trust Tier**: AAA (highest trust) → C (lowest trust). Assigned based on behavioral evaluation.
35
37
  - **Risk Level**: GREEN, YELLOW, or RED.
@@ -47,9 +49,15 @@ Valiron also provides **API Scaffolding** as a separate product for organization
47
49
  | ERC-8004 / on-chain EVM agent | ERC-8004 token ID | `x-agent-id` | `/operator/agent/:agentId` |
48
50
  | Solana 8004 agent | Metaplex Core asset pubkey or indexed ID | `x-agent-id` | `/operator/agent/:agentId?chain=solana` |
49
51
  | Local, Web2, or non-ERC-8004 agent | Persistent Ethereum-style agent address | `x-agent-address` | `/operator/key/:agentAddress` |
52
+ | ANS, DNS, DID, API-key, or future provider identity | Provider-canonical agent ID | `x-valiron-identity-*` proof headers | SDK identity gate or `/operator/identity/verify` |
50
53
 
51
54
  Do not send a local agent name such as `my-agent` to `/operator/agent/:agentId`. That endpoint is for registry-backed on-chain agents. Local and Web2 agents should generate or reuse a persistent keypair, prove ownership through Valiron's challenge-response flow, and then use their `x-agent-address` for trust checks.
52
55
 
56
+ Provider identity gates calculate the digest from the API's exact raw request
57
+ bytes and never trust a caller-supplied digest header. ANS credentials and the
58
+ trusted CA bundle live in Valiron's hosted service, not customer applications. See
59
+ [Provider-Backed Agent Identity](./PROVIDER-IDENTITY.md).
60
+
53
61
  ## Supported Registries
54
62
 
55
63
  | Network | Provider | Identity | Reputation |
@@ -372,6 +372,31 @@ console.log(snapshot.interactionCount); // 15
372
372
 
373
373
  ---
374
374
 
375
+ ### verifyAgentIdentity(proof, policy?)
376
+
377
+ Verifies an ANS or other provider-backed identity, loads Valiron reputation,
378
+ and returns the requested policy decision.
379
+
380
+ ```typescript
381
+ const identity = await valiron.verifyAgentIdentity(proof, {
382
+ anonymous: "challenge",
383
+ claimed: "block",
384
+ verified: "allow",
385
+ minReputationScore: 65,
386
+ belowMinimumScore: "limit",
387
+ highRisk: "block",
388
+ });
389
+ ```
390
+
391
+ For protected API routes, prefer the provider identity middleware below. It
392
+ calculates `requestDigest` from the exact received bytes. Direct callers are
393
+ responsible for binding the proof and decision to those same bytes.
394
+
395
+ See [Provider-Backed Agent Identity](./PROVIDER-IDENTITY.md) for proof and result
396
+ types, signing helpers, identity statuses, and policy semantics.
397
+
398
+ ---
399
+
375
400
  ### createValironGate(config)
376
401
 
377
402
  Express-compatible middleware factory. Automatically gates requests based on agent trust.
@@ -629,13 +654,16 @@ Trusted-payload ingestion for local/internal tests only. Production integrations
629
654
 
630
655
  The SDK collects opt-out usage telemetry to improve reliability. Events include SDK version, runtime, environment, method names, chain labels, latency, HTTP status/error buckets, route decisions, and coarse score/reputation buckets. Raw agent IDs, wallet addresses, API keys, and exact scores are not sent in SDK telemetry. Operator paywall usage logs are separate customer analytics and are authenticated with the operator API key.
631
656
 
657
+ SDK reports are anonymous client reports and may be sampled. Signal counts describe reported selections, not successful verifications. Version comes from the shipped package metadata. Environment defaults to recognized `NODE_ENV` values (`production` → `prod`, `development` → `dev`, `test` → `test`), otherwise `unknown`; set it explicitly for browser applications. Telemetry observer failures do not affect API calls. Server statistics identify persisted counters versus counters limited to one process, and latency percentiles cover the latest 1,000 reported calls per method, chain, and version.
658
+
632
659
  ### TelemetryConfig
633
660
 
634
661
  | Field | Type | Default | Description |
635
662
  |-------|------|---------|-------------|
636
663
  | `enabled` | boolean | `true` | Enable/disable telemetry |
637
664
  | `sampleRate` | number | `1.0` | Fraction of events to sample (0–1) |
638
- | `onEvent` | function | — | Custom event handler |
665
+ | `env` | prod / staging / dev / test / unknown | NODE_ENV or unknown | Environment label |
666
+ | `onEvent` | function | — | Custom event handler; failures are isolated from API calls |
639
667
 
640
668
  **Example**:
641
669
  ```typescript
@@ -717,6 +745,47 @@ app.use(async (c, next) => {
717
745
  });
718
746
  ```
719
747
 
748
+ ### Provider identity middleware — ANS and future adapters
749
+
750
+ Provider identity uses dedicated, non-caching gates because every request has
751
+ a fresh timestamp and nonce:
752
+
753
+ ```typescript
754
+ import {
755
+ createValironIdentityGate,
756
+ valironIdentityFastifyPlugin,
757
+ createValironIdentityNextMiddleware,
758
+ valironIdentityGateCheck,
759
+ } from "@valiron/sdk";
760
+ ```
761
+
762
+ `createValironIdentityGate({ sdk, policy, getRawBody? })` protects Express and
763
+ Connect routes. `valironIdentityFastifyPlugin` provides the equivalent Fastify
764
+ `preHandler`; `createValironIdentityNextMiddleware` hashes a cloned Fetch
765
+ request; and `valironIdentityGateCheck` accepts explicit proof fields and exact
766
+ body bytes for Hono, Koa, Bun, and custom runtimes.
767
+
768
+ The default transport uses `x-valiron-identity-provider`,
769
+ `x-valiron-identity-agent-id`, `x-valiron-identity-signature`,
770
+ `x-valiron-identity-timestamp`, `x-valiron-identity-nonce`, and optional
771
+ `x-valiron-identity-key-id`. The request digest is never accepted from a header;
772
+ the gate calculates it locally. See
773
+ [Provider-Backed Agent Identity](./PROVIDER-IDENTITY.md#api-owner-enforce-an-identity-policy)
774
+ for complete Express and agent examples.
775
+
776
+ Policy actions map to HTTP status as follows:
777
+
778
+ | Action | Middleware behavior |
779
+ | --- | --- |
780
+ | `allow` | Continue and attach `valironIdentity` to the request |
781
+ | `challenge` | HTTP 401 with `WWW-Authenticate: ValironIdentity` |
782
+ | `block` | HTTP 403 |
783
+ | `limit` | HTTP 429 with `Retry-After: 60` |
784
+
785
+ Unexpected verification failures return 503 and fail closed. Express and
786
+ Fastify return `IDENTITY_RAW_BODY_REQUIRED` with HTTP 400 when a body was parsed
787
+ without preserving its exact bytes.
788
+
720
789
  ### Client-Side Caching
721
790
 
722
791
  All middleware adapters include a built-in in-memory cache (default TTL: 30 seconds).
@@ -821,6 +890,14 @@ import {
821
890
  valironFastifyPlugin,
822
891
  createValironNextMiddleware,
823
892
  valironGateCheck,
893
+ createValironIdentityGate,
894
+ valironIdentityFastifyPlugin,
895
+ createValironIdentityNextMiddleware,
896
+ valironIdentityGateCheck,
897
+ createAgentIdentityProof,
898
+ agentIdentityProofHeaders,
899
+ sha256RequestDigest,
900
+ buildAgentIdentitySigningPayload,
824
901
  isValidAddress,
825
902
  generateChallenge,
826
903
  type WalletRiskSnapshot,
@@ -2,6 +2,26 @@
2
2
 
3
3
  Valiron uses a hybrid trust model to evaluate AI agents hitting your API. This document explains what behaviors are evaluated and what each trust tier means for your routing decisions.
4
4
 
5
+ ## Identity proof is not reputation
6
+
7
+ Provider-backed identity separates who controls an agent identity
8
+ from how that agent should be treated. `anonymous`, `claimed`, and `verified`
9
+ describe identity evidence only. `verified` remains pseudonymous and does not
10
+ mean that Valiron identified a human or that the agent has good behavioral
11
+ history.
12
+
13
+ After identity verification, Valiron looks up reputation using the stable
14
+ provider-canonical subject. For ANS this is `agentHost`, not the versioned ANS
15
+ name or registration UUID. The verification endpoint can then return a policy
16
+ action of `allow`, `limit`, `challenge`, or `block`. An identity with no observed
17
+ reputation returns an unknown risk level rather than being inferred as risky.
18
+
19
+ ANS trust-index and lifecycle evidence remain external provider evidence; they
20
+ are not relabeled as Valiron-observed reputation. SDK 1.3 exposes dedicated
21
+ provider identity gates using `x-valiron-identity-*` proof headers. The ANS
22
+ resolver and provider credentials remain inside Valiron's hosted service. See
23
+ [Provider-Backed Agent Identity](./PROVIDER-IDENTITY.md).
24
+
5
25
  ## Trust Tiers
6
26
 
7
27
  Valiron assigns a Moody's-style credit tier from a normalized `0-100` trust score:
package/docs/llms.txt CHANGED
@@ -10,6 +10,8 @@ On-chain agents use x-agent-id and GET /operator/agent/{agentId}. The agentId is
10
10
 
11
11
  Local, Web2, and non-ERC-8004 agents use x-agent-address plus challenge-response auth. Do not send a local agent name to /operator/agent/{agentId}. Generate or reuse a persistent Ethereum-style keypair, request POST /operator/key/{agentAddress}/challenge, sign the challenge, verify with POST /operator/key/verify, then use x-agent-address and x-agent-session on gated requests. Agents can follow https://www.valiron.co/auth.md.
12
12
 
13
+ Provider-backed identity uses SDK 1.3 signing helpers and x-valiron-identity-* proof headers. Agents call createAgentIdentityProof() and agentIdentityProofHeaders(); API owners use createValironIdentityGate(), valironIdentityFastifyPlugin, createValironIdentityNextMiddleware, or valironIdentityGateCheck. The headers are untrusted proof inputs until the gate hashes exact request bytes, calls verifyAgentIdentity(), prevents replay, and enforces allow|limit|challenge|block. Valiron hosts ANS credentials and CA trust; customers do not configure them. See https://www.valiron.co/docs/agents/PROVIDER-IDENTITY.md.
14
+
13
15
  ## API
14
16
 
15
17
  Base URL: https://valiron-edge-proxy.onrender.com
@@ -45,6 +47,11 @@ POST /operator/key/verify
45
47
  ### Key-based agent profile
46
48
  GET /operator/key/{agentAddress}
47
49
 
50
+ ### Provider-backed identity proof
51
+ POST /operator/identity/verify
52
+ Body: { provider, agentId, signature, timestamp, nonce, requestDigest, keyId?, policy? }
53
+ Returns: { agentId, provider, organization, identityStatus, humanIdentified, stableIdentityId, credentialId?, credentialVersion?, externalTrust?, verifiedAt, failureReason?, reputationScore, riskLevel, policyDecision }
54
+
48
55
  ### Trust gate (allow/deny)
49
56
  POST /operator/gate/{agentId}
50
57
  Body: { "ttlMs": 86400000 }
@@ -67,7 +74,7 @@ GET /operator/health
67
74
  Install: npm install @valiron/sdk
68
75
 
69
76
  ```typescript
70
- import { ValironSDK } from "@valiron/sdk";
77
+ import { ValironSDK, createValironIdentityGate } from "@valiron/sdk";
71
78
  const valiron = new ValironSDK({ chain: "ethereum" });
72
79
 
73
80
  // Quick routing check
@@ -96,6 +103,12 @@ console.log(snapshot.previousHash); // "0x0" (genesis)
96
103
  // Sandbox evaluation for key-based agent
97
104
  const keyResult = await valiron.triggerKeyAgentSandbox("0x1234...abcd");
98
105
  console.log(keyResult.tier); // "A"
106
+
107
+ // Provider identity: low-level verification
108
+ const identity = await valiron.verifyAgentIdentity(proof, { claimed: "block" });
109
+
110
+ // Provider identity: route enforcement
111
+ app.post("/api/quote", createValironIdentityGate({ sdk: valiron }), handler);
99
112
  ```
100
113
 
101
114
  Auto-sandbox: Middleware automatically triggers sandbox evaluation for new agents (on-chain with totalFeedback=0, or key-based with no score). Returns 403 with { error: "Agent pending evaluation", retryAfterMs: 30000 }.
@@ -108,7 +121,7 @@ GET/POST/etc /wrap/{operatorId}/{path}
108
121
 
109
122
  Wrapper config fields: path, method, targetUrl (upstream API base URL), pricePerCall, paymentProtocol ("x402" or "mpp"), paymentNetwork ("eip155:8453", "eip155:84532", "tempo:4217", or "tempo:42431"), payoutAddress, trustEnabled, rateLimit, upstreamAuthType, upstreamAuthHeader, upstreamAuthSecret.
110
123
 
111
- Free wrappers (pricePerCall=0) forward directly to targetUrl. x402 paid wrappers return 402 with x402 payment challenge and require retry with X-PAYMENT. MPP paid wrappers return 402 with WWW-Authenticate: Payment and require retry with Authorization: Payment. Trust-enabled wrappers require x-agent-id and deny untrusted agents before forwarding. Use SDK middleware in your own backend when you need to support x-agent-address.
124
+ Free wrappers (pricePerCall=0) forward directly to targetUrl. x402 paid wrappers return 402 with x402 payment challenge and require retry with X-PAYMENT. MPP paid wrappers return 402 with WWW-Authenticate: Payment and require retry with Authorization: Payment. Trust-enabled wrappers require x-agent-id and deny untrusted agents before forwarding. Use SDK middleware in your own backend when you need to support x-agent-address. Wrapper controls and analytics apply only to traffic sent to `/wrap/{operatorId}/{path}`: publish that URL to agents and protect any public origin with HMAC upstream auth, rejecting direct unsigned requests. Do not treat `x-valiron-*` metadata headers as credentials.
112
125
 
113
126
  ## Operator SDK (ValironOperator)
114
127
 
@@ -228,7 +241,7 @@ New key agents are automatically sandbox-evaluated on first gated request. Middl
228
241
 
229
242
  ## Telemetry
230
243
 
231
- Opt-in anonymous usage metrics. Disable with `telemetry: { enabled: false }`. Supports custom sampleRate (0–1) and custom handler function.
244
+ Opt-out anonymous client usage reports. Disable with `telemetry: { enabled: false }`. Supports custom sampleRate (0–1) and custom handler function. Environment defaults to recognized NODE_ENV values, otherwise unknown. Signal selections do not measure successful verifications.
232
245
 
233
246
  ## Middleware Error Responses
234
247
 
@@ -256,6 +269,7 @@ All middleware returns actionable JSON. Use the stable `code` for program logic
256
269
  - docs/agents/SDK-REFERENCE.md — TypeScript SDK reference
257
270
  - docs/agents/TRUST-MODEL.md — Trust evaluation and behavioral factors
258
271
  - docs/agents/IDENTITY.md — ERC-8004 identity and reputation
272
+ - docs/agents/PROVIDER-IDENTITY.md — Provider-independent identity proof, replay protection, policy actions, and ANS adapter status
259
273
  - docs/agents/SANDBOX.md — Sandbox testing environment
260
274
  - docs/agents/CHAINS.md — Supported blockchains
261
275
  - docs/agents/ERRORS.md — Error handling and troubleshooting
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valiron/sdk",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "description": "Official TypeScript SDK for Valiron — Trust & Reputation Middleware for API Protection",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  "clean": "node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true});\"",
21
21
  "build": "pnpm clean && tsc",
22
22
  "dev": "tsc --watch",
23
- "test": "node test/validate.mjs && node test/validate-examples.mjs && tsx test/test-identity.ts",
23
+ "test": "node test/validate-telemetry.mjs && node test/validate.mjs && node test/validate-examples.mjs && node test/validate-middleware.mjs && node test/validate-provider-identity.mjs && node --import tsx test/test-identity.ts",
24
24
  "prepublishOnly": "pnpm build"
25
25
  },
26
26
  "keywords": [