/* eslint-disable @typescript-eslint/no-explicit-any */ /** * In-memory stand-in for `expo-secure-store`. * * The real module is native-only. Both `StorageService` (auth token) and * `StorageServiceCasual` (cart/region/OTP keys) run against this store, so * persistence can be asserted directly instead of via mocks. */ const store = new Map() export const __store = store export function __reset() { store.clear() } export function __snapshot(): Record { return Object.fromEntries(store.entries()) } /** Synchronous seeding for test setup (avoids waiting a microtask). */ export function __set(key: string, value: string) { store.set(key, value) } export function __delete(key: string) { store.delete(key) } export async function setItemAsync(key: string, value: string): Promise { if (typeof value !== 'string') { throw new Error(`expo-secure-store mock: value for "${key}" must be a string`) } store.set(key, value) } export async function getItemAsync(key: string): Promise { return store.has(key) ? (store.get(key) as string) : null } export async function deleteItemAsync(key: string): Promise { store.delete(key) } export async function isAvailableAsync(): Promise { return true } export async function getItem(key: string): Promise { return getItemAsync(key) } export async function setItem(key: string, value: string): Promise { return setItemAsync(key, value) } export async function removeItem(key: string): Promise { return deleteItemAsync(key) } export const AFTER_FIRST_UNLOCK = 'AFTER_FIRST_UNLOCK' export const WHEN_UNLOCKED = 'WHEN_UNLOCKED' export default { setItemAsync, getItemAsync, deleteItemAsync, isAvailableAsync, getItem, setItem, removeItem, __reset, __store, }