(session: T, get: (sessionID: string) => Promise<T>)
| 37 | } |
| 38 | |
| 39 | export async function rootSession<T extends SessionParent>(session: T, get: (sessionID: string) => Promise<T>) { |
| 40 | const seen = new Set([session.id]) |
| 41 | let current = session |
| 42 | while (current.parentID) { |
| 43 | if (seen.has(current.parentID)) throw new Error(`Session parent cycle: ${current.parentID}`) |
| 44 | seen.add(current.parentID) |
| 45 | current = await get(current.parentID) |
| 46 | } |
| 47 | return current |
| 48 | } |
no test coverage detected