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