import type { BackofficeSession } from './backoffice-session.js';
import type {
  BackofficeUser,
  BackofficeUserWithHash,
  NewBackofficeUser,
} from './backoffice-user.js';

export interface BackofficePasswordHasher {
  hash(plain: string): Promise<string>;
  verify(hash: string, plain: string): Promise<boolean>;
}

export interface BackofficeUserRepository {
  create(input: NewBackofficeUser): Promise<BackofficeUser>;
  findByEmail(email: string): Promise<BackofficeUserWithHash | undefined>;
  findById(id: string): Promise<BackofficeUser | undefined>;
  updateMfaEnrolled(id: string, enrolled: boolean): Promise<void>;
}

export interface BackofficeSessionRepository {
  create(userId: string, tokenHash: string, expiresAt: Date): Promise<BackofficeSession>;
  revokeByTokenHash(tokenHash: string): Promise<boolean>;
}

export interface BackofficeLoginRateLimiter {
  hit(key: string): { allowed: boolean; retryAfterMs: number; remaining: number };
}
