
Product
Reachability for Ruby Now in Beta
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.
Bindings over pcsclite to access Smart Cards. It works in Linux, macOS and Windows.
Looking for library to work easy with NFC tags?
take a look at nfc-pcsc which offers easy to use high level API for detecting / reading and writing NFC tags and cards
In order to install the package you need to have installed in the system the pcsclite libraries.
In macOS and Windows you don't have to install anything.
For example, in Debian/Ubuntu:
apt-get install libpcsclite1 libpcsclite-devTo run any code you will also need to have installed the pcsc daemon:
apt-get install pcscd
Once you have all needed libraries, you can install using npm:
npm install @pokusew/pcsclite --save
const pcsclite = require("pcsclite");
const pcsc = pcsclite();
pcsc.on("reader", function(reader) {
console.log("New reader detected", reader.name);
reader.on("error", function(err) {
console.log("Error(", this.name, "):", err.message);
});
reader.on("status", function(status) {
console.log("Status(", this.name, "):", status);
/* check what has changed */
const changes = this.state ^ status.state;
if (changes) {
if (changes & this.SCARD_STATE_EMPTY && status.state & this.SCARD_STATE_EMPTY) {
console.log("card removed"); /* card removed */
reader.disconnect(reader.SCARD_LEAVE_CARD, function(err) {
if (err) {
console.log(err);
} else {
console.log("Disconnected");
}
});
} else if (
changes & this.SCARD_STATE_PRESENT &&
status.state & this.SCARD_STATE_PRESENT
) {
console.log("card inserted"); /* card inserted */
reader.connect(
{ share_mode: this.SCARD_SHARE_SHARED },
function(err, protocol) {
if (err) {
console.log(err);
} else {
console.log("Protocol(", reader.name, "):", protocol);
reader.transmit(
new Buffer([0x00, 0xb0, 0x00, 0x00, 0x20]),
40,
protocol,
function(err, data) {
if (err) {
console.log(err);
} else {
console.log("Data received", data);
reader.close();
pcsc.close();
}
}
);
}
}
);
}
}
});
reader.on("end", function() {
console.log("Reader", this.name, "removed");
});
});
pcsc.on("error", function(err) {
console.log("PCSC error", err.message);
});
TODO document
The PCSCLite object is an EventEmitter that notifies the existence of Card Readers.
Error Object. The error.CardReader. A CardReader object associated to the card reader detectedEmitted whenever a new card reader is detected.
It frees the resources associated with this PCSCLite instance. At a low level it calls SCardCancel so it stops watching for new readers.
The CardReader object is an EventEmitter that allows to manipulate a card reader.
Error Object. The error.Emitted when the card reader has been removed.
Object.
SCardGetStatusChangeEmitted whenever the status of the reader changes.
Object Optional
Number Shared mode. Defaults to SCARD_SHARE_EXCLUSIVENumber Preferred protocol. Defaults to SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1Function called when connection operation ends
ErrorNumber Established protocol to this connection.Wrapper around SCardConnect.
Establishes a connection to the reader.
Number. Reader function to execute. Defaults to SCARD_UNPOWER_CARDFunction called when disconnection operation ends
ErrorWrapper around SCardDisconnect.
Terminates a connection to the reader.
Buffer input data to be transmittedNumber. Max. expected length of the responseNumber. Protocol to be used in the transmissionFunction called when transmit operation ends
ErrorBufferWrapper around SCardTransmit.
Sends an APDU to the smart card contained in the reader connected to.
Buffer input data to be transmittedNumber. Control code for the operationNumber. Max. expected length of the responseFunction called when control operation ends
ErrorBufferWrapper around SCardControl.
Sends a command directly to the IFD Handler (reader driver) to be processed by the reader.
It frees the resources associated with this CardReader instance.
At a low level it calls SCardCancel so it stops watching for the reader status changes.
Yes, you can! It works well.
But please read carefully Using Native Node Modules guide in Electron documentation to fully understand the problematic.
Note, that because of Node Native Modules, you must build your app on target platform (you must run Windows build on Windows machine, etc.).
You can use CI/CD server to build your app for certain platforms.
For Windows, I recommend you to use AppVeyor.
For macOS and Linux build, there are plenty of services to choose from, for example CircleCI, Travis CI CodeShip.
FAQs
Bindings over PC/SC to access Smart Cards
We found that pcsclite2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.

Research
/Security News
Malicious npm packages use Adspect cloaking and fake CAPTCHAs to fingerprint visitors and redirect victims to crypto-themed scam sites.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.