caelum0x 2d43618725 feat: real integrations (Casper Testnet, x402/EIP-712, MCP, RealFi, cross-chain), wallet sign-in, branding
Replace the design-note docs (p1–p7) with the implemented "make it real" phase
docs (p8–p10) and wire production-grade, env-gated real integrations:

- p8 Casper Testnet: byte-exact deploys + WASM install via casper-js-sdk; live
  node reads (node.testnet.casper.network); CRED402_CHAIN=sim|testnet transport.
- p9 x402 + data + MCP: real EIP-712 typed-data digests (@casper-ecosystem/
  casper-eip-712); casper-x402 facilitator client (x402 V2); live Open-Meteo GHI;
  official @modelcontextprotocol/sdk server; casper-sidecar SSE event feed.
- p10 RealFi + cross-chain: real Stripe test-mode webhooks (HMAC-verified) and
  Plaid sandbox → privacy-preserving on-chain envelopes; Base Sepolia EVM deploy
  (Foundry); reachable via /api/realfi/* and /api/x402/facilitator routes.
- Sign-in with Casper Wallet: real extension provider + challenge/ed25519/session
  flow (/v1/auth/wallet/*), console connect + sign-in button.
- Branding: Cred402 logo mark, favicon, OG image; Vercel config for the console.

All env-gated with sim/free-API fallbacks; full suite green, all toolchains
(TS/Rust/Go/Solidity) build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 00:37:36 +03:00

64 lines
2.2 KiB
Markdown

# @cred402/openapi
The OpenAPI 3.1 specification for the **Cred402 public REST API (`/v1`)**.
`cred402.v1.yaml` is the **contract** for the externally-versioned `/v1` API. It
is generated to match the real route definitions in `api/v1/router.ts`, the
gateway envelope in `lib/gateway/errors.ts`, the auth model in
`lib/gateway/index.ts`, and the response shapes in `lib/services/*`. Treat it as
the source of truth for clients and integrators.
## What it covers
Every `/v1` route the gateway serves:
- **System** — `GET /v1/health`
- **Agents** — `GET /v1/agents`, `POST /v1/agents`, `GET /v1/agents/{id}`,
`GET /v1/agents/{id}/passport`, `GET /v1/agents/{id}/credit-line`,
`GET /v1/agents/{id}/credit-explain`, `GET /v1/receipts`,
`GET /v1/x402/receipts/{id}`
- **Compliance** — `GET /v1/compliance/agents/{id}`
- **Credit** — `GET /v1/credit/pool`, `POST /v1/credit/lines`,
`POST /v1/credit/lines/{id}/draw`, `POST /v1/credit/lines/{id}/repay`
- **Analytics** — `GET /v1/economics`, `GET /v1/analytics`,
`GET /v1/notifications`, `GET /v1/search`
- **Marketplace** — `GET /v1/marketplace`
- **Disputes** — `POST /v1/disputes`
- **RealFi** — `GET /v1/realfi`, `POST /v1/realfi/operators`,
`POST /v1/realfi/fiat-receipts`
- **Admin** — `GET`/`POST /v1/admin/api-keys`, `GET`/`POST /v1/webhooks`
## Authentication
Provide a scoped API key either as a Bearer token
(`Authorization: Bearer <key>`) or via the `X-Api-Key` header. Scopes are
`read`, `write`, and `admin` (an `admin` key implicitly satisfies `read` and
`write`). Each operation's description documents the scope it requires.
## Response envelope
- Success: `{ "success": true, "data": <payload>, "request_id": "req_..." }`
- Failure: `{ "success": false, "error": { "code": "...", "message": "..." }, "request_id": "req_..." }`
Mutations (POSTs) accept an optional `Idempotency-Key` header for safe retries.
## Viewing the spec
Preview with Redoc:
```bash
npx @redocly/cli preview-docs packages/openapi/cred402.v1.yaml
```
Or render with Swagger UI:
```bash
npx swagger-ui-watcher packages/openapi/cred402.v1.yaml
```
## Linting / validating
```bash
npx @redocly/cli lint packages/openapi/cred402.v1.yaml
```