x402-surface-check 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -78,6 +78,7 @@ function parseArgs(argv) {
78
78
  }
79
79
 
80
80
  function moneyFromAtomic(amount, decimals = 6) {
81
+ if (amount === '' || amount === null || amount === undefined) return ''
81
82
  const numeric = Number(amount)
82
83
  if (!Number.isFinite(numeric)) return String(amount ?? '')
83
84
  const value = numeric / (10 ** decimals)
@@ -381,13 +382,14 @@ function hasPaymentChallenge(result) {
381
382
  function challengeSummary(result) {
382
383
  const challenge = result.body.json
383
384
  const firstAccept = challenge?.accepts?.[0] ?? {}
385
+ const hasChallenge = hasPaymentChallenge(result)
384
386
  const amount = firstAccept.amount ?? firstAccept.maxAmountRequired ?? firstAccept.maxAmount ?? ''
385
387
  const resourceUrl = challenge?.resource?.url ?? firstAccept.resource ?? ''
386
388
  const extraResource = firstAccept.extra?.resource ?? firstAccept.resource ?? ''
387
389
 
388
390
  return {
389
391
  status: result.status,
390
- protocol: challenge?.protocol ?? (firstAccept.scheme === 'mpp' ? 'mpp' : 'x402'),
392
+ protocol: hasChallenge ? challenge?.protocol ?? (firstAccept.scheme === 'mpp' ? 'mpp' : 'x402') : '',
391
393
  resourceUrl,
392
394
  network: firstAccept.network ?? '',
393
395
  amount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x402-surface-check",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "No-payment x402 public-surface checker for manifests, OpenAPI specs, and HTTP 402 challenges.",
5
5
  "type": "module",
6
6
  "bin": {