SHA256
Доработать UI личных сообщений
This commit is contained in:
+1
-1
@@ -39,7 +39,7 @@
|
||||
}());
|
||||
</script>
|
||||
<script>
|
||||
window.__SHINE_BUILD_HASH__ = '20261110-pwa-avatar-01';
|
||||
window.__SHINE_BUILD_HASH__ = '20261113-dm-security-note-01';
|
||||
window.__SHINE_CLIENT_VERSION__ = '1.20.9';
|
||||
</script>
|
||||
<script>
|
||||
|
||||
@@ -2215,6 +2215,17 @@
|
||||
"text_039": "Who to show"
|
||||
},
|
||||
"chat_view": {
|
||||
"security_notice": {
|
||||
"title": "Your conversation is protected by end-to-end encryption",
|
||||
"encryption": "All private messages are encrypted using modern cryptographic algorithms. Encryption keys are stored ONLY on the participants’ devices.",
|
||||
"servers": "SHiNE servers do not possess your private keys and cannot technically read your messages.",
|
||||
"derivation": "Your encryption key is derived from your login and password.",
|
||||
"rotation": "When you change your password, your messages are re-encrypted from the old password to the new one on your device.",
|
||||
"source": "The source code of our applications is fully open, so you can verify these claims yourself.",
|
||||
"warning_label": "Important:",
|
||||
"warning": "if you forget your password, you will not be able to recover access to your encrypted conversations.",
|
||||
"recovery": "SHiNE does not store your secret keys and cannot help you restore your conversations."
|
||||
},
|
||||
"text_002": "Muted",
|
||||
"text_015": "Search",
|
||||
"text_020": "Clear history",
|
||||
|
||||
@@ -2348,6 +2348,17 @@
|
||||
"text_039": "Кого показать"
|
||||
},
|
||||
"chat_view": {
|
||||
"security_notice": {
|
||||
"title": "Ваша переписка защищена сквозным шифрованием",
|
||||
"encryption": "Все личные сообщения шифруются с использованием современных криптографических алгоритмов. Ключи шифрования хранятся ТОЛЬКО на устройствах участников переписки.",
|
||||
"servers": "Сервера SHiNE не имеют ваших приватных ключей и даже технически никак не могут прочитать ваши сообщения.",
|
||||
"derivation": "Ваш ключ шифрования высчитывается из вашего логина и пароля.",
|
||||
"rotation": "При смене пароля перекодирование всех ваших сообщений со старого пароля на новый происходит на устройстве пользователя.",
|
||||
"source": "Код наших приложений полностью открыт и вы легко можете проверить всё это сами.",
|
||||
"warning_label": "Важно:",
|
||||
"warning": "если вы забудете свой пароль, восстановить доступ к вашей зашифрованной переписке будет невозможно.",
|
||||
"recovery": "SHiNE не хранит ваши секретные ключи и никак не сможет помочь вам восстановить вашу переписку."
|
||||
},
|
||||
"text_001": "Чат",
|
||||
"text_002": "Без звука",
|
||||
"text_003": "Показать связи",
|
||||
|
||||
@@ -1135,6 +1135,41 @@ function scrollToUnreadSeparator(list) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Постоянная справка в начале личного диалога. Это только UI: не DM, не запись в блокчейн.
|
||||
function createDmEncryptionNotice() {
|
||||
const notice = document.createElement('aside');
|
||||
notice.className = 'dm-security-notice';
|
||||
notice.setAttribute('role', 'note');
|
||||
|
||||
const heading = document.createElement('strong');
|
||||
heading.className = 'dm-security-notice__title';
|
||||
heading.textContent = `🔒 ${t('screens.chat_view.security_notice.title')}`;
|
||||
notice.append(heading);
|
||||
|
||||
for (const text of [
|
||||
t('screens.chat_view.security_notice.encryption'),
|
||||
t('screens.chat_view.security_notice.servers'),
|
||||
t('screens.chat_view.security_notice.derivation'),
|
||||
t('screens.chat_view.security_notice.rotation'),
|
||||
t('screens.chat_view.security_notice.source'),
|
||||
]) {
|
||||
const paragraph = document.createElement('p');
|
||||
paragraph.textContent = text;
|
||||
notice.append(paragraph);
|
||||
}
|
||||
|
||||
const warning = document.createElement('p');
|
||||
const warningLabel = document.createElement('strong');
|
||||
warningLabel.textContent = `${t('screens.chat_view.security_notice.warning_label')} `;
|
||||
warning.append(warningLabel, document.createTextNode(t('screens.chat_view.security_notice.warning')));
|
||||
notice.append(warning);
|
||||
|
||||
const recovery = document.createElement('p');
|
||||
recovery.textContent = t('screens.chat_view.security_notice.recovery');
|
||||
notice.append(recovery);
|
||||
return notice;
|
||||
}
|
||||
|
||||
function renderLog(
|
||||
list,
|
||||
chatId,
|
||||
@@ -1148,6 +1183,7 @@ function renderLog(
|
||||
} = {},
|
||||
) {
|
||||
list.innerHTML = '';
|
||||
list.append(createDmEncryptionNotice());
|
||||
const messages = getChatMessages(chatId);
|
||||
let unreadSeparatorInserted = false;
|
||||
const separatorMessageKey = String(unreadSeparatorMessageKey || '').trim();
|
||||
|
||||
@@ -371,6 +371,7 @@ export function parseRouteFromPath(pathname = '') {
|
||||
if (sub === 'language') return { pageId: 'language-view', params: {} };
|
||||
if (sub === 'appearance') return { pageId: 'appearance-view', params: {} };
|
||||
if (sub === 'notifications') return { pageId: 'notification-settings-view', params: {} };
|
||||
if (sub === 'application') return { pageId: 'application-settings-view', params: {} };
|
||||
if (sub === 'app-log') return { pageId: 'app-log-view', params: {} };
|
||||
if (sub === 'pwa-diagnostics') return { pageId: 'pwa-diagnostics-view', params: {} };
|
||||
if (sub === 'solana-users-init') return { pageId: 'solana-users-init-view', params: {} };
|
||||
|
||||
@@ -323,6 +323,35 @@
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* Ненавязчивая справка в начале DM-ленты: не является отправленным сообщением. */
|
||||
.dm-security-notice {
|
||||
width: min(100%, 460px);
|
||||
box-sizing: border-box;
|
||||
justify-self: center;
|
||||
margin: 24px auto 16px;
|
||||
padding: 0 18px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.55;
|
||||
text-align: center;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.dm-security-notice__title {
|
||||
display: block;
|
||||
margin-bottom: 12px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.dm-security-notice p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.dm-security-notice p + p {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
|
||||
.dm-screen .bubble {
|
||||
max-width: 78%;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const source = (path) => readFileSync(new URL(path, import.meta.url), 'utf8');
|
||||
const chat = source('../js/pages/chat-view.js');
|
||||
const css = source('../styles/features/chat.css');
|
||||
const ru = JSON.parse(source('../js/i18n/locales/ru.json'));
|
||||
const en = JSON.parse(source('../js/i18n/locales/en.json'));
|
||||
|
||||
for (const [locale, language] of [['ru', ru], ['en', en]]) {
|
||||
test(`в ${locale} есть полный текст предупреждения DM`, () => {
|
||||
const note = language.screens.chat_view.security_notice;
|
||||
for (const key of ['title', 'encryption', 'servers', 'derivation', 'rotation', 'source', 'warning_label', 'warning', 'recovery']) {
|
||||
assert.ok(typeof note[key] === 'string' && note[key].trim(), `${locale}/${key}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
test('уведомление формируется только локально и добавляется первым элементом ленты', () => {
|
||||
const start = chat.indexOf('function createDmEncryptionNotice()');
|
||||
const end = chat.indexOf('function renderLog(', start);
|
||||
const functionBody = chat.slice(start, end);
|
||||
assert.ok(start >= 0 && end > start);
|
||||
assert.match(functionBody, /document\.createElement\('aside'\)/);
|
||||
assert.match(functionBody, /dm-security-notice/);
|
||||
assert.match(chat, /list\.innerHTML = '';\s*list\.append\(createDmEncryptionNotice\(\)\);\s*const messages = getChatMessages\(chatId\);/);
|
||||
assert.doesNotMatch(functionBody, /authService|addSignedMessageToChat|sendDirectMessage|AddBlock|fetch\(/);
|
||||
});
|
||||
|
||||
test('уведомление имеет собственные серые стили и не оформляется как bubble', () => {
|
||||
assert.match(css, /\.dm-security-notice\s*\{[\s\S]*?color: var\(--text-secondary\)/);
|
||||
assert.doesNotMatch(chat.slice(chat.indexOf('function createDmEncryptionNotice()'), chat.indexOf('function renderLog(')), /className = ['"`]bubble/);
|
||||
});
|
||||
Reference in New Issue
Block a user