mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-14 12:38:45 +00:00
fix(algorithms/fast): fix fast challenge on insecure contexts
Closes #1192 Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
@@ -18,7 +18,12 @@ export default function process(
|
|||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
console.debug("fast algo");
|
console.debug("fast algo");
|
||||||
|
|
||||||
let workerMethod = window.crypto !== undefined ? "webcrypto" : "purejs";
|
// Choose worker based on secure context.
|
||||||
|
// Use the WebCrypto worker if the page is a secure context; otherwise fall back to pure‑JS.
|
||||||
|
let workerMethod: "webcrypto" | "purejs" = "purejs";
|
||||||
|
if (window.isSecureContext) {
|
||||||
|
workerMethod = "webcrypto";
|
||||||
|
}
|
||||||
|
|
||||||
if (navigator.userAgent.includes("Firefox") || navigator.userAgent.includes("Goanna")) {
|
if (navigator.userAgent.includes("Firefox") || navigator.userAgent.includes("Goanna")) {
|
||||||
console.log("Firefox detected, using pure-JS fallback");
|
console.log("Firefox detected, using pure-JS fallback");
|
||||||
@@ -82,4 +87,4 @@ export default function process(
|
|||||||
workers.push(worker);
|
workers.push(worker);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user