Skip to content

feat(x402): implement V2 discovery manifest - #43

Merged
whoabuddy merged 4 commits into
mainfrom
feat/x402-manifest-v2
Feb 17, 2026
Merged

whoabuddy merged 4 commits into
mainfrom
feat/x402-manifest-v2

Conversation

@whoabuddy

Copy link
Copy Markdown
Contributor

Summary

  • Rewrite /x402.json to emit V2-compliant manifest with CAIP-2 network IDs (stacks:1 / stacks:2147483648), per-endpoint resource objects, amount field (replacing maxAmountRequired), and service metadata wrapper
  • Move Bazaar metadata into extensions.bazaar per-endpoint with proper nesting
  • Simplify generator by removing dead types, unused imports, and unnecessary config indirection

Closes #40

Test plan

  • npm run check passes (type check)
  • npm run deploy:dry-run succeeds (build)
  • Deploy to staging and fetch https://x402.aibtc.dev/x402.json
  • Submit manifest to x402lint.com — zero errors
  • Verify 402 payment flow still works (npm test)

🤖 Generated with Claude Code

whoabuddy and others added 4 commits February 16, 2026 16:48
Rewrite x402 discovery manifest to comply with V2 protocol spec:

- Add V2-compliant types: V2PaymentRequirements, V2ManifestEntry, V2Manifest
- Replace X402Entry/X402Schema with per-endpoint grouped structure
- Rename generateX402Schema() to generateX402Manifest()
- Use CAIP-2 network format ("stacks:1" / "stacks:2147483648")
- Change maxAmountRequired to amount per V2 spec
- Add baseUrl to GeneratorConfig for full resource URLs
- Group accepts by endpoint instead of flat token array
- Include service metadata wrapper
- Add Bazaar extensions per endpoint
- Add lastUpdated timestamp
- Retain X402InputSchema/X402OutputSchema for Bazaar compatibility

Fixes issues #1-2 from quest tracking:
1. Invalid network format (now CAIP-2)
2. Missing amount field (now uses amount instead of maxAmountRequired)

Related to #40

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Update /x402.json route handler to extract baseUrl from request URL
and pass to generateX402Manifest(). This enables building full resource
URLs (e.g., "https://x402.aibtc.dev/path") instead of relative paths.

Changes:
- Extract baseUrl from c.req.url origin
- Pass baseUrl, serviceName, serviceUrl to generator
- Update import from generateX402Schema to generateX402Manifest
- Rename variable from schema to manifest for clarity

Fixes issue #3 from quest tracking (resource object format).

Related to #40

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Changes resource field from string to ResourceInfo object (with url, description, mimeType)
and fixes Bazaar extension nesting to match V2 protocol spec. Resolves x402lint validation
warnings for MISSING_RESOURCE and INVALID_BAZAAR_* fields.

- Add ResourceInfo interface matching x402-stacks V2 types
- Update V2ManifestEntry to use ResourceInfo object for resource field
- Fix Bazaar extension type to use inner structure (BazaarExtension["bazaar"])
- Extract .bazaar property when building extensions (matches middleware pattern)
- Add description and mimeType to each manifest entry resource

Validation results:
- x402lint: ✓ Valid (v2) with zero errors
- Remaining warnings: UNKNOWN_NETWORK/ASSET (expected for Stacks testnet)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Remove dead legacy types, unused imports, unreachable guards, and
unnecessary config indirection. Behavior unchanged.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copilot AI review requested due to automatic review settings February 17, 2026 00:08
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
x402-api-staging 5ae820b Feb 17 2026, 12:08 AM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
x402-api-production 5ae820b Feb 17 2026, 12:08 AM

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the x402 discovery manifest endpoint (/x402.json) to comply with the V2 protocol specification, fixing validation errors identified by x402lint.com. The changes migrate from a flat manifest structure to a per-endpoint grouping format with proper CAIP-2 network identifiers, resource objects, and Bazaar metadata extensions.

Changes:

  • Rewrote manifest generator to emit V2-compliant structure with items array instead of flat accepts list
  • Replaced maxAmountRequired with amount field and implemented CAIP-2 network IDs (stacks:1 / stacks:2147483648)
  • Moved Bazaar metadata into per-endpoint extensions.bazaar structure with proper nesting

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/utils/x402-schema.ts Complete rewrite of manifest generator: new V2 types, per-endpoint structure, CAIP-2 network IDs, simplified helper functions, proper Bazaar extension nesting
src/index.ts Updated to call renamed generateX402Manifest() function with new config structure (baseUrl instead of name/image)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@whoabuddy
whoabuddy merged commit 6012668 into main Feb 17, 2026
8 checks passed
@whoabuddy
whoabuddy deleted the feat/x402-manifest-v2 branch February 17, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check x402 spec

2 participants