Repository navigation
feat(request): enforce charge policy through machine-fetch before signing - #303
Draft
brendanjryan wants to merge 1 commit into
Draft
brendanjryan wants to merge 1 commit into
brendanjryan wants to merge 1 commit into
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This branch has not been deployed
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.
tempo requestnow signs MPP charge credentials through machine-fetch (MppxFetch.createCredential), so the spend cap and funding run fail-closed right before signing. Today the last check lives in mppx'sonChallengeReceived, which swallows listener errors, so it can't stop a payment. This was a blocker in machine-fetch's pre-open-source review.Draft: blocked on machine-fetch 0.5.0 being published (version PR tempoxyz/machine-fetch#111).
package.jsonalready says"machine-fetch": "0.5.0", butpnpm-lock.yamlstill points at the local tarball of machine-fetch main used for verification, so CI's install will fail until 0.5.0 is on npm andpnpm installregenerates the lockfile.Changes
src/request/policy.ts:createChargeCredentialbuildsMppxFetch.extension({ maxPayment, autoSwap })per payment and callsMppxFetch.createCredential. Selection, then policy and funding, then signing.--max-spend/TEMPO_MAX_SPEND/ savedmax-spend/ default 10 becomes a per-paymentmaxPaymentceiling in the charged token. If mppx selects an offer that differs from the one the CLI validated (amount, token or chain), it's refused withE_LIMIT_EXCEEDEDbefore signing. The earlierenforceMaxSpendcheck stays as defence in depth.--machand unlisted tokens never swap. Previously charges never swapped. This adds a balance read over RPC before signing; a failed read fails the payment.E_LIMIT_EXCEEDED,E_INSUFFICIENT_FUNDS,E_PAYMENT,E_PAYMENT_OUTCOME_UNKNOWN). No new codes.--dry-runwithin_budgetfor charges comes fromPayment.plan.Follow-ups (not here)
spendLimitreader, so a key that can't cover the swap is refused before signing with an OUSD-specific error.--dry-run.Verification
pnpm checkpasses (67 files, 2,914 tests), pluschangelog:validateanddocs:check. 23 new tests intest/request-policy.test.tscover: a policy refusal never calls the signer, funding runs before signing, and each machine-fetch error maps to the right code.