/**
 * QR auth types for SmartAuth Phase 5E.
 * QR auth allows a mobile auth app to scan a QR code on desktop/TV
 * and authorize the login from the phone.
 */

import { z } from 'zod';

export interface QrChallengeDoc {
  id: string; // "qr_{random}"
  /** The challenge token embedded in the QR code */
  challengeToken: string;
  /** Which product is requesting login */
  productId: string;
  /** Client platform that displayed the QR (e.g. "web", "desktop") */
  platform: string;
  status: 'pending' | 'confirmed' | 'expired';
  /** Set when the auth app confirms */
  userId?: string;
  createdAt: string;
  expiresAt: string;
  confirmedAt?: string;
}

export const QrChallengeCreateSchema = z.object({
  productId: z.string().min(1),
  platform: z.string().min(1).default('web'),
});

export const QrConfirmSchema = z.object({
  challengeToken: z.string().min(1),
});
