@unicitylabs/sphere-sdk 0.11.7 → 0.11.8
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 +31 -18
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +31 -18
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +31 -18
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +11 -7
- package/dist/impl/nodejs/index.d.ts +11 -7
- package/dist/impl/nodejs/index.js +31 -18
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/impl/shared/wallet-api/index.cjs +31 -18
- package/dist/impl/shared/wallet-api/index.cjs.map +1 -1
- package/dist/impl/shared/wallet-api/index.d.cts +11 -7
- package/dist/impl/shared/wallet-api/index.d.ts +11 -7
- package/dist/impl/shared/wallet-api/index.js +31 -18
- package/dist/impl/shared/wallet-api/index.js.map +1 -1
- package/dist/index.cjs +31 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -7
- package/dist/index.d.ts +11 -7
- package/dist/index.js +31 -18
- package/dist/index.js.map +1 -1
- package/dist/wallet-api/index.cjs +31 -18
- package/dist/wallet-api/index.cjs.map +1 -1
- package/dist/wallet-api/index.d.cts +11 -7
- package/dist/wallet-api/index.d.ts +11 -7
- package/dist/wallet-api/index.js +31 -18
- package/dist/wallet-api/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -2262,11 +2262,14 @@ declare class WalletApiClient {
|
|
|
2262
2262
|
/**
|
|
2263
2263
|
* Retry transient REST failures with bounded exponential backoff + jitter:
|
|
2264
2264
|
* - a thrown transient `NETWORK` failure (dropped/reset connection, DNS blip)
|
|
2265
|
-
* retries on **idempotent
|
|
2266
|
-
*
|
|
2265
|
+
* retries on **idempotent requests** — every GET, plus a write the caller
|
|
2266
|
+
* marked `idempotentWrite` (the server replays it as a no-op, so a
|
|
2267
|
+
* lost-response retry cannot double-apply; today only `inventory/apply`,
|
|
2268
|
+
* idempotent by transferId — #664). A non-idempotent write is single-attempt;
|
|
2267
2269
|
* - a `429` response retries on **any** method (a 429 is rejected before the
|
|
2268
2270
|
* handler runs — the write never executed), honoring the server `Retry-After`;
|
|
2269
|
-
* - a `503` response retries on **
|
|
2271
|
+
* - a `503` response retries on **idempotent requests only** (a non-idempotent
|
|
2272
|
+
* write may have started).
|
|
2270
2273
|
* Every other outcome (2xx, or a non-retryable status) is returned to the
|
|
2271
2274
|
* caller, which maps a non-2xx to a typed {@link WalletApiError}.
|
|
2272
2275
|
*/
|
|
@@ -2275,8 +2278,8 @@ declare class WalletApiClient {
|
|
|
2275
2278
|
private backoffMs;
|
|
2276
2279
|
/**
|
|
2277
2280
|
* Delay before retrying a non-2xx response, or `null` to not retry. `429`
|
|
2278
|
-
* retries on any method (rejected before execution); `503` on idempotent
|
|
2279
|
-
* Honors a capped `Retry-After` when present, else
|
|
2281
|
+
* retries on any method (rejected before execution); `503` on idempotent
|
|
2282
|
+
* requests only. Honors a capped `Retry-After` when present, else backoff.
|
|
2280
2283
|
*/
|
|
2281
2284
|
private retryDelayForStatus;
|
|
2282
2285
|
/** Parse `Retry-After` (delta-seconds or an HTTP-date) to ms, or `null` if absent/unparseable. */
|
|
@@ -2286,8 +2289,9 @@ declare class WalletApiClient {
|
|
|
2286
2289
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
2287
2290
|
* (refresh → challenge fallback) and one retry; {@link rawFetchWithRetry}
|
|
2288
2291
|
* additionally rides out transient failures — a dropped connection on an
|
|
2289
|
-
* idempotent GET, or a
|
|
2290
|
-
*
|
|
2292
|
+
* idempotent request (any GET, or a write flagged `opts.idempotent`), or a
|
|
2293
|
+
* `429`/`503` with `Retry-After` — so a single blip or a brief rate-limit
|
|
2294
|
+
* window doesn't fail the call.
|
|
2291
2295
|
*/
|
|
2292
2296
|
private requestJson;
|
|
2293
2297
|
/** `GET /v1/inventory?since=` — one page; the caller loops while `more`. */
|
|
@@ -2262,11 +2262,14 @@ declare class WalletApiClient {
|
|
|
2262
2262
|
/**
|
|
2263
2263
|
* Retry transient REST failures with bounded exponential backoff + jitter:
|
|
2264
2264
|
* - a thrown transient `NETWORK` failure (dropped/reset connection, DNS blip)
|
|
2265
|
-
* retries on **idempotent
|
|
2266
|
-
*
|
|
2265
|
+
* retries on **idempotent requests** — every GET, plus a write the caller
|
|
2266
|
+
* marked `idempotentWrite` (the server replays it as a no-op, so a
|
|
2267
|
+
* lost-response retry cannot double-apply; today only `inventory/apply`,
|
|
2268
|
+
* idempotent by transferId — #664). A non-idempotent write is single-attempt;
|
|
2267
2269
|
* - a `429` response retries on **any** method (a 429 is rejected before the
|
|
2268
2270
|
* handler runs — the write never executed), honoring the server `Retry-After`;
|
|
2269
|
-
* - a `503` response retries on **
|
|
2271
|
+
* - a `503` response retries on **idempotent requests only** (a non-idempotent
|
|
2272
|
+
* write may have started).
|
|
2270
2273
|
* Every other outcome (2xx, or a non-retryable status) is returned to the
|
|
2271
2274
|
* caller, which maps a non-2xx to a typed {@link WalletApiError}.
|
|
2272
2275
|
*/
|
|
@@ -2275,8 +2278,8 @@ declare class WalletApiClient {
|
|
|
2275
2278
|
private backoffMs;
|
|
2276
2279
|
/**
|
|
2277
2280
|
* Delay before retrying a non-2xx response, or `null` to not retry. `429`
|
|
2278
|
-
* retries on any method (rejected before execution); `503` on idempotent
|
|
2279
|
-
* Honors a capped `Retry-After` when present, else
|
|
2281
|
+
* retries on any method (rejected before execution); `503` on idempotent
|
|
2282
|
+
* requests only. Honors a capped `Retry-After` when present, else backoff.
|
|
2280
2283
|
*/
|
|
2281
2284
|
private retryDelayForStatus;
|
|
2282
2285
|
/** Parse `Retry-After` (delta-seconds or an HTTP-date) to ms, or `null` if absent/unparseable. */
|
|
@@ -2286,8 +2289,9 @@ declare class WalletApiClient {
|
|
|
2286
2289
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
2287
2290
|
* (refresh → challenge fallback) and one retry; {@link rawFetchWithRetry}
|
|
2288
2291
|
* additionally rides out transient failures — a dropped connection on an
|
|
2289
|
-
* idempotent GET, or a
|
|
2290
|
-
*
|
|
2292
|
+
* idempotent request (any GET, or a write flagged `opts.idempotent`), or a
|
|
2293
|
+
* `429`/`503` with `Retry-After` — so a single blip or a brief rate-limit
|
|
2294
|
+
* window doesn't fail the call.
|
|
2291
2295
|
*/
|
|
2292
2296
|
private requestJson;
|
|
2293
2297
|
/** `GET /v1/inventory?since=` — one page; the caller loops while `more`. */
|
|
@@ -27962,16 +27962,19 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
27962
27962
|
/**
|
|
27963
27963
|
* Retry transient REST failures with bounded exponential backoff + jitter:
|
|
27964
27964
|
* - a thrown transient `NETWORK` failure (dropped/reset connection, DNS blip)
|
|
27965
|
-
* retries on **idempotent
|
|
27966
|
-
*
|
|
27965
|
+
* retries on **idempotent requests** — every GET, plus a write the caller
|
|
27966
|
+
* marked `idempotentWrite` (the server replays it as a no-op, so a
|
|
27967
|
+
* lost-response retry cannot double-apply; today only `inventory/apply`,
|
|
27968
|
+
* idempotent by transferId — #664). A non-idempotent write is single-attempt;
|
|
27967
27969
|
* - a `429` response retries on **any** method (a 429 is rejected before the
|
|
27968
27970
|
* handler runs — the write never executed), honoring the server `Retry-After`;
|
|
27969
|
-
* - a `503` response retries on **
|
|
27971
|
+
* - a `503` response retries on **idempotent requests only** (a non-idempotent
|
|
27972
|
+
* write may have started).
|
|
27970
27973
|
* Every other outcome (2xx, or a non-retryable status) is returned to the
|
|
27971
27974
|
* caller, which maps a non-2xx to a typed {@link WalletApiError}.
|
|
27972
27975
|
*/
|
|
27973
|
-
async rawFetchWithRetry(method, path3, body, jwt) {
|
|
27974
|
-
const idempotent = method === "GET";
|
|
27976
|
+
async rawFetchWithRetry(method, path3, body, jwt, idempotentWrite = false) {
|
|
27977
|
+
const idempotent = method === "GET" || idempotentWrite;
|
|
27975
27978
|
for (let attempt = 1; ; attempt += 1) {
|
|
27976
27979
|
let res;
|
|
27977
27980
|
try {
|
|
@@ -27994,8 +27997,8 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
27994
27997
|
}
|
|
27995
27998
|
/**
|
|
27996
27999
|
* Delay before retrying a non-2xx response, or `null` to not retry. `429`
|
|
27997
|
-
* retries on any method (rejected before execution); `503` on idempotent
|
|
27998
|
-
* Honors a capped `Retry-After` when present, else
|
|
28000
|
+
* retries on any method (rejected before execution); `503` on idempotent
|
|
28001
|
+
* requests only. Honors a capped `Retry-After` when present, else backoff.
|
|
27999
28002
|
*/
|
|
28000
28003
|
retryDelayForStatus(res, idempotent, attempt) {
|
|
28001
28004
|
const retryable = res.status === 429 || res.status === 503 && idempotent;
|
|
@@ -28019,16 +28022,18 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
28019
28022
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
28020
28023
|
* (refresh → challenge fallback) and one retry; {@link rawFetchWithRetry}
|
|
28021
28024
|
* additionally rides out transient failures — a dropped connection on an
|
|
28022
|
-
* idempotent GET, or a
|
|
28023
|
-
*
|
|
28025
|
+
* idempotent request (any GET, or a write flagged `opts.idempotent`), or a
|
|
28026
|
+
* `429`/`503` with `Retry-After` — so a single blip or a brief rate-limit
|
|
28027
|
+
* window doesn't fail the call.
|
|
28024
28028
|
*/
|
|
28025
|
-
async requestJson(method, path3, body) {
|
|
28029
|
+
async requestJson(method, path3, body, opts) {
|
|
28030
|
+
const idempotent = opts?.idempotent ?? false;
|
|
28026
28031
|
if (!this.jwt) await this.signIn();
|
|
28027
|
-
let res = await this.rawFetchWithRetry(method, path3, body, this.jwt);
|
|
28032
|
+
let res = await this.rawFetchWithRetry(method, path3, body, this.jwt, idempotent);
|
|
28028
28033
|
if (res.status === 401) {
|
|
28029
28034
|
this.jwt = null;
|
|
28030
28035
|
await this.signIn();
|
|
28031
|
-
res = await this.rawFetchWithRetry(method, path3, body, this.jwt);
|
|
28036
|
+
res = await this.rawFetchWithRetry(method, path3, body, this.jwt, idempotent);
|
|
28032
28037
|
}
|
|
28033
28038
|
if (res.status === 204) return null;
|
|
28034
28039
|
if (!res.ok) throw await this.toError(res, `${method} ${path3}`);
|
|
@@ -28060,12 +28065,20 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
28060
28065
|
*/
|
|
28061
28066
|
async applyInventoryDelta(req) {
|
|
28062
28067
|
const cursor = parseApplyResult(
|
|
28063
|
-
await this.requestJson(
|
|
28064
|
-
|
|
28065
|
-
|
|
28066
|
-
|
|
28067
|
-
|
|
28068
|
-
|
|
28068
|
+
await this.requestJson(
|
|
28069
|
+
"POST",
|
|
28070
|
+
"/v1/inventory/apply",
|
|
28071
|
+
{
|
|
28072
|
+
transferId: req.transferId,
|
|
28073
|
+
spent: req.spent,
|
|
28074
|
+
added: req.added,
|
|
28075
|
+
...req.externalDelivery !== void 0 ? { externalDelivery: req.externalDelivery } : {}
|
|
28076
|
+
},
|
|
28077
|
+
// Idempotent by transferId — the server replays a re-applied transferId
|
|
28078
|
+
// to the same cursor (beginApplied), so a lost-response retry on a flaky
|
|
28079
|
+
// link is safe and won't double-apply (#664).
|
|
28080
|
+
{ idempotent: true }
|
|
28081
|
+
)
|
|
28069
28082
|
);
|
|
28070
28083
|
await this.setLocalIntentStatus(req.transferId, "completed");
|
|
28071
28084
|
return cursor;
|