Repository
Current version released
3 years ago
Versions
Deno FFI bindings to the PC/SC API
Currently for OS/X, with (windows/linux) coming soon
This mod offers three abstractions over the PC/SC API
- High-level classes
Context, Card, CommandAPDU/ResponseAPDU
- Low-level functions
SCardxx
that roughly map to standard [PC/SC] - TODO: OpenMobileAPI [OMAPI]
High level usage
import { Context, CommandAPDU, PCSC } from "https://<pcsc-deno-repo>/mod.ts";
const context = Context.establishContext();
const readerNames = context.listReaderNames();
console.log(`Readers:[${readerNames.join(",")}]`);
const readers = context.listReaders();
for( const reader of readers ) {
if ( await reader.isPresent ) {
const card = reader.connect();
const selectMF = CommandAPDU.from([0x00, 0xA4, 0x00, 0x00])
.setData([0x3f, 0x00]);
const resp = card.transmitAPDU( selectMF );
if ( resp.SW == 0x9000 ) {
// success ..
console.log(`Reader ${reader.name}: MF selected`);
console.log( resp.data )
} else {
console.error(`Reader ${reader.name}: error ${resp.SW}`);
}
card.disconnect(PCSC.SCARD_RESET_CARD);
}
}
context.shutdown();