uvd-x402-sdk 2.41.0 → 2.43.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 +98 -16
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/backend/index.d.mts +246 -231
- package/dist/backend/index.d.ts +246 -231
- 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-BJrBRC2u.d.mts → index-Bw4S80Ph.d.mts} +2 -2
- package/dist/{index-m2PwYmcQ.d.ts → index-Dgus5K-7.d.ts} +2 -2
- package/dist/{index-DBCFd6mO.d.mts → index-NDRI_c7e.d.mts} +1 -1
- package/dist/{index-DBCFd6mO.d.ts → index-NDRI_c7e.d.ts} +1 -1
- package/dist/index.d.mts +148 -3
- package/dist/index.d.ts +148 -3
- package/dist/index.js +142 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +136 -1
- package/dist/index.mjs.map +1 -1
- package/dist/providers/algorand/index.d.mts +1 -1
- package/dist/providers/algorand/index.d.ts +1 -1
- package/dist/providers/evm/index.d.mts +1 -1
- package/dist/providers/evm/index.d.ts +1 -1
- package/dist/providers/near/index.d.mts +1 -1
- package/dist/providers/near/index.d.ts +1 -1
- package/dist/providers/solana/index.d.mts +1 -1
- package/dist/providers/solana/index.d.ts +1 -1
- package/dist/providers/stellar/index.d.mts +1 -1
- package/dist/providers/stellar/index.d.ts +1 -1
- package/dist/providers/sui/index.d.mts +1 -1
- package/dist/providers/sui/index.d.ts +1 -1
- package/dist/providers/xrpl/index.d.mts +1 -1
- package/dist/providers/xrpl/index.d.ts +1 -1
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/backend/index.ts +361 -562
- package/src/events.ts +301 -0
- package/src/index.ts +17 -0
package/dist/backend/index.js
CHANGED
|
@@ -1692,404 +1692,196 @@ function createHonoMiddleware(options) {
|
|
|
1692
1692
|
await next();
|
|
1693
1693
|
};
|
|
1694
1694
|
}
|
|
1695
|
+
var MAX_SEARCH_LEN = 128;
|
|
1696
|
+
var HEALTH_FILTERS = [
|
|
1697
|
+
"alive",
|
|
1698
|
+
"degraded",
|
|
1699
|
+
"auth_gated",
|
|
1700
|
+
"quarantined",
|
|
1701
|
+
"unknown",
|
|
1702
|
+
"unprobeable",
|
|
1703
|
+
"any"
|
|
1704
|
+
];
|
|
1705
|
+
var TIER_FILTERS = [
|
|
1706
|
+
"first_party",
|
|
1707
|
+
"vip",
|
|
1708
|
+
"verified",
|
|
1709
|
+
"listed"
|
|
1710
|
+
];
|
|
1711
|
+
function epochToDate(seconds) {
|
|
1712
|
+
return seconds === void 0 ? void 0 : new Date(seconds * 1e3);
|
|
1713
|
+
}
|
|
1714
|
+
function isAlive(resource) {
|
|
1715
|
+
return resource.health?.status === "alive";
|
|
1716
|
+
}
|
|
1695
1717
|
var BazaarClient = class {
|
|
1696
1718
|
baseUrl;
|
|
1697
|
-
apiKey;
|
|
1698
1719
|
timeout;
|
|
1699
1720
|
constructor(options = {}) {
|
|
1700
|
-
this.baseUrl = options.baseUrl || "https://
|
|
1701
|
-
this.apiKey = options.apiKey;
|
|
1721
|
+
this.baseUrl = (options.baseUrl || "https://facilitator.ultravioletadao.xyz").replace(/\/+$/, "");
|
|
1702
1722
|
this.timeout = options.timeout || 3e4;
|
|
1703
1723
|
}
|
|
1704
1724
|
/**
|
|
1705
|
-
*
|
|
1706
|
-
*
|
|
1707
|
-
* @param options - Discovery filters
|
|
1708
|
-
* @returns Paginated list of matching resources
|
|
1709
|
-
*
|
|
1710
|
-
* @example
|
|
1711
|
-
* ```ts
|
|
1712
|
-
* // Find AI APIs on Base with USDC under $0.10
|
|
1713
|
-
* const results = await bazaar.discover({
|
|
1714
|
-
* category: 'ai',
|
|
1715
|
-
* network: 'base',
|
|
1716
|
-
* token: 'USDC',
|
|
1717
|
-
* maxPrice: '0.10',
|
|
1718
|
-
* });
|
|
1719
|
-
*
|
|
1720
|
-
* for (const resource of results.resources) {
|
|
1721
|
-
* console.log(`${resource.name}: ${resource.url}`);
|
|
1722
|
-
* }
|
|
1723
|
-
* ```
|
|
1725
|
+
* Issue a request against the facilitator with the configured timeout.
|
|
1724
1726
|
*/
|
|
1725
|
-
async
|
|
1726
|
-
const params = new URLSearchParams();
|
|
1727
|
-
if (options.category) params.set("category", options.category);
|
|
1728
|
-
if (options.network) params.set("network", options.network);
|
|
1729
|
-
if (options.token) params.set("token", options.token);
|
|
1730
|
-
if (options.provider) params.set("provider", options.provider);
|
|
1731
|
-
if (options.tags?.length) params.set("tags", options.tags.join(","));
|
|
1732
|
-
if (options.query) params.set("query", options.query);
|
|
1733
|
-
if (options.maxPrice) params.set("maxPrice", options.maxPrice);
|
|
1734
|
-
if (options.page) params.set("page", options.page.toString());
|
|
1735
|
-
if (options.limit) params.set("limit", options.limit.toString());
|
|
1736
|
-
if (options.sortBy) params.set("sortBy", options.sortBy);
|
|
1737
|
-
if (options.sortOrder) params.set("sortOrder", options.sortOrder);
|
|
1738
|
-
const url = `${this.baseUrl}/resources${params.toString() ? `?${params}` : ""}`;
|
|
1727
|
+
async request(path, init) {
|
|
1739
1728
|
const controller = new AbortController();
|
|
1740
1729
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
1741
1730
|
try {
|
|
1742
|
-
const response = await fetch(
|
|
1743
|
-
|
|
1744
|
-
headers: {
|
|
1731
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
1732
|
+
...init,
|
|
1733
|
+
headers: { Accept: "application/json", ...init?.headers || {} },
|
|
1745
1734
|
signal: controller.signal
|
|
1746
1735
|
});
|
|
1747
|
-
clearTimeout(timeoutId);
|
|
1748
1736
|
if (!response.ok) {
|
|
1749
1737
|
const errorText = await response.text();
|
|
1750
|
-
throw new Error(
|
|
1738
|
+
throw new Error(
|
|
1739
|
+
`Bazaar API error: ${response.status} - ${errorText}`
|
|
1740
|
+
);
|
|
1751
1741
|
}
|
|
1752
1742
|
return await response.json();
|
|
1753
|
-
}
|
|
1743
|
+
} finally {
|
|
1754
1744
|
clearTimeout(timeoutId);
|
|
1755
|
-
throw error;
|
|
1756
1745
|
}
|
|
1757
1746
|
}
|
|
1758
1747
|
/**
|
|
1759
|
-
*
|
|
1748
|
+
* List resources from the discovery registry.
|
|
1760
1749
|
*
|
|
1761
|
-
* @param
|
|
1762
|
-
* @returns
|
|
1763
|
-
*/
|
|
1764
|
-
async getResource(resourceId) {
|
|
1765
|
-
const url = `${this.baseUrl}/resources/${encodeURIComponent(resourceId)}`;
|
|
1766
|
-
const controller = new AbortController();
|
|
1767
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
1768
|
-
try {
|
|
1769
|
-
const response = await fetch(url, {
|
|
1770
|
-
method: "GET",
|
|
1771
|
-
headers: { "Accept": "application/json" },
|
|
1772
|
-
signal: controller.signal
|
|
1773
|
-
});
|
|
1774
|
-
clearTimeout(timeoutId);
|
|
1775
|
-
if (!response.ok) {
|
|
1776
|
-
const errorText = await response.text();
|
|
1777
|
-
throw new Error(`Bazaar API error: ${response.status} - ${errorText}`);
|
|
1778
|
-
}
|
|
1779
|
-
return await response.json();
|
|
1780
|
-
} catch (error) {
|
|
1781
|
-
clearTimeout(timeoutId);
|
|
1782
|
-
throw error;
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
/**
|
|
1786
|
-
* Get a resource by its URL
|
|
1750
|
+
* @param options - Server-side filters and pagination
|
|
1751
|
+
* @returns One page of resources plus the total across all pages
|
|
1787
1752
|
*
|
|
1788
|
-
* @
|
|
1789
|
-
*
|
|
1753
|
+
* @example
|
|
1754
|
+
* ```ts
|
|
1755
|
+
* const page = await bazaar.listResources({ network: 'eip155:8453', health: 'alive' });
|
|
1756
|
+
* ```
|
|
1790
1757
|
*/
|
|
1791
|
-
async
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
1795
|
-
try {
|
|
1796
|
-
const response = await fetch(url, {
|
|
1797
|
-
method: "GET",
|
|
1798
|
-
headers: { "Accept": "application/json" },
|
|
1799
|
-
signal: controller.signal
|
|
1800
|
-
});
|
|
1801
|
-
clearTimeout(timeoutId);
|
|
1802
|
-
if (!response.ok) {
|
|
1803
|
-
const errorText = await response.text();
|
|
1804
|
-
throw new Error(`Bazaar API error: ${response.status} - ${errorText}`);
|
|
1805
|
-
}
|
|
1806
|
-
return await response.json();
|
|
1807
|
-
} catch (error) {
|
|
1808
|
-
clearTimeout(timeoutId);
|
|
1809
|
-
throw error;
|
|
1758
|
+
async listResources(options = {}) {
|
|
1759
|
+
if (options.q !== void 0 && options.q.length > MAX_SEARCH_LEN) {
|
|
1760
|
+
throw new Error(`q must be at most ${MAX_SEARCH_LEN} characters`);
|
|
1810
1761
|
}
|
|
1762
|
+
const params = new URLSearchParams();
|
|
1763
|
+
params.set("limit", String(options.limit ?? 10));
|
|
1764
|
+
params.set("offset", String(options.offset ?? 0));
|
|
1765
|
+
if (options.category) params.set("category", options.category);
|
|
1766
|
+
if (options.network) params.set("network", options.network);
|
|
1767
|
+
if (options.provider) params.set("provider", options.provider);
|
|
1768
|
+
if (options.tag) params.set("tag", options.tag);
|
|
1769
|
+
if (options.source) params.set("source", options.source);
|
|
1770
|
+
if (options.sourceFacilitator)
|
|
1771
|
+
params.set("sourceFacilitator", options.sourceFacilitator);
|
|
1772
|
+
if (options.health) params.set("health", options.health);
|
|
1773
|
+
if (options.tier) params.set("tier", options.tier);
|
|
1774
|
+
if (options.q) params.set("q", options.q);
|
|
1775
|
+
return this.request(
|
|
1776
|
+
`/discovery/resources?${params.toString()}`
|
|
1777
|
+
);
|
|
1811
1778
|
}
|
|
1812
1779
|
/**
|
|
1813
|
-
*
|
|
1780
|
+
* Walk the whole filtered catalog, one page at a time.
|
|
1814
1781
|
*
|
|
1815
|
-
*
|
|
1782
|
+
* Pages are fetched in sequence rather than in parallel: the read routes are
|
|
1783
|
+
* rate limited, and a burst of parallel pages is how a legitimate catalog
|
|
1784
|
+
* walk turns into a wall of 429s.
|
|
1816
1785
|
*
|
|
1817
|
-
* @param options -
|
|
1818
|
-
* @returns Registered resource
|
|
1786
|
+
* @param options - Same filters as {@link listResources}; `limit` is the page size
|
|
1819
1787
|
*
|
|
1820
1788
|
* @example
|
|
1821
1789
|
* ```ts
|
|
1822
|
-
* const
|
|
1823
|
-
*
|
|
1824
|
-
*
|
|
1825
|
-
* description: 'Generate images with AI',
|
|
1826
|
-
* category: 'ai',
|
|
1827
|
-
* networks: ['base', 'ethereum', 'polygon'],
|
|
1828
|
-
* price: '0.05',
|
|
1829
|
-
* payTo: '0x1234...',
|
|
1830
|
-
* tags: ['ai', 'image', 'generator'],
|
|
1831
|
-
* });
|
|
1790
|
+
* for await (const r of bazaar.iterateResources({ health: 'alive' })) {
|
|
1791
|
+
* console.log(r.url);
|
|
1792
|
+
* }
|
|
1832
1793
|
* ```
|
|
1833
1794
|
*/
|
|
1834
|
-
async
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
const response = await fetch(url, {
|
|
1843
|
-
method: "POST",
|
|
1844
|
-
headers: {
|
|
1845
|
-
"Content-Type": "application/json",
|
|
1846
|
-
"Accept": "application/json",
|
|
1847
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
1848
|
-
},
|
|
1849
|
-
body: JSON.stringify({
|
|
1850
|
-
url: options.url,
|
|
1851
|
-
name: options.name,
|
|
1852
|
-
description: options.description,
|
|
1853
|
-
category: options.category,
|
|
1854
|
-
networks: options.networks,
|
|
1855
|
-
tokens: options.tokens || ["USDC"],
|
|
1856
|
-
price: options.price,
|
|
1857
|
-
priceCurrency: options.priceCurrency || "USDC",
|
|
1858
|
-
payTo: options.payTo,
|
|
1859
|
-
mimeType: options.mimeType || "application/json",
|
|
1860
|
-
outputSchema: options.outputSchema,
|
|
1861
|
-
tags: options.tags
|
|
1862
|
-
}),
|
|
1863
|
-
signal: controller.signal
|
|
1864
|
-
});
|
|
1865
|
-
clearTimeout(timeoutId);
|
|
1866
|
-
if (!response.ok) {
|
|
1867
|
-
const errorText = await response.text();
|
|
1868
|
-
throw new Error(`Bazaar API error: ${response.status} - ${errorText}`);
|
|
1869
|
-
}
|
|
1870
|
-
return await response.json();
|
|
1871
|
-
} catch (error) {
|
|
1872
|
-
clearTimeout(timeoutId);
|
|
1873
|
-
throw error;
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
/**
|
|
1877
|
-
* Update an existing resource
|
|
1878
|
-
*
|
|
1879
|
-
* Requires API key authentication. Only the owner can update.
|
|
1880
|
-
*
|
|
1881
|
-
* @param resourceId - Resource ID to update
|
|
1882
|
-
* @param updates - Partial update options
|
|
1883
|
-
* @returns Updated resource
|
|
1884
|
-
*/
|
|
1885
|
-
async update(resourceId, updates) {
|
|
1886
|
-
if (!this.apiKey) {
|
|
1887
|
-
throw new Error("API key required for resource update");
|
|
1888
|
-
}
|
|
1889
|
-
const url = `${this.baseUrl}/resources/${encodeURIComponent(resourceId)}`;
|
|
1890
|
-
const controller = new AbortController();
|
|
1891
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
1892
|
-
try {
|
|
1893
|
-
const response = await fetch(url, {
|
|
1894
|
-
method: "PATCH",
|
|
1895
|
-
headers: {
|
|
1896
|
-
"Content-Type": "application/json",
|
|
1897
|
-
"Accept": "application/json",
|
|
1898
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
1899
|
-
},
|
|
1900
|
-
body: JSON.stringify(updates),
|
|
1901
|
-
signal: controller.signal
|
|
1795
|
+
async *iterateResources(options = {}) {
|
|
1796
|
+
const pageSize = options.limit ?? 100;
|
|
1797
|
+
let offset = options.offset ?? 0;
|
|
1798
|
+
for (; ; ) {
|
|
1799
|
+
const page = await this.listResources({
|
|
1800
|
+
...options,
|
|
1801
|
+
limit: pageSize,
|
|
1802
|
+
offset
|
|
1902
1803
|
});
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
}
|
|
1908
|
-
return await response.json();
|
|
1909
|
-
} catch (error) {
|
|
1910
|
-
clearTimeout(timeoutId);
|
|
1911
|
-
throw error;
|
|
1804
|
+
if (page.items.length === 0) return;
|
|
1805
|
+
for (const item of page.items) yield item;
|
|
1806
|
+
offset += page.items.length;
|
|
1807
|
+
if (offset >= page.pagination.total) return;
|
|
1912
1808
|
}
|
|
1913
1809
|
}
|
|
1914
1810
|
/**
|
|
1915
|
-
*
|
|
1811
|
+
* Look up a single resource by its URL.
|
|
1916
1812
|
*
|
|
1917
|
-
*
|
|
1813
|
+
* The registry keys on URL and has no by-id lookup, so this searches and
|
|
1814
|
+
* then matches exactly.
|
|
1918
1815
|
*
|
|
1919
|
-
* @param
|
|
1816
|
+
* @param resourceUrl - Exact URL of the resource
|
|
1817
|
+
* @returns The resource, or null when it is not registered
|
|
1920
1818
|
*/
|
|
1921
|
-
async
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
try {
|
|
1929
|
-
const response = await fetch(url, {
|
|
1930
|
-
method: "DELETE",
|
|
1931
|
-
headers: {
|
|
1932
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
1933
|
-
},
|
|
1934
|
-
signal: controller.signal
|
|
1935
|
-
});
|
|
1936
|
-
clearTimeout(timeoutId);
|
|
1937
|
-
if (!response.ok) {
|
|
1938
|
-
const errorText = await response.text();
|
|
1939
|
-
throw new Error(`Bazaar API error: ${response.status} - ${errorText}`);
|
|
1940
|
-
}
|
|
1941
|
-
} catch (error) {
|
|
1942
|
-
clearTimeout(timeoutId);
|
|
1943
|
-
throw error;
|
|
1944
|
-
}
|
|
1819
|
+
async getResourceByUrl(resourceUrl) {
|
|
1820
|
+
const page = await this.listResources({
|
|
1821
|
+
q: resourceUrl.slice(0, MAX_SEARCH_LEN),
|
|
1822
|
+
limit: 100,
|
|
1823
|
+
health: "any"
|
|
1824
|
+
});
|
|
1825
|
+
return page.items.find((item) => item.url === resourceUrl) ?? null;
|
|
1945
1826
|
}
|
|
1946
1827
|
/**
|
|
1947
|
-
*
|
|
1828
|
+
* Register a paid resource in the discovery registry.
|
|
1948
1829
|
*
|
|
1949
|
-
*
|
|
1830
|
+
* Registration is open and rate limited; re-registering a known URL updates
|
|
1831
|
+
* the existing record rather than creating a duplicate.
|
|
1950
1832
|
*
|
|
1951
|
-
* @param
|
|
1952
|
-
* @returns
|
|
1833
|
+
* @param options - Resource details
|
|
1834
|
+
* @returns The registry's acknowledgement
|
|
1953
1835
|
*/
|
|
1954
|
-
async
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
signal: controller.signal
|
|
1968
|
-
});
|
|
1969
|
-
clearTimeout(timeoutId);
|
|
1970
|
-
if (!response.ok) {
|
|
1971
|
-
const errorText = await response.text();
|
|
1972
|
-
throw new Error(`Bazaar API error: ${response.status} - ${errorText}`);
|
|
1973
|
-
}
|
|
1974
|
-
return await response.json();
|
|
1975
|
-
} catch (error) {
|
|
1976
|
-
clearTimeout(timeoutId);
|
|
1977
|
-
throw error;
|
|
1978
|
-
}
|
|
1836
|
+
async registerResource(options) {
|
|
1837
|
+
const payload = {
|
|
1838
|
+
url: options.url,
|
|
1839
|
+
type: options.type || "http",
|
|
1840
|
+
description: options.description || ""
|
|
1841
|
+
};
|
|
1842
|
+
if (options.accepts) payload.accepts = options.accepts;
|
|
1843
|
+
if (options.metadata) payload.metadata = options.metadata;
|
|
1844
|
+
return this.request("/discovery/register", {
|
|
1845
|
+
method: "POST",
|
|
1846
|
+
headers: { "Content-Type": "application/json" },
|
|
1847
|
+
body: JSON.stringify(payload)
|
|
1848
|
+
});
|
|
1979
1849
|
}
|
|
1980
1850
|
/**
|
|
1981
|
-
*
|
|
1851
|
+
* Aggregate catalog metrics (60s cached server-side).
|
|
1982
1852
|
*
|
|
1983
|
-
*
|
|
1984
|
-
*
|
|
1985
|
-
* @param resourceId - Resource ID to reactivate
|
|
1986
|
-
* @returns Updated resource with isActive: true
|
|
1853
|
+
* @returns Counts by source, facilitator, network, tier and liveness
|
|
1987
1854
|
*/
|
|
1988
|
-
async
|
|
1989
|
-
|
|
1990
|
-
throw new Error("API key required for resource reactivation");
|
|
1991
|
-
}
|
|
1992
|
-
const url = `${this.baseUrl}/resources/${encodeURIComponent(resourceId)}/reactivate`;
|
|
1993
|
-
const controller = new AbortController();
|
|
1994
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
1995
|
-
try {
|
|
1996
|
-
const response = await fetch(url, {
|
|
1997
|
-
method: "POST",
|
|
1998
|
-
headers: {
|
|
1999
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
2000
|
-
},
|
|
2001
|
-
signal: controller.signal
|
|
2002
|
-
});
|
|
2003
|
-
clearTimeout(timeoutId);
|
|
2004
|
-
if (!response.ok) {
|
|
2005
|
-
const errorText = await response.text();
|
|
2006
|
-
throw new Error(`Bazaar API error: ${response.status} - ${errorText}`);
|
|
2007
|
-
}
|
|
2008
|
-
return await response.json();
|
|
2009
|
-
} catch (error) {
|
|
2010
|
-
clearTimeout(timeoutId);
|
|
2011
|
-
throw error;
|
|
2012
|
-
}
|
|
1855
|
+
async getStats() {
|
|
1856
|
+
return this.request("/discovery/stats");
|
|
2013
1857
|
}
|
|
2014
1858
|
/**
|
|
2015
|
-
*
|
|
2016
|
-
*
|
|
2017
|
-
* Requires API key authentication.
|
|
1859
|
+
* Check that the facilitator serving the registry is up.
|
|
2018
1860
|
*
|
|
2019
|
-
* @
|
|
2020
|
-
* @returns Paginated list of owned resources
|
|
1861
|
+
* @returns True when the facilitator answers its health check
|
|
2021
1862
|
*/
|
|
2022
|
-
async
|
|
2023
|
-
if (!this.apiKey) {
|
|
2024
|
-
throw new Error("API key required to list owned resources");
|
|
2025
|
-
}
|
|
2026
|
-
const params = new URLSearchParams();
|
|
2027
|
-
if (options.page) params.set("page", options.page.toString());
|
|
2028
|
-
if (options.limit) params.set("limit", options.limit.toString());
|
|
2029
|
-
if (options.includeInactive) params.set("includeInactive", "true");
|
|
2030
|
-
const url = `${this.baseUrl}/resources/mine${params.toString() ? `?${params}` : ""}`;
|
|
1863
|
+
async healthCheck() {
|
|
2031
1864
|
const controller = new AbortController();
|
|
2032
1865
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
2033
1866
|
try {
|
|
2034
|
-
const response = await fetch(
|
|
1867
|
+
const response = await fetch(`${this.baseUrl}/health`, {
|
|
2035
1868
|
method: "GET",
|
|
2036
|
-
headers: {
|
|
2037
|
-
"Accept": "application/json",
|
|
2038
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
2039
|
-
},
|
|
2040
1869
|
signal: controller.signal
|
|
2041
1870
|
});
|
|
2042
|
-
clearTimeout(timeoutId);
|
|
2043
|
-
if (!response.ok) {
|
|
2044
|
-
const errorText = await response.text();
|
|
2045
|
-
throw new Error(`Bazaar API error: ${response.status} - ${errorText}`);
|
|
2046
|
-
}
|
|
2047
|
-
return await response.json();
|
|
2048
|
-
} catch (error) {
|
|
2049
|
-
clearTimeout(timeoutId);
|
|
2050
|
-
throw error;
|
|
2051
|
-
}
|
|
2052
|
-
}
|
|
2053
|
-
/**
|
|
2054
|
-
* Get Bazaar API health status
|
|
2055
|
-
*
|
|
2056
|
-
* @returns True if the Bazaar API is healthy
|
|
2057
|
-
*/
|
|
2058
|
-
async healthCheck() {
|
|
2059
|
-
try {
|
|
2060
|
-
const response = await fetch(`${this.baseUrl}/health`, {
|
|
2061
|
-
method: "GET"
|
|
2062
|
-
});
|
|
2063
1871
|
return response.ok;
|
|
2064
1872
|
} catch {
|
|
2065
1873
|
return false;
|
|
1874
|
+
} finally {
|
|
1875
|
+
clearTimeout(timeoutId);
|
|
2066
1876
|
}
|
|
2067
1877
|
}
|
|
2068
1878
|
/**
|
|
2069
|
-
*
|
|
2070
|
-
*
|
|
2071
|
-
*
|
|
1879
|
+
* @deprecated Renamed to {@link listResources}, which returns the registry's
|
|
1880
|
+
* real `{ items, pagination }` envelope. The old `discover()` returned a
|
|
1881
|
+
* `{ resources, page, totalPages }` shape that no endpoint ever served.
|
|
2072
1882
|
*/
|
|
2073
|
-
async
|
|
2074
|
-
|
|
2075
|
-
const controller = new AbortController();
|
|
2076
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
2077
|
-
try {
|
|
2078
|
-
const response = await fetch(url, {
|
|
2079
|
-
method: "GET",
|
|
2080
|
-
headers: { "Accept": "application/json" },
|
|
2081
|
-
signal: controller.signal
|
|
2082
|
-
});
|
|
2083
|
-
clearTimeout(timeoutId);
|
|
2084
|
-
if (!response.ok) {
|
|
2085
|
-
const errorText = await response.text();
|
|
2086
|
-
throw new Error(`Bazaar API error: ${response.status} - ${errorText}`);
|
|
2087
|
-
}
|
|
2088
|
-
return await response.json();
|
|
2089
|
-
} catch (error) {
|
|
2090
|
-
clearTimeout(timeoutId);
|
|
2091
|
-
throw error;
|
|
2092
|
-
}
|
|
1883
|
+
async discover(options = {}) {
|
|
1884
|
+
return this.listResources(options);
|
|
2093
1885
|
}
|
|
2094
1886
|
};
|
|
2095
1887
|
var EscrowClient = class {
|
|
@@ -4081,9 +3873,12 @@ exports.ESCROW_TIMEOUT_MS = ESCROW_TIMEOUT_MS;
|
|
|
4081
3873
|
exports.Erc8004Client = Erc8004Client;
|
|
4082
3874
|
exports.EscrowClient = EscrowClient;
|
|
4083
3875
|
exports.FacilitatorClient = FacilitatorClient;
|
|
3876
|
+
exports.HEALTH_FILTERS = HEALTH_FILTERS;
|
|
3877
|
+
exports.MAX_SEARCH_LEN = MAX_SEARCH_LEN;
|
|
4084
3878
|
exports.OPERATOR_ABI = OPERATOR_ABI;
|
|
4085
3879
|
exports.OPERATOR_ABI_CREATE3 = OPERATOR_ABI_CREATE3;
|
|
4086
3880
|
exports.PAYMENT_INFO_TYPEHASH = PAYMENT_INFO_TYPEHASH;
|
|
3881
|
+
exports.TIER_FILTERS = TIER_FILTERS;
|
|
4087
3882
|
exports.TIER_TIMINGS = TIER_TIMINGS;
|
|
4088
3883
|
exports.USDC_DOMAIN_NAME = USDC_DOMAIN_NAME;
|
|
4089
3884
|
exports.X402_CORS_HEADERS = X402_CORS_HEADERS;
|
|
@@ -4098,11 +3893,13 @@ exports.canReleaseEscrow = canReleaseEscrow;
|
|
|
4098
3893
|
exports.create402Response = create402Response;
|
|
4099
3894
|
exports.createHonoMiddleware = createHonoMiddleware;
|
|
4100
3895
|
exports.createPaymentMiddleware = createPaymentMiddleware;
|
|
3896
|
+
exports.epochToDate = epochToDate;
|
|
4101
3897
|
exports.escrowTimeRemaining = escrowTimeRemaining;
|
|
4102
3898
|
exports.extractPaymentFromHeaders = extractPaymentFromHeaders;
|
|
4103
3899
|
exports.getCorsHeaders = getCorsHeaders;
|
|
4104
3900
|
exports.getEscrowContractsByChainId = getEscrowContractsByChainId;
|
|
4105
3901
|
exports.getEscrowSupportedChainIds = getEscrowSupportedChainIds;
|
|
3902
|
+
exports.isAlive = isAlive;
|
|
4106
3903
|
exports.isEscrowExpired = isEscrowExpired;
|
|
4107
3904
|
exports.isEscrowSupportedOnChain = isEscrowSupportedOnChain;
|
|
4108
3905
|
exports.parsePaymentHeader = parsePaymentHeader;
|