/** Options for connecting to a quicproquo server. */
export interface ConnectOptions {
  /** WebSocket URL, e.g. ws://host:port or wss://host:port */
  addr: string;
  /** Skip TLS certificate verification (development only). */
  insecureSkipVerify?: boolean;
  /** Timeout in milliseconds for the initial connection. Default: 5000. */
  connectTimeoutMs?: number;
  /** Timeout in milliseconds for RPC request/response. Default: 10000. */
  requestTimeoutMs?: number;
}

/** A message received from the server. */
export interface Message {
  seq: number;
  data: Uint8Array;
}

/** Result of creating or joining a channel. */
export interface ChannelResult {
  channelId: Uint8Array;
  wasNew: boolean;
}

/** An Ed25519 identity (seed + derived public key). */
export interface Identity {
  seed: Uint8Array;
  publicKey: Uint8Array;
}

/** A hybrid (X25519 + ML-KEM-768) keypair. */
export interface HybridKeypair {
  /** Full keypair blob: private(2432) || public(1216). */
  blob: Uint8Array;
  publicKey: Uint8Array;
}

/** Internal RPC request envelope. */
export interface RpcRequest {
  id: number;
  method: string;
  params: Record<string, unknown>;
}

/** Internal RPC response envelope. */
export interface RpcResponse {
  id: number;
  ok: boolean;
  result?: unknown;
  error?: string;
}

/** Events emitted by the transport layer. */
export type TransportEvent =
  | { type: "open" }
  | { type: "close"; code: number; reason: string }
  | { type: "error"; error: Error }
  | { type: "message"; data: Uint8Array };
