@valiron/sdk 1.2.1 → 1.3.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/dist/types.d.ts CHANGED
@@ -11,6 +11,50 @@ export type RiskLevel = "GREEN" | "YELLOW" | "RED";
11
11
  export type MoodysRating = "AAA" | "AA" | "A" | "BAA" | "BA" | "B" | "CAA" | "CA" | "C";
12
12
  export type TrustSignal = "8004" | "sandbox" | "world" | "icebreaker" | "self" | "wallet";
13
13
  export type WalletRiskLevel = "LOW" | "MEDIUM" | "HIGH" | "CRITICAL";
14
+ export type AgentIdentityStatus = "anonymous" | "claimed" | "verified";
15
+ export type AgentIdentityPolicyAction = "allow" | "limit" | "challenge" | "block";
16
+ /** Proof submitted to Valiron's provider-independent identity verifier. */
17
+ export interface AgentIdentityProof {
18
+ provider?: string;
19
+ agentId?: string;
20
+ signature?: string;
21
+ timestamp?: string;
22
+ nonce?: string;
23
+ requestDigest?: string;
24
+ keyId?: string;
25
+ }
26
+ /** Proof fields transported with an HTTP request. The receiving gate computes requestDigest itself. */
27
+ export type AgentIdentityTransportProof = Omit<AgentIdentityProof, "requestDigest">;
28
+ export interface AgentIdentityPolicy {
29
+ anonymous?: AgentIdentityPolicyAction;
30
+ claimed?: AgentIdentityPolicyAction;
31
+ verified?: AgentIdentityPolicyAction;
32
+ belowMinimumScore?: AgentIdentityPolicyAction;
33
+ minReputationScore?: number;
34
+ mediumRisk?: AgentIdentityPolicyAction;
35
+ highRisk?: AgentIdentityPolicyAction;
36
+ }
37
+ export interface AgentIdentityPolicyDecision {
38
+ action: AgentIdentityPolicyAction;
39
+ reason: string;
40
+ }
41
+ /** Normalized provider identity, Valiron reputation, and the caller-selected policy decision. */
42
+ export interface AgentIdentityVerificationResult {
43
+ agentId: string | null;
44
+ provider: string | null;
45
+ organization: string | null;
46
+ identityStatus: AgentIdentityStatus;
47
+ humanIdentified: false;
48
+ stableIdentityId: string | null;
49
+ credentialId?: string;
50
+ credentialVersion?: string;
51
+ externalTrust?: Record<string, unknown>;
52
+ verifiedAt: string | null;
53
+ failureReason?: string;
54
+ reputationScore: number | null;
55
+ riskLevel: "low" | "medium" | "high" | "unknown";
56
+ policyDecision: AgentIdentityPolicyDecision;
57
+ }
14
58
  export interface AgentIdentity {
15
59
  agentId: string;
16
60
  wallet: string;
@@ -13,6 +13,13 @@ Agent or client
13
13
  -> response returned through Valiron
14
14
  ```
15
15
 
16
+ > **Important: protect the origin.** A hosted wrapper evaluates and logs only
17
+ > requests sent to its Valiron URL. It is not a network firewall in front of a
18
+ > separately public API origin. If callers can reach your origin directly, they
19
+ > can bypass the wrapper's payment, trust, rate-limit, and analytics path.
20
+ > Publish the generated wrapper URL as the agent-facing URL and configure your
21
+ > origin to accept only authenticated requests from Valiron.
22
+
16
23
  The wrapper is intentionally narrow: Valiron forwards valid HTTP requests to an existing upstream API. It does not need direct database access, internal service access, or provider infrastructure credentials beyond the optional upstream auth secret needed to call the API.
17
24
 
18
25
  ## When To Use This
@@ -43,7 +50,7 @@ Providers configure one wrapper per public endpoint.
43
50
  | Payment protocol | Yes | `x402` or `MPP`. |
44
51
  | Payment network | Yes | x402: `eip155:8453` or `eip155:84532`; MPP: `tempo:4217` or `tempo:42431`. |
45
52
  | Payout wallet | Paid only | EVM address receiving payment. |
46
- | Upstream auth | No | Secret Valiron injects when forwarding to your upstream. |
53
+ | Upstream auth | Required to prevent origin bypass | Auth Valiron adds when forwarding to your upstream. Use `hmac` for a public origin. |
47
54
  | Rate limit | No | Max requests per minute per client. |
48
55
  | Trust check | No | Whether callers must pass Valiron agent trust evaluation before forwarding. |
49
56
 
@@ -72,9 +79,12 @@ https://api.example.com/v1/weather
72
79
  3. Click **Make API Agent-Ready**.
73
80
  4. Enter the upstream URL, public path, method, price, protocol, network, and payout wallet.
74
81
  5. Choose whether Valiron trust checks are required.
75
- 6. Configure upstream auth only if your API needs it.
82
+ 6. Configure upstream authentication. For a public origin, choose `hmac` and
83
+ store the same secret in your origin's verification middleware.
76
84
  7. Create the wrapper.
77
- 8. Distribute the generated Valiron URL to agent clients or API customers.
85
+ 8. Distribute only the generated Valiron URL to agent clients or API customers.
86
+ 9. Verify that a direct request to your origin is rejected and a request to the
87
+ wrapper is recorded in Valiron call logs.
78
88
 
79
89
  ## HTTP API Flow
80
90
 
@@ -117,7 +127,8 @@ curl -X POST https://valiron-edge-proxy.onrender.com/operator/endpoints \
117
127
  "paymentProtocol": "x402",
118
128
  "paymentNetwork": "eip155:8453",
119
129
  "trustEnabled": false,
120
- "upstreamAuthType": "none"
130
+ "upstreamAuthType": "hmac",
131
+ "upstreamAuthSecret": "replace-with-a-unique-shared-secret"
121
132
  }'
122
133
  ```
123
134
 
@@ -136,7 +147,8 @@ curl -X POST https://valiron-edge-proxy.onrender.com/operator/endpoints \
136
147
  "paymentNetwork": "eip155:8453",
137
148
  "payoutAddress": "0xYourPayoutWallet",
138
149
  "trustEnabled": false,
139
- "upstreamAuthType": "none"
150
+ "upstreamAuthType": "hmac",
151
+ "upstreamAuthSecret": "replace-with-a-unique-shared-secret"
140
152
  }'
141
153
  ```
142
154
 
@@ -155,7 +167,8 @@ curl -X POST https://valiron-edge-proxy.onrender.com/operator/endpoints \
155
167
  "paymentNetwork": "tempo:4217",
156
168
  "payoutAddress": "0xYourPayoutWallet",
157
169
  "trustEnabled": false,
158
- "upstreamAuthType": "none"
170
+ "upstreamAuthType": "hmac",
171
+ "upstreamAuthSecret": "replace-with-a-unique-shared-secret"
159
172
  }'
160
173
  ```
161
174
 
@@ -299,7 +312,15 @@ Use payment-only wrappers when:
299
312
 
300
313
  ## Upstream Auth
301
314
 
302
- If your existing API requires auth, Valiron stores the secret encrypted and injects it only when forwarding a valid request upstream.
315
+ Valiron stores the configured secret encrypted and injects or derives it only
316
+ when forwarding a request that has reached the wrapper. This is how your origin
317
+ distinguishes an authenticated wrapper request from a direct public request.
318
+
319
+ For a public API origin, configure upstream authentication before announcing or
320
+ indexing the wrapper. Otherwise, a caller can send traffic directly to the
321
+ origin and bypass Valiron entirely. `none` is appropriate only when the origin
322
+ is already inaccessible to untrusted callers or bypass is intentionally
323
+ acceptable.
303
324
 
304
325
  Supported auth modes:
305
326
 
@@ -312,6 +333,40 @@ Supported auth modes:
312
333
 
313
334
  The calling agent never sees your upstream secret.
314
335
 
336
+ ### Recommended production pattern: HMAC origin verification
337
+
338
+ Choose `hmac` for an origin that is publicly reachable. Valiron sends:
339
+
340
+ ```text
341
+ x-valiron-signature: sha256=<hex HMAC>
342
+ x-valiron-timestamp: <Unix seconds>
343
+ ```
344
+
345
+ Your origin must reject requests when the signature is missing, invalid, or too
346
+ old. Verify the signature against the request method, public wrapper path, raw
347
+ body SHA-256, and timestamp with the shared secret configured on the wrapper.
348
+ Use constant-time signature comparison and a short timestamp window to reduce
349
+ replay risk.
350
+
351
+ Do **not** treat headers such as `x-valiron-wrapper-id`,
352
+ `x-valiron-payment-protocol`, or `x-valiron-trust-enabled` as proof that a
353
+ request came through Valiron. They are request metadata, not a credential, and
354
+ can be forged by a caller that reaches your origin directly.
355
+
356
+ ### Origin-lockdown checklist
357
+
358
+ Before production:
359
+
360
+ 1. Set `upstreamAuthType` to `hmac` and configure a unique secret.
361
+ 2. Deploy origin middleware that verifies the HMAC and timestamp before the API
362
+ handler runs.
363
+ 3. Make the Valiron `/wrap/{operatorId}/{path}` URL the only public URL in
364
+ agent discovery metadata, examples, and client configuration.
365
+ 4. Send a direct request to the origin without the signature and confirm a
366
+ `401` or `403` response.
367
+ 5. Send a request through the wrapper and confirm the expected payment/trust
368
+ result and a corresponding Valiron call-log entry.
369
+
315
370
  Production requires `VALIRON_SECRET_ENCRYPTION_KEY` to store upstream auth secrets. Use a 32-byte hex key:
316
371
 
317
372
  ```bash
@@ -12,6 +12,120 @@ Endpoints are organized into three groups:
12
12
 
13
13
  ## Trust Evaluation Endpoints
14
14
 
15
+ ### POST /operator/identity/verify
16
+
17
+ Normalize and verify a provider-backed agent identity proof. This endpoint is
18
+ provider-independent. SDK 1.3 exposes it as `verifyAgentIdentity()` and provides
19
+ dedicated middleware for `x-valiron-identity-*` proof headers. The ANS adapter
20
+ and provider credentials run inside Valiron's hosted service.
21
+
22
+ An empty body returns `identityStatus: "anonymous"`. Supplying an agent ID with
23
+ an incomplete or failed proof returns HTTP 200 with `identityStatus: "claimed"`
24
+ and a machine-readable `failureReason`. Only a validated authority binding,
25
+ fresh signature, and unused nonce return `identityStatus: "verified"`.
26
+
27
+ #### Request body
28
+
29
+ ```json
30
+ {
31
+ "provider": "ans",
32
+ "agentId": "ans://v1.0.0.sales-agent.acme.com",
33
+ "signature": "BASE64URL_OR_0xHEX_SIGNATURE",
34
+ "timestamp": "2026-09-04T12:00:00.000Z",
35
+ "nonce": "nonce-0123456789abcdef",
36
+ "requestDigest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
37
+ "keyId": "optional-provider-key-id",
38
+ "policy": {
39
+ "anonymous": "challenge",
40
+ "claimed": "block",
41
+ "verified": "allow",
42
+ "minReputationScore": 65,
43
+ "belowMinimumScore": "limit",
44
+ "mediumRisk": "limit",
45
+ "highRisk": "block"
46
+ }
47
+ }
48
+ ```
49
+
50
+ | Field | Type | Required | Description |
51
+ | --- | --- | --- | --- |
52
+ | `provider` | string | for a claimed identity | Registered resolver name. `ans` is implemented; DNS, DID, and API-key adapters are future integrations |
53
+ | `agentId` | string | no | Provider identity. Omit it to classify the request as anonymous |
54
+ | `signature` | string | for verification | Base64/base64url or `0x`-hex signature unless the resolver defines a provider-specific proof |
55
+ | `timestamp` | ISO timestamp | for verification | Signed time; default acceptance window is five minutes |
56
+ | `nonce` | string | for verification | 16–256 URL-safe characters; atomically claimed to prevent replay |
57
+ | `requestDigest` | string | for verification | `sha256:` plus 64 hexadecimal characters for the protected request bytes |
58
+ | `keyId` | string | no | Selects one provider-resolved verification key |
59
+ | `policy` | object | no | Per-status and per-risk actions. Every action must be `allow`, `limit`, `challenge`, or `block` |
60
+
61
+ The signature covers the exact canonical payload documented in
62
+ [PROVIDER-IDENTITY.md](./PROVIDER-IDENTITY.md#low-level-verification-request).
63
+ SDK identity gates calculate `requestDigest` from the exact received request
64
+ bytes rather than trusting a digest header.
65
+
66
+ #### Response — verified
67
+
68
+ ```json
69
+ {
70
+ "agentId": "ans://v1.0.0.sales-agent.acme.com",
71
+ "provider": "ans",
72
+ "organization": "Acme Corp",
73
+ "identityStatus": "verified",
74
+ "humanIdentified": false,
75
+ "stableIdentityId": "identity:ans:<sha256>",
76
+ "credentialId": "7b93c61c-e261-488c-89a3-f948119be0a0",
77
+ "credentialVersion": "1.0.0",
78
+ "verifiedAt": "2026-09-04T12:00:00.000Z",
79
+ "reputationScore": 82,
80
+ "riskLevel": "low",
81
+ "policyDecision": {
82
+ "action": "allow",
83
+ "reason": "identity_verified"
84
+ }
85
+ }
86
+ ```
87
+
88
+ For ANS, `stableIdentityId` is derived from `agentHost`, so reputation and
89
+ activity remain continuous across versioned registrations. `credentialId` is
90
+ the Registry Authority UUID and `credentialVersion` is the resolved version.
91
+
92
+ #### Response — claimed, resolver unavailable
93
+
94
+ ```json
95
+ {
96
+ "agentId": "ans://v1.0.0.sales-agent.acme.com",
97
+ "provider": "ans",
98
+ "organization": null,
99
+ "identityStatus": "claimed",
100
+ "humanIdentified": false,
101
+ "stableIdentityId": null,
102
+ "verifiedAt": null,
103
+ "failureReason": "resolver_unavailable",
104
+ "reputationScore": null,
105
+ "riskLevel": "unknown",
106
+ "policyDecision": {
107
+ "action": "challenge",
108
+ "reason": "resolver_unavailable"
109
+ }
110
+ }
111
+ ```
112
+
113
+ This response occurs when the requested provider is not registered. For ANS it
114
+ also occurs when the deployment does not have the required ANS credentials and
115
+ trusted CA configuration.
116
+
117
+ #### Error responses
118
+
119
+ | Status | Error | Meaning |
120
+ | --- | --- | --- |
121
+ | 400 | `invalid_identity_policy` | A policy is not an object, an action is unsupported, or `minReputationScore` is outside 0–100 |
122
+ | 503 | `identity_verification_unavailable` | Valiron could not safely resolve identity or atomically claim replay state |
123
+
124
+ See [Provider-Backed Identity Errors](./ERRORS.md#provider-backed-identity-errors)
125
+ for all `failureReason` values and retry guidance.
126
+
127
+ ---
128
+
15
129
  ### GET /operator/agent/:agentId
16
130
 
17
131
  Retrieve the complete trust profile for an agent.
@@ -976,9 +1090,8 @@ Create a hosted agent-ready API wrapper. Requires JWT.
976
1090
  "paymentNetwork": "eip155:8453",
977
1091
  "payoutAddress": "0xYourReceivingWallet",
978
1092
  "trustEnabled": false,
979
- "upstreamAuthType": "header",
980
- "upstreamAuthHeader": "Authorization",
981
- "upstreamAuthSecret": "Bearer upstream-secret"
1093
+ "upstreamAuthType": "hmac",
1094
+ "upstreamAuthSecret": "replace-with-a-unique-shared-secret"
982
1095
  }
983
1096
  ```
984
1097
 
@@ -994,9 +1107,9 @@ Create a hosted agent-ready API wrapper. Requires JWT.
994
1107
  | `paymentNetwork` | string | no | Payment network. Use `eip155:8453` or `eip155:84532` for x402, and `tempo:4217` or `tempo:42431` for MPP. |
995
1108
  | `payoutAddress` | string | no | Receiving wallet for paid x402 wrappers. Required if no platform default receiving address is configured. |
996
1109
  | `trustEnabled` | boolean | no | When true, the wrapper requires Valiron agent identity headers and checks trust before forwarding. |
997
- | `upstreamAuthType` | string | no | `none` or `header`. Defaults to `none`. |
998
- | `upstreamAuthHeader` | string | no | Header name to attach to the upstream request, such as `Authorization` or `X-API-Key`. |
999
- | `upstreamAuthSecret` | string | no | Secret value for `upstreamAuthHeader`. Stored encrypted at rest. |
1110
+ | `upstreamAuthType` | string | no | `none`, `bearer`, `api_key`, or `hmac`. Defaults to `none`. Use `hmac` for a public origin that must reject direct requests. |
1111
+ | `upstreamAuthHeader` | string | no | Header name for `api_key` or `hmac`; defaults to `x-api-key` and `x-valiron-signature` respectively. Ignored by `bearer`. |
1112
+ | `upstreamAuthSecret` | string | required when auth is enabled | Shared secret, stored encrypted at rest. For `hmac`, your origin uses it to verify the signature and `x-valiron-timestamp`. |
1000
1113
 
1001
1114
  ---
1002
1115
 
@@ -1016,7 +1129,7 @@ Public agent-facing wrapper URL. This endpoint is created by `POST /operator/end
1016
1129
  https://valiron-edge-proxy.onrender.com/wrap/{operatorId}/{path}
1017
1130
  ```
1018
1131
 
1019
- The wrapper matches the operator ID, path, and HTTP method to an active endpoint config. It can enforce payment, optional trust checks, rate limits, SSRF protection, upstream auth injection, and request forwarding.
1132
+ The wrapper matches the operator ID, path, and HTTP method to an active endpoint config. It can enforce payment, optional trust checks, rate limits, SSRF protection, upstream auth injection, and request forwarding. These controls apply only to traffic sent to this wrapper URL. Protect a public upstream with `hmac` auth and reject direct, unsigned origin traffic. See [API Scaffolding](./AGENT-READY-APIS.md#recommended-production-pattern-hmac-origin-verification).
1020
1133
 
1021
1134
  #### Caller Headers
1022
1135
 
@@ -1025,8 +1138,7 @@ The wrapper matches the operator ID, path, and HTTP method to an active endpoint
1025
1138
  | `X-PAYMENT` | paid x402 retry | x402 payment payload returned by an x402-capable client. |
1026
1139
  | `Authorization: Payment ...` | paid MPP retry | MPP payment authorization header. |
1027
1140
  | `x-agent-id` | if trust enabled | ERC-8004 agent ID. |
1028
- | `x-agent-address` | if trust enabled | Key-based agent wallet address. |
1029
- | `x-agent-session` | key agents | Session token from key-based challenge-response. |
1141
+ | `x-agent-address` | not supported by hosted trust wrappers | Use SDK middleware in your own backend when you need key/address identity support. |
1030
1142
 
1031
1143
  #### Free Wrapper Response
1032
1144
 
package/docs/DASHBOARD.md CHANGED
@@ -114,8 +114,9 @@ This product is appropriate when an API must be callable by autonomous agents wi
114
114
  1. Open **Make API Agent-Ready**.
115
115
  2. Click **Make API Agent-Ready**.
116
116
  3. Enter your upstream API details and payment settings.
117
- 4. Save the wrapper.
118
- 5. Distribute the generated wrapper URL to agent clients:
117
+ 4. Configure upstream authentication to protect your origin.
118
+ 5. Save the wrapper.
119
+ 6. Distribute only the generated wrapper URL to agent clients:
119
120
 
120
121
  ```text
121
122
  https://valiron-edge-proxy.onrender.com/wrap/{operatorId}/{path}
@@ -129,6 +130,12 @@ When an agent calls the wrapper:
129
130
  4. Valiron appends the wrapper path to `targetUrl`, forwards the request, and adds Valiron metadata headers.
130
131
  5. Valiron returns the upstream response and records analytics.
131
132
 
133
+ > **Origin protection is required for a public upstream.** Valiron can enforce
134
+ > payment, trust, rate limits, and logging only for calls made to the wrapper
135
+ > URL. A call sent directly to your upstream does not pass through Valiron. Use
136
+ > HMAC upstream auth and reject missing or invalid signatures at your origin;
137
+ > do not rely on the presence of `x-valiron-*` metadata headers.
138
+
132
139
  ### Wrapper fields
133
140
 
134
141
  | Field | Required | Description |
@@ -142,7 +149,7 @@ When an agent calls the wrapper:
142
149
  | Payout wallet | No | Required for paid x402 wrappers unless a platform default receiving address is configured. |
143
150
  | Require Valiron trust | No | When enabled, callers must provide agent identity headers and pass the trust threshold. |
144
151
  | Rate limit (req/min) | No | Max requests per minute per agent (null = unlimited) |
145
- | Upstream auth | No | Optional static header secret Valiron should attach to your upstream request. |
152
+ | Upstream auth | Required for a public origin | `hmac` recommended. Your origin verifies the signature and timestamp before serving the request. |
146
153
  | Description | No | What this endpoint does |
147
154
 
148
155
  **Removing a wrapper** performs a soft-delete. The wrapper stops matching new calls but historical logs remain available.
@@ -330,6 +337,10 @@ API Scaffolding is a separate product that provides a hosted, agent-facing wrapp
330
337
  4. Test the generated `/wrap/{operatorId}/{path}` URL.
331
338
  5. Monitor calls in Analytics and Logs.
332
339
 
340
+ For hosted wrappers, also verify that a direct request to the upstream origin
341
+ returns `401` or `403`, while a wrapper request is visible in call logs. See
342
+ [API Scaffolding origin protection](./AGENT-READY-APIS.md#origin-lockdown-checklist).
343
+
333
344
  For deployments requiring full backend control, protect the API directly with Valiron middleware using `createValironGate()` or `ValironOperator.paywall()`.
334
345
 
335
346
  For full hosted wrapper docs, see [AGENT-READY-APIS.md](./AGENT-READY-APIS.md).
@@ -30,14 +30,16 @@ npm install @valiron/sdk
30
30
 
31
31
  ## 1. Identify every agent
32
32
 
33
- Valiron middleware supports both identity paths automatically. Send one of the
34
- following headers on the request to your API:
33
+ The standard gate automatically handles on-chain and key-based identities.
34
+ Provider-backed identity uses the dedicated identity gate because its proof is
35
+ bound to each exact request body:
35
36
 
36
37
  | Agent type | Header | Value | Setup |
37
38
  | --- | --- | --- | --- |
38
39
  | ERC-8004 EVM agent | `x-agent-id` | ERC-8004 token ID | Agent is registered on-chain |
39
40
  | Solana agent | `x-agent-id` | Metaplex Core asset pubkey or supported indexed ID | Use `chain: "solana"` |
40
41
  | Local, Web2, or non-ERC-8004 agent | `x-agent-address` | Persistent Ethereum-style address | Complete [key-based challenge-response](https://www.valiron.co/auth.md) first |
42
+ | ANS or another provider-backed identity | `x-valiron-identity-*` | Canonical provider ID, signature, timestamp, and nonce | Sign with `createAgentIdentityProof()` |
41
43
 
42
44
  Do not send a local agent name to `x-agent-id`. Key-based agents must prove
43
45
  ownership of their persistent address before they can pass an identity-aware
@@ -47,6 +49,12 @@ policy.
47
49
  > `x-agent-id` when its trust check is enabled. Use the SDK middleware in your
48
50
  > own backend for a policy that accepts either identity path.
49
51
 
52
+ > **Provider-backed identity:** use the dedicated `createValironIdentityGate`,
53
+ > `valironIdentityFastifyPlugin`, `createValironIdentityNextMiddleware`, or
54
+ > `valironIdentityGateCheck` exports documented in
55
+ > [PROVIDER-IDENTITY.md](./PROVIDER-IDENTITY.md). Do not send an ANS name through
56
+ > `x-agent-id`. Valiron hosts the ANS credentials and trusted CA bundle.
57
+
50
58
  ## 2. Choose trust signals
51
59
 
52
60
  Pass `trustSignals` to the middleware configuration. Start with the default
package/docs/ERRORS.md CHANGED
@@ -226,6 +226,40 @@ Each response includes `message`, `action`, and `docsUrl`; denials retain the tr
226
226
 
227
227
  > **Fail-closed:** When the Valiron service is unreachable, middleware returns 503 — it never fails open and never allows unverified agents through.
228
228
 
229
+ ## Provider-Backed Identity Errors
230
+
231
+ Provider identity proof failures are classifications, not transport failures:
232
+ the SDK and `POST /operator/identity/verify` return
233
+ HTTP 200 with `identityStatus: "claimed"` and one of these `failureReason`
234
+ values.
235
+
236
+ Dedicated identity middleware maps policy actions to HTTP responses: `challenge`
237
+ to 401, `block` to 403, and `limit` to 429. `IDENTITY_RAW_BODY_REQUIRED` is a
238
+ local HTTP 400 response when Express or Fastify parsed a body without retaining
239
+ its exact bytes. `IDENTITY_GATE_UNAVAILABLE` is a fail-closed HTTP 503.
240
+
241
+ | Failure reason | Meaning | Action |
242
+ | --- | --- | --- |
243
+ | `provider_missing` | An agent ID was supplied without a provider | Send the resolver provider name |
244
+ | `resolver_unavailable` | No adapter is registered for the provider | For ANS, configure credentials and a trusted CA bundle; never treat the claim as verified |
245
+ | `proof_incomplete` | Signature, timestamp, nonce, or digest is missing | Construct and sign the complete proof |
246
+ | `request_digest_invalid` | Digest is not `sha256:` plus 64 hex characters | Recalculate and format the SHA-256 digest |
247
+ | `nonce_invalid` | Nonce is shorter than 16 characters or contains unsupported characters | Generate a 16–256 character URL-safe nonce |
248
+ | `timestamp_invalid` | Timestamp cannot be parsed | Send an ISO-8601 timestamp |
249
+ | `timestamp_out_of_window` | Timestamp is outside the default five-minute window | Sign a fresh request; do not reuse the old proof |
250
+ | `resolution_failed` | Provider resolution threw an error | Retry only if the provider failure is transient |
251
+ | `identity_not_found` | Provider has no acceptable matching identity; ANS also uses this when strict lifecycle, certificate, or Transparency Log checks fail | Correct the ID or repair the provider registration outside Valiron |
252
+ | `provider_mismatch` | Resolved record belongs to a different provider | Reject the proof and inspect resolver configuration |
253
+ | `ownership_chain_unverified` | Provider authority or organization/domain binding did not validate | Do not grant verified access |
254
+ | `public_key_not_found` | No verification key matched the optional key ID | Refresh provider metadata or use an active key ID |
255
+ | `signature_invalid` | Signature encoding is invalid | Send base64/base64url or `0x`-hex as required by the resolver |
256
+ | `signature_verification_failed` | Proof does not match a resolved key or provider verifier | Reject the proof and sign the exact canonical payload |
257
+ | `replay_detected` | This identity and nonce were already accepted | Generate a fresh nonce and signature |
258
+
259
+ Malformed policies return HTTP 400 with `invalid_identity_policy`. A replay
260
+ store or other safe-verification failure returns HTTP 503 with
261
+ `identity_verification_unavailable`; the endpoint fails closed.
262
+
229
263
  ## Proxy Gateway Errors
230
264
 
231
265
  | Status | When | Action |
package/docs/IDENTITY.md CHANGED
@@ -1,15 +1,25 @@
1
- # Agent Identity: ERC-8004 and Key-Based Agents
1
+ # Agent Identity: On-Chain, Key-Based, and Provider-Backed Agents
2
2
 
3
- Valiron supports two identity paths:
3
+ Valiron supports on-chain, key-based, and provider-backed middleware identity
4
+ paths:
4
5
 
5
6
  | Agent type | Use this identifier | Request header | Lookup path |
6
7
  |------------|---------------------|----------------|-------------|
7
8
  | ERC-8004 / on-chain EVM agent | ERC-8004 token ID | `x-agent-id` | `/operator/agent/:agentId` |
8
9
  | Solana 8004 agent | Metaplex Core asset pubkey or indexed ID | `x-agent-id` | `/operator/agent/:agentId?chain=solana` |
9
10
  | Local, Web2, or non-ERC-8004 agent | Persistent Ethereum-style agent address | `x-agent-address` | `/operator/key/:agentAddress` |
11
+ | ANS, DNS, DID, API-key, or future provider identity | Provider-canonical ID | `x-valiron-identity-*` proof headers | SDK identity gate or `/operator/identity/verify` |
10
12
 
11
13
  Use `/operator/agent/:agentId` only 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.
12
14
 
15
+ The provider-backed framework normalizes identity into `anonymous`, `claimed`,
16
+ or `verified`, performs freshness and replay checks, and can return an
17
+ `allow`, `limit`, `challenge`, or `block` policy action. SDK 1.3 includes
18
+ signing helpers and dedicated provider identity gates; Valiron hosts the ANS
19
+ credentials and trusted CA bundle. See
20
+ [Provider-Backed Agent Identity](./PROVIDER-IDENTITY.md) for the exact request,
21
+ signature payload, SDK integration, response, and current ANS boundary.
22
+
13
23
  ## Wallet as a Trust Input
14
24
 
15
25
  When a Pro policy selects `trustSignals: ["wallet"]`, Valiron evaluates the wallet associated with the chosen identity path. ERC-8004 and Solana agents use the wallet resolved from their registry identity; key-based agents use their verified persistent agent address. Wallet intelligence does not establish identity by itself—it is an additional economic-history signal applied after Valiron has a wallet address.