x402-surface-check 0.2.29 → 0.2.31

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.
@@ -343,7 +343,7 @@ function manifestEndpointPaymentSignal(endpoint) {
343
343
  if (!endpoint || typeof endpoint !== 'object') return 0
344
344
  if (Number(endpoint.phase1_response?.status) === 402) return 2
345
345
  if (/payment-required|x-payment|402/i.test(String(endpoint.phase1_response?.header ?? ''))) return 2
346
- if (/^\$?\d+(\.\d+)?/.test(String(endpoint.price ?? endpoint.cost ?? endpoint.amount ?? ''))) return 1
346
+ if (/^\$?\d+(\.\d+)?/.test(String(endpoint.price ?? endpoint.priceUsd ?? endpoint.price_usd ?? endpoint.cost ?? endpoint.amount ?? ''))) return 1
347
347
  if (/payment|required|402/i.test(String(endpoint.description ?? ''))) return 1
348
348
  if (endpoint.accepts || endpoint.schemes || endpoint.payment || endpoint['x-payment-info']) return 1
349
349
  return 0
@@ -415,13 +415,52 @@ function endpointEntries(document, sourceUrl, limit) {
415
415
  })
416
416
  }
417
417
  }
418
+ if (Array.isArray(document.routes)) {
419
+ for (const route of document.routes) {
420
+ if (!route || typeof route !== 'object') continue
421
+ const exampleCall = Array.isArray(route.exampleCalls)
422
+ ? route.exampleCalls.find(call => call?.url)
423
+ : undefined
424
+ const rawPath = exampleCall?.url ?? route.url ?? route.endpoint ?? route.path
425
+ if (!rawPath) continue
426
+ const method = String(route.method ?? exampleCall?.method ?? 'GET').toUpperCase()
427
+ const paymentSignal = manifestEndpointPaymentSignal(route)
428
+ const hasPathParameters = /\{[^}]+\}/.test(String(rawPath))
429
+ if (paymentSignal === 0 && (method !== 'GET' || hasPathParameters)) continue
430
+ entries.push({
431
+ name: route.id ?? route.reportType ?? route.agentName ?? String(rawPath).split('/').filter(Boolean).at(-1) ?? String(rawPath),
432
+ url: manifestEndpointUrl(rawPath, route, baseUrl, sourceUrl),
433
+ method,
434
+ requestBody: manifestEndpointBody(route, document),
435
+ publicDiscovery: paymentSignal === 0,
436
+ })
437
+ }
438
+ }
418
439
  const endpointMaps = []
419
440
  if (!Array.isArray(document.endpoints) && document.endpoints && typeof document.endpoints === 'object') {
420
441
  endpointMaps.push(document.endpoints)
421
442
  }
422
- if (document.tools && typeof document.tools === 'object') {
443
+ if (document.tools && typeof document.tools === 'object' && !Array.isArray(document.tools)) {
423
444
  endpointMaps.push(document.tools)
424
445
  }
446
+ if (Array.isArray(document.tools)) {
447
+ for (const tool of document.tools) {
448
+ if (!tool || typeof tool !== 'object') continue
449
+ const rawPath = tool.url ?? tool.endpoint ?? tool.path
450
+ if (!rawPath) continue
451
+ const method = String(tool.method ?? 'POST').toUpperCase()
452
+ const paymentSignal = manifestEndpointPaymentSignal(tool)
453
+ const hasPathParameters = /\{[^}]+\}/.test(String(rawPath))
454
+ if (paymentSignal === 0 && (method !== 'GET' || hasPathParameters)) continue
455
+ entries.push({
456
+ name: tool.id ?? tool.name ?? String(rawPath).split('/').filter(Boolean).at(-1) ?? String(rawPath),
457
+ url: manifestEndpointUrl(rawPath, tool, baseUrl, sourceUrl),
458
+ method,
459
+ requestBody: manifestEndpointBody(tool, document),
460
+ publicDiscovery: paymentSignal === 0,
461
+ })
462
+ }
463
+ }
425
464
  for (const endpointMap of endpointMaps) {
426
465
  for (const [key, endpoint] of Object.entries(endpointMap)) {
427
466
  if (typeof endpoint === 'string') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x402-surface-check",
3
- "version": "0.2.29",
3
+ "version": "0.2.31",
4
4
  "description": "No-payment x402 public-surface checker for manifests, OpenAPI specs, and HTTP 402 challenges.",
5
5
  "type": "module",
6
6
  "bin": {