mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-19 14:31:50 +02:00
Addresses the security review on #2575. Enforce policy against the actual challenge. The previous example compared a budget against a number the caller passed in, so a server quoting any amount could still be paid. Replaces it with a PaymentPolicy registered on the client, which filters the server-provided requirements before a signature exists and validates all three fields — amount, asset, network. Filtering everything out makes createPaymentPayload throw rather than fall back to paying. Testing this adversarially surfaced a bug in the guard itself: EVM addresses are case-insensitive, so a server quoting lowercase USDC — the same token — was dropped. Assets are now normalised before comparison, lowercasing only 0x addresses, since Solana base58 is case-sensitive and must not be folded. Also rejects negative amounts. Verified against 12 cases: over-budget, wrong mint, wrong network, case-flipped Solana mint, non-numeric and negative amounts all refuse; checksummed, lowercase and uppercase EVM forms and the cap boundary all pass. Refresh the supported contract. Pins move 2.19.0 -> 2.22.0 (upstream shipped 2.20, 2.21 and 2.22 since this branch opened). The documented server and client APIs are unchanged across that range — re-ran the seller middleware on 2.22.0 and it still returns a multi-network 402. Keep facilitator guidance vendor-neutral. Self-facilitation and running your own facilitator are now listed first, ahead of the testnet default and hosted options, and the hosted paragraph points at the upstream maintained list rather than naming a default. Adds an explicit disclosure of the author's affiliation with one listed facilitator. Mirrored across en, ja-JP, and zh-CN.