refactor(x402): split 2720-LOC god-file into class-based middleware (P3B.1)
Move app/routers/x402_enforcement.py verbatim to app/billing/x402/enforcement.py with a thin X402Enforcer class wrapper exposing the public API. The legacy app/routers/x402_enforcement.py becomes a re-export shim. Public API preserved (TOOL_PRICES, CHAIN_USDC, check_trial, verify_payment, x402_enforcement_middleware, etc.). Routes unchanged (56). Phase 3B of AUDIT-2026-Q3.md.
This commit is contained in:
parent
f1d357e70a
commit
0440dbe46a
4 changed files with 2888 additions and 2720 deletions
4
app/billing/__init__.py
Normal file
4
app/billing/__init__.py
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
"""Billing subsystem.
|
||||||
|
|
||||||
|
Phase 3B of AUDIT-2026-Q3.md.
|
||||||
|
"""
|
||||||
31
app/billing/x402/__init__.py
Normal file
31
app/billing/x402/__init__.py
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
"""x402 billing subsystem.
|
||||||
|
|
||||||
|
Phase 3B of AUDIT-2026-Q3.md.
|
||||||
|
|
||||||
|
Re-exports the canonical public API of the x402 payment enforcement
|
||||||
|
middleware. Implementation lives in app.billing.x402.enforcement
|
||||||
|
(moved verbatim from app.routers.x402_enforcement on 2026-07-07).
|
||||||
|
"""
|
||||||
|
from app.billing.x402.enforcement import ( # noqa: F401
|
||||||
|
CHAIN_USDC,
|
||||||
|
EVM_PAY_TO,
|
||||||
|
SECURITY_HEADERS,
|
||||||
|
SOL_PAY_TO,
|
||||||
|
TOOL_PRICES,
|
||||||
|
VERIFIER,
|
||||||
|
X402Enforcer,
|
||||||
|
build_402_response,
|
||||||
|
check_idempotency,
|
||||||
|
check_trial,
|
||||||
|
consume_trial,
|
||||||
|
get_redis_async,
|
||||||
|
get_revenue,
|
||||||
|
get_trial_status,
|
||||||
|
parse_x_pay_header,
|
||||||
|
request_refund,
|
||||||
|
self_verify_evm_usdc,
|
||||||
|
verify_payment,
|
||||||
|
verify_payment_via_router,
|
||||||
|
x402_discovery,
|
||||||
|
x402_enforcement_middleware,
|
||||||
|
)
|
||||||
2812
app/billing/x402/enforcement.py
Executable file
2812
app/billing/x402/enforcement.py
Executable file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue