Skip to content

proposal: mppx.challenge and mppx.verifyCredential interface refactor#337

Open
brendanjryan wants to merge 3 commits intomainfrom
proposal/ucp-api-improvements
Open

proposal: mppx.challenge and mppx.verifyCredential interface refactor#337
brendanjryan wants to merge 3 commits intomainfrom
proposal/ucp-api-improvements

Conversation

@brendanjryan
Copy link
Copy Markdown
Collaborator

@brendanjryan brendanjryan commented Apr 14, 2026

Two ergonomic changes to public mppx interface

mppx.challenge.{method}.{intent}(opts) — Generate a Challenge object using the same options, defaults, and schema transforms as the 402 handler. Eliminates manual base-unit conversion.

const challenge = mppx.challenge.tempo.charge({
  amount: '25.92',           // human-readable — SDK applies parseUnits
  description: 'Order #123',
})

mppx.verifyCredential(credential) — Single-call end-to-end verification (deserialize → HMAC → method match → schema validate → expiry → verify). Replaces 5 manual steps.

const receipt = await mppx.verifyCredential('eyJjaGFsbGVuZ2...')
const receipt = await mppx.verifyCredential(credential)

Both are extractions of existing createMethodFn internals — no new verification logic.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 14, 2026

Open in StackBlitz

npm i https://pkg.pr.new/mppx@337

commit: de17026

Add two new methods on the Mppx instance:

- mppx.challenge.{method}.{intent}(opts) — generates Challenge objects
  using the same options, defaults, and schema transforms as the 402
  handler. Eliminates manual base-unit conversion for UCP/webhook use.

- mppx.verifyCredential(credential) — single-call end-to-end
  verification: deserialize, HMAC-check, method match, schema validate,
  expiry check, and verify. Replaces 5 manual steps.

Both are extractions of existing createMethodFn internals.

Tests cover charge + session intents, multi-method dispatch, schema
transforms, HMAC rejection, expiry, invalid payloads, unregistered
methods, malformed input, and full round-trip flows.
@brendanjryan brendanjryan changed the title proposal: mppx.challenge and mppx.verifyCredential for UCP proposal: mppx.challenge and mppx.verifyCredential interface refactor Apr 14, 2026
@brendanjryan brendanjryan force-pushed the proposal/ucp-api-improvements branch from 894000e to de17026 Compare April 14, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant