@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/CHANGELOG.md +6 -0
- package/dist/index.cjs +9 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to `@qed-proof/sdk` are documented here. Format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project uses
|
|
5
5
|
[Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.1.5] - Unreleased
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- `waitForVerdict` backs off exponentially (x2 per poll, capped at 30 s), matching the Python SDK. It still never sleeps past `timeoutMs` and still honours `Retry-After`.
|
|
11
|
+
- A generated `client_claim_id` uses `crypto.getRandomValues` when `crypto.randomUUID` is unavailable, before falling back to `Math.random`.
|
|
12
|
+
|
|
7
13
|
## [0.1.4] - Unreleased
|
|
8
14
|
|
|
9
15
|
### Fixed
|
package/dist/index.cjs
CHANGED
|
@@ -1836,8 +1836,9 @@ var QedProof = class {
|
|
|
1836
1836
|
const timeoutMs = options.timeoutMs ?? 12e4;
|
|
1837
1837
|
const pollIntervalMs = options.pollIntervalMs ?? 2e3;
|
|
1838
1838
|
const deadline = Date.now() + timeoutMs;
|
|
1839
|
+
let interval = pollIntervalMs;
|
|
1839
1840
|
for (; ; ) {
|
|
1840
|
-
let wait =
|
|
1841
|
+
let wait = interval;
|
|
1841
1842
|
try {
|
|
1842
1843
|
const status = await this.getClaim(claimId);
|
|
1843
1844
|
if (status.state === "decided") return status;
|
|
@@ -1852,6 +1853,7 @@ var QedProof = class {
|
|
|
1852
1853
|
throw new QedProofError(408, `timed out after ${timeoutMs}ms waiting for claim ${claimId} to decide`);
|
|
1853
1854
|
}
|
|
1854
1855
|
await sleep(Math.min(wait, Math.max(0, deadline - Date.now())));
|
|
1856
|
+
interval = Math.min(interval * 2, 3e4);
|
|
1855
1857
|
}
|
|
1856
1858
|
}
|
|
1857
1859
|
/**
|
|
@@ -1906,6 +1908,12 @@ function sleep(ms) {
|
|
|
1906
1908
|
function cryptoRandomId() {
|
|
1907
1909
|
const g = globalThis;
|
|
1908
1910
|
if (g.crypto?.randomUUID) return g.crypto.randomUUID();
|
|
1911
|
+
if (g.crypto?.getRandomValues) {
|
|
1912
|
+
const bytes = new Uint8Array(16);
|
|
1913
|
+
g.crypto.getRandomValues(bytes);
|
|
1914
|
+
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
1915
|
+
return `claim-${Date.now()}-${hex}`;
|
|
1916
|
+
}
|
|
1909
1917
|
return `claim-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
1910
1918
|
}
|
|
1911
1919
|
|