@qed-proof/sdk 0.1.4 → 0.1.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.
package/dist/index.js CHANGED
@@ -1789,8 +1789,9 @@ var QedProof = class {
1789
1789
  const timeoutMs = options.timeoutMs ?? 12e4;
1790
1790
  const pollIntervalMs = options.pollIntervalMs ?? 2e3;
1791
1791
  const deadline = Date.now() + timeoutMs;
1792
+ let interval = pollIntervalMs;
1792
1793
  for (; ; ) {
1793
- let wait = pollIntervalMs;
1794
+ let wait = interval;
1794
1795
  try {
1795
1796
  const status = await this.getClaim(claimId);
1796
1797
  if (status.state === "decided") return status;
@@ -1805,6 +1806,7 @@ var QedProof = class {
1805
1806
  throw new QedProofError(408, `timed out after ${timeoutMs}ms waiting for claim ${claimId} to decide`);
1806
1807
  }
1807
1808
  await sleep(Math.min(wait, Math.max(0, deadline - Date.now())));
1809
+ interval = Math.min(interval * 2, 3e4);
1808
1810
  }
1809
1811
  }
1810
1812
  /**
@@ -1859,6 +1861,12 @@ function sleep(ms) {
1859
1861
  function cryptoRandomId() {
1860
1862
  const g = globalThis;
1861
1863
  if (g.crypto?.randomUUID) return g.crypto.randomUUID();
1864
+ if (g.crypto?.getRandomValues) {
1865
+ const bytes = new Uint8Array(16);
1866
+ g.crypto.getRandomValues(bytes);
1867
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
1868
+ return `claim-${Date.now()}-${hex}`;
1869
+ }
1862
1870
  return `claim-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1863
1871
  }
1864
1872