import { SmrtCollection } from '@happyvertical/smrt-core'; import { Session } from '../models/Session.js'; /** * Options for creating a new session */ export interface CreateSessionOptions { /** User ID for the session */ userId: string; /** Optional tenant ID for multi-tenant context */ tenantId?: string; /** Session TTL in seconds (default: 7 days) */ ttl?: number; /** User agent string */ userAgent?: string; /** Client IP address */ ipAddress?: string; /** Custom session data */ data?: Record; } /** * Collection for managing Session objects */ export declare class SessionCollection extends SmrtCollection { static readonly _itemClass: typeof Session; /** * Create a new session with a secure ID */ createSession(options: CreateSessionOptions): Promise; /** * Find a valid session by ID * Returns null if session doesn't exist, is expired, or is revoked */ findValidSession(sessionId: string): Promise; /** * Update last accessed time and optionally extend session */ touch(sessionId: string, extendTtl?: boolean, ttl?: number): Promise; /** * Find all active sessions for a user */ findByUser(userId: string): Promise; /** * Delete all sessions for a user (logout from all devices) */ deleteUserSessions(userId: string): Promise; /** * Revoke all sessions for a user (soft delete) */ revokeUserSessions(userId: string): Promise; /** * Revoke a specific session */ revokeSession(sessionId: string): Promise; /** * Delete expired sessions (cleanup job) * * Scheduled by the framework retention sweep (#2375); `expires_at` carries * an index for this predicate. * * @param options.dryRun - Count the sessions the predicate selects without * deleting them. * @returns Number of sessions deleted (or, under `dryRun`, matched) */ deleteExpired(options?: { dryRun?: boolean; }): Promise; /** * Count active sessions for a user */ countUserSessions(userId: string): Promise; /** * Update tenant context for a session (low-level primitive). * * SECURITY (#1400): this does NOT verify that the session's user is a member * of `tenantId` — it is the unguarded storage primitive. Application/route * code must go through {@link SessionService.switchTenant}, which fail-closes * on a missing/inactive membership before calling this. Calling it directly * with an untrusted `tenantId` reintroduces the cross-tenant access bug. */ setSessionTenant(sessionId: string, tenantId: string | null): Promise; /** * Set custom session data */ setSessionData(sessionId: string, key: string, value: unknown): Promise; /** * Get custom session data */ getSessionData(sessionId: string, key: string): Promise; } //# sourceMappingURL=SessionCollection.d.ts.map