import { SmrtObject, SmrtObjectOptions } from '@happyvertical/smrt-core'; import { SessionStatus } from '../types/index.js'; /** * Constructor options for {@link Session}. */ export interface SessionOptions extends SmrtObjectOptions { userId?: string; tenantId?: string | null; status?: SessionStatus; /** Accepts a Date or any value the Date constructor can coerce. */ expiresAt?: Date | string | number; userAgent?: string; ipAddress?: string; /** Accepts a Date or any value the Date constructor can coerce. */ lastAccessedAt?: Date | string | number; data?: Record; } /** * Default session TTL: 7 days in seconds */ export declare const DEFAULT_SESSION_TTL: number; /** * Generate a cryptographically secure session ID */ export declare function generateSessionId(): string; /** * Session represents an authenticated user session. * * Sessions are stored server-side and linked to users. * A session ID is stored in a cookie and used to look up the session. * * @example * ```typescript * const session = await sessions.create({ * userId: user.id, * tenantId: tenant.id, * expiresAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), * userAgent: request.headers.get('user-agent'), * ipAddress: getClientAddress(event) * }); * await session.save(); * ``` */ export declare class Session extends SmrtObject { /** * User who owns this session */ userId: string; /** * Tenant context for this session (for multi-tenant apps) * Null means no tenant context selected */ tenantId: string | null; /** * Session status */ status: SessionStatus; /** * Session expiration time * * Indexed: `deleteExpired()` — and the retention sweep that now schedules it * (#2375) — scans this column on every pass. */ expiresAt: Date; /** * User agent string from the browser */ userAgent: string; /** * IP address of the client */ ipAddress: string; /** * Last activity timestamp (updated on each request) */ lastAccessedAt: Date; /** * Custom session data (JSON serializable) */ data: Record; constructor(options?: SessionOptions); /** * Check if the session is currently valid (active and not expired) */ isValid(): boolean; /** * Check if the session has expired */ isExpired(): boolean; /** * Check if the session was revoked */ isRevoked(): boolean; /** * Update the last accessed timestamp */ touch(): void; /** * Extend the session expiration by the given TTL (in seconds) */ extend(ttlSeconds?: number): void; /** * Revoke the session */ revoke(): void; /** * Set the tenant context for this session */ setTenant(tenantId: string | null): void; /** * Get or set custom session data */ getData(key: string): T | undefined; /** * Set custom session data */ setData(key: string, value: unknown): void; /** * Remove custom session data */ removeData(key: string): void; } //# sourceMappingURL=Session.d.ts.map