x402-surface-check 0.2.5 → 0.2.7

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.
@@ -365,6 +365,24 @@ function valueList(value) {
365
365
  return []
366
366
  }
367
367
 
368
+ function displayMetadataValue(value) {
369
+ if (value === null || value === undefined || value === '') return '-'
370
+ if (Array.isArray(value)) {
371
+ return value.map(displayMetadataValue).filter(item => item && item !== '-').join(', ') || '-'
372
+ }
373
+ if (typeof value === 'object') {
374
+ const parts = [
375
+ value.name,
376
+ value.operator,
377
+ value.url,
378
+ value.jurisdiction,
379
+ value.network,
380
+ ].filter(item => item !== null && item !== undefined && item !== '').map(String)
381
+ return parts.join(' / ') || Object.keys(value).join(', ') || '-'
382
+ }
383
+ return String(value)
384
+ }
385
+
368
386
  function capabilityList(value) {
369
387
  if (!Array.isArray(value)) return []
370
388
  return value.map(item => item?.id ?? item?.name ?? item).filter(Boolean).map(String)
@@ -382,13 +400,14 @@ function hasPaymentChallenge(result) {
382
400
  function challengeSummary(result) {
383
401
  const challenge = result.body.json
384
402
  const firstAccept = challenge?.accepts?.[0] ?? {}
403
+ const hasChallenge = hasPaymentChallenge(result)
385
404
  const amount = firstAccept.amount ?? firstAccept.maxAmountRequired ?? firstAccept.maxAmount ?? ''
386
405
  const resourceUrl = challenge?.resource?.url ?? firstAccept.resource ?? ''
387
406
  const extraResource = firstAccept.extra?.resource ?? firstAccept.resource ?? ''
388
407
 
389
408
  return {
390
409
  status: result.status,
391
- protocol: challenge?.protocol ?? (firstAccept.scheme === 'mpp' ? 'mpp' : 'x402'),
410
+ protocol: hasChallenge ? challenge?.protocol ?? (firstAccept.scheme === 'mpp' ? 'mpp' : 'x402') : '',
392
411
  resourceUrl,
393
412
  network: firstAccept.network ?? '',
394
413
  amount,
@@ -519,7 +538,7 @@ function formatMarkdown(report) {
519
538
  `- Type: ${report.directEndpoint ? 'direct endpoint' : (document.openapi ? 'OpenAPI' : 'x402 manifest or JSON document')}`,
520
539
  `- Agent: ${document.agent?.name ?? '-'}`,
521
540
  `- Wallet: ${document.agent?.wallet ?? '-'}`,
522
- `- Facilitator: ${document.facilitator ?? '-'}`,
541
+ `- Facilitator: ${displayMetadataValue(document.facilitator)}`,
523
542
  `- Networks: ${valueList(document.networks).join(', ') || '-'}`,
524
543
  `- Capabilities: ${capabilityList(document.capabilities).join(', ') || '-'}`,
525
544
  `- Probed endpoints: ${report.entries.length}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x402-surface-check",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "No-payment x402 public-surface checker for manifests, OpenAPI specs, and HTTP 402 challenges.",
5
5
  "type": "module",
6
6
  "bin": {