@palbase/web 7.3.2 → 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/{chunk-OZLTH7YB.js → chunk-IVD6BP5Z.js} +2 -2
- package/dist/{chunk-TQAQR3OP.js → chunk-PYJ3CMA2.js} +3 -3
- package/dist/{chunk-TQAQR3OP.js.map → chunk-PYJ3CMA2.js.map} +1 -1
- package/dist/{chunk-HKZVA3I3.js → chunk-RAP37ILS.js} +17 -4
- package/dist/chunk-RAP37ILS.js.map +1 -0
- package/dist/index.cjs +15 -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 +17 -4
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.js +2 -2
- package/dist/next/client.cjs +17 -4
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +2 -2
- package/dist/next/index.cjs +17 -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 +15 -2
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-HKZVA3I3.js.map +0 -1
- /package/dist/{chunk-OZLTH7YB.js.map → chunk-IVD6BP5Z.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-PYJ3CMA2.js";
|
|
15
15
|
import {
|
|
16
16
|
BackendError,
|
|
17
17
|
isBackendError
|
|
18
|
-
} from "./chunk-
|
|
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,13 +84,25 @@ var MAX_POW_DIFFICULTY = 24;
|
|
|
83
84
|
function powBudget(difficulty) {
|
|
84
85
|
return 8 * 2 ** difficulty;
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
+
var POW_DEADLINE_MS = 12e4;
|
|
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++) {
|
|
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
|
+
}
|
|
105
|
+
}
|
|
93
106
|
const digest = await crypto.subtle.digest("SHA-256", encoder.encode(challenge.prefix + nonce));
|
|
94
107
|
if (leadingZeroBits(new Uint8Array(digest)) >= challenge.difficulty) {
|
|
95
108
|
return {
|
|
@@ -259,7 +272,7 @@ var HttpClient = class _HttpClient {
|
|
|
259
272
|
if (attempt < MAX_RETRIES - 1) {
|
|
260
273
|
const backoff = INITIAL_BACKOFF_MS * 2 ** attempt;
|
|
261
274
|
await this.delay(backoff);
|
|
262
|
-
return this.executeWithRetry(method, path, options, attempt + 1
|
|
275
|
+
return this.executeWithRetry(method, path, options, attempt + 1);
|
|
263
276
|
}
|
|
264
277
|
throw new PalbaseError(
|
|
265
278
|
"network_error",
|
|
@@ -295,7 +308,7 @@ var HttpClient = class _HttpClient {
|
|
|
295
308
|
path,
|
|
296
309
|
options,
|
|
297
310
|
attempt,
|
|
298
|
-
await solvePowChallenge(challenge)
|
|
311
|
+
await solvePowChallenge(challenge, void 0, options?.signal)
|
|
299
312
|
);
|
|
300
313
|
}
|
|
301
314
|
}
|
|
@@ -9364,7 +9377,7 @@ function defaultSessionStorage(key) {
|
|
|
9364
9377
|
}
|
|
9365
9378
|
|
|
9366
9379
|
// src/version.ts
|
|
9367
|
-
var VERSION = "7.3.
|
|
9380
|
+
var VERSION = "7.3.4";
|
|
9368
9381
|
|
|
9369
9382
|
// src/runtime.ts
|
|
9370
9383
|
function buildRuntime(config) {
|