@zanii/gateway
v0.1.0
Published
Drop-in proxy that receipts every HTTP API call an agent makes - zero code changes. Edge-compatible (fetch handler) plus a Node server and CLI.
Readme
@zanii/gateway
A transparent HTTP proxy that records a signed Zanii receipt for every API call
an agent makes — no changes to the agent's code. Point its HTTP client at the
gateway; the gateway forwards to the real upstream and receipts each call as
http.<method>.<path>.
npm install @zanii/gateway @zanii/sdkAs a fetch handler (edge / serverless)
import { createZaniiHandler } from '@zanii/gateway';
import { ZaniiAgent } from '@zanii/sdk';
const agent = new ZaniiAgent({ /* did, key, delegation … */ });
const handler = createZaniiHandler({ upstream: 'https://api.stripe.com', agent });
// Cloudflare Workers / Vercel edge:
export default { fetch: handler };Each forwarded request is recorded before the response is returned. Works in any
fetch-based runtime (Node 18+, Workers, Vercel edge).
As a CLI
zanii-gateway --upstream https://api.stripe.com --port 4800 --identity identity.json
# now point the agent at http://localhost:4800 instead of api.stripe.comidentity.json is { "agent": { "did": "…", "privateKey": "<hex>" }, "delegation": [ … ] }.
Server URL comes from ZANII_SERVER (default https://ledger.zanii.agency),
API key from ZANII_API_KEY.
Changelog
- 0.1.0 — initial release:
createZaniiHandler(fetch),createZaniiGateway(Node),zanii-gatewayCLI.
License
Apache-2.0.
