import { getStore } from './store.js'; export async function listAllowedEmails() { const store = await getStore(); return store.google_auth.listAllowedEmails(); } export async function getAllowedEmail(email) { const normalized = email.trim().toLowerCase(); const store = await getStore(); return (await store.google_auth.getByEmail(normalized)) ?? null; } export async function getById(authId) { const store = await getStore(); return (await store.google_auth.getById(authId)) ?? null; } export async function addAllowedEmail(email) { const normalized = email.trim().toLowerCase(); const store = await getStore(); const id = await store.google_auth.add(normalized); return { id, email: normalized }; } export async function removeAllowedEmail(email) { const normalized = email.trim().toLowerCase(); const row = await getAllowedEmail(normalized); if (!row) return false; const store = await getStore(); await store.google_auth.removeAllowedEmail(normalized); return true; } export async function setSelectedCompany(authId, companyId) { const store = await getStore(); await store.google_auth.setSelectedCompany(authId, companyId); } export async function setProfile(authId, { picture = null, pictureBinary = null, sub = null } = {}) { const store = await getStore(); await store.google_auth.setProfile(authId, { picture, pictureBinary, sub }); }