reguard 0.8.0 → 0.8.1
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/chunks/{chunk-YDDBWUPV.js → chunk-U54IP6G4.js} +13 -3
- package/dist/cjs/fetch.cjs +13 -3
- package/dist/cjs/next.cjs +21 -4
- package/dist/fetch.js +1 -1
- package/dist/next.js +9 -2
- package/package.json +1 -1
|
@@ -394,14 +394,24 @@ function reguardFetch(options = {}) {
|
|
|
394
394
|
...a.internal ? { internal: true } : {}
|
|
395
395
|
});
|
|
396
396
|
if (queue.length > 5e3) queue.splice(0, queue.length - 5e3);
|
|
397
|
-
|
|
397
|
+
const waitUntil = ctx?.waitUntil ? (p2) => ctx.waitUntil.call(ctx, p2) : void 0;
|
|
398
|
+
ensureTimer();
|
|
399
|
+
flushSoon(waitUntil, !!decision);
|
|
398
400
|
} catch (e) {
|
|
399
401
|
onError(e);
|
|
400
402
|
}
|
|
401
403
|
})();
|
|
402
404
|
};
|
|
403
|
-
|
|
404
|
-
|
|
405
|
+
let timer;
|
|
406
|
+
const ensureTimer = () => {
|
|
407
|
+
if (timer !== void 0 || platform === "workers" || typeof setInterval !== "function") return;
|
|
408
|
+
try {
|
|
409
|
+
timer = setInterval(() => flushSoon(void 0, true), flushIntervalMs);
|
|
410
|
+
timer.unref?.();
|
|
411
|
+
} catch {
|
|
412
|
+
timer = null;
|
|
413
|
+
}
|
|
414
|
+
};
|
|
405
415
|
return {
|
|
406
416
|
site,
|
|
407
417
|
handle: (request) => handle(request),
|
package/dist/cjs/fetch.cjs
CHANGED
|
@@ -1408,14 +1408,24 @@ function reguardFetch(options = {}) {
|
|
|
1408
1408
|
...a.internal ? { internal: true } : {}
|
|
1409
1409
|
});
|
|
1410
1410
|
if (queue.length > 5e3) queue.splice(0, queue.length - 5e3);
|
|
1411
|
-
|
|
1411
|
+
const waitUntil = ctx?.waitUntil ? (p2) => ctx.waitUntil.call(ctx, p2) : void 0;
|
|
1412
|
+
ensureTimer();
|
|
1413
|
+
flushSoon(waitUntil, !!decision);
|
|
1412
1414
|
} catch (e) {
|
|
1413
1415
|
onError(e);
|
|
1414
1416
|
}
|
|
1415
1417
|
})();
|
|
1416
1418
|
};
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
+
let timer;
|
|
1420
|
+
const ensureTimer = () => {
|
|
1421
|
+
if (timer !== void 0 || platform === "workers" || typeof setInterval !== "function") return;
|
|
1422
|
+
try {
|
|
1423
|
+
timer = setInterval(() => flushSoon(void 0, true), flushIntervalMs);
|
|
1424
|
+
timer.unref?.();
|
|
1425
|
+
} catch {
|
|
1426
|
+
timer = null;
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1419
1429
|
return {
|
|
1420
1430
|
site,
|
|
1421
1431
|
handle: (request) => handle(request),
|
package/dist/cjs/next.cjs
CHANGED
|
@@ -1410,14 +1410,24 @@ function reguardFetch(options = {}) {
|
|
|
1410
1410
|
...a.internal ? { internal: true } : {}
|
|
1411
1411
|
});
|
|
1412
1412
|
if (queue.length > 5e3) queue.splice(0, queue.length - 5e3);
|
|
1413
|
-
|
|
1413
|
+
const waitUntil = ctx?.waitUntil ? (p2) => ctx.waitUntil.call(ctx, p2) : void 0;
|
|
1414
|
+
ensureTimer();
|
|
1415
|
+
flushSoon(waitUntil, !!decision);
|
|
1414
1416
|
} catch (e) {
|
|
1415
1417
|
onError(e);
|
|
1416
1418
|
}
|
|
1417
1419
|
})();
|
|
1418
1420
|
};
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
+
let timer;
|
|
1422
|
+
const ensureTimer = () => {
|
|
1423
|
+
if (timer !== void 0 || platform === "workers" || typeof setInterval !== "function") return;
|
|
1424
|
+
try {
|
|
1425
|
+
timer = setInterval(() => flushSoon(void 0, true), flushIntervalMs);
|
|
1426
|
+
timer.unref?.();
|
|
1427
|
+
} catch {
|
|
1428
|
+
timer = null;
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1421
1431
|
return {
|
|
1422
1432
|
site,
|
|
1423
1433
|
handle: (request) => handle(request),
|
|
@@ -1477,9 +1487,16 @@ async function reguardVerdict(request, options = {}) {
|
|
|
1477
1487
|
const prev = parseSiteKey((options.previousKey ?? envValue("REGUARD_KEY_PREVIOUS"))?.trim());
|
|
1478
1488
|
return prev?.site === parsed.site ? readVerdictFrom(prev.secret, prev.site, cookie) : null;
|
|
1479
1489
|
}
|
|
1490
|
+
function publicSite() {
|
|
1491
|
+
try {
|
|
1492
|
+
return process.env.NEXT_PUBLIC_REGUARD_SITE || void 0;
|
|
1493
|
+
} catch {
|
|
1494
|
+
return void 0;
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1480
1497
|
var warned = false;
|
|
1481
1498
|
function reguardScriptProps(options = {}) {
|
|
1482
|
-
const site = parseSiteKey((options.key ?? envValue("REGUARD_KEY"))?.trim())?.site ??
|
|
1499
|
+
const site = parseSiteKey((options.key ?? envValue("REGUARD_KEY"))?.trim())?.site ?? publicSite();
|
|
1483
1500
|
if (!site && !warned) {
|
|
1484
1501
|
warned = true;
|
|
1485
1502
|
console.warn("[reguard] REGUARD_KEY is not set (and withReguard didn't provide NEXT_PUBLIC_REGUARD_SITE): the script will load but not start.");
|
package/dist/fetch.js
CHANGED
package/dist/next.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
reguardFetch
|
|
3
|
-
} from "./chunks/chunk-
|
|
3
|
+
} from "./chunks/chunk-U54IP6G4.js";
|
|
4
4
|
import {
|
|
5
5
|
ReguardConfigError,
|
|
6
6
|
checkBlock,
|
|
@@ -46,9 +46,16 @@ async function reguardVerdict(request, options = {}) {
|
|
|
46
46
|
const prev = parseSiteKey((options.previousKey ?? envValue("REGUARD_KEY_PREVIOUS"))?.trim());
|
|
47
47
|
return prev?.site === parsed.site ? readVerdictFrom(prev.secret, prev.site, cookie) : null;
|
|
48
48
|
}
|
|
49
|
+
function publicSite() {
|
|
50
|
+
try {
|
|
51
|
+
return process.env.NEXT_PUBLIC_REGUARD_SITE || void 0;
|
|
52
|
+
} catch {
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
49
56
|
var warned = false;
|
|
50
57
|
function reguardScriptProps(options = {}) {
|
|
51
|
-
const site = parseSiteKey((options.key ?? envValue("REGUARD_KEY"))?.trim())?.site ??
|
|
58
|
+
const site = parseSiteKey((options.key ?? envValue("REGUARD_KEY"))?.trim())?.site ?? publicSite();
|
|
52
59
|
if (!site && !warned) {
|
|
53
60
|
warned = true;
|
|
54
61
|
console.warn("[reguard] REGUARD_KEY is not set (and withReguard didn't provide NEXT_PUBLIC_REGUARD_SITE): the script will load but not start.");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reguard",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Reguard for your server: catch AI agents and tools reverse engineering your web app. app.use(reguard()) serves /_s/*, adds the script tag, verifies verdicts, blocks (or dry-runs) flagged visitors and sends request summaries (hashes and shapes only). Next.js helpers in reguard/next, fetch runtimes in reguard/fetch, Fastify in reguard/fastify, test helpers in reguard/testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"reguard",
|