fix(algorithms/fast): fix fast challenge on insecure contexts

Closes #1192

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2025-10-17 22:51:33 +00:00
parent 00261d049e
commit b345e0069b

View File

@@ -18,7 +18,12 @@ export default function process(
): Promise<string> {
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 pureJS.
let workerMethod: "webcrypto" | "purejs" = "purejs";
if (window.isSecureContext) {
workerMethod = "webcrypto";
}
if (navigator.userAgent.includes("Firefox") || navigator.userAgent.includes("Goanna")) {
console.log("Firefox detected, using pure-JS fallback");
@@ -82,4 +87,4 @@ export default function process(
workers.push(worker);
}
});
}
}