/**
 * @lastid/lastid-sdk — TypeScript definitions for native (napi) binding.
 *
 * For WASM types, import from '@lastid/lastid-sdk/wasm'.
 */

export interface ClientConfig {
  idpEndpoint: string;
  clientId: string;
  timeoutSeconds?: number;
}

export interface CredentialRequestResponse {
  requestId: string;
  requestUri: string;
  expiresIn: number;
  nonce: string;
}

export interface RequestStatusResponse {
  state: 'pending' | 'fulfilled' | 'denied' | 'expired' | 'not_found' | 'timeout';
  requestId: string;
  presentation?: string;
  error?: string;
}

export interface VerifiedCredentialResponse {
  subjectDid: string;
  issuerDid: string;
  credentialType: string;
  claims: Record<string, unknown>;
  issuedAt: string;
  expiresAt: string;
  issuerStatus: string;
  signatureVerified: boolean;
}

export declare class NapiClient {
  constructor(config: ClientConfig);

  /** Request a base credential presentation. */
  requestCredential(
    callbackUrl: string,
    state?: string,
    nonce?: string,
  ): Promise<CredentialRequestResponse>;

  /** Request a persona credential presentation. */
  requestPersonaCredential(
    callbackUrl: string,
    fields?: string[],
    optionalFields?: string[],
  ): Promise<CredentialRequestResponse>;

  /** Request a verified email credential presentation. */
  requestVerifiedEmailCredential(
    callbackUrl: string,
    domainConstraint?: string,
    state?: string,
    nonce?: string,
  ): Promise<CredentialRequestResponse>;

  /** Request a verified phone credential presentation. */
  requestVerifiedPhoneCredential(
    callbackUrl: string,
    countryCode?: string,
    state?: string,
    nonce?: string,
  ): Promise<CredentialRequestResponse>;

  /** Request an employment credential presentation. */
  requestEmploymentCredential(
    callbackUrl: string,
    employerDomain?: string,
    state?: string,
    nonce?: string,
  ): Promise<CredentialRequestResponse>;

  /** Request a trust credential presentation. */
  requestTrustCredential(
    callbackUrl: string,
    minimumLevel?: number,
    state?: string,
    nonce?: string,
  ): Promise<CredentialRequestResponse>;

  /** Request an age proof credential presentation. */
  requestAgeProofCredential(
    callbackUrl: string,
    minimumAge?: number,
    state?: string,
    nonce?: string,
  ): Promise<CredentialRequestResponse>;

  /** Poll for credential request status (single check). */
  pollStatus(requestId: string): Promise<RequestStatusResponse>;

  /** Poll until the request completes or times out (HTTP polling with backoff). */
  pollForCompletion(requestId: string): Promise<RequestStatusResponse>;

  /** Subscribe for real-time status via WebSocket (falls back to HTTP polling). */
  subscribeForCompletion(requestId: string): Promise<RequestStatusResponse>;

  /** Verify a credential presentation string (SD-JWT). */
  verifyPresentation(presentation: string): Promise<VerifiedCredentialResponse>;

  /** Get the SDK version. */
  static version(): string;
}
