@routstr/sdk 0.1.2 → 0.1.4
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/client/index.js +13 -3
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +13 -3
- package/dist/client/index.mjs.map +1 -1
- package/dist/discovery/index.d.mts +3 -2
- package/dist/discovery/index.d.ts +3 -2
- package/dist/discovery/index.js +17 -4
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/index.mjs +17 -4
- package/dist/discovery/index.mjs.map +1 -1
- package/dist/index.d.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +51 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -10
- package/dist/index.mjs.map +1 -1
- package/dist/{interfaces-Dnrvxr6N.d.ts → interfaces-CC0LT9p9.d.ts} +10 -0
- package/dist/{interfaces-nanJOqdW.d.mts → interfaces-DGdP8fQp.d.mts} +10 -0
- package/dist/storage/index.d.mts +4 -1
- package/dist/storage/index.d.ts +4 -1
- package/dist/storage/index.js +16 -2
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/index.mjs +16 -2
- package/dist/storage/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/client/index.js
CHANGED
|
@@ -2048,22 +2048,31 @@ var RoutstrClient = class {
|
|
|
2048
2048
|
try {
|
|
2049
2049
|
const url = `${baseUrl.replace(/\/$/, "")}${path}`;
|
|
2050
2050
|
if (this.mode === "xcashu") this._log("DEBUG", "HEADERS,", headers);
|
|
2051
|
+
this._log("DEBUG", "HEADERS,", headers);
|
|
2051
2052
|
const response = await fetch(url, {
|
|
2052
2053
|
method,
|
|
2053
2054
|
headers,
|
|
2054
2055
|
body: body === void 0 || method === "GET" ? void 0 : JSON.stringify(body)
|
|
2055
2056
|
});
|
|
2056
2057
|
if (this.mode === "xcashu") this._log("DEBUG", "response,", response);
|
|
2058
|
+
this._log("DEBUG", "response,", response);
|
|
2057
2059
|
response.baseUrl = baseUrl;
|
|
2058
2060
|
response.token = token;
|
|
2059
2061
|
if (!response.ok) {
|
|
2060
2062
|
const requestId = response.headers.get("x-routstr-request-id") || void 0;
|
|
2063
|
+
let bodyText;
|
|
2064
|
+
try {
|
|
2065
|
+
bodyText = await response.text();
|
|
2066
|
+
} catch (e) {
|
|
2067
|
+
bodyText = void 0;
|
|
2068
|
+
}
|
|
2061
2069
|
return await this._handleErrorResponse(
|
|
2062
2070
|
params,
|
|
2063
2071
|
token,
|
|
2064
2072
|
response.status,
|
|
2065
2073
|
requestId,
|
|
2066
|
-
this.mode === "xcashu" ? response.headers.get("x-cashu") ?? void 0 : void 0
|
|
2074
|
+
this.mode === "xcashu" ? response.headers.get("x-cashu") ?? void 0 : void 0,
|
|
2075
|
+
bodyText
|
|
2067
2076
|
);
|
|
2068
2077
|
}
|
|
2069
2078
|
return response;
|
|
@@ -2082,7 +2091,7 @@ var RoutstrClient = class {
|
|
|
2082
2091
|
/**
|
|
2083
2092
|
* Handle error responses with failover
|
|
2084
2093
|
*/
|
|
2085
|
-
async _handleErrorResponse(params, token, status, requestId, xCashuRefundToken) {
|
|
2094
|
+
async _handleErrorResponse(params, token, status, requestId, xCashuRefundToken, responseBody) {
|
|
2086
2095
|
const { path, method, body, selectedModel, baseUrl, mintUrl } = params;
|
|
2087
2096
|
let tryNextProvider = false;
|
|
2088
2097
|
this._log(
|
|
@@ -2152,7 +2161,8 @@ var RoutstrClient = class {
|
|
|
2152
2161
|
);
|
|
2153
2162
|
}
|
|
2154
2163
|
}
|
|
2155
|
-
if (status === 402 && !tryNextProvider && (this.mode === "apikeys" || this.mode === "lazyrefund")) {
|
|
2164
|
+
if ((status === 402 || status === 413 && responseBody?.includes("Insufficient balance")) && !tryNextProvider && (this.mode === "apikeys" || this.mode === "lazyrefund")) {
|
|
2165
|
+
console.log("RESPONSFE ", responseBody);
|
|
2156
2166
|
const topupResult = await this.balanceManager.topUp({
|
|
2157
2167
|
mintUrl,
|
|
2158
2168
|
baseUrl,
|