mirror of
https://github.com/ramvignesh-b/pi-ku.git
synced 2026-05-04 00:56:34 +00:00
fix: reduce pbkdf iteration in tests to prevent timeout nad keep them fast
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
import { lazy, Suspense, useEffect } from "react";
|
||||
import { lazy, Suspense, useEffect, useRef } from "react";
|
||||
import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom";
|
||||
import { ProtectedRoute, PublicRoute } from "./components/RouteGuards";
|
||||
import SplashScreen from "./components/SplashScreen";
|
||||
import { ROUTES } from "./config/routes";
|
||||
import { useAuth } from "./hooks/useAuth";
|
||||
|
||||
let authInitialized = false;
|
||||
|
||||
const Activate = lazy(() => import("./pages/Activate"));
|
||||
const Drawer = lazy(() => import("./pages/Drawer"));
|
||||
const Editor = lazy(() => import("./pages/Editor"));
|
||||
@@ -18,11 +16,12 @@ const VerifyEmail = lazy(() => import("./pages/VerifyEmail"));
|
||||
|
||||
export default function App() {
|
||||
const { initialize, isInitializing } = useAuth();
|
||||
const authInitialized = useRef<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (authInitialized) return;
|
||||
authInitialized = true;
|
||||
initialize();
|
||||
if (authInitialized.current) return;
|
||||
authInitialized.current = true;
|
||||
initialize().then();
|
||||
}, [initialize]);
|
||||
|
||||
if (isInitializing) {
|
||||
|
||||
@@ -26,7 +26,8 @@ interface SealedEnvelope {
|
||||
// TODO: try refactoring into a pure function for consistency
|
||||
export class CryptoUtils {
|
||||
private dek!: CryptoKey;
|
||||
private static readonly PBKDF2_ITERATIONS = 600_000;
|
||||
private static readonly PBKDF2_ITERATIONS =
|
||||
Number(import.meta.env.VITE_PBKDF2_ITERATIONS) || 600_000;
|
||||
// NOTE: https://www.w3.org/TR/webcrypto/#aes-gcm
|
||||
private static readonly AES_ALGO = { name: "AES-GCM", length: 256 };
|
||||
private static readonly IV_BYTE_LENGTH = 12;
|
||||
|
||||
@@ -9,6 +9,8 @@ export default defineConfig({
|
||||
env: {
|
||||
VITE_API_URL: "http://piku-server",
|
||||
TZ: "Asia/Kolkata",
|
||||
// using the actual 600_000 iterations causes timeout in tests
|
||||
VITE_PBKDF2_ITERATIONS: "1",
|
||||
},
|
||||
include: ["**/*.test.ts", "**/*.test.tsx"],
|
||||
environment: "jsdom",
|
||||
|
||||
Reference in New Issue
Block a user