Core Types
Challenge, Credential, and Receipt primitives
The SDK provides three core types that map directly to HTTP headers: Challenge, Credential, and Receipt.
from mpp import Challenge, Credential, ReceiptParse a Challenge
challenge = Challenge.from_www_authenticate(
'Payment id="...", realm="...", method="tempo", intent="charge", request="eyJ..."'
)On the wire, request and optional opaque are base64url-encoded JSON strings in the WWW-Authenticate header. Challenge.from_www_authenticate(...) decodes them for application code.
Create and serialize a Credential
credential = Credential(
id="challenge-id",
payload={"type": "transaction", "signature": "0x..."},
source="did:pkh:eip155:42431:0xa726a1...",
)
header = credential.to_authorization()When a Credential echoes a Challenge, challenge.request and challenge.opaque stay in their base64url string form inside the serialized Authorization payload.
Parse and serialize a Receipt
receipt = Receipt.from_payment_receipt(header_value)
header = receipt.to_payment_receipt()