moltspay 1.0.0 → 1.1.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/dist/cli/index.js +4822 -62
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +4813 -49
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/index.d.mts +7 -2
- package/dist/client/index.d.ts +7 -2
- package/dist/client/index.js +13 -4
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +13 -4
- package/dist/client/index.mjs.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -31756,11 +31756,20 @@ var MoltsPayClient = class {
|
|
|
31756
31756
|
* Get services from a provider
|
|
31757
31757
|
*/
|
|
31758
31758
|
async getServices(serverUrl) {
|
|
31759
|
-
const
|
|
31760
|
-
|
|
31761
|
-
|
|
31759
|
+
const normalizedUrl = serverUrl.replace(/\/(services|api\/services|registry\/services)\/?$/, "");
|
|
31760
|
+
const endpoints = ["/services", "/api/services", "/registry/services"];
|
|
31761
|
+
for (const endpoint of endpoints) {
|
|
31762
|
+
try {
|
|
31763
|
+
const res = await fetch(`${normalizedUrl}${endpoint}`);
|
|
31764
|
+
if (!res.ok) continue;
|
|
31765
|
+
const contentType = res.headers.get("content-type") || "";
|
|
31766
|
+
if (!contentType.includes("application/json")) continue;
|
|
31767
|
+
return await res.json();
|
|
31768
|
+
} catch {
|
|
31769
|
+
continue;
|
|
31770
|
+
}
|
|
31762
31771
|
}
|
|
31763
|
-
|
|
31772
|
+
throw new Error(`Failed to get services: no valid endpoint found at ${normalizedUrl}`);
|
|
31764
31773
|
}
|
|
31765
31774
|
/**
|
|
31766
31775
|
* Pay for a service and get the result (x402 protocol)
|