@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/{chunk-IRPS637F.js → chunk-IVD6BP5Z.js} +2 -2
- package/dist/{chunk-XF7NM6HF.js → chunk-PYJ3CMA2.js} +3 -3
- package/dist/{chunk-XF7NM6HF.js.map → chunk-PYJ3CMA2.js.map} +1 -1
- package/dist/{chunk-43BGZCNU.js → chunk-RAP37ILS.js} +13 -3
- package/dist/chunk-RAP37ILS.js.map +1 -0
- package/dist/index.cjs +13 -3
- 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 +13 -3
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.js +2 -2
- package/dist/next/client.cjs +13 -3
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +2 -2
- package/dist/next/index.cjs +13 -3
- 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 +13 -3
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-43BGZCNU.js.map +0 -1
- /package/dist/{chunk-IRPS637F.js.map → chunk-IVD6BP5Z.js.map} +0 -0
package/dist/next/client.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
__configure,
|
|
8
8
|
getRuntime
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-PYJ3CMA2.js";
|
|
10
|
+
import "../chunk-RAP37ILS.js";
|
|
11
11
|
import {
|
|
12
12
|
environmentRefFromPublishableApiKey
|
|
13
13
|
} from "../chunk-CFDU23TB.js";
|
package/dist/next/index.cjs
CHANGED
|
@@ -180,6 +180,7 @@ function asPowChallenge(details) {
|
|
|
180
180
|
return { id, prefix, difficulty };
|
|
181
181
|
}
|
|
182
182
|
var encoder = new TextEncoder();
|
|
183
|
+
var now = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
183
184
|
function leadingZeroBits(hash) {
|
|
184
185
|
let bits = 0;
|
|
185
186
|
for (const byte of hash) {
|
|
@@ -195,15 +196,24 @@ var MAX_POW_DIFFICULTY = 24;
|
|
|
195
196
|
function powBudget(difficulty) {
|
|
196
197
|
return 8 * 2 ** difficulty;
|
|
197
198
|
}
|
|
199
|
+
var POW_DEADLINE_MS = 12e4;
|
|
198
200
|
async function solvePowChallenge(challenge, maxIterations = powBudget(challenge.difficulty), signal) {
|
|
199
201
|
if (challenge.difficulty > MAX_POW_DIFFICULTY) {
|
|
200
202
|
throw new Error(
|
|
201
203
|
`proof-of-work: refusing difficulty ${challenge.difficulty}; this client attempts at most ${MAX_POW_DIFFICULTY}, which is the highest a Palbase stack issues`
|
|
202
204
|
);
|
|
203
205
|
}
|
|
206
|
+
const deadline = now() + POW_DEADLINE_MS;
|
|
204
207
|
for (let nonce = 0; nonce < maxIterations; nonce++) {
|
|
205
|
-
if ((nonce & 1023) === 0
|
|
206
|
-
|
|
208
|
+
if ((nonce & 1023) === 0) {
|
|
209
|
+
if (signal?.aborted) {
|
|
210
|
+
throw new DOMException("proof-of-work solve aborted", "AbortError");
|
|
211
|
+
}
|
|
212
|
+
if (now() > deadline) {
|
|
213
|
+
throw new Error(
|
|
214
|
+
`proof-of-work: gave up after ${POW_DEADLINE_MS / 1e3}s at difficulty ${challenge.difficulty} (${nonce} attempts)`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
207
217
|
}
|
|
208
218
|
const digest = await crypto.subtle.digest("SHA-256", encoder.encode(challenge.prefix + nonce));
|
|
209
219
|
if (leadingZeroBits(new Uint8Array(digest)) >= challenge.difficulty) {
|
|
@@ -9376,7 +9386,7 @@ function defaultSessionStorage(key) {
|
|
|
9376
9386
|
}
|
|
9377
9387
|
|
|
9378
9388
|
// src/version.ts
|
|
9379
|
-
var VERSION = "7.3.
|
|
9389
|
+
var VERSION = "7.3.4";
|
|
9380
9390
|
|
|
9381
9391
|
// src/runtime.ts
|
|
9382
9392
|
function buildRuntime(config) {
|