proposal: mppx.challenge and mppx.verifyCredential interface refactor#337
proposal: mppx.challenge and mppx.verifyCredential interface refactor#337brendanjryan wants to merge 3 commits intomainfrom
Conversation
commit: |
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.
894000e to
de17026
Compare
|
Thank you so much for iterating on this, the APIs here are perfect for more complex workflows managing the http requests manually ❤️ Quick feedback from Claude while testing locally:
|
Two ergonomic changes to public
mppxinterfacemppx.challenge.{method}.{intent}(opts)— Generate aChallengeobject using the same options, defaults, and schema transforms as the 402 handler. Eliminates manual base-unit conversion.mppx.verifyCredential(credential)— Single-call end-to-end verification (deserialize → HMAC → method match → schema validate → expiry → verify). Replaces 5 manual steps.Both are extractions of existing
createMethodFninternals — no new verification logic.