@palbase/web 7.3.1 → 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/{chunk-53TN7KYR.js → chunk-43BGZCNU.js} +16 -4
- package/dist/chunk-43BGZCNU.js.map +1 -0
- package/dist/{chunk-CBN3PWNL.js → chunk-IRPS637F.js} +2 -2
- package/dist/{chunk-RRHJV6YD.js → chunk-XF7NM6HF.js} +3 -3
- package/dist/{chunk-RRHJV6YD.js.map → chunk-XF7NM6HF.js.map} +1 -1
- package/dist/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/internal.cjs +16 -4
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.js +2 -2
- package/dist/next/client.cjs +16 -4
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +2 -2
- package/dist/next/index.cjs +16 -4
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +3 -3
- package/dist/next/proxy.js +2 -2
- package/dist/react/index.cjs +14 -2
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-53TN7KYR.js.map +0 -1
- /package/dist/{chunk-CBN3PWNL.js.map → chunk-IRPS637F.js.map} +0 -0
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
localStorageSessionStorage,
|
|
12
12
|
memorySessionStorage,
|
|
13
13
|
pb
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-XF7NM6HF.js";
|
|
15
15
|
import {
|
|
16
16
|
BackendError,
|
|
17
17
|
isBackendError
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-43BGZCNU.js";
|
|
19
19
|
import "./chunk-CFDU23TB.js";
|
|
20
20
|
import "./chunk-PZ5AY32C.js";
|
|
21
21
|
export {
|
package/dist/internal.cjs
CHANGED
|
@@ -79,8 +79,20 @@ function leadingZeroBits(hash) {
|
|
|
79
79
|
}
|
|
80
80
|
return bits;
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
var MAX_POW_DIFFICULTY = 24;
|
|
83
|
+
function powBudget(difficulty) {
|
|
84
|
+
return 8 * 2 ** difficulty;
|
|
85
|
+
}
|
|
86
|
+
async function solvePowChallenge(challenge, maxIterations = powBudget(challenge.difficulty), signal) {
|
|
87
|
+
if (challenge.difficulty > MAX_POW_DIFFICULTY) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`proof-of-work: refusing difficulty ${challenge.difficulty}; this client attempts at most ${MAX_POW_DIFFICULTY}, which is the highest a Palbase stack issues`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
83
92
|
for (let nonce = 0; nonce < maxIterations; nonce++) {
|
|
93
|
+
if ((nonce & 1023) === 0 && signal?.aborted) {
|
|
94
|
+
throw new DOMException("proof-of-work solve aborted", "AbortError");
|
|
95
|
+
}
|
|
84
96
|
const digest = await crypto.subtle.digest("SHA-256", encoder.encode(challenge.prefix + nonce));
|
|
85
97
|
if (leadingZeroBits(new Uint8Array(digest)) >= challenge.difficulty) {
|
|
86
98
|
return {
|
|
@@ -250,7 +262,7 @@ var HttpClient = class _HttpClient {
|
|
|
250
262
|
if (attempt < MAX_RETRIES - 1) {
|
|
251
263
|
const backoff = INITIAL_BACKOFF_MS * 2 ** attempt;
|
|
252
264
|
await this.delay(backoff);
|
|
253
|
-
return this.executeWithRetry(method, path, options, attempt + 1
|
|
265
|
+
return this.executeWithRetry(method, path, options, attempt + 1);
|
|
254
266
|
}
|
|
255
267
|
throw new PalbaseError(
|
|
256
268
|
"network_error",
|
|
@@ -286,7 +298,7 @@ var HttpClient = class _HttpClient {
|
|
|
286
298
|
path,
|
|
287
299
|
options,
|
|
288
300
|
attempt,
|
|
289
|
-
await solvePowChallenge(challenge)
|
|
301
|
+
await solvePowChallenge(challenge, void 0, options?.signal)
|
|
290
302
|
);
|
|
291
303
|
}
|
|
292
304
|
}
|
|
@@ -9355,7 +9367,7 @@ function defaultSessionStorage(key) {
|
|
|
9355
9367
|
}
|
|
9356
9368
|
|
|
9357
9369
|
// src/version.ts
|
|
9358
|
-
var VERSION = "7.3.
|
|
9370
|
+
var VERSION = "7.3.3";
|
|
9359
9371
|
|
|
9360
9372
|
// src/runtime.ts
|
|
9361
9373
|
function buildRuntime(config) {
|