diff --git a/docs/src/03-services.md b/docs/src/03-services.md index c665052ee..0ec728b38 100644 --- a/docs/src/03-services.md +++ b/docs/src/03-services.md @@ -172,14 +172,7 @@ const socket = io(BACKEND_URL, { ### Socket event contract (Tauri) -In Tauri mode, the Rust socket forwards server events to the frontend via the `server:event` Tauri event. The frontend listens and can emit back via `emitViaRustSocket` (see `utils/tauriSocket.ts`). - -| Direction | Event name | Payload | Description | -|------------|----------------------------|----------------------------------|-------------| -| Backend → | `request:encryption_key` | (any) | Backend requests the client’s encryption key. | -| Frontend → | `encryption_key` | `{ encryptionKey: string \| null }` | Frontend sends `encryptionKeyByUser` for the current user from authSlice. | - -Constants: `REQUEST_ENCRYPTION_KEY`, `ENCRYPTION_KEY_EVENT` (exported from `utils/tauriSocket.ts`). +In Tauri mode, the Rust socket forwards server events to the frontend via the `server:event` Tauri event. The frontend listens and can emit back via `emitViaRustSocket` (see `utils/tauriSocket.ts`). Encryption key is handled via the API, not the socket. ## MTProto Service (`services/mtprotoService.ts`) diff --git a/src/pages/Mnemonic.tsx b/src/pages/Mnemonic.tsx index 25cd9bcfa..43592f5eb 100644 --- a/src/pages/Mnemonic.tsx +++ b/src/pages/Mnemonic.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; +import { useCallback, useEffect, useMemo, useRef, useState, type KeyboardEvent } from 'react'; import { useNavigate } from 'react-router-dom'; import LottieAnimation from '../components/LottieAnimation'; @@ -96,7 +96,7 @@ const Mnemonic = () => { ); const handleImportKeyDown = useCallback( - (index: number, e: React.KeyboardEvent) => { + (index: number, e: KeyboardEvent) => { if (e.key === 'Backspace' && !importWords[index] && index > 0) { inputRefs.current[index - 1]?.focus(); } diff --git a/src/utils/tauriSocket.ts b/src/utils/tauriSocket.ts index 95ded80e4..e603742a5 100644 --- a/src/utils/tauriSocket.ts +++ b/src/utils/tauriSocket.ts @@ -12,10 +12,6 @@ * Legacy bridge (for backwards compatibility during migration): * - socket:should_connect / socket:should_disconnect * - report_socket_connected / disconnected / error - * - * Socket event contract (backend <-> frontend): - * - Backend emits: REQUEST_ENCRYPTION_KEY — frontend should reply with encryption key. - * - Frontend emits: ENCRYPTION_KEY_EVENT — payload { encryptionKey: string | null } from authSlice. */ import { isTauri as coreIsTauri, invoke } from '@tauri-apps/api/core'; import { listen, UnlistenFn } from '@tauri-apps/api/event'; @@ -25,12 +21,6 @@ import { store } from '../store'; import { setSocketIdForUser, setStatusForUser } from '../store/socketSlice'; import { BACKEND_URL } from './config'; -/** Event name the backend emits to request the client’s encryption key. */ -export const REQUEST_ENCRYPTION_KEY = 'request:encryption_key'; - -/** Event name the frontend emits with encryptionKeyByUser (authSlice) for the current user. */ -export const ENCRYPTION_KEY_EVENT = 'encryption_key'; - // Check if we're running in Tauri export const isTauri = (): boolean => { return coreIsTauri(); @@ -171,14 +161,6 @@ export async function setupTauriSocketListeners(): Promise { unlistenServerEvent = await listen<{ event: string; data: unknown }>('server:event', event => { const { event: eventName, data } = event.payload; console.log('[TauriSocket] Server event:', eventName, data); - - if (eventName === REQUEST_ENCRYPTION_KEY) { - const state = store.getState(); - const userId = - state.user.user?._id ?? getSocketUserId(); - const encryptionKey = state.auth.encryptionKeyByUser[userId] ?? null; - void emitViaRustSocket(ENCRYPTION_KEY_EVENT, { encryptionKey }); - } }); // Legacy: Listen for connect requests from Rust (backwards compat)