Skip to main content

mpp

Interfaces

MPPMethodHandler

Defined in: packages/types/src/mpp/handler.ts:16

Properties

capabilities
capabilities: HandlerCapabilities
Defined in: packages/types/src/mpp/handler.ts:18
method
method: string
Defined in: packages/types/src/mpp/handler.ts:17

Methods

getChallenge()
getChallenge(intent, pricing, resourceURL, opts?): Promise<{ description?: string; digest?: string; expires?: string; id: string; intent: string; method: string; opaque?: string; realm: string; request: string; }>
Defined in: packages/types/src/mpp/handler.ts:20
Parameters
intent
string
pricing
ResourcePricing
resourceURL
string
opts?
ChallengeOpts
Returns
Promise<{ description?: string; digest?: string; expires?: string; id: string; intent: string; method: string; opaque?: string; realm: string; request: string; }>
getSupportedIntents()
getSupportedIntents(): string[]
Defined in: packages/types/src/mpp/handler.ts:19
Returns
string[]
handleSettle()
handleSettle(credential): Promise<null | { method: string; reference: string; status: "success" | "failed"; timestamp: string; }>
Defined in: packages/types/src/mpp/handler.ts:26
Parameters
credential
challenge
{ description?: string; digest?: string; expires?: string; id: string; intent: string; method: string; opaque?: string; realm: string; request: string; } = mppChallengeParams
challenge.description?
string = "string"
challenge.digest?
string = "string"
challenge.expires?
string = "string"
challenge.id
string = "string"
challenge.intent
string = "string"
challenge.method
string = "string"
challenge.opaque?
string = "string"
challenge.realm
string = "string"
challenge.request
string = "string"
payload
Record<string, unknown> = "Record<string, unknown>"
source?
string = "string"
Returns
Promise<null | { method: string; reference: string; status: "success" | "failed"; timestamp: string; }>

Type Aliases

ChallengeOpts

ChallengeOpts = object
Defined in: packages/types/src/mpp/handler.ts:12 Server-side handler for an MPP payment method. Named after the spec’s concept of a “payment method” — the mechanism for transferring value (e.g. “solana”). A method handler supports one or more intents (e.g. “charge”).

Properties

digest?
optional digest: string
Defined in: packages/types/src/mpp/handler.ts:13

mppChallengeParams

mppChallengeParams = typeof mppChallengeParams.infer
Defined in: packages/types/src/mpp/types.ts:8

mppCredential

mppCredential = typeof mppCredential.infer
Defined in: packages/types/src/mpp/types.ts:22

MPPPaymentExecer

MPPPaymentExecer = object
Defined in: packages/types/src/mpp/handler.ts:32 Result of executing an MPP payment on the client side.

Properties

challenge
challenge: mppChallengeParams
Defined in: packages/types/src/mpp/handler.ts:33

Methods

exec()
exec(): Promise<{ challenge: { description?: string; digest?: string; expires?: string; id: string; intent: string; method: string; opaque?: string; realm: string; request: string; }; payload: Record<string, unknown>; source?: string; }>
Defined in: packages/types/src/mpp/handler.ts:34
Returns
Promise<{ challenge: { description?: string; digest?: string; expires?: string; id: string; intent: string; method: string; opaque?: string; realm: string; request: string; }; payload: Record<string, unknown>; source?: string; }>

MPPPaymentHandler()

MPPPaymentHandler = (challenge) => Promise<MPPPaymentExecer | null>
Defined in: packages/types/src/mpp/handler.ts:43 Client-side handler that matches MPP challenges and produces credentials. Returns null when the challenge does not match this handler’s method or intent, allowing multiple handlers to be composed.

Parameters

challenge
mppChallengeParams

Returns

Promise<MPPPaymentExecer | null>

mppReceipt

mppReceipt = typeof mppReceipt.infer
Defined in: packages/types/src/mpp/types.ts:30

Variables

AUTHORIZATION_HEADER

const AUTHORIZATION_HEADER: "Authorization" = "Authorization"
Defined in: packages/types/src/mpp/types.ts:4

MPP_PAYMENT_SCHEME

const MPP_PAYMENT_SCHEME: "Payment" = "Payment"
Defined in: packages/types/src/mpp/types.ts:6

mppChallengeParams

const mppChallengeParams: Type<{ description?: string; digest?: string; expires?: string; id: string; intent: string; method: string; opaque?: string; realm: string; request: string; }, { }>
Defined in: packages/types/src/mpp/types.ts:8

mppCredential

const mppCredential: Type<{ challenge: { description?: string; digest?: string; expires?: string; id: string; intent: string; method: string; opaque?: string; realm: string; request: string; }; payload: Record<string, unknown>; source?: string; }, { }>
Defined in: packages/types/src/mpp/types.ts:22

mppReceipt

const mppReceipt: Type<{ method: string; reference: string; status: "success" | "failed"; timestamp: string; }, { }>
Defined in: packages/types/src/mpp/types.ts:30

PAYMENT_RECEIPT_HEADER

const PAYMENT_RECEIPT_HEADER: "Payment-Receipt" = "Payment-Receipt"
Defined in: packages/types/src/mpp/types.ts:5

WWW_AUTHENTICATE_HEADER

const WWW_AUTHENTICATE_HEADER: "WWW-Authenticate" = "WWW-Authenticate"
Defined in: packages/types/src/mpp/types.ts:3

Functions

canonicalizeSortedJSON()

canonicalizeSortedJSON(obj): string
Defined in: packages/types/src/mpp/encoding.ts:38 Sorted-key JSON canonicalization following RFC 8785 JCS for the subset of inputs used by MPP (string keys, no integer-indexed properties). Integer-indexed keys would violate RFC 8785 sort order due to ECMAScript property enumeration rules.

Parameters

obj
unknown

Returns

string

computeBodyDigest()

computeBodyDigest(body): Promise<string>
Defined in: packages/types/src/mpp/encoding.ts:165 Computes an RFC 9530 content digest for a request body. Format: sha-256=:base64value:

Parameters

body
ArrayBuffer

Returns

Promise<string>

decodeBase64URL()

decodeBase64URL(encoded): string
Defined in: packages/types/src/mpp/encoding.ts:21

Parameters

encoded
string

Returns

string

encodeBase64URL()

encodeBase64URL(input): string
Defined in: packages/types/src/mpp/encoding.ts:9

Parameters

input
string

Returns

string

formatWWWAuthenticate()

formatWWWAuthenticate(challenges): string
Defined in: packages/types/src/mpp/encoding.ts:58

Parameters

challenges
object[]

Returns

string

parseAuthorizationPayment()

parseAuthorizationPayment(header): undefined | { challenge: { description?: string; digest?: string; expires?: string; id: string; intent: string; method: string; opaque?: string; realm: string; request: string; }; payload: Record<string, unknown>; source?: string; }
Defined in: packages/types/src/mpp/encoding.ts:125

Parameters

header
string

Returns

undefined | { challenge: { description?: string; digest?: string; expires?: string; id: string; intent: string; method: string; opaque?: string; realm: string; request: string; }; payload: Record<string, unknown>; source?: string; }

parseReceipt()

parseReceipt(header): undefined | { method: string; reference: string; status: "success" | "failed"; timestamp: string; }
Defined in: packages/types/src/mpp/encoding.ts:171

Parameters

header
string

Returns

undefined | { method: string; reference: string; status: "success" | "failed"; timestamp: string; }

parseWWWAuthenticate()

parseWWWAuthenticate(header): object[]
Defined in: packages/types/src/mpp/encoding.ts:93 Parses a WWW-Authenticate header value containing one or more Payment challenges. Each challenge starts with the token “Payment” followed by auth-param key=value pairs.

Parameters

header
string

Returns

object[]

resolveMPPChallenges()

resolveMPPChallenges(handlers, pricing, resourceURL, opts?): Promise<object[]>
Defined in: packages/types/src/mpp/handler.ts:63 Generates MPP challenges by matching pricing entries to handlers. For each handler, matches pricing by capabilities, then calls getChallenge for each matched pricing entry and each supported intent. The middleware emits all challenges; the client picks one.

Parameters

handlers
MPPMethodHandler[]
pricing
ResourcePricing[]
resourceURL
string
opts?
ResolveOpts

Returns

Promise<object[]>

serializeCredential()

serializeCredential(credential): string
Defined in: packages/types/src/mpp/encoding.ts:153

Parameters

credential
challenge
{ description?: string; digest?: string; expires?: string; id: string; intent: string; method: string; opaque?: string; realm: string; request: string; } = mppChallengeParams
challenge.description?
string = "string"
challenge.digest?
string = "string"
challenge.expires?
string = "string"
challenge.id
string = "string"
challenge.intent
string = "string"
challenge.method
string = "string"
challenge.opaque?
string = "string"
challenge.realm
string = "string"
challenge.request
string = "string"
payload
Record<string, unknown> = "Record<string, unknown>"
source?
string = "string"

Returns

string

serializeReceipt()

serializeReceipt(receipt): string
Defined in: packages/types/src/mpp/encoding.ts:157

Parameters

receipt
method
string = "string"
reference
string = "string"
status
"success" | "failed" = “‘success’|‘failed‘“
timestamp
string = "string"

Returns

string

settleMPPPayment()

settleMPPPayment(handlers, credential): Promise<{ method: string; reference: string; status: "success" | "failed"; timestamp: string; }>
Defined in: packages/types/src/mpp/handler.ts:114 Routes an MPP credential to the appropriate handler for settlement. Filters handlers by exact method match against the credential’s challenge method, then iterates handleSettle until one returns a non-null result.

Parameters

handlers
MPPMethodHandler[]
credential
challenge
{ description?: string; digest?: string; expires?: string; id: string; intent: string; method: string; opaque?: string; realm: string; request: string; } = mppChallengeParams
challenge.description?
string = "string"
challenge.digest?
string = "string"
challenge.expires?
string = "string"
challenge.id
string = "string"
challenge.intent
string = "string"
challenge.method
string = "string"
challenge.opaque?
string = "string"
challenge.realm
string = "string"
challenge.request
string = "string"
payload
Record<string, unknown> = "Record<string, unknown>"
source?
string = "string"

Returns

Promise<{ method: string; reference: string; status: "success" | "failed"; timestamp: string; }>