/**
 * POY Verify SDK - TypeScript Definitions
 * Human verification API client
 * @see https://poyverify.com/docs
 */

export interface POYVerifyOptions {
  /** API base URL (default: https://api.poyverify.com/v1) */
  baseUrl?: string;
  /** Request timeout in milliseconds (default: 10000) */
  timeout?: number;
}

export interface VerifyResult {
  /** Whether the user is a verified human */
  verified: boolean;
  /** Human status: 'confirmed' | 'unconfirmed' */
  humanStatus: string;
  /** Trust score (0-100) */
  trustScore: number;
  /** Verification confidence (0-1) */
  confidence: number;
  /** Total number of verifications */
  verificationCount: number;
  /** Last verification timestamp */
  lastVerifiedAt: string | null;
  /** PoY ID */
  poyId: string;
  /** Raw API response */
  raw: Record<string, any>;
}

export interface Profile {
  /** PoY ID (e.g., "PoY #A3F9C2E") */
  poyId: string;
  /** Whether user is a verified human */
  isHuman: boolean;
  /** Trust score (0-100) */
  trustScore: number;
  /** Total verifications completed */
  verificationCount: number;
  /** Total content stamps created */
  totalStamps: number;
  /** Account status */
  status: string;
  /** Earned badges */
  badges: string[];
  /** First verification date */
  verifiedSince: string | null;
  /** Raw API response */
  raw: Record<string, any>;
}

export interface StampOptions {
  /** SHA-256 hash of the content */
  contentHash: string;
  /** PoY ID of the verified human creator */
  authorId: string;
  /** Content type: 'text' | 'image' | 'video' | 'audio' | 'document' */
  type?: string;
  /** Additional metadata */
  metadata?: Record<string, any>;
}

export interface Stamp {
  /** Stamp ID (stmp_xxxx) */
  stampId: string;
  /** SHA-256 content hash */
  contentHash: string;
  /** HMAC-SHA256 signature */
  signature: string;
  /** Author PoY ID */
  author: string;
  /** Creation timestamp */
  createdAt: string;
  /** Whether stamped by a verified human */
  humanVerified: boolean;
  /** Raw API response */
  raw: Record<string, any>;
}

export interface CheckStampOptions {
  /** Stamp ID to verify */
  stampId?: string;
  /** Content hash to verify */
  contentHash?: string;
}

export interface StampVerification {
  /** Whether the stamp is authentic */
  authentic: boolean;
  /** Stamp ID */
  stampId: string;
  /** Author PoY ID */
  author: string;
  /** Author's current trust score */
  authorTrustScore: number;
  /** Content hash */
  contentHash: string;
  /** Whether signature is mathematically valid */
  signatureValid: boolean;
  /** Chain of custody: 'intact' | 'broken' */
  chainOfCustody: string;
  /** Whether content was created by a verified human */
  humanVerified: boolean;
  /** Stamp creation timestamp */
  createdAt: string;
  /** Raw API response */
  raw: Record<string, any>;
}

export interface VerifyOptions {
  /** SHA-256 biometric hash for re-verification */
  biometricHash?: string;
}

export declare class POYVerify {
  /**
   * Create a POY Verify client
   * @param apiKey - Your API key (poy_live_xxx or poy_test_xxx)
   * @param options - Configuration options
   */
  constructor(apiKey: string, options?: POYVerifyOptions);

  /**
   * Verify if a user is a real human
   */
  verify(userId: string, options?: VerifyOptions): Promise<VerifyResult>;

  /**
   * Quick boolean check - is this user a verified human?
   */
  isHuman(userId: string): Promise<boolean>;

  /**
   * Get a user's public profile
   */
  getProfile(userId: string): Promise<Profile>;

  /**
   * Stamp content as human-made
   */
  stamp(options: StampOptions): Promise<Stamp>;

  /**
   * Verify a content stamp is authentic
   */
  checkStamp(options: CheckStampOptions): Promise<StampVerification>;

  /**
   * Get a user's trust score (0-100)
   */
  trustScore(userId: string): Promise<number>;

  /**
   * Check if the SDK can reach the API
   */
  ping(): Promise<boolean>;

  /**
   * Generate a SHA-256 hash of content (browser + Node.js compatible)
   */
  static hash(content: string | Buffer | ArrayBuffer): Promise<string>;
}

export default POYVerify;
