uvd-x402-sdk 2.41.0 → 2.42.0
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/README.md +40 -16
- package/dist/backend/index.d.mts +245 -230
- package/dist/backend/index.d.ts +245 -230
- package/dist/backend/index.js +128 -331
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs +124 -332
- package/dist/backend/index.mjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/backend/index.ts +361 -562
package/README.md
CHANGED
|
@@ -1014,34 +1014,58 @@ The facilitator's `/supported` endpoint advertises both `'escrow'` and `'commerc
|
|
|
1014
1014
|
|
|
1015
1015
|
Register and discover paid x402 resources across the network.
|
|
1016
1016
|
|
|
1017
|
+
The Bazaar is served by the facilitator itself under `/discovery/*`. No API key, no separate host.
|
|
1018
|
+
|
|
1017
1019
|
```typescript
|
|
1018
|
-
import { BazaarClient } from 'uvd-x402-sdk/backend';
|
|
1020
|
+
import { BazaarClient, isAlive } from 'uvd-x402-sdk/backend';
|
|
1019
1021
|
|
|
1020
|
-
const bazaar = new BazaarClient(
|
|
1022
|
+
const bazaar = new BazaarClient();
|
|
1021
1023
|
|
|
1022
|
-
//
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1024
|
+
// List resources. Every filter is applied server-side over the whole catalog,
|
|
1025
|
+
// so `pagination.total` is the real number of matches -- filtering one page
|
|
1026
|
+
// locally is not the same thing and will under-report.
|
|
1027
|
+
const page = await bazaar.listResources({
|
|
1028
|
+
network: 'eip155:8453',
|
|
1029
|
+
health: 'alive', // only endpoints a probe actually reached
|
|
1030
|
+
tier: 'vip', // first_party | vip | verified | listed
|
|
1031
|
+
limit: 20,
|
|
1027
1032
|
});
|
|
1028
1033
|
|
|
1029
|
-
for (const
|
|
1030
|
-
console.log(`${
|
|
1034
|
+
for (const r of page.items) {
|
|
1035
|
+
console.log(r.url, r.health?.status, `${r.health?.latencyMs}ms`, r.curation?.label);
|
|
1036
|
+
}
|
|
1037
|
+
console.log(`${page.items.length} of ${page.pagination.total}`);
|
|
1038
|
+
|
|
1039
|
+
// Free-text search. The parameter is `q`; anything else is rejected with a 400.
|
|
1040
|
+
const hits = await bazaar.listResources({ q: 'logs' });
|
|
1041
|
+
|
|
1042
|
+
// Walk the whole filtered catalog, one page at a time
|
|
1043
|
+
for await (const r of bazaar.iterateResources({ health: 'alive' })) {
|
|
1044
|
+
if (isAlive(r)) console.log(r.url);
|
|
1031
1045
|
}
|
|
1032
1046
|
|
|
1033
|
-
// Register a resource
|
|
1034
|
-
|
|
1047
|
+
// Register a resource. Registration is open and rate limited.
|
|
1048
|
+
await bazaar.registerResource({
|
|
1035
1049
|
url: 'https://api.example.com/v1/generate',
|
|
1036
|
-
name: 'Image Generator API',
|
|
1037
1050
|
description: 'Generate images with AI',
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1051
|
+
accepts: [{
|
|
1052
|
+
scheme: 'exact',
|
|
1053
|
+
network: 'eip155:8453',
|
|
1054
|
+
asset: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
1055
|
+
amount: '50000',
|
|
1056
|
+
payTo: '0x1234...',
|
|
1057
|
+
maxTimeoutSeconds: 60,
|
|
1058
|
+
}],
|
|
1059
|
+
metadata: { category: 'ai', tags: ['image'] },
|
|
1042
1060
|
});
|
|
1061
|
+
|
|
1062
|
+
// Aggregate catalog metrics
|
|
1063
|
+
const stats = await bazaar.getStats();
|
|
1064
|
+
console.log(stats.total, stats.visible, stats.byHealth.alive);
|
|
1043
1065
|
```
|
|
1044
1066
|
|
|
1067
|
+
Timestamps (`firstSeen`, `lastSeen`, `lastUpdated`, `health.lastChecked`) are Unix epoch **seconds**. Use `epochToDate()` to get a `Date`.
|
|
1068
|
+
|
|
1045
1069
|
## Facilitator Info
|
|
1046
1070
|
|
|
1047
1071
|
Query the facilitator for version, supported networks, and compliance data.
|
package/dist/backend/index.d.mts
CHANGED
|
@@ -526,301 +526,316 @@ declare function createHonoMiddleware(options: HonoMiddlewareOptions): (c: {
|
|
|
526
526
|
set?: (key: string, value: unknown) => void;
|
|
527
527
|
}, next: () => Promise<void>) => Promise<unknown>;
|
|
528
528
|
/**
|
|
529
|
-
*
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
* Network/chain filter for discovery
|
|
534
|
-
*/
|
|
535
|
-
type BazaarNetwork = 'base' | 'ethereum' | 'polygon' | 'arbitrum' | 'optimism' | 'avalanche' | 'celo' | 'hyperevm' | 'unichain' | 'monad' | 'scroll' | 'skale-base' | 'robinhood' | 'robinhood-testnet' | 'solana' | 'fogo' | 'stellar' | 'near' | 'algorand' | 'sui' | 'xrpl-mainnet' | 'xrpl-testnet';
|
|
536
|
-
/**
|
|
537
|
-
* Token/asset filter for discovery
|
|
529
|
+
* Maximum length of the free-text `q` filter.
|
|
530
|
+
*
|
|
531
|
+
* Mirrors the facilitator's `MAX_SEARCH_LEN`; a longer needle is rejected
|
|
532
|
+
* server-side with a 400.
|
|
538
533
|
*/
|
|
539
|
-
|
|
534
|
+
declare const MAX_SEARCH_LEN = 128;
|
|
540
535
|
/**
|
|
541
|
-
*
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
/**
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
536
|
+
* Liveness of a registered resource, as measured by the facilitator's prober.
|
|
537
|
+
*
|
|
538
|
+
* Resources that stop answering are quarantined rather than deleted, so filter
|
|
539
|
+
* on this before paying anyone.
|
|
540
|
+
*/
|
|
541
|
+
type DiscoveryHealthStatus = 'alive' | 'degraded' | 'auth_gated' | 'quarantined' | 'unknown' | 'unprobeable';
|
|
542
|
+
/** Values accepted by the `health` filter, including the `any` escape hatch. */
|
|
543
|
+
declare const HEALTH_FILTERS: readonly ["alive", "degraded", "auth_gated", "quarantined", "unknown", "unprobeable", "any"];
|
|
544
|
+
/** Curated tier, in descending order of trust. */
|
|
545
|
+
type DiscoveryTier = 'first_party' | 'vip' | 'verified' | 'listed';
|
|
546
|
+
/** Values accepted by the `tier` filter. */
|
|
547
|
+
declare const TIER_FILTERS: readonly ["first_party", "vip", "verified", "listed"];
|
|
548
|
+
/** How a resource got into the registry. */
|
|
549
|
+
type DiscoverySource = 'self_registered' | 'settlement' | 'crawled' | 'aggregated';
|
|
550
|
+
/** Health of a single resource, as reported by the registry's prober. */
|
|
551
|
+
interface DiscoveryHealth {
|
|
552
|
+
/** Last observed liveness */
|
|
553
|
+
status?: DiscoveryHealthStatus;
|
|
554
|
+
/** Unix epoch seconds of the last probe */
|
|
555
|
+
lastChecked?: number;
|
|
556
|
+
/** HTTP status the probe got back (402 is the healthy answer for x402) */
|
|
557
|
+
httpStatus?: number;
|
|
558
|
+
/** Round-trip time of the last probe, in milliseconds */
|
|
559
|
+
latencyMs?: number;
|
|
560
|
+
}
|
|
561
|
+
/** Curation metadata attached to a resource. */
|
|
562
|
+
interface DiscoveryCuration {
|
|
563
|
+
/** Curated tier */
|
|
564
|
+
tier?: DiscoveryTier;
|
|
565
|
+
/** Human-readable name of the curated set */
|
|
566
|
+
label?: string;
|
|
567
|
+
}
|
|
568
|
+
/** One payment method a resource declares. */
|
|
569
|
+
interface DiscoveryAccepts {
|
|
570
|
+
/** Payment scheme ("exact", "escrow", "commerce") */
|
|
571
|
+
scheme: string;
|
|
572
|
+
/** CAIP-2 network id, e.g. "eip155:8453" */
|
|
573
|
+
network: string;
|
|
574
|
+
/** Token contract address */
|
|
575
|
+
asset?: string;
|
|
576
|
+
/** Price in atomic units of `asset` */
|
|
577
|
+
amount?: string;
|
|
578
|
+
/** Recipient address */
|
|
579
|
+
payTo?: string;
|
|
580
|
+
/** Settlement deadline in seconds */
|
|
581
|
+
maxTimeoutSeconds?: number;
|
|
582
|
+
/** Scheme-specific extras (EIP-712 domain, etc.) */
|
|
583
|
+
extra?: Record<string, unknown>;
|
|
584
|
+
/** Anything the registry adds later */
|
|
585
|
+
[key: string]: unknown;
|
|
578
586
|
}
|
|
579
587
|
/**
|
|
580
|
-
*
|
|
588
|
+
* A discoverable paid resource, exactly as `GET /discovery/resources` serves it.
|
|
589
|
+
*
|
|
590
|
+
* Timestamps are Unix epoch **seconds**, not ISO strings and not milliseconds.
|
|
581
591
|
*/
|
|
582
|
-
interface
|
|
583
|
-
/** Resource URL
|
|
592
|
+
interface DiscoveryResource {
|
|
593
|
+
/** Resource URL. This is the registry's primary key -- there is no `id` */
|
|
584
594
|
url: string;
|
|
585
|
-
/**
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
|
|
593
|
-
/**
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
|
|
599
|
-
/**
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
|
|
595
|
+
/** Resource type ("http", "mcp", "a2a") */
|
|
596
|
+
type: string;
|
|
597
|
+
/** x402 protocol version the resource speaks */
|
|
598
|
+
x402Version: number;
|
|
599
|
+
/** Human-readable description */
|
|
600
|
+
description?: string;
|
|
601
|
+
/** Payment methods the resource accepts */
|
|
602
|
+
accepts: DiscoveryAccepts[];
|
|
603
|
+
/** Free-form metadata (category, provider, tags) */
|
|
604
|
+
metadata?: Record<string, unknown>;
|
|
605
|
+
/** How this resource entered the registry */
|
|
606
|
+
source?: DiscoverySource;
|
|
607
|
+
/** Facilitator this resource was aggregated from */
|
|
608
|
+
sourceFacilitator?: string;
|
|
609
|
+
/** Unix epoch seconds when the registry first saw this resource */
|
|
610
|
+
firstSeen?: number;
|
|
611
|
+
/** Unix epoch seconds when the registry last saw this resource */
|
|
612
|
+
lastSeen?: number;
|
|
613
|
+
/** Unix epoch seconds of the last change to this record */
|
|
614
|
+
lastUpdated?: number;
|
|
615
|
+
/** Liveness, when the resource has been probed */
|
|
616
|
+
health?: DiscoveryHealth;
|
|
617
|
+
/** Curation tier, when the resource has been curated */
|
|
618
|
+
curation?: DiscoveryCuration;
|
|
619
|
+
/** Anything the registry adds later */
|
|
620
|
+
[key: string]: unknown;
|
|
621
|
+
}
|
|
622
|
+
/** Pagination envelope of `GET /discovery/resources`. */
|
|
623
|
+
interface DiscoveryPagination {
|
|
624
|
+
/** Page size that was applied */
|
|
625
|
+
limit: number;
|
|
626
|
+
/** Offset that was applied */
|
|
627
|
+
offset: number;
|
|
628
|
+
/** Total number of resources matching the filters, across all pages */
|
|
629
|
+
total: number;
|
|
630
|
+
}
|
|
631
|
+
/** Paginated response from `GET /discovery/resources`. */
|
|
632
|
+
interface DiscoveryResponse {
|
|
633
|
+
/** x402 protocol version of the response envelope */
|
|
634
|
+
x402Version: number;
|
|
635
|
+
/** Resources on this page */
|
|
636
|
+
items: DiscoveryResource[];
|
|
637
|
+
/** Pagination state */
|
|
638
|
+
pagination: DiscoveryPagination;
|
|
607
639
|
}
|
|
608
640
|
/**
|
|
609
|
-
*
|
|
641
|
+
* Filters for `listResources()`.
|
|
642
|
+
*
|
|
643
|
+
* Every one of these is applied server-side over the whole catalog, so
|
|
644
|
+
* `pagination.total` reflects the filtered set. Filtering a page after the
|
|
645
|
+
* fact is not the same thing and will under-report.
|
|
610
646
|
*/
|
|
611
|
-
interface
|
|
647
|
+
interface DiscoveryListOptions {
|
|
648
|
+
/** Page size (default: 10, max: 100) */
|
|
649
|
+
limit?: number;
|
|
650
|
+
/** Number of resources to skip */
|
|
651
|
+
offset?: number;
|
|
612
652
|
/** Filter by category */
|
|
613
|
-
category?:
|
|
614
|
-
/** Filter by network */
|
|
615
|
-
network?:
|
|
616
|
-
/** Filter by
|
|
617
|
-
token?: BazaarToken;
|
|
618
|
-
/** Filter by provider address */
|
|
653
|
+
category?: string;
|
|
654
|
+
/** Filter by network, CAIP-2 or v1 name */
|
|
655
|
+
network?: string;
|
|
656
|
+
/** Filter by provider name */
|
|
619
657
|
provider?: string;
|
|
620
|
-
/** Filter by
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
|
|
624
|
-
/**
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
|
|
628
|
-
/**
|
|
629
|
-
|
|
630
|
-
/**
|
|
631
|
-
|
|
632
|
-
/** Sort direction */
|
|
633
|
-
sortOrder?: 'asc' | 'desc';
|
|
658
|
+
/** Filter by tag */
|
|
659
|
+
tag?: string;
|
|
660
|
+
/** Filter by how the resource was discovered */
|
|
661
|
+
source?: DiscoverySource;
|
|
662
|
+
/** Filter by originating facilitator */
|
|
663
|
+
sourceFacilitator?: string;
|
|
664
|
+
/** Filter by liveness, or 'any' to opt out of the default visibility rules */
|
|
665
|
+
health?: DiscoveryHealthStatus | 'any';
|
|
666
|
+
/** Filter by curated tier */
|
|
667
|
+
tier?: DiscoveryTier;
|
|
668
|
+
/** Free-text search over url / description / provider / category / tags */
|
|
669
|
+
q?: string;
|
|
634
670
|
}
|
|
635
|
-
/**
|
|
636
|
-
|
|
637
|
-
*/
|
|
638
|
-
|
|
639
|
-
/**
|
|
640
|
-
|
|
641
|
-
/**
|
|
671
|
+
/** Options for `registerResource()`. */
|
|
672
|
+
interface DiscoveryRegisterOptions {
|
|
673
|
+
/** URL of the paid resource. Doubles as its identity in the registry */
|
|
674
|
+
url: string;
|
|
675
|
+
/** Resource type (default: "http") */
|
|
676
|
+
type?: string;
|
|
677
|
+
/** Human-readable description */
|
|
678
|
+
description?: string;
|
|
679
|
+
/** Payment methods the resource accepts */
|
|
680
|
+
accepts?: DiscoveryAccepts[];
|
|
681
|
+
/** Free-form metadata (category, provider, tags) */
|
|
682
|
+
metadata?: Record<string, unknown>;
|
|
683
|
+
}
|
|
684
|
+
/** Aggregate catalog metrics from `GET /discovery/stats`. */
|
|
685
|
+
interface DiscoveryStats {
|
|
686
|
+
/** Every record the registry holds, including quarantined ones */
|
|
642
687
|
total: number;
|
|
643
|
-
/**
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
|
|
688
|
+
/** Records served by default listings */
|
|
689
|
+
visible: number;
|
|
690
|
+
/** Counts by discovery source */
|
|
691
|
+
bySource: Record<string, number>;
|
|
692
|
+
/** Counts by originating facilitator */
|
|
693
|
+
bySourceFacilitator: Record<string, number>;
|
|
694
|
+
/** Counts by CAIP-2 network */
|
|
695
|
+
byNetwork: Record<string, number>;
|
|
696
|
+
/** Counts by curated tier */
|
|
697
|
+
byTier: Record<string, number>;
|
|
698
|
+
/** Counts by liveness */
|
|
699
|
+
byHealth: Record<string, number>;
|
|
700
|
+
/** Unix epoch seconds this snapshot was computed (60s cache) */
|
|
701
|
+
generatedAt?: number;
|
|
651
702
|
}
|
|
652
|
-
/**
|
|
653
|
-
* Options for the BazaarClient
|
|
654
|
-
*/
|
|
703
|
+
/** Options for the {@link BazaarClient}. */
|
|
655
704
|
interface BazaarClientOptions {
|
|
656
|
-
/**
|
|
705
|
+
/** Facilitator base URL (default: https://facilitator.ultravioletadao.xyz) */
|
|
657
706
|
baseUrl?: string;
|
|
658
|
-
/** API key for authenticated operations (required for register/update/delete) */
|
|
659
|
-
apiKey?: string;
|
|
660
707
|
/** Request timeout in milliseconds (default: 30000) */
|
|
661
708
|
timeout?: number;
|
|
662
709
|
}
|
|
710
|
+
/** Render an epoch-seconds field as a `Date`. */
|
|
711
|
+
declare function epochToDate(seconds?: number): Date | undefined;
|
|
712
|
+
/** True when the last probe reached this resource. */
|
|
713
|
+
declare function isAlive(resource: DiscoveryResource): boolean;
|
|
663
714
|
/**
|
|
664
|
-
* Client for
|
|
715
|
+
* Client for the x402 Bazaar Discovery API.
|
|
665
716
|
*
|
|
666
|
-
* The Bazaar is
|
|
667
|
-
* Providers
|
|
717
|
+
* The Bazaar is the facilitator's own registry of x402-enabled resources.
|
|
718
|
+
* Providers register their endpoints and consumers discover them, with a
|
|
719
|
+
* liveness probe and a curation tier attached to every record.
|
|
668
720
|
*
|
|
669
721
|
* @example
|
|
670
722
|
* ```ts
|
|
671
|
-
* // Discover resources (no auth required)
|
|
672
723
|
* const bazaar = new BazaarClient();
|
|
673
|
-
* const results = await bazaar.discover({
|
|
674
|
-
* category: 'ai',
|
|
675
|
-
* network: 'base',
|
|
676
|
-
* maxPrice: '0.10',
|
|
677
|
-
* });
|
|
678
724
|
*
|
|
679
|
-
* //
|
|
680
|
-
* const
|
|
681
|
-
* const
|
|
682
|
-
* url
|
|
683
|
-
*
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
*
|
|
688
|
-
*
|
|
725
|
+
* // Only endpoints a probe actually reached, best-curated first
|
|
726
|
+
* const page = await bazaar.listResources({ limit: 20, health: 'alive', tier: 'vip' });
|
|
727
|
+
* for (const r of page.items) {
|
|
728
|
+
* console.log(r.url, r.health?.status, r.health?.latencyMs, r.curation?.label);
|
|
729
|
+
* }
|
|
730
|
+
*
|
|
731
|
+
* // Free-text search runs server-side over the whole catalog
|
|
732
|
+
* const hits = await bazaar.listResources({ q: 'logs' });
|
|
733
|
+
* console.log(hits.pagination.total);
|
|
734
|
+
*
|
|
735
|
+
* // Register your own
|
|
736
|
+
* await bazaar.registerResource({
|
|
737
|
+
* url: 'https://api.example.com/v1/generate',
|
|
738
|
+
* description: 'Generate images with AI',
|
|
739
|
+
* accepts: [{
|
|
740
|
+
* scheme: 'exact',
|
|
741
|
+
* network: 'eip155:8453',
|
|
742
|
+
* asset: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
743
|
+
* amount: '10000',
|
|
744
|
+
* payTo: '0xYourWallet...',
|
|
745
|
+
* maxTimeoutSeconds: 60,
|
|
746
|
+
* }],
|
|
747
|
+
* metadata: { category: 'ai', tags: ['image'] },
|
|
689
748
|
* });
|
|
690
749
|
* ```
|
|
691
750
|
*/
|
|
692
751
|
declare class BazaarClient {
|
|
693
752
|
private readonly baseUrl;
|
|
694
|
-
private readonly apiKey?;
|
|
695
753
|
private readonly timeout;
|
|
696
754
|
constructor(options?: BazaarClientOptions);
|
|
697
755
|
/**
|
|
698
|
-
*
|
|
756
|
+
* Issue a request against the facilitator with the configured timeout.
|
|
757
|
+
*/
|
|
758
|
+
private request;
|
|
759
|
+
/**
|
|
760
|
+
* List resources from the discovery registry.
|
|
699
761
|
*
|
|
700
|
-
* @param options -
|
|
701
|
-
* @returns
|
|
762
|
+
* @param options - Server-side filters and pagination
|
|
763
|
+
* @returns One page of resources plus the total across all pages
|
|
702
764
|
*
|
|
703
765
|
* @example
|
|
704
766
|
* ```ts
|
|
705
|
-
*
|
|
706
|
-
* const results = await bazaar.discover({
|
|
707
|
-
* category: 'ai',
|
|
708
|
-
* network: 'base',
|
|
709
|
-
* token: 'USDC',
|
|
710
|
-
* maxPrice: '0.10',
|
|
711
|
-
* });
|
|
712
|
-
*
|
|
713
|
-
* for (const resource of results.resources) {
|
|
714
|
-
* console.log(`${resource.name}: ${resource.url}`);
|
|
715
|
-
* }
|
|
767
|
+
* const page = await bazaar.listResources({ network: 'eip155:8453', health: 'alive' });
|
|
716
768
|
* ```
|
|
717
769
|
*/
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* Get a specific resource by ID
|
|
721
|
-
*
|
|
722
|
-
* @param resourceId - Resource ID
|
|
723
|
-
* @returns Resource details
|
|
724
|
-
*/
|
|
725
|
-
getResource(resourceId: string): Promise<BazaarResource>;
|
|
726
|
-
/**
|
|
727
|
-
* Get a resource by its URL
|
|
728
|
-
*
|
|
729
|
-
* @param resourceUrl - Resource URL
|
|
730
|
-
* @returns Resource details
|
|
731
|
-
*/
|
|
732
|
-
getResourceByUrl(resourceUrl: string): Promise<BazaarResource>;
|
|
770
|
+
listResources(options?: DiscoveryListOptions): Promise<DiscoveryResponse>;
|
|
733
771
|
/**
|
|
734
|
-
*
|
|
772
|
+
* Walk the whole filtered catalog, one page at a time.
|
|
735
773
|
*
|
|
736
|
-
*
|
|
774
|
+
* Pages are fetched in sequence rather than in parallel: the read routes are
|
|
775
|
+
* rate limited, and a burst of parallel pages is how a legitimate catalog
|
|
776
|
+
* walk turns into a wall of 429s.
|
|
737
777
|
*
|
|
738
|
-
* @param options -
|
|
739
|
-
* @returns Registered resource
|
|
778
|
+
* @param options - Same filters as {@link listResources}; `limit` is the page size
|
|
740
779
|
*
|
|
741
780
|
* @example
|
|
742
781
|
* ```ts
|
|
743
|
-
* const
|
|
744
|
-
*
|
|
745
|
-
*
|
|
746
|
-
* description: 'Generate images with AI',
|
|
747
|
-
* category: 'ai',
|
|
748
|
-
* networks: ['base', 'ethereum', 'polygon'],
|
|
749
|
-
* price: '0.05',
|
|
750
|
-
* payTo: '0x1234...',
|
|
751
|
-
* tags: ['ai', 'image', 'generator'],
|
|
752
|
-
* });
|
|
782
|
+
* for await (const r of bazaar.iterateResources({ health: 'alive' })) {
|
|
783
|
+
* console.log(r.url);
|
|
784
|
+
* }
|
|
753
785
|
* ```
|
|
754
786
|
*/
|
|
755
|
-
|
|
756
|
-
/**
|
|
757
|
-
* Update an existing resource
|
|
758
|
-
*
|
|
759
|
-
* Requires API key authentication. Only the owner can update.
|
|
760
|
-
*
|
|
761
|
-
* @param resourceId - Resource ID to update
|
|
762
|
-
* @param updates - Partial update options
|
|
763
|
-
* @returns Updated resource
|
|
764
|
-
*/
|
|
765
|
-
update(resourceId: string, updates: Partial<BazaarRegisterOptions>): Promise<BazaarResource>;
|
|
787
|
+
iterateResources(options?: DiscoveryListOptions): AsyncGenerator<DiscoveryResource, void, undefined>;
|
|
766
788
|
/**
|
|
767
|
-
*
|
|
789
|
+
* Look up a single resource by its URL.
|
|
768
790
|
*
|
|
769
|
-
*
|
|
791
|
+
* The registry keys on URL and has no by-id lookup, so this searches and
|
|
792
|
+
* then matches exactly.
|
|
770
793
|
*
|
|
771
|
-
* @param
|
|
794
|
+
* @param resourceUrl - Exact URL of the resource
|
|
795
|
+
* @returns The resource, or null when it is not registered
|
|
772
796
|
*/
|
|
773
|
-
|
|
797
|
+
getResourceByUrl(resourceUrl: string): Promise<DiscoveryResource | null>;
|
|
774
798
|
/**
|
|
775
|
-
*
|
|
799
|
+
* Register a paid resource in the discovery registry.
|
|
776
800
|
*
|
|
777
|
-
*
|
|
801
|
+
* Registration is open and rate limited; re-registering a known URL updates
|
|
802
|
+
* the existing record rather than creating a duplicate.
|
|
778
803
|
*
|
|
779
|
-
* @param
|
|
780
|
-
* @returns
|
|
804
|
+
* @param options - Resource details
|
|
805
|
+
* @returns The registry's acknowledgement
|
|
781
806
|
*/
|
|
782
|
-
|
|
807
|
+
registerResource(options: DiscoveryRegisterOptions): Promise<Record<string, unknown>>;
|
|
783
808
|
/**
|
|
784
|
-
*
|
|
809
|
+
* Aggregate catalog metrics (60s cached server-side).
|
|
785
810
|
*
|
|
786
|
-
*
|
|
787
|
-
*
|
|
788
|
-
* @param resourceId - Resource ID to reactivate
|
|
789
|
-
* @returns Updated resource with isActive: true
|
|
811
|
+
* @returns Counts by source, facilitator, network, tier and liveness
|
|
790
812
|
*/
|
|
791
|
-
|
|
813
|
+
getStats(): Promise<DiscoveryStats>;
|
|
792
814
|
/**
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
* Requires API key authentication.
|
|
815
|
+
* Check that the facilitator serving the registry is up.
|
|
796
816
|
*
|
|
797
|
-
* @
|
|
798
|
-
* @returns Paginated list of owned resources
|
|
799
|
-
*/
|
|
800
|
-
listMyResources(options?: {
|
|
801
|
-
page?: number;
|
|
802
|
-
limit?: number;
|
|
803
|
-
includeInactive?: boolean;
|
|
804
|
-
}): Promise<BazaarDiscoverResponse>;
|
|
805
|
-
/**
|
|
806
|
-
* Get Bazaar API health status
|
|
807
|
-
*
|
|
808
|
-
* @returns True if the Bazaar API is healthy
|
|
817
|
+
* @returns True when the facilitator answers its health check
|
|
809
818
|
*/
|
|
810
819
|
healthCheck(): Promise<boolean>;
|
|
811
820
|
/**
|
|
812
|
-
*
|
|
813
|
-
*
|
|
814
|
-
*
|
|
821
|
+
* @deprecated Renamed to {@link listResources}, which returns the registry's
|
|
822
|
+
* real `{ items, pagination }` envelope. The old `discover()` returned a
|
|
823
|
+
* `{ resources, page, totalPages }` shape that no endpoint ever served.
|
|
815
824
|
*/
|
|
816
|
-
|
|
817
|
-
totalResources: number;
|
|
818
|
-
activeResources: number;
|
|
819
|
-
totalProviders: number;
|
|
820
|
-
categoryCounts: Record<BazaarCategory, number>;
|
|
821
|
-
networkCounts: Record<BazaarNetwork, number>;
|
|
822
|
-
}>;
|
|
825
|
+
discover(options?: DiscoveryListOptions): Promise<DiscoveryResponse>;
|
|
823
826
|
}
|
|
827
|
+
/**
|
|
828
|
+
* @deprecated Use {@link DiscoveryResource}. The old shape (`id`, `name`,
|
|
829
|
+
* `pricePerRequest`, `isActive`, ISO `createdAt`) described an API that was
|
|
830
|
+
* never deployed.
|
|
831
|
+
*/
|
|
832
|
+
type BazaarResource = DiscoveryResource;
|
|
833
|
+
/** @deprecated Use {@link DiscoveryResponse}. */
|
|
834
|
+
type BazaarDiscoverResponse = DiscoveryResponse;
|
|
835
|
+
/** @deprecated Use {@link DiscoveryListOptions}. */
|
|
836
|
+
type BazaarDiscoverOptions = DiscoveryListOptions;
|
|
837
|
+
/** @deprecated Use {@link DiscoveryRegisterOptions}. */
|
|
838
|
+
type BazaarRegisterOptions = DiscoveryRegisterOptions;
|
|
824
839
|
/**
|
|
825
840
|
* Escrow payment status
|
|
826
841
|
*/
|
|
@@ -2171,4 +2186,4 @@ declare class AdvancedEscrowClient {
|
|
|
2171
2186
|
private sendViaAdapter;
|
|
2172
2187
|
}
|
|
2173
2188
|
|
|
2174
|
-
export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS,
|
|
2189
|
+
export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, parsePaymentHeader };
|