// Только будущие публичные поля 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 {} }