@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
|
@@ -4639,6 +4639,8 @@ function defaultWebSocketFactory(url) {
|
|
|
4639
4639
|
}
|
|
4640
4640
|
return new Ctor(url);
|
|
4641
4641
|
}
|
|
4642
|
+
var GET_RETRY_ATTEMPTS = 3;
|
|
4643
|
+
var GET_RETRY_BASE_MS = 200;
|
|
4642
4644
|
var WalletApiClient = class _WalletApiClient {
|
|
4643
4645
|
/** Network name (also the blob-key prefix `<network>/t/<sha256>` — §5.2). */
|
|
4644
4646
|
network;
|
|
@@ -4832,17 +4834,36 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
4832
4834
|
}
|
|
4833
4835
|
return WalletApiError.fromStatus(res.status, message);
|
|
4834
4836
|
}
|
|
4837
|
+
/**
|
|
4838
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
4839
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
4840
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
4841
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
4842
|
+
*/
|
|
4843
|
+
async rawFetchWithReadRetry(method, path, body, jwt) {
|
|
4844
|
+
const attempts = method === "GET" ? GET_RETRY_ATTEMPTS : 1;
|
|
4845
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
4846
|
+
try {
|
|
4847
|
+
return await this.rawFetch(method, path, body, jwt);
|
|
4848
|
+
} catch (err) {
|
|
4849
|
+
const transient = err instanceof WalletApiError && err.code === "NETWORK";
|
|
4850
|
+
if (!transient || attempt >= attempts) throw err;
|
|
4851
|
+
await new Promise((resolve) => setTimeout(resolve, GET_RETRY_BASE_MS * 2 ** (attempt - 1)));
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4854
|
+
}
|
|
4835
4855
|
/**
|
|
4836
4856
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
4837
|
-
* (refresh → challenge fallback) and one retry
|
|
4857
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
4858
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
4838
4859
|
*/
|
|
4839
4860
|
async requestJson(method, path, body) {
|
|
4840
4861
|
if (!this.jwt) await this.signIn();
|
|
4841
|
-
let res = await this.
|
|
4862
|
+
let res = await this.rawFetchWithReadRetry(method, path, body, this.jwt);
|
|
4842
4863
|
if (res.status === 401) {
|
|
4843
4864
|
this.jwt = null;
|
|
4844
4865
|
await this.signIn();
|
|
4845
|
-
res = await this.
|
|
4866
|
+
res = await this.rawFetchWithReadRetry(method, path, body, this.jwt);
|
|
4846
4867
|
}
|
|
4847
4868
|
if (res.status === 204) return null;
|
|
4848
4869
|
if (!res.ok) throw await this.toError(res, `${method} ${path}`);
|