Skip to content

feat: add Tempo session credential lifecycle hooks - #710

Open
brendanjryan wants to merge 2 commits into
mainfrom
brendanjryan/tempo-session-credential-validation
Open

feat: add Tempo session credential lifecycle hooks#710
brendanjryan wants to merge 2 commits into
mainfrom
brendanjryan/tempo-session-credential-validation

Conversation

@brendanjryan

Copy link
Copy Markdown
Collaborator

Motivation

Expose non-mutating validation and terminal broadcast hooks for Tempo session credentials.

Summary

  • Added full session credential validation across open, top-up, voucher, and close actions
  • Added shared transaction preparation and unsponsored simulation checks
  • Preserved legacy verification behavior through the server method adapter

Key design considerations

  • Validation performs no store writes, fee-payer signing, or transaction broadcast
  • Broadcast revalidates state before applying payment transitions
  • Sponsored transactions are simulated only after fee-payer completion

@cursor

cursor Bot commented Jul 24, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@pkg-pr-new

pkg-pr-new Bot commented Jul 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 4c24dfa

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a8c5eb0c32

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

})
assertCredentialSourceCanSpend({ chainId, channel, source: credentialSource })
if (channel.finalized) throw new ChannelClosedError({ reason: 'channel is finalized' })
const channelState = await Chain.getChannelState(client, channelId, escrow)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve channel-state TTL during voucher validation

When the split hooks are installed, Mppx invokes validate before broadcast on every credential-bearing request, so this unconditional getChannelState makes every normal voucher request depend on a fresh RPC eth_call even when channelStateTtl was configured to rely on the cached store state. The existing broadcast path still has the TTL guard, so high-frequency session traffic now pays an extra chain read per voucher and can start failing during transient RPC outages despite a fresh cached channel state; validation should reuse the same TTL/cache inputs as broadcast or avoid the mandatory read on the hot path.

Useful? React with 👍 / 👎.

/** Parsed client-signed Tempo transaction. */
transaction: ReturnType<(typeof Transaction)['deserialize']>
}): Promise<void> {
if (parameters.feePayer) return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject invalid sponsored credentials during validation

When a session is configured with a local fee payer or hosted fee payer, this early return makes the validation hook accept sponsored open/topUp credentials without checking the sponsorship constraints that broadcast later enforces (for example an explicitly disallowed feeToken, expired validBefore, or gas values outside feePayerPolicy). A caller using mppx.validateCredential() can therefore receive a successful validation for a credential that the same method rejects during broadcast, so sponsored validation should run the non-mutating fee-payer policy/fee-token checks instead of unconditionally skipping them.

Useful? React with 👍 / 👎.

Comment on lines +525 to +529
await Chain.simulateCredentialTransaction({
client,
feePayer: parameters.feePayer,
transaction: transaction.transaction,
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check top-up channel state during validation

For top-up credentials this simulation is the final validation step, so mppx.validateCredential() can return success even when the channel is already pending close on-chain; the broadcast path rejects that same case after readback with validateChannelState(state). Callers that use validation as a preflight for top-up management will get a false positive for channels with closeRequestedAt != 0, so validation should read/validate the channel state (or at least reject known closed/pending-close store state) before accepting the credential.

Useful? React with 👍 / 👎.

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