@bsv/sdk 1.4.13 → 1.4.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/sdk",
3
- "version": "1.4.13",
3
+ "version": "1.4.15",
4
4
  "type": "module",
5
5
  "description": "BSV Blockchain Software Development Kit",
6
6
  "main": "dist/cjs/mod.js",
@@ -222,11 +222,13 @@ export class AuthFetch {
222
222
  config.retryCounter ??= 3
223
223
  const response = await this.fetch(url, config)
224
224
  resolve(response)
225
+ return
225
226
  }
226
227
  if (error.message.includes('HTTP server failed to authenticate')) {
227
228
  try {
228
229
  const response = await this.handleFetchAndValidate(url, config, peerToUse)
229
230
  resolve(response)
231
+ return
230
232
  } catch (fetchError) {
231
233
  reject(fetchError)
232
234
  }
@@ -126,23 +126,9 @@ export class SimplifiedFetchTransport implements Transport {
126
126
  })
127
127
 
128
128
  // Check for an acceptable status
129
- if (!SUCCESS_STATUS_CODES.includes(response.status)) {
129
+ if (response.status === 500 && !response.headers.get('x-bsv-auth-request-id')) {
130
130
  // Try parsing JSON error
131
- let errorInfo;
132
- try {
133
- errorInfo = await response.json();
134
- } catch {
135
- // Fallback to text if JSON parse fails
136
- const text = await response.text().catch(() => '');
137
- throw new Error(`HTTP ${response.status} - ${text || 'Unknown error'}`);
138
- }
139
-
140
- // If we find a known { status: 'error', code, description } structure
141
- if (errorInfo?.status === 'error' && typeof errorInfo.description === 'string') {
142
- const msg = `HTTP ${response.status} - ${errorInfo.description}`;
143
- throw new Error(errorInfo.code ? `${msg} (code: ${errorInfo.code})` : msg);
144
- }
145
-
131
+ const errorInfo = await response.json()
146
132
  // Otherwise just throw whatever we got
147
133
  throw new Error(`HTTP ${response.status} - ${JSON.stringify(errorInfo)}`);
148
134
  }