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