Skip to content

feat(cli): doctor --seller <url> to validate a remote x402 seller - #110

Merged
Eras256 merged 3 commits into
nirium-protocol:mainfrom
Edgadafi:feat/doctor-seller
Oct 10, 2026
Merged

Eras256 merged 3 commits into
nirium-protocol:mainfrom
Edgadafi:feat/doctor-seller

Conversation

@Edgadafi

@Edgadafi Edgadafi commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #105

nirium doctor --seller <url> valida un vendedor x402 remoto sin pagar. Pide la URL y exige 402 con un PAYMENT-REQUIRED decodificable. Revisa que network, asset, amount y payTo existan y estén bien formados, y que resource.url sea https://. Manda un preflight CORS con un origen al azar y comprueba que no responde 500, que el 402 expone PAYMENT-REQUIRED y PAYMENT-RESPONSE (el navegador ignora Access-Control-Expose-Headers del preflight), y que PAYMENT-SIGNATURE está permitido. Cada check se imprime pass/fail. --json queda para CI y el exit code es distinto de cero si alguno falla.

El probe es un GET más un OPTIONS. No envía PAYMENT-SIGNATURE ni lee el .env. El User-Agent es nirium-doctor/<version> leído de packages/cli/package.json. El #103 no está en main, así que los tests del fixture viven aquí.

Rebaseado sobre main después de #108 (pay ya no acepta el secreto como argumento).

Este paquete no tiene ESLint ni un script lint. npm test es el único script nuevo y corre node --test contra el fixture. El workflow de upstream (sdk-test.yml) no cubre packages/cli/**. Estos tests se pueden sumar ahí, o dejarlo para #107.

Cómo se probó

  • npm test en packages/cli: 11/11 contra un servidor en 127.0.0.1, sin red. Incluye el caso en que el preflight expone los headers y el 402 no: cors-expose falla.
  • Lectura, sin pago, de https://x402.holatia.app/v1/quote. Pasaron challenge, stellar:pubnet, asset, amount, payTo, resource.url, preflight 204 y PAYMENT-SIGNATURE. Falló cors-expose: el 402 no envía Access-Control-Expose-Headers. Exit code 1.
🩺 Nirium Doctor — remote x402 seller
Seller:         https://x402.holatia.app/v1/quote
Target Network: stellar:pubnet
--------------------------------------------------
✔ [CHALLENGE] HTTP 402 with a decodable PAYMENT-REQUIRED header
✔ [NETWORK] network is present and well formed
✔ [ASSET] asset is present and well formed
✔ [AMOUNT] amount is a positive integer string
✔ [PAYTO] payTo is present and well formed
✔ [RESOURCE-URL] resource.url is https://
✔ [CORS-PREFLIGHT] CORS preflight returned HTTP 204 for a random origin
❌ [CORS-EXPOSE] browser clients cannot read PAYMENT-REQUIRED and PAYMENT-RESPONSE
✔ [CORS-ALLOW] PAYMENT-SIGNATURE is allowed on the preflight
--------------------------------------------------
❌ Diagnostic failed. See fix suggestions above.

Disclosure: implemented with AI assistance (Cursor) under my direction and reviewed by hand.

cursoragent and others added 3 commits October 9, 2026 17:49
npm run build and npm run lint syntax-check the CLI. This package
ships as one JavaScript file and has no tsc or eslint config.

Co-Authored-By: Grok 4.7 <noreply@x.ai>
Browsers ignore Access-Control-Expose-Headers on the preflight.
The doctor User-Agent now takes its version from package.json, and
the node --check scripts are gone so they are not mistaken for a linter.

Co-Authored-By: Grok 4.7 <noreply@x.ai>
@Eras256
Eras256 merged commit c7c8283 into nirium-protocol:main Oct 10, 2026
Eras256 added a commit that referenced this pull request Oct 11, 2026
Drop the duplicate Added heading, credit #110 and @Edgadafi on the doctor
--seller line, and update the stale (v1.1.4) comment in bin/nirium.js.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

doctor: add --seller <url> to validate a remote x402 seller

3 participants