@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/internal.js CHANGED
@@ -6,8 +6,8 @@ import {
6
6
  createBoundClient,
7
7
  getRuntime,
8
8
  onConfigured
9
- } from "./chunk-TQAQR3OP.js";
10
- import "./chunk-HKZVA3I3.js";
9
+ } from "./chunk-XF7NM6HF.js";
10
+ import "./chunk-43BGZCNU.js";
11
11
  import "./chunk-CFDU23TB.js";
12
12
  import "./chunk-PZ5AY32C.js";
13
13
  export {
@@ -85,13 +85,16 @@ var MAX_POW_DIFFICULTY = 24;
85
85
  function powBudget(difficulty) {
86
86
  return 8 * 2 ** difficulty;
87
87
  }
88
- async function solvePowChallenge(challenge, maxIterations = powBudget(challenge.difficulty)) {
88
+ async function solvePowChallenge(challenge, maxIterations = powBudget(challenge.difficulty), signal) {
89
89
  if (challenge.difficulty > MAX_POW_DIFFICULTY) {
90
90
  throw new Error(
91
91
  `proof-of-work: refusing difficulty ${challenge.difficulty}; this client attempts at most ${MAX_POW_DIFFICULTY}, which is the highest a Palbase stack issues`
92
92
  );
93
93
  }
94
94
  for (let nonce = 0; nonce < maxIterations; nonce++) {
95
+ if ((nonce & 1023) === 0 && signal?.aborted) {
96
+ throw new DOMException("proof-of-work solve aborted", "AbortError");
97
+ }
95
98
  const digest = await crypto.subtle.digest("SHA-256", encoder.encode(challenge.prefix + nonce));
96
99
  if (leadingZeroBits(new Uint8Array(digest)) >= challenge.difficulty) {
97
100
  return {
@@ -261,7 +264,7 @@ var HttpClient = class _HttpClient {
261
264
  if (attempt < MAX_RETRIES - 1) {
262
265
  const backoff = INITIAL_BACKOFF_MS * 2 ** attempt;
263
266
  await this.delay(backoff);
264
- return this.executeWithRetry(method, path, options, attempt + 1, earned);
267
+ return this.executeWithRetry(method, path, options, attempt + 1);
265
268
  }
266
269
  throw new PalbaseError(
267
270
  "network_error",
@@ -297,7 +300,7 @@ var HttpClient = class _HttpClient {
297
300
  path,
298
301
  options,
299
302
  attempt,
300
- await solvePowChallenge(challenge)
303
+ await solvePowChallenge(challenge, void 0, options?.signal)
301
304
  );
302
305
  }
303
306
  }
@@ -9164,7 +9167,7 @@ function defaultSessionStorage(key) {
9164
9167
  }
9165
9168
 
9166
9169
  // src/version.ts
9167
- var VERSION = "7.3.2";
9170
+ var VERSION = "7.3.3";
9168
9171
 
9169
9172
  // src/runtime.ts
9170
9173
  function buildRuntime(config) {