// Characters and presets made before accounts existed were protected by secret keys in this browser. // After login they are handed over to the account once; the old keys are then removed. export async function claimLegacy() { const post = (kind, id, token) => fetch(`/api/claim/${kind}/${id}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ token }) }).catch(() => null) try { const chars = JSON.parse(localStorage.getItem('aw_chars')) || [] for (const c of chars) if (c?.id && c?.token) await post('characters', c.id, c.token) localStorage.removeItem('aw_chars') } catch { /* nothing to claim */ } try { const presets = JSON.parse(localStorage.getItem('aw_presets')) || {} for (const [id, token] of Object.entries(presets)) await post('presets', id, token) localStorage.removeItem('aw_presets') } catch { /* nothing to claim */ } }