import { Injectable } from '@angular/core';
import { Observable, throwError } from 'rxjs';
import { Ed25519Challenge, Ed25519SignedResponse, Ed25519VerificationResult, Ed25519VerificationService } from './ed25519-verification.model';

/**
 * Default DI binding for Ed25519VerificationService until the backend ships
 * the real challenge/verify endpoints. Intentionally fails closed (throws)
 * rather than pretending to verify anything, so accidental use in a login
 * path is loud instead of silently accepting unsigned sessions.
 */
@Injectable({ providedIn: 'root' })
export class NoopEd25519VerificationService implements Ed25519VerificationService {
  requestChallenge(): Observable<Ed25519Challenge> {
    return throwError(() => new Error('Ed25519 challenge endpoint is not yet available from the backend.'));
  }

  verify(_response: Ed25519SignedResponse): Observable<Ed25519VerificationResult> {
    return throwError(() => new Error('Ed25519 verification endpoint is not yet available from the backend.'));
  }
}
