feat(ap2): add experimental AP2 mandate verification - #11
Merged
Merged
Conversation
SergeevDmitry
approved these changes
Sep 15, 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.
Summary
Add experimental, opt-in support for AP2 v0.2.0 Direct Checkout Mandate verification on paid resources.
The gateway verifies that a trusted issuer authorized the exact resource, input, price, and payment rail before allowing settlement. Mandates use static operator-configured trust and durable replay
protection. The package also exports a merchant checkout JWT signing helper through the optional ./ap2 entry point.
What changed
Supported scope
This initial implementation supports:
The gateway verifies mandates but does not issue them, act as a full AP2 Merchant, or produce signed Checkout Receipts. It does not implement autonomous mode, open Checkout Mandates, intent or cart
mandates, Payment Mandate verification, spending constraints, key-bound presentations, delegation chains, remote key discovery, remote revocation, algorithms other than ES256, an AP2 transport, or AP2
over the ACP adapter.
Replay protection favors preventing duplicate settlement. If settlement was broadcast but its outcome is unknown, the mandate remains unavailable and is marked uncertain. A process failure between
settlement and the local replay-store update can leave a reservation unusable until an operator resolves it.
Compatibility
AP2 remains disabled unless explicitly enabled. Existing HTTP, MCP, A2A, ACP, and payment configurations continue to work, and resources without an authorization policy follow the existing execution path.
Authorization can only be required on paid resources because it gates settlement rather than access by itself. Configuration and runtime checks reject authorization policies on free resources.
The AP2 implementation and its exact-version peers, jose, @sd-jwt/core, and canonicalize, live behind the optional ./ap2 entry point. Deployments that do not use AP2 do not need to install them.