Commit 8f30d45
fix(x402): derive WWW-Authenticate realm from host, not full endpoint URL (#93)
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](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent eef3dfe commit 8f30d45
4 files changed
Lines changed: 29 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
152 | 166 | | |
153 | 167 | | |
154 | 168 | | |
| |||
907 | 921 | | |
908 | 922 | | |
909 | 923 | | |
910 | | - | |
| 924 | + | |
911 | 925 | | |
912 | 926 | | |
913 | 927 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
985 | 985 | | |
986 | 986 | | |
987 | 987 | | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments