30 03 25
Сделал адекватное отображение ключей / и при регистрации ключи спрашивают какие сохранять (что то работает что то сложно)
This commit is contained in:
parent
089146a137
commit
eb5593c7be
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SRC_DIR="/home/player/docker/shine-UI"
|
SRC_DIR="shine-UI"
|
||||||
REMOTE_HOST="root@194.87.0.247"
|
REMOTE_HOST="root@194.87.0.247"
|
||||||
REMOTE_DIR="/home/user/docker/caddyFile/sites/shine-UI"
|
REMOTE_DIR="/home/user/docker/caddyFile/sites/shine-UI"
|
||||||
BUILD_VERSION="$(date -u +%Y%m%d%H%M%S)"
|
BUILD_VERSION="$(date -u +%Y%m%d%H%M%S)"
|
||||||
|
|||||||
@ -4,9 +4,9 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
||||||
<title>Shine UI Demo</title>
|
<title>Shine UI Demo</title>
|
||||||
<link rel="stylesheet" href="./styles/main.css?v=20260327192619" />
|
<link rel="stylesheet" href="./styles/main.css?v=20260330001044" />
|
||||||
<link rel="stylesheet" href="./styles/layout.css?v=20260327192619" />
|
<link rel="stylesheet" href="./styles/layout.css?v=20260330001044" />
|
||||||
<link rel="stylesheet" href="./styles/components.css?v=20260327192619" />
|
<link rel="stylesheet" href="./styles/components.css?v=20260330001044" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="app-shell">
|
<div class="app-shell">
|
||||||
@ -15,6 +15,6 @@
|
|||||||
<div id="toolbar-slot" class="toolbar-slot"></div>
|
<div id="toolbar-slot" class="toolbar-slot"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="modal-root"></div>
|
<div id="modal-root"></div>
|
||||||
<script type="module" src="./js/app.js?v=20260327192619"></script>
|
<script type="module" src="./js/app.js?v=20260330001044"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -1,37 +1,46 @@
|
|||||||
import { navigate, getRoute, PRE_AUTH_PAGES } from './router.js?v=20260327192619';
|
import { navigate, getRoute, PRE_AUTH_PAGES } from './router.js?v=20260330001044';
|
||||||
import { renderToolbar } from './components/toolbar.js?v=20260327192619';
|
import { renderToolbar } from './components/toolbar.js?v=20260330001044';
|
||||||
import { renderPageLabel } from './components/page-label.js?v=20260327192619';
|
import { renderPageLabel } from './components/page-label.js?v=20260330001044';
|
||||||
import { authService, authorizeSession, refreshSessions, state, togglePageLabel } from './state.js?v=20260327192619';
|
import {
|
||||||
|
authService,
|
||||||
|
authorizeSession,
|
||||||
|
isSessionInvalidError,
|
||||||
|
refreshSessions,
|
||||||
|
setSessionResetHandler,
|
||||||
|
state,
|
||||||
|
terminateCurrentSession,
|
||||||
|
togglePageLabel,
|
||||||
|
} from './state.js?v=20260330001044';
|
||||||
|
|
||||||
import * as startView from './pages/start-view.js?v=20260327192619';
|
import * as startView from './pages/start-view.js?v=20260330001044';
|
||||||
import * as entrySettingsView from './pages/entry-settings-view.js?v=20260327192619';
|
import * as entrySettingsView from './pages/entry-settings-view.js?v=20260330001044';
|
||||||
import * as registerView from './pages/register-view.js?v=20260327192619';
|
import * as registerView from './pages/register-view.js?v=20260330001044';
|
||||||
import * as registrationPaymentView from './pages/registration-payment-view.js?v=20260327192619';
|
import * as registrationPaymentView from './pages/registration-payment-view.js?v=20260330001044';
|
||||||
import * as registrationKeysView from './pages/registration-keys-view.js?v=20260327192619';
|
import * as registrationKeysView from './pages/registration-keys-view.js?v=20260330001044';
|
||||||
import * as topupView from './pages/topup-view.js?v=20260327192619';
|
import * as topupView from './pages/topup-view.js?v=20260330001044';
|
||||||
import * as loginView from './pages/login-view.js?v=20260327192619';
|
import * as loginView from './pages/login-view.js?v=20260330001044';
|
||||||
import * as loginCameraView from './pages/login-camera-view.js?v=20260327192619';
|
import * as loginCameraView from './pages/login-camera-view.js?v=20260330001044';
|
||||||
import * as loginPasswordView from './pages/login-password-view.js?v=20260327192619';
|
import * as loginPasswordView from './pages/login-password-view.js?v=20260330001044';
|
||||||
import * as keyStorageView from './pages/key-storage-view.js?v=20260327192619';
|
import * as keyStorageView from './pages/key-storage-view.js?v=20260330001044';
|
||||||
|
|
||||||
import * as profileView from './pages/profile-view.js?v=20260327192619';
|
import * as profileView from './pages/profile-view.js?v=20260330001044';
|
||||||
import * as walletView from './pages/wallet-view.js?v=20260327192619';
|
import * as walletView from './pages/wallet-view.js?v=20260330001044';
|
||||||
import * as settingsView from './pages/settings-view.js?v=20260327192619';
|
import * as settingsView from './pages/settings-view.js?v=20260330001044';
|
||||||
import * as serverSettingsView from './pages/server-settings-view.js?v=20260327192619';
|
import * as serverSettingsView from './pages/server-settings-view.js?v=20260330001044';
|
||||||
import * as deviceView from './pages/device-view.js?v=20260327192619';
|
import * as deviceView from './pages/device-view.js?v=20260330001044';
|
||||||
import * as connectDeviceView from './pages/connect-device-view.js?v=20260327192619';
|
import * as connectDeviceView from './pages/connect-device-view.js?v=20260330001044';
|
||||||
import * as deviceQrView from './pages/device-qr-view.js?v=20260327192619';
|
import * as deviceQrView from './pages/device-qr-view.js?v=20260330001044';
|
||||||
import * as deviceCameraView from './pages/device-camera-view.js?v=20260327192619';
|
import * as deviceCameraView from './pages/device-camera-view.js?v=20260330001044';
|
||||||
import * as showKeysView from './pages/show-keys-view.js?v=20260327192619';
|
import * as showKeysView from './pages/show-keys-view.js?v=20260330001044';
|
||||||
import * as deviceSessionView from './pages/device-session-view.js?v=20260327192619';
|
import * as deviceSessionView from './pages/device-session-view.js?v=20260330001044';
|
||||||
import * as languageView from './pages/language-view.js?v=20260327192619';
|
import * as languageView from './pages/language-view.js?v=20260330001044';
|
||||||
import * as messagesList from './pages/messages-list.js?v=20260327192619';
|
import * as messagesList from './pages/messages-list.js?v=20260330001044';
|
||||||
import * as contactSearchView from './pages/contact-search-view.js?v=20260327192619';
|
import * as contactSearchView from './pages/contact-search-view.js?v=20260330001044';
|
||||||
import * as chatView from './pages/chat-view.js?v=20260327192619';
|
import * as chatView from './pages/chat-view.js?v=20260330001044';
|
||||||
import * as channelsList from './pages/channels-list.js?v=20260327192619';
|
import * as channelsList from './pages/channels-list.js?v=20260330001044';
|
||||||
import * as channelView from './pages/channel-view.js?v=20260327192619';
|
import * as channelView from './pages/channel-view.js?v=20260330001044';
|
||||||
import * as networkView from './pages/network-view.js?v=20260327192619';
|
import * as networkView from './pages/network-view.js?v=20260330001044';
|
||||||
import * as notificationsView from './pages/notifications-view.js?v=20260327192619';
|
import * as notificationsView from './pages/notifications-view.js?v=20260330001044';
|
||||||
|
|
||||||
const routes = {
|
const routes = {
|
||||||
'start-view': startView,
|
'start-view': startView,
|
||||||
@ -120,12 +129,19 @@ async function tryAutoLogin() {
|
|||||||
const resumed = await authService.resumeSession(state.session.login, state.session.sessionId);
|
const resumed = await authService.resumeSession(state.session.login, state.session.sessionId);
|
||||||
authorizeSession(resumed);
|
authorizeSession(resumed);
|
||||||
await refreshSessions();
|
await refreshSessions();
|
||||||
} catch {
|
} catch (error) {
|
||||||
// silent fallback to auth screens
|
if (isSessionInvalidError(error)) {
|
||||||
|
await terminateCurrentSession({
|
||||||
|
infoMessage: 'Сессия на этом устройстве уже завершена. Выполните вход заново.',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
|
setSessionResetHandler(() => {
|
||||||
|
navigate('start-view');
|
||||||
|
});
|
||||||
await tryAutoLogin();
|
await tryAutoLogin();
|
||||||
|
|
||||||
if (!window.location.hash) {
|
if (!window.location.hash) {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { resolveToolbarActive } from '../router.js?v=20260327192619';
|
import { resolveToolbarActive } from '../router.js?v=20260330001044';
|
||||||
|
|
||||||
const ITEMS = [
|
const ITEMS = [
|
||||||
{ pageId: 'messages-list', label: 'Личные сообщения', icon: '💬' },
|
{ pageId: 'messages-list', label: 'Личные сообщения', icon: '💬' },
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { channelPosts, channels } from '../mock-data.js?v=20260327192619';
|
import { channelPosts, channels } from '../mock-data.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'channel-view', title: 'Канал' };
|
export const pageMeta = { id: 'channel-view', title: 'Канал' };
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { channels } from '../mock-data.js?v=20260327192619';
|
import { channels } from '../mock-data.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'channels-list', title: 'Каналы' };
|
export const pageMeta = { id: 'channels-list', title: 'Каналы' };
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { directMessages } from '../mock-data.js?v=20260327192619';
|
import { directMessages } from '../mock-data.js?v=20260330001044';
|
||||||
import { addChatMessage, getChatMessages } from '../state.js?v=20260327192619';
|
import { addChatMessage, getChatMessages } from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'chat-view', title: 'Чат' };
|
export const pageMeta = { id: 'chat-view', title: 'Чат' };
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { state } from '../state.js?v=20260327192619';
|
import { state } from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'connect-device-view', title: 'Подключить устройство' };
|
export const pageMeta = { id: 'connect-device-view', title: 'Подключить устройство' };
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { contactDirectory, directMessages } from '../mock-data.js?v=20260327192619';
|
import { contactDirectory, directMessages } from '../mock-data.js?v=20260330001044';
|
||||||
import { ensureChat } from '../state.js?v=20260327192619';
|
import { ensureChat } from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'contact-search-view', title: 'Поиск контактов' };
|
export const pageMeta = { id: 'contact-search-view', title: 'Поиск контактов' };
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'device-camera-view', title: 'Подключить через камеру' };
|
export const pageMeta = { id: 'device-camera-view', title: 'Подключить через камеру' };
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { profile } from '../mock-data.js?v=20260327192619';
|
import { profile } from '../mock-data.js?v=20260330001044';
|
||||||
import { state } from '../state.js?v=20260327192619';
|
import { state } from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'device-qr-view', title: 'Показать QR-код' };
|
export const pageMeta = { id: 'device-qr-view', title: 'Показать QR-код' };
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,12 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { authService, refreshSessions, setAuthError, state } from '../state.js?v=20260327192619';
|
import {
|
||||||
|
authService,
|
||||||
|
isSessionInvalidError,
|
||||||
|
refreshSessions,
|
||||||
|
setAuthError,
|
||||||
|
state,
|
||||||
|
terminateCurrentSession,
|
||||||
|
} from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'device-session-view', title: 'Сеанс устройства' };
|
export const pageMeta = { id: 'device-session-view', title: 'Сеанс устройства' };
|
||||||
|
|
||||||
@ -51,11 +58,39 @@ export function render({ navigate, route }) {
|
|||||||
actionBtn.textContent = 'Завершить сеанс';
|
actionBtn.textContent = 'Завершить сеанс';
|
||||||
|
|
||||||
actionBtn.addEventListener('click', async () => {
|
actionBtn.addEventListener('click', async () => {
|
||||||
|
const isCurrentSession = session.sessionId === state.session.sessionId;
|
||||||
|
const confirmed = window.confirm(
|
||||||
|
isCurrentSession ? 'Хотите завершить текущую сессию?' : 'Хотите завершить этот сеанс?',
|
||||||
|
);
|
||||||
|
if (!confirmed) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await authService.closeSession(session.sessionId);
|
await authService.closeSession(session.sessionId);
|
||||||
|
} catch (error) {
|
||||||
|
if (!isSessionInvalidError(error)) {
|
||||||
|
setAuthError(error.message);
|
||||||
|
window.alert(error.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isCurrentSession) {
|
||||||
|
await terminateCurrentSession({
|
||||||
|
infoMessage: 'Текущая сессия завершена, данные на устройстве очищены.',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
await refreshSessions();
|
await refreshSessions();
|
||||||
navigate('device-view');
|
navigate('device-view');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (isSessionInvalidError(error)) {
|
||||||
|
await terminateCurrentSession({
|
||||||
|
infoMessage: 'Сессия на этом устройстве уже завершена. Выполните вход заново.',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
setAuthError(error.message);
|
setAuthError(error.message);
|
||||||
window.alert(error.message);
|
window.alert(error.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import {
|
import {
|
||||||
|
authService,
|
||||||
|
isSessionInvalidError,
|
||||||
refreshSessions,
|
refreshSessions,
|
||||||
setAuthError,
|
setAuthError,
|
||||||
setAuthInfo,
|
setAuthInfo,
|
||||||
state,
|
state,
|
||||||
terminateCurrentSession,
|
terminateCurrentSession,
|
||||||
} from '../state.js?v=20260327192619';
|
} from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'device-view', title: 'Устройства' };
|
export const pageMeta = { id: 'device-view', title: 'Устройства' };
|
||||||
|
|
||||||
@ -83,9 +85,23 @@ export function render({ navigate }) {
|
|||||||
endCurrentSessionBtn.className = 'text-btn';
|
endCurrentSessionBtn.className = 'text-btn';
|
||||||
endCurrentSessionBtn.type = 'button';
|
endCurrentSessionBtn.type = 'button';
|
||||||
endCurrentSessionBtn.textContent = 'Завершить текущую сессию';
|
endCurrentSessionBtn.textContent = 'Завершить текущую сессию';
|
||||||
endCurrentSessionBtn.addEventListener('click', () => {
|
endCurrentSessionBtn.addEventListener('click', async () => {
|
||||||
terminateCurrentSession();
|
const confirmed = window.confirm('Хотите завершить текущую сессию?');
|
||||||
navigate('start-view');
|
if (!confirmed) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await authService.closeSession(state.session.sessionId);
|
||||||
|
} catch (error) {
|
||||||
|
if (!isSessionInvalidError(error)) {
|
||||||
|
setAuthError(error.message);
|
||||||
|
window.alert(error.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await terminateCurrentSession({
|
||||||
|
infoMessage: 'Текущая сессия завершена, данные на устройстве очищены.',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
currentMenu.append(endCurrentSessionBtn);
|
currentMenu.append(endCurrentSessionBtn);
|
||||||
|
|
||||||
@ -113,6 +129,12 @@ export function render({ navigate }) {
|
|||||||
buildList();
|
buildList();
|
||||||
setAuthInfo('Список сессий обновлён.');
|
setAuthInfo('Список сессий обновлён.');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (isSessionInvalidError(error)) {
|
||||||
|
await terminateCurrentSession({
|
||||||
|
infoMessage: 'Сессия на этом устройстве уже завершена. Выполните вход заново.',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
setAuthError(error.message);
|
setAuthError(error.message);
|
||||||
window.alert(error.message);
|
window.alert(error.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { checkServerAvailability, saveEntrySettings, state } from '../state.js?v=20260327192619';
|
import { checkServerAvailability, saveEntrySettings, state } from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'entry-settings-view', title: 'Настройки входа', showAppChrome: false };
|
export const pageMeta = { id: 'entry-settings-view', title: 'Настройки входа', showAppChrome: false };
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { authorizeSession, state } from '../state.js?v=20260327192619';
|
import { authorizeSession, state } from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'key-storage-view', title: 'Какие ключи сохранить', showAppChrome: false };
|
export const pageMeta = { id: 'key-storage-view', title: 'Какие ключи сохранить', showAppChrome: false };
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { state } from '../state.js?v=20260327192619';
|
import { state } from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'language-view', title: 'Язык' };
|
export const pageMeta = { id: 'language-view', title: 'Язык' };
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'login-camera-view', title: 'Войти по камере', showAppChrome: false };
|
export const pageMeta = { id: 'login-camera-view', title: 'Войти по камере', showAppChrome: false };
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import {
|
import {
|
||||||
authService,
|
authService,
|
||||||
authorizeSession,
|
|
||||||
clearAuthMessages,
|
clearAuthMessages,
|
||||||
refreshSessions,
|
|
||||||
setAuthBusy,
|
setAuthBusy,
|
||||||
setAuthError,
|
setAuthError,
|
||||||
setAuthInfo,
|
|
||||||
state,
|
state,
|
||||||
} from '../state.js?v=20260327192619';
|
} from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'login-password-view', title: 'Войти по логину', showAppChrome: false };
|
export const pageMeta = { id: 'login-password-view', title: 'Войти по логину', showAppChrome: false };
|
||||||
|
|
||||||
@ -75,11 +72,14 @@ export function render({ navigate }) {
|
|||||||
try {
|
try {
|
||||||
await authService.reconnect(state.entrySettings.shineServer);
|
await authService.reconnect(state.entrySettings.shineServer);
|
||||||
const result = await authService.createSessionForExistingUser(state.loginDraft.login, state.loginDraft.password);
|
const result = await authService.createSessionForExistingUser(state.loginDraft.login, state.loginDraft.password);
|
||||||
await authService.persistSessionMaterial(state.loginDraft.login, result.sessionMaterial);
|
state.registrationDraft.flowType = 'login';
|
||||||
authorizeSession(result);
|
state.registrationDraft.login = result.login;
|
||||||
await refreshSessions();
|
state.registrationDraft.password = state.loginDraft.password;
|
||||||
setAuthInfo('Успешный вход выполнен.');
|
state.registrationDraft.sessionId = result.sessionId;
|
||||||
navigate('profile-view');
|
state.registrationDraft.storagePwd = result.storagePwd;
|
||||||
|
state.registrationDraft.pendingKeyBundle = result.keyBundle;
|
||||||
|
state.registrationDraft.pendingSessionMaterial = result.sessionMaterial;
|
||||||
|
navigate('registration-keys-view');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setAuthError(error.message);
|
setAuthError(error.message);
|
||||||
window.alert(error.message);
|
window.alert(error.message);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'login-view', title: 'Войти', showAppChrome: false };
|
export const pageMeta = { id: 'login-view', title: 'Войти', showAppChrome: false };
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { directMessages } from '../mock-data.js?v=20260327192619';
|
import { directMessages } from '../mock-data.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'messages-list', title: 'Личные сообщения' };
|
export const pageMeta = { id: 'messages-list', title: 'Личные сообщения' };
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { networkGraph } from '../mock-data.js?v=20260327192619';
|
import { networkGraph } from '../mock-data.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'network-view', title: 'Связи' };
|
export const pageMeta = { id: 'network-view', title: 'Связи' };
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { notifications } from '../mock-data.js?v=20260327192619';
|
import { notifications } from '../mock-data.js?v=20260330001044';
|
||||||
import { state } from '../state.js?v=20260327192619';
|
import { state } from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'notifications-view', title: 'Уведомления' };
|
export const pageMeta = { id: 'notifications-view', title: 'Уведомления' };
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { profile } from '../mock-data.js?v=20260327192619';
|
import { profile } from '../mock-data.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'profile-view', title: 'Профиль' };
|
export const pageMeta = { id: 'profile-view', title: 'Профиль' };
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { authService, state } from '../state.js?v=20260327192619';
|
import { authService, clearAuthMessages, state } from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'register-view', title: 'Зарегистрироваться', showAppChrome: false };
|
export const pageMeta = { id: 'register-view', title: 'Зарегистрироваться', showAppChrome: false };
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import {
|
import {
|
||||||
authService,
|
authService,
|
||||||
authorizeSession,
|
authorizeSession,
|
||||||
@ -6,7 +6,7 @@ import {
|
|||||||
setAuthError,
|
setAuthError,
|
||||||
setAuthInfo,
|
setAuthInfo,
|
||||||
state,
|
state,
|
||||||
} from '../state.js?v=20260327192619';
|
} from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'registration-keys-view', title: 'Сохранение ключей', showAppChrome: false };
|
export const pageMeta = { id: 'registration-keys-view', title: 'Сохранение ключей', showAppChrome: false };
|
||||||
|
|
||||||
@ -14,6 +14,7 @@ export function render({ navigate }) {
|
|||||||
const screen = document.createElement('section');
|
const screen = document.createElement('section');
|
||||||
screen.className = 'stack';
|
screen.className = 'stack';
|
||||||
|
|
||||||
|
const isLoginFlow = state.registrationDraft.flowType === 'login';
|
||||||
const normalizedLogin = (state.registrationDraft.login || '').trim();
|
const normalizedLogin = (state.registrationDraft.login || '').trim();
|
||||||
const displayLogin = normalizedLogin || '@new.user';
|
const displayLogin = normalizedLogin || '@new.user';
|
||||||
|
|
||||||
@ -22,7 +23,9 @@ export function render({ navigate }) {
|
|||||||
|
|
||||||
const title = document.createElement('p');
|
const title = document.createElement('p');
|
||||||
title.className = 'auth-copy';
|
title.className = 'auth-copy';
|
||||||
title.textContent = `Отлично, логин ${displayLogin} зарегистрирован.`;
|
title.textContent = isLoginFlow
|
||||||
|
? `Вход выполнен для логина ${displayLogin}.`
|
||||||
|
: `Отлично, логин ${displayLogin} зарегистрирован.`;
|
||||||
|
|
||||||
const question = document.createElement('p');
|
const question = document.createElement('p');
|
||||||
question.className = 'auth-copy';
|
question.className = 'auth-copy';
|
||||||
@ -43,17 +46,17 @@ export function render({ navigate }) {
|
|||||||
|
|
||||||
const rootRow = document.createElement('label');
|
const rootRow = document.createElement('label');
|
||||||
rootRow.className = 'checkbox-row';
|
rootRow.className = 'checkbox-row';
|
||||||
rootRow.innerHTML = `<input type="checkbox" ${state.keyStorage.saveRoot ? 'checked' : ''} disabled /> <span>root key</span>`;
|
rootRow.append(rootToggle, document.createTextNode('root key'));
|
||||||
|
|
||||||
const blockchainRow = document.createElement('label');
|
const blockchainRow = document.createElement('label');
|
||||||
blockchainRow.className = 'checkbox-row';
|
blockchainRow.className = 'checkbox-row';
|
||||||
blockchainRow.innerHTML = `<input type="checkbox" ${state.keyStorage.saveBlockchain ? 'checked' : ''} disabled /> <span>blockchain key</span>`;
|
blockchainRow.append(blockchainToggle, document.createTextNode('blockchain.key'));
|
||||||
|
|
||||||
const deviceRow = document.createElement('label');
|
const deviceRow = document.createElement('label');
|
||||||
deviceRow.className = 'checkbox-row';
|
deviceRow.className = 'checkbox-row';
|
||||||
deviceRow.append(deviceToggle, document.createTextNode('device key (всегда)'));
|
deviceRow.append(deviceToggle, document.createTextNode('device key (всегда)'));
|
||||||
|
|
||||||
card.append(title, question, rootRow, deviceRow, blockchainRow);
|
card.append(title, question, rootRow, blockchainRow, deviceRow);
|
||||||
|
|
||||||
const actions = document.createElement('div');
|
const actions = document.createElement('div');
|
||||||
actions.className = 'auth-footer-actions';
|
actions.className = 'auth-footer-actions';
|
||||||
@ -91,13 +94,30 @@ export function render({ navigate }) {
|
|||||||
state.registrationDraft.pendingSessionMaterial,
|
state.registrationDraft.pendingSessionMaterial,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!state.keyStorage.saveRoot && state.registrationDraft.pendingKeyBundle) {
|
||||||
|
state.registrationDraft.pendingKeyBundle.rootPair = null;
|
||||||
|
}
|
||||||
|
if (!state.keyStorage.saveBlockchain && state.registrationDraft.pendingKeyBundle) {
|
||||||
|
state.registrationDraft.pendingKeyBundle.blockchainPair = null;
|
||||||
|
}
|
||||||
|
|
||||||
authorizeSession({
|
authorizeSession({
|
||||||
login: state.registrationDraft.login,
|
login: state.registrationDraft.login,
|
||||||
sessionId: state.registrationDraft.sessionId,
|
sessionId: state.registrationDraft.sessionId,
|
||||||
storagePwd: state.registrationDraft.storagePwd,
|
storagePwd: state.registrationDraft.storagePwd,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
state.loginDraft.login = state.registrationDraft.login;
|
||||||
|
state.loginDraft.password = '';
|
||||||
|
state.registrationDraft.flowType = '';
|
||||||
|
state.registrationDraft.password = '';
|
||||||
|
state.registrationDraft.storagePwd = '';
|
||||||
|
state.registrationDraft.sessionId = '';
|
||||||
|
state.registrationDraft.pendingKeyBundle = null;
|
||||||
|
state.registrationDraft.pendingSessionMaterial = null;
|
||||||
|
|
||||||
await refreshSessions();
|
await refreshSessions();
|
||||||
setAuthInfo('Ключи сохранены, регистрация завершена.');
|
setAuthInfo(isLoginFlow ? 'Ключи сохранены, вход завершён.' : 'Ключи сохранены, регистрация завершена.');
|
||||||
navigate('profile-view');
|
navigate('profile-view');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setAuthError(error.message);
|
setAuthError(error.message);
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import {
|
import {
|
||||||
authService,
|
authService,
|
||||||
refreshRegistrationBalance,
|
refreshRegistrationBalance,
|
||||||
setAuthError,
|
setAuthError,
|
||||||
setAuthInfo,
|
setAuthInfo,
|
||||||
state,
|
state,
|
||||||
} from '../state.js?v=20260327192619';
|
} from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'registration-payment-view', title: 'Оплата регистрации', showAppChrome: false };
|
export const pageMeta = { id: 'registration-payment-view', title: 'Оплата регистрации', showAppChrome: false };
|
||||||
|
|
||||||
@ -79,6 +79,7 @@ export function render({ navigate }) {
|
|||||||
|
|
||||||
await authService.reconnect(state.entrySettings.shineServer);
|
await authService.reconnect(state.entrySettings.shineServer);
|
||||||
const result = await authService.registerUser(state.registrationDraft.login, state.registrationDraft.password);
|
const result = await authService.registerUser(state.registrationDraft.login, state.registrationDraft.password);
|
||||||
|
state.registrationDraft.flowType = 'registration';
|
||||||
state.registrationDraft.sessionId = result.sessionId;
|
state.registrationDraft.sessionId = result.sessionId;
|
||||||
state.registrationDraft.storagePwd = result.storagePwd;
|
state.registrationDraft.storagePwd = result.storagePwd;
|
||||||
state.registrationDraft.pendingKeyBundle = result.keyBundle;
|
state.registrationDraft.pendingKeyBundle = result.keyBundle;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { checkServerAvailability, saveEntrySettings, state } from '../state.js?v=20260327192619';
|
import { checkServerAvailability, saveEntrySettings, state } from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'server-settings-view', title: 'Настройки серверов' };
|
export const pageMeta = { id: 'server-settings-view', title: 'Настройки серверов' };
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'settings-view', title: 'Настройки' };
|
export const pageMeta = { id: 'settings-view', title: 'Настройки' };
|
||||||
|
|
||||||
|
|||||||
@ -1,32 +1,25 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
|
import { state } from '../state.js?v=20260330001044';
|
||||||
|
import { loadEncryptedUserSecrets } from '../services/key-vault.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'show-keys-view', title: 'Показать ключи' };
|
export const pageMeta = { id: 'show-keys-view', title: 'Показать ключи' };
|
||||||
|
|
||||||
function randomKey(length = 44) {
|
|
||||||
const chars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz123456789';
|
|
||||||
let result = '';
|
|
||||||
for (let i = 0; i < length; i += 1) {
|
|
||||||
result += chars[Math.floor(Math.random() * chars.length)];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function render({ navigate }) {
|
export function render({ navigate }) {
|
||||||
const screen = document.createElement('section');
|
const screen = document.createElement('section');
|
||||||
screen.className = 'stack';
|
screen.className = 'stack';
|
||||||
|
|
||||||
const keys = {
|
|
||||||
root: randomKey(),
|
|
||||||
blockchain: randomKey(),
|
|
||||||
device: randomKey(),
|
|
||||||
};
|
|
||||||
|
|
||||||
const visible = {
|
const visible = {
|
||||||
root: false,
|
root: false,
|
||||||
blockchain: false,
|
blockchain: false,
|
||||||
device: false,
|
device: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const keys = {
|
||||||
|
root: '',
|
||||||
|
blockchain: '',
|
||||||
|
device: '',
|
||||||
|
};
|
||||||
|
|
||||||
screen.append(
|
screen.append(
|
||||||
renderHeader({
|
renderHeader({
|
||||||
title: 'Показать ключи',
|
title: 'Показать ключи',
|
||||||
@ -37,6 +30,11 @@ export function render({ navigate }) {
|
|||||||
const card = document.createElement('div');
|
const card = document.createElement('div');
|
||||||
card.className = 'card stack';
|
card.className = 'card stack';
|
||||||
|
|
||||||
|
const status = document.createElement('p');
|
||||||
|
status.className = 'meta-muted';
|
||||||
|
status.textContent = 'Загружаем сохранённые ключи...';
|
||||||
|
card.append(status);
|
||||||
|
|
||||||
const renderField = (id, label) => {
|
const renderField = (id, label) => {
|
||||||
const row = document.createElement('div');
|
const row = document.createElement('div');
|
||||||
row.className = 'key-card stack';
|
row.className = 'key-card stack';
|
||||||
@ -50,79 +48,80 @@ export function render({ navigate }) {
|
|||||||
return row;
|
return row;
|
||||||
};
|
};
|
||||||
|
|
||||||
card.append(renderField('root', 'root key'), renderField('blockchain', 'blockchain key'), renderField('device', 'device key'));
|
card.append(
|
||||||
|
renderField('root', 'root key'),
|
||||||
|
renderField('blockchain', 'blockchain.key'),
|
||||||
|
renderField('device', 'device key'),
|
||||||
|
);
|
||||||
|
|
||||||
|
const setMissingState = (id) => {
|
||||||
|
const valueEl = card.querySelector(`[data-value="${id}"]`);
|
||||||
|
const btnEl = card.querySelector(`[data-toggle="${id}"]`);
|
||||||
|
valueEl.textContent = 'нет данных';
|
||||||
|
btnEl.disabled = true;
|
||||||
|
btnEl.textContent = 'Нет';
|
||||||
|
};
|
||||||
|
|
||||||
const updateField = (id) => {
|
const updateField = (id) => {
|
||||||
const valueEl = card.querySelector(`[data-value="${id}"]`);
|
const valueEl = card.querySelector(`[data-value="${id}"]`);
|
||||||
const btnEl = card.querySelector(`[data-toggle="${id}"]`);
|
const btnEl = card.querySelector(`[data-toggle="${id}"]`);
|
||||||
|
if (!keys[id]) {
|
||||||
|
setMissingState(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
valueEl.textContent = visible[id] ? keys[id] : '*****';
|
valueEl.textContent = visible[id] ? keys[id] : '*****';
|
||||||
|
btnEl.disabled = false;
|
||||||
btnEl.textContent = visible[id] ? 'Скрыть' : 'Показать';
|
btnEl.textContent = visible[id] ? 'Скрыть' : 'Показать';
|
||||||
};
|
};
|
||||||
|
|
||||||
card.querySelectorAll('[data-toggle]').forEach((button) => {
|
card.querySelectorAll('[data-toggle]').forEach((button) => {
|
||||||
button.addEventListener('click', () => {
|
button.addEventListener('click', () => {
|
||||||
const { toggle } = button.dataset;
|
const { toggle } = button.dataset;
|
||||||
|
if (!keys[toggle]) return;
|
||||||
visible[toggle] = !visible[toggle];
|
visible[toggle] = !visible[toggle];
|
||||||
updateField(toggle);
|
updateField(toggle);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
['root', 'blockchain', 'device'].forEach((id) => updateField(id));
|
||||||
|
|
||||||
const actions = document.createElement('div');
|
const actions = document.createElement('div');
|
||||||
actions.className = 'auth-footer-actions';
|
actions.className = 'auth-footer-actions';
|
||||||
actions.innerHTML = `
|
|
||||||
<button class="primary-btn" type="button" id="save-keys">Сохранить новые</button>
|
|
||||||
<button class="ghost-btn" type="button" id="cancel-keys">Отмена</button>
|
|
||||||
`;
|
|
||||||
|
|
||||||
const confirmModal = document.createElement('div');
|
const closeButton = document.createElement('button');
|
||||||
confirmModal.className = 'modal-shell';
|
closeButton.className = 'ghost-btn';
|
||||||
confirmModal.hidden = true;
|
closeButton.type = 'button';
|
||||||
confirmModal.innerHTML = `
|
closeButton.textContent = 'Назад';
|
||||||
<div class="modal-backdrop" data-close="true"></div>
|
closeButton.addEventListener('click', () => navigate('device-view'));
|
||||||
<div class="modal-dialog card" role="dialog" aria-modal="true" tabindex="-1">
|
actions.append(closeButton);
|
||||||
<p>Вы уверены, что хотите изменить ключи?</p>
|
|
||||||
<div class="auth-footer-actions">
|
|
||||||
<button class="primary-btn" type="button" id="confirm-keys-ok">ОК</button>
|
|
||||||
<button class="ghost-btn" type="button" data-close="true">Отмена</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
const openModal = () => {
|
(async () => {
|
||||||
confirmModal.hidden = false;
|
try {
|
||||||
confirmModal.querySelector('.modal-dialog').focus();
|
if (!state.session.login || !state.session.storagePwdInMemory) {
|
||||||
};
|
throw new Error('Нет активной сессии для чтения ключей');
|
||||||
|
|
||||||
const closeModal = () => {
|
|
||||||
confirmModal.hidden = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
actions.querySelector('#save-keys').addEventListener('click', openModal);
|
|
||||||
actions.querySelector('#cancel-keys').addEventListener('click', () => navigate('device-view'));
|
|
||||||
|
|
||||||
confirmModal.querySelector('#confirm-keys-ok').addEventListener('click', () => {
|
|
||||||
keys.root = randomKey();
|
|
||||||
keys.blockchain = randomKey();
|
|
||||||
keys.device = randomKey();
|
|
||||||
updateField('root');
|
|
||||||
updateField('blockchain');
|
|
||||||
updateField('device');
|
|
||||||
closeModal();
|
|
||||||
});
|
|
||||||
|
|
||||||
confirmModal.addEventListener('click', (event) => {
|
|
||||||
const target = event.target;
|
|
||||||
if (target instanceof HTMLElement && target.dataset.close === 'true') {
|
|
||||||
closeModal();
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
confirmModal.addEventListener('keydown', (event) => {
|
const savedKeys = await loadEncryptedUserSecrets(
|
||||||
if (event.key === 'Escape') {
|
state.session.login,
|
||||||
closeModal();
|
state.session.storagePwdInMemory,
|
||||||
|
);
|
||||||
|
|
||||||
|
keys.root = savedKeys.rootKey || '';
|
||||||
|
keys.blockchain = savedKeys.blockchainKey || '';
|
||||||
|
keys.device = savedKeys.deviceKey || '';
|
||||||
|
|
||||||
|
if (keys.root || keys.blockchain || keys.device) {
|
||||||
|
status.textContent = 'Показаны только ключи, сохранённые на этом устройстве.';
|
||||||
|
} else {
|
||||||
|
status.textContent = 'На этом устройстве нет сохранённых ключей.';
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
status.textContent = 'На этом устройстве нет сохранённых ключей.';
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
screen.append(card, actions, confirmModal);
|
['root', 'blockchain', 'device'].forEach((id) => updateField(id));
|
||||||
|
})();
|
||||||
|
|
||||||
|
screen.append(card, actions);
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { clearStartHint, state } from '../state.js?v=20260327192619';
|
import { clearStartHint, state } from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'start-view', title: 'Старт', showAppChrome: false };
|
export const pageMeta = { id: 'start-view', title: 'Старт', showAppChrome: false };
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { state } from '../state.js?v=20260327192619';
|
import { state } from '../state.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'topup-view', title: 'Пополнение счета', showAppChrome: false };
|
export const pageMeta = { id: 'topup-view', title: 'Пополнение счета', showAppChrome: false };
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
import { renderHeader } from '../components/header.js?v=20260330001044';
|
||||||
import { wallet } from '../mock-data.js?v=20260327192619';
|
import { wallet } from '../mock-data.js?v=20260330001044';
|
||||||
|
|
||||||
export const pageMeta = { id: 'wallet-view', title: 'Кошелёк' };
|
export const pageMeta = { id: 'wallet-view', title: 'Кошелёк' };
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { WsJsonClient } from './ws-client.js?v=20260327192619';
|
import { WsJsonClient } from './ws-client.js?v=20260330001044';
|
||||||
import {
|
import {
|
||||||
deriveEd25519FromPassword,
|
deriveEd25519FromPassword,
|
||||||
exportEd25519PublicKeyB64,
|
exportEd25519PublicKeyB64,
|
||||||
@ -7,8 +7,8 @@ import {
|
|||||||
importPkcs8Ed25519,
|
importPkcs8Ed25519,
|
||||||
randomBase64,
|
randomBase64,
|
||||||
signBase64,
|
signBase64,
|
||||||
} from './crypto-utils.js?v=20260327192619';
|
} from './crypto-utils.js?v=20260330001044';
|
||||||
import { loadSessionMaterial, saveEncryptedUserSecrets, saveSessionMaterial } from './key-vault.js?v=20260327192619';
|
import { loadSessionMaterial, saveEncryptedUserSecrets, saveSessionMaterial } from './key-vault.js?v=20260330001044';
|
||||||
|
|
||||||
const BCH_SUFFIX = '001';
|
const BCH_SUFFIX = '001';
|
||||||
|
|
||||||
@ -25,7 +25,11 @@ function normalizeServerUrl(url) {
|
|||||||
function opError(op, response) {
|
function opError(op, response) {
|
||||||
const message = response?.payload?.message || response?.message || 'Неизвестная ошибка сервера';
|
const message = response?.payload?.message || response?.message || 'Неизвестная ошибка сервера';
|
||||||
const code = response?.payload?.code || response?.code || 'UNKNOWN';
|
const code = response?.payload?.code || response?.code || 'UNKNOWN';
|
||||||
return new Error(`${op}: ${message} (${code})`);
|
const error = new Error(`${op}: ${message} (${code})`);
|
||||||
|
error.op = op;
|
||||||
|
error.code = code;
|
||||||
|
error.status = response?.status || 0;
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeClientInfo() {
|
function makeClientInfo() {
|
||||||
@ -145,7 +149,8 @@ export class AuthService {
|
|||||||
if (!user.exists) throw new Error('Пользователь не найден');
|
if (!user.exists) throw new Error('Пользователь не найден');
|
||||||
|
|
||||||
const keyBundle = await this.derivePasswordKeyBundle(password);
|
const keyBundle = await this.derivePasswordKeyBundle(password);
|
||||||
return this.createAuthSession(cleanLogin, keyBundle);
|
const session = await this.createAuthSession(cleanLogin, keyBundle);
|
||||||
|
return { ...session, keyBundle };
|
||||||
}
|
}
|
||||||
|
|
||||||
async persistSelectedKeys(login, storagePwd, keyBundle, saveOptions = { saveRoot: true, saveBlockchain: true }) {
|
async persistSelectedKeys(login, storagePwd, keyBundle, saveOptions = { saveRoot: true, saveBlockchain: true }) {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
decryptJsonWithStoragePwd,
|
decryptJsonWithStoragePwd,
|
||||||
encryptJsonWithStoragePwd,
|
encryptJsonWithStoragePwd,
|
||||||
} from './crypto-utils.js?v=20260327192619';
|
} from './crypto-utils.js?v=20260330001044';
|
||||||
|
|
||||||
const DB_NAME = 'shine-ui-auth';
|
const DB_NAME = 'shine-ui-auth';
|
||||||
const DB_VERSION = 1;
|
const DB_VERSION = 1;
|
||||||
@ -76,3 +76,12 @@ export async function saveSessionMaterial(login, material) {
|
|||||||
export async function loadSessionMaterial(login) {
|
export async function loadSessionMaterial(login) {
|
||||||
return get(STORE_SESSIONS, login);
|
return get(STORE_SESSIONS, login);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function clearClientAuthData() {
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
const request = indexedDB.deleteDatabase(DB_NAME);
|
||||||
|
request.onsuccess = () => resolve();
|
||||||
|
request.onerror = () => reject(request.error || new Error('Не удалось очистить IndexedDB'));
|
||||||
|
request.onblocked = () => reject(new Error('Очистка IndexedDB заблокирована открытыми соединениями'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@ -1,8 +1,15 @@
|
|||||||
import { chatMessages, wallet } from './mock-data.js?v=20260327192619';
|
import { chatMessages, wallet } from './mock-data.js?v=20260330001044';
|
||||||
import { AuthService } from './services/auth-service.js?v=20260327192619';
|
import { AuthService } from './services/auth-service.js?v=20260330001044';
|
||||||
|
import { clearClientAuthData } from './services/key-vault.js?v=20260330001044';
|
||||||
|
|
||||||
const clone = (value) => JSON.parse(JSON.stringify(value));
|
const clone = (value) => JSON.parse(JSON.stringify(value));
|
||||||
const SESSION_STORAGE_KEY = 'shine-ui-current-session-v1';
|
const SESSION_STORAGE_KEY = 'shine-ui-current-session-v1';
|
||||||
|
const INVALID_SESSION_CODES = new Set([
|
||||||
|
'NOT_AUTHENTICATED',
|
||||||
|
'SESSION_NOT_FOUND',
|
||||||
|
'SESSION_KEY_NOT_ACTUAL',
|
||||||
|
'SESSION_OF_ANOTHER_USER',
|
||||||
|
]);
|
||||||
|
|
||||||
function loadStoredSession() {
|
function loadStoredSession() {
|
||||||
try {
|
try {
|
||||||
@ -30,9 +37,9 @@ function clearStoredSession() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const storedSession = loadStoredSession();
|
function createInitialState({ withStoredSession = true } = {}) {
|
||||||
|
const storedSession = withStoredSession ? loadStoredSession() : null;
|
||||||
export const state = {
|
return {
|
||||||
chats: clone(chatMessages),
|
chats: clone(chatMessages),
|
||||||
notificationsTab: 'replies',
|
notificationsTab: 'replies',
|
||||||
pageLabelCollapsed: false,
|
pageLabelCollapsed: false,
|
||||||
@ -55,6 +62,7 @@ export const state = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
registrationDraft: {
|
registrationDraft: {
|
||||||
|
flowType: '',
|
||||||
login: '',
|
login: '',
|
||||||
password: '',
|
password: '',
|
||||||
sessionId: '',
|
sessionId: '',
|
||||||
@ -74,7 +82,7 @@ export const state = {
|
|||||||
rootKey: 'Ключ root хранится в зашифрованном виде',
|
rootKey: 'Ключ root хранится в зашифрованном виде',
|
||||||
blockchainKey: 'Ключ blockchain хранится в зашифрованном виде',
|
blockchainKey: 'Ключ blockchain хранится в зашифрованном виде',
|
||||||
deviceKey: 'Ключ device хранится в зашифрованном виде',
|
deviceKey: 'Ключ device хранится в зашифрованном виде',
|
||||||
saveRoot: true,
|
saveRoot: false,
|
||||||
saveBlockchain: true,
|
saveBlockchain: true,
|
||||||
saveDevice: true,
|
saveDevice: true,
|
||||||
},
|
},
|
||||||
@ -90,8 +98,12 @@ export const state = {
|
|||||||
},
|
},
|
||||||
sessions: [],
|
sessions: [],
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const state = createInitialState();
|
||||||
|
|
||||||
export const authService = new AuthService(state.entrySettings.shineServer);
|
export const authService = new AuthService(state.entrySettings.shineServer);
|
||||||
|
let onSessionReset = null;
|
||||||
|
|
||||||
export function getChatMessages(chatId) {
|
export function getChatMessages(chatId) {
|
||||||
if (!state.chats[chatId]) {
|
if (!state.chats[chatId]) {
|
||||||
@ -170,19 +182,49 @@ export function authorizeSession({ login, sessionId, storagePwd }) {
|
|||||||
state.startHint = '';
|
state.startHint = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setSessionResetHandler(handler) {
|
||||||
|
onSessionReset = typeof handler === 'function' ? handler : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isSessionInvalidError(error) {
|
||||||
|
return INVALID_SESSION_CODES.has(error?.code);
|
||||||
|
}
|
||||||
|
|
||||||
export async function refreshSessions() {
|
export async function refreshSessions() {
|
||||||
state.sessions = await authService.listSessions();
|
state.sessions = await authService.listSessions();
|
||||||
return state.sessions;
|
return state.sessions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function terminateCurrentSession() {
|
function resetStateForSignedOut() {
|
||||||
state.session.isAuthorized = false;
|
const next = createInitialState({ withStoredSession: false });
|
||||||
state.session.login = '';
|
state.chats = next.chats;
|
||||||
state.session.sessionId = '';
|
state.notificationsTab = next.notificationsTab;
|
||||||
state.session.storagePwdInMemory = '';
|
state.session = next.session;
|
||||||
state.sessions = [];
|
state.startHint = next.startHint;
|
||||||
|
state.registrationDraft = next.registrationDraft;
|
||||||
|
state.loginDraft = next.loginDraft;
|
||||||
|
state.registrationPayment = next.registrationPayment;
|
||||||
|
state.keyStorage = next.keyStorage;
|
||||||
|
state.deviceConnect = next.deviceConnect;
|
||||||
|
state.authUi = next.authUi;
|
||||||
|
state.sessions = next.sessions;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function terminateCurrentSession({ infoMessage = '' } = {}) {
|
||||||
clearStoredSession();
|
clearStoredSession();
|
||||||
state.startHint = '';
|
resetStateForSignedOut();
|
||||||
|
authService.close();
|
||||||
|
try {
|
||||||
|
await clearClientAuthData();
|
||||||
|
} catch {
|
||||||
|
// ignore cleanup errors in prototype mode
|
||||||
|
}
|
||||||
|
if (infoMessage) {
|
||||||
|
state.startHint = infoMessage;
|
||||||
|
}
|
||||||
|
if (onSessionReset) {
|
||||||
|
onSessionReset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function refreshRegistrationBalance() {
|
export function refreshRegistrationBalance() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user