@routstr/sdk 0.1.2 → 0.1.3
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 +10 -3
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +10 -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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +43 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -9
- 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.mjs
CHANGED
|
@@ -2056,12 +2056,19 @@ var RoutstrClient = class {
|
|
|
2056
2056
|
response.token = token;
|
|
2057
2057
|
if (!response.ok) {
|
|
2058
2058
|
const requestId = response.headers.get("x-routstr-request-id") || void 0;
|
|
2059
|
+
let bodyText;
|
|
2060
|
+
try {
|
|
2061
|
+
bodyText = await response.text();
|
|
2062
|
+
} catch (e) {
|
|
2063
|
+
bodyText = void 0;
|
|
2064
|
+
}
|
|
2059
2065
|
return await this._handleErrorResponse(
|
|
2060
2066
|
params,
|
|
2061
2067
|
token,
|
|
2062
2068
|
response.status,
|
|
2063
2069
|
requestId,
|
|
2064
|
-
this.mode === "xcashu" ? response.headers.get("x-cashu") ?? void 0 : void 0
|
|
2070
|
+
this.mode === "xcashu" ? response.headers.get("x-cashu") ?? void 0 : void 0,
|
|
2071
|
+
bodyText
|
|
2065
2072
|
);
|
|
2066
2073
|
}
|
|
2067
2074
|
return response;
|
|
@@ -2080,7 +2087,7 @@ var RoutstrClient = class {
|
|
|
2080
2087
|
/**
|
|
2081
2088
|
* Handle error responses with failover
|
|
2082
2089
|
*/
|
|
2083
|
-
async _handleErrorResponse(params, token, status, requestId, xCashuRefundToken) {
|
|
2090
|
+
async _handleErrorResponse(params, token, status, requestId, xCashuRefundToken, responseBody) {
|
|
2084
2091
|
const { path, method, body, selectedModel, baseUrl, mintUrl } = params;
|
|
2085
2092
|
let tryNextProvider = false;
|
|
2086
2093
|
this._log(
|
|
@@ -2150,7 +2157,7 @@ var RoutstrClient = class {
|
|
|
2150
2157
|
);
|
|
2151
2158
|
}
|
|
2152
2159
|
}
|
|
2153
|
-
if (status === 402 && !tryNextProvider && (this.mode === "apikeys" || this.mode === "lazyrefund")) {
|
|
2160
|
+
if ((status === 402 || status === 413 && responseBody?.includes("Insufficient balance")) && !tryNextProvider && (this.mode === "apikeys" || this.mode === "lazyrefund")) {
|
|
2154
2161
|
const topupResult = await this.balanceManager.topUp({
|
|
2155
2162
|
mintUrl,
|
|
2156
2163
|
baseUrl,
|