diff --git a/frontend/src/api/authApi.ts b/frontend/src/api/authApi.ts index 86fab4e..d95d6bd 100644 --- a/frontend/src/api/authApi.ts +++ b/frontend/src/api/authApi.ts @@ -1,7 +1,7 @@ import type { Headers, UploadPublicKeyRequest, BackupBlob } from "../pages/chat/core/types"; -import { generateX25519KeyPair } from "../pages/chat/utils/crypto/asymmetric"; -import { encodeBlob, encryptBackupWithPassword, decryptBackupWithPassword, decodeBlob } from "../pages/chat/utils/crypto/backup"; -import { b64, ub64 } from "../pages/chat/utils/utils"; +import { generateX25519KeyPair } from "../utils/crypto/asymmetric"; +import { encodeBlob, encryptBackupWithPassword, decryptBackupWithPassword, decodeBlob } from "../utils/crypto/backup"; +import { b64, ub64 } from "../utils/utils"; import { API_BASE_URL } from "../pages/chat/core/config"; /** diff --git a/frontend/src/api/dmApi.ts b/frontend/src/api/dmApi.ts index 7c195af..e1d906e 100644 --- a/frontend/src/api/dmApi.ts +++ b/frontend/src/api/dmApi.ts @@ -1,12 +1,12 @@ import { API_BASE_URL } from "../pages/chat/core/config"; import { getAuthHeaders } from "./authApi"; -import { ecdhSharedSecret, deriveWrappingKey } from "../pages/chat/utils/crypto/asymmetric"; -import { importAesGcmKey, aesGcmEncrypt, aesGcmDecrypt } from "../pages/chat/utils/crypto/symmetric"; -import { randomBytes } from "../pages/chat/utils/crypto/kdf"; +import { ecdhSharedSecret, deriveWrappingKey } from "../utils/crypto/asymmetric"; +import { importAesGcmKey, aesGcmEncrypt, aesGcmDecrypt } from "../utils/crypto/symmetric"; +import { randomBytes } from "../utils/crypto/kdf"; import { getCurrentKeys } from "./authApi"; import { request } from "../pages/chat/core/websocket"; import type { SendDMRequest, DmEnvelope, User, DMEditRequest, DmEncryptedJSON, BaseDmEnvelope } from "../pages/chat/core/types"; -import { b64, ub64 } from "../pages/chat/utils/utils"; +import { b64, ub64 } from "../utils/utils"; export async function decryptDm(envelope: DmEnvelope, senderPublicKeyB64: string): Promise { const keys = getCurrentKeys(); diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index c7f0e07..9269967 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -8,7 +8,7 @@ import './css/style.scss'; import "mdui/mdui.css"; -import "./pages/chat/utils/material"; +import "./utils/material"; import "./pages/chat/core/init"; import "./pages/chat/electron/electron"; import { createRoot } from 'react-dom/client'; diff --git a/frontend/src/pages/auth/LoginPage.tsx b/frontend/src/pages/auth/LoginPage.tsx index 4bbb165..0a36ecd 100644 --- a/frontend/src/pages/auth/LoginPage.tsx +++ b/frontend/src/pages/auth/LoginPage.tsx @@ -8,7 +8,7 @@ import { useRef } from "react"; import type { TextField } from "mdui/components/text-field"; import { useAppState } from "../chat/ui/state"; import { MaterialTextField } from "../chat/ui/components/core/TextField"; -import { initialize, isSupported, startElectronReceiver, subscribe } from "../chat/utils/push-notifications"; +import { initialize, isSupported, startElectronReceiver, subscribe } from "../chat/push-notifications"; import { isElectron } from "../chat/electron/electron"; import { useNavigate } from "react-router-dom"; import "./auth.scss"; diff --git a/frontend/src/pages/chat/core/websocket.ts b/frontend/src/pages/chat/core/websocket.ts index c881cf3..b08f771 100644 --- a/frontend/src/pages/chat/core/websocket.ts +++ b/frontend/src/pages/chat/core/websocket.ts @@ -7,7 +7,7 @@ import { API_WS_BASE_URL } from "./config"; import type { WebSocketMessage } from "./types"; -import { delay } from "../utils/utils"; +import { delay } from "../../../utils/utils"; /** * Creates a new WebSocket connection to the chat server diff --git a/frontend/src/pages/chat/utils/push-notifications.ts b/frontend/src/pages/chat/push-notifications.ts similarity index 98% rename from frontend/src/pages/chat/utils/push-notifications.ts rename to frontend/src/pages/chat/push-notifications.ts index 869d7e5..c5f7689 100644 --- a/frontend/src/pages/chat/utils/push-notifications.ts +++ b/frontend/src/pages/chat/push-notifications.ts @@ -1,7 +1,7 @@ -import { API_BASE_URL } from "../core/config"; -import { isElectron } from "../electron/electron"; -import { websocket } from "../core/websocket"; -import type { NewMessageWebSocketMessage, WebSocketMessage } from "../core/types"; +import { API_BASE_URL } from "./core/config"; +import { isElectron } from "./electron/electron"; +import { websocket } from "./core/websocket"; +import type { NewMessageWebSocketMessage, WebSocketMessage } from "./core/types"; import serviceWorker from "../../../service-worker?worker&url"; export interface PushSubscriptionData { diff --git a/frontend/src/pages/chat/ui/components/chat/ChatMessages.tsx b/frontend/src/pages/chat/ui/components/chat/ChatMessages.tsx index 43923a9..60df171 100644 --- a/frontend/src/pages/chat/ui/components/chat/ChatMessages.tsx +++ b/frontend/src/pages/chat/ui/components/chat/ChatMessages.tsx @@ -6,7 +6,7 @@ import { UserProfileDialog } from "./UserProfileDialog"; import { MessageContextMenu, type ContextMenuState } from "./MessageContextMenu"; import { fetchUserProfile } from "../../../../../api/profileApi"; import { useEffect, useState, type ReactNode } from "react"; -import { delay } from "../../../utils/utils"; +import { delay } from "../../../../../utils/utils"; import { MaterialDialog } from "../core/Dialog"; import { request } from "../../../core/websocket"; import type { AddReactionRequest, AddDmReactionRequest } from "../../../core/types"; diff --git a/frontend/src/pages/chat/ui/components/chat/Message.tsx b/frontend/src/pages/chat/ui/components/chat/Message.tsx index 1894390..05fe6d0 100644 --- a/frontend/src/pages/chat/ui/components/chat/Message.tsx +++ b/frontend/src/pages/chat/ui/components/chat/Message.tsx @@ -1,4 +1,4 @@ -import { formatTime, id } from "../../../utils/utils"; +import { formatTime, id } from "../../../../../utils/utils"; import type { Attachment, Message as MessageType } from "../../../core/types"; import defaultAvatar from "../../../../../images/default-avatar.png"; import Quote from "../core/Quote"; @@ -6,11 +6,11 @@ import { parse } from "marked"; import DOMPurify from "dompurify"; import { useEffect, useState, useRef } from "react"; import { getCurrentKeys } from "../../../../../api/authApi"; -import { ecdhSharedSecret, deriveWrappingKey } from "../../../utils/crypto/asymmetric"; -import { importAesGcmKey, aesGcmDecrypt } from "../../../utils/crypto/symmetric"; +import { ecdhSharedSecret, deriveWrappingKey } from "../../../../../utils/crypto/asymmetric"; +import { importAesGcmKey, aesGcmDecrypt } from "../../../../../utils/crypto/symmetric"; import { getAuthHeaders } from "../../../../../api/authApi"; import { useAppState } from "../../state"; -import { ub64 } from "../../../utils/utils"; +import { ub64 } from "../../../../../utils/utils"; import { useImmer } from "use-immer"; import { createPortal } from "react-dom"; import { MessageReactions } from "./MessageReactions"; diff --git a/frontend/src/pages/chat/ui/components/chat/UserProfileDialog.tsx b/frontend/src/pages/chat/ui/components/chat/UserProfileDialog.tsx index ee77e28..1861f7c 100644 --- a/frontend/src/pages/chat/ui/components/chat/UserProfileDialog.tsx +++ b/frontend/src/pages/chat/ui/components/chat/UserProfileDialog.tsx @@ -1,7 +1,7 @@ import type { DialogProps } from "../../../core/types"; import type { UserProfile } from "../../../core/types"; import { MaterialDialog } from "../core/Dialog"; -import { formatTime } from "../../../utils/utils"; +import { formatTime } from "../../../../../utils/utils"; import defaultAvatar from "../../../../../images/default-avatar.png"; interface UserProfileDialogProps extends DialogProps { diff --git a/frontend/src/pages/chat/ui/components/core/Dialog.tsx b/frontend/src/pages/chat/ui/components/core/Dialog.tsx index d339d7f..43d1923 100644 --- a/frontend/src/pages/chat/ui/components/core/Dialog.tsx +++ b/frontend/src/pages/chat/ui/components/core/Dialog.tsx @@ -1,7 +1,7 @@ import type { Dialog as MduiDialog } from "mdui/components/dialog"; import { useEffect, type Ref } from "react" import { createPortal } from "react-dom"; -import { id } from "../../../utils/utils"; +import { id } from "../../../../../utils/utils"; import useCombinedRefs from "../../hooks/useCombinedRefs"; export interface BaseDialogProps { diff --git a/frontend/src/pages/chat/ui/components/settings/SettingsDialog.tsx b/frontend/src/pages/chat/ui/components/settings/SettingsDialog.tsx index 9a1ead0..7cf21eb 100644 --- a/frontend/src/pages/chat/ui/components/settings/SettingsDialog.tsx +++ b/frontend/src/pages/chat/ui/components/settings/SettingsDialog.tsx @@ -2,7 +2,7 @@ import { useState, useEffect } from "react"; import { PRODUCT_NAME, API_BASE_URL } from "../../../core/config"; import type { DialogProps } from "../../../core/types"; import { MaterialDialog } from "../core/Dialog"; -import { initialize, isSupported, startElectronReceiver, stopElectronReceiver, subscribe, unsubscribe } from "../../../utils/push-notifications"; +import { initialize, isSupported, startElectronReceiver, stopElectronReceiver, subscribe, unsubscribe } from "../../../push-notifications"; import { isElectron } from "../../../electron/electron"; import { useAppState } from "../../state"; import type { Switch } from "mdui/components/switch"; diff --git a/frontend/src/pages/chat/ui/hooks/useProfile.ts b/frontend/src/pages/chat/ui/hooks/useProfile.ts index 9cad0a2..de890e6 100644 --- a/frontend/src/pages/chat/ui/hooks/useProfile.ts +++ b/frontend/src/pages/chat/ui/hooks/useProfile.ts @@ -1,7 +1,7 @@ import { useState, useCallback, useEffect } from "react"; import { useAppState } from "../state"; import { loadProfile, updateProfile, uploadProfilePicture, type ProfileData } from "../../../../api/profileApi"; -import { showSuccess, showError } from "../../utils/notification"; +import { showSuccess, showError } from "../../../../utils/notification"; export default function useProfile() { const { user } = useAppState(); diff --git a/frontend/src/pages/chat/ui/screen/LoginScreen.tsx b/frontend/src/pages/chat/ui/screen/LoginScreen.tsx index c6e5656..85adff9 100644 --- a/frontend/src/pages/chat/ui/screen/LoginScreen.tsx +++ b/frontend/src/pages/chat/ui/screen/LoginScreen.tsx @@ -9,7 +9,7 @@ import type { TextField } from "mdui/components/text-field"; import { useAppState } from "../state"; import { useNavigate } from "react-router-dom"; import { MaterialTextField } from "../components/core/TextField"; -import { initialize, isSupported, startElectronReceiver, subscribe } from "../../utils/push-notifications"; +import { initialize, isSupported, startElectronReceiver, subscribe } from "../../push-notifications"; import { isElectron } from "../../electron/electron"; export default function LoginScreen() { diff --git a/frontend/src/pages/chat/ui/state.ts b/frontend/src/pages/chat/ui/state.ts index c9b9e79..2b011af 100644 --- a/frontend/src/pages/chat/ui/state.ts +++ b/frontend/src/pages/chat/ui/state.ts @@ -7,7 +7,7 @@ import { DMPanel, type DMPanelData } from "./panels/DMPanel"; import { getAuthHeaders } from "../../../api/authApi"; import { restoreKeys } from "../../../api/authApi"; import { API_BASE_URL } from "../core/config"; -import { initialize, subscribe, startElectronReceiver, isSupported } from "../utils/push-notifications"; +import { initialize, subscribe, startElectronReceiver, isSupported } from "../push-notifications"; import { isElectron } from "../electron/electron"; export type ChatTabs = "chats" | "channels" | "contacts" | "dms" diff --git a/frontend/src/pages/chat/utils/crypto/asymmetric.ts b/frontend/src/utils/crypto/asymmetric.ts similarity index 100% rename from frontend/src/pages/chat/utils/crypto/asymmetric.ts rename to frontend/src/utils/crypto/asymmetric.ts diff --git a/frontend/src/pages/chat/utils/crypto/backup.ts b/frontend/src/utils/crypto/backup.ts similarity index 100% rename from frontend/src/pages/chat/utils/crypto/backup.ts rename to frontend/src/utils/crypto/backup.ts diff --git a/frontend/src/pages/chat/utils/crypto/kdf.ts b/frontend/src/utils/crypto/kdf.ts similarity index 100% rename from frontend/src/pages/chat/utils/crypto/kdf.ts rename to frontend/src/utils/crypto/kdf.ts diff --git a/frontend/src/pages/chat/utils/crypto/symmetric.ts b/frontend/src/utils/crypto/symmetric.ts similarity index 100% rename from frontend/src/pages/chat/utils/crypto/symmetric.ts rename to frontend/src/utils/crypto/symmetric.ts diff --git a/frontend/src/pages/chat/utils/material.ts b/frontend/src/utils/material.ts similarity index 100% rename from frontend/src/pages/chat/utils/material.ts rename to frontend/src/utils/material.ts diff --git a/frontend/src/pages/chat/utils/notification.ts b/frontend/src/utils/notification.ts similarity index 100% rename from frontend/src/pages/chat/utils/notification.ts rename to frontend/src/utils/notification.ts diff --git a/frontend/src/pages/chat/utils/utils.ts b/frontend/src/utils/utils.ts similarity index 100% rename from frontend/src/pages/chat/utils/utils.ts rename to frontend/src/utils/utils.ts