Skip to content

fix(x402): derive WWW-Authenticate realm from host, not full endpoint URL - #93

Merged
vvillait88 merged 2 commits into
mainfrom
fix/x402-realm-host
Jul 18, 2026
Merged

fix(x402): derive WWW-Authenticate realm from host, not full endpoint URL#93
vvillait88 merged 2 commits into
mainfrom
fix/x402-realm-host

Conversation

@vvillait88

Copy link
Copy Markdown
Contributor

Surfaced by npx mppx@latest validate against store: the challenge realm was https://agents.agentscore.com/purchase (full URL with path) while martin/sayer (Node) emit the bare host.

Root cause: the Python Checkout auto-derived the MPP realm from the full endpoint url. The Node SDK passes new URL(APP_URL).host; the WWW-Authenticate realm should be the bare protection-space host. _realm_from_url normalizes the derived realm to the host, restoring parity. Falls back to the input unchanged when it has no parseable host (already-bare host, relative path).

Advisory-only (the challenge was fully valid and settles); this clears the validator warning and aligns the two SDKs.

Unit test covers full-URL, host:port, bare-host, and relative-path cases. Full suite green (1841 passed, 95.36% coverage), ruff + ty clean.

🤖 Generated with Claude Code

vvillait88 and others added 2 commits July 17, 2026 21:41
…endpoint URL

The Checkout auto-derived the MPP challenge realm from the full endpoint `url`
(e.g. https://agents.example.com/purchase), so the emitted WWW-Authenticate
realm carried the path. The Node SDK passes `new URL(APP_URL).host`; validators
expect the realm to be the bare protection-space host. `_realm_from_url`
normalizes the derived realm to the host (agents.example.com), restoring parity
with the Node SDK. Falls back to the input unchanged when it has no parseable
host. Bump to 2.5.11.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vvillait88
vvillait88 merged commit 8f30d45 into main Jul 18, 2026
7 checks passed
@vvillait88
vvillait88 deleted the fix/x402-realm-host branch July 18, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant