Repository navigation
Add MPP decode and pay to the Link SDK - #563
Merged
Merged
Conversation
Add link.mpp.decode and link.mpp.pay, with matching mpp_decode and mpp_pay agent tools, and run link-cli mpp commands on them. Preserve the scope and behavior of #489 on current main, resolving conflicts only. Co-authored-by: Ryan Aubrey <185865758+raubrey-stripe@users.noreply.github.com> Committed-By-Agent: codex Co-authored-by: codex <noreply@openai.com> Committed-By-Agent: codex Co-authored-by: codex <noreply@openai.com>
ksn-stripe
force-pushed
the
ksn/mpp-sdk-clean
branch
from
November 16, 2026 22:47
e31a79e to
4bea117
Compare
ksn-stripe
marked this pull request as ready for review
November 17, 2026 14:21
Restore the approved-challenge checks from main (#325, #525) instead of replacing them. `link.mpp.pay` accepts an optional `approvedChallenge` (the `www_authenticate` header returned by `decode`) and refuses a re-fetched challenge, or an offer mppx selects, whose terms differ from it. The `mpp_pay` tool exposes this as `approved_challenge`, and `link-cli mpp pay --approved-challenge` and its continuations work as on main, so the CLI change is no longer breaking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Committed-By-Agent: claude
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Committed-By-Agent: claude
raubrey-stripe
left a comment
Contributor
There was a problem hiding this comment.
Looks reasonable, if you can take a look at this agent safety feedback before we merge that'd be great otherwise I imagine it'll come up in a SAT
- High: configured headers can reach merchant hosts. The new MPP resource (https://github.com/stripe/link-cli/blob/1f5f0c616af93caf13f2dc72674dde58a6f0a7b9/packages/sdk/src/resources/mpp.ts#L227-L230) uses the SDK fetch wrapper, which adds defaultHeaders to requests. I reproduced defaultHeaders.Authorization being sent to a merchant URL and added again after a cross-origin redirect, before payment approval. Merchant requests need a fetch path that does not inherit credential-bearing Link API headers.
- Medium: payment can move to another path after approval. pay() (https://github.com/stripe/link-cli/blob/1f5f0c616af93caf13f2dc72674dde58a6f0a7b9/packages/sdk/src/resources/mpp.ts#L266-L275) rejects a changed origin but follows a same-origin redirect. I reproduced an approved /order-a request sending its payment credential to /order-b when that path returned the same challenge terms. The previous CLI rejected redirects during the approved payment step; that destination pin should be retained.
Merchant requests used the SDK's Link API fetch, so configured defaultHeaders (such as Authorization) reached merchant hosts, including after redirects. MppResource now uses the caller's fetch without them. pay() also followed same-origin redirects when re-fetching an approved request, so a credential approved for one path could be sent to another. pay() now follows no redirects, restoring main's destination pin; decode() still resolves redirects before approval. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Committed-By-Agent: claude
Contributor
Author
|
Fixed both! |
raubrey-stripe
approved these changes
Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SDK agents can now pay MPP (HTTP 402) merchants with a balance-backed shared payment token, the same flow
link-cli mpp decodeandmpp payprovide.link-cli mppnow runs on the same SDK code, so the CLI and SDK can't drift apart.Reimplements #489 on current
mainto resolve merge conflicts. Two differences from #489:mpp pay --approved-challengekeeps working and the CLI change is no longer breaking.SDK API
link.mpp.decode(request)probes the URL without credentials. It returns either{ payment_required: false, response }or{ payment_required: true, challenges, www_authenticate, request }, whererequestis the request after any safe redirects.link.mpp.pay(request, { spendRequestId, approvedChallenge })re-fetches the challenge and pays it with the approved spend request's SPT. Passwww_authenticatefromdecodeasapprovedChallenge.decodeMppChallengesis exported, andlink-cli mpp decodenow calls it directly instead of parsing challenges itself.mpp_decodeandmpp_paytools increateLinkTools, the Eve extension, and the Mastra integration.mpp_paytakes an optionalapproved_challenge.link-clino longer depends onmppxat runtime; it moves to the CLI's devDependencies (used only by tests).Pay-time checks
payrefuses to send a credential unless:approvedChallenge, the re-fetched challenge and the offer mppx selects to sign match it, ignoring only the challenge ID, expiry, and rotating_mppx_nonce(Fix MPP payments when mppx rotates challenge nonces #490). This is the pinning frommain, moved into the SDK; the CLI full flow and its continuations pass it as before.amount,currencyand network ID match the spend request.pay.decoderesolves redirects before approval;pay's re-fetch and payment follow none, so the credential can't move to another path (as onmain).Merchant requests use the caller's
fetchwithout the Link client'sdefaultHeaders, so Link credentials never reach merchant hosts.If the fetch no longer returns 402,
payreturns that response without paying. So retrying with the same arguments after an uncertain result (for example a 503) doesn't create a second payment.Review questions (carried over from #489)
mpp_<challengeId>_<spt>idempotency key doesn't dedupe retries with the same SPT. Can someone confirm the SPT's reuse limits?mppxto avoid Eve discovery hanging on its viem graph. That adds about 136KB and slows Eve discovery (about 24s cold / 14.5s warm in CI vs 17.6s / 7.6s on main), so this raises the discovery test limits. Is that startup cost acceptable, and is it OK that picking up an mppx fix now requires an SDK release?Validation
SDK, CLI, Eve, and Mastra typechecks and unit tests pass locally, including the pinning tests ported from
main. CI covers packaged builds, command continuations, and Eve discovery.