Skip to main content

ASGI middleware for XRPL-backed MPP HTTP payments

Project description

xrpl-mpp-middleware

ASGI middleware for XRPL-backed MPP HTTP payments.

Install

pip install xrpl-mpp-middleware

Main APIs

  • PaymentMiddlewareASGI
  • require_payment(...)
  • require_session(...)
  • XRPLFacilitatorClient

The middleware emits MPP challenges, validates paid retries through the facilitator, injects request.state.mpp_payment, and adds Payment-Receipt on success.

Example

from fastapi import FastAPI
from xrpl_mpp_middleware import PaymentMiddlewareASGI, require_payment

app = FastAPI()

app.add_middleware(
    PaymentMiddlewareASGI,
    route_configs={
        "GET /premium": require_payment(
            facilitator_url="http://127.0.0.1:8000",
            bearer_token="replace-with-your-facilitator-token",
            pay_to="rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
            network="xrpl:1",
            xrp_drops=1000,
            description="One premium request",
        )
    },
    challenge_secret="replace-with-a-shared-secret",
)

WWW-Authenticate and Authorization scheme matching is case-insensitive, though examples keep the canonical Payment casing.

Protected routes enforce a request body limit of 32768 bytes by default. Override it with PaymentMiddlewareASGI(..., max_request_body_bytes=...); oversized protected requests return 413 {"detail":"Request body too large"} before facilitator or app processing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xrpl_mpp_middleware-0.1.4.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xrpl_mpp_middleware-0.1.4-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file xrpl_mpp_middleware-0.1.4.tar.gz.

File metadata

  • Download URL: xrpl_mpp_middleware-0.1.4.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xrpl_mpp_middleware-0.1.4.tar.gz
Algorithm Hash digest
SHA256 2981011297a9c07e4a5d56c129e69728d17c0c5276c0c0e2a23c92b9812d7a5b
MD5 f8a51bdc21b16116d2854fb02d2231e9
BLAKE2b-256 2d8a4741e0696f0917e4e3360be34e2212bf0c1289825a1103c81e437a50d042

See more details on using hashes here.

Provenance

The following attestation bundles were made for xrpl_mpp_middleware-0.1.4.tar.gz:

Publisher: publish-package.yml on lgcarrier/xrpl-mpp-stack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xrpl_mpp_middleware-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for xrpl_mpp_middleware-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a94b34a2f48d2146572ac3ebacad4034c03668db3b567f9fd4019eb81647df6d
MD5 bd8b0a311084be93ae94c82ca876f45d
BLAKE2b-256 03dfffa94c1b757c4925a096c66b14b26568482e2b84c51abec779fbfdd73757

See more details on using hashes here.

Provenance

The following attestation bundles were made for xrpl_mpp_middleware-0.1.4-py3-none-any.whl:

Publisher: publish-package.yml on lgcarrier/xrpl-mpp-stack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page