Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/bsv_brc/brc105/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,26 @@
)
from bsv_brc.brc105.nonce import NonceManager
from bsv_brc.brc105.challenge import create_challenge, parse_challenge_headers
from bsv_brc.brc105.middleware import PaymentMiddleware

# PaymentMiddleware depends on Starlette, which is an optional extra
# (`pip install "bsv-brc[starlette]"`). Import it lazily so the core 402
# primitives above remain usable without Starlette installed.
try:
from bsv_brc.brc105.middleware import PaymentMiddleware
except ModuleNotFoundError as _exc: # pragma: no cover - only without the extra

class _MissingPaymentMiddleware:
"""Placeholder raising a clear error when Starlette is not installed."""

_err = _exc

def __init__(self, *_args, **_kwargs):
raise ImportError(
"PaymentMiddleware requires Starlette. "
'Install it with: pip install "bsv-brc[starlette]"'
) from self._err

PaymentMiddleware = _MissingPaymentMiddleware # type: ignore[assignment,misc]

__all__ = [
"PaymentChallenge",
Expand Down
Loading