@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
|
@@ -1457,9 +1457,17 @@ declare class WalletApiClient {
|
|
|
1457
1457
|
private rawFetch;
|
|
1458
1458
|
private readJson;
|
|
1459
1459
|
private toError;
|
|
1460
|
+
/**
|
|
1461
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
1462
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
1463
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
1464
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
1465
|
+
*/
|
|
1466
|
+
private rawFetchWithReadRetry;
|
|
1460
1467
|
/**
|
|
1461
1468
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
1462
|
-
* (refresh → challenge fallback) and one retry
|
|
1469
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
1470
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
1463
1471
|
*/
|
|
1464
1472
|
private requestJson;
|
|
1465
1473
|
/** `GET /v1/inventory?since=` — one page; the caller loops while `more`. */
|
|
@@ -1457,9 +1457,17 @@ declare class WalletApiClient {
|
|
|
1457
1457
|
private rawFetch;
|
|
1458
1458
|
private readJson;
|
|
1459
1459
|
private toError;
|
|
1460
|
+
/**
|
|
1461
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
1462
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
1463
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
1464
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
1465
|
+
*/
|
|
1466
|
+
private rawFetchWithReadRetry;
|
|
1460
1467
|
/**
|
|
1461
1468
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
1462
|
-
* (refresh → challenge fallback) and one retry
|
|
1469
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
1470
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
1463
1471
|
*/
|
|
1464
1472
|
private requestJson;
|
|
1465
1473
|
/** `GET /v1/inventory?since=` — one page; the caller loops while `more`. */
|
|
@@ -1173,6 +1173,8 @@ function defaultWebSocketFactory(url) {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
return new Ctor(url);
|
|
1175
1175
|
}
|
|
1176
|
+
var GET_RETRY_ATTEMPTS = 3;
|
|
1177
|
+
var GET_RETRY_BASE_MS = 200;
|
|
1176
1178
|
var WalletApiClient = class _WalletApiClient {
|
|
1177
1179
|
/** Network name (also the blob-key prefix `<network>/t/<sha256>` — §5.2). */
|
|
1178
1180
|
network;
|
|
@@ -1366,17 +1368,36 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
1366
1368
|
}
|
|
1367
1369
|
return WalletApiError.fromStatus(res.status, message);
|
|
1368
1370
|
}
|
|
1371
|
+
/**
|
|
1372
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
1373
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
1374
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
1375
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
1376
|
+
*/
|
|
1377
|
+
async rawFetchWithReadRetry(method, path, body, jwt) {
|
|
1378
|
+
const attempts = method === "GET" ? GET_RETRY_ATTEMPTS : 1;
|
|
1379
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
1380
|
+
try {
|
|
1381
|
+
return await this.rawFetch(method, path, body, jwt);
|
|
1382
|
+
} catch (err) {
|
|
1383
|
+
const transient = err instanceof WalletApiError && err.code === "NETWORK";
|
|
1384
|
+
if (!transient || attempt >= attempts) throw err;
|
|
1385
|
+
await new Promise((resolve) => setTimeout(resolve, GET_RETRY_BASE_MS * 2 ** (attempt - 1)));
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1369
1389
|
/**
|
|
1370
1390
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
1371
|
-
* (refresh → challenge fallback) and one retry
|
|
1391
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
1392
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
1372
1393
|
*/
|
|
1373
1394
|
async requestJson(method, path, body) {
|
|
1374
1395
|
if (!this.jwt) await this.signIn();
|
|
1375
|
-
let res = await this.
|
|
1396
|
+
let res = await this.rawFetchWithReadRetry(method, path, body, this.jwt);
|
|
1376
1397
|
if (res.status === 401) {
|
|
1377
1398
|
this.jwt = null;
|
|
1378
1399
|
await this.signIn();
|
|
1379
|
-
res = await this.
|
|
1400
|
+
res = await this.rawFetchWithReadRetry(method, path, body, this.jwt);
|
|
1380
1401
|
}
|
|
1381
1402
|
if (res.status === 204) return null;
|
|
1382
1403
|
if (!res.ok) throw await this.toError(res, `${method} ${path}`);
|