@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
|
@@ -490,9 +490,17 @@ declare class WalletApiClient {
|
|
|
490
490
|
private rawFetch;
|
|
491
491
|
private readJson;
|
|
492
492
|
private toError;
|
|
493
|
+
/**
|
|
494
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
495
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
496
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
497
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
498
|
+
*/
|
|
499
|
+
private rawFetchWithReadRetry;
|
|
493
500
|
/**
|
|
494
501
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
495
|
-
* (refresh → challenge fallback) and one retry
|
|
502
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
503
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
496
504
|
*/
|
|
497
505
|
private requestJson;
|
|
498
506
|
/** `GET /v1/inventory?since=` — one page; the caller loops while `more`. */
|
|
@@ -490,9 +490,17 @@ declare class WalletApiClient {
|
|
|
490
490
|
private rawFetch;
|
|
491
491
|
private readJson;
|
|
492
492
|
private toError;
|
|
493
|
+
/**
|
|
494
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
495
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
496
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
497
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
498
|
+
*/
|
|
499
|
+
private rawFetchWithReadRetry;
|
|
493
500
|
/**
|
|
494
501
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
495
|
-
* (refresh → challenge fallback) and one retry
|
|
502
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
503
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
496
504
|
*/
|
|
497
505
|
private requestJson;
|
|
498
506
|
/** `GET /v1/inventory?since=` — one page; the caller loops while `more`. */
|
package/dist/wallet-api/index.js
CHANGED
|
@@ -980,6 +980,8 @@ function defaultWebSocketFactory(url) {
|
|
|
980
980
|
}
|
|
981
981
|
return new Ctor(url);
|
|
982
982
|
}
|
|
983
|
+
var GET_RETRY_ATTEMPTS = 3;
|
|
984
|
+
var GET_RETRY_BASE_MS = 200;
|
|
983
985
|
var WalletApiClient = class _WalletApiClient {
|
|
984
986
|
/** Network name (also the blob-key prefix `<network>/t/<sha256>` — §5.2). */
|
|
985
987
|
network;
|
|
@@ -1173,17 +1175,36 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
1173
1175
|
}
|
|
1174
1176
|
return WalletApiError.fromStatus(res.status, message);
|
|
1175
1177
|
}
|
|
1178
|
+
/**
|
|
1179
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
1180
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
1181
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
1182
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
1183
|
+
*/
|
|
1184
|
+
async rawFetchWithReadRetry(method, path, body, jwt) {
|
|
1185
|
+
const attempts = method === "GET" ? GET_RETRY_ATTEMPTS : 1;
|
|
1186
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
1187
|
+
try {
|
|
1188
|
+
return await this.rawFetch(method, path, body, jwt);
|
|
1189
|
+
} catch (err) {
|
|
1190
|
+
const transient = err instanceof WalletApiError && err.code === "NETWORK";
|
|
1191
|
+
if (!transient || attempt >= attempts) throw err;
|
|
1192
|
+
await new Promise((resolve) => setTimeout(resolve, GET_RETRY_BASE_MS * 2 ** (attempt - 1)));
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1176
1196
|
/**
|
|
1177
1197
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
1178
|
-
* (refresh → challenge fallback) and one retry
|
|
1198
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
1199
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
1179
1200
|
*/
|
|
1180
1201
|
async requestJson(method, path, body) {
|
|
1181
1202
|
if (!this.jwt) await this.signIn();
|
|
1182
|
-
let res = await this.
|
|
1203
|
+
let res = await this.rawFetchWithReadRetry(method, path, body, this.jwt);
|
|
1183
1204
|
if (res.status === 401) {
|
|
1184
1205
|
this.jwt = null;
|
|
1185
1206
|
await this.signIn();
|
|
1186
|
-
res = await this.
|
|
1207
|
+
res = await this.rawFetchWithReadRetry(method, path, body, this.jwt);
|
|
1187
1208
|
}
|
|
1188
1209
|
if (res.status === 204) return null;
|
|
1189
1210
|
if (!res.ok) throw await this.toError(res, `${method} ${path}`);
|