HEADER v3, primary аккаунты и подтверждения

This commit is contained in:
AidarKC
2026-11-27 12:29:24 +03:00
parent f9e7c4ef94
commit ae430e84c7
89 changed files with 1201 additions and 1596 deletions
@@ -0,0 +1,21 @@
// Только будущие публичные поля HEADER; никаких паролей или приватных ключей.
const prefix = 'shine-pending-header-v3:';
const memory = new Map();
const key = (login, publicKey) => `${prefix}${String(login).trim().toLowerCase()}:${String(publicKey).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')}`;
export function savePendingHeaderIdentity(login, publicKey, identity) {
if (!publicKey || ![0, 1].includes(identity.accountType)) throw new Error('Missing HEADER identity');
const k = key(login, publicKey);
const data = JSON.stringify({ accountType: identity.accountType, previousAccounts: [...identity.previousAccounts] });
memory.set(k, data);
try { localStorage.setItem(k, data); } catch { /* encrypted vault is a second persistence path */ }
}
export function readPendingHeaderIdentity(login, publicKey) {
const k = key(login, publicKey);
let value = memory.get(k);
try { value = value || localStorage.getItem(k); } catch {}
try { return value ? JSON.parse(value) : null; } catch { return null; }
}
export function clearPendingHeaderIdentity(login, publicKey) {
const k = key(login, publicKey); memory.delete(k);
try { localStorage.removeItem(k); } catch {}
}