@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/dist/cjs/package.json +1 -1
- package/dist/cjs/src/auth/clients/AuthFetch.js +2 -0
- package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js +2 -15
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/auth/clients/AuthFetch.js +2 -0
- package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js +2 -15
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -1
- package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/package.json +1 -1
- package/src/auth/clients/AuthFetch.ts +2 -0
- package/src/auth/transports/SimplifiedFetchTransport.ts +2 -16
package/package.json
CHANGED
|
@@ -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 (!
|
|
129
|
+
if (response.status === 500 && !response.headers.get('x-bsv-auth-request-id')) {
|
|
130
130
|
// Try parsing JSON error
|
|
131
|
-
|
|
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
|
}
|