From b345e0069b56b90f09f52f4f1a1ae90201b4ffa2 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Fri, 17 Oct 2025 22:51:33 +0000 Subject: [PATCH] fix(algorithms/fast): fix fast challenge on insecure contexts Closes #1192 Signed-off-by: Xe Iaso --- web/js/algorithms/fast.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/js/algorithms/fast.ts b/web/js/algorithms/fast.ts index 178cef84..6330da56 100644 --- a/web/js/algorithms/fast.ts +++ b/web/js/algorithms/fast.ts @@ -18,7 +18,12 @@ export default function process( ): Promise { 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")) { console.log("Firefox detected, using pure-JS fallback"); @@ -82,4 +87,4 @@ export default function process( workers.push(worker); } }); -} \ No newline at end of file +}