Repository navigation
Let a plugin route declare a price, and have the host run the x402 flow using the site's own x402 configuration #3700
masonjames
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The problem
EmDash ships x402 for Astro pages through
@emdash-cms/x402, but sandboxed plugins can't use it. That includes every plugin installed from the registry.ALLOWED_RESPONSE_HEADERSinpackages/core/src/plugins/route-wire.ts).PAYMENT-REQUIREDandPAYMENT-RESPONSEaren't on that list, so a plugin route can't send an x402 challenge or a payment receipt.ctx.http, with the network capability and the facilitator as an allowed host. But payment handling would stay plugin-managed: each plugin would verify and settle payments in sandboxed code and choose where the money goes. That's security-critical work, and it belongs to the host.I'm building a paid-content plugin, Paid Access, that sells Markdown reads of individual posts to AI agents over x402. Its registry build can't serve the x402 route, so that route ships as a native Astro companion that site operators must install and configure separately.
Proposal
Let a plugin route declare a price, and have the host run the x402 flow using the site's own x402 configuration (
payTo, network and facilitator):PAYMENT-REQUIRED. On the retry, it verifies the client'sPAYMENT-SIGNATUREagainst that quote.If the handler succeeded, the host settles the payment, adds
PAYMENT-RESPONSEand sends the response.The plugin never handles payment headers and never picks the recipient; the site owner's configuration does. The host settles only after the handler returns a successful response, so a request that throws or returns an error isn't charged.
A possible shape:
Alternatives
ctx.http. It's a smaller change, but every plugin reimplements payment handling and sets its own recipient.Questions
If this direction works, I'm happy to write the PR.
All reactions