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 +}