/**
 * Extended Supabase Session Types
 * 
 * Supabase session objects contain additional properties not in the official types.
 * These extended types provide type safety for AAL (Authentication Assurance Level) and other fields.
 */

import type { Session } from '@supabase/supabase-js';

export type AALLevel = 'aal1' | 'aal2';

/**
 * Extended session type with AAL property
 * Supabase auth sessions include this property but it's not in the official types
 */
export interface ExtendedSession extends Session {
  aal?: AALLevel;
}

/**
 * Type guard to check if session has AAL property
 */
export function hasAAL(session: Session | null): session is ExtendedSession {
  return session !== null && 'aal' in session;
}

/**
 * Safely extract AAL level from session
 */
export function getSessionAAL(session: Session | null): AALLevel {
  if (hasAAL(session) && session.aal) {
    return session.aal;
  }
  return 'aal1';
}
