import * as SecureStore from 'expo-secure-store' const TOKEN_KEY = 'memento_token' export async function getToken(): Promise { try { return await SecureStore.getItemAsync(TOKEN_KEY) } catch { return null } } export async function setToken(token: string): Promise { try { await SecureStore.setItemAsync(TOKEN_KEY, token) } catch (e) { console.warn('[SecureStore] setToken failed:', e) } } export async function clearToken(): Promise { await SecureStore.deleteItemAsync(TOKEN_KEY) } export async function apiFetch(url: string, options: RequestInit = {}): Promise { const token = await getToken() return fetch(url, { ...options, headers: { 'Content-Type': 'application/json', ...(token ? { Authorization: `Bearer ${token}` } : {}), ...options.headers, }, }) }