@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.
@@ -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.
@@ -855,6 +969,7 @@ Get the current operator's profile. Requires JWT.
855
969
  "role": "operator",
856
970
  "plan": "standard",
857
971
  "fee_rate": "0.03",
972
+ "onboarding_completed_at": "2026-01-01T00:05:00.000Z",
858
973
  "created_at": "2026-01-01T00:00:00.000Z",
859
974
  "updated_at": "2026-01-01T00:00:00.000Z"
860
975
  }
@@ -877,6 +992,30 @@ Update operator name. Requires JWT.
877
992
 
878
993
  ---
879
994
 
995
+ ### POST /operator/onboarding/complete
996
+
997
+ Mark the guided account setup as completed or dismissed. Requires JWT. This
998
+ endpoint is idempotent, so clients can safely retry it.
999
+
1000
+ New accounts have a null `onboarding_completed_at` value until this endpoint is
1001
+ called. Valiron uses that value to resume unfinished setup after email, Google,
1002
+ or GitHub authentication.
1003
+
1004
+ #### Response — 200 OK
1005
+
1006
+ ```json
1007
+ {
1008
+ "ok": true,
1009
+ "operator": {
1010
+ "id": "uuid",
1011
+ "email": "you@example.com",
1012
+ "onboarding_completed_at": "2026-01-01T00:05:00.000Z"
1013
+ }
1014
+ }
1015
+ ```
1016
+
1017
+ ---
1018
+
880
1019
  ### GET /operator/keys
881
1020
 
882
1021
  List all API keys for the current operator. Requires JWT.
@@ -976,9 +1115,8 @@ Create a hosted agent-ready API wrapper. Requires JWT.
976
1115
  "paymentNetwork": "eip155:8453",
977
1116
  "payoutAddress": "0xYourReceivingWallet",
978
1117
  "trustEnabled": false,
979
- "upstreamAuthType": "header",
980
- "upstreamAuthHeader": "Authorization",
981
- "upstreamAuthSecret": "Bearer upstream-secret"
1118
+ "upstreamAuthType": "hmac",
1119
+ "upstreamAuthSecret": "replace-with-a-unique-shared-secret"
982
1120
  }
983
1121
  ```
984
1122
 
@@ -994,9 +1132,9 @@ Create a hosted agent-ready API wrapper. Requires JWT.
994
1132
  | `paymentNetwork` | string | no | Payment network. Use `eip155:8453` or `eip155:84532` for x402, and `tempo:4217` or `tempo:42431` for MPP. |
995
1133
  | `payoutAddress` | string | no | Receiving wallet for paid x402 wrappers. Required if no platform default receiving address is configured. |
996
1134
  | `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. |
1135
+ | `upstreamAuthType` | string | no | `none`, `bearer`, `api_key`, or `hmac`. Defaults to `none`. Use `hmac` for a public origin that must reject direct requests. |
1136
+ | `upstreamAuthHeader` | string | no | Header name for `api_key` or `hmac`; defaults to `x-api-key` and `x-valiron-signature` respectively. Ignored by `bearer`. |
1137
+ | `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
1138
 
1001
1139
  ---
1002
1140
 
@@ -1016,7 +1154,7 @@ Public agent-facing wrapper URL. This endpoint is created by `POST /operator/end
1016
1154
  https://valiron-edge-proxy.onrender.com/wrap/{operatorId}/{path}
1017
1155
  ```
1018
1156
 
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.
1157
+ 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
1158
 
1021
1159
  #### Caller Headers
1022
1160
 
@@ -1025,8 +1163,7 @@ The wrapper matches the operator ID, path, and HTTP method to an active endpoint
1025
1163
  | `X-PAYMENT` | paid x402 retry | x402 payment payload returned by an x402-capable client. |
1026
1164
  | `Authorization: Payment ...` | paid MPP retry | MPP payment authorization header. |
1027
1165
  | `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. |
1166
+ | `x-agent-address` | not supported by hosted trust wrappers | Use SDK middleware in your own backend when you need key/address identity support. |
1030
1167
 
1031
1168
  #### Free Wrapper Response
1032
1169
 
package/docs/DASHBOARD.md CHANGED
@@ -11,10 +11,21 @@
11
11
  To create an account:
12
12
 
13
13
  1. Go to [valiron.co/dashboard](https://www.valiron.co/dashboard) and click **Create account**
14
- 2. Enter your name, email, and password
14
+ 2. Enter your name, email, and password, or continue with Google or GitHub
15
15
  3. On success, you'll see a **one-time API key** — copy it immediately (it won't be shown again)
16
+ 4. Complete the same guided setup for every sign-up method: Account, Signals, Policy, Endpoint, Install, Deploy, and Finish
16
17
 
17
- After registration, sign in with your email and password. Your session is stored as a JWT in the browser.
18
+ Onboarding completion is stored on the operator account, so an unfinished setup
19
+ resumes after email, Google, or GitHub login and on another browser. If the
20
+ original one-time key is no longer available, the wizard can generate a
21
+ dedicated setup key. Existing operators are not forced back through onboarding.
22
+
23
+ The Signals step supports registered ERC-8004/Solana agents, persistent
24
+ key-based agents, and ANS or other provider-backed identities. ANS is an agent
25
+ identity option; it is not required to create a Valiron operator account.
26
+
27
+ After registration, sign in with your email and password, Google, or GitHub.
28
+ Your session is stored as a JWT in the browser.
18
29
 
19
30
  ---
20
31
 
@@ -114,8 +125,9 @@ This product is appropriate when an API must be callable by autonomous agents wi
114
125
  1. Open **Make API Agent-Ready**.
115
126
  2. Click **Make API Agent-Ready**.
116
127
  3. Enter your upstream API details and payment settings.
117
- 4. Save the wrapper.
118
- 5. Distribute the generated wrapper URL to agent clients:
128
+ 4. Configure upstream authentication to protect your origin.
129
+ 5. Save the wrapper.
130
+ 6. Distribute only the generated wrapper URL to agent clients:
119
131
 
120
132
  ```text
121
133
  https://valiron-edge-proxy.onrender.com/wrap/{operatorId}/{path}
@@ -129,6 +141,12 @@ When an agent calls the wrapper:
129
141
  4. Valiron appends the wrapper path to `targetUrl`, forwards the request, and adds Valiron metadata headers.
130
142
  5. Valiron returns the upstream response and records analytics.
131
143
 
144
+ > **Origin protection is required for a public upstream.** Valiron can enforce
145
+ > payment, trust, rate limits, and logging only for calls made to the wrapper
146
+ > URL. A call sent directly to your upstream does not pass through Valiron. Use
147
+ > HMAC upstream auth and reject missing or invalid signatures at your origin;
148
+ > do not rely on the presence of `x-valiron-*` metadata headers.
149
+
132
150
  ### Wrapper fields
133
151
 
134
152
  | Field | Required | Description |
@@ -142,7 +160,7 @@ When an agent calls the wrapper:
142
160
  | Payout wallet | No | Required for paid x402 wrappers unless a platform default receiving address is configured. |
143
161
  | Require Valiron trust | No | When enabled, callers must provide agent identity headers and pass the trust threshold. |
144
162
  | 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. |
163
+ | Upstream auth | Required for a public origin | `hmac` recommended. Your origin verifies the signature and timestamp before serving the request. |
146
164
  | Description | No | What this endpoint does |
147
165
 
148
166
  **Removing a wrapper** performs a soft-delete. The wrapper stops matching new calls but historical logs remain available.
@@ -330,6 +348,10 @@ API Scaffolding is a separate product that provides a hosted, agent-facing wrapp
330
348
  4. Test the generated `/wrap/{operatorId}/{path}` URL.
331
349
  5. Monitor calls in Analytics and Logs.
332
350
 
351
+ For hosted wrappers, also verify that a direct request to the upstream origin
352
+ returns `401` or `403`, while a wrapper request is visible in call logs. See
353
+ [API Scaffolding origin protection](./AGENT-READY-APIS.md#origin-lockdown-checklist).
354
+
333
355
  For deployments requiring full backend control, protect the API directly with Valiron middleware using `createValironGate()` or `ValironOperator.paywall()`.
334
356
 
335
357
  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.
@@ -0,0 +1,277 @@
1
+ # Provider-Backed Agent Identity
2
+
3
+ Valiron now has a provider-independent verification foundation for identities
4
+ resolved through ANS, DNS, DIDs, API keys, and future standards. An ANS REST
5
+ resolver adapter is implemented and is registered at service startup when its
6
+ credentials and trusted CA bundle are configured. SDK 1.3 adds signing helpers,
7
+ a typed verification method, and dedicated identity gates for Express, Fastify,
8
+ Next.js, and framework-independent runtimes.
9
+
10
+ ## Responsibility boundary
11
+
12
+ An identity provider establishes the agent's canonical identifier, verification
13
+ key or credential, endpoints, metadata, and authoritative organization or domain
14
+ binding. Valiron verifies the signed request proof, prevents replay, attaches
15
+ reputation and activity to the stable provider identity, and applies the API
16
+ seller's policy.
17
+
18
+ Provider trust evidence is not silently converted into Valiron reputation. ANS
19
+ may expose certificate integrity, lifecycle, trust-index, permission, or
20
+ historical signals; Valiron keeps those external signals separate from behavior
21
+ Valiron observed and from the endpoint owner's action-time policy.
22
+
23
+ Valiron does not register domains or issue provider identities.
24
+
25
+ ## Identity statuses
26
+
27
+ | Status | Meaning |
28
+ | --- | --- |
29
+ | `anonymous` | No agent identity was supplied. |
30
+ | `claimed` | An identity was supplied, but resolution, authority binding, freshness, signature, or replay validation failed. |
31
+ | `verified` | The provider authority binding and signed request proof both passed. |
32
+
33
+ `verified` is pseudonymous. It proves that the caller controls the credential
34
+ bound to the agent identity; it does not identify an employee, customer, or
35
+ other human. This endpoint therefore always returns `humanIdentified: false`.
36
+
37
+ ## Install
38
+
39
+ ```bash
40
+ npm install @valiron/sdk@^1.3.0
41
+ ```
42
+
43
+ ANS credentials and CA certificates are configured by Valiron on the hosted
44
+ verification service. API owners using the SDK do not need GoDaddy credentials
45
+ and must not expose Valiron's provider credentials to agents or browsers.
46
+
47
+ ## Agent: sign and send a request
48
+
49
+ The agent signs the canonical Valiron payload using the private key bound to its
50
+ provider identity. The signing callback lets the agent use its existing key
51
+ manager, HSM, wallet, or provider-specific crypto library.
52
+
53
+ ```typescript
54
+ import {
55
+ agentIdentityProofHeaders,
56
+ createAgentIdentityProof,
57
+ } from "@valiron/sdk";
58
+
59
+ const body = JSON.stringify({ operation: "quote", amount: 25 });
60
+ const proof = await createAgentIdentityProof({
61
+ provider: "ans",
62
+ agentId: "ans://v1.0.0.sales-agent.acme.com",
63
+ body,
64
+ sign: (payload) => agentKey.sign(payload),
65
+ });
66
+
67
+ await fetch("https://api.example.com/quote", {
68
+ method: "POST",
69
+ headers: {
70
+ "content-type": "application/json",
71
+ ...agentIdentityProofHeaders(proof),
72
+ },
73
+ body,
74
+ });
75
+ ```
76
+
77
+ The helper sends these proof headers:
78
+
79
+ | Header | Purpose |
80
+ | --- | --- |
81
+ | `x-valiron-identity-provider` | Resolver name, such as `ans` |
82
+ | `x-valiron-identity-agent-id` | Provider-canonical agent ID |
83
+ | `x-valiron-identity-signature` | Signature over the canonical payload |
84
+ | `x-valiron-identity-timestamp` | ISO 8601 signing time |
85
+ | `x-valiron-identity-nonce` | Unique replay-prevention nonce |
86
+ | `x-valiron-identity-key-id` | Optional provider key selector |
87
+
88
+ These headers are untrusted proof inputs until a Valiron identity gate validates
89
+ them. Never authorize a request merely because an `x-valiron-identity-*` header
90
+ exists, and never treat output metadata such as `x-valiron-tier` or
91
+ `x-valiron-route` as caller authentication.
92
+
93
+ There is intentionally no request-digest header. The receiving API computes
94
+ the SHA-256 digest from the exact request bytes so an agent cannot substitute a
95
+ digest for different content.
96
+
97
+ ## API owner: enforce an identity policy
98
+
99
+ For Express, capture the raw bytes while parsing and install the provider
100
+ identity gate on the protected route:
101
+
102
+ ```typescript
103
+ import express from "express";
104
+ import { ValironSDK, createValironIdentityGate } from "@valiron/sdk";
105
+
106
+ const app = express();
107
+ app.use(express.json({
108
+ verify(req: any, _res, bytes) {
109
+ req.rawBody = Buffer.from(bytes);
110
+ },
111
+ }));
112
+
113
+ const valiron = new ValironSDK({ apiKey: process.env.VALIRON_API_KEY });
114
+
115
+ app.post("/quote", createValironIdentityGate({
116
+ sdk: valiron,
117
+ policy: {
118
+ anonymous: "challenge",
119
+ claimed: "block",
120
+ verified: "allow",
121
+ minReputationScore: 65,
122
+ belowMinimumScore: "limit",
123
+ highRisk: "block",
124
+ },
125
+ }), handler);
126
+ ```
127
+
128
+ Allowed requests expose the normalized result as `req.valironIdentity`.
129
+ `challenge`, `block`, and `limit` decisions return HTTP 401, 403, and 429
130
+ respectively. Verification errors fail closed with HTTP 503. Body-bearing
131
+ Express and Fastify requests return HTTP 400 if exact raw bytes were not
132
+ captured. Next.js middleware safely hashes `request.clone()` automatically.
133
+
134
+ Equivalent exports are `valironIdentityFastifyPlugin`,
135
+ `createValironIdentityNextMiddleware`, and `valironIdentityGateCheck`.
136
+
137
+ ## Low-level verification request
138
+
139
+ `ValironSDK.verifyAgentIdentity(proof, policy)` calls
140
+ `POST /operator/identity/verify`. Advanced integrations can call it directly:
141
+
142
+ ```json
143
+ {
144
+ "provider": "ans",
145
+ "agentId": "ans://v1.0.0.sales-agent.acme.com",
146
+ "signature": "BASE64URL_OR_0xHEX_SIGNATURE",
147
+ "timestamp": "2026-09-04T12:00:00.000Z",
148
+ "nonce": "nonce-0123456789abcdef",
149
+ "requestDigest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
150
+ "keyId": "optional-provider-key-id",
151
+ "policy": {
152
+ "anonymous": "challenge",
153
+ "claimed": "block",
154
+ "verified": "allow",
155
+ "minReputationScore": 65,
156
+ "belowMinimumScore": "limit",
157
+ "mediumRisk": "limit",
158
+ "highRisk": "block"
159
+ }
160
+ }
161
+ ```
162
+
163
+ The signature covers the UTF-8 bytes of this exact payload:
164
+
165
+ ```text
166
+ valiron-agent-request-v1
167
+ agent-id:<provider-canonical-agent-id>
168
+ timestamp:<timestamp-as-submitted>
169
+ nonce:<nonce-as-submitted>
170
+ request-digest:<lowercase-request-digest>
171
+ ```
172
+
173
+ The request digest must use `sha256:` followed by 64 hexadecimal characters.
174
+ The nonce must contain 16–256 URL-safe characters. The default timestamp window
175
+ is five minutes, and nonce claims are retained for ten minutes.
176
+
177
+ The caller must calculate `requestDigest` from the protected request bytes and
178
+ apply the returned decision to that same request. This standalone verification
179
+ endpoint cannot infer the bytes of a separate downstream request.
180
+
181
+ ## Response
182
+
183
+ ```json
184
+ {
185
+ "agentId": "ans://v1.0.0.sales-agent.acme.com",
186
+ "provider": "ans",
187
+ "organization": "Acme Corp",
188
+ "identityStatus": "verified",
189
+ "humanIdentified": false,
190
+ "stableIdentityId": "identity:ans:<sha256>",
191
+ "credentialId": "7b93c61c-e261-488c-89a3-f948119be0a0",
192
+ "credentialVersion": "1.0.0",
193
+ "verifiedAt": "2026-09-04T12:00:00.000Z",
194
+ "reputationScore": 82,
195
+ "riskLevel": "low",
196
+ "policyDecision": {
197
+ "action": "allow",
198
+ "reason": "identity_verified"
199
+ }
200
+ }
201
+ ```
202
+
203
+ The action is one of `allow`, `limit`, `challenge`, or `block`. A verified
204
+ identity without stored reputation returns `reputationScore: null` and
205
+ `riskLevel: "unknown"`; it is not treated as having a negative score.
206
+
207
+ Failed proofs return HTTP 200 with `identityStatus: "claimed"` and a
208
+ machine-readable `failureReason`. See [Errors](./ERRORS.md#provider-backed-identity-errors).
209
+
210
+ ## Replay and storage behavior
211
+
212
+ Nonce claims use an atomic Redis write. Verification returns HTTP 503 when the
213
+ replay store is unavailable, so the flow cannot fail open. Only verified
214
+ requests update the stable identity activity record. Failed claims cannot write
215
+ activity or reputation against the identity they attempted to impersonate.
216
+
217
+ For ANS, the stable reputation subject is the normalized `agentHost`, such as
218
+ `sales-agent.acme.com`. The versioned ANS name and Registry Authority UUID are
219
+ returned as credential identity fields. A new ANS version therefore gets a new
220
+ credential while retaining the same Valiron reputation subject.
221
+
222
+ ## ANS resolver
223
+
224
+ As checked on 2026-09-10, the public ANS reference implementation uses
225
+ versioned `ans://v<major>.<minor>.<patch>.<agentHost>` names. Each version is an
226
+ independent registration with its own UUID and certificates, while `agentHost`
227
+ is the cross-version correlation key.
228
+
229
+ For an ANS claim, the adapter:
230
+
231
+ 1. resolves the exact host and version through `POST /v1/agents/resolution`;
232
+ 2. follows only a same-origin Registry Authority agent-details link;
233
+ 3. requires the UUID, host, ANS name, version, and `ACTIVE` lifecycle state to match;
234
+ 4. loads an identity certificate and validates its time window and signature chain against the configured CA roots;
235
+ 5. requires an exact URI SAN for the versioned ANS name;
236
+ 6. loads the current Transparency Log record, requires `ACTIVE` or `WARNING`, and matches its identity-certificate fingerprint; and
237
+ 7. extracts the certificate public key for the Valiron request proof.
238
+
239
+ The timestamp, nonce, request digest, and `valiron-agent-request-v1` payload are
240
+ a Valiron transport-proof envelope. They are not presented as an ANS-native HTTP
241
+ signature standard.
242
+
243
+ Configure the resolver on the edge-proxy service with:
244
+
245
+ | Variable | Required | Purpose |
246
+ | --- | --- | --- |
247
+ | `ANS_TRUSTED_CA_PEM` | yes | PEM bundle of trusted ANS Registry Authority CA roots; escaped `\\n` is accepted |
248
+ | `ANS_API_KEY` and `ANS_API_SECRET` | one auth method | GoDaddy classic Developer Portal `sso-key` credentials |
249
+ | `ANS_OAUTH_TOKEN` | one auth method | Future OAuth/PAT bearer token; takes precedence, so leave it unset when using classic credentials |
250
+ | `ANS_API_BASE_URL` | no | Registry Authority origin; defaults to `https://api.godaddy.com` |
251
+ | `ANS_TRANSPARENCY_BASE_URL` | no | Transparency Log origin; defaults to the matching production or OTE GoDaddy service |
252
+
253
+ The official production CA bundle is published at
254
+ <https://raw.githubusercontent.com/agentnameservice/ans-registry/main/pki/prod/ca-bundle.pem>
255
+ (with [PKI documentation](https://github.com/agentnameservice/ans-registry/tree/main/pki)).
256
+ Copy its raw PEM content with exact `BEGIN CERTIFICATE` and `END CERTIFICATE`
257
+ lines. Do not include Markdown backslashes or wrap the entire value in literal
258
+ quotes in the Render dashboard. These variables belong to Valiron's service,
259
+ not customer SDK installations.
260
+
261
+ If credentials or the CA bundle are absent, the resolver is not registered and
262
+ ANS claims return `claimed` with `failureReason: "resolver_unavailable"`.
263
+ Malformed, inactive, revoked, mismatched, untrusted, or certificate-less ANS
264
+ records cannot become `verified`.
265
+
266
+ This first adapter does not independently validate live DNS/DANE state, a SCITT
267
+ receipt, Merkle inclusion, checkpoint signatures, OCSP, or CRLs. Those are
268
+ additional ANS integrity checks, not claims made by this endpoint. There is no
269
+ domain-registration feature in Valiron.
270
+
271
+ Public references:
272
+
273
+ - <https://www.godaddy.com/en-in/ans/developers>
274
+ - <https://docs.developer.commerce.godaddy.com/en/docs/references/rest/ans/resolution>
275
+ - <https://github.com/agentnameservice/ans-registry>
276
+ - <https://github.com/agentnameservice/ans-sdk-go>
277
+ - <https://www.rfc-editor.org/rfc/rfc5280#section-6>