feat: standalone: minor improvements
This commit is contained in:
+1
-1
@@ -331,7 +331,7 @@ class Cap extends EventEmitter {
|
||||
}),
|
||||
);
|
||||
|
||||
const isValid = hashes.every((pair) => pair?.[0].startsWith(pair[1]));
|
||||
const isValid = hashes.every((pair) => pair?.[0]?.startsWith?.(pair[1]));
|
||||
|
||||
if (!isValid) return { success: false, message: "Invalid solution" };
|
||||
|
||||
|
||||
@@ -8,7 +8,12 @@ const welcomeScreen = document.getElementById("welcomeScreen");
|
||||
const keyDetail = document.getElementById("keyDetail");
|
||||
|
||||
const escapeHtml = (s) => {
|
||||
return s.replaceAll("<", "<").replaceAll(">", ">");
|
||||
return String(s)
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
};
|
||||
|
||||
const api = async (method, path, body) => {
|
||||
@@ -508,7 +513,7 @@ async function saveConfig() {
|
||||
|
||||
if (!name || difficulty < 2 || challengeCount < 1 || saltSize < 7) {
|
||||
showModal(
|
||||
"Validation Error",
|
||||
"Validation error",
|
||||
`<div class="modal-body"><p>Please check your input values. Difficulty must be ≥2, challenge count ≥1, and salt size ≥7.</p></div>`,
|
||||
);
|
||||
btn.disabled = false;
|
||||
|
||||
@@ -4,7 +4,8 @@ export const ratelimitGenerator = (req, server) => {
|
||||
const ip = req.headers.get(header) || req.headers.get(header.toLowerCase());
|
||||
|
||||
if (ip) {
|
||||
return ip.split(",")[0].trim();
|
||||
const parts = ip.split(",").filter((e) => !!e.trim());
|
||||
return (parts[parts.length - 1] || parts[0]).trim();
|
||||
}
|
||||
|
||||
console.error(
|
||||
|
||||
@@ -295,6 +295,7 @@ export const server = new Elysia({
|
||||
instrumentation,
|
||||
blockAutomatedBrowsers,
|
||||
} = body;
|
||||
|
||||
const config = {
|
||||
...keyDefaults,
|
||||
...existingConfig,
|
||||
@@ -313,10 +314,10 @@ export const server = new Elysia({
|
||||
},
|
||||
{
|
||||
body: t.Object({
|
||||
name: t.Optional(t.String()),
|
||||
difficulty: t.Optional(t.Number()),
|
||||
challengeCount: t.Optional(t.Number()),
|
||||
saltSize: t.Optional(t.Number()),
|
||||
name: t.Optional(t.String({ maxLength: 600 })),
|
||||
difficulty: t.Optional(t.Number({ minimum: 1, maximum: 8 })),
|
||||
challengeCount: t.Optional(t.Number({ minimum: 1, maximum: 500 })),
|
||||
saltSize: t.Optional(t.Number({ minimum: 7, maximum: 1_001 })),
|
||||
instrumentation: t.Optional(t.Boolean()),
|
||||
blockAutomatedBrowsers: t.Optional(t.Boolean()),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user