@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
package/dist/index.d.cts
CHANGED
|
@@ -9904,11 +9904,14 @@ declare class WalletApiClient {
|
|
|
9904
9904
|
/**
|
|
9905
9905
|
* Retry transient REST failures with bounded exponential backoff + jitter:
|
|
9906
9906
|
* - a thrown transient `NETWORK` failure (dropped/reset connection, DNS blip)
|
|
9907
|
-
* retries on **idempotent
|
|
9908
|
-
*
|
|
9907
|
+
* retries on **idempotent requests** — every GET, plus a write the caller
|
|
9908
|
+
* marked `idempotentWrite` (the server replays it as a no-op, so a
|
|
9909
|
+
* lost-response retry cannot double-apply; today only `inventory/apply`,
|
|
9910
|
+
* idempotent by transferId — #664). A non-idempotent write is single-attempt;
|
|
9909
9911
|
* - a `429` response retries on **any** method (a 429 is rejected before the
|
|
9910
9912
|
* handler runs — the write never executed), honoring the server `Retry-After`;
|
|
9911
|
-
* - a `503` response retries on **
|
|
9913
|
+
* - a `503` response retries on **idempotent requests only** (a non-idempotent
|
|
9914
|
+
* write may have started).
|
|
9912
9915
|
* Every other outcome (2xx, or a non-retryable status) is returned to the
|
|
9913
9916
|
* caller, which maps a non-2xx to a typed {@link WalletApiError}.
|
|
9914
9917
|
*/
|
|
@@ -9917,8 +9920,8 @@ declare class WalletApiClient {
|
|
|
9917
9920
|
private backoffMs;
|
|
9918
9921
|
/**
|
|
9919
9922
|
* Delay before retrying a non-2xx response, or `null` to not retry. `429`
|
|
9920
|
-
* retries on any method (rejected before execution); `503` on idempotent
|
|
9921
|
-
* Honors a capped `Retry-After` when present, else
|
|
9923
|
+
* retries on any method (rejected before execution); `503` on idempotent
|
|
9924
|
+
* requests only. Honors a capped `Retry-After` when present, else backoff.
|
|
9922
9925
|
*/
|
|
9923
9926
|
private retryDelayForStatus;
|
|
9924
9927
|
/** Parse `Retry-After` (delta-seconds or an HTTP-date) to ms, or `null` if absent/unparseable. */
|
|
@@ -9928,8 +9931,9 @@ declare class WalletApiClient {
|
|
|
9928
9931
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
9929
9932
|
* (refresh → challenge fallback) and one retry; {@link rawFetchWithRetry}
|
|
9930
9933
|
* additionally rides out transient failures — a dropped connection on an
|
|
9931
|
-
* idempotent GET, or a
|
|
9932
|
-
*
|
|
9934
|
+
* idempotent request (any GET, or a write flagged `opts.idempotent`), or a
|
|
9935
|
+
* `429`/`503` with `Retry-After` — so a single blip or a brief rate-limit
|
|
9936
|
+
* window doesn't fail the call.
|
|
9933
9937
|
*/
|
|
9934
9938
|
private requestJson;
|
|
9935
9939
|
/** `GET /v1/inventory?since=` — one page; the caller loops while `more`. */
|
package/dist/index.d.ts
CHANGED
|
@@ -9904,11 +9904,14 @@ declare class WalletApiClient {
|
|
|
9904
9904
|
/**
|
|
9905
9905
|
* Retry transient REST failures with bounded exponential backoff + jitter:
|
|
9906
9906
|
* - a thrown transient `NETWORK` failure (dropped/reset connection, DNS blip)
|
|
9907
|
-
* retries on **idempotent
|
|
9908
|
-
*
|
|
9907
|
+
* retries on **idempotent requests** — every GET, plus a write the caller
|
|
9908
|
+
* marked `idempotentWrite` (the server replays it as a no-op, so a
|
|
9909
|
+
* lost-response retry cannot double-apply; today only `inventory/apply`,
|
|
9910
|
+
* idempotent by transferId — #664). A non-idempotent write is single-attempt;
|
|
9909
9911
|
* - a `429` response retries on **any** method (a 429 is rejected before the
|
|
9910
9912
|
* handler runs — the write never executed), honoring the server `Retry-After`;
|
|
9911
|
-
* - a `503` response retries on **
|
|
9913
|
+
* - a `503` response retries on **idempotent requests only** (a non-idempotent
|
|
9914
|
+
* write may have started).
|
|
9912
9915
|
* Every other outcome (2xx, or a non-retryable status) is returned to the
|
|
9913
9916
|
* caller, which maps a non-2xx to a typed {@link WalletApiError}.
|
|
9914
9917
|
*/
|
|
@@ -9917,8 +9920,8 @@ declare class WalletApiClient {
|
|
|
9917
9920
|
private backoffMs;
|
|
9918
9921
|
/**
|
|
9919
9922
|
* Delay before retrying a non-2xx response, or `null` to not retry. `429`
|
|
9920
|
-
* retries on any method (rejected before execution); `503` on idempotent
|
|
9921
|
-
* Honors a capped `Retry-After` when present, else
|
|
9923
|
+
* retries on any method (rejected before execution); `503` on idempotent
|
|
9924
|
+
* requests only. Honors a capped `Retry-After` when present, else backoff.
|
|
9922
9925
|
*/
|
|
9923
9926
|
private retryDelayForStatus;
|
|
9924
9927
|
/** Parse `Retry-After` (delta-seconds or an HTTP-date) to ms, or `null` if absent/unparseable. */
|
|
@@ -9928,8 +9931,9 @@ declare class WalletApiClient {
|
|
|
9928
9931
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
9929
9932
|
* (refresh → challenge fallback) and one retry; {@link rawFetchWithRetry}
|
|
9930
9933
|
* additionally rides out transient failures — a dropped connection on an
|
|
9931
|
-
* idempotent GET, or a
|
|
9932
|
-
*
|
|
9934
|
+
* idempotent request (any GET, or a write flagged `opts.idempotent`), or a
|
|
9935
|
+
* `429`/`503` with `Retry-After` — so a single blip or a brief rate-limit
|
|
9936
|
+
* window doesn't fail the call.
|
|
9933
9937
|
*/
|
|
9934
9938
|
private requestJson;
|
|
9935
9939
|
/** `GET /v1/inventory?since=` — one page; the caller loops while `more`. */
|
package/dist/index.js
CHANGED
|
@@ -7098,16 +7098,19 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
7098
7098
|
/**
|
|
7099
7099
|
* Retry transient REST failures with bounded exponential backoff + jitter:
|
|
7100
7100
|
* - a thrown transient `NETWORK` failure (dropped/reset connection, DNS blip)
|
|
7101
|
-
* retries on **idempotent
|
|
7102
|
-
*
|
|
7101
|
+
* retries on **idempotent requests** — every GET, plus a write the caller
|
|
7102
|
+
* marked `idempotentWrite` (the server replays it as a no-op, so a
|
|
7103
|
+
* lost-response retry cannot double-apply; today only `inventory/apply`,
|
|
7104
|
+
* idempotent by transferId — #664). A non-idempotent write is single-attempt;
|
|
7103
7105
|
* - a `429` response retries on **any** method (a 429 is rejected before the
|
|
7104
7106
|
* handler runs — the write never executed), honoring the server `Retry-After`;
|
|
7105
|
-
* - a `503` response retries on **
|
|
7107
|
+
* - a `503` response retries on **idempotent requests only** (a non-idempotent
|
|
7108
|
+
* write may have started).
|
|
7106
7109
|
* Every other outcome (2xx, or a non-retryable status) is returned to the
|
|
7107
7110
|
* caller, which maps a non-2xx to a typed {@link WalletApiError}.
|
|
7108
7111
|
*/
|
|
7109
|
-
async rawFetchWithRetry(method, path, body, jwt) {
|
|
7110
|
-
const idempotent = method === "GET";
|
|
7112
|
+
async rawFetchWithRetry(method, path, body, jwt, idempotentWrite = false) {
|
|
7113
|
+
const idempotent = method === "GET" || idempotentWrite;
|
|
7111
7114
|
for (let attempt = 1; ; attempt += 1) {
|
|
7112
7115
|
let res;
|
|
7113
7116
|
try {
|
|
@@ -7130,8 +7133,8 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
7130
7133
|
}
|
|
7131
7134
|
/**
|
|
7132
7135
|
* Delay before retrying a non-2xx response, or `null` to not retry. `429`
|
|
7133
|
-
* retries on any method (rejected before execution); `503` on idempotent
|
|
7134
|
-
* Honors a capped `Retry-After` when present, else
|
|
7136
|
+
* retries on any method (rejected before execution); `503` on idempotent
|
|
7137
|
+
* requests only. Honors a capped `Retry-After` when present, else backoff.
|
|
7135
7138
|
*/
|
|
7136
7139
|
retryDelayForStatus(res, idempotent, attempt) {
|
|
7137
7140
|
const retryable = res.status === 429 || res.status === 503 && idempotent;
|
|
@@ -7155,16 +7158,18 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
7155
7158
|
* Authenticated JSON request. A 401 triggers one silent re-auth
|
|
7156
7159
|
* (refresh → challenge fallback) and one retry; {@link rawFetchWithRetry}
|
|
7157
7160
|
* additionally rides out transient failures — a dropped connection on an
|
|
7158
|
-
* idempotent GET, or a
|
|
7159
|
-
*
|
|
7161
|
+
* idempotent request (any GET, or a write flagged `opts.idempotent`), or a
|
|
7162
|
+
* `429`/`503` with `Retry-After` — so a single blip or a brief rate-limit
|
|
7163
|
+
* window doesn't fail the call.
|
|
7160
7164
|
*/
|
|
7161
|
-
async requestJson(method, path, body) {
|
|
7165
|
+
async requestJson(method, path, body, opts) {
|
|
7166
|
+
const idempotent = opts?.idempotent ?? false;
|
|
7162
7167
|
if (!this.jwt) await this.signIn();
|
|
7163
|
-
let res = await this.rawFetchWithRetry(method, path, body, this.jwt);
|
|
7168
|
+
let res = await this.rawFetchWithRetry(method, path, body, this.jwt, idempotent);
|
|
7164
7169
|
if (res.status === 401) {
|
|
7165
7170
|
this.jwt = null;
|
|
7166
7171
|
await this.signIn();
|
|
7167
|
-
res = await this.rawFetchWithRetry(method, path, body, this.jwt);
|
|
7172
|
+
res = await this.rawFetchWithRetry(method, path, body, this.jwt, idempotent);
|
|
7168
7173
|
}
|
|
7169
7174
|
if (res.status === 204) return null;
|
|
7170
7175
|
if (!res.ok) throw await this.toError(res, `${method} ${path}`);
|
|
@@ -7196,12 +7201,20 @@ var WalletApiClient = class _WalletApiClient {
|
|
|
7196
7201
|
*/
|
|
7197
7202
|
async applyInventoryDelta(req) {
|
|
7198
7203
|
const cursor = parseApplyResult(
|
|
7199
|
-
await this.requestJson(
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7204
|
+
await this.requestJson(
|
|
7205
|
+
"POST",
|
|
7206
|
+
"/v1/inventory/apply",
|
|
7207
|
+
{
|
|
7208
|
+
transferId: req.transferId,
|
|
7209
|
+
spent: req.spent,
|
|
7210
|
+
added: req.added,
|
|
7211
|
+
...req.externalDelivery !== void 0 ? { externalDelivery: req.externalDelivery } : {}
|
|
7212
|
+
},
|
|
7213
|
+
// Idempotent by transferId — the server replays a re-applied transferId
|
|
7214
|
+
// to the same cursor (beginApplied), so a lost-response retry on a flaky
|
|
7215
|
+
// link is safe and won't double-apply (#664).
|
|
7216
|
+
{ idempotent: true }
|
|
7217
|
+
)
|
|
7205
7218
|
);
|
|
7206
7219
|
await this.setLocalIntentStatus(req.transferId, "completed");
|
|
7207
7220
|
return cursor;
|