// Type definitions for WebAuthn/Passkey authentication

export interface WebAuthnChallengeData {
  challenge: string;
  rp: {
    name: string;
    id: string;
  };
  user: {
    id: string;
    name: string;
    displayName: string;
  };
  pubKeyCredParams: Array<{
    type: string;
    alg: number;
  }>;
  authenticatorSelection?: {
    authenticatorAttachment?: string;
    requireResidentKey?: boolean;
    residentKey?: string;
    userVerification?: string;
  };
  timeout: number;
  attestation?: string;
}

export interface WebAuthnAuthChallengeData {
  challenge: string;
  rpId: string;
  allowCredentials: Array<{
    type: string;
    id: string;
    transports?: string[];
  }>;
  timeout: number;
  userVerification: string;
}

export interface WebAuthnRegistrationResult {
  name: string;
  attestation: {
    id: string;
    rawId: string;
    type: string;
    response: {
      clientDataJSON: string;
      attestationObject: string;
    };
  };
}

export interface WebAuthnAuthenticationResult {
  assertion: {
    id: string;
    rawId: string;
    type: string;
    response: {
      clientDataJSON: string;
      authenticatorData: string;
      signature: string;
      userHandle: string | null;
    };
  };
}

export interface ErrorResponse {
  error?: string;
}

export interface AuthSuccessResponse {
  redirect: string;
}
