@palbase/web 7.3.2 → 7.3.3

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.cjs CHANGED
@@ -90,13 +90,16 @@ var MAX_POW_DIFFICULTY = 24;
90
90
  function powBudget(difficulty) {
91
91
  return 8 * 2 ** difficulty;
92
92
  }
93
- async function solvePowChallenge(challenge, maxIterations = powBudget(challenge.difficulty)) {
93
+ async function solvePowChallenge(challenge, maxIterations = powBudget(challenge.difficulty), signal) {
94
94
  if (challenge.difficulty > MAX_POW_DIFFICULTY) {
95
95
  throw new Error(
96
96
  `proof-of-work: refusing difficulty ${challenge.difficulty}; this client attempts at most ${MAX_POW_DIFFICULTY}, which is the highest a Palbase stack issues`
97
97
  );
98
98
  }
99
99
  for (let nonce = 0; nonce < maxIterations; nonce++) {
100
+ if ((nonce & 1023) === 0 && signal?.aborted) {
101
+ throw new DOMException("proof-of-work solve aborted", "AbortError");
102
+ }
100
103
  const digest = await crypto.subtle.digest("SHA-256", encoder.encode(challenge.prefix + nonce));
101
104
  if (leadingZeroBits(new Uint8Array(digest)) >= challenge.difficulty) {
102
105
  return {
@@ -7965,7 +7968,7 @@ function localStorageSessionStorage(key = DEFAULT_KEY) {
7965
7968
  }
7966
7969
 
7967
7970
  // src/version.ts
7968
- var VERSION = "7.3.2";
7971
+ var VERSION = "7.3.3";
7969
7972
 
7970
7973
  // src/internal.ts
7971
7974
  function getRuntime() {