export function createStorageKeys(e="auth"){return{token:`${e}:token`,entitlements:`${e}:entitlements`,expiresAt:`${e}:expiresAt`,sessionToken:`${e}:sessionToken`,deviceId:`${e}:deviceId`,lastCheck:`${e}:lastCheck`,email:`${e}:email`,activatedFlag:"isActivated"}}export async function getOrCreateDeviceId(e){const t=await chrome.storage.local.get(e.deviceId);if(t&&t[e.deviceId])return String(t[e.deviceId]);const n=crypto&&typeof crypto.randomUUID=="function"&&crypto.randomUUID()||`dev-${Date.now()}-${Math.random().toString(16).slice(2)}`;return await chrome.storage.local.set({[e.deviceId]:n}),n}export async function readStoredAuth(e){const t=await chrome.storage.local.get([e.token,e.entitlements,e.expiresAt,e.sessionToken,e.deviceId,e.lastCheck,e.email]);return{entitlements:t[e.entitlements]||[],token:t[e.token]||null,expiresAt:t[e.expiresAt]||null,sessionToken:t[e.sessionToken]||null,deviceId:t[e.deviceId]||null,lastCheck:t[e.lastCheck]||null,email:t[e.email]||null}}
