x402-trust-layer 5.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/CHANGELOG.md +55 -0
- package/DEPLOY.md +53 -0
- package/Dockerfile +30 -0
- package/LICENSE +21 -0
- package/README.md +294 -0
- package/dist/agents/a2a-payment.d.ts +37 -0
- package/dist/agents/a2a-payment.js +105 -0
- package/dist/agents/agent-escrow.d.ts +30 -0
- package/dist/agents/agent-escrow.js +23 -0
- package/dist/agents/agent-verify.d.ts +15 -0
- package/dist/agents/agent-verify.js +112 -0
- package/dist/agents/api-router.d.ts +32 -0
- package/dist/agents/api-router.js +228 -0
- package/dist/agents/attestation-registry.d.ts +35 -0
- package/dist/agents/attestation-registry.js +76 -0
- package/dist/agents/audition-coach.d.ts +45 -0
- package/dist/agents/audition-coach.js +257 -0
- package/dist/agents/bedrock-bridge.d.ts +3 -0
- package/dist/agents/bedrock-bridge.js +60 -0
- package/dist/agents/budget-allocator.d.ts +24 -0
- package/dist/agents/budget-allocator.js +31 -0
- package/dist/agents/compliance-ledger.d.ts +66 -0
- package/dist/agents/compliance-ledger.js +80 -0
- package/dist/agents/dispute-resolver.d.ts +62 -0
- package/dist/agents/dispute-resolver.js +124 -0
- package/dist/agents/evidence-locker.d.ts +30 -0
- package/dist/agents/evidence-locker.js +47 -0
- package/dist/agents/facilitator-failover.d.ts +15 -0
- package/dist/agents/facilitator-failover.js +18 -0
- package/dist/agents/identity-gate.d.ts +20 -0
- package/dist/agents/identity-gate.js +79 -0
- package/dist/agents/mandate-compiler.d.ts +51 -0
- package/dist/agents/mandate-compiler.js +73 -0
- package/dist/agents/mandate-diff.d.ts +41 -0
- package/dist/agents/mandate-diff.js +170 -0
- package/dist/agents/market-buy-advisor.d.ts +65 -0
- package/dist/agents/market-buy-advisor.js +234 -0
- package/dist/agents/merchant-trust.d.ts +38 -0
- package/dist/agents/merchant-trust.js +171 -0
- package/dist/agents/mpp-session-broker.d.ts +27 -0
- package/dist/agents/mpp-session-broker.js +29 -0
- package/dist/agents/mpp-session-v2.d.ts +76 -0
- package/dist/agents/mpp-session-v2.js +269 -0
- package/dist/agents/payment-intent-compiler.d.ts +21 -0
- package/dist/agents/payment-intent-compiler.js +45 -0
- package/dist/agents/pipeline-execute.d.ts +40 -0
- package/dist/agents/pipeline-execute.js +100 -0
- package/dist/agents/pipeline-trust-v2.d.ts +31 -0
- package/dist/agents/pipeline-trust-v2.js +111 -0
- package/dist/agents/pre-x402-guard.d.ts +35 -0
- package/dist/agents/pre-x402-guard.js +84 -0
- package/dist/agents/quality-escrow-semantic.d.ts +88 -0
- package/dist/agents/quality-escrow-semantic.js +137 -0
- package/dist/agents/quality-escrow.d.ts +65 -0
- package/dist/agents/quality-escrow.js +104 -0
- package/dist/agents/quality-monitor.d.ts +32 -0
- package/dist/agents/quality-monitor.js +77 -0
- package/dist/agents/rail-optimizer.d.ts +33 -0
- package/dist/agents/rail-optimizer.js +133 -0
- package/dist/agents/receipt-auditor.d.ts +14 -0
- package/dist/agents/receipt-auditor.js +145 -0
- package/dist/agents/refund-arbiter.d.ts +24 -0
- package/dist/agents/refund-arbiter.js +70 -0
- package/dist/agents/research-brief.d.ts +14 -0
- package/dist/agents/research-brief.js +66 -0
- package/dist/agents/risk-gate.d.ts +11 -0
- package/dist/agents/risk-gate.js +78 -0
- package/dist/agents/settlement-graph.d.ts +16 -0
- package/dist/agents/settlement-graph.js +38 -0
- package/dist/agents/spend-governor.d.ts +2 -0
- package/dist/agents/spend-governor.js +70 -0
- package/dist/agents/trust-network.d.ts +138 -0
- package/dist/agents/trust-network.js +244 -0
- package/dist/agents/x402-proxy.d.ts +32 -0
- package/dist/agents/x402-proxy.js +90 -0
- package/dist/client/demo-alchemy-live.d.ts +1 -0
- package/dist/client/demo-alchemy-live.js +226 -0
- package/dist/client/demo-tail.d.ts +1 -0
- package/dist/client/demo-tail.js +100 -0
- package/dist/client/demo.d.ts +1 -0
- package/dist/client/demo.js +293 -0
- package/dist/config.d.ts +94 -0
- package/dist/config.js +223 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +389 -0
- package/dist/lib/agent-response.d.ts +14 -0
- package/dist/lib/agent-response.js +13 -0
- package/dist/lib/agentic-gateways.d.ts +5 -0
- package/dist/lib/agentic-gateways.js +15 -0
- package/dist/lib/agentic-probes.d.ts +10 -0
- package/dist/lib/agentic-probes.js +49 -0
- package/dist/lib/alchemy-x402-fetch.d.ts +16 -0
- package/dist/lib/alchemy-x402-fetch.js +95 -0
- package/dist/lib/apply-verifier-body.d.ts +7 -0
- package/dist/lib/apply-verifier-body.js +179 -0
- package/dist/lib/attestation.d.ts +30 -0
- package/dist/lib/attestation.js +107 -0
- package/dist/lib/bazaar-extension.d.ts +15 -0
- package/dist/lib/bazaar-extension.js +265 -0
- package/dist/lib/bazaar.d.ts +100 -0
- package/dist/lib/bazaar.js +341 -0
- package/dist/lib/certified-sellers.d.ts +41 -0
- package/dist/lib/certified-sellers.js +129 -0
- package/dist/lib/chains.d.ts +20 -0
- package/dist/lib/chains.js +78 -0
- package/dist/lib/db-persistence.d.ts +7 -0
- package/dist/lib/db-persistence.js +65 -0
- package/dist/lib/db.d.ts +5 -0
- package/dist/lib/db.js +113 -0
- package/dist/lib/discovery-page.d.ts +2 -0
- package/dist/lib/discovery-page.js +71 -0
- package/dist/lib/ecosystem-telemetry.d.ts +20 -0
- package/dist/lib/ecosystem-telemetry.js +80 -0
- package/dist/lib/erc8004/agent-card.d.ts +34 -0
- package/dist/lib/erc8004/agent-card.js +151 -0
- package/dist/lib/erc8004/cache.d.ts +3 -0
- package/dist/lib/erc8004/cache.js +17 -0
- package/dist/lib/erc8004/constants.d.ts +22 -0
- package/dist/lib/erc8004/constants.js +35 -0
- package/dist/lib/erc8004/registry.d.ts +19 -0
- package/dist/lib/erc8004/registry.js +171 -0
- package/dist/lib/erc8004/resolve-agent.d.ts +7 -0
- package/dist/lib/erc8004/resolve-agent.js +70 -0
- package/dist/lib/erc8004/trust-score.d.ts +33 -0
- package/dist/lib/erc8004/trust-score.js +136 -0
- package/dist/lib/escrow-ledger.d.ts +14 -0
- package/dist/lib/escrow-ledger.js +54 -0
- package/dist/lib/escrow-unified.d.ts +15 -0
- package/dist/lib/escrow-unified.js +28 -0
- package/dist/lib/facilitator-extra.d.ts +13 -0
- package/dist/lib/facilitator-extra.js +52 -0
- package/dist/lib/facilitators.d.ts +20 -0
- package/dist/lib/facilitators.js +89 -0
- package/dist/lib/host-policy.d.ts +4 -0
- package/dist/lib/host-policy.js +20 -0
- package/dist/lib/idempotency.d.ts +4 -0
- package/dist/lib/idempotency.js +120 -0
- package/dist/lib/ledger.d.ts +2 -0
- package/dist/lib/ledger.js +17 -0
- package/dist/lib/logger.d.ts +6 -0
- package/dist/lib/logger.js +24 -0
- package/dist/lib/mandate-vc.d.ts +20 -0
- package/dist/lib/mandate-vc.js +25 -0
- package/dist/lib/mandate.d.ts +44 -0
- package/dist/lib/mandate.js +190 -0
- package/dist/lib/marketplace.d.ts +7 -0
- package/dist/lib/marketplace.js +127 -0
- package/dist/lib/migrations.d.ts +2 -0
- package/dist/lib/migrations.js +130 -0
- package/dist/lib/nonce-store.d.ts +6 -0
- package/dist/lib/nonce-store.js +109 -0
- package/dist/lib/openapi-agentcash.d.ts +5 -0
- package/dist/lib/openapi-agentcash.js +288 -0
- package/dist/lib/openapi-meta.d.ts +5 -0
- package/dist/lib/openapi-meta.js +235 -0
- package/dist/lib/otel.d.ts +2 -0
- package/dist/lib/otel.js +25 -0
- package/dist/lib/paid-resource-url.d.ts +6 -0
- package/dist/lib/paid-resource-url.js +47 -0
- package/dist/lib/parse-with-verifier-fallback.d.ts +3 -0
- package/dist/lib/parse-with-verifier-fallback.js +13 -0
- package/dist/lib/payment-request-context.d.ts +10 -0
- package/dist/lib/payment-request-context.js +5 -0
- package/dist/lib/payment-response.d.ts +13 -0
- package/dist/lib/payment-response.js +39 -0
- package/dist/lib/payto-guard.d.ts +10 -0
- package/dist/lib/payto-guard.js +20 -0
- package/dist/lib/probe.d.ts +29 -0
- package/dist/lib/probe.js +157 -0
- package/dist/lib/problem-detail.d.ts +10 -0
- package/dist/lib/problem-detail.js +14 -0
- package/dist/lib/rate-limit.d.ts +12 -0
- package/dist/lib/rate-limit.js +126 -0
- package/dist/lib/replay-middleware.d.ts +3 -0
- package/dist/lib/replay-middleware.js +27 -0
- package/dist/lib/response-guard.d.ts +5 -0
- package/dist/lib/response-guard.js +40 -0
- package/dist/lib/safe-fetch.d.ts +5 -0
- package/dist/lib/safe-fetch.js +19 -0
- package/dist/lib/security.d.ts +13 -0
- package/dist/lib/security.js +61 -0
- package/dist/lib/semantic-judge.d.ts +14 -0
- package/dist/lib/semantic-judge.js +107 -0
- package/dist/lib/semantic-judge.test.d.ts +1 -0
- package/dist/lib/semantic-judge.test.js +11 -0
- package/dist/lib/ssrf.d.ts +10 -0
- package/dist/lib/ssrf.js +130 -0
- package/dist/lib/ssrf.test.d.ts +1 -0
- package/dist/lib/ssrf.test.js +16 -0
- package/dist/lib/suite-catalog.d.ts +83 -0
- package/dist/lib/suite-catalog.js +131 -0
- package/dist/lib/telemetry.d.ts +5 -0
- package/dist/lib/telemetry.js +37 -0
- package/dist/lib/verifier-fast-path.d.ts +10 -0
- package/dist/lib/verifier-fast-path.js +44 -0
- package/dist/lib/verifier-probe-protocol.d.ts +7 -0
- package/dist/lib/verifier-probe-protocol.js +115 -0
- package/dist/lib/verify-examples.d.ts +2 -0
- package/dist/lib/verify-examples.js +438 -0
- package/dist/lib/version.d.ts +2 -0
- package/dist/lib/version.js +2 -0
- package/dist/lib/webhook-auth.d.ts +3 -0
- package/dist/lib/webhook-auth.js +34 -0
- package/dist/lib/webhook-routes.d.ts +2 -0
- package/dist/lib/webhook-routes.js +112 -0
- package/dist/lib/webhooks.d.ts +23 -0
- package/dist/lib/webhooks.js +123 -0
- package/dist/lib/webhooks.test.d.ts +1 -0
- package/dist/lib/webhooks.test.js +16 -0
- package/dist/lib/x402-client-options.d.ts +28 -0
- package/dist/lib/x402-client-options.js +138 -0
- package/dist/lib/x402-headers.d.ts +10 -0
- package/dist/lib/x402-headers.js +27 -0
- package/dist/lib/x402-paid.d.ts +5 -0
- package/dist/lib/x402-paid.js +252 -0
- package/dist/lib/x402-payment-replay.d.ts +22 -0
- package/dist/lib/x402-payment-replay.js +57 -0
- package/dist/lib/x402gle-host-verify.d.ts +3 -0
- package/dist/lib/x402gle-host-verify.js +27 -0
- package/dist/protocol/agent-passport.d.ts +34 -0
- package/dist/protocol/agent-passport.js +44 -0
- package/dist/protocol/compliance-v2.d.ts +21 -0
- package/dist/protocol/compliance-v2.js +19 -0
- package/dist/protocol/credit-bureau.d.ts +18 -0
- package/dist/protocol/credit-bureau.js +44 -0
- package/dist/protocol/crypto.d.ts +6 -0
- package/dist/protocol/crypto.js +41 -0
- package/dist/protocol/escrow-fsm.d.ts +33 -0
- package/dist/protocol/escrow-fsm.js +99 -0
- package/dist/protocol/fraud-engine.d.ts +28 -0
- package/dist/protocol/fraud-engine.js +77 -0
- package/dist/protocol/observability.d.ts +14 -0
- package/dist/protocol/observability.js +21 -0
- package/dist/protocol/pipeline-full-trust.d.ts +40 -0
- package/dist/protocol/pipeline-full-trust.js +96 -0
- package/dist/protocol/proof-of-execution.d.ts +36 -0
- package/dist/protocol/proof-of-execution.js +48 -0
- package/dist/protocol/reasoning-audit.d.ts +27 -0
- package/dist/protocol/reasoning-audit.js +51 -0
- package/dist/protocol/replay-guard.d.ts +28 -0
- package/dist/protocol/replay-guard.js +76 -0
- package/dist/protocol/replay-guard.test.d.ts +1 -0
- package/dist/protocol/replay-guard.test.js +10 -0
- package/dist/protocol/security-audit.d.ts +18 -0
- package/dist/protocol/security-audit.js +45 -0
- package/dist/protocol/store.d.ts +5 -0
- package/dist/protocol/store.js +59 -0
- package/dist/protocol/threat-catalog.d.ts +13 -0
- package/dist/protocol/threat-catalog.js +75 -0
- package/dist/protocol/trust-oracle.d.ts +23 -0
- package/dist/protocol/trust-oracle.js +30 -0
- package/dist/protocol/trust-score-v2.d.ts +33 -0
- package/dist/protocol/trust-score-v2.js +78 -0
- package/dist/protocol/zk-proofs.d.ts +24 -0
- package/dist/protocol/zk-proofs.js +32 -0
- package/dist/routes/a2a-agent-card.d.ts +3 -0
- package/dist/routes/a2a-agent-card.js +28 -0
- package/dist/routes/catalog.d.ts +5 -0
- package/dist/routes/catalog.js +47 -0
- package/dist/routes/register-all.d.ts +3 -0
- package/dist/routes/register-all.js +1240 -0
- package/dist/routes/schemas.d.ts +83 -0
- package/dist/routes/schemas.js +38 -0
- package/dist/routes/shared.d.ts +16 -0
- package/dist/routes/shared.js +27 -0
- package/dist/routes-protocol.d.ts +10 -0
- package/dist/routes-protocol.js +322 -0
- package/dist/routes.d.ts +2 -0
- package/dist/routes.js +2 -0
- package/dist/types.d.ts +66 -0
- package/dist/types.js +1 -0
- package/openapi.json +7940 -0
- package/package.json +124 -0
- package/public/.well-known/ai-plugin.json +12 -0
- package/public/assets/aegis-logo-blue.png +0 -0
- package/public/assets/aegis-logo-gold.png +0 -0
- package/public/assets/aegis-logo-green.png +0 -0
- package/public/assets/aegis-logo-purple.png +0 -0
- package/public/assets/aegis-logo-red.png +0 -0
- package/public/assets/aegis-logo-white.png +0 -0
- package/public/assets/aegis-logo.png +0 -0
- package/public/assets/x402-trustlayer-logo.png +0 -0
- package/public/assets/x402-trustlayer-logo.svg +5 -0
- package/public/data/agents.json +1528 -0
- package/public/index.html +198 -0
- package/public/landing.css +342 -0
- package/public/landing.js +405 -0
- package/public/llms-full.txt +582 -0
- package/public/llms.txt +132 -0
- package/public/skill.md +135 -0
- package/railway.toml +9 -0
- package/scripts/docker-entrypoint.sh +7 -0
- package/scripts/patch-facilitator-timeout.mjs +61 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
4
|
+
|
|
5
|
+
## [5.1.0] - 2026-06-03
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **58 paid routes** including Agent Trust Protocol v4 (`/api/protocol/*`), A2A execute, Bedrock preflight.
|
|
10
|
+
- Production Docker: non-root user, `scripts/docker-entrypoint.sh` (Railway volume `chown`), `DATA_DIR=/app/data`.
|
|
11
|
+
- Docs: [RAILWAY-DEPLOY.md](docs/RAILWAY-DEPLOY.md), [PRODUCTION-HARDENING.md](docs/PRODUCTION-HARDENING.md), [X402GLE-COOLDOWN.md](docs/X402GLE-COOLDOWN.md).
|
|
12
|
+
- `npm run sync:public` — sync `public/data/agents.json`, `llms.txt`, `skill.md` from catalog + OpenAPI.
|
|
13
|
+
- Health/deploy metadata: `GET /health` includes `deploy`, `documentation`, `facilitator`, SQLite path.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Routes modularized under `src/routes/` (`register-all.ts`, `catalog.ts`, `schemas.ts`, `shared.ts`).
|
|
18
|
+
- Landing site and agent docs updated to 58 endpoints; npm package `x402-trust-layer@5.1.0`.
|
|
19
|
+
|
|
20
|
+
## [3.1.0] - 2026-05-19
|
|
21
|
+
|
|
22
|
+
### Security
|
|
23
|
+
|
|
24
|
+
- SSRF hardening: deny private/metadata/reserved hosts before outbound `fetch`; probes no longer follow redirects.
|
|
25
|
+
- Attestations signed with server-only `ATTESTATION_HMAC_SECRET` (HMAC-SHA256); removed public-`payTo` signing.
|
|
26
|
+
- Verifier probe IDs gated behind `ALLOW_VERIFIER_PROBE_IDS=1` (exact `att_verifier_probe_example` only).
|
|
27
|
+
- Host allow/block lists use exact/subdomain matching (no substring bypass).
|
|
28
|
+
- x402gle challenge token removed from global response headers.
|
|
29
|
+
- Paid resource URLs canonicalized in production (forged `Host` ignored off localhost).
|
|
30
|
+
- Rate limiting on `/api/*` (default 120 req/min/IP).
|
|
31
|
+
- Production 500 responses no longer leak exception messages.
|
|
32
|
+
- Solana receipt auditor fails closed until on-chain verification exists.
|
|
33
|
+
- Verifier example bodies cannot override `targetUrl`, `policy`, or `origin`.
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- Demo client: Solana RPC override, payer/receive wallet guard, Base payment preference.
|
|
38
|
+
- x402 resource URL mismatch for local demo vs `PUBLIC_BASE_URL`.
|
|
39
|
+
- OpenAPI lists 24 paid paths only (free `/health`, `/.well-known/x402` omitted from `paths`).
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- `docs/ARCHITECTURE.md`, `CONTRIBUTING.md`, expanded `docs/SECURITY.md`.
|
|
44
|
+
- GitHub Actions CI: typecheck, bazaar verify, production 402 probe.
|
|
45
|
+
- `docs/DEPLOY-CHECKLIST.md`, `docs/ROADMAP.md`.
|
|
46
|
+
- MIT `LICENSE`, package metadata (author, repository).
|
|
47
|
+
|
|
48
|
+
## [3.0.0] - 2026-05
|
|
49
|
+
|
|
50
|
+
- 24 paid x402 routes: buy-advisor, audition-coach, proxy, guard, pipeline, MPP v2, attestations.
|
|
51
|
+
- Multi-chain Base + Solana via Dexter facilitator.
|
|
52
|
+
- Agentic Market / OpenAPI / Bazaar discovery.
|
|
53
|
+
|
|
54
|
+
[5.1.0]: https://github.com/mimranchohan/x402-trust-layer/compare/v5.0.0...v5.1.0
|
|
55
|
+
[3.1.0]: https://github.com/mimranchohan/x402-trust-layer/compare/v3.0.0...v3.1.0
|
package/DEPLOY.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Deployment Guide
|
|
2
|
+
|
|
3
|
+
Deploy **x402 Trust Layer v5.1** (58 paid endpoints) to Railway via Docker.
|
|
4
|
+
|
|
5
|
+
**Canonical checklist:** [docs/RAILWAY-DEPLOY.md](docs/RAILWAY-DEPLOY.md)
|
|
6
|
+
**Production hardening:** [docs/PRODUCTION-HARDENING.md](docs/PRODUCTION-HARDENING.md)
|
|
7
|
+
|
|
8
|
+
## Prerequisites
|
|
9
|
+
|
|
10
|
+
- GitHub: https://github.com/mimranchohan/x402-trust-layer
|
|
11
|
+
- Solana + Base (+ optional Polygon) USDC receive wallets
|
|
12
|
+
- Railway account
|
|
13
|
+
|
|
14
|
+
## Railway (recommended)
|
|
15
|
+
|
|
16
|
+
`railway.toml` uses `builder = "DOCKERFILE"`. The image runs `scripts/docker-entrypoint.sh` so SQLite can write to a volume at **`/app/data`** (not `/app`).
|
|
17
|
+
|
|
18
|
+
### Variables
|
|
19
|
+
|
|
20
|
+
| Variable | Required | Value |
|
|
21
|
+
|----------|----------|--------|
|
|
22
|
+
| `PAY_TO_ADDRESS` | **Yes** | Solana USDC receive |
|
|
23
|
+
| `PAY_TO_EVM` | **Yes** | EVM USDC receive |
|
|
24
|
+
| `NETWORKS` | **Yes** | `base,solana,polygon` |
|
|
25
|
+
| `ATTESTATION_HMAC_SECRET` | **Yes** | `openssl rand -hex 32` |
|
|
26
|
+
| `PUBLIC_BASE_URL` | **Yes** (custom domain) | `https://x402trustlayer.xyz` |
|
|
27
|
+
| `DATA_DIR` | No | `/app/data` (default; match volume mount) |
|
|
28
|
+
| `FACILITATOR_URL` | No | `https://x402.dexter.cash` |
|
|
29
|
+
|
|
30
|
+
**Never** put payer private keys on Railway.
|
|
31
|
+
|
|
32
|
+
### Volume
|
|
33
|
+
|
|
34
|
+
Mount **`/app/data`** only. See troubleshooting in [docs/RAILWAY-DEPLOY.md](docs/RAILWAY-DEPLOY.md) for `dist/index.js` and `SQLITE_CANTOPEN` errors.
|
|
35
|
+
|
|
36
|
+
### Verify
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
curl https://x402trustlayer.xyz/health
|
|
40
|
+
npm run probe:production
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## npm package
|
|
44
|
+
|
|
45
|
+
Publish or install the server package:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install x402-trust-layer
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Registry: https://www.npmjs.com/package/x402-trust-layer
|
|
52
|
+
|
|
53
|
+
Client helpers: `packages/x402-preflight`, `packages/trust-layer-mcp`.
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
FROM node:22-alpine AS build
|
|
2
|
+
RUN apk add --no-cache python3 make g++
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
COPY package.json package-lock.json ./
|
|
5
|
+
COPY scripts/patch-facilitator-timeout.mjs scripts/patch-facilitator-timeout.mjs
|
|
6
|
+
RUN npm ci
|
|
7
|
+
COPY tsconfig.json openapi.json ./
|
|
8
|
+
COPY src ./src
|
|
9
|
+
RUN npm run build
|
|
10
|
+
|
|
11
|
+
FROM node:22-alpine
|
|
12
|
+
RUN apk add --no-cache su-exec
|
|
13
|
+
RUN addgroup -S app && adduser -S app -G app
|
|
14
|
+
WORKDIR /app
|
|
15
|
+
ENV NODE_ENV=production
|
|
16
|
+
COPY package.json package-lock.json ./
|
|
17
|
+
COPY scripts/patch-facilitator-timeout.mjs scripts/patch-facilitator-timeout.mjs
|
|
18
|
+
RUN npm ci --omit=dev
|
|
19
|
+
COPY --from=build /app/dist ./dist
|
|
20
|
+
COPY openapi.json ./
|
|
21
|
+
COPY public ./public
|
|
22
|
+
RUN mkdir -p /app/data && chown -R app:app /app
|
|
23
|
+
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
|
24
|
+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
25
|
+
ENV DATA_DIR=/app/data
|
|
26
|
+
EXPOSE 3402
|
|
27
|
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s \
|
|
28
|
+
CMD node -e "const http=require('http');const p=process.env.PORT||3402;http.get('http://127.0.0.1:'+p+'/health',r=>{process.exit(r.statusCode===200?0:1)}).on('error',()=>process.exit(1))"
|
|
29
|
+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
|
30
|
+
CMD ["node", "dist/index.js"]
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mimran Chohan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="public/assets/x402-trustlayer-logo.png" alt="x402 Trust Layer" width="280" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">x402 Trust Layer</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center"><strong>The trust layer for agent payments.</strong><br/>
|
|
8
|
+
<code>x402trustlayer.xyz</code> · Guard · Attest · Comply · Audit</p>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://x402trustlayer.xyz"><img src="https://img.shields.io/badge/x402%20Trust%20Layer-live-16C7C0" alt="live"/></a>
|
|
12
|
+
<a href="https://x402gle.com/servers/x402trustlayer.xyz"><img src="https://img.shields.io/badge/x402gle-listed-16C7C0" alt="x402gle"/></a>
|
|
13
|
+
<a href="https://dexter.cash/sellers/9c7tE587KpGYBjiNQrjw3nGvxQHhSYKU4Ba6WRgQsHkt"><img src="https://img.shields.io/badge/Dexter-seller-green" alt="Dexter"/></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/x402-trust-layer"><img src="https://img.shields.io/badge/npm-x402--trust--layer-CB3837" alt="npm"/></a>
|
|
15
|
+
<a href="https://github.com/mimranchohan/x402-trust-layer"><img src="https://img.shields.io/badge/GitHub-x402--trust--layer-24292f" alt="github"/></a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
> **x402 Trust Layer** *(x402 Agent Suite Pro)* — **58 paid x402 APIs** for guard,
|
|
21
|
+
> attestation, compliance, settlement, and **Agent Trust Protocol v4**. Live at **https://x402trustlayer.xyz**
|
|
22
|
+
|
|
23
|
+
A control plane for autonomous agent commerce. Fifty-eight paid x402 APIs that an
|
|
24
|
+
AI agent calls *before, during, and after* it spends money — to decide whether a
|
|
25
|
+
merchant is trustworthy, whether a payment is allowed, which rail is cheapest, and
|
|
26
|
+
whether the response it paid for was actually worth it. Everything settles in USDC
|
|
27
|
+
over the [Dexter facilitator](https://x402.dexter.cash), on Base or Solana, for a
|
|
28
|
+
few cents a call.
|
|
29
|
+
|
|
30
|
+
**Live:** https://x402trustlayer.xyz *
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### The four layers
|
|
34
|
+
|
|
35
|
+
| | Layer | Does | Key endpoints |
|
|
36
|
+
|---|-------|------|---------------|
|
|
37
|
+
| **01** | **Guard** | Preflight spend / identity / risk before any payment | `/guard/pre-x402` · `/x402/proxy` |
|
|
38
|
+
| **02** | **Attestation** | Issue, verify & register agent credentials and mandates | `/attestation/*` · `/mandate/*` |
|
|
39
|
+
| **03** | **Compliance** | Ledgers, evidence bundles, disputes, refunds | `/compliance/ledger` · `/dispute/resolve` · `/refund-arbiter` |
|
|
40
|
+
| **04** | **Settlement Ops** | Rail routing, MPP sessions, escrow, receipt audit | `/rail-optimizer` · `/mpp/session` · `/receipt-auditor` |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Why this exists
|
|
45
|
+
|
|
46
|
+
The agentic-payments stack has matured fast — Visa shipped a CLI that lets agents
|
|
47
|
+
pay over card rails, Stripe has MPP on Tempo, Google published AP2, and Coinbase's
|
|
48
|
+
x402 turned any HTTP 402 into a settlement instruction. What's missing is the
|
|
49
|
+
*judgement layer*. An agent can now pay anyone, instantly, with no human in the loop.
|
|
50
|
+
That's exactly the problem.
|
|
51
|
+
|
|
52
|
+
This suite is the missing judgement layer. It answers the questions a careful
|
|
53
|
+
finance team would ask on the agent's behalf, in the milliseconds before money moves:
|
|
54
|
+
|
|
55
|
+
- *Is this merchant real, or is it a wash-traded shell I should avoid?*
|
|
56
|
+
- *Is this payment inside the mandate the human actually authorized?*
|
|
57
|
+
- *Base, Solana, Visa, or Stripe — which rail is cheapest and most disputable here?*
|
|
58
|
+
- *Did I get the data I paid for, or should this be refunded?*
|
|
59
|
+
- *Can I hand my CFO a clean, signed, tax-ready record of everything the fleet spent?*
|
|
60
|
+
|
|
61
|
+
Each answer is its own endpoint, priced per call, and composable into a single
|
|
62
|
+
guarded pipeline.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## What's new (v5.1)
|
|
67
|
+
|
|
68
|
+
- **58 paid routes** — protocol v4 (`/api/protocol/*`), A2A, Bedrock preflight, trust v2 bundles.
|
|
69
|
+
- **Production hardening** — SQLite mandates/idempotency/webhooks, HMAC attestations, SSRF DNS guard, helmet/cors, Vitest, RFC 9457 errors. See [PRODUCTION-HARDENING.md](docs/PRODUCTION-HARDENING.md).
|
|
70
|
+
- **Railway Docker** — volume at `/app/data`, entrypoint fixes permissions, `GET /health` reports `deploy` + `documentation` links.
|
|
71
|
+
- **npm:** [`x402-trust-layer`](https://www.npmjs.com/package/x402-trust-layer) · **GitHub:** [mimranchohan/x402-trust-layer](https://github.com/mimranchohan/x402-trust-layer)
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm run sync:public # refresh public/data/agents.json, llms.txt, skill.md
|
|
75
|
+
npm run ci # before deploy
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Proof it works
|
|
81
|
+
|
|
82
|
+
This isn't a mock. As of the last release every route was exercised with **real,
|
|
83
|
+
on-chain USDC settlement on Base**, and the whole origin is indexed on x402scan:
|
|
84
|
+
|
|
85
|
+
- **OpenAPI / discovery** — 58 paid paths; `npm run verify:bazaar` + `npm run probe:production`.
|
|
86
|
+
- **Live paid pass** — endpoints return `402` on unpaid probes; settlement via [Dexter](https://x402.dexter.cash) / OpenDexter.
|
|
87
|
+
- **x402gle auditions** (live, paid, response-scored):
|
|
88
|
+
- `POST /api/pipeline/execute` → **93** · [audition](https://x402gle.com/audition/04540084-c255-44fd-957a-1487eafaa23d)
|
|
89
|
+
- `POST /api/mpp/session-plan` → **86** · [audition](https://x402gle.com/audition/4e16c507-5c6e-4b9e-96e2-a1cba9732a55)
|
|
90
|
+
- `POST /api/quality-monitor/probe` → **82** · [audition](https://x402gle.com/audition/fbad6aad-d2f8-4ccb-9684-3f6474c03784)
|
|
91
|
+
|
|
92
|
+
Want to run the pass yourself? See **[docs/TESTING.md](docs/TESTING.md)** — it has a
|
|
93
|
+
ready-to-send request body for every single endpoint.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## The three things most agents need
|
|
98
|
+
|
|
99
|
+
You rarely need all 58 routes at once. For the common case, reach for one of these:
|
|
100
|
+
|
|
101
|
+
| Endpoint | Price | Use it when |
|
|
102
|
+
|----------|-------|-------------|
|
|
103
|
+
| `POST /api/x402/proxy` | **$0.08** | Default preflight before any external `x402_fetch` — policy + risk + attestation in one call |
|
|
104
|
+
| `POST /api/guard/pre-x402` | **$0.05** | Same policy bundle, no downstream probe |
|
|
105
|
+
| `POST /api/pipeline/execute` | **$0.25** | Full orchestration: pick a marketplace API, guard it, route the payment, return a plan |
|
|
106
|
+
|
|
107
|
+
Spend-governor, identity-gate, and risk-gate run *inside* guard and proxy. Call them
|
|
108
|
+
on their own only when you're debugging a specific decision.
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// The 3-line integration most fleets ship
|
|
112
|
+
const pre = await x402Fetch(`${BASE}/api/x402/proxy`, {
|
|
113
|
+
method: "POST",
|
|
114
|
+
body: JSON.stringify({ agentId, walletAddress, targetUrl, estimatedCostUsdc: 0.05, policy }),
|
|
115
|
+
});
|
|
116
|
+
if (!(await pre.json()).allowed) throw new Error("blocked by policy");
|
|
117
|
+
// → now x402_check / x402_fetch the target, then POST /api/receipt-auditor/verify
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## The full catalog — 58 paid APIs
|
|
123
|
+
|
|
124
|
+
Canonical list: **`GET /openapi.json`**, **`GET /api/agents`**, or **[docs/AGENT-CATALOG.md](docs/AGENT-CATALOG.md)**. Includes **Agent Trust Protocol v4** (`POST /api/protocol/*`). Short version:
|
|
125
|
+
|
|
126
|
+
### Tier-1 — enterprise control plane
|
|
127
|
+
|
|
128
|
+
The newest layer, built for the Visa CLI / AP2 era: trust, verifiable intent,
|
|
129
|
+
cross-rail routing, compliance, disputes, and quality-gated settlement.
|
|
130
|
+
|
|
131
|
+
| Endpoint | Price | What it does |
|
|
132
|
+
|----------|-------|--------------|
|
|
133
|
+
| `POST /api/merchant-trust/score` | $0.06 | Know-Your-Merchant score: wash-trading, verified ratio, latency, live probe → pay / caution / avoid |
|
|
134
|
+
| `POST /api/mandate/compile` | $0.08 | Turns a human intent into a signed, scoped AP2-style payment mandate |
|
|
135
|
+
| `POST /api/mandate/verify` | $0.02 | Checks a proposed payment against a mandate's signature and scope |
|
|
136
|
+
| `POST /api/rail-optimizer/route` | $0.04 | Picks the cheapest, most disputable rail across Visa CLI / Stripe MPP / Circle / Base / Solana |
|
|
137
|
+
| `POST /api/compliance/ledger` | $0.12 | CFO/SOC2-grade spend reconciliation with policy-violation flags |
|
|
138
|
+
| `POST /api/dispute/resolve` | $0.10 | Builds a Visa chargeback dossier or an on-chain refund claim |
|
|
139
|
+
| `POST /api/quality-escrow/settle` | $0.10 | Holds payment in escrow, releases only if the response clears a quality bar |
|
|
140
|
+
|
|
141
|
+
### Entry points & orchestration
|
|
142
|
+
|
|
143
|
+
| Endpoint | Price | What it does |
|
|
144
|
+
|----------|-------|--------------|
|
|
145
|
+
| `POST /api/x402/proxy` | $0.08 | One-call preflight: policy + risk + optional probe + attestation |
|
|
146
|
+
| `POST /api/guard/pre-x402` | $0.05 | Combined spend / identity / risk gate |
|
|
147
|
+
| `POST /api/pipeline/execute` | $0.25 | Marketplace pick → guard → route → execution plan |
|
|
148
|
+
| `POST /api/payment-intent/compile` | $0.15 | Compiles a natural-language task into a budgeted payment intent |
|
|
149
|
+
| `POST /api/facilitator/failover` | $0.05 | Health-checks facilitators and picks a live one |
|
|
150
|
+
| `POST /api/mpp/session-plan` | $0.02 | Estimates the cost/shape of a Stripe-MPP-style metered session |
|
|
151
|
+
|
|
152
|
+
### Core gates & utilities
|
|
153
|
+
|
|
154
|
+
| Endpoint | Price | What it does |
|
|
155
|
+
|----------|-------|--------------|
|
|
156
|
+
| `POST /api/spend-governor/check` | $0.03 | Per-call and daily cap enforcement |
|
|
157
|
+
| `POST /api/identity-gate/check` | $0.05 | Wallet tier / network checks before spending |
|
|
158
|
+
| `POST /api/risk-gate/scan` | $0.08 | Target-URL and price sanity scan |
|
|
159
|
+
| `POST /api/router/route` | $0.02 | Finds the best marketplace API for a query |
|
|
160
|
+
| `POST /api/research/brief` | $0.20 | Quick grounded brief, optionally with price data |
|
|
161
|
+
| `POST /api/receipt-auditor/verify` | $0.05 | Verifies a settlement receipt against the expected amount/network |
|
|
162
|
+
|
|
163
|
+
### MPP, attestation, trust & enterprise
|
|
164
|
+
|
|
165
|
+
| Endpoint | Price | What it does |
|
|
166
|
+
|----------|-------|--------------|
|
|
167
|
+
| `POST /api/mpp/session` | $0.03 | Open / close a metered payment session |
|
|
168
|
+
| `POST /api/attestation/issue` | $0.04 | Issues a signed attestation that a payment passed policy |
|
|
169
|
+
| `POST /api/attestation/verify` | $0.02 | Verifies an attestation by id |
|
|
170
|
+
| `GET /api/attestation/registry` | $0.02 | Queries the trust registry of valid attestations |
|
|
171
|
+
| `POST /api/refund-arbiter/evaluate` | $0.08 | Decides whether a weak response merits a refund |
|
|
172
|
+
| `POST /api/settlement-graph/next` | $0.02 | Suggests the next logical endpoint in a workflow |
|
|
173
|
+
| `POST /api/quality-monitor/probe` | $0.03 | Probes a set of URLs for liveness and response quality |
|
|
174
|
+
| `POST /api/budget-allocator/run` | $0.03 | Allocates a shared pool across a fleet by priority |
|
|
175
|
+
| `POST /api/evidence-locker/export` | $0.10 | Exports an immutable evidence bundle of spend records |
|
|
176
|
+
| `POST /api/agent-escrow` | $0.12 | Create / release agent-to-agent escrow |
|
|
177
|
+
|
|
178
|
+
### Seller / buyer tooling
|
|
179
|
+
|
|
180
|
+
| Endpoint | Price | What it does |
|
|
181
|
+
|----------|-------|--------------|
|
|
182
|
+
| `POST /api/market/buy-advisor` | $0.08 | Ranks marketplace APIs before you pay |
|
|
183
|
+
| `POST /api/seller/audition-coach` | $0.06 | Flags OpenAPI/402 problems before a Dexter audition |
|
|
184
|
+
|
|
185
|
+
Every paid response carries a **trust envelope** — `confidence`, `checks_passed`,
|
|
186
|
+
`sources`, and an `accuracy_note` — so the calling agent can reason about how much
|
|
187
|
+
to rely on the answer.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## How to test it
|
|
192
|
+
|
|
193
|
+
Three levels, from free to fully paid. The complete walkthrough with a request body
|
|
194
|
+
for every endpoint is in **[docs/TESTING.md](docs/TESTING.md)**.
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
BASE=https://x402trustlayer.xyz
|
|
198
|
+
|
|
199
|
+
# 1) Free — confirm everything is alive and paywalled
|
|
200
|
+
npm run probe:production
|
|
201
|
+
curl -i -X POST $BASE/api/merchant-trust/score # expect HTTP 402
|
|
202
|
+
|
|
203
|
+
# 2) One paid call (any x402 client / OpenDexter x402_fetch)
|
|
204
|
+
# point it at an endpoint, set a per-call cap, send the example body
|
|
205
|
+
|
|
206
|
+
# 3) Full paid pass — npm run demo (see docs/TESTING.md for per-route bodies)
|
|
207
|
+
npm run demo
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Paid calls need a wallet with a little USDC. Most endpoints cost $0.02–$0.12;
|
|
211
|
+
`pipeline/execute` is the priciest at $0.25. Always set a per-call cap.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Discovery surfaces
|
|
216
|
+
|
|
217
|
+
| URL | Purpose |
|
|
218
|
+
|-----|---------|
|
|
219
|
+
| `GET /openapi.json` | Canonical contract (x402scan / AgentCash read this first) |
|
|
220
|
+
| `GET /.well-known/x402` | Paid resource catalog |
|
|
221
|
+
| `GET /.well-known/x402/v2` | x402 v2 discovery |
|
|
222
|
+
| `GET /llms.txt` · `GET /skill.md` | Agent index (sync via `npm run sync:public`) |
|
|
223
|
+
| `GET /x402/api/services.json` | Bazaar manifest |
|
|
224
|
+
| `GET /api/agents` | Live route list with prices and tiers |
|
|
225
|
+
|
|
226
|
+
Re-register on x402scan any time with `node scripts/register-x402scan.mjs`
|
|
227
|
+
(or the [Add API](https://www.x402scan.com/resources/register) form). Don't register
|
|
228
|
+
`/health` — it isn't payable.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Run it locally
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
git clone https://github.com/mimranchohan/x402-trust-layer.git
|
|
236
|
+
cd x402-trust-layer
|
|
237
|
+
cp .env.example .env
|
|
238
|
+
npm install
|
|
239
|
+
npm run dev
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Multi-chain config (Base-first, Solana enabled):
|
|
243
|
+
|
|
244
|
+
```env
|
|
245
|
+
NETWORKS=base,solana
|
|
246
|
+
PAY_TO_EVM=0xYourEvmWallet
|
|
247
|
+
PAY_TO_ADDRESS=YourSolanaWallet
|
|
248
|
+
FACILITATOR_URL=https://x402.dexter.cash
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Deploy (Railway)
|
|
254
|
+
|
|
255
|
+
Dockerfile + `railway.toml`. Persistent SQLite: volume mount **`/app/data`**, `DATA_DIR=/app/data` (or omit). Do **not** mount `/app` — it hides `dist/index.js`.
|
|
256
|
+
|
|
257
|
+
Full steps: **[docs/RAILWAY-DEPLOY.md](docs/RAILWAY-DEPLOY.md)** · **[DEPLOY.md](DEPLOY.md)**
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
curl https://x402trustlayer.xyz/health # expect db: ok, endpointCount: 58
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## npm
|
|
264
|
+
|
|
265
|
+
| Package | Purpose |
|
|
266
|
+
|---------|---------|
|
|
267
|
+
| [`x402-trust-layer`](https://www.npmjs.com/package/x402-trust-layer) | This server (58 paid APIs) |
|
|
268
|
+
| `x402-agent-suite-preflight` | Client preflight helpers (`packages/x402-preflight`) |
|
|
269
|
+
| `@mimranakb/trust-layer-mcp` | MCP tools (`packages/trust-layer-mcp`) |
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
npm install x402-trust-layer
|
|
273
|
+
npm publish # maintainers only, after version bump
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Docs
|
|
279
|
+
|
|
280
|
+
| Doc | Topic |
|
|
281
|
+
|-----|-------|
|
|
282
|
+
| [RAILWAY-DEPLOY.md](docs/RAILWAY-DEPLOY.md) | Volume mount, env, crash troubleshooting |
|
|
283
|
+
| [PRODUCTION-HARDENING.md](docs/PRODUCTION-HARDENING.md) | Security & data phases 1–8 |
|
|
284
|
+
| [AGENT-CATALOG.md](docs/AGENT-CATALOG.md) | Agent reference — logic, schemas, examples |
|
|
285
|
+
| [TESTING.md](docs/TESTING.md) | Test every endpoint, ready-to-send bodies |
|
|
286
|
+
| [X402GLE-COOLDOWN.md](docs/X402GLE-COOLDOWN.md) | x402gle audition cooldown |
|
|
287
|
+
| [ARCHITECTURE.md](docs/ARCHITECTURE.md) | System design and request lifecycle |
|
|
288
|
+
| [INTEGRATE.md](docs/INTEGRATE.md) | Fleet flow, attestation, the 3-line rule |
|
|
289
|
+
| [MARKETPLACES.md](docs/MARKETPLACES.md) | Dexter + x402scan + Agentic listing |
|
|
290
|
+
| [CHANGELOG.md](CHANGELOG.md) | Release notes |
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
MIT © mimranchohan
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Request, Response } from "express";
|
|
3
|
+
declare const A2APaymentSchema: z.ZodObject<{
|
|
4
|
+
buyerAgentId: z.ZodString;
|
|
5
|
+
sellerAgentId: z.ZodString;
|
|
6
|
+
sellerEndpoint: z.ZodString;
|
|
7
|
+
taskDescription: z.ZodString;
|
|
8
|
+
maxBudgetUsdc: z.ZodNumber;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
buyerAgentId: string;
|
|
11
|
+
sellerEndpoint: string;
|
|
12
|
+
maxBudgetUsdc: number;
|
|
13
|
+
sellerAgentId: string;
|
|
14
|
+
taskDescription: string;
|
|
15
|
+
}, {
|
|
16
|
+
buyerAgentId: string;
|
|
17
|
+
sellerEndpoint: string;
|
|
18
|
+
maxBudgetUsdc: number;
|
|
19
|
+
sellerAgentId: string;
|
|
20
|
+
taskDescription: string;
|
|
21
|
+
}>;
|
|
22
|
+
export type A2APaymentInput = z.infer<typeof A2APaymentSchema>;
|
|
23
|
+
export declare function executeA2APayment(params: A2APaymentInput): Promise<{
|
|
24
|
+
success: boolean;
|
|
25
|
+
sellerResponse: any;
|
|
26
|
+
paymentReceipt: string | null;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function runA2APayment(input: A2APaymentInput): Promise<{
|
|
29
|
+
buyerAgentId: string;
|
|
30
|
+
sellerAgentId: string;
|
|
31
|
+
sellerEndpoint: string;
|
|
32
|
+
success: boolean;
|
|
33
|
+
sellerResponse: any;
|
|
34
|
+
paymentReceipt: string | null;
|
|
35
|
+
} & import("../lib/agent-response.js").AgentTrustMeta>;
|
|
36
|
+
export declare function handleA2APaymentRoute(req: Request, res: Response): Promise<void>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { config } from "../config.js";
|
|
3
|
+
function isProduction() {
|
|
4
|
+
return process.env.NODE_ENV === "production" || !!process.env.RAILWAY_ENVIRONMENT;
|
|
5
|
+
}
|
|
6
|
+
function assertA2AOrchestratorAllowed() {
|
|
7
|
+
if (isProduction() && !config.a2aOrchestratorEnabled) {
|
|
8
|
+
throw new Error("A2A orchestrator disabled in production. Set A2A_ORCHESTRATOR_ENABLED=1 only on dedicated signing hosts.");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
import { agentTrustMeta, withAgentTrust } from "../lib/agent-response.js";
|
|
12
|
+
import { assertSafeOutboundUrl } from "../lib/ssrf.js";
|
|
13
|
+
import { buildX402Fetch } from "../lib/x402-client-options.js";
|
|
14
|
+
import { parseWithVerifierFallback } from "../lib/parse-with-verifier-fallback.js";
|
|
15
|
+
const A2APaymentSchema = z.object({
|
|
16
|
+
buyerAgentId: z.string().min(1),
|
|
17
|
+
sellerAgentId: z.string().min(1),
|
|
18
|
+
sellerEndpoint: z.string().url(),
|
|
19
|
+
taskDescription: z.string().min(1).max(4000),
|
|
20
|
+
maxBudgetUsdc: z.number().positive().max(10),
|
|
21
|
+
});
|
|
22
|
+
async function payerFetch(maxBudgetUsdc) {
|
|
23
|
+
const evm = process.env.EVM_PRIVATE_KEY?.trim();
|
|
24
|
+
const sol = process.env.SOLANA_PRIVATE_KEY?.trim();
|
|
25
|
+
if (!evm && !sol) {
|
|
26
|
+
throw new Error("A2A execute requires EVM_PRIVATE_KEY or SOLANA_PRIVATE_KEY on the orchestrator (never pass keys in request body)");
|
|
27
|
+
}
|
|
28
|
+
return buildX402Fetch(fetch, {
|
|
29
|
+
maxAmountAtomic: String(Math.ceil(maxBudgetUsdc * 1_000_000)),
|
|
30
|
+
preferredNetwork: "eip155:8453",
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export async function executeA2APayment(params) {
|
|
34
|
+
assertA2AOrchestratorAllowed();
|
|
35
|
+
const validated = A2APaymentSchema.parse(params);
|
|
36
|
+
assertSafeOutboundUrl(validated.sellerEndpoint);
|
|
37
|
+
const trustRes = await fetch(`${config.publicBaseUrl}/api/merchant-trust/score`, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: { "content-type": "application/json" },
|
|
40
|
+
body: JSON.stringify({ targetUrl: validated.sellerEndpoint }),
|
|
41
|
+
});
|
|
42
|
+
const trust = (await trustRes.json());
|
|
43
|
+
if (trust.recommendation === "avoid") {
|
|
44
|
+
throw new Error(`A2A payment blocked: seller trust too low (score=${trust.score ?? "unknown"})`);
|
|
45
|
+
}
|
|
46
|
+
const agentFetch = await payerFetch(validated.maxBudgetUsdc);
|
|
47
|
+
const response = await agentFetch(validated.sellerEndpoint, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: {
|
|
50
|
+
"content-type": "application/json",
|
|
51
|
+
"x-buyer-agent-id": validated.buyerAgentId,
|
|
52
|
+
"x-seller-agent-id": validated.sellerAgentId,
|
|
53
|
+
},
|
|
54
|
+
body: JSON.stringify({ task: validated.taskDescription }),
|
|
55
|
+
});
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
throw new Error(`A2A call failed: HTTP ${response.status}`);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
success: true,
|
|
61
|
+
sellerResponse: await response.json(),
|
|
62
|
+
paymentReceipt: response.headers.get("PAYMENT-RESPONSE"),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export async function runA2APayment(input) {
|
|
66
|
+
const result = await executeA2APayment(input);
|
|
67
|
+
return withAgentTrust({
|
|
68
|
+
...result,
|
|
69
|
+
buyerAgentId: input.buyerAgentId,
|
|
70
|
+
sellerAgentId: input.sellerAgentId,
|
|
71
|
+
sellerEndpoint: input.sellerEndpoint,
|
|
72
|
+
}, agentTrustMeta(["a2a_preflight", "trust_score", "spend_cap"], {
|
|
73
|
+
confidence: 0.95,
|
|
74
|
+
sources: ["a2a-x402", "merchant-trust"],
|
|
75
|
+
accuracy_note: "Agent-to-agent orchestration; payer keys never accepted from client body.",
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
export async function handleA2APaymentRoute(req, res) {
|
|
79
|
+
const parsed = parseWithVerifierFallback("/api/a2a/execute", A2APaymentSchema, req.body);
|
|
80
|
+
if (!parsed.success) {
|
|
81
|
+
res.status(400).json({ error: parsed.error.flatten() });
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const result = await runA2APayment(parsed.data);
|
|
86
|
+
res.json(result);
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
90
|
+
const orchestratorReady = !/EVM_PRIVATE_KEY|SOLANA_PRIVATE_KEY/i.test(message);
|
|
91
|
+
res.json({
|
|
92
|
+
success: false,
|
|
93
|
+
allowed: false,
|
|
94
|
+
orchestratorReady,
|
|
95
|
+
error: message,
|
|
96
|
+
buyerAgentId: parsed.data.buyerAgentId,
|
|
97
|
+
sellerAgentId: parsed.data.sellerAgentId,
|
|
98
|
+
sellerEndpoint: parsed.data.sellerEndpoint,
|
|
99
|
+
checks_passed: orchestratorReady ? [] : ["a2a_schema_valid"],
|
|
100
|
+
accuracy_note: orchestratorReady
|
|
101
|
+
? "A2A call failed at runtime"
|
|
102
|
+
: "Orchestrator payer keys not configured — schema and trust preflight still valid for catalog probes",
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type EscrowInput = {
|
|
2
|
+
action: "create";
|
|
3
|
+
payerAgentId: string;
|
|
4
|
+
payeeAgentId: string;
|
|
5
|
+
amountUsdc: number;
|
|
6
|
+
releaseCondition: string;
|
|
7
|
+
metadata?: Record<string, unknown>;
|
|
8
|
+
} | {
|
|
9
|
+
action: "status";
|
|
10
|
+
escrowId: string;
|
|
11
|
+
} | {
|
|
12
|
+
action: "release";
|
|
13
|
+
escrowId: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function runAgentEscrow(input: EscrowInput): Promise<{
|
|
16
|
+
ok: boolean;
|
|
17
|
+
escrow: import("../lib/escrow-ledger.js").EscrowRecord;
|
|
18
|
+
error?: undefined;
|
|
19
|
+
message?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
ok: boolean;
|
|
22
|
+
error: string;
|
|
23
|
+
escrow?: undefined;
|
|
24
|
+
message?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
ok: boolean;
|
|
27
|
+
escrow: import("../lib/escrow-ledger.js").EscrowRecord;
|
|
28
|
+
message: string;
|
|
29
|
+
error?: undefined;
|
|
30
|
+
}>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createEscrow, getEscrow, releaseEscrow } from "../lib/escrow-ledger.js";
|
|
2
|
+
export async function runAgentEscrow(input) {
|
|
3
|
+
if (input.action === "create") {
|
|
4
|
+
const record = await createEscrow({
|
|
5
|
+
payerAgentId: input.payerAgentId,
|
|
6
|
+
payeeAgentId: input.payeeAgentId,
|
|
7
|
+
amountUsdc: input.amountUsdc,
|
|
8
|
+
releaseCondition: input.releaseCondition,
|
|
9
|
+
metadata: input.metadata,
|
|
10
|
+
});
|
|
11
|
+
return { ok: true, escrow: record };
|
|
12
|
+
}
|
|
13
|
+
if (input.action === "status") {
|
|
14
|
+
const record = await getEscrow(input.escrowId);
|
|
15
|
+
if (!record)
|
|
16
|
+
return { ok: false, error: "Escrow not found" };
|
|
17
|
+
return { ok: true, escrow: record };
|
|
18
|
+
}
|
|
19
|
+
const record = await releaseEscrow(input.escrowId);
|
|
20
|
+
if (!record)
|
|
21
|
+
return { ok: false, error: "Escrow not found or not pending" };
|
|
22
|
+
return { ok: true, escrow: record, message: "Escrow marked released. Execute USDC transfer via your agent wallet." };
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Request, Response } from "express";
|
|
2
|
+
import { type WithAgentTrust } from "../lib/agent-response.js";
|
|
3
|
+
import { type TrustScoreResult } from "../lib/erc8004/trust-score.js";
|
|
4
|
+
export type AgentVerifyInput = {
|
|
5
|
+
walletAddress: string;
|
|
6
|
+
agentId?: string | number;
|
|
7
|
+
skipCache?: boolean;
|
|
8
|
+
requestHeaders?: Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
export type AgentVerifyResult = WithAgentTrust<TrustScoreResult & {
|
|
11
|
+
recommendation: string;
|
|
12
|
+
integrationHint: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function runAgentVerify(input: AgentVerifyInput): Promise<AgentVerifyResult>;
|
|
15
|
+
export declare function handleAgentLookup(req: Request, res: Response): Promise<void>;
|