{"version":3,"file":"session-B_jK90RC.mjs","names":[],"sources":["../src/lib/auth/session.ts"],"sourcesContent":["import type { IronSession } from \"iron-session\";\nimport { serverEnv } from \"~/env\";\nimport type { ProviderId, User } from \"~/models/User\";\n\nexport interface AppSessionData {\n  /** Which identity provider signed this user in. */\n  provider?: ProviderId;\n  /** The only token persisted; delegated access tokens are minted from it. */\n  refreshToken?: string;\n  user?: User;\n  /** Transient, only between /auth/login and /auth/callback. */\n  pkceVerifier?: string;\n  state?: string;\n  returnTo?: string;\n}\n\nexport type AppSession = IronSession<AppSessionData>;\n\nexport const getAppSession = async (): Promise<AppSession> => {\n  // Dynamic import: `@tanstack/react-start/server` is the server entry and drags\n  // in the SSR renderer (`react-dom/server`). Keep it out of the client graph —\n  // this helper is only ever called server-side, and all callers already await it.\n  const [{ getIronSession }, { getCookie, setCookie }] = await Promise.all([\n    import(\"iron-session\"),\n    import(\"@tanstack/react-start/server\"),\n  ]);\n\n  return getIronSession<AppSessionData>(\n    { read: getCookie, write: setCookie },\n    {\n      // Not `session`: that name holds the pre-stable `useSession` seal, which\n      // iron-session can't read. Users sign in once more after the upgrade.\n      cookieName: \"app-session\",\n      password: serverEnv.SESSION_SECRET,\n      chunk: true,\n      cookieOptions: {\n        secure: process.env.NODE_ENV === \"production\",\n        sameSite: \"lax\",\n        httpOnly: true,\n        path: \"/\",\n        // Explicit `undefined`: browser-session cookie and a seal that never\n        // expires — what `useSession` did. Omit it to fall back to iron's 14-day `ttl`.\n        maxAge: undefined,\n      },\n    },\n  );\n};\n"],"mappings":";;AAkBA,MAAa,gBAAgB,YAAiC;CAI5D,MAAM,CAAC,EAAE,kBAAkB,EAAE,WAAW,eAAe,MAAM,QAAQ,IAAI,CACvE,OAAO,iBACP,OAAO,+BACT,CAAC;CAED,OAAO,eACL;EAAE,MAAM;EAAW,OAAO;CAAU,GACpC;EAGE,YAAY;EACZ,UAAU,UAAU;EACpB,OAAO;EACP,eAAe;GACb,QAAQ,QAAQ,IAAI,aAAa;GACjC,UAAU;GACV,UAAU;GACV,MAAM;GAGN,QAAQ,KAAA;EACV;CACF,CACF;AACF"}