All Projects → santigimeno → Node Pcsclite

santigimeno / Node Pcsclite

Licence: isc
Bindings over pcsclite to access Smart Cards

Labels

Projects that are alternatives of or similar to Node Pcsclite

Show time for flutter
华丽的Flutter的demo----新闻阅读+音乐+短视频+小说
Stars: ✭ 72 (-43.31%)
Mutual labels:  reader
Novelreader
仿照"任阅"的追书、看书的小说阅读器。重写"任阅"的代码,优化代码逻辑和代码结构,降低内存使用率。重写小说阅读器,支持网络阅读、本地阅读(支持分章,虚拟分章)。支持仿真翻页、上下滚动翻页等翻页效果。支持小说断点续传功能。优化用户使用体验。
Stars: ✭ 1,325 (+943.31%)
Mutual labels:  reader
Kreader
Android阅读器
Stars: ✭ 117 (-7.87%)
Mutual labels:  reader
Lector
Qt based ebook reader
Stars: ✭ 1,218 (+859.06%)
Mutual labels:  reader
Reader
Reader for PDF,use Qt5 and Poppler
Stars: ✭ 89 (-29.92%)
Mutual labels:  reader
Go Excel
A simple and light excel file reader to read a standard excel as a table faster | 一个轻量级的Excel数据读取库,用一种更`关系数据库`的方式解析Excel。
Stars: ✭ 114 (-10.24%)
Mutual labels:  reader
Mymanga
Manga downloader and reader for Windows 7/8.1/10. Written in C# with a clean and simple WPF interface.
Stars: ✭ 66 (-48.03%)
Mutual labels:  reader
Parquet4s
Read and write Parquet in Scala. Use Scala classes as schema. No need to start a cluster.
Stars: ✭ 125 (-1.57%)
Mutual labels:  reader
Reader
📕一款在任阅基础上改进的网络小说阅读器,采用Kt编写,支持听书,仿真翻页,插页图片等。欢迎 star or fork!
Stars: ✭ 94 (-25.98%)
Mutual labels:  reader
Qrandbarcodescanner
An Android app for scanning QR codes and barcodes
Stars: ✭ 114 (-10.24%)
Mutual labels:  reader
Byline
Go library for convert io.Reader to line-by-line Reader
Stars: ✭ 80 (-37.01%)
Mutual labels:  reader
Iostreams
IOStreams is an incredibly powerful streaming library that makes changes to file formats, compression, encryption, or storage mechanism transparent to the application.
Stars: ✭ 84 (-33.86%)
Mutual labels:  reader
Laravel Log Reader
A log reader and management tool for Laravel
Stars: ✭ 115 (-9.45%)
Mutual labels:  reader
Reader
Extract clean(er), readable text from web pages via Mercury Web Parser.
Stars: ✭ 75 (-40.94%)
Mutual labels:  reader
Deepreader
a highly modular, Vue.js-based framework designed for building online reading environments for deep reading of texts with rich annotations and integrated learning tools
Stars: ✭ 119 (-6.3%)
Mutual labels:  reader
Remoteink
📖 🖥️ Turns Pockerbook E-Ink reader into a computer monitor
Stars: ✭ 67 (-47.24%)
Mutual labels:  reader
Album Bankakyou
Most simple UI, gallery before your eyes.
Stars: ✭ 102 (-19.69%)
Mutual labels:  reader
Javascript Barcode Reader
Simple and Fast Barcode decoder with support of Code128, Code93, Code39, Standard/Industrial 2 of 5, Interleaved 2 of 5, Codabar, EAN-13, EAN-8 barcodes in javascript.
Stars: ✭ 127 (+0%)
Mutual labels:  reader
External Nfc Api
Interaction with external NFC readers in Android
Stars: ✭ 123 (-3.15%)
Mutual labels:  reader
Gosumemory
Cross-Platform memory reader for osu!
Stars: ✭ 112 (-11.81%)
Mutual labels:  reader

node-pcsclite

![Gitter](https://badges.gitter.im/Join Chat.svg)

Bindings over pcsclite to access Smart Cards. Starting with version 0.4.0 it works in Linux, OS X and Windows.

Installation

You'll need a node version installed in the system. You have several options:

  • Download and install it from the node website

  • Install it from your own distro. For the Debian users:

    apt-get install nodejs nodejs-legacy

  • Use nodesource repository for different distros.

  • Use tools like nave or nvm

In order to install the package you need to have installed in the system the pcsclite libraries. For example, in Debian/Ubuntu:

apt-get install libpcsclite1 libpcsclite-dev

Once they are installed just run:

npm install pcsclite

To run any code you will also need to have installed the pcsc daemon:

apt-get install pcscd

Example

var pcsc = require('pcsclite');

var pcsc = pcsc();
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 */
        var 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);
});

API

Class: PCSCLite

The PCSCLite object is an EventEmitter that notifies the existence of Card Readers.

Event: 'error'

  • err Error Object. The error.

Event: 'reader'

  • reader CardReader. A CardReader object associated to the card reader detected

Emitted whenever a new card reader is detected.

pcsclite.close()

It frees the resources associated with this PCSCLite instance. At a low level it calls SCardCancel so it stops watching for new readers.

pcsclite.readers

An object containing all detected readers by name. Updated as readers are attached and removed.

Class: CardReader

The CardReader object is an EventEmitter that allows to manipulate a card reader.

Event: 'error'

  • err Error Object. The error.

Event: 'end'

Emitted when the card reader has been removed.

Event: 'status'

  • status Object.
    • state The current status of the card reader as returned by SCardGetStatusChange
    • atr ATR of the card inserted (if any)

Emitted whenever the status of the reader changes.

reader.connect([options], callback)

  • options Object Optional
    • share_mode Number Shared mode. Defaults to SCARD_SHARE_EXCLUSIVE
    • protocol Number Preferred protocol. Defaults to SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1
  • callback Function called when connection operation ends
    • error Error
    • protocol Number Established protocol to this connection.

Wrapper around SCardConnect. Establishes a connection to the reader.

reader.disconnect(disposition, callback)

  • disposition Number. Reader function to execute. Defaults to SCARD_UNPOWER_CARD
  • callback Function called when disconnection operation ends
    • error Error

Wrapper around SCardDisconnect. Terminates a connection to the reader.

reader.transmit(input, res_len, protocol, callback)

  • input Buffer input data to be transmitted
  • res_len Number. Max. expected length of the response
  • protocol Number. Protocol to be used in the transmission
  • callback Function called when transmit operation ends
    • error Error
    • output Buffer

Wrapper around SCardTransmit. Sends an APDU to the smart card contained in the reader connected to.

reader.control(input, control_code, res_len, callback)

  • input Buffer input data to be transmitted
  • control_code Number. Control code for the operation
  • res_len Number. Max. expected length of the response
  • callback Function called when control operation ends
    • error Error
    • output Buffer

Wrapper around SCardControl. Sends a command directly to the IFD Handler (reader driver) to be processed by the reader.

reader.close()

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].