chore: import MCTF services
- Added all seven issued service trees without omissions. - Preserved the supplied runtime configuration, binaries, and assets.
This commit is contained in:
commit
13f936bee9
1222 files changed
+21280
No files matched your search
Executable
+151
@@ -0,0 +1,151 @@
|
||||
import { api } from '../shared/api/client.js';
|
||||
import { state, setSession } from '../shared/session.js';
|
||||
import { renderLogin } from '../features/auth/login.js';
|
||||
import { renderIssue } from '../features/implants/create.js';
|
||||
import { renderList } from '../features/implants/list.js';
|
||||
import { renderCard } from '../features/implants/details.js';
|
||||
import { renderHolder } from '../features/implants/holder.js';
|
||||
import { renderReissue } from '../features/implants/reissue.js';
|
||||
import { renderRegistry } from '../features/implants/registry.js';
|
||||
|
||||
const nav = document.querySelector('#nav');
|
||||
const username = document.querySelector('#username');
|
||||
const layout = document.querySelector('#layout');
|
||||
const logout = document.querySelector('#logout');
|
||||
const loginLink = document.querySelector('#login-link');
|
||||
|
||||
const pageTitles = {
|
||||
'/login': 'Вход',
|
||||
'/home': 'Главная',
|
||||
'/home/register_implant': 'Новый имплант',
|
||||
'/home/check_certificate': 'Проверка',
|
||||
'/home/reissue': 'Перевыпуск',
|
||||
'/home/implants': 'Импланты',
|
||||
'/home/registry': 'Реестр сертификатов',
|
||||
};
|
||||
|
||||
function go(path, { replace = false } = {}) {
|
||||
if (replace) history.replaceState(null, '', path);
|
||||
else history.pushState(null, '', path);
|
||||
render();
|
||||
}
|
||||
|
||||
function syncChrome() {
|
||||
const signedIn = Boolean(state.user);
|
||||
layout.classList.toggle('signed-out', !signedIn);
|
||||
username.textContent = state.user ? state.user.username : '';
|
||||
logout.hidden = !signedIn;
|
||||
loginLink.hidden = signedIn;
|
||||
for (const link of nav.querySelectorAll('[data-auth]')) {
|
||||
link.hidden = !signedIn;
|
||||
}
|
||||
for (const link of nav.querySelectorAll('a')) {
|
||||
const href = link.getAttribute('href');
|
||||
const active = href === location.pathname
|
||||
|| (href === '/home/implants' && location.pathname.startsWith('/home/implants/'))
|
||||
|| (href === '/home/check_certificate' && location.pathname.startsWith('/home/check_certificate/'));
|
||||
link.classList.toggle('active', active);
|
||||
if (active) link.setAttribute('aria-current', 'page');
|
||||
else link.removeAttribute('aria-current');
|
||||
}
|
||||
const routeTitle = location.pathname.startsWith('/home/implants/')
|
||||
? 'Карточка импланта'
|
||||
: location.pathname.startsWith('/home/check_certificate/') ? 'Проверка' : pageTitles[location.pathname];
|
||||
document.title = routeTitle ? `${routeTitle} · Chrome Ledger` : 'Chrome Ledger';
|
||||
}
|
||||
|
||||
function render() {
|
||||
const path = location.pathname;
|
||||
const publicPage = path === '/login';
|
||||
if (path === '/') return go(state.user ? '/home' : '/login', { replace: true });
|
||||
if (!state.user && !publicPage) return go('/login', { replace: true });
|
||||
if (state.user && path === '/login') return go('/home', { replace: true });
|
||||
syncChrome();
|
||||
if (path === '/login') return renderLogin(go);
|
||||
if (path === '/home') {
|
||||
document.querySelector('#view').innerHTML = '<section class="page"><div class="panel welcome"><h1>Добро пожаловать в Chrome Ledger!</h1></div></section>';
|
||||
return;
|
||||
}
|
||||
if (path === '/home/register_implant') return renderIssue();
|
||||
if (path === '/home/check_certificate') return renderHolder();
|
||||
if (path === '/home/reissue') {
|
||||
const params = new URLSearchParams(location.search);
|
||||
return renderReissue(params.get('id') || '', params.get('serial') || '');
|
||||
}
|
||||
const check = path.match(/^\/home\/check_certificate\/([^/]+)\/check$/);
|
||||
if (check) return renderHolder(decodeURIComponent(check[1]));
|
||||
if (path === '/home/implants') return renderList();
|
||||
if (path === '/home/registry') return renderRegistry();
|
||||
const card = path.match(/^\/home\/implants\/([^/]+)$/);
|
||||
if (card) return renderCard(decodeURIComponent(card[1]));
|
||||
go('/home', { replace: true });
|
||||
}
|
||||
|
||||
window.addEventListener('ledger:session-expired', () => go('/login', { replace: true }));
|
||||
|
||||
logout.addEventListener('click', async (event) => {
|
||||
const button = event.currentTarget;
|
||||
button.disabled = true;
|
||||
try {
|
||||
await api('/logout', { method: 'DELETE' });
|
||||
setSession(null);
|
||||
go('/login', { replace: true });
|
||||
} catch (error) {
|
||||
window.alert(error.message);
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('input', ({ target }) => {
|
||||
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) {
|
||||
target.setCustomValidity(/[^\x00-\x7F]/.test(target.value)
|
||||
? 'Допустимы только английские буквы, цифры и символы ASCII' : '');
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('click', (event) => {
|
||||
if (
|
||||
event.defaultPrevented
|
||||
|| event.button !== 0
|
||||
|| event.metaKey
|
||||
|| event.ctrlKey
|
||||
|| event.shiftKey
|
||||
|| event.altKey
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const link = event.target.closest('a');
|
||||
if (!link) {
|
||||
return;
|
||||
}
|
||||
if (link.target && link.target !== '_self') {
|
||||
return;
|
||||
}
|
||||
if (link.hasAttribute('download')) {
|
||||
return;
|
||||
}
|
||||
const url = new URL(link.href, location.origin);
|
||||
if (url.origin !== location.origin) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
go(url.pathname + url.search);
|
||||
});
|
||||
|
||||
window.addEventListener('popstate', render);
|
||||
|
||||
async function start() {
|
||||
if (state.token) {
|
||||
const token = state.token;
|
||||
try {
|
||||
const user = await api('/me');
|
||||
if (state.token === token) state.user = user;
|
||||
} catch (error) {
|
||||
if (state.token === token) window.alert(error.message);
|
||||
}
|
||||
}
|
||||
render();
|
||||
}
|
||||
|
||||
start();
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
import { api } from '../../shared/api/client.js';
|
||||
import { setSession } from '../../shared/session.js';
|
||||
import { setError } from '../../shared/ui/dom.js';
|
||||
|
||||
const view = document.querySelector('#view');
|
||||
|
||||
export function renderLogin(go) {
|
||||
let registering = false;
|
||||
view.innerHTML = `
|
||||
<section class="page login">
|
||||
<header class="page-header">
|
||||
<h1 id="login-title">Войти в <span>личный кабинет</span></h1>
|
||||
</header>
|
||||
<form class="panel fields" id="login-form">
|
||||
<h2 id="login-form-title">Учетные данные</h2>
|
||||
<label>
|
||||
Имя пользователя
|
||||
<input id="login-username" required autocomplete="username" minlength="3" maxlength="32" pattern="[A-Za-z0-9_\\-]{3,32}">
|
||||
</label>
|
||||
<label>
|
||||
Пароль
|
||||
<input id="login-password" type="password" required minlength="8" maxlength="128" autocomplete="current-password">
|
||||
</label>
|
||||
<p class="error" id="login-error" role="alert" hidden></p>
|
||||
<div class="actions">
|
||||
<button type="submit" id="login-submit">Войти</button>
|
||||
<button class="secondary" type="button" id="login-toggle">Создать аккаунт</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>`;
|
||||
|
||||
const form = document.querySelector('#login-form');
|
||||
const title = document.querySelector('#login-title');
|
||||
const userInput = document.querySelector('#login-username');
|
||||
const password = document.querySelector('#login-password');
|
||||
const problem = document.querySelector('#login-error');
|
||||
const submit = document.querySelector('#login-submit');
|
||||
const toggle = document.querySelector('#login-toggle');
|
||||
|
||||
const setMode = (next) => {
|
||||
registering = next;
|
||||
title.innerHTML = next ? 'Создать <span>аккаунт</span>' : 'Войти в <span>личный кабинет</span>';
|
||||
submit.textContent = next ? 'Создать аккаунт' : 'Войти';
|
||||
toggle.textContent = next ? 'У меня есть аккаунт' : 'Создать аккаунт';
|
||||
password.autocomplete = next ? 'new-password' : 'current-password';
|
||||
password.value = '';
|
||||
setError(problem, '');
|
||||
};
|
||||
|
||||
toggle.addEventListener('click', () => setMode(!registering));
|
||||
|
||||
form.addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
setError(problem, '');
|
||||
submit.disabled = true;
|
||||
toggle.disabled = true;
|
||||
try {
|
||||
setSession(await api(registering ? '/register' : '/login', {
|
||||
method: 'POST',
|
||||
body: { username: userInput.value, password: password.value },
|
||||
}));
|
||||
go('/home', { replace: true });
|
||||
} catch (error) {
|
||||
setError(problem, error.message);
|
||||
} finally {
|
||||
submit.disabled = false;
|
||||
toggle.disabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export const certificateStatus = {
|
||||
active: 'Действует', revoked: 'Отозван', expired: 'Срок истёк', invalid: 'Недействителен',
|
||||
};
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
import { api } from '../../shared/api/client.js';
|
||||
import { escapeHtml, setError, showResultDialog } from '../../shared/ui/dom.js';
|
||||
|
||||
const view = document.querySelector('#view');
|
||||
|
||||
export function renderIssue() {
|
||||
view.innerHTML = `
|
||||
<section class="page">
|
||||
<header class="page-header">
|
||||
<p class="eyebrow"><a href="/home/implants">Импланты</a> / Новый имплант</p>
|
||||
<h1>Новый <span>имплант</span></h1>
|
||||
<p class="intro">Зарегистрируйте устройство и выпустите сертификат</p>
|
||||
</header>
|
||||
<form class="panel fields" id="issue-form">
|
||||
<h2>Сведения об импланте</h2>
|
||||
<div class="field-grid">
|
||||
<label>Название
|
||||
<input id="issue-name" required minlength="1" maxlength="80" autocomplete="off">
|
||||
</label>
|
||||
<label>Модель
|
||||
<input id="issue-model" required minlength="1" maxlength="80" autocomplete="off">
|
||||
</label>
|
||||
</div>
|
||||
<div class="field-grid">
|
||||
<label>Код проекта
|
||||
<input id="issue-project" required minlength="1" maxlength="80" autocomplete="off">
|
||||
</label>
|
||||
<label>Код организации
|
||||
<input id="issue-organization" required minlength="1" maxlength="80" autocomplete="off">
|
||||
</label>
|
||||
</div>
|
||||
<p class="notice">Код проекта и код организации — приватные данные, необходимые для учёта происхождения импланта. Не раскрывайте их значения третьим лицам</p>
|
||||
<label>
|
||||
Открытый ключ
|
||||
<textarea id="issue-key" class="mono" rows="7" spellcheck="false" required placeholder="-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----"></textarea>
|
||||
<small>Полный открытый ключ в формате PEM: ECDSA P-256 или RSA от 2048 бит</small>
|
||||
</label>
|
||||
<p class="notice">После выпуска сохраните сертификат</p>
|
||||
<p class="error" id="issue-error" role="alert" hidden></p>
|
||||
<div class="actions">
|
||||
<button type="submit" id="issue-submit">Выпустить сертификат</button>
|
||||
</div>
|
||||
</form>
|
||||
<div id="issue-result"></div>
|
||||
</section>`;
|
||||
|
||||
const form = document.querySelector('#issue-form');
|
||||
const key = document.querySelector('#issue-key');
|
||||
const problem = document.querySelector('#issue-error');
|
||||
const submit = document.querySelector('#issue-submit');
|
||||
const result = document.querySelector('#issue-result');
|
||||
|
||||
form.addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
setError(problem, '');
|
||||
result.innerHTML = '';
|
||||
const body = {
|
||||
public_key_pem: key.value,
|
||||
display_name: document.querySelector('#issue-name').value,
|
||||
model: document.querySelector('#issue-model').value,
|
||||
project_codename: document.querySelector('#issue-project').value,
|
||||
installed_by: document.querySelector('#issue-organization').value,
|
||||
};
|
||||
submit.disabled = true;
|
||||
submit.textContent = 'Оформляем сертификат…';
|
||||
try {
|
||||
const data = await api('/register_implant', { method: 'POST', body });
|
||||
form.reset();
|
||||
result.innerHTML = `
|
||||
<dialog class="issue-dialog" aria-labelledby="issue-result-title">
|
||||
<section class="panel fields" aria-live="polite">
|
||||
<h2 id="issue-result-title">Сертификат выпущен</h2>
|
||||
<p class="success-message">Имплант зарегистрирован. Сохраните сертификат перед продолжением работы</p>
|
||||
<dl class="details">
|
||||
<dt>ID импланта</dt>
|
||||
<dd class="mono">${escapeHtml(data.id)}</dd>
|
||||
</dl>
|
||||
<label>Сертификат (PEM)
|
||||
<textarea class="mono" readonly rows="5">${escapeHtml(data.cert_pem)}</textarea>
|
||||
</label>
|
||||
<div class="actions">
|
||||
<button class="secondary" type="button" data-close-dialog>Закрыть</button>
|
||||
</div>
|
||||
</section>
|
||||
</dialog>`;
|
||||
|
||||
showResultDialog(result);
|
||||
} catch (error) {
|
||||
setError(problem, error.message);
|
||||
} finally {
|
||||
submit.disabled = false;
|
||||
submit.textContent = 'Выпустить сертификат';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
import { api } from '../../shared/api/client.js';
|
||||
import { state } from '../../shared/session.js';
|
||||
import { certificateStatus } from './certificate.js';
|
||||
import { dateTime, escapeHtml, readOnlyField } from '../../shared/ui/dom.js';
|
||||
|
||||
const view = document.querySelector('#view');
|
||||
|
||||
|
||||
export async function renderCard(id) {
|
||||
const route = location.pathname;
|
||||
view.innerHTML = '<section class="page"><div class="panel loading" aria-live="polite">Загружаем карточку…</div></section>';
|
||||
try {
|
||||
const base = '/implants/' + encodeURIComponent(id);
|
||||
const implant = await api(base);
|
||||
if (location.pathname !== route || !state.user) return;
|
||||
const certificate = implant.certificate;
|
||||
view.innerHTML = `<section class="page">
|
||||
<header class="page-header">
|
||||
<p class="eyebrow"><a href="/home/implants">Импланты</a> / Карточка</p>
|
||||
<h1>${escapeHtml(implant.display_name)}</h1>
|
||||
<p class="intro">Сведения об устройстве и сертификаты</p>
|
||||
</header>
|
||||
<section class="panel fields summary-panel">
|
||||
<div class="result-heading">
|
||||
<h2>Сведения об импланте</h2>
|
||||
<span class="status ${certificate.valid ? 'status-valid' : 'status-invalid'}">
|
||||
${escapeHtml(certificateStatus[certificate.status] || certificate.status)}
|
||||
</span>
|
||||
</div>
|
||||
<dl class="details">
|
||||
<dt>ID</dt><dd class="mono">${escapeHtml(id)}</dd>
|
||||
<dt>Модель</dt><dd>${escapeHtml(implant.model || 'Не указана')}</dd>
|
||||
<dt>Создан</dt><dd>${escapeHtml(dateTime(implant.created_at))}</dd>
|
||||
<dt>Сертификат</dt><dd>${escapeHtml(certificateStatus[certificate.status] || certificate.status)}</dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section class="panel fields">
|
||||
<h2>Публичный сертификат</h2>
|
||||
<dl class="details">
|
||||
<dt>Серийный номер</dt><dd class="mono">${escapeHtml(certificate.serial)}</dd>
|
||||
<dt>Действует до</dt><dd>${escapeHtml(dateTime(certificate.not_after))}</dd>
|
||||
<dt>SHA-256</dt><dd class="mono">${escapeHtml(certificate.fingerprint)}</dd>
|
||||
${certificate.revoked_at ? `<dt>Отозван</dt><dd>${escapeHtml(dateTime(certificate.revoked_at))}</dd>` : ''}
|
||||
</dl>
|
||||
${readOnlyField('Сертификат (PEM)', certificate.cert_pem, 4)}
|
||||
</section>
|
||||
</section>`;
|
||||
} catch (error) {
|
||||
if (location.pathname !== route) return;
|
||||
view.innerHTML = `<section class="page"><div class="panel fields">
|
||||
<p class="error" role="alert">${escapeHtml(error.message)}</p>
|
||||
<div><a class="text-link" href="/home/implants">Вернуться к имплантам</a></div>
|
||||
</div></section>`;
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
import { api } from '../../shared/api/client.js';
|
||||
import { escapeHtml, setError, readOnlyField, showResultDialog } from '../../shared/ui/dom.js';
|
||||
|
||||
const view = document.querySelector('#view');
|
||||
|
||||
export function renderHolder(wanted = '') {
|
||||
view.innerHTML = `<section class="page">
|
||||
<header class="page-header">
|
||||
<p class="eyebrow">/Проверка</p>
|
||||
<h1>Проверка</h1>
|
||||
<p class="intro">Проверьте данные своего сертификата</p>
|
||||
</header>
|
||||
<ol class="steps" aria-label="Порядок доступа">
|
||||
<li>Получите верификатор</li>
|
||||
<li>Подпишите строку закрытым ключом</li>
|
||||
<li>Отправьте подпись в base64</li>
|
||||
</ol>
|
||||
<form class="panel fields" id="challenge-form">
|
||||
<h2>Получить верификатор</h2>
|
||||
<label>ID импланта
|
||||
<input class="mono" id="holder-id" required spellcheck="false" autocomplete="off"
|
||||
value="${escapeHtml(wanted)}">
|
||||
</label>
|
||||
<button type="submit">Получить верификатор</button>
|
||||
</form>
|
||||
<form class="panel fields" id="holder-form" hidden>
|
||||
<h2>Подписать верификатор</h2>
|
||||
<div id="holder-challenge"></div>
|
||||
<label>Подпись в base64
|
||||
<textarea class="mono" id="holder-signature" required rows="4" spellcheck="false"></textarea>
|
||||
<small>Подпишите точную ASCII-строку выше закрытым ключом импланта</small>
|
||||
</label>
|
||||
<button type="submit">Посмотреть данные</button>
|
||||
</form>
|
||||
<p class="error" id="holder-error" role="alert" hidden></p>
|
||||
<div id="holder-result" aria-live="polite"></div>
|
||||
</section>`;
|
||||
const challengeForm = document.querySelector('#challenge-form');
|
||||
const holderForm = document.querySelector('#holder-form');
|
||||
const challengeField = document.querySelector('#holder-challenge');
|
||||
const result = document.querySelector('#holder-result');
|
||||
const problem = document.querySelector('#holder-error');
|
||||
let pending = null;
|
||||
challengeForm.addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
const button = challengeForm.querySelector('button');
|
||||
button.disabled = true;
|
||||
pending = null;
|
||||
holderForm.hidden = true;
|
||||
result.innerHTML = '';
|
||||
setError(problem, '');
|
||||
try {
|
||||
const id = document.querySelector('#holder-id').value.trim();
|
||||
const base = '/check_certificate/' + encodeURIComponent(id);
|
||||
const challenge = await api(base + '/check');
|
||||
pending = { id, nonce: challenge.challenge, certificate: challenge.certificate.cert_pem };
|
||||
history.replaceState(null, '', '/home/check_certificate/' + encodeURIComponent(id) + '/check');
|
||||
challengeField.innerHTML = readOnlyField('Сертификат (PEM)', pending.certificate, 4)
|
||||
+ readOnlyField('Верификатор: подпишите эту ASCII-строку', pending.nonce, 2);
|
||||
document.querySelector('#holder-signature').value = '';
|
||||
holderForm.hidden = false;
|
||||
} catch (error) {
|
||||
setError(problem, error.message);
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
}
|
||||
});
|
||||
holderForm.addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
if (!pending) return;
|
||||
const button = holderForm.querySelector('button');
|
||||
button.disabled = true;
|
||||
setError(problem, '');
|
||||
try {
|
||||
const data = await api('/check_certificate/' + encodeURIComponent(pending.id) + '/check', {
|
||||
method: 'POST', body: { certificate: pending.certificate, nonce: pending.nonce,
|
||||
signature: document.querySelector('#holder-signature').value.trim() },
|
||||
});
|
||||
result.innerHTML = `
|
||||
<dialog class="issue-dialog" aria-labelledby="holder-result-title">
|
||||
<section class="panel fields" aria-live="polite">
|
||||
<h2 id="holder-result-title">Данные импланта</h2>
|
||||
${readOnlyField('Код проекта', data.project_codename, 1)}
|
||||
${readOnlyField('Код организации', data.installed_by, 1)}
|
||||
<div class="actions">
|
||||
<button class="secondary" type="button" data-close-dialog>Закрыть</button>
|
||||
</div>
|
||||
</section>
|
||||
</dialog>`;
|
||||
|
||||
showResultDialog(result);
|
||||
pending = null;
|
||||
holderForm.hidden = true;
|
||||
} catch (error) {
|
||||
setError(problem, error.message);
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
}
|
||||
});
|
||||
if (wanted) challengeForm.requestSubmit();
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
import { api } from '../../shared/api/client.js';
|
||||
import { state } from '../../shared/session.js';
|
||||
import { dateTime, escapeHtml } from '../../shared/ui/dom.js';
|
||||
|
||||
const view = document.querySelector('#view');
|
||||
|
||||
export async function renderList() {
|
||||
view.innerHTML = `<section class="page">
|
||||
<header class="page-header page-header-row">
|
||||
<div>
|
||||
<h1>Мои <span>импланты</span></h1>
|
||||
<p class="intro">Управляйте сертификатами зарегистрированных устройств</p>
|
||||
</div>
|
||||
<a class="button-link" id="implant-add" href="/home/register_implant" hidden>Добавить имплант</a>
|
||||
</header>
|
||||
<div class="record-list" id="implant-list" aria-live="polite">
|
||||
<p class="panel loading">Загружаем импланты…</p>
|
||||
</div>
|
||||
</section>`;
|
||||
const list = document.querySelector('#implant-list');
|
||||
const add = document.querySelector('#implant-add');
|
||||
try {
|
||||
const { implants } = await api('/implants');
|
||||
if (!list.isConnected || !state.user) return;
|
||||
add.hidden = !implants.length;
|
||||
list.innerHTML = implants.map((implant) => `
|
||||
<article class="panel fields">
|
||||
<div class="record-heading">
|
||||
<div>
|
||||
<h2>${escapeHtml(implant.display_name)}</h2>
|
||||
<p>${escapeHtml(implant.model || 'Модель не указана')}</p>
|
||||
</div>
|
||||
<a class="text-link" href="/home/implants/${encodeURIComponent(implant.id)}">Открыть карточку</a>
|
||||
</div>
|
||||
<dl class="details compact-details">
|
||||
<dt>ID</dt><dd class="mono">${escapeHtml(implant.id)}</dd>
|
||||
<dt>Создан</dt><dd>${escapeHtml(dateTime(implant.created_at))}</dd>
|
||||
</dl>
|
||||
</article>`).join('') || `
|
||||
<div class="panel empty-state fields">
|
||||
<h2>Имплантов пока нет</h2>
|
||||
<p>Добавьте первый имплант, чтобы выпустить сертификат</p>
|
||||
<div><a class="button-link" href="/home/register_implant">Добавить имплант</a></div>
|
||||
</div>`;
|
||||
} catch (error) {
|
||||
if (list.isConnected) list.innerHTML = `<p class="panel error" role="alert">${escapeHtml(error.message)}</p>`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import { api } from '../../shared/api/client.js';
|
||||
import { state } from '../../shared/session.js';
|
||||
import { certificateStatus } from './certificate.js';
|
||||
import { dateTime, escapeHtml, readOnlyField } from '../../shared/ui/dom.js';
|
||||
|
||||
const view = document.querySelector('#view');
|
||||
|
||||
export async function renderRegistry() {
|
||||
view.innerHTML = `<section class="page">
|
||||
<header class="page-header">
|
||||
<p class="eyebrow">/Реестр</p>
|
||||
<h1>Публичные <span>сертификаты</span></h1>
|
||||
<p class="intro">Импланты всех пользователей и история выпущенных сертификатов</p>
|
||||
</header>
|
||||
<div class="record-list" id="registry-list" aria-live="polite">
|
||||
<p class="panel loading">Загружаем реестр…</p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="secondary" id="registry-prev" type="button" disabled>Назад</button>
|
||||
<span id="registry-page" aria-live="polite"></span>
|
||||
<button class="secondary" id="registry-next" type="button" disabled>Далее</button>
|
||||
</div>
|
||||
</section>`;
|
||||
const list = document.querySelector('#registry-list');
|
||||
const previous = document.querySelector('#registry-prev');
|
||||
const next = document.querySelector('#registry-next');
|
||||
const counter = document.querySelector('#registry-page');
|
||||
try {
|
||||
const { results } = await api('/registry');
|
||||
if (!list.isConnected || !state.user) return;
|
||||
let page = 0;
|
||||
const renderPage = () => {
|
||||
list.innerHTML = results.slice(page * 20, (page + 1) * 20).map((implant) => `
|
||||
<article class="panel fields">
|
||||
<div class="record-heading">
|
||||
<h2>${escapeHtml(implant.display_name)}</h2>
|
||||
<span class="counter">${implant.certificates.length}</span>
|
||||
</div>
|
||||
<dl class="details">
|
||||
<dt>ID импланта</dt><dd class="mono">${escapeHtml(implant.id)}</dd>
|
||||
<dt>Модель</dt><dd>${escapeHtml(implant.model || 'Не указана')}</dd>
|
||||
<dt>Владелец</dt><dd>${escapeHtml(implant.owner)}</dd>
|
||||
<dt>Создан</dt><dd>${escapeHtml(dateTime(implant.created_at))}</dd>
|
||||
</dl>
|
||||
${implant.certificates.map((certificate) => `
|
||||
<details class="certificate-record">
|
||||
<summary>
|
||||
<span class="mono">${escapeHtml(certificate.serial)}</span>
|
||||
<span class="status ${certificate.valid ? 'status-valid' : 'status-invalid'}">${escapeHtml(certificateStatus[certificate.status] || certificate.status)}</span>
|
||||
</summary>
|
||||
<div class="fields">
|
||||
<dl class="details">
|
||||
<dt>SHA-256</dt><dd class="mono">${escapeHtml(certificate.fingerprint)}</dd>
|
||||
<dt>Субъект</dt><dd>${escapeHtml(certificate.subject)}</dd>
|
||||
<dt>Удостоверяющий центр</dt><dd>${escapeHtml(certificate.issuer)}</dd>
|
||||
<dt>Действует с</dt><dd>${escapeHtml(dateTime(certificate.not_before))}</dd>
|
||||
<dt>Действует до</dt><dd>${escapeHtml(dateTime(certificate.not_after))}</dd>
|
||||
${certificate.revoked_at ? `<dt>Отозван</dt><dd>${escapeHtml(dateTime(certificate.revoked_at))}</dd>` : ''}
|
||||
</dl>
|
||||
${readOnlyField('Сертификат (PEM)', certificate.cert_pem, 4)}
|
||||
</div>
|
||||
</details>`).join('')}
|
||||
</article>`).join('') || '<div class="panel empty-state">В реестре пока нет имплантов</div>';
|
||||
previous.disabled = page === 0;
|
||||
next.disabled = (page + 1) * 20 >= results.length;
|
||||
counter.textContent = `Страница ${page + 1} из ${Math.max(1, Math.ceil(results.length / 20))} · Имплантов: ${results.length}`;
|
||||
};
|
||||
previous.addEventListener('click', () => { if (page > 0) { page -= 1; renderPage(); } });
|
||||
next.addEventListener('click', () => { if ((page + 1) * 20 < results.length) { page += 1; renderPage(); } });
|
||||
renderPage();
|
||||
} catch (error) {
|
||||
if (list.isConnected) list.innerHTML = `<p class="panel error" role="alert">${escapeHtml(error.message)}</p>`;
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
import { api } from '../../shared/api/client.js';
|
||||
import { escapeHtml, setError, readOnlyField, showResultDialog } from '../../shared/ui/dom.js';
|
||||
|
||||
const view = document.querySelector('#view');
|
||||
|
||||
export function renderReissue(wanted = '', serial = '') {
|
||||
view.innerHTML = `<section class="page">
|
||||
<header class="page-header">
|
||||
<p class="eyebrow">/Перевыпуск</p>
|
||||
<h1>Перевыпуск</h1>
|
||||
</header>
|
||||
<form class="panel fields" id="reissue-form">
|
||||
<label>ID импланта
|
||||
<input class="mono" id="reissue-id" required spellcheck="false" autocomplete="off" value="${escapeHtml(wanted)}">
|
||||
</label>
|
||||
<label>Серийный номер текущего сертификата
|
||||
<input class="mono" id="reissue-serial" required maxlength="40" pattern="[0-9a-f]+"
|
||||
spellcheck="false" autocomplete="off" value="${escapeHtml(serial)}">
|
||||
</label>
|
||||
<label>Подписанный CSR (PEM)
|
||||
<textarea class="mono" id="reissue-csr" required rows="6" maxlength="60000" spellcheck="false"
|
||||
placeholder="-----BEGIN CERTIFICATE REQUEST-----"></textarea>
|
||||
</label>
|
||||
<label>Подпись текущим ключом в base64
|
||||
<textarea class="mono" id="reissue-signature" required rows="4" spellcheck="false"></textarea>
|
||||
<small><a class="text-link" id="signature-rules-link" href="#signature-rules">Правила подписи</a></small>
|
||||
</label>
|
||||
<button type="submit">Перевыпустить сертификат</button>
|
||||
</form>
|
||||
<dialog class="issue-dialog" id="signature-rules" aria-labelledby="signature-rules-title">
|
||||
<section class="panel fields">
|
||||
<h2 id="signature-rules-title">Правила подписи</h2>
|
||||
<p>Вычислите SHA-256 от DER-представления подписанного CSR. Запишите хеш строчными шестнадцатеричными символами.</p>
|
||||
<p>Подставьте ID импланта, серийный номер текущего сертификата и хеш в ASCII-строку без перевода строки в конце:</p>
|
||||
<code>reissue:<ID импланта>:<серийный номер>:<SHA256(CSR_DER)></code>
|
||||
<p>Подпишите строку текущим закрытым ключом импланта: ECDSA с SHA-256 или RSA PKCS#1 v1.5 с SHA-256</p>
|
||||
<p>Преобразуйте полученную подпись в Base64 и вставьте её в поле «Подпись текущим ключом в base64»</p>
|
||||
<div class="actions">
|
||||
<button class="secondary" type="button" data-close-dialog>Закрыть</button>
|
||||
</div>
|
||||
</section>
|
||||
</dialog>
|
||||
<p class="error" id="reissue-error" role="alert" hidden></p>
|
||||
<div id="reissue-result" aria-live="polite"></div>
|
||||
</section>`;
|
||||
const form = document.querySelector('#reissue-form');
|
||||
const result = document.querySelector('#reissue-result');
|
||||
const problem = document.querySelector('#reissue-error');
|
||||
const rules = document.querySelector('#signature-rules');
|
||||
document.querySelector('#signature-rules-link').addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
rules.showModal();
|
||||
});
|
||||
rules.querySelector('[data-close-dialog]').addEventListener('click', () => rules.close());
|
||||
form.addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
const button = form.querySelector('button');
|
||||
button.disabled = true;
|
||||
result.innerHTML = '';
|
||||
setError(problem, '');
|
||||
try {
|
||||
const id = document.querySelector('#reissue-id').value.trim();
|
||||
const data = await api('/reissue/' + encodeURIComponent(id), {
|
||||
method: 'POST', body: { csr_pem: document.querySelector('#reissue-csr').value.trim(),
|
||||
certificate_serial: document.querySelector('#reissue-serial').value.trim(),
|
||||
signature: document.querySelector('#reissue-signature').value.trim() },
|
||||
});
|
||||
const certificate = data.certificate;
|
||||
result.innerHTML = `<dialog class="issue-dialog" aria-labelledby="reissue-result-title">
|
||||
<section class="panel fields">
|
||||
<h2 id="reissue-result-title">Сертификат перевыпущен</h2>
|
||||
${[
|
||||
['ID импланта', data.id], ['Название', data.display_name], ['Модель', data.model],
|
||||
['Владелец', data.owner], ['ID владельца', data.user_id], ['Создан', data.created_at],
|
||||
['Код проекта', data.project_codename], ['Код организации', data.installed_by],
|
||||
['Владелец сертификата', certificate.subject], ['Издатель', certificate.issuer],
|
||||
['Серийный номер', certificate.serial], ['Действует с', certificate.not_before],
|
||||
['Действует до', certificate.not_after], ['Статус', certificate.valid ? 'Действует' : 'Недействителен'],
|
||||
['SHA-256', certificate.fingerprint],
|
||||
].map(([label, value]) => readOnlyField(label, value, 1)).join('')}
|
||||
${readOnlyField('Сертификат (PEM)', data.cert_pem, 4)}
|
||||
<div class="actions">
|
||||
<button class="secondary" type="button" data-close-dialog>Закрыть</button>
|
||||
</div>
|
||||
</section>
|
||||
</dialog>`;
|
||||
showResultDialog(result);
|
||||
document.querySelector('#reissue-serial').value = certificate.serial;
|
||||
document.querySelector('#reissue-signature').value = '';
|
||||
} catch (error) {
|
||||
setError(problem, error.message);
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import { state, setSession } from '../session.js';
|
||||
|
||||
export async function api(path, { method = 'GET', body } = {}) {
|
||||
if (path !== '/login' && path !== '/register') path = '/home/api' + path;
|
||||
const token = state.token;
|
||||
let response;
|
||||
try {
|
||||
response = await fetch(path, {
|
||||
method,
|
||||
credentials: 'omit',
|
||||
headers: {
|
||||
...(body === undefined ? {} : { 'Content-Type': 'application/json' }),
|
||||
...(token ? { Authorization: 'Bearer ' + token } : {}),
|
||||
},
|
||||
body: body === undefined ? undefined : JSON.stringify(body),
|
||||
});
|
||||
} catch {
|
||||
throw new Error('Нет связи с Chrome Ledger');
|
||||
}
|
||||
if (response.status === 204) return null;
|
||||
const data = await response.json().catch(() => null);
|
||||
if (!response.ok || data === null) {
|
||||
if (response.status === 401 && token && state.token === token && data && data.error === 'Authentication required') {
|
||||
setSession(null);
|
||||
window.dispatchEvent(new Event('ledger:session-expired'));
|
||||
}
|
||||
if (data && data.error) {
|
||||
throw new Error(data.error);
|
||||
}
|
||||
throw new Error('Сервис вернул неожиданный ответ');
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
export const state = { user: null, token: sessionStorage.getItem('ledger-token') };
|
||||
|
||||
export function setSession(data) {
|
||||
state.user = data ? { id: data.id, username: data.username } : null;
|
||||
state.token = data ? data.access_token : null;
|
||||
if (state.token) sessionStorage.setItem('ledger-token', state.token);
|
||||
else sessionStorage.removeItem('ledger-token');
|
||||
}
|
||||
+476
@@ -0,0 +1,476 @@
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
font-family: var(--sans);
|
||||
--sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
--text: #e8eef6;
|
||||
--ink: #080b11;
|
||||
--panel: #10151e;
|
||||
--line: #303b4b;
|
||||
--muted: #aeb9c8;
|
||||
--accent: #9db2c9;
|
||||
--accent-edge: #5b7794;
|
||||
--signal: #89b1ad;
|
||||
--danger: #d99cac;
|
||||
color: var(--text);
|
||||
background: var(--ink);
|
||||
--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
|
||||
--gutter: clamp(16px, 4vw, 56px);
|
||||
}
|
||||
|
||||
*, *::before, *::after { box-sizing: border-box; }
|
||||
body { margin: 0; min-width: 280px; }
|
||||
button, input, textarea, select { font: inherit; }
|
||||
a { color: inherit; }
|
||||
[hidden] { display: none !important; }
|
||||
|
||||
.layout {
|
||||
min-height: 100vh;
|
||||
background:
|
||||
radial-gradient(ellipse at 97% 53%, #32293d49, transparent 42%),
|
||||
radial-gradient(ellipse at 70% 12%, #1b313e65, transparent 45%),
|
||||
linear-gradient(#9db2c909 1px, transparent 1px),
|
||||
linear-gradient(90deg, #9db2c909 1px, transparent 1px),
|
||||
var(--ink);
|
||||
background-size: auto, auto, 44px 44px, 44px 44px, auto;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
border-bottom: 1px solid var(--line);
|
||||
background: #0c1018f5;
|
||||
backdrop-filter: blur(12px);
|
||||
}
|
||||
|
||||
.topbar-inner {
|
||||
max-width: 1440px;
|
||||
min-height: 74px;
|
||||
margin-inline: auto;
|
||||
padding-inline: var(--gutter);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: clamp(16px, 4vw, 54px);
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 11px;
|
||||
color: var(--accent);
|
||||
font: 21px var(--mono);
|
||||
letter-spacing: -.07em;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.brand-mark {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex: 0 0 auto;
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
background: var(--accent);
|
||||
clip-path: polygon(23% 0, 100% 0, 100% 77%, 77% 100%, 0 100%, 0 23%);
|
||||
}
|
||||
|
||||
.brand-mark::after {
|
||||
content: '';
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background: var(--ink);
|
||||
clip-path: polygon(30% 0, 100% 0, 100% 29%, 44% 29%, 29% 44%, 29% 71%, 100% 71%, 100% 100%, 0 100%, 0 30%);
|
||||
}
|
||||
|
||||
#nav { display: flex; align-self: stretch; gap: 4px; align-items: stretch; }
|
||||
#nav a {
|
||||
display: grid;
|
||||
align-content: center;
|
||||
padding: 10px 12px;
|
||||
border-block: 2px solid transparent;
|
||||
color: var(--muted);
|
||||
font: 14px var(--mono);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#nav a:hover { color: var(--signal); }
|
||||
#nav a.active {
|
||||
color: var(--signal);
|
||||
border-bottom-color: var(--signal);
|
||||
background: #89b1ad12;
|
||||
}
|
||||
|
||||
.account {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 13px;
|
||||
color: var(--muted);
|
||||
font: 13px var(--mono);
|
||||
}
|
||||
|
||||
.account span { overflow-wrap: anywhere; min-width: 0; }
|
||||
.account-login { color: var(--signal); font: 14px var(--mono); text-underline-offset: 4px; }
|
||||
|
||||
.workspace {
|
||||
width: min(100%, 1380px);
|
||||
margin: 0 auto;
|
||||
padding: clamp(32px, 5vw, 70px) var(--gutter) 64px;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 860px) minmax(260px, 360px);
|
||||
gap: clamp(20px, 4vw, 58px);
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.content { min-width: 0; }
|
||||
.content > .error { margin-bottom: 15px; }
|
||||
.signed-out .workspace {
|
||||
grid-template-columns: minmax(0, 510px) minmax(0, 440px);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: calc(100vh - 75px);
|
||||
}
|
||||
|
||||
.circuit {
|
||||
--trace: #89b1ad19;
|
||||
position: sticky;
|
||||
top: 24px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
aspect-ratio: 4 / 5;
|
||||
overflow: hidden;
|
||||
border: 1px solid #3a555e;
|
||||
background:
|
||||
linear-gradient(135deg, #9db2c90a 0 39%, transparent 39% 75%, #77628418 75%),
|
||||
repeating-linear-gradient(0deg, transparent 0 27px, var(--trace) 28px, transparent 29px),
|
||||
repeating-linear-gradient(90deg, transparent 0 27px, var(--trace) 28px, transparent 29px),
|
||||
radial-gradient(ellipse at 52% 46%, #20343e, #0b111b 68%);
|
||||
clip-path: polygon(0 0, calc(100% - 30px) 0, 100% 30px, 100% 100%, 30px 100%, 0 calc(100% - 30px));
|
||||
isolation: isolate;
|
||||
}
|
||||
|
||||
.circuit::before, .circuit::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 14px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.circuit::before {
|
||||
border: 1px solid #89b1ad36;
|
||||
background:
|
||||
linear-gradient(90deg, var(--signal) 0 27px, transparent 27px) top left,
|
||||
linear-gradient(270deg, var(--accent-edge) 0 32px, transparent 32px) bottom right;
|
||||
background-size: 100% 2px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.circuit::after {
|
||||
inset: 25px;
|
||||
border: 1px dashed #89b1ad2e;
|
||||
}
|
||||
|
||||
.chip {
|
||||
z-index: 1;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 48%;
|
||||
aspect-ratio: 1;
|
||||
transform: rotate(-24deg);
|
||||
border: 1px solid #5d7f86;
|
||||
background: #111923;
|
||||
box-shadow: inset 0 0 25px #89b1ad20, 0 0 45px #89b1ad22, 7px 8px 0 #77628430;
|
||||
}
|
||||
|
||||
.chip::before, .chip::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 140%;
|
||||
height: 58%;
|
||||
background: repeating-linear-gradient(0deg, var(--signal) 0 1px, transparent 1px 11px);
|
||||
z-index: -1;
|
||||
opacity: .38;
|
||||
}
|
||||
|
||||
.chip::after { transform: rotate(90deg); }
|
||||
.chip span {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 74%;
|
||||
aspect-ratio: 1;
|
||||
border: 1px solid #496d73;
|
||||
background: #121d2a;
|
||||
box-shadow: 0 0 0 4px #0a141e;
|
||||
}
|
||||
|
||||
.chip span::after {
|
||||
content: '';
|
||||
width: 65%;
|
||||
aspect-ratio: 1;
|
||||
background: var(--accent-edge);
|
||||
clip-path: polygon(27% 0, 100% 0, 100% 29%, 40% 29%, 29% 40%, 29% 71%, 100% 71%, 100% 100%, 0 100%, 0 27%);
|
||||
}
|
||||
|
||||
.scanline {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
inset: 12% 14px auto;
|
||||
height: 2px;
|
||||
opacity: 0;
|
||||
background: linear-gradient(90deg, transparent, var(--signal), transparent);
|
||||
box-shadow: 0 0 18px #89b1ad47;
|
||||
animation: scan 8s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes scan {
|
||||
0%, 15% { top: 12%; opacity: 0; }
|
||||
27% { opacity: .4; }
|
||||
65% { opacity: .4; }
|
||||
78%, 100% { top: 87%; opacity: 0; }
|
||||
}
|
||||
|
||||
h1, h2, p, dl { margin: 0; }
|
||||
h1 {
|
||||
font-size: clamp(34px, 4vw, 56px);
|
||||
font-weight: 800;
|
||||
line-height: .98;
|
||||
letter-spacing: -.065em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
h1 span { display: block; color: var(--accent); }
|
||||
h2 { font-size: 20px; font-weight: 800; }
|
||||
.page-header { margin-bottom: 26px; }
|
||||
.welcome { text-align: center; }
|
||||
.page-header-row { display: flex; justify-content: space-between; align-items: end; gap: 24px; }
|
||||
.page-header-row .button-link { flex: 0 0 auto; margin-bottom: 4px; }
|
||||
.intro { color: var(--muted); max-width: 62ch; margin-top: 14px; line-height: 1.6; }
|
||||
.eyebrow {
|
||||
margin-bottom: 11px;
|
||||
color: var(--signal);
|
||||
font: 700 13px/1.4 var(--mono);
|
||||
letter-spacing: .04em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.eyebrow a { text-underline-offset: 4px; }
|
||||
.mono { font-family: var(--mono); }
|
||||
.valid { color: var(--signal); }
|
||||
.invalid, .error { color: var(--danger); }
|
||||
.error { overflow-wrap: anywhere; border-left: 2px solid var(--danger); padding-left: 10px; }
|
||||
.muted { color: var(--muted); }
|
||||
|
||||
.panel {
|
||||
position: relative;
|
||||
border: 1px solid var(--line);
|
||||
border-top-color: #435568;
|
||||
padding: clamp(16px, 2.15vw, 29px);
|
||||
background: linear-gradient(135deg, #9db2c908, transparent 55%), var(--panel);
|
||||
box-shadow: 5px 5px 0 #070910;
|
||||
}
|
||||
|
||||
.panel::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -1px;
|
||||
left: -1px;
|
||||
width: 64px;
|
||||
height: 2px;
|
||||
background: var(--signal);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.panel::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: auto -1px -1px auto;
|
||||
width: 45px;
|
||||
height: 11px;
|
||||
background: repeating-linear-gradient(125deg, var(--accent-edge) 0 2px, transparent 2px 6px);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.panel + .panel { margin-top: 21px; }
|
||||
.record-list { margin-top: 24px; }
|
||||
.record-list { display: grid; gap: 18px; }
|
||||
.record-list .panel + .panel { margin-top: 0; }
|
||||
.certificate-record { padding-top: 2px; }
|
||||
.certificate-record + .certificate-record { padding-top: 22px; border-top: 1px solid var(--line); }
|
||||
.certificate-record > summary { cursor: pointer; }
|
||||
.certificate-record > summary .status { margin-left: 12px; vertical-align: middle; }
|
||||
.certificate-record > .fields { margin-top: 17px; padding-left: 20px; }
|
||||
#holder-error { margin-top: 16px; }
|
||||
.fields { display: grid; gap: 17px; min-width: 0; }
|
||||
.fields > label, .readonly-field { display: grid; gap: 8px; min-width: 0; }
|
||||
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
|
||||
.field-grid > label { display: grid; gap: 8px; }
|
||||
label { font-size: 14px; font-weight: 600; }
|
||||
small { color: var(--muted); font: 400 13px/1.45 var(--sans); }
|
||||
.optional { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }
|
||||
|
||||
input, textarea, select {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
background: #0b1019;
|
||||
border: 1px solid var(--line);
|
||||
border-left: 2px solid #486071;
|
||||
border-radius: 0;
|
||||
color: var(--text);
|
||||
padding: 11px 12px;
|
||||
line-height: 1.5;
|
||||
transition: border-color .16s, background-color .16s;
|
||||
}
|
||||
|
||||
input::placeholder, textarea::placeholder { color: #929fb3; }
|
||||
textarea { display: block; resize: vertical; overflow-wrap: anywhere; }
|
||||
textarea.mono, input.mono, select.mono { font-size: 13px; }
|
||||
textarea[readonly] { background: #0f1724; }
|
||||
select {
|
||||
appearance: none;
|
||||
padding-right: 42px;
|
||||
background-image:
|
||||
linear-gradient(45deg, transparent 50%, var(--muted) 50%),
|
||||
linear-gradient(135deg, var(--muted) 50%, transparent 50%);
|
||||
background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
|
||||
background-size: 5px 5px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
input:focus, textarea:focus, select:focus { border-color: var(--signal); background: #101923; }
|
||||
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
|
||||
|
||||
button, .button-link {
|
||||
position: relative;
|
||||
border: 1px solid var(--accent-edge);
|
||||
border-radius: 0;
|
||||
padding: 10px 15px;
|
||||
font-weight: 800;
|
||||
font-size: 13px;
|
||||
background: #2b4056;
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
transition: color .16s, background-color .16s, box-shadow .16s;
|
||||
}
|
||||
|
||||
button:hover, .button-link:hover { background: #36516b; box-shadow: 3px 3px 0 #151f2b; }
|
||||
button:disabled { opacity: .64; cursor: wait; }
|
||||
button.secondary { background: #121a25; border-color: #486071; color: var(--accent); }
|
||||
button.secondary:hover { background: #1c2a38; box-shadow: none; }
|
||||
.button-link { display: inline-block; text-decoration: none; }
|
||||
.text-link { color: var(--signal); font: 14px var(--mono); text-underline-offset: 4px; }
|
||||
.text-link:hover { color: var(--accent); }
|
||||
|
||||
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
|
||||
.public-actions { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-top: 20px; }
|
||||
.details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 12px 20px; font-size: 14px; }
|
||||
.details dt { color: var(--muted); }
|
||||
.details dd { margin: 0; overflow-wrap: anywhere; }
|
||||
.compact-details { padding-top: 15px; border-top: 1px solid var(--line); }
|
||||
.record-heading, .result-heading {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: start;
|
||||
gap: 18px;
|
||||
}
|
||||
.record-heading p { margin-top: 7px; color: var(--muted); }
|
||||
.status {
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
min-height: 28px;
|
||||
padding: 4px 9px;
|
||||
border: 1px solid var(--line);
|
||||
font: 700 12px var(--mono);
|
||||
}
|
||||
.status-valid { color: #a9d7d1; border-color: #466d6b; background: #142523; }
|
||||
.status-invalid { color: #efb4c2; border-color: #754553; background: #28181e; }
|
||||
.counter {
|
||||
min-width: 28px;
|
||||
padding: 4px 8px;
|
||||
text-align: center;
|
||||
border: 1px solid var(--line);
|
||||
color: var(--muted);
|
||||
font: 13px var(--mono);
|
||||
}
|
||||
.notice {
|
||||
padding: 12px 14px;
|
||||
border-left: 2px solid var(--accent-edge);
|
||||
background: #172130;
|
||||
color: #cbd6e4;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.success-message { color: #b8d8d4; line-height: 1.5; }
|
||||
.empty-state { padding-block: 34px; }
|
||||
.loading { color: var(--muted); }
|
||||
.steps {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 1px;
|
||||
margin: 0 0 21px;
|
||||
padding: 1px;
|
||||
list-style-position: inside;
|
||||
background: var(--line);
|
||||
}
|
||||
.steps li { padding: 13px 14px; background: #0d131c; color: var(--muted); font-size: 13px; line-height: 1.45; }
|
||||
|
||||
.issue-dialog {
|
||||
width: min(760px, calc(100vw - 32px));
|
||||
max-width: none;
|
||||
max-height: calc(100vh - 32px);
|
||||
padding: 0;
|
||||
border: 0;
|
||||
color: var(--text);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.issue-dialog::backdrop {
|
||||
background: #02050bcc;
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.issue-dialog > .panel {
|
||||
max-height: calc(100vh - 32px);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.topbar-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; min-height: 64px; }
|
||||
#nav { grid-row: 2; grid-column: 1 / -1; flex-wrap: wrap; }
|
||||
#nav a { padding-inline: 8px; }
|
||||
.brand, .account { margin-block: 12px; }
|
||||
.workspace, .signed-out .workspace { grid-template-columns: minmax(0, 1fr) minmax(0, .55fr); }
|
||||
.signed-out .workspace { min-height: auto; }
|
||||
.circuit { top: 16px; }
|
||||
}
|
||||
|
||||
@media (max-width: 650px) {
|
||||
.workspace, .signed-out .workspace { position: relative; display: block; isolation: isolate; }
|
||||
.content { position: relative; z-index: 1; }
|
||||
.circuit {
|
||||
width: 125px;
|
||||
position: absolute;
|
||||
top: 14px;
|
||||
right: var(--gutter);
|
||||
opacity: .29;
|
||||
pointer-events: none;
|
||||
mask-image: linear-gradient(225deg, #000, transparent 86%);
|
||||
}
|
||||
.circuit::before, .circuit::after { inset: 7px; }
|
||||
.scanline { display: none; }
|
||||
}
|
||||
|
||||
@media (max-width: 415px) {
|
||||
.brand { min-width: 0; font-size: 17px; gap: 6px; line-height: 1.05; white-space: normal; }
|
||||
.brand-mark { width: 20px; height: 20px; }
|
||||
.brand-mark::after { width: 12px; height: 12px; }
|
||||
.account { max-width: 46vw; gap: 7px; font-size: 12px; }
|
||||
.account button { padding-inline: 9px; }
|
||||
#nav a { font-size: 11px; padding-inline: 6px; }
|
||||
h1 { font-size: clamp(27px, 9vw, 32px); }
|
||||
.details { grid-template-columns: minmax(0, 1fr); gap: 3px; }
|
||||
.details dd + dt { margin-top: 9px; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.scanline { animation: none; }
|
||||
input, textarea, select, button { transition: none; }
|
||||
}
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
const dateFormat = new Intl.DateTimeFormat('ru-RU', {
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'short',
|
||||
timeZone: 'UTC',
|
||||
});
|
||||
|
||||
export function dateTime(value) {
|
||||
return dateFormat.format(new Date(value)) + ' UTC';
|
||||
}
|
||||
|
||||
export function escapeHtml(value) {
|
||||
if (value === null || value === undefined) {
|
||||
return '';
|
||||
}
|
||||
return String(value).replace(/[&<>"']/g, (character) => ({
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
})[character]);
|
||||
}
|
||||
|
||||
export function setError(element, message) {
|
||||
element.textContent = message;
|
||||
element.hidden = !message;
|
||||
}
|
||||
|
||||
export function readOnlyField(label, value, rows = 3) {
|
||||
return `<label class="readonly-field">${escapeHtml(label)}
|
||||
<textarea class="mono" readonly rows="${rows}">${escapeHtml(value)}</textarea>
|
||||
</label>`;
|
||||
}
|
||||
|
||||
export function showResultDialog(container) {
|
||||
const dialog = container.querySelector('dialog');
|
||||
dialog.querySelector('[data-close-dialog]').addEventListener('click', () => dialog.close());
|
||||
dialog.addEventListener('close', () => dialog.remove(), { once: true });
|
||||
dialog.showModal();
|
||||
}
|
||||
Reference in new issue
Block a user