@valiron/sdk 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -2
- package/dist/clients.d.ts +40 -1
- package/dist/clients.js +69 -6
- package/dist/index.d.ts +50 -1
- package/dist/index.js +51 -0
- package/dist/middleware.d.ts +9 -1
- package/dist/middleware.js +228 -9
- package/dist/operatorSdk.d.ts +11 -1
- package/dist/operatorSdk.js +152 -3
- package/dist/telemetry.js +1 -1
- package/dist/types.d.ts +101 -2
- package/docs/AGENT-READY-APIS.md +417 -0
- package/docs/API-REFERENCE.md +208 -26
- package/docs/DASHBOARD.md +107 -28
- package/docs/ERRORS.md +12 -2
- package/docs/IDENTITY.md +67 -14
- package/docs/QUICKSTART.md +67 -5
- package/docs/README.md +20 -4
- package/docs/SDK-REFERENCE.md +58 -12
- package/docs/TRUST-MODEL.md +38 -4
- package/docs/llms.txt +119 -7
- package/package.json +2 -2
package/dist/types.d.ts
CHANGED
|
@@ -9,6 +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" | "self";
|
|
12
13
|
export interface AgentIdentity {
|
|
13
14
|
agentId: string;
|
|
14
15
|
wallet: string;
|
|
@@ -192,6 +193,8 @@ export interface GateOptions {
|
|
|
192
193
|
minScore?: number;
|
|
193
194
|
/** TTL in ms for cached sandbox results. Stale results trigger re-testing (default: 86400000 = 24 h). */
|
|
194
195
|
ttlMs?: number;
|
|
196
|
+
/** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+self+icebreaker. */
|
|
197
|
+
trustSignals?: TrustSignal[];
|
|
195
198
|
/** Override the blockchain network for this call. */
|
|
196
199
|
chain?: SupportedChain;
|
|
197
200
|
}
|
|
@@ -325,6 +328,98 @@ export interface WorldIdAgentProfile {
|
|
|
325
328
|
reasons: string[];
|
|
326
329
|
timestamp: string;
|
|
327
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
|
+
}
|
|
328
423
|
/**
|
|
329
424
|
* Icebreaker ownership attestation linked to an agent key hash.
|
|
330
425
|
*/
|
|
@@ -354,7 +449,7 @@ export interface KeyAgentProfile {
|
|
|
354
449
|
agentAddress: string;
|
|
355
450
|
/** Whether identity has been verified via challenge-response */
|
|
356
451
|
verified: boolean;
|
|
357
|
-
/** Behavioral score (0-
|
|
452
|
+
/** Behavioral score (0-100) — same scoring as ERC-8004 agents */
|
|
358
453
|
score: number | null;
|
|
359
454
|
/** Moody's-style tier (AAA → C) */
|
|
360
455
|
tier: MoodysRating | null;
|
|
@@ -376,6 +471,8 @@ export interface CallOptions {
|
|
|
376
471
|
* Takes precedence over the default chain set in the constructor.
|
|
377
472
|
*/
|
|
378
473
|
chain?: SupportedChain;
|
|
474
|
+
/** Customer-selected scoring signals for profile/routing calls. */
|
|
475
|
+
trustSignals?: TrustSignal[];
|
|
379
476
|
}
|
|
380
477
|
export type TelemetryEnvironment = "prod" | "staging" | "dev";
|
|
381
478
|
export interface TelemetryEventBase {
|
|
@@ -418,7 +515,9 @@ export interface ValironConfig {
|
|
|
418
515
|
*/
|
|
419
516
|
chain?: SupportedChain;
|
|
420
517
|
/**
|
|
421
|
-
* Request timeout in milliseconds
|
|
518
|
+
* Request timeout in milliseconds. When omitted, the SDK uses method-aware
|
|
519
|
+
* defaults: 10s generally, 15s for gate/proxy calls, and 30s for sandbox
|
|
520
|
+
* triggers. When set, this value overrides all method-aware defaults.
|
|
422
521
|
*/
|
|
423
522
|
timeout?: number;
|
|
424
523
|
/**
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
# API Scaffolding
|
|
2
|
+
|
|
3
|
+
API Scaffolding is a separate Valiron product for exposing existing HTTPS APIs through hosted, agent-facing URLs. It can add x402 or MPP payment handling, optional Valiron trust checks, rate limits, upstream forwarding, and usage logs without requiring immediate SDK middleware integration.
|
|
4
|
+
|
|
5
|
+
Use this flow when Valiron should host the payment and optional trust layer for an existing HTTPS API:
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
Agent or client
|
|
9
|
+
-> Valiron-hosted wrapper URL
|
|
10
|
+
-> x402 or MPP payment check
|
|
11
|
+
-> optional Valiron trust check
|
|
12
|
+
-> provider's existing API
|
|
13
|
+
-> response returned through Valiron
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
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
|
+
|
|
18
|
+
## When To Use This
|
|
19
|
+
|
|
20
|
+
Use API Scaffolding when:
|
|
21
|
+
|
|
22
|
+
- You already have an HTTPS API and want to sell per-call access to agents.
|
|
23
|
+
- You want x402 or MPP payment challenges without implementing those protocols yourself.
|
|
24
|
+
- You want Valiron trust checks before paid traffic reaches your API.
|
|
25
|
+
- You need a no-code or low-code path from an existing API to an agent-compatible endpoint.
|
|
26
|
+
|
|
27
|
+
Use the SDK middleware instead when:
|
|
28
|
+
|
|
29
|
+
- You want payments to be handled entirely by your own server.
|
|
30
|
+
- You need custom payment terms, subscriptions, account billing, or business-specific authorization.
|
|
31
|
+
- Valiron should run directly in the API backend as the primary trust and policy enforcement layer.
|
|
32
|
+
|
|
33
|
+
## Provider Setup
|
|
34
|
+
|
|
35
|
+
Providers configure one wrapper per public endpoint.
|
|
36
|
+
|
|
37
|
+
| Field | Required | Description |
|
|
38
|
+
|-------|----------|-------------|
|
|
39
|
+
| Public path | Yes | Path callers use on Valiron, for example `/weather`. |
|
|
40
|
+
| HTTP method | Yes | `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, or `HEAD`. |
|
|
41
|
+
| Upstream base URL | Yes | Existing HTTPS API base URL, for example `https://api.example.com`. |
|
|
42
|
+
| Price per call | Yes | USD amount charged for paid requests. Use `0` for a free wrapper. |
|
|
43
|
+
| Payment protocol | Yes | `x402` or `MPP`. |
|
|
44
|
+
| Payment network | Yes | x402: `eip155:8453` or `eip155:84532`; MPP: `tempo:4217` or `tempo:42431`. |
|
|
45
|
+
| Payout wallet | Paid only | EVM address receiving payment. |
|
|
46
|
+
| Upstream auth | No | Secret Valiron injects when forwarding to your upstream. |
|
|
47
|
+
| Rate limit | No | Max requests per minute per client. |
|
|
48
|
+
| Trust check | No | Whether callers must pass Valiron agent trust evaluation before forwarding. |
|
|
49
|
+
|
|
50
|
+
Example existing API:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
GET https://api.example.com/weather
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Example Valiron URL:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
GET https://valiron-edge-proxy.onrender.com/wrap/{operatorId}/weather
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Valiron preserves query strings and appends the public wrapper path to the upstream base URL. If your upstream base URL is `https://api.example.com/v1` and your public path is `/weather`, Valiron forwards to:
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
https://api.example.com/v1/weather
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Dashboard Flow
|
|
69
|
+
|
|
70
|
+
1. Open [valiron.co/dashboard](https://www.valiron.co/dashboard).
|
|
71
|
+
2. Go to **Make API Agent-Ready**.
|
|
72
|
+
3. Click **Make API Agent-Ready**.
|
|
73
|
+
4. Enter the upstream URL, public path, method, price, protocol, network, and payout wallet.
|
|
74
|
+
5. Choose whether Valiron trust checks are required.
|
|
75
|
+
6. Configure upstream auth only if your API needs it.
|
|
76
|
+
7. Create the wrapper.
|
|
77
|
+
8. Distribute the generated Valiron URL to agent clients or API customers.
|
|
78
|
+
|
|
79
|
+
## HTTP API Flow
|
|
80
|
+
|
|
81
|
+
The dashboard calls the same operator API you can call directly.
|
|
82
|
+
|
|
83
|
+
### Register
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
curl -X POST https://valiron-edge-proxy.onrender.com/operator/register \
|
|
87
|
+
-H "content-type: application/json" \
|
|
88
|
+
-d '{
|
|
89
|
+
"email": "you@example.com",
|
|
90
|
+
"password": "a-long-password",
|
|
91
|
+
"name": "Example Operator"
|
|
92
|
+
}'
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Login
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
curl -X POST https://valiron-edge-proxy.onrender.com/operator/login \
|
|
99
|
+
-H "content-type: application/json" \
|
|
100
|
+
-d '{
|
|
101
|
+
"email": "you@example.com",
|
|
102
|
+
"password": "a-long-password"
|
|
103
|
+
}'
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Create A Free Wrapper
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
curl -X POST https://valiron-edge-proxy.onrender.com/operator/endpoints \
|
|
110
|
+
-H "authorization: Bearer $VALIRON_JWT" \
|
|
111
|
+
-H "content-type: application/json" \
|
|
112
|
+
-d '{
|
|
113
|
+
"path": "/weather",
|
|
114
|
+
"method": "GET",
|
|
115
|
+
"pricePerCall": 0,
|
|
116
|
+
"targetUrl": "https://api.example.com",
|
|
117
|
+
"paymentProtocol": "x402",
|
|
118
|
+
"paymentNetwork": "eip155:8453",
|
|
119
|
+
"trustEnabled": false,
|
|
120
|
+
"upstreamAuthType": "none"
|
|
121
|
+
}'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Create A Paid x402 Wrapper
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
curl -X POST https://valiron-edge-proxy.onrender.com/operator/endpoints \
|
|
128
|
+
-H "authorization: Bearer $VALIRON_JWT" \
|
|
129
|
+
-H "content-type: application/json" \
|
|
130
|
+
-d '{
|
|
131
|
+
"path": "/weather",
|
|
132
|
+
"method": "GET",
|
|
133
|
+
"pricePerCall": 0.001,
|
|
134
|
+
"targetUrl": "https://api.example.com",
|
|
135
|
+
"paymentProtocol": "x402",
|
|
136
|
+
"paymentNetwork": "eip155:8453",
|
|
137
|
+
"payoutAddress": "0xYourPayoutWallet",
|
|
138
|
+
"trustEnabled": false,
|
|
139
|
+
"upstreamAuthType": "none"
|
|
140
|
+
}'
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Create A Paid MPP Wrapper
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
curl -X POST https://valiron-edge-proxy.onrender.com/operator/endpoints \
|
|
147
|
+
-H "authorization: Bearer $VALIRON_JWT" \
|
|
148
|
+
-H "content-type: application/json" \
|
|
149
|
+
-d '{
|
|
150
|
+
"path": "/research",
|
|
151
|
+
"method": "GET",
|
|
152
|
+
"pricePerCall": 0.001,
|
|
153
|
+
"targetUrl": "https://api.example.com",
|
|
154
|
+
"paymentProtocol": "mpp",
|
|
155
|
+
"paymentNetwork": "tempo:4217",
|
|
156
|
+
"payoutAddress": "0xYourPayoutWallet",
|
|
157
|
+
"trustEnabled": false,
|
|
158
|
+
"upstreamAuthType": "none"
|
|
159
|
+
}'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
For Tempo testnet, use:
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{ "paymentNetwork": "tempo:42431" }
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### List Wrappers
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
curl https://valiron-edge-proxy.onrender.com/operator/endpoints \
|
|
172
|
+
-H "authorization: Bearer $VALIRON_JWT"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Deactivate A Wrapper
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
curl -X DELETE https://valiron-edge-proxy.onrender.com/operator/endpoints/{endpointId} \
|
|
179
|
+
-H "authorization: Bearer $VALIRON_JWT"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Deactivation is a soft delete. Existing logs remain available.
|
|
183
|
+
|
|
184
|
+
## Calling A Wrapper
|
|
185
|
+
|
|
186
|
+
Call the generated URL directly:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
curl -i https://valiron-edge-proxy.onrender.com/wrap/{operatorId}/weather
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
For a free wrapper, Valiron forwards immediately and returns the upstream response with Valiron wrapper headers:
|
|
193
|
+
|
|
194
|
+
```text
|
|
195
|
+
x-valiron-wrapper-id: ...
|
|
196
|
+
x-valiron-payment-protocol: free
|
|
197
|
+
x-valiron-trust-enabled: false
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
For a paid x402 wrapper without payment, Valiron returns `402` and an x402 payment challenge:
|
|
201
|
+
|
|
202
|
+
```text
|
|
203
|
+
HTTP/1.1 402 Payment Required
|
|
204
|
+
x-payment-required: ...
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
For a paid MPP wrapper without payment, Valiron returns `402` and an MPP challenge:
|
|
208
|
+
|
|
209
|
+
```text
|
|
210
|
+
HTTP/1.1 402 Payment Required
|
|
211
|
+
WWW-Authenticate: Payment ...
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## x402 Paid Client
|
|
215
|
+
|
|
216
|
+
Use an x402-capable client to retry with payment. The repo includes a local buyer test client in `services/x402-test-server/src/buyer-test.ts`, and the production smoke path uses the same libraries:
|
|
217
|
+
|
|
218
|
+
- `@x402/fetch`
|
|
219
|
+
- `@x402/core/client`
|
|
220
|
+
- `@x402/evm/exact/client`
|
|
221
|
+
- `viem/accounts`
|
|
222
|
+
|
|
223
|
+
Minimal client shape:
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
import { wrapFetchWithPayment } from "@x402/fetch";
|
|
227
|
+
import { x402Client } from "@x402/core/client";
|
|
228
|
+
import { ExactEvmScheme } from "@x402/evm/exact/client";
|
|
229
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
230
|
+
|
|
231
|
+
const account = privateKeyToAccount(process.env.BUYER_PRIVATE_KEY as `0x${string}`);
|
|
232
|
+
|
|
233
|
+
const client = new x402Client();
|
|
234
|
+
client.register("eip155:*", new ExactEvmScheme(account));
|
|
235
|
+
|
|
236
|
+
const fetchWithPayment = wrapFetchWithPayment(fetch, client);
|
|
237
|
+
|
|
238
|
+
const response = await fetchWithPayment(
|
|
239
|
+
"https://valiron-edge-proxy.onrender.com/wrap/{operatorId}/weather",
|
|
240
|
+
{ method: "GET", headers: { "x-agent-id": "25459" } }
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
console.log(response.status);
|
|
244
|
+
console.log(await response.text());
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
The buyer wallet must hold the required token on the selected x402 network. For Base mainnet, the default production path expects USDC on Base.
|
|
248
|
+
|
|
249
|
+
## MPP Paid Client
|
|
250
|
+
|
|
251
|
+
Valiron MPP support uses the official `mppx` SDK with the Tempo `charge` intent.
|
|
252
|
+
|
|
253
|
+
Server behavior:
|
|
254
|
+
|
|
255
|
+
- Unpaid request returns `402`.
|
|
256
|
+
- Response includes `WWW-Authenticate: Payment ...`.
|
|
257
|
+
- Paid request includes `Authorization: Payment ...`.
|
|
258
|
+
- Successful paid response includes `Payment-Receipt`.
|
|
259
|
+
|
|
260
|
+
Recommended testnet client flow:
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
pnpm exec mppx account create
|
|
264
|
+
pnpm exec mppx https://valiron-edge-proxy.onrender.com/wrap/{operatorId}/research
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Use `tempo:42431` for Tempo testnet and `tempo:4217` for Tempo mainnet.
|
|
268
|
+
|
|
269
|
+
Default Tempo currencies from `mppx`:
|
|
270
|
+
|
|
271
|
+
| Network | Chain ID | Default currency |
|
|
272
|
+
|---------|----------|------------------|
|
|
273
|
+
| Tempo mainnet | `4217` | USDC (`0x20C000000000000000000000b9537d11c60E8b50`) |
|
|
274
|
+
| Tempo testnet | `42431` | pathUSD (`0x20c0000000000000000000000000000000000000`) |
|
|
275
|
+
|
|
276
|
+
## Optional Trust Checks
|
|
277
|
+
|
|
278
|
+
When `trustEnabled` is `false`, Valiron only handles payment, rate limiting, upstream auth, and forwarding.
|
|
279
|
+
|
|
280
|
+
When `trustEnabled` is `true`, callers must identify the agent:
|
|
281
|
+
|
|
282
|
+
```text
|
|
283
|
+
x-agent-id: 25459
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Valiron evaluates the agent before forwarding. If the agent is denied, the upstream API is not called.
|
|
287
|
+
|
|
288
|
+
Use trust checks when:
|
|
289
|
+
|
|
290
|
+
- You want to block risky agents even if they can pay.
|
|
291
|
+
- You want route decisions and call logs tied to agent IDs.
|
|
292
|
+
- You plan to vary pricing, limits, or access based on trust tiers.
|
|
293
|
+
|
|
294
|
+
Use payment-only wrappers when:
|
|
295
|
+
|
|
296
|
+
- You want the lowest-friction paid endpoint.
|
|
297
|
+
- You do not need agent identity yet.
|
|
298
|
+
- You are testing x402 or MPP integration.
|
|
299
|
+
|
|
300
|
+
## Upstream Auth
|
|
301
|
+
|
|
302
|
+
If your existing API requires auth, Valiron stores the secret encrypted and injects it only when forwarding a valid request upstream.
|
|
303
|
+
|
|
304
|
+
Supported auth modes:
|
|
305
|
+
|
|
306
|
+
| Mode | Behavior |
|
|
307
|
+
|------|----------|
|
|
308
|
+
| `none` | No upstream auth is added. |
|
|
309
|
+
| `bearer` | Adds `Authorization: Bearer <secret>`. |
|
|
310
|
+
| `api_key` | Adds the secret to the configured header name. |
|
|
311
|
+
| `hmac` | Signs the request using the secret and adds signature headers. |
|
|
312
|
+
|
|
313
|
+
The calling agent never sees your upstream secret.
|
|
314
|
+
|
|
315
|
+
Production requires `VALIRON_SECRET_ENCRYPTION_KEY` to store upstream auth secrets. Use a 32-byte hex key:
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
openssl rand -hex 32
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## Security Defaults
|
|
322
|
+
|
|
323
|
+
In production, Valiron wrappers:
|
|
324
|
+
|
|
325
|
+
- Require HTTPS upstream URLs.
|
|
326
|
+
- Block localhost, private IP ranges, link-local IPs, metadata hosts, and internal hostnames.
|
|
327
|
+
- Resolve upstream DNS and block private resolved IPs.
|
|
328
|
+
- Strip hop-by-hop and sensitive inbound headers before forwarding.
|
|
329
|
+
- Do not forward inbound `Authorization`, `Cookie`, `x-payment`, or `payment-signature` headers to the upstream.
|
|
330
|
+
- Add Valiron wrapper metadata headers to forwarded requests.
|
|
331
|
+
- Apply per-endpoint rate limits.
|
|
332
|
+
- Enforce request body size limits.
|
|
333
|
+
- Time out slow upstream calls.
|
|
334
|
+
|
|
335
|
+
Local development can set:
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
VALIRON_ALLOW_INSECURE_UPSTREAMS=true
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Only use this for local testing. Do not enable it in production.
|
|
342
|
+
|
|
343
|
+
## Production Environment Variables
|
|
344
|
+
|
|
345
|
+
Render / edge proxy:
|
|
346
|
+
|
|
347
|
+
| Variable | Required | Purpose |
|
|
348
|
+
|----------|----------|---------|
|
|
349
|
+
| `VALIRON_SECRET_ENCRYPTION_KEY` | Required for upstream auth | AES-256-GCM key for storing upstream secrets. |
|
|
350
|
+
| `X402_RECEIVING_ADDRESS` | Required for paid x402 without per-endpoint payout | Default payout wallet. Per-endpoint `payoutAddress` can also be used. |
|
|
351
|
+
| `X402_FACILITATOR_URL` | Optional | Defaults to `https://facilitator.payai.network`. |
|
|
352
|
+
| `MPP_SECRET_KEY` | Required for MPP | Secret used by `mppx` to sign/verify payment challenges. |
|
|
353
|
+
| `MPP_TEMPO_CURRENCY` | Optional | Override Tempo currency. Defaults come from `mppx`. |
|
|
354
|
+
| `MPP_TEMPO_CHAIN_ID` | Optional | Fallback Tempo chain ID when not set by endpoint. |
|
|
355
|
+
| `MPP_TEMPO_TESTNET` | Optional | Fallback testnet flag when not set by endpoint. |
|
|
356
|
+
| `MPP_TEMPO_WAIT_FOR_CONFIRMATION` | Optional | Defaults to `true`; set `false` only for specific test flows. |
|
|
357
|
+
| `MPP_REALM` | Optional | Defaults to `Valiron`. |
|
|
358
|
+
| `VALIRON_WRAPPER_MAX_BODY_BYTES` | Optional | Request body size limit. |
|
|
359
|
+
| `VALIRON_WRAPPER_UPSTREAM_TIMEOUT_MS` | Optional | Upstream request timeout. |
|
|
360
|
+
|
|
361
|
+
Vercel / website:
|
|
362
|
+
|
|
363
|
+
| Variable | Required | Purpose |
|
|
364
|
+
|----------|----------|---------|
|
|
365
|
+
| `NEXT_PUBLIC_API_URL` | Recommended | Edge proxy base URL used by the dashboard. |
|
|
366
|
+
|
|
367
|
+
## Local Test Example
|
|
368
|
+
|
|
369
|
+
Run the local x402 test server:
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
pnpm --filter x402-test-server dev
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Run the edge proxy with local upstreams allowed:
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
VALIRON_ALLOW_INSECURE_UPSTREAMS=true pnpm --filter edge-proxy dev
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
Create a free test wrapper pointing at:
|
|
382
|
+
|
|
383
|
+
```text
|
|
384
|
+
http://localhost:4021
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
with public path:
|
|
388
|
+
|
|
389
|
+
```text
|
|
390
|
+
/health
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Then call:
|
|
394
|
+
|
|
395
|
+
```bash
|
|
396
|
+
curl -i http://localhost:3005/wrap/{operatorId}/health
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
For paid x402 tests, use the buyer test client with a funded buyer key and the configured facilitator/network.
|
|
400
|
+
|
|
401
|
+
## Current Limits
|
|
402
|
+
|
|
403
|
+
The first wrapper release supports:
|
|
404
|
+
|
|
405
|
+
- Per-call x402 payments.
|
|
406
|
+
- Per-call MPP Tempo charge payments.
|
|
407
|
+
- Free wrappers.
|
|
408
|
+
- Optional trust checks.
|
|
409
|
+
- Optional upstream auth injection.
|
|
410
|
+
- Per-endpoint rate limits.
|
|
411
|
+
|
|
412
|
+
It does not yet support:
|
|
413
|
+
|
|
414
|
+
- MPP sessions or subscriptions.
|
|
415
|
+
- Multi-upstream routing.
|
|
416
|
+
- Cross-protocol fallback on a single endpoint.
|
|
417
|
+
- Non-HTTPS production upstreams.
|