Repository navigation
v0.4.1
What's new
-
X402\Protocol\PaymentSignature::fromArray(array $data): self— symmetric tofromHeader()but skips the base64 + JSON decode step. Designed for transports that decode the envelope earlier in the pipeline:- JSON-RPC / MCP consumers (
params._meta["x402/payment"]is already a PHP array by the time the method handler sees it — this letslaravel-x402-mcp'sX402CallTool/X402ReadResource/X402GetPromptdelete their privatehydrateSignature()duplicates). - A2A consumers (
metadatadecoded by the agent transport). - Custom test harnesses that build the envelope as an array.
fromHeader()now thin-wrapsfromArray()so the hydration path is single-source — sameaccepted/extensions/ version-tolerance behaviour, sameInvalidPaymentExceptionerrors on missing-fields, just one input format earlier in the pipeline. - JSON-RPC / MCP consumers (
-
X402\Support\PriceParser::toAtomic(float|string $amount, int $decimals): string— public extraction of the decimal-to-atomic-unit conversion that was previously private insideX402\Testing\PaymentRequiredBuilder::toAtomicUnits(). Adapters that need to parse"0.01"→"10000"for USDC config (laravel-x402'sSupport\PriceParser, future Symfony / Slim / raw-PSR-15 integrations) now share one bcmath-or-string-shift implementation. Prefersbcmul()when ext-bcmath is available; falls back to a pure-string decimal shift otherwise. Both paths are exact; neither introduces float rounding. Truncation past$decimalsis strict (no rounding) so atomic conversions don't silently bump cents.PaymentRequiredBuildernow delegates to it — no behaviour change for existing callers. -
X402\Server\IdempotencyKeyBuilderdocblock recommendations — two pieces of guidance surfaced fromlaravel-x402-mcp's cache-adapter spec work are now codified in the class docblock:- Pre-derive scope segments via a transport-specific value object rather than building the list inline at the call site. JSON-RPC consumers in particular should canonicalise the resource fingerprint (e.g.
sha256of sort-keys-recursive canonical-JSON fortools/callargument bags) so client-side re-serialisation can't split keys across cache entries. - Set an explicit transport-namespaced
prefixin your adapter wiring (x402:idem:mcp:,x402:idem:http:) when multiple transports share one Redis store. TheDEFAULT_PREFIXisx402:idem:— fine for single-transport deployments, recipe for footgun in mixed.
- Pre-derive scope segments via a transport-specific value object rather than building the list inline at the call site. JSON-RPC consumers in particular should canonicalise the resource fingerprint (e.g.
Full Changelog: 0.4.0...0.4.1