x402-surface-check 0.2.30 → 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.
- package/bin/x402-surface-check.mjs +22 -1
- package/package.json +1 -1
|
@@ -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,6 +415,27 @@ 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)
|