@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.cjs
CHANGED
|
@@ -5911,6 +5911,8 @@ function defaultWebSocketFactory(url) {
|
|
|
5911
5911
|
}
|
|
5912
5912
|
return new Ctor(url);
|
|
5913
5913
|
}
|
|
5914
|
+
var GET_RETRY_ATTEMPTS = 3;
|
|
5915
|
+
var GET_RETRY_BASE_MS = 200;
|
|
5914
5916
|
var WalletApiClient = class _WalletApiClient {
|
|
5915
5917
|
/** Network name (also the blob-key prefix `<network>/t/<sha256>` — §5.2). */
|
|
5916
5918
|
network;
|
|
@@ -6104,17 +6106,36 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
6104
6106
|
}
|
|
6105
6107
|
return WalletApiError.fromStatus(res.status, message);
|
|
6106
6108
|
}
|
|
6109
|
+
/**
|
|
6110
|
+
* GET-only retry on a transient NETWORK failure (a dropped/reset connection — e.g. a backend under
|
|
6111
|
+
* load resetting mid-read). GETs are idempotent, so re-issuing is safe; non-GET methods are NEVER
|
|
6112
|
+
* retried here because a lost-response retry could double-apply a write. Non-NETWORK outcomes (any
|
|
6113
|
+
* HTTP status) come back as a response and are handled by the caller. Bounded exponential backoff.
|
|
6114
|
+
*/
|
|
6115
|
+
async rawFetchWithReadRetry(method, path, body, jwt) {
|
|
6116
|
+
const attempts = method === "GET" ? GET_RETRY_ATTEMPTS : 1;
|
|
6117
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
6118
|
+
try {
|
|
6119
|
+
return await this.rawFetch(method, path, body, jwt);
|
|
6120
|
+
} catch (err) {
|
|
6121
|
+
const transient = err instanceof WalletApiError && err.code === "NETWORK";
|
|
6122
|
+
if (!transient || attempt >= attempts) throw err;
|
|
6123
|
+
await new Promise((resolve) => setTimeout(resolve, GET_RETRY_BASE_MS * 2 ** (attempt - 1)));
|
|
6124
|
+
}
|
|
6125
|
+
}
|
|
6126
|
+
}
|
|
6107
6127
|
/**
|
|
6108
6128
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
6109
|
-
* (refresh → challenge fallback) and one retry
|
|
6129
|
+
* (refresh → challenge fallback) and one retry; idempotent GETs additionally retry a transient
|
|
6130
|
+
* NETWORK failure (rawFetchWithReadRetry) so a single dropped connection doesn't fail the call.
|
|
6110
6131
|
*/
|
|
6111
6132
|
async requestJson(method, path, body) {
|
|
6112
6133
|
if (!this.jwt) await this.signIn();
|
|
6113
|
-
let res = await this.
|
|
6134
|
+
let res = await this.rawFetchWithReadRetry(method, path, body, this.jwt);
|
|
6114
6135
|
if (res.status === 401) {
|
|
6115
6136
|
this.jwt = null;
|
|
6116
6137
|
await this.signIn();
|
|
6117
|
-
res = await this.
|
|
6138
|
+
res = await this.rawFetchWithReadRetry(method, path, body, this.jwt);
|
|
6118
6139
|
}
|
|
6119
6140
|
if (res.status === 204) return null;
|
|
6120
6141
|
if (!res.ok) throw await this.toError(res, `${method} ${path}`);
|