@unicitylabs/sphere-sdk 0.14.4 → 0.14.5

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.
@@ -9466,35 +9466,18 @@ function resolveProofTimeoutMs(configured) {
9466
9466
  }
9467
9467
  return configured;
9468
9468
  }
9469
- function lateDeliveringSignal(signal) {
9470
- return new Proxy(signal, {
9471
- get(target, prop) {
9472
- if (prop === "addEventListener") {
9473
- return (type, listener, options) => {
9474
- if (type === "abort" && target.aborted) {
9475
- queueMicrotask(() => {
9476
- listener.call(target, new Event("abort"));
9477
- });
9478
- return;
9479
- }
9480
- target.addEventListener(type, listener, options);
9481
- };
9482
- }
9483
- const value = Reflect.get(target, prop, target);
9484
- return typeof value === "function" ? value.bind(target) : value;
9485
- }
9486
- });
9469
+ var TRANSIENT_HTTP_STATUSES = /* @__PURE__ */ new Set([408, 425, 429, 500, 502, 503, 504]);
9470
+ function isTransientGatewayError(err) {
9471
+ return err instanceof import_JsonRpcNetworkError.JsonRpcNetworkError && TRANSIENT_HTTP_STATUSES.has(err.status);
9487
9472
  }
9488
- function rejectOnAbort(signal) {
9489
- return new Promise((_resolve, reject) => {
9490
- if (signal.aborted) {
9491
- reject(signal.reason);
9492
- return;
9493
- }
9473
+ function pause(ms, signal) {
9474
+ return new Promise((resolve) => {
9475
+ const timer = setTimeout(resolve, ms);
9494
9476
  signal.addEventListener(
9495
9477
  "abort",
9496
9478
  () => {
9497
- reject(signal.reason);
9479
+ clearTimeout(timer);
9480
+ resolve();
9498
9481
  },
9499
9482
  { once: true }
9500
9483
  );
@@ -9517,17 +9500,23 @@ async function awaitProofBounded(deps, transaction, external) {
9517
9500
  )
9518
9501
  );
9519
9502
  }, deps.timeoutMs);
9520
- const wait = (0, import_InclusionProofUtils.waitInclusionProof)(
9521
- deps.client,
9522
- deps.trustBase,
9523
- deps.predicateVerifier,
9524
- transaction,
9525
- lateDeliveringSignal(controller.signal),
9526
- deps.intervalMs
9527
- );
9528
- wait.catch(() => void 0);
9529
9503
  try {
9530
- return await Promise.race([wait, rejectOnAbort(controller.signal)]);
9504
+ for (; ; ) {
9505
+ try {
9506
+ return await (0, import_InclusionProofUtils.waitInclusionProof)(
9507
+ deps.client,
9508
+ deps.trustBase,
9509
+ deps.predicateVerifier,
9510
+ transaction,
9511
+ controller.signal,
9512
+ deps.intervalMs
9513
+ );
9514
+ } catch (err) {
9515
+ if (controller.signal.aborted) throw err;
9516
+ if (!isTransientGatewayError(err)) throw err;
9517
+ await pause(deps.intervalMs, controller.signal);
9518
+ }
9519
+ }
9531
9520
  } finally {
9532
9521
  clearTimeout(timer);
9533
9522
  external?.removeEventListener("abort", relayAbort);