// Where the session token lives on disk. // // Split out of lib/session.tsx so the background location task can read the // token without importing the session provider: the task module is imported // by app/_layout at bundle evaluation, and sign-out needs to stop the task — // pointing those two at each other would be an import cycle. Both depend on // this leaf instead. import * as SecureStore from "expo-secure-store"; export const TOKEN_KEY = "waseel_auth_token"; /** * The stored session token, read straight from secure storage. * * Normal requests use the in-memory copy in lib/fetch, which the session * provider sets on sign-in. The background location task can't rely on that: * Android may restart the app process headlessly to deliver a location update, * with no React tree run and therefore no token in memory. */ export const readStoredToken = (): Promise => SecureStore.getItemAsync(TOKEN_KEY);