@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
|
@@ -27719,6 +27719,8 @@ function defaultWebSocketFactory(url) {
|
|
|
27719
27719
|
}
|
|
27720
27720
|
return new Ctor(url);
|
|
27721
27721
|
}
|
|
27722
|
+
var GET_RETRY_ATTEMPTS = 3;
|
|
27723
|
+
var GET_RETRY_BASE_MS = 200;
|
|
27722
27724
|
var WalletApiClient = class _WalletApiClient {
|
|
27723
27725
|
/** Network name (also the blob-key prefix `<network>/t/<sha256>` — §5.2). */
|
|
27724
27726
|
network;
|
|
@@ -27912,17 +27914,36 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
27912
27914
|
}
|
|
27913
27915
|
return WalletApiError.fromStatus(res.status, message);
|
|
27914
27916
|
}
|
|
27917
|
+
/**
|
|
27918
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
27919
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
27920
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
27921
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
27922
|
+
*/
|
|
27923
|
+
async rawFetchWithReadRetry(method, path3, body, jwt) {
|
|
27924
|
+
const attempts = method === "GET" ? GET_RETRY_ATTEMPTS : 1;
|
|
27925
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
27926
|
+
try {
|
|
27927
|
+
return await this.rawFetch(method, path3, body, jwt);
|
|
27928
|
+
} catch (err) {
|
|
27929
|
+
const transient = err instanceof WalletApiError && err.code === "NETWORK";
|
|
27930
|
+
if (!transient || attempt >= attempts) throw err;
|
|
27931
|
+
await new Promise((resolve) => setTimeout(resolve, GET_RETRY_BASE_MS * 2 ** (attempt - 1)));
|
|
27932
|
+
}
|
|
27933
|
+
}
|
|
27934
|
+
}
|
|
27915
27935
|
/**
|
|
27916
27936
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
27917
|
-
* (refresh → challenge fallback) and one retry
|
|
27937
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
27938
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
27918
27939
|
*/
|
|
27919
27940
|
async requestJson(method, path3, body) {
|
|
27920
27941
|
if (!this.jwt) await this.signIn();
|
|
27921
|
-
let res = await this.
|
|
27942
|
+
let res = await this.rawFetchWithReadRetry(method, path3, body, this.jwt);
|
|
27922
27943
|
if (res.status === 401) {
|
|
27923
27944
|
this.jwt = null;
|
|
27924
27945
|
await this.signIn();
|
|
27925
|
-
res = await this.
|
|
27946
|
+
res = await this.rawFetchWithReadRetry(method, path3, body, this.jwt);
|
|
27926
27947
|
}
|
|
27927
27948
|
if (res.status === 204) return null;
|
|
27928
27949
|
if (!res.ok) throw await this.toError(res, `${method} ${path3}`);
|