import { ApiFailure, meKey, unwrapApi } from '@app/lib' import Apis, { type EnvelopeMeResp } from '@app/services/api' import { invalidateCache } from '@app/services/storage' export type SessionUser = NonNullable export function fetchSessionUser(): Promise { return unwrapApi(Apis.account.me()).catch((err) => { if (err instanceof ApiFailure && (err.code === 401 || err.code === 403)) { invalidateCache(meKey()) } throw err }) }