feat(x402): FastAPI/Flask Python decorator + Express.js TypeScript middleware - #28
Open
jdjioe5-cpu wants to merge 1 commit into
Open
feat(x402): FastAPI/Flask Python decorator + Express.js TypeScript middleware#28jdjioe5-cpu wants to merge 1 commit into
jdjioe5-cpu wants to merge 1 commit into
Conversation
…t middleware
Two deliverables targeting GrantFox bounty campaign (Org b6550049-a239-4dc1-b95e-2fb28ded7ea6):
1. nirium.fastapi_x402 (Python)
- @x402_required(price='0.02', pay_to='GXXX...')
- Works on FastAPI and Flask routes (same decorator)
- Inspects X-402-Signature header; returns HTTP 402 with structured body + WWW-Authenticate
- Async verify via aiohttp with bounded timeout + offline fallback
- 5 pytest tests cover happy / missing / short / unreachable / undecorated paths
2. @nirium/express-x402 (TypeScript)
- nirium.x402Serve({ price, payTo, ... }) Express middleware
- Inspects X-402-Signature header; returns HTTP 402 with bounded reason
- Uses fetch + AbortController for verify with timeout
- Exposes validation at req.x402Validation for downstream handlers
- 5 jest tests cover the same paths
Both packages are read-only: they validate signatures; they never open bank rails, never issue credits, never mutate external state.
This was referenced Jul 24, 2026
Author
|
Hi maintainer — ping for review on PR #28. Both bounty #9 (Express.js) and #10 (Python) deliverables are complete:
PR is mergeable: clean. No conflicts with main. Ready for review whenever you have a moment. Both deliverables satisfy the bounty acceptance criteria: #10 (FastAPI Python x402 Decorator):
#9 (Express.js x402 Micropayment Middleware Helper):
Payout address: Base USDC (will DM on completion). Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two x402 packages targeting the GrantFox OSS Campaign
This PR adds two complementary x402 implementations for the Nirium SDK v0.7.0, one in Python (FastAPI / Flask) and one in TypeScript (Express.js). Both satisfy the acceptance criteria from the GrantFox bounty campaign (Org ID: b6550049-a239-4dc1-b95e-2fb28ded7ea6).
1. Python - nirium.fastapi_x402
2. TypeScript - @nirium/express-x402
Bounded by design
Both packages validate signatures only. They never open bank rails, never issue credits, never mutate external state, never sign or broadcast Stellar transactions.
Tests