Socket
Socket
Sign inDemoInstall

card-reader

Package Overview
Dependencies
18
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    card-reader

>## DEPRECATED - Please use [smartcard](https://github.com/tomkp/smartcard) instead....


Version published
Weekly downloads
39
increased by333.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

DEPRECATED - Please use smartcard instead....


Card Reader

A simple wrapper around Santiago Gimeno's great pcsclite library.

Emits events for:

  • device-activated
  • device-deactivated
  • card-inserted
  • card-removed
  • issue-command
  • receive-response
  • error

Examples

var cardreader = require('../lib/card-reader');

cardreader.on('device-activated', function (reader) {
    console.log(`Device '${reader.name}' activated`);
});

cardreader.on('device-deactivated', function (reader) {
    console.log(`Device '${reader}' deactivated`);
});

cardreader.on('card-removed', function (reader) {
    console.log(`Card removed from '${reader.name}' `);
});

cardreader.on('command-issued', function (reader, command) {
    console.log(`Command '${command}' issued to '${reader.name}' `);
});

cardreader.on('response-received', function (reader, response, command) {
    console.log(`Response '${response}' received from '${reader.name}' in response to '${command}'`);
});

cardreader.on('error', function (message) {
    console.log(`Error '${message}' received`);
});

cardreader.on('card-inserted', function (reader, status) {

   console.log(`Card inserted into '${reader.name}' `);
   // issue a command...

   // ...either callback style
   cardreader.issueCommand('00A404000E315041592E5359532E4444463031', function (err, response) {
       if (err) {
           console.error(err);
       } else {
            console.log(`Response '${response.toString('hex')}`);
       }
   });
       
   // ...or as a promise
   cardreader
        .issueCommand('00A404000E315041592E5359532E4444463031')
        .then(function (response) {
            console.log(`Response '${response.toString('hex')}`);
        }).catch(function (error) {
            console.error(error);
        });
});


Compatible Readers

Tested on Mac OSX with the SCM SCR3500 Smart Card Reader. This library should work with most PC/SC readers - I'll update this page when I get to test others. If you know of any other devices that work please let me know.

Keywords

FAQs

Last updated on 15 Feb 2021

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc