feat: CDP mainnet facilitator auth (per-request signed EdDSA JWT) - #5
Open
Robin Schulte (relativvv) wants to merge 3 commits into
Open
feat: CDP mainnet facilitator auth (per-request signed EdDSA JWT)#5Robin Schulte (relativvv) wants to merge 3 commits into
Robin Schulte (relativvv) wants to merge 3 commits into
Conversation
… — local only, no PR X402FacilitatorClient now signs a Coinbase CDP Bearer JWT (Ed25519, uri-bound, 120s) when facilitatorCdpKeyId+Secret are configured; static bearer otherwise. New X402CdpJwtFactory (libsodium) + config fields + unit tests. 92/92 X402 tests pass.
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.
Problem
X402FacilitatorClientonly ever sent a staticAuthorization: Bearer <facilitatorApiKey>. That works for testnet / static-token facilitators but not for Coinbase's CDP mainnet facilitator, which requires a short-lived JWT signed with the CDP API key on every request, with auriclaim bound to the exact method + host + path. Without it, mainnet settlement through the fee-free CDP facilitator is impossible without standing up a signing proxy.Root cause
The facilitator auth had a single, hardcoded mode (static bearer). There was no way to plug in a request-signing scheme, so CDP's per-request signed-JWT requirement could not be satisfied.
What changed
src/Core/X402/X402CdpJwtFactory.php(new) — mints a CDP Bearer JWT with no external JWT library:alg=EdDSA,kid,noncesub=keyId,iss=cdp,nbf,exp=+120s,uri="POST <host><path>"src/Core/X402/X402FacilitatorClient.php— whenfacilitatorCdpKeyId+facilitatorCdpKeySecretare configured, signs a per-request JWT for the exact URL; otherwise falls back to the existing static bearer.src/Core/X402/Config/X402Config.php+X402ConfigService.php+src/Resources/config/config.xml— new config fieldsfacilitatorCdpKeyId(text) andfacilitatorCdpKeySecret(password, Ed25519).src/Resources/config/services.xml— register the JWT factory and inject it into the facilitator client.tests/Unit/Core/X402/X402CdpJwtFactoryTest.php(new) — verifies the minted JWT against a test Ed25519 public key and asserts the CDP claim shape.tests/Unit/Core/X402/X402FacilitatorClientTest.php— extended for the CDP-signing branch.Testing
php -lclean on all changed PHP files.vendor/bin/phpunit --filter 'X402CdpJwtFactory|X402FacilitatorClient'→ 11 tests, 37 assertions, OK (PHP 8.3.30, PHPUnit 11.5.56).Notes for reviewers