@agentcash/discovery 1.0.2 → 1.1.1

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/dist/index.d.cts CHANGED
@@ -128,6 +128,11 @@ interface L3Result {
128
128
  outputSchema?: Record<string, unknown>;
129
129
  /** Live payment options parsed from the 402 response. Only present on probe results. */
130
130
  paymentOptions?: PaymentOption[];
131
+ /**
132
+ * Raw 402 response body captured during probing. Present when the endpoint was probed
133
+ * and returned a 402. Used by getWarningsForL3 to run full payment-required validation.
134
+ */
135
+ paymentRequiredBody?: unknown;
131
136
  }
132
137
  interface L4Result {
133
138
  guidance: string;
@@ -229,6 +234,13 @@ declare function checkL2ForWellknown(wellKnown: WellKnownSource): L2Result;
229
234
 
230
235
  declare function getL3ForOpenAPI(openApi: OpenApiSource, path: string, method: HttpMethod): L3Result | null;
231
236
  declare function getL3ForProbe(probe: ProbeResult[], path: string, method: HttpMethod): L3Result | null;
237
+ /**
238
+ * Probes `url` and populates `paymentRequiredBody` on each advisory so that
239
+ * getWarningsForL3 can run full 402-body validation. Mutates in place; no-ops on network error.
240
+ */
241
+ declare function attachProbePayload(url: string, advisories: Array<L3Result & {
242
+ method: HttpMethod;
243
+ }>): Promise<void>;
232
244
  declare function getL3(openApi: OpenApiSource | null, probe: ProbeResult[], path: string, method: HttpMethod): L3Result | null;
233
245
 
234
246
  declare function checkL4ForOpenAPI(openApi: OpenApiSource): L4Result | null;
@@ -239,6 +251,7 @@ declare const VALIDATION_CODES: {
239
251
  readonly X402_NOT_OBJECT: "X402_NOT_OBJECT";
240
252
  readonly X402_VERSION_MISSING: "X402_VERSION_MISSING";
241
253
  readonly X402_VERSION_UNSUPPORTED: "X402_VERSION_UNSUPPORTED";
254
+ readonly X402_VERSION_V1_NOT_SUPPORTED: "X402_VERSION_V1_NOT_SUPPORTED";
242
255
  readonly X402_ACCEPTS_MISSING: "X402_ACCEPTS_MISSING";
243
256
  readonly X402_ACCEPTS_INVALID: "X402_ACCEPTS_INVALID";
244
257
  readonly X402_ACCEPTS_EMPTY: "X402_ACCEPTS_EMPTY";
@@ -316,6 +329,10 @@ interface ValidatePaymentRequiredDetailedResult {
316
329
 
317
330
  declare function evaluateMetadataCompleteness(metadata: MetadataPreview): ValidationIssue[];
318
331
 
332
+ /**
333
+ * Validates a 402 response body. Delegates to getWarningsFor402Body (the canonical
334
+ * audit function) and reconstructs the full typed result shape for backwards compatibility.
335
+ */
319
336
  declare function validatePaymentRequiredDetailed(payload: unknown, options?: ValidatePaymentRequiredOptions): ValidatePaymentRequiredDetailedResult;
320
337
 
321
338
  declare const AUDIT_CODES: {
@@ -325,6 +342,7 @@ declare const AUDIT_CODES: {
325
342
  readonly L2_NO_ROUTES: "L2_NO_ROUTES";
326
343
  readonly L2_ROUTE_COUNT_HIGH: "L2_ROUTE_COUNT_HIGH";
327
344
  readonly L2_AUTH_MODE_MISSING: "L2_AUTH_MODE_MISSING";
345
+ readonly L2_NO_PAID_ROUTES: "L2_NO_PAID_ROUTES";
328
346
  readonly L2_PRICE_MISSING_ON_PAID: "L2_PRICE_MISSING_ON_PAID";
329
347
  readonly L2_PROTOCOLS_MISSING_ON_PAID: "L2_PROTOCOLS_MISSING_ON_PAID";
330
348
  readonly L3_NOT_FOUND: "L3_NOT_FOUND";
@@ -348,8 +366,18 @@ interface AuditWarning {
348
366
 
349
367
  declare function getWarningsForOpenAPI(openApi: OpenApiSource | null): AuditWarning[];
350
368
  declare function getWarningsForWellKnown(wellKnown: WellKnownSource | null): AuditWarning[];
369
+
351
370
  declare function getWarningsForL2(l2: L2Result): AuditWarning[];
371
+
372
+ /**
373
+ * Validates a raw 402 response body and returns issues as AuditWarnings.
374
+ * Uses the v1/v2 protocol validators directly — the canonical source of truth
375
+ * for 402 body quality checks. x402scan should call this instead of
376
+ * validatePaymentRequiredDetailed.
377
+ */
378
+ declare function getWarningsFor402Body(body: unknown): AuditWarning[];
352
379
  declare function getWarningsForL3(l3: L3Result | null): AuditWarning[];
380
+
353
381
  declare function getWarningsForL4(l4: L4Result | null): AuditWarning[];
354
382
 
355
- export { AUDIT_CODES, type AuditCode, type AuditSeverity, type AuditWarning, type AuthMode, type CheckEndpointNotFound, type CheckEndpointOptions, type CheckEndpointResult, type CheckEndpointSuccess, type DiscoverOriginSchemaNotFound, type DiscoverOriginSchemaOptions, type DiscoverOriginSchemaResult, type DiscoverOriginSchemaSuccess, type EndpointMethodAdvisory, GuidanceMode, type HttpMethod, type L2Result, type L2Route, type L3Result, type L4Result, type MetadataPreview, type MppPaymentOption, type NormalizedAccept, type NormalizedPaymentRequired, type OpenApiRoute, type OpenApiSource, type PaymentOption, type PricingMode, type ProbeResult, type TrustTier, VALIDATION_CODES, type ValidatePaymentRequiredDetailedResult, type ValidatePaymentRequiredOptions, type ValidationIssue, type ValidationSeverity, type ValidationStage, type ValidationSummary, type WellKnownRoute, type WellKnownSource, type X402PaymentOption, type X402V1PaymentOption, type X402V2PaymentOption, checkEndpointSchema, checkL2ForOpenAPI, checkL2ForWellknown, checkL4ForOpenAPI, checkL4ForWellknown, discoverOriginSchema, evaluateMetadataCompleteness, getL3, getL3ForOpenAPI, getL3ForProbe, getOpenAPI, getProbe, getWarningsForL2, getWarningsForL3, getWarningsForL4, getWarningsForOpenAPI, getWarningsForWellKnown, getWellKnown, validatePaymentRequiredDetailed };
383
+ export { AUDIT_CODES, type AuditCode, type AuditSeverity, type AuditWarning, type AuthMode, type CheckEndpointNotFound, type CheckEndpointOptions, type CheckEndpointResult, type CheckEndpointSuccess, type DiscoverOriginSchemaNotFound, type DiscoverOriginSchemaOptions, type DiscoverOriginSchemaResult, type DiscoverOriginSchemaSuccess, type EndpointMethodAdvisory, GuidanceMode, type HttpMethod, type L2Result, type L2Route, type L3Result, type L4Result, type MetadataPreview, type MppPaymentOption, type NormalizedAccept, type NormalizedPaymentRequired, type OpenApiRoute, type OpenApiSource, type PaymentOption, type PricingMode, type ProbeResult, type TrustTier, VALIDATION_CODES, type ValidatePaymentRequiredDetailedResult, type ValidatePaymentRequiredOptions, type ValidationIssue, type ValidationSeverity, type ValidationStage, type ValidationSummary, type WellKnownRoute, type WellKnownSource, type X402PaymentOption, type X402V1PaymentOption, type X402V2PaymentOption, attachProbePayload, checkEndpointSchema, checkL2ForOpenAPI, checkL2ForWellknown, checkL4ForOpenAPI, checkL4ForWellknown, discoverOriginSchema, evaluateMetadataCompleteness, getL3, getL3ForOpenAPI, getL3ForProbe, getOpenAPI, getProbe, getWarningsFor402Body, getWarningsForL2, getWarningsForL3, getWarningsForL4, getWarningsForOpenAPI, getWarningsForWellKnown, getWellKnown, validatePaymentRequiredDetailed };
package/dist/index.d.ts CHANGED
@@ -128,6 +128,11 @@ interface L3Result {
128
128
  outputSchema?: Record<string, unknown>;
129
129
  /** Live payment options parsed from the 402 response. Only present on probe results. */
130
130
  paymentOptions?: PaymentOption[];
131
+ /**
132
+ * Raw 402 response body captured during probing. Present when the endpoint was probed
133
+ * and returned a 402. Used by getWarningsForL3 to run full payment-required validation.
134
+ */
135
+ paymentRequiredBody?: unknown;
131
136
  }
132
137
  interface L4Result {
133
138
  guidance: string;
@@ -229,6 +234,13 @@ declare function checkL2ForWellknown(wellKnown: WellKnownSource): L2Result;
229
234
 
230
235
  declare function getL3ForOpenAPI(openApi: OpenApiSource, path: string, method: HttpMethod): L3Result | null;
231
236
  declare function getL3ForProbe(probe: ProbeResult[], path: string, method: HttpMethod): L3Result | null;
237
+ /**
238
+ * Probes `url` and populates `paymentRequiredBody` on each advisory so that
239
+ * getWarningsForL3 can run full 402-body validation. Mutates in place; no-ops on network error.
240
+ */
241
+ declare function attachProbePayload(url: string, advisories: Array<L3Result & {
242
+ method: HttpMethod;
243
+ }>): Promise<void>;
232
244
  declare function getL3(openApi: OpenApiSource | null, probe: ProbeResult[], path: string, method: HttpMethod): L3Result | null;
233
245
 
234
246
  declare function checkL4ForOpenAPI(openApi: OpenApiSource): L4Result | null;
@@ -239,6 +251,7 @@ declare const VALIDATION_CODES: {
239
251
  readonly X402_NOT_OBJECT: "X402_NOT_OBJECT";
240
252
  readonly X402_VERSION_MISSING: "X402_VERSION_MISSING";
241
253
  readonly X402_VERSION_UNSUPPORTED: "X402_VERSION_UNSUPPORTED";
254
+ readonly X402_VERSION_V1_NOT_SUPPORTED: "X402_VERSION_V1_NOT_SUPPORTED";
242
255
  readonly X402_ACCEPTS_MISSING: "X402_ACCEPTS_MISSING";
243
256
  readonly X402_ACCEPTS_INVALID: "X402_ACCEPTS_INVALID";
244
257
  readonly X402_ACCEPTS_EMPTY: "X402_ACCEPTS_EMPTY";
@@ -316,6 +329,10 @@ interface ValidatePaymentRequiredDetailedResult {
316
329
 
317
330
  declare function evaluateMetadataCompleteness(metadata: MetadataPreview): ValidationIssue[];
318
331
 
332
+ /**
333
+ * Validates a 402 response body. Delegates to getWarningsFor402Body (the canonical
334
+ * audit function) and reconstructs the full typed result shape for backwards compatibility.
335
+ */
319
336
  declare function validatePaymentRequiredDetailed(payload: unknown, options?: ValidatePaymentRequiredOptions): ValidatePaymentRequiredDetailedResult;
320
337
 
321
338
  declare const AUDIT_CODES: {
@@ -325,6 +342,7 @@ declare const AUDIT_CODES: {
325
342
  readonly L2_NO_ROUTES: "L2_NO_ROUTES";
326
343
  readonly L2_ROUTE_COUNT_HIGH: "L2_ROUTE_COUNT_HIGH";
327
344
  readonly L2_AUTH_MODE_MISSING: "L2_AUTH_MODE_MISSING";
345
+ readonly L2_NO_PAID_ROUTES: "L2_NO_PAID_ROUTES";
328
346
  readonly L2_PRICE_MISSING_ON_PAID: "L2_PRICE_MISSING_ON_PAID";
329
347
  readonly L2_PROTOCOLS_MISSING_ON_PAID: "L2_PROTOCOLS_MISSING_ON_PAID";
330
348
  readonly L3_NOT_FOUND: "L3_NOT_FOUND";
@@ -348,8 +366,18 @@ interface AuditWarning {
348
366
 
349
367
  declare function getWarningsForOpenAPI(openApi: OpenApiSource | null): AuditWarning[];
350
368
  declare function getWarningsForWellKnown(wellKnown: WellKnownSource | null): AuditWarning[];
369
+
351
370
  declare function getWarningsForL2(l2: L2Result): AuditWarning[];
371
+
372
+ /**
373
+ * Validates a raw 402 response body and returns issues as AuditWarnings.
374
+ * Uses the v1/v2 protocol validators directly — the canonical source of truth
375
+ * for 402 body quality checks. x402scan should call this instead of
376
+ * validatePaymentRequiredDetailed.
377
+ */
378
+ declare function getWarningsFor402Body(body: unknown): AuditWarning[];
352
379
  declare function getWarningsForL3(l3: L3Result | null): AuditWarning[];
380
+
353
381
  declare function getWarningsForL4(l4: L4Result | null): AuditWarning[];
354
382
 
355
- export { AUDIT_CODES, type AuditCode, type AuditSeverity, type AuditWarning, type AuthMode, type CheckEndpointNotFound, type CheckEndpointOptions, type CheckEndpointResult, type CheckEndpointSuccess, type DiscoverOriginSchemaNotFound, type DiscoverOriginSchemaOptions, type DiscoverOriginSchemaResult, type DiscoverOriginSchemaSuccess, type EndpointMethodAdvisory, GuidanceMode, type HttpMethod, type L2Result, type L2Route, type L3Result, type L4Result, type MetadataPreview, type MppPaymentOption, type NormalizedAccept, type NormalizedPaymentRequired, type OpenApiRoute, type OpenApiSource, type PaymentOption, type PricingMode, type ProbeResult, type TrustTier, VALIDATION_CODES, type ValidatePaymentRequiredDetailedResult, type ValidatePaymentRequiredOptions, type ValidationIssue, type ValidationSeverity, type ValidationStage, type ValidationSummary, type WellKnownRoute, type WellKnownSource, type X402PaymentOption, type X402V1PaymentOption, type X402V2PaymentOption, checkEndpointSchema, checkL2ForOpenAPI, checkL2ForWellknown, checkL4ForOpenAPI, checkL4ForWellknown, discoverOriginSchema, evaluateMetadataCompleteness, getL3, getL3ForOpenAPI, getL3ForProbe, getOpenAPI, getProbe, getWarningsForL2, getWarningsForL3, getWarningsForL4, getWarningsForOpenAPI, getWarningsForWellKnown, getWellKnown, validatePaymentRequiredDetailed };
383
+ export { AUDIT_CODES, type AuditCode, type AuditSeverity, type AuditWarning, type AuthMode, type CheckEndpointNotFound, type CheckEndpointOptions, type CheckEndpointResult, type CheckEndpointSuccess, type DiscoverOriginSchemaNotFound, type DiscoverOriginSchemaOptions, type DiscoverOriginSchemaResult, type DiscoverOriginSchemaSuccess, type EndpointMethodAdvisory, GuidanceMode, type HttpMethod, type L2Result, type L2Route, type L3Result, type L4Result, type MetadataPreview, type MppPaymentOption, type NormalizedAccept, type NormalizedPaymentRequired, type OpenApiRoute, type OpenApiSource, type PaymentOption, type PricingMode, type ProbeResult, type TrustTier, VALIDATION_CODES, type ValidatePaymentRequiredDetailedResult, type ValidatePaymentRequiredOptions, type ValidationIssue, type ValidationSeverity, type ValidationStage, type ValidationSummary, type WellKnownRoute, type WellKnownSource, type X402PaymentOption, type X402V1PaymentOption, type X402V2PaymentOption, attachProbePayload, checkEndpointSchema, checkL2ForOpenAPI, checkL2ForWellknown, checkL4ForOpenAPI, checkL4ForWellknown, discoverOriginSchema, evaluateMetadataCompleteness, getL3, getL3ForOpenAPI, getL3ForProbe, getOpenAPI, getProbe, getWarningsFor402Body, getWarningsForL2, getWarningsForL3, getWarningsForL4, getWarningsForOpenAPI, getWarningsForWellKnown, getWellKnown, validatePaymentRequiredDetailed };