fix(ack-pay): enforce payment request expiresAt - #158
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
WalkthroughPayment request token verification now validates ChangesPayment request expiry verification
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change adds enforcement for expired payment requests while preserving receipt verification behavior when expiry checks are disabled; no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
venables
left a comment
There was a problem hiding this comment.
This change causes a downstream error in examples/issuer/src/routes/receipts.ts:221-226: The receipt revoke route calls verifyPaymentRequestToken with only resolver, so after this PR it throws InvalidPaymentRequestTokenError for any receipt whose request expiresAt has passed. The route only needs parsed.issuer.
Likely have to pass verifyExpiry: false in that call, the same way verifyPaymentReceipt does.
| if ( | ||
| options.verifyExpiry !== false && | ||
| output.expiresAt !== undefined && | ||
| Date.parse(output.expiresAt) <= Date.now() |
There was a problem hiding this comment.
The did-jwt library includes a skew variable to allow for clock drift, which we may want to support here? (defaults to 300 https://github.com/decentralized-identity/did-jwt/blob/master/src/JWT.ts#L522C97-L522C105)
PaymentRequest.expiresAtis documented as the point after which a payment request becomes invalid, butverifyPaymentRequestTokenonly enforced the standard JWTexpclaim.Payment requests created through ACK-Pay carry
expiresAtin the JWT payload without anexpclaim, so a validly signed request with a pastexpiresAtwas still accepted by the default verification path.Fix: after parsing the payment request, reject it when
expiresAthas passed and expiry verification is enabled.verifyExpiry: falsecontinues to skip expiry checks, preserving the existing receipt-verification behavior where receipts may outlive the payment request.Tests: added regression coverage for past and future
expiresAtvalues,verifyExpiry: false, and verifying a receipt over an expired payment request.Changeset: added (
@agentcommercekit/ack-pay, patch).Related to #120, but non-overlapping: that PR validates and normalizes
expiresAtvalues at the schema level; this change enforces the parsed timestamp during verification.Verified locally:
@agentcommercekit/ack-paytests (38/38), package build,oxlint,oxfmt --check, andgit diff --check.AI usage disclosure (per AI_POLICY.md): this fix was developed with AI assistance (Codex - GPT 5.6 Sol). I reviewed the final diff and understand the change.
Summary by CodeRabbit