@palbase/web 7.3.3 → 7.3.4

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.d.cts CHANGED
@@ -206,6 +206,6 @@ interface MlsGlue {
206
206
  */
207
207
  declare function initMls(): Promise<MlsGlue>;
208
208
 
209
- declare const VERSION = "7.3.3";
209
+ declare const VERSION = "7.3.4";
210
210
 
211
211
  export { VERSION, initMls };
package/dist/index.d.ts CHANGED
@@ -206,6 +206,6 @@ interface MlsGlue {
206
206
  */
207
207
  declare function initMls(): Promise<MlsGlue>;
208
208
 
209
- declare const VERSION = "7.3.3";
209
+ declare const VERSION = "7.3.4";
210
210
 
211
211
  export { VERSION, initMls };
package/dist/index.js CHANGED
@@ -11,11 +11,11 @@ import {
11
11
  localStorageSessionStorage,
12
12
  memorySessionStorage,
13
13
  pb
14
- } from "./chunk-XF7NM6HF.js";
14
+ } from "./chunk-PYJ3CMA2.js";
15
15
  import {
16
16
  BackendError,
17
17
  isBackendError
18
- } from "./chunk-43BGZCNU.js";
18
+ } from "./chunk-RAP37ILS.js";
19
19
  import "./chunk-CFDU23TB.js";
20
20
  import "./chunk-PZ5AY32C.js";
21
21
  export {
package/dist/internal.cjs CHANGED
@@ -68,6 +68,7 @@ function asPowChallenge(details) {
68
68
  return { id, prefix, difficulty };
69
69
  }
70
70
  var encoder = new TextEncoder();
71
+ var now = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
71
72
  function leadingZeroBits(hash) {
72
73
  let bits = 0;
73
74
  for (const byte of hash) {
@@ -83,15 +84,24 @@ var MAX_POW_DIFFICULTY = 24;
83
84
  function powBudget(difficulty) {
84
85
  return 8 * 2 ** difficulty;
85
86
  }
87
+ var POW_DEADLINE_MS = 12e4;
86
88
  async function solvePowChallenge(challenge, maxIterations = powBudget(challenge.difficulty), signal) {
87
89
  if (challenge.difficulty > MAX_POW_DIFFICULTY) {
88
90
  throw new Error(
89
91
  `proof-of-work: refusing difficulty ${challenge.difficulty}; this client attempts at most ${MAX_POW_DIFFICULTY}, which is the highest a Palbase stack issues`
90
92
  );
91
93
  }
94
+ const deadline = now() + POW_DEADLINE_MS;
92
95
  for (let nonce = 0; nonce < maxIterations; nonce++) {
93
- if ((nonce & 1023) === 0 && signal?.aborted) {
94
- throw new DOMException("proof-of-work solve aborted", "AbortError");
96
+ if ((nonce & 1023) === 0) {
97
+ if (signal?.aborted) {
98
+ throw new DOMException("proof-of-work solve aborted", "AbortError");
99
+ }
100
+ if (now() > deadline) {
101
+ throw new Error(
102
+ `proof-of-work: gave up after ${POW_DEADLINE_MS / 1e3}s at difficulty ${challenge.difficulty} (${nonce} attempts)`
103
+ );
104
+ }
95
105
  }
96
106
  const digest = await crypto.subtle.digest("SHA-256", encoder.encode(challenge.prefix + nonce));
97
107
  if (leadingZeroBits(new Uint8Array(digest)) >= challenge.difficulty) {
@@ -9367,7 +9377,7 @@ function defaultSessionStorage(key) {
9367
9377
  }
9368
9378
 
9369
9379
  // src/version.ts
9370
- var VERSION = "7.3.3";
9380
+ var VERSION = "7.3.4";
9371
9381
 
9372
9382
  // src/runtime.ts
9373
9383
  function buildRuntime(config) {