import type { ReadActor } from './read-trail.service'; /** * Resolves the {@link ReadActor} of a cookie-session request (issue #222). * Structural parameter instead of `AuthedRequest` so the read-trail module * never imports the auth guard. PAT requests build their key directly * (`token:`, public-api controller). */ export function readActorOf(request: { user?: { id: string } | null; sessionId?: string; }): ReadActor { // Session-less authenticated requests (trusted-proxy identity, #215) key // per user — the proxy re-authenticates every request, so the user is // the closest thing to a session the channel has. const sessionKey = request.sessionId ? `session:${request.sessionId}` : request.user ? `user:${request.user.id}` : 'anon'; return { actorId: request.user?.id ?? null, sessionKey }; }