@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.
@@ -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,