/**
 * PKCS#11 Smart Card Provider
 *
 * Interface for PKCS#11 smart card communication.
 * Provides card reader management, certificate extraction,
 * and cryptographic operations.
 *
 * Features:
 * - Smart card reader enumeration
 * - Card presence monitoring
 * - Certificate extraction from PIV slots
 * - PIN verification
 * - Digital signature operations
 *
 * @packageDocumentation
 */
import { EventEmitter } from 'events';
import { type PKCS11Config, type CardEvent, type ParsedCertificate, PIVErrorCode } from './types.js';
/** PIV slot IDs */
export declare const PIV_SLOTS: {
    /** PIV Authentication (9A) */
    readonly PIV_AUTHENTICATION: 154;
    /** Card Authentication (9E) */
    readonly CARD_AUTHENTICATION: 158;
    /** Digital Signature (9C) */
    readonly DIGITAL_SIGNATURE: 156;
    /** Key Management (9D) */
    readonly KEY_MANAGEMENT: 157;
};
/**
 * Smart card reader information
 */
export interface ReaderInfo {
    /** Slot ID */
    slotId: number;
    /** Reader name/description */
    name: string;
    /** Whether card is present */
    cardPresent: boolean;
    /** Token label */
    tokenLabel?: string;
    /** Manufacturer */
    manufacturer?: string;
    /** Card ATR (Answer To Reset) */
    atr?: string;
}
/**
 * Token information
 */
export interface TokenInfo {
    /** Token label */
    label: string;
    /** Manufacturer */
    manufacturer: string;
    /** Model */
    model: string;
    /** Serial number */
    serialNumber: string;
    /** Total public memory */
    totalPublicMemory: number;
    /** Free public memory */
    freePublicMemory: number;
    /** Total private memory */
    totalPrivateMemory: number;
    /** Free private memory */
    freePrivateMemory: number;
    /** Whether token is initialized */
    initialized: boolean;
    /** Whether PIN is required */
    pinRequired: boolean;
}
/**
 * Certificate from smart card
 */
export interface SmartCardCertificate {
    /** PIV slot */
    slot: number;
    /** Slot name */
    slotName: string;
    /** Certificate label */
    label: string;
    /** Certificate ID */
    id: Buffer;
    /** Parsed certificate */
    certificate: ParsedCertificate;
}
/**
 * Sign request
 */
export interface SignRequest {
    /** Slot ID to use for signing */
    slotId: number;
    /** Key ID to use */
    keyId: Buffer;
    /** Data to sign */
    data: Buffer;
    /** Signature mechanism */
    mechanism: 'rsa-pkcs' | 'rsa-pss' | 'ecdsa';
    /** PIN for key access */
    pin?: string;
}
/**
 * PKCS#11 provider events
 */
export interface PKCS11ProviderEvents {
    initialized: () => void;
    error: (error: Error) => void;
    cardInserted: (event: CardEvent) => void;
    cardRemoved: (event: CardEvent) => void;
    readerConnected: (reader: ReaderInfo) => void;
    readerDisconnected: (slotId: number) => void;
}
/**
 * PKCS#11 error
 */
export declare class PKCS11Error extends Error {
    readonly code: PIVErrorCode;
    readonly pkcs11Code?: number;
    readonly details?: Record<string, unknown>;
    constructor(message: string, code?: PIVErrorCode, pkcs11Code?: number, details?: Record<string, unknown>);
}
/**
 * Library not found error
 */
export declare class LibraryNotFoundError extends PKCS11Error {
    constructor(libraryPath: string);
}
/**
 * PIN error
 */
export declare class PINError extends PKCS11Error {
    constructor(message: string, code: PIVErrorCode);
}
/**
 * Card not present error
 */
export declare class CardNotPresentError extends PKCS11Error {
    constructor(slotId: number);
}
/**
 * PKCS#11 smart card provider
 *
 * NOTE: This is an interface/abstraction layer. The actual PKCS#11
 * implementation requires native bindings (e.g., node-pkcs11 or graphene-pk11).
 * This code provides the API contract and mock implementation for testing.
 */
export declare class PKCS11Provider extends EventEmitter {
    private config;
    private initialized;
    private readers;
    private pollingTimer?;
    private pkcs11?;
    constructor(config?: Partial<PKCS11Config>);
    /**
     * Initialize PKCS#11 library
     */
    initialize(): Promise<void>;
    /**
     * Simulate PKCS#11 initialization for testing/development
     */
    private simulateInitialization;
    /**
     * Finalize and cleanup
     */
    finalize(): Promise<void>;
    /**
     * Get available readers
     */
    getReaders(): ReaderInfo[];
    /**
     * Get reader by slot ID
     */
    getReader(slotId: number): ReaderInfo | undefined;
    /**
     * Check if card is present in reader
     */
    isCardPresent(slotId: number): boolean;
    /**
     * Get token info from card
     */
    getTokenInfo(slotId: number): Promise<TokenInfo>;
    /**
     * Get certificates from card
     */
    getCertificates(slotId: number, pin?: string): Promise<SmartCardCertificate[]>;
    /**
     * Get authentication certificate (slot 9A)
     */
    getAuthenticationCertificate(slotId: number, pin?: string): Promise<SmartCardCertificate | undefined>;
    /**
     * Verify PIN
     */
    verifyPIN(slotId: number, pin: string): Promise<boolean>;
    /**
     * Sign data using card's private key
     */
    sign(request: SignRequest): Promise<Buffer>;
    /**
     * Challenge-response authentication
     */
    challengeResponse(slotId: number, challenge: Buffer, pin?: string): Promise<Buffer>;
    /**
     * Get card ATR (Answer To Reset)
     */
    getATR(slotId: number): Promise<string | undefined>;
    /**
     * Start polling for card changes
     */
    private startPolling;
    /**
     * Stop polling
     */
    private stopPolling;
    /**
     * Poll readers for changes
     */
    private pollReaders;
    /**
     * Simulate card insertion (for testing)
     */
    simulateCardInsert(slotId: number, atr?: string): void;
    /**
     * Simulate card removal (for testing)
     */
    simulateCardRemove(slotId: number): void;
    /**
     * Ensure library is initialized
     */
    private ensureInitialized;
    /**
     * Ensure card is present
     */
    private ensureCardPresent;
    /**
     * Get configuration
     */
    getConfig(): PKCS11Config;
    /**
     * Check if initialized
     */
    isInitialized(): boolean;
}
/**
 * Get the default PKCS#11 provider
 */
export declare function getPKCS11Provider(config?: Partial<PKCS11Config>): PKCS11Provider;
/**
 * Create a new PKCS#11 provider
 */
export declare function createPKCS11Provider(config?: Partial<PKCS11Config>): PKCS11Provider;
/**
 * Reset the default provider (for testing)
 */
export declare function resetPKCS11Provider(): Promise<void>;
/**
 * Common PKCS#11 library paths by platform
 */
export declare const PKCS11_LIBRARY_PATHS: {
    /** OpenSC on Linux */
    readonly openscLinux: "/usr/lib/opensc-pkcs11.so";
    /** OpenSC on macOS */
    readonly openscMac: "/usr/local/lib/opensc-pkcs11.so";
    /** OpenSC on macOS (Homebrew) */
    readonly openscMacBrew: "/opt/homebrew/lib/opensc-pkcs11.so";
    /** OpenSC on Windows */
    readonly openscWindows: "C:\\Program Files\\OpenSC Project\\OpenSC\\pkcs11\\opensc-pkcs11.dll";
    /** CoolKey on Linux */
    readonly coolkey: "/usr/lib64/pkcs11/libcoolkeypk11.so";
    /** YubiKey */
    readonly yubikey: "/usr/lib/x86_64-linux-gnu/libykcs11.so";
    /** SafeNet on Windows */
    readonly safenet: "C:\\Program Files\\SafeNet\\Authentication\\SAC\\x64\\sac10x.dll";
    /** Gemalto on Windows */
    readonly gemalto: "C:\\Windows\\System32\\gclib.dll";
};
/**
 * Detect available PKCS#11 library
 */
export declare function detectPKCS11Library(): Promise<string | undefined>;
//# sourceMappingURL=pkcs11-provider.d.ts.map