Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: run prerequisite checks on app start

Abdullah Atta31367066f7a8
diff --git a/apps/web/src/bootstrap.tsx b/apps/web/src/bootstrap.tsx
index 691f75325..5cc7ddfec 100644
--- a/apps/web/src/bootstrap.tsx
+++ b/apps/web/src/bootstrap.tsx
@@ -20,7 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { getCurrentHash, getCurrentPath, makeURL } from "./navigation";
import Config from "./utils/config";
import type { AuthProps } from "./views/auth";
-import { initializeFeatureChecks } from "./utils/feature-check";
+import {
+ initializeFeatureChecks,
+ isFeatureSupported
+} from "./utils/feature-check";
import { initializeLogger } from "./utils/logger";
type Route<TProps = null> = {
@@ -142,9 +145,24 @@ function isSessionExpired(path: Routes): RouteWithPath<AuthProps> | null {
return null;
}
+function checkPrerequisites() {
+ if (!window.isSecureContext)
+ throw new Error("Please run Notesnook in a secure (https) context.");
+ if (!navigator.locks)
+ throw new Error("Your browser does not support the Web Locks API.");
+ if (!crypto.subtle)
+ throw new Error("Your browser does not support the SubtleCrypto API.");
+ if (!window.indexedDB && !isFeatureSupported("opfs"))
+ throw new Error("Your browser does not support IndexedDB or OPFS.");
+ if (!window.WebAssembly)
+ throw new Error("Your browser does not support WebAssembly.");
+}
+
export async function init() {
await initializeFeatureChecks();
+ checkPrerequisites();
+
const { path, route } = getRoute();
const [{ default: Component }] = await Promise.all([