@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.
Files changed (37) hide show
  1. package/dist/connect/index.cjs +1 -1
  2. package/dist/connect/index.cjs.map +1 -1
  3. package/dist/connect/index.js +1 -1
  4. package/dist/connect/index.js.map +1 -1
  5. package/dist/impl/browser/connect/index.cjs +1 -1
  6. package/dist/impl/browser/connect/index.cjs.map +1 -1
  7. package/dist/impl/browser/connect/index.js +1 -1
  8. package/dist/impl/browser/connect/index.js.map +1 -1
  9. package/dist/impl/browser/index.cjs +24 -3
  10. package/dist/impl/browser/index.cjs.map +1 -1
  11. package/dist/impl/browser/index.js +24 -3
  12. package/dist/impl/browser/index.js.map +1 -1
  13. package/dist/impl/nodejs/index.cjs +24 -3
  14. package/dist/impl/nodejs/index.cjs.map +1 -1
  15. package/dist/impl/nodejs/index.d.cts +9 -1
  16. package/dist/impl/nodejs/index.d.ts +9 -1
  17. package/dist/impl/nodejs/index.js +24 -3
  18. package/dist/impl/nodejs/index.js.map +1 -1
  19. package/dist/impl/shared/wallet-api/index.cjs +24 -3
  20. package/dist/impl/shared/wallet-api/index.cjs.map +1 -1
  21. package/dist/impl/shared/wallet-api/index.d.cts +9 -1
  22. package/dist/impl/shared/wallet-api/index.d.ts +9 -1
  23. package/dist/impl/shared/wallet-api/index.js +24 -3
  24. package/dist/impl/shared/wallet-api/index.js.map +1 -1
  25. package/dist/index.cjs +24 -3
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +9 -1
  28. package/dist/index.d.ts +9 -1
  29. package/dist/index.js +24 -3
  30. package/dist/index.js.map +1 -1
  31. package/dist/wallet-api/index.cjs +24 -3
  32. package/dist/wallet-api/index.cjs.map +1 -1
  33. package/dist/wallet-api/index.d.cts +9 -1
  34. package/dist/wallet-api/index.d.ts +9 -1
  35. package/dist/wallet-api/index.js +24 -3
  36. package/dist/wallet-api/index.js.map +1 -1
  37. 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.rawFetch(method, path, body, this.jwt);
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.rawFetch(method, path, body, this.jwt);
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}`);