smartcard-interface
A simple package for sending commands into smartcards.
Note: This simply wraps the smartcard package on mac/linux and pcsc on windows.
Installation
$ npm install smartcard-interface
Usage
const DeviceManager = ; let devices = ; // Called when a device is inserted.devices;
Documentation
Classes
Card
Container for cards
Kind: global class
Properties
Name | Type | Description |
---|---|---|
card | smartcard.Card |
The card to wrap |
device | Device |
Parent device |
new Card()
Wraps a smartcard.Card
string
card.getAtr() ⇒ Returns the card atr.
Kind: instance method of Card
Returns: string
- card atr
card.connect()
Connects to the card. Do this before sending commands.
Kind: instance method of Card
card.close()
Closes the current connection.
Kind: instance method of Card
Promise.<Device>
card.sendCommand(APDUBuffer) ⇒ Executes the APDUBuffer on the card.
Kind: instance method of Card
Returns: Promise.<Device>
- Output APDU
Param | Type | Description |
---|---|---|
APDUBuffer | Buffer |
Buffer of bytes |
Example
let aid = 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00; card; // You need to connect in order to issue commands. // Selects the aid above.let response = await card; console; // Buffer < 90 00 > card; // Don't forget to close the connection when you're done.
Device
Container for card readers
Kind: global class
Properties
Name | Type | Description |
---|---|---|
name | string |
Device name. |
index | number |
Device index. |
new Device(device, index)
Wraps a smartcard.Device
Param | Type | Description |
---|---|---|
device | smartcard.Device |
The device to wrap |
index | number |
Raw device index usually 0 |
"insert"
Fired when a card is inserted into the reader.
Kind: event emitted by Device
Properties
Name | Type | Description |
---|---|---|
card | Card |
The card that was inserted. |
"remove"
Fired when a card is removed from the reader.
Kind: event emitted by Device
Properties
Name | Type | Description |
---|---|---|
card | Card |
The card that was removed. |