/**
 * WebAuthn passkey types for SmartAuth.
 */

import { z } from 'zod';

export interface PasskeyDoc {
  id: string; // "pk_{credentialId}"
  userId: string;
  productId: 'smartauth';
  credentialId: string; // base64url
  publicKey: string; // base64url encoded COSE key
  counter: number; // signature counter for replay prevention
  deviceType: string; // 'singleDevice' | 'multiDevice'
  backedUp: boolean;
  transports?: string[]; // ['usb', 'ble', 'nfc', 'internal']
  friendlyName?: string;
  createdAt: string;
  lastUsedAt: string;
}

export const PasskeyRegisterOptionsSchema = z.object({});

export const PasskeyRegisterVerifySchema = z.object({
  credential: z.record(z.unknown()),
});

export const PasskeyAuthOptionsSchema = z.object({
  email: z.string().email().optional(),
});

export const PasskeyAuthVerifySchema = z.object({
  credential: z.record(z.unknown()),
  productId: z.string().min(1),
});

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