Skip to content

feat(cli): add nirium doctor preflight diagnostic command - #59

Merged
Eras256 merged 1 commit into
nirium-protocol:mainfrom
M0nsxx:feat/cli-nirium-doctor
Aug 25, 2026
Merged

Eras256 merged 1 commit into
nirium-protocol:mainfrom
M0nsxx:feat/cli-nirium-doctor

Conversation

@M0nsxx

@M0nsxx M0nsxx commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Closes #37

Summary

Adds the nirium doctor command to the nirium-cli package (packages/cli), offering preflight diagnostics for x402/MPP configurations to detect misconfigurations (missing or invalid payTo, missing or rejected facilitator API key, network passphrase mismatches, unreachable Soroban RPC endpoints) before developers encounter silent 402 or authentication errors.

Acceptance Criteria Checklist

  • nirium doctor Command & Options: Supports -n, --network <testnet|pubnet>, -c, --config <file>, --json, and --help.
  • payTo Validation: Validates Stellar public key format (G..., 56 chars). Detects missing address, malformed keys, or accidental use of secret keys (S...).
  • Facilitator API Key & Health Check: Validates required API key for default OpenZeppelin Channels facilitator on testnet/mainnet, and checks live or mocked ${facilitatorUrl}/supported endpoint health/authentication (including 401/403 detection).
  • Network & RPC Consistency Check: Validates network passphrase (Test SDF Network ; July 2015 vs Public Global Stellar Network ; September 2015) against target Soroban RPC health endpoint.
  • Human-Readable & JSON Outputs: Provides clear, colored pass/fail outputs with actionable 1-line fix suggestions per failure, as well as a --json output mode for CI pipelines.
  • Automated Tests: Includes full unit/integration test suite (test/doctor.test.js) verifying both failing/broken configurations and green pass paths against mocked endpoints.
  • Documentation: Updated packages/cli/README.md with CLI usage and example human-readable and JSON output snippets.

Verification

  • Tested broken configs: missing payTo, secret key used as payTo, missing facilitatorApiKey, 401 rejected key. All correctly identified with proper fix suggestions and non-zero exit code.
  • Tested known-good config: all checks green (ok: true) with exit code 0.
  • npm run build and npm test passing 100%.

@Eras256
Eras256 merged commit 42d0724 into nirium-protocol:main Aug 25, 2026
Eras256 added a commit to M0nsxx/nirium-sdk that referenced this pull request Aug 26, 2026
- Kept both CLI commands (verify + doctor, from nirium-protocol#59 already merged) in
  index.ts, bin/nirium.js, and README — this branch and nirium-protocol#59 each added
  one, neither replaces the other.
- Combined test scripts to run both test/verify.test.js and
  test/doctor.test.js under one `npm test`.
- Aligned @stellar/stellar-sdk to ^14.5.0 (matching packages/sdk's own
  pin) instead of this branch's ^17.0.0, to avoid two different major
  versions of the same dependency living side by side once nirium-protocol#62 also
  merges its own ^14.5.0 addition.
Eras256 pushed a commit that referenced this pull request Aug 26, 2026
…tion verifier (#60)

Verified independently (code + real test run): statement is always recomputed as nirium-audit-v1:<computedHash>, never trusted from the document. Merge conflict against main (doctor command from #59 already merged) resolved by keeping both CLI commands side by side. 10/10 tests passing (5 verify + 5 doctor combined under one npm test).
Eras256 added a commit to M0nsxx/nirium-sdk that referenced this pull request Aug 26, 2026
- Kept all six CLI commands side by side (create/pay/serve/config from
  this branch, verify/doctor from nirium-protocol#59+nirium-protocol#60 already merged) in both
  src/index.ts and bin/nirium.js — removed a stale duplicate doctor and
  a broken verify (calling a nonexistent runAuditVerifier) that this
  branch's own index.ts still had from before verify.ts existed.
- Added pay/serve/config to bin/nirium.js too — the real published
  entrypoint (package.json's "bin") only had create/doctor/verify; this
  branch's new commands were only reachable from the unpublished
  src/index.ts.
- Added express + @types/express as real dependencies — serve.ts
  imports express directly but it was never declared.
- Combined test scripts to run all three suites (verify/doctor/
  pay-serve) under one npm test. Aligned @stellar/stellar-sdk to
  ^14.5.0 across the merge.
- Rebuilt package-lock.json for both packages/cli and packages/sdk.

Known issue NOT fixed here, left for a follow-up (see PR comment):
`npm run build` still fails for pay.ts/serve.ts/config.ts — they import
sibling files with an explicit .ts extension, which the test runner's
native TS stripping needs but tsc's NodeNext resolution rejects. Fixing
it by switching to .js extensions breaks the test runner instead (no
dist/ exists when running from source). Needs an actual resolution
strategy, not a one-line swap.
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.

[Advanced] nirium doctor: CLI preflight diagnostics for x402/MPP misconfiguration

2 participants