@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
|
@@ -2143,9 +2143,17 @@ declare class WalletApiClient {
|
|
|
2143
2143
|
private rawFetch;
|
|
2144
2144
|
private readJson;
|
|
2145
2145
|
private toError;
|
|
2146
|
+
/**
|
|
2147
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
2148
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
2149
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
2150
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
2151
|
+
*/
|
|
2152
|
+
private rawFetchWithReadRetry;
|
|
2146
2153
|
/**
|
|
2147
2154
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
2148
|
-
* (refresh → challenge fallback) and one retry
|
|
2155
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
2156
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
2149
2157
|
*/
|
|
2150
2158
|
private requestJson;
|
|
2151
2159
|
/** `GET /v1/inventory?since=` — one page; the caller loops while `more`. */
|
|
@@ -2143,9 +2143,17 @@ declare class WalletApiClient {
|
|
|
2143
2143
|
private rawFetch;
|
|
2144
2144
|
private readJson;
|
|
2145
2145
|
private toError;
|
|
2146
|
+
/**
|
|
2147
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
2148
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
2149
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
2150
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
2151
|
+
*/
|
|
2152
|
+
private rawFetchWithReadRetry;
|
|
2146
2153
|
/**
|
|
2147
2154
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
2148
|
-
* (refresh → challenge fallback) and one retry
|
|
2155
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
2156
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
2149
2157
|
*/
|
|
2150
2158
|
private requestJson;
|
|
2151
2159
|
/** `GET /v1/inventory?since=` — one page; the caller loops while `more`. */
|
|
@@ -27683,6 +27683,8 @@ function defaultWebSocketFactory(url) {
|
|
|
27683
27683
|
}
|
|
27684
27684
|
return new Ctor(url);
|
|
27685
27685
|
}
|
|
27686
|
+
var GET_RETRY_ATTEMPTS = 3;
|
|
27687
|
+
var GET_RETRY_BASE_MS = 200;
|
|
27686
27688
|
var WalletApiClient = class _WalletApiClient {
|
|
27687
27689
|
/** Network name (also the blob-key prefix `<network>/t/<sha256>` — §5.2). */
|
|
27688
27690
|
network;
|
|
@@ -27876,17 +27878,36 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
27876
27878
|
}
|
|
27877
27879
|
return WalletApiError.fromStatus(res.status, message);
|
|
27878
27880
|
}
|
|
27881
|
+
/**
|
|
27882
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
27883
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
27884
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
27885
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
27886
|
+
*/
|
|
27887
|
+
async rawFetchWithReadRetry(method, path3, body, jwt) {
|
|
27888
|
+
const attempts = method === "GET" ? GET_RETRY_ATTEMPTS : 1;
|
|
27889
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
27890
|
+
try {
|
|
27891
|
+
return await this.rawFetch(method, path3, body, jwt);
|
|
27892
|
+
} catch (err) {
|
|
27893
|
+
const transient = err instanceof WalletApiError && err.code === "NETWORK";
|
|
27894
|
+
if (!transient || attempt >= attempts) throw err;
|
|
27895
|
+
await new Promise((resolve) => setTimeout(resolve, GET_RETRY_BASE_MS * 2 ** (attempt - 1)));
|
|
27896
|
+
}
|
|
27897
|
+
}
|
|
27898
|
+
}
|
|
27879
27899
|
/**
|
|
27880
27900
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
27881
|
-
* (refresh → challenge fallback) and one retry
|
|
27901
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
27902
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
27882
27903
|
*/
|
|
27883
27904
|
async requestJson(method, path3, body) {
|
|
27884
27905
|
if (!this.jwt) await this.signIn();
|
|
27885
|
-
let res = await this.
|
|
27906
|
+
let res = await this.rawFetchWithReadRetry(method, path3, body, this.jwt);
|
|
27886
27907
|
if (res.status === 401) {
|
|
27887
27908
|
this.jwt = null;
|
|
27888
27909
|
await this.signIn();
|
|
27889
|
-
res = await this.
|
|
27910
|
+
res = await this.rawFetchWithReadRetry(method, path3, body, this.jwt);
|
|
27890
27911
|
}
|
|
27891
27912
|
if (res.status === 204) return null;
|
|
27892
27913
|
if (!res.ok) throw await this.toError(res, `${method} ${path3}`);
|