import { JSONObject, Timestamp, XID } from './index';
import { User } from './user';
import { Organization } from './organization';
export type SessionStatus = 'active' | 'expired' | 'revoked' | 'replaced';
export interface Session {
    id: XID;
    userId: XID;
    organizationId?: XID;
    status: SessionStatus;
    isActive: boolean;
    clientId?: string;
    userAgent?: string;
    deviceName?: string;
    deviceType: 'desktop' | 'mobile' | 'tablet' | 'unknown';
    operatingSystem?: string;
    browser?: string;
    ipAddress?: string;
    country?: string;
    city?: string;
    lastActiveIpAddress?: string;
    createdAt: Timestamp;
    updatedAt: Timestamp;
    lastActiveAt: Timestamp;
    expiresAt: Timestamp;
    authMethod: string;
    mfaVerified: boolean;
    mfaRequiredAt?: Timestamp;
    accessToken?: string;
    refreshToken?: string;
    tokenType: 'bearer' | 'jwt';
    metadata?: JSONObject;
    user?: User;
    organization?: Organization;
}
export interface SessionSummary {
    id: XID;
    deviceName?: string;
    deviceType: 'desktop' | 'mobile' | 'tablet' | 'unknown';
    browser?: string;
    operatingSystem?: string;
    ipAddress?: string;
    country?: string;
    city?: string;
    isCurrentSession: boolean;
    lastActiveAt: Timestamp;
    createdAt: Timestamp;
    status: SessionStatus;
}
export interface SessionInfo {
    id: XID;
    userId: XID;
    organizationId?: XID;
    isActive: boolean;
    lastActiveAt: Timestamp;
    expiresAt: Timestamp;
    mfaVerified: boolean;
}
export interface CreateSessionRequest {
    userId: XID;
    organizationId?: XID;
    clientId?: string;
    userAgent?: string;
    ipAddress?: string;
    deviceName?: string;
    authMethod: string;
    expiresIn?: number;
    metadata?: JSONObject;
}
export interface RefreshSessionRequest {
    refreshToken: string;
    extendExpiry?: boolean;
}
export interface RefreshSessionResponse {
    accessToken: string;
    refreshToken?: string;
    expiresAt: Timestamp;
    session: Session;
}
export interface SessionValidationResult {
    valid: boolean;
    session?: Session;
    reason?: 'expired' | 'revoked' | 'invalid' | 'mfa_required';
    requiresMfa?: boolean;
    mfaMethods?: string[];
}
export interface SessionDevice {
    id: XID;
    sessionId: XID;
    deviceId?: string;
    deviceName?: string;
    deviceType: 'desktop' | 'mobile' | 'tablet' | 'unknown';
    operatingSystem?: string;
    browser?: string;
    userAgent?: string;
    fingerprint?: string;
    trusted: boolean;
    registeredAt: Timestamp;
    lastSeenAt: Timestamp;
}
export interface SessionActivity {
    id: XID;
    sessionId: XID;
    activityType: 'login' | 'page_view' | 'api_call' | 'logout' | 'timeout';
    timestamp: Timestamp;
    ipAddress?: string;
    userAgent?: string;
    url?: string;
    method?: string;
    statusCode?: number;
    duration?: number;
    metadata?: JSONObject;
}
export interface SessionSecurityEvent {
    id: XID;
    sessionId: XID;
    eventType: 'suspicious_activity' | 'location_change' | 'device_change' | 'concurrent_limit';
    severity: 'low' | 'medium' | 'high' | 'critical';
    description: string;
    timestamp: Timestamp;
    ipAddress?: string;
    location?: string;
    automated: boolean;
    resolved: boolean;
    resolvedAt?: Timestamp;
    resolvedBy?: XID;
    metadata?: JSONObject;
}
export interface SessionPolicy {
    maxConcurrentSessions: number;
    sessionDuration: number;
    inactivityTimeout: number;
    requireMfaForSensitive: boolean;
    allowMultipleDevices: boolean;
    trustDeviceDuration?: number;
    ipRestrictions?: string[];
    locationRestrictions?: string[];
    timeRestrictions?: {
        allowedHours: [number, number];
        allowedDays: number[];
        timezone: string;
    };
}
export interface TerminateSessionRequest {
    sessionId?: XID;
    userId?: XID;
    reason?: 'user_logout' | 'admin_revoke' | 'security_policy' | 'account_disabled';
    terminateAll?: boolean;
    notifyUser?: boolean;
}
export interface TerminateSessionResponse {
    success: boolean;
    terminatedSessions: number;
    failedSessions?: Array<{
        sessionId: XID;
        error: string;
    }>;
}
export interface SessionAnalytics {
    organizationId?: XID;
    dateRange: {
        start: Timestamp;
        end: Timestamp;
    };
    totalSessions: number;
    activeSessions: number;
    uniqueUsers: number;
    averageSessionDuration: number;
    deviceTypes: Record<string, number>;
    browsers: Record<string, number>;
    operatingSystems: Record<string, number>;
    countries: Record<string, number>;
    cities: Record<string, number>;
    sessionsOverTime: Array<{
        date: string;
        sessions: number;
        uniqueUsers: number;
        averageDuration: number;
    }>;
    authMethods: Record<string, number>;
    mfaUsage: {
        enabled: number;
        disabled: number;
        methods: Record<string, number>;
    };
}
export interface SessionStorage {
    getSession(sessionId: XID): Promise<Session | null>;
    setSession(session: Session): Promise<void>;
    removeSession(sessionId: XID): Promise<void>;
    getAllSessions(userId: XID): Promise<Session[]>;
    cleanupExpiredSessions(): Promise<number>;
}
export interface SessionMiddlewareOptions {
    required?: boolean;
    allowExpired?: boolean;
    requireMfa?: boolean;
    requireOrganization?: boolean;
    permissions?: string[];
    roles?: string[];
}
export interface SessionContext {
    session: Session | null;
    user: User | null;
    organization: Organization | null;
    isAuthenticated: boolean;
    hasPermission: (permission: string, resource?: string) => boolean;
    hasRole: (role: string, context?: string) => boolean;
}
export interface JWTPayload {
    sub: XID;
    aud: string;
    iss: string;
    exp: number;
    iat: number;
    nbf: number;
    jti: XID;
    user_type: string;
    organization_id?: XID;
    permissions?: string[];
    roles?: string[];
    mfa_verified: boolean;
    device_id?: string;
    client_id?: string;
}
export interface SessionTokens {
    accessToken: string;
    refreshToken?: string;
    idToken?: string;
    tokenType: 'bearer' | 'jwt';
    expiresIn: number;
    expiresAt: Timestamp;
    scope?: string;
}
export interface ImpersonationContext {
    impersonatorId: XID;
    impersonatorSession: XID;
    targetUserId: XID;
    organizationId?: XID;
    reason: string;
    startedAt: Timestamp;
    expiresAt: Timestamp;
    permissions: string[];
}
export interface SessionBackup {
    userId: XID;
    sessionData: Record<string, any>;
    createdAt: Timestamp;
    expiresAt: Timestamp;
    encrypted: boolean;
}
export interface SessionSync {
    userId: XID;
    lastSyncAt: Timestamp;
    syncData: {
        preferences: JSONObject;
        state: JSONObject;
        notifications: JSONObject;
    };
    deviceSessions: XID[];
}
//# sourceMappingURL=session.d.ts.map