@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
|
@@ -27999,16 +27999,19 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
27999
27999
|
/**
|
|
28000
28000
|
* Retry transient REST failures with bounded exponential backoff + jitter:
|
|
28001
28001
|
* - a thrown transient `NETWORK` failure (dropped/reset connection, DNS blip)
|
|
28002
|
-
* retries on **idempotent
|
|
28003
|
-
*
|
|
28002
|
+
* retries on **idempotent requests** — every GET, plus a write the caller
|
|
28003
|
+
* marked `idempotentWrite` (the server replays it as a no-op, so a
|
|
28004
|
+
* lost-response retry cannot double-apply; today only `inventory/apply`,
|
|
28005
|
+
* idempotent by transferId — #664). A non-idempotent write is single-attempt;
|
|
28004
28006
|
* - a `429` response retries on **any** method (a 429 is rejected before the
|
|
28005
28007
|
* handler runs — the write never executed), honoring the server `Retry-After`;
|
|
28006
|
-
* - a `503` response retries on **
|
|
28008
|
+
* - a `503` response retries on **idempotent requests only** (a non-idempotent
|
|
28009
|
+
* write may have started).
|
|
28007
28010
|
* Every other outcome (2xx, or a non-retryable status) is returned to the
|
|
28008
28011
|
* caller, which maps a non-2xx to a typed {@link WalletApiError}.
|
|
28009
28012
|
*/
|
|
28010
|
-
async rawFetchWithRetry(method, path3, body, jwt) {
|
|
28011
|
-
const idempotent = method === "GET";
|
|
28013
|
+
async rawFetchWithRetry(method, path3, body, jwt, idempotentWrite = false) {
|
|
28014
|
+
const idempotent = method === "GET" || idempotentWrite;
|
|
28012
28015
|
for (let attempt = 1; ; attempt += 1) {
|
|
28013
28016
|
let res;
|
|
28014
28017
|
try {
|
|
@@ -28031,8 +28034,8 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
28031
28034
|
}
|
|
28032
28035
|
/**
|
|
28033
28036
|
* Delay before retrying a non-2xx response, or `null` to not retry. `429`
|
|
28034
|
-
* retries on any method (rejected before execution); `503` on idempotent
|
|
28035
|
-
* Honors a capped `Retry-After` when present, else
|
|
28037
|
+
* retries on any method (rejected before execution); `503` on idempotent
|
|
28038
|
+
* requests only. Honors a capped `Retry-After` when present, else backoff.
|
|
28036
28039
|
*/
|
|
28037
28040
|
retryDelayForStatus(res, idempotent, attempt) {
|
|
28038
28041
|
const retryable = res.status === 429 || res.status === 503 && idempotent;
|
|
@@ -28056,16 +28059,18 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
28056
28059
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
28057
28060
|
* (refresh → challenge fallback) and one retry; {@link rawFetchWithRetry}
|
|
28058
28061
|
* additionally rides out transient failures — a dropped connection on an
|
|
28059
|
-
* idempotent GET, or a
|
|
28060
|
-
*
|
|
28062
|
+
* idempotent request (any GET, or a write flagged `opts.idempotent`), or a
|
|
28063
|
+
* `429`/`503` with `Retry-After` — so a single blip or a brief rate-limit
|
|
28064
|
+
* window doesn't fail the call.
|
|
28061
28065
|
*/
|
|
28062
|
-
async requestJson(method, path3, body) {
|
|
28066
|
+
async requestJson(method, path3, body, opts) {
|
|
28067
|
+
const idempotent = opts?.idempotent ?? false;
|
|
28063
28068
|
if (!this.jwt) await this.signIn();
|
|
28064
|
-
let res = await this.rawFetchWithRetry(method, path3, body, this.jwt);
|
|
28069
|
+
let res = await this.rawFetchWithRetry(method, path3, body, this.jwt, idempotent);
|
|
28065
28070
|
if (res.status === 401) {
|
|
28066
28071
|
this.jwt = null;
|
|
28067
28072
|
await this.signIn();
|
|
28068
|
-
res = await this.rawFetchWithRetry(method, path3, body, this.jwt);
|
|
28073
|
+
res = await this.rawFetchWithRetry(method, path3, body, this.jwt, idempotent);
|
|
28069
28074
|
}
|
|
28070
28075
|
if (res.status === 204) return null;
|
|
28071
28076
|
if (!res.ok) throw await this.toError(res, `${method} ${path3}`);
|
|
@@ -28097,12 +28102,20 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
28097
28102
|
*/
|
|
28098
28103
|
async applyInventoryDelta(req) {
|
|
28099
28104
|
const cursor = parseApplyResult(
|
|
28100
|
-
await this.requestJson(
|
|
28101
|
-
|
|
28102
|
-
|
|
28103
|
-
|
|
28104
|
-
|
|
28105
|
-
|
|
28105
|
+
await this.requestJson(
|
|
28106
|
+
"POST",
|
|
28107
|
+
"/v1/inventory/apply",
|
|
28108
|
+
{
|
|
28109
|
+
transferId: req.transferId,
|
|
28110
|
+
spent: req.spent,
|
|
28111
|
+
added: req.added,
|
|
28112
|
+
...req.externalDelivery !== void 0 ? { externalDelivery: req.externalDelivery } : {}
|
|
28113
|
+
},
|
|
28114
|
+
// Idempotent by transferId — the server replays a re-applied transferId
|
|
28115
|
+
// to the same cursor (beginApplied), so a lost-response retry on a flaky
|
|
28116
|
+
// link is safe and won't double-apply (#664).
|
|
28117
|
+
{ idempotent: true }
|
|
28118
|
+
)
|
|
28106
28119
|
);
|
|
28107
28120
|
await this.setLocalIntentStatus(req.transferId, "completed");
|
|
28108
28121
|
return cursor;
|