@agentcash/discovery 1.1.0 → 1.1.2

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
@@ -59,7 +59,7 @@ interface X402V2PaymentOption {
59
59
  type X402PaymentOption = X402V1PaymentOption | X402V2PaymentOption;
60
60
  type PaymentOption = X402PaymentOption | MppPaymentOption;
61
61
  interface PricingHint {
62
- pricingMode: PricingMode;
62
+ pricingMode: PricingMode | string;
63
63
  price?: string;
64
64
  minPrice?: string;
65
65
  maxPrice?: string;
@@ -116,6 +116,7 @@ interface L2Route {
116
116
  summary: string;
117
117
  authMode?: AuthMode;
118
118
  price?: string;
119
+ pricingMode?: string;
119
120
  protocols?: string[];
120
121
  }
121
122
  interface L3Result {
@@ -128,6 +129,11 @@ interface L3Result {
128
129
  outputSchema?: Record<string, unknown>;
129
130
  /** Live payment options parsed from the 402 response. Only present on probe results. */
130
131
  paymentOptions?: PaymentOption[];
132
+ /**
133
+ * Raw 402 response body captured during probing. Present when the endpoint was probed
134
+ * and returned a 402. Used by getWarningsForL3 to run full payment-required validation.
135
+ */
136
+ paymentRequiredBody?: unknown;
131
137
  }
132
138
  interface L4Result {
133
139
  guidance: string;
@@ -229,6 +235,13 @@ declare function checkL2ForWellknown(wellKnown: WellKnownSource): L2Result;
229
235
 
230
236
  declare function getL3ForOpenAPI(openApi: OpenApiSource, path: string, method: HttpMethod): L3Result | null;
231
237
  declare function getL3ForProbe(probe: ProbeResult[], path: string, method: HttpMethod): L3Result | null;
238
+ /**
239
+ * Probes `url` and populates `paymentRequiredBody` on each advisory so that
240
+ * getWarningsForL3 can run full 402-body validation. Mutates in place; no-ops on network error.
241
+ */
242
+ declare function attachProbePayload(url: string, advisories: Array<L3Result & {
243
+ method: HttpMethod;
244
+ }>): Promise<void>;
232
245
  declare function getL3(openApi: OpenApiSource | null, probe: ProbeResult[], path: string, method: HttpMethod): L3Result | null;
233
246
 
234
247
  declare function checkL4ForOpenAPI(openApi: OpenApiSource): L4Result | null;
@@ -239,6 +252,7 @@ declare const VALIDATION_CODES: {
239
252
  readonly X402_NOT_OBJECT: "X402_NOT_OBJECT";
240
253
  readonly X402_VERSION_MISSING: "X402_VERSION_MISSING";
241
254
  readonly X402_VERSION_UNSUPPORTED: "X402_VERSION_UNSUPPORTED";
255
+ readonly X402_VERSION_V1_NOT_SUPPORTED: "X402_VERSION_V1_NOT_SUPPORTED";
242
256
  readonly X402_ACCEPTS_MISSING: "X402_ACCEPTS_MISSING";
243
257
  readonly X402_ACCEPTS_INVALID: "X402_ACCEPTS_INVALID";
244
258
  readonly X402_ACCEPTS_EMPTY: "X402_ACCEPTS_EMPTY";
@@ -316,6 +330,10 @@ interface ValidatePaymentRequiredDetailedResult {
316
330
 
317
331
  declare function evaluateMetadataCompleteness(metadata: MetadataPreview): ValidationIssue[];
318
332
 
333
+ /**
334
+ * Validates a 402 response body. Delegates to getWarningsFor402Body (the canonical
335
+ * audit function) and reconstructs the full typed result shape for backwards compatibility.
336
+ */
319
337
  declare function validatePaymentRequiredDetailed(payload: unknown, options?: ValidatePaymentRequiredOptions): ValidatePaymentRequiredDetailedResult;
320
338
 
321
339
  declare const AUDIT_CODES: {
@@ -327,6 +345,7 @@ declare const AUDIT_CODES: {
327
345
  readonly L2_AUTH_MODE_MISSING: "L2_AUTH_MODE_MISSING";
328
346
  readonly L2_NO_PAID_ROUTES: "L2_NO_PAID_ROUTES";
329
347
  readonly L2_PRICE_MISSING_ON_PAID: "L2_PRICE_MISSING_ON_PAID";
348
+ readonly L2_PRICING_MODE_UNKNOWN: "L2_PRICING_MODE_UNKNOWN";
330
349
  readonly L2_PROTOCOLS_MISSING_ON_PAID: "L2_PROTOCOLS_MISSING_ON_PAID";
331
350
  readonly L3_NOT_FOUND: "L3_NOT_FOUND";
332
351
  readonly L3_INPUT_SCHEMA_MISSING: "L3_INPUT_SCHEMA_MISSING";
@@ -349,8 +368,18 @@ interface AuditWarning {
349
368
 
350
369
  declare function getWarningsForOpenAPI(openApi: OpenApiSource | null): AuditWarning[];
351
370
  declare function getWarningsForWellKnown(wellKnown: WellKnownSource | null): AuditWarning[];
371
+
352
372
  declare function getWarningsForL2(l2: L2Result): AuditWarning[];
373
+
374
+ /**
375
+ * Validates a raw 402 response body and returns issues as AuditWarnings.
376
+ * Uses the v1/v2 protocol validators directly — the canonical source of truth
377
+ * for 402 body quality checks. x402scan should call this instead of
378
+ * validatePaymentRequiredDetailed.
379
+ */
380
+ declare function getWarningsFor402Body(body: unknown): AuditWarning[];
353
381
  declare function getWarningsForL3(l3: L3Result | null): AuditWarning[];
382
+
354
383
  declare function getWarningsForL4(l4: L4Result | null): AuditWarning[];
355
384
 
356
- 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 };
385
+ 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
@@ -59,7 +59,7 @@ interface X402V2PaymentOption {
59
59
  type X402PaymentOption = X402V1PaymentOption | X402V2PaymentOption;
60
60
  type PaymentOption = X402PaymentOption | MppPaymentOption;
61
61
  interface PricingHint {
62
- pricingMode: PricingMode;
62
+ pricingMode: PricingMode | string;
63
63
  price?: string;
64
64
  minPrice?: string;
65
65
  maxPrice?: string;
@@ -116,6 +116,7 @@ interface L2Route {
116
116
  summary: string;
117
117
  authMode?: AuthMode;
118
118
  price?: string;
119
+ pricingMode?: string;
119
120
  protocols?: string[];
120
121
  }
121
122
  interface L3Result {
@@ -128,6 +129,11 @@ interface L3Result {
128
129
  outputSchema?: Record<string, unknown>;
129
130
  /** Live payment options parsed from the 402 response. Only present on probe results. */
130
131
  paymentOptions?: PaymentOption[];
132
+ /**
133
+ * Raw 402 response body captured during probing. Present when the endpoint was probed
134
+ * and returned a 402. Used by getWarningsForL3 to run full payment-required validation.
135
+ */
136
+ paymentRequiredBody?: unknown;
131
137
  }
132
138
  interface L4Result {
133
139
  guidance: string;
@@ -229,6 +235,13 @@ declare function checkL2ForWellknown(wellKnown: WellKnownSource): L2Result;
229
235
 
230
236
  declare function getL3ForOpenAPI(openApi: OpenApiSource, path: string, method: HttpMethod): L3Result | null;
231
237
  declare function getL3ForProbe(probe: ProbeResult[], path: string, method: HttpMethod): L3Result | null;
238
+ /**
239
+ * Probes `url` and populates `paymentRequiredBody` on each advisory so that
240
+ * getWarningsForL3 can run full 402-body validation. Mutates in place; no-ops on network error.
241
+ */
242
+ declare function attachProbePayload(url: string, advisories: Array<L3Result & {
243
+ method: HttpMethod;
244
+ }>): Promise<void>;
232
245
  declare function getL3(openApi: OpenApiSource | null, probe: ProbeResult[], path: string, method: HttpMethod): L3Result | null;
233
246
 
234
247
  declare function checkL4ForOpenAPI(openApi: OpenApiSource): L4Result | null;
@@ -239,6 +252,7 @@ declare const VALIDATION_CODES: {
239
252
  readonly X402_NOT_OBJECT: "X402_NOT_OBJECT";
240
253
  readonly X402_VERSION_MISSING: "X402_VERSION_MISSING";
241
254
  readonly X402_VERSION_UNSUPPORTED: "X402_VERSION_UNSUPPORTED";
255
+ readonly X402_VERSION_V1_NOT_SUPPORTED: "X402_VERSION_V1_NOT_SUPPORTED";
242
256
  readonly X402_ACCEPTS_MISSING: "X402_ACCEPTS_MISSING";
243
257
  readonly X402_ACCEPTS_INVALID: "X402_ACCEPTS_INVALID";
244
258
  readonly X402_ACCEPTS_EMPTY: "X402_ACCEPTS_EMPTY";
@@ -316,6 +330,10 @@ interface ValidatePaymentRequiredDetailedResult {
316
330
 
317
331
  declare function evaluateMetadataCompleteness(metadata: MetadataPreview): ValidationIssue[];
318
332
 
333
+ /**
334
+ * Validates a 402 response body. Delegates to getWarningsFor402Body (the canonical
335
+ * audit function) and reconstructs the full typed result shape for backwards compatibility.
336
+ */
319
337
  declare function validatePaymentRequiredDetailed(payload: unknown, options?: ValidatePaymentRequiredOptions): ValidatePaymentRequiredDetailedResult;
320
338
 
321
339
  declare const AUDIT_CODES: {
@@ -327,6 +345,7 @@ declare const AUDIT_CODES: {
327
345
  readonly L2_AUTH_MODE_MISSING: "L2_AUTH_MODE_MISSING";
328
346
  readonly L2_NO_PAID_ROUTES: "L2_NO_PAID_ROUTES";
329
347
  readonly L2_PRICE_MISSING_ON_PAID: "L2_PRICE_MISSING_ON_PAID";
348
+ readonly L2_PRICING_MODE_UNKNOWN: "L2_PRICING_MODE_UNKNOWN";
330
349
  readonly L2_PROTOCOLS_MISSING_ON_PAID: "L2_PROTOCOLS_MISSING_ON_PAID";
331
350
  readonly L3_NOT_FOUND: "L3_NOT_FOUND";
332
351
  readonly L3_INPUT_SCHEMA_MISSING: "L3_INPUT_SCHEMA_MISSING";
@@ -349,8 +368,18 @@ interface AuditWarning {
349
368
 
350
369
  declare function getWarningsForOpenAPI(openApi: OpenApiSource | null): AuditWarning[];
351
370
  declare function getWarningsForWellKnown(wellKnown: WellKnownSource | null): AuditWarning[];
371
+
352
372
  declare function getWarningsForL2(l2: L2Result): AuditWarning[];
373
+
374
+ /**
375
+ * Validates a raw 402 response body and returns issues as AuditWarnings.
376
+ * Uses the v1/v2 protocol validators directly — the canonical source of truth
377
+ * for 402 body quality checks. x402scan should call this instead of
378
+ * validatePaymentRequiredDetailed.
379
+ */
380
+ declare function getWarningsFor402Body(body: unknown): AuditWarning[];
353
381
  declare function getWarningsForL3(l3: L3Result | null): AuditWarning[];
382
+
354
383
  declare function getWarningsForL4(l4: L4Result | null): AuditWarning[];
355
384
 
356
- 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 };
385
+ 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 };