Commit b8ef7ad
feat: add Bazaar discovery metadata for x402 endpoints (#35)
* feat(bazaar): add TypeScript types for Bazaar extension
Define interfaces for Coinbase x402 Bazaar discovery metadata:
- BazaarInputHttp: HTTP method and parameter spec
- BazaarOutputJson: Response example structure
- BazaarInfo: Complete input/output info
- BazaarSchema: JSON Schema validator
- BazaarExtension: Full extension object
- EndpointMetadata: Registry entry structure
Implements Bazaar format natively rather than using @x402/extensions
(which depends on EVM-focused @x402/core).
Co-Authored-By: Claude <noreply@anthropic.com>
* feat(bazaar): add complete endpoint metadata registry
Create comprehensive discovery registry for all ~40 API endpoints:
Hashing (6 endpoints):
- SHA-256, SHA-512, SHA-512/256, Keccak-256, Hash160, RIPEMD-160
Stacks (6 endpoints):
- Address conversion, Clarity decode, transaction decode
- Profile lookup, message verification, SIP-018 verification
Inference (4 endpoints):
- OpenRouter models (free), OpenRouter chat (dynamic pricing)
- Cloudflare models (free), Cloudflare chat (standard)
Storage (21 endpoints):
- KV store (4): set, get, list, delete
- Paste service (3): create, get, delete
- SQLite DB (3): query, execute, schema
- Distributed locks (5): acquire, release, extend, status, list
- Priority queues (5): push, pop, peek, status, clear
- Vector memory (5): store, search, delete, list, clear
Each entry includes:
- HTTP method and path (with path parameters)
- Request body/query param JSON schemas
- Realistic output examples
- Category and description
Provides helper functions:
- getEndpointMetadata(path): Pattern matching for parameterized paths
- getEndpointsByCategory(category): Filter by category
- REGISTRY_STATS: Count totals
Co-Authored-By: Claude <noreply@anthropic.com>
* feat(bazaar): add public API and helper functions
Create src/bazaar/index.ts with:
Exports:
- All types from types.ts (BazaarExtension, EndpointMetadata, etc.)
- Registry and utilities from registry.ts
Helper Functions:
- buildBazaarExtension(metadata): Constructs complete Bazaar extension
with info (input/output spec) and schema (JSON Schema validator)
- extractQueryParamsSchema(metadata): Get query param schema
- extractBodySchema(metadata): Get request body schema
The buildBazaarExtension helper will be used by the x402 middleware
to inject discovery metadata into PaymentRequired responses.
Co-Authored-By: Claude <noreply@anthropic.com>
* feat(x402): inject Bazaar extensions into 402 responses
Modify x402 middleware to include `extensions.bazaar` in PaymentRequired
responses. The middleware now:
1. Looks up endpoint metadata from the Bazaar registry
2. Uses `buildBazaarExtension()` to construct discovery metadata
3. Injects the extension into the 402 response if metadata exists
This enables facilitators to catalog API endpoints by reading the Bazaar
discovery metadata directly from payment-required responses.
Co-Authored-By: Claude <noreply@anthropic.com>
* feat(schema): upgrade x402.json to v2 with Bazaar metadata
Enhance the x402.json schema generator to emit v2 format with full
Bazaar-compatible discovery metadata:
- Upgrade x402Version from 1 to 2
- Import Bazaar registry and types
- Add buildOutputSchema() helper to populate rich input/output metadata
- Include full JSON schemas, query params, and realistic examples per endpoint
- Maintain backward compatibility with existing ENDPOINT_REGISTRY structure
The outputSchema now includes:
- input.bodySchema: Full JSON Schema for request bodies
- input.queryParams: Query parameter schemas
- output.example: Realistic response examples from Bazaar registry
- output.schema: Optional JSON Schema for responses
This enables better endpoint discovery and integration with the
Coinbase x402 Bazaar scanning layer.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(bazaar): simplify discovery metadata and fix registry key collision
Extract repeated tokenType query params and hash body schemas into shared
constants, inline intermediate Bazaar types into BazaarExtension, remove
unused helpers (extractQueryParamsSchema, extractBodySchema, REGISTRY_STATS,
getEndpointsByCategory), hoist static JSON Schema to a module-level constant,
fix Map key collision where endpoints sharing a path but differing by HTTP
method silently overwrote each other, and normalize imports through the
barrel module.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(bazaar): normalize resource paths and include schemas in extensions
- Use {param} format for resource paths in x402.json (was :param)
- Include bodySchema and outputSchema in Bazaar 402 extensions
- Update BazaarExtension type to allow new fields
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 2c7b45b commit b8ef7ad
5 files changed
Lines changed: 1204 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
0 commit comments