@unicitylabs/sphere-sdk 0.10.6 → 0.10.7
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/connect/index.cjs +1 -1
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.js +1 -1
- package/dist/connect/index.js.map +1 -1
- package/dist/impl/browser/connect/index.cjs +1 -1
- package/dist/impl/browser/connect/index.cjs.map +1 -1
- package/dist/impl/browser/connect/index.js +1 -1
- package/dist/impl/browser/connect/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +24 -3
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +24 -3
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +24 -3
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +9 -1
- package/dist/impl/nodejs/index.d.ts +9 -1
- package/dist/impl/nodejs/index.js +24 -3
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/impl/shared/wallet-api/index.cjs +24 -3
- package/dist/impl/shared/wallet-api/index.cjs.map +1 -1
- package/dist/impl/shared/wallet-api/index.d.cts +9 -1
- package/dist/impl/shared/wallet-api/index.d.ts +9 -1
- package/dist/impl/shared/wallet-api/index.js +24 -3
- package/dist/impl/shared/wallet-api/index.js.map +1 -1
- package/dist/index.cjs +24 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/dist/wallet-api/index.cjs +24 -3
- package/dist/wallet-api/index.cjs.map +1 -1
- package/dist/wallet-api/index.d.cts +9 -1
- package/dist/wallet-api/index.d.ts +9 -1
- package/dist/wallet-api/index.js +24 -3
- package/dist/wallet-api/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1215,6 +1215,8 @@ function defaultWebSocketFactory(url) {
|
|
|
1215
1215
|
}
|
|
1216
1216
|
return new Ctor(url);
|
|
1217
1217
|
}
|
|
1218
|
+
var GET_RETRY_ATTEMPTS = 3;
|
|
1219
|
+
var GET_RETRY_BASE_MS = 200;
|
|
1218
1220
|
var WalletApiClient = class _WalletApiClient {
|
|
1219
1221
|
/** Network name (also the blob-key prefix `<network>/t/<sha256>` — §5.2). */
|
|
1220
1222
|
network;
|
|
@@ -1408,17 +1410,36 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
1408
1410
|
}
|
|
1409
1411
|
return WalletApiError.fromStatus(res.status, message);
|
|
1410
1412
|
}
|
|
1413
|
+
/**
|
|
1414
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
1415
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
1416
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
1417
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
1418
|
+
*/
|
|
1419
|
+
async rawFetchWithReadRetry(method, path, body, jwt) {
|
|
1420
|
+
const attempts = method === "GET" ? GET_RETRY_ATTEMPTS : 1;
|
|
1421
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
1422
|
+
try {
|
|
1423
|
+
return await this.rawFetch(method, path, body, jwt);
|
|
1424
|
+
} catch (err) {
|
|
1425
|
+
const transient = err instanceof WalletApiError && err.code === "NETWORK";
|
|
1426
|
+
if (!transient || attempt >= attempts) throw err;
|
|
1427
|
+
await new Promise((resolve) => setTimeout(resolve, GET_RETRY_BASE_MS * 2 ** (attempt - 1)));
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1411
1431
|
/**
|
|
1412
1432
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
1413
|
-
* (refresh → challenge fallback) and one retry
|
|
1433
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
1434
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
1414
1435
|
*/
|
|
1415
1436
|
async requestJson(method, path, body) {
|
|
1416
1437
|
if (!this.jwt) await this.signIn();
|
|
1417
|
-
let res = await this.
|
|
1438
|
+
let res = await this.rawFetchWithReadRetry(method, path, body, this.jwt);
|
|
1418
1439
|
if (res.status === 401) {
|
|
1419
1440
|
this.jwt = null;
|
|
1420
1441
|
await this.signIn();
|
|
1421
|
-
res = await this.
|
|
1442
|
+
res = await this.rawFetchWithReadRetry(method, path, body, this.jwt);
|
|
1422
1443
|
}
|
|
1423
1444
|
if (res.status === 204) return null;
|
|
1424
1445
|
if (!res.ok) throw await this.toError(res, `${method} ${path}`);
|