UNPKG

emv

Version:

EMV / Chip and PIN CLI and library for PC/SC card readers

139 lines 4.12 kB
/** * CLI command implementations */ import type { CardResponse } from './types.js'; import type { DiscoverAppsResult } from './emv-application.js'; /** * Context for command execution */ export interface CommandContext { output: (message: string) => void; error: (message: string) => void; readerName: string | undefined; format: string | undefined; verbose: boolean | undefined; } /** * Minimal Reader interface for commands */ interface ReaderInfo { name: string; state: number; atr: Buffer | null; } /** * Minimal Devices interface for dependency injection */ interface DevicesLike { listReaders(): ReaderInfo[]; start(): void; stop(): void; on(event: string, handler: (event: unknown) => void): void; once(event: string, handler: (event: unknown) => void): void; } /** * Minimal EmvApplication interface for dependency injection */ interface EmvLike { selectPse?(): Promise<CardResponse>; selectApplication?(aid: Buffer | readonly number[]): Promise<CardResponse>; readRecord?(sfi: number, record: number): Promise<CardResponse>; getData?(tag: number): Promise<CardResponse>; verifyPin?(pin: string): Promise<CardResponse>; getAtr?(): string; getReaderName?(): string; discoverApplications?(): Promise<DiscoverAppsResult>; } /** * Options for commands (for dependency injection in tests) */ export interface CommandOptions { devices?: DevicesLike; emv?: EmvLike; timeout?: number; } /** * List available PC/SC readers */ export declare function listReaders(ctx: CommandContext, options?: CommandOptions): Promise<number>; /** * Wait for a card to be inserted */ export declare function waitForCard(ctx: CommandContext, options?: CommandOptions): Promise<number>; /** * Select Payment System Environment */ export declare function selectPse(ctx: CommandContext, options?: CommandOptions): Promise<number>; /** * Select application by AID */ export declare function selectApp(ctx: CommandContext, aidHex: string, options?: CommandOptions): Promise<number>; /** * Application information from PSE */ export interface PseAppInfo { aid: string; label: string | undefined; priority: number | undefined; } /** * Record data from PSE */ export interface PseRecordData { sfi: number; record: number; data: string; } /** * Result of reading PSE applications */ export interface PseReadResult { pseOk: boolean; pseBuffer: Buffer; sfi: number; apps: PseAppInfo[]; records: PseRecordData[]; } /** * Read applications from Payment System Environment * This is a shared helper used by listApps, cardInfo, and dumpCard. * Uses EmvApplication.discoverApplications() for app discovery, with additional * record reading for dump functionality. */ export declare function readPseApplications(options?: CommandOptions): Promise<PseReadResult>; /** * List applications on card from PSE */ export declare function listApps(ctx: CommandContext, options?: CommandOptions): Promise<number>; /** * Read a record from an SFI */ export declare function readRecord(ctx: CommandContext, sfi: number, record: number, options?: CommandOptions): Promise<number>; /** * Get data by EMV tag */ export declare function getData(ctx: CommandContext, tagStr: string, options?: CommandOptions): Promise<number>; /** * Verify PIN */ export declare function verifyPin(ctx: CommandContext, pin: string, options?: CommandOptions): Promise<number>; /** * Show card information */ export declare function cardInfo(ctx: CommandContext, options?: CommandOptions): Promise<number>; /** * Dump all readable data from card */ export declare function dumpCard(ctx: CommandContext, options?: CommandOptions): Promise<number>; /** * Result of processing a shell command */ export interface ShellCommandResult { action: 'continue' | 'exit'; } /** * Process a command in the interactive shell */ export declare function processShellCommand(ctx: CommandContext, input: string, options?: CommandOptions): Promise<ShellCommandResult>; export {}; //# sourceMappingURL=commands.d.ts.map