SHA256
Обновить pairing устройств и доработать ESP32 UI
This commit is contained in:
@@ -362,7 +362,7 @@ async function startPairing({ login, usePassword, password }) {
|
||||
|
||||
state.pairingId = String(payload?.pairingId || '').trim();
|
||||
state.expiresAtMs = Number(payload?.expiresAtMs || 0);
|
||||
state.shortCode = String(payload?.shortCode || '0000000');
|
||||
state.shortCode = String(payload?.shortCode || '');
|
||||
state.trustedSessionOnline = !!payload?.trustedSessionOnline;
|
||||
if (!state.pairingId) {
|
||||
throw new Error('Сервер не вернул pairingId.');
|
||||
@@ -375,7 +375,7 @@ async function startPairing({ login, usePassword, password }) {
|
||||
setStatus('Wallet-session заявка создана. Ожидаем подтверждение на доверенном устройстве.', 'info');
|
||||
return {
|
||||
pairingId: state.pairingId,
|
||||
shortCode: String(payload?.shortCode || '0000000'),
|
||||
shortCode: String(payload?.shortCode || ''),
|
||||
expiresAtMs: state.expiresAtMs,
|
||||
trustedSessionOnline: !!payload?.trustedSessionOnline,
|
||||
};
|
||||
|
||||
@@ -59,6 +59,15 @@ export async function createRequesterPairingMaterial() {
|
||||
};
|
||||
}
|
||||
|
||||
export function normalizePairingShortCode(value, digits = 10) {
|
||||
return String(value || '').replace(/\D+/g, '').slice(0, digits).padStart(digits, '0');
|
||||
}
|
||||
|
||||
export function formatPairingShortCode(value) {
|
||||
const normalized = normalizePairingShortCode(value, 10);
|
||||
return normalized.match(/.{1,2}/g)?.join(' ') || normalized;
|
||||
}
|
||||
|
||||
export async function deriveEspPairingPasswordHash(login, password) {
|
||||
const loginLower = String(login || '').trim().toLowerCase();
|
||||
const preimage = `${PAIRING_HASH_VERSION}|${loginLower}|${String(password ?? '')}`;
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
|
||||
<div id="pairing-card" class="card hidden">
|
||||
<div class="card-title">Код подключения</div>
|
||||
<div id="short-code" class="code">0000000</div>
|
||||
<div id="short-code" class="code">00 00 00 00 00</div>
|
||||
<p id="pairing-hint" class="muted small">
|
||||
Покажите код на доверенном устройстве в разделе «Подключить по коду».
|
||||
</p>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { formatPairingShortCode } from './js/lib/device-pairing.js';
|
||||
|
||||
const els = {
|
||||
serverLoginInfo: document.querySelector('#server-login-info'),
|
||||
serverAddress: document.querySelector('#server-address'),
|
||||
@@ -159,9 +161,9 @@ function applyState(nextState) {
|
||||
const pairing = state?.pairing || {};
|
||||
if (pairing.active) {
|
||||
els.pairingCard.classList.remove('hidden');
|
||||
const shortCode = String(pairing.shortCode || els.shortCode.dataset.shortCode || els.shortCode.textContent || '0000000');
|
||||
const shortCode = String(pairing.shortCode || els.shortCode.dataset.shortCode || els.shortCode.textContent || '');
|
||||
els.shortCode.dataset.shortCode = shortCode;
|
||||
els.shortCode.textContent = shortCode;
|
||||
els.shortCode.textContent = formatPairingShortCode(shortCode);
|
||||
els.pairingHint.textContent = pairing.trustedSessionOnline
|
||||
? 'Покажите код на доверенном устройстве и подтвердите выпуск wallet-session.'
|
||||
: 'Сейчас нет онлайн доверенной сессии. Откройте другое устройство и подтвердите заявку.';
|
||||
@@ -170,7 +172,7 @@ function applyState(nextState) {
|
||||
els.startBtn.disabled = true;
|
||||
} else {
|
||||
els.pairingCard.classList.add('hidden');
|
||||
els.shortCode.textContent = '0000000';
|
||||
els.shortCode.textContent = formatPairingShortCode('');
|
||||
delete els.shortCode.dataset.shortCode;
|
||||
els.pairingExpire.textContent = '';
|
||||
els.startBtn.disabled = false;
|
||||
|
||||
Reference in New Issue
Block a user