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