@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
package/dist/index.d.cts
CHANGED
|
@@ -9665,9 +9665,17 @@ declare class WalletApiClient {
|
|
|
9665
9665
|
private rawFetch;
|
|
9666
9666
|
private readJson;
|
|
9667
9667
|
private toError;
|
|
9668
|
+
/**
|
|
9669
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
9670
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
9671
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
9672
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
9673
|
+
*/
|
|
9674
|
+
private rawFetchWithReadRetry;
|
|
9668
9675
|
/**
|
|
9669
9676
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
9670
|
-
* (refresh → challenge fallback) and one retry
|
|
9677
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
9678
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
9671
9679
|
*/
|
|
9672
9680
|
private requestJson;
|
|
9673
9681
|
/** `GET /v1/inventory?since=` — one page; the caller loops while `more`. */
|
package/dist/index.d.ts
CHANGED
|
@@ -9665,9 +9665,17 @@ declare class WalletApiClient {
|
|
|
9665
9665
|
private rawFetch;
|
|
9666
9666
|
private readJson;
|
|
9667
9667
|
private toError;
|
|
9668
|
+
/**
|
|
9669
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
9670
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
9671
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
9672
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
9673
|
+
*/
|
|
9674
|
+
private rawFetchWithReadRetry;
|
|
9668
9675
|
/**
|
|
9669
9676
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
9670
|
-
* (refresh → challenge fallback) and one retry
|
|
9677
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
9678
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
9671
9679
|
*/
|
|
9672
9680
|
private requestJson;
|
|
9673
9681
|
/** `GET /v1/inventory?since=` — one page; the caller loops while `more`. */
|
package/dist/index.js
CHANGED
|
@@ -5725,6 +5725,8 @@ function defaultWebSocketFactory(url) {
|
|
|
5725
5725
|
}
|
|
5726
5726
|
return new Ctor(url);
|
|
5727
5727
|
}
|
|
5728
|
+
var GET_RETRY_ATTEMPTS = 3;
|
|
5729
|
+
var GET_RETRY_BASE_MS = 200;
|
|
5728
5730
|
var WalletApiClient = class _WalletApiClient {
|
|
5729
5731
|
/** Network name (also the blob-key prefix `<network>/t/<sha256>` — §5.2). */
|
|
5730
5732
|
network;
|
|
@@ -5918,17 +5920,36 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
5918
5920
|
}
|
|
5919
5921
|
return WalletApiError.fromStatus(res.status, message);
|
|
5920
5922
|
}
|
|
5923
|
+
/**
|
|
5924
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
5925
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
5926
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
5927
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
5928
|
+
*/
|
|
5929
|
+
async rawFetchWithReadRetry(method, path, body, jwt) {
|
|
5930
|
+
const attempts = method === "GET" ? GET_RETRY_ATTEMPTS : 1;
|
|
5931
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
5932
|
+
try {
|
|
5933
|
+
return await this.rawFetch(method, path, body, jwt);
|
|
5934
|
+
} catch (err) {
|
|
5935
|
+
const transient = err instanceof WalletApiError && err.code === "NETWORK";
|
|
5936
|
+
if (!transient || attempt >= attempts) throw err;
|
|
5937
|
+
await new Promise((resolve) => setTimeout(resolve, GET_RETRY_BASE_MS * 2 ** (attempt - 1)));
|
|
5938
|
+
}
|
|
5939
|
+
}
|
|
5940
|
+
}
|
|
5921
5941
|
/**
|
|
5922
5942
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
5923
|
-
* (refresh → challenge fallback) and one retry
|
|
5943
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
5944
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
5924
5945
|
*/
|
|
5925
5946
|
async requestJson(method, path, body) {
|
|
5926
5947
|
if (!this.jwt) await this.signIn();
|
|
5927
|
-
let res = await this.
|
|
5948
|
+
let res = await this.rawFetchWithReadRetry(method, path, body, this.jwt);
|
|
5928
5949
|
if (res.status === 401) {
|
|
5929
5950
|
this.jwt = null;
|
|
5930
5951
|
await this.signIn();
|
|
5931
|
-
res = await this.
|
|
5952
|
+
res = await this.rawFetchWithReadRetry(method, path, body, this.jwt);
|
|
5932
5953
|
}
|
|
5933
5954
|
if (res.status === 204) return null;
|
|
5934
5955
|
if (!res.ok) throw await this.toError(res, `${method} ${path}`);
|