{"_id":"@ap-mitch/pcsclite","_rev":"2-72e47a4cc0be618df44b0c85e12501cb","name":"@ap-mitch/pcsclite","dist-tags":{"latest":"0.5.3"},"versions":{"0.5.2":{"name":"@ap-mitch/pcsclite","version":"0.5.2","description":"Bindings over PC/SC to access Smart Cards","keywords":["nfc","pcsc","pcsclite","smartcards"],"homepage":"https://github.com/pokusew/node-pcsclite#readme","bugs":{"url":"https://github.com/pokusew/node-pcsclite/issues"},"repository":{"type":"git","url":"git+https://github.com/pokusew/node-pcsclite.git"},"license":"ISC","author":{"name":"Santiago Gimeno","email":"santiago.gimeno@gmail.com","url":"https://github.com/santigimeno"},"contributors":[{"name":"Martin Endler","url":"https://github.com/pokusew"}],"main":"lib/pcsclite.js","types":"index.d.ts","directories":{"example":"examples","lib":"lib","test":"test"},"scripts":{"install":"node-gyp rebuild","test":"mocha"},"dependencies":{"bindings":"^1.4.0","nan":"^2.12.1"},"devDependencies":{"mocha":"^6.0.0","should":"^13.2.3","sinon":"^7.2.4"},"gypfile":true,"gitHead":"79a659bc6631f726233b460c1e87791c04f11b65","_id":"@ap-mitch/pcsclite@0.5.2","_nodeVersion":"10.15.0","_npmVersion":"6.9.2","dist":{"integrity":"sha512-7aLKrLT//SdAJM2LFXk3Rr1tdHwvvmo47/kvVOnVuCZHLQif60G0xDXstD5UcWJK+L/ChOZTamDEsUBnOwO5sQ==","shasum":"c67c37b93266fe7d3fd04c947e73c92ae5323eca","tarball":"https://registry.npmjs.org/@ap-mitch/pcsclite/-/pcsclite-0.5.2.tgz","fileCount":24,"unpackedSize":69520,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdGVuwCRA9TVsSAnZWagAAaDEP/R9xfSDWlbadejmfuxYt\n2Zn7aybsLgCO9q99Vu8/Z3tX/qlz1DWInef7uywxHPMozvcge09NhzD7Qkuh\n+9r98I26qmgZhwNDv48cRShdODauJZ86ox97F8TlEufOkpVR17NFxpNxCgDh\nSxPt6PWndP66lS54icWRiq8WbaB45f0C24uGuyHP29XwD3x5Ax1dNuCvNaKR\nVpDP9rVRZe7/z95jaKXVk3GMSw4eXJ7ivDOXKjO7/L5xG7yW9TpBlTuIChyI\nVwLtHyu0GMYwJkNR7eWFe9iY8eQqju/Zx7NOucMSFUb6gcr3d82IboDrLzqn\nHgDybCCl8lzMJHEGS7lGkzRxkAItVxhW3/oLdt404O7OmiLzYadoeQVPrNv0\nLjaYRnRerEOjJZ1jLgbJSWZoHPDnSOHPDoqSBRj5DLWQ9KbCNIdiU43or4iP\nsq/hUGh1Ooxinx8w70PqZHntkWfS9gtkjw19Ta5bxHpHufiwD7f7SZcYTBXq\nuabqqr7YP8/YGf6IHQCMMkAv3iaS/C76iOStqyCXPJ4gz2JvkRfA6RnOgzNz\nicsY6glCRA4qtzH38UKkihLpxhwZ9nBsx8oTSu9gR/x2cylQ0pqyrhOeBfiW\nhiwJKuexW1VJajKBcLczD3uHoZZM+BVnCBwvUts2zyAB7zIdrmCEY3kCXRjZ\nP/1d\r\n=IgDr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCWBGqNmwOISKqW3lk83/g53CCgZtSMLyNLi27lX0cxJQIhAOJe2aw7RG1Z5ypqV6acvt1AoSn+VmvM+DmqZJowMNw8"}]},"maintainers":[{"name":"ap-mitch","email":"mitch@artprocessors.net"}],"_npmUser":{"name":"ap-mitch","email":"mitch@artprocessors.net"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pcsclite_0.5.2_1561942959651_0.7535657391094142"},"_hasShrinkwrap":false},"0.5.3":{"name":"@ap-mitch/pcsclite","version":"0.5.3","description":"Bindings over PC/SC to access Smart Cards","keywords":["nfc","pcsc","pcsclite","smartcards"],"homepage":"https://github.com/ap-mitch/node-pcsclite#readme","bugs":{"url":"https://github.com/ap-mitch/node-pcsclite/issues"},"repository":{"type":"git","url":"git+https://github.com/ap-mitch/node-pcsclite.git"},"license":"ISC","author":{"name":"Santiago Gimeno","email":"santiago.gimeno@gmail.com","url":"https://github.com/santigimeno"},"contributors":[{"name":"Martin Endler","url":"https://github.com/pokusew"},{"name":"Mitch McCaffrey","url":"https://github.com/ap-mitch"}],"main":"lib/pcsclite.js","types":"index.d.ts","directories":{"example":"examples","lib":"lib","test":"test"},"scripts":{"install":"node-gyp rebuild","test":"mocha"},"dependencies":{"@types/node":"^12.6.9","bindings":"^1.4.0","nan":"^2.12.1"},"devDependencies":{"mocha":"^6.0.0","should":"^13.2.3","sinon":"^7.2.4"},"gypfile":true,"gitHead":"744514fdf9e652ebdcfe94fdd947cece6835fa94","_id":"@ap-mitch/pcsclite@0.5.3","_nodeVersion":"10.15.0","_npmVersion":"6.10.2","dist":{"integrity":"sha512-T4QJWbjVmaNoHvWFvQojaE35+qs56fDjK/pP/R2wNgFpuqaVGtVyAbSUer1uhfRmNc9oHi6X3s4KtOR3QW4zgQ==","shasum":"1123981c59b978aeec830b1748570b4bd693fe74","tarball":"https://registry.npmjs.org/@ap-mitch/pcsclite/-/pcsclite-0.5.3.tgz","fileCount":36,"unpackedSize":1074769,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdSRPTCRA9TVsSAnZWagAA2JkP/2JximGkLXkySyUmmHz2\naG+XBb1RHkH53FQeCxJxNPTPJUpbRsJOQ6FWoZ5nVD5WMkhPlgwqZAXUMq6y\ntGYRvEMAkoa4OZUulTL8LSNEGofM/KgvLPYm4AqEn5W4SVPvIWqwJQhSb+e+\njHtVWNYtwvVNJeS2rqBAuJo99C1Y9IZQ7s9MAe+r6d70Sq8gM4GzSd2hMhrJ\nNSFnKfQZefogN/3wj5oNSglLbkhczqFmskN7kdR6vVelHIkcIJIIoSX/8xeP\nRCGZqbPv9tq1Wu2Lr+OWmiO9mBtPB9Prd8MwHcE5fthtiXiX5VglcPHfgjUW\nb/oC7hRPJZqhvUYwDgfsWoz0TbjcA4uwcxUw2tVHGH7ry8cmUNgKRi1jsjKi\nZ4JScK8W8094f+0jdZ52vR+x0SL0Wi1oyG30+OcAqQyYzv8YstcOPOPxUjzL\n91SMlad9wB+TPNHPa0QjEyS4VHXHEmEU+I0CIMIjnbGvGeFSlO4TFlbjUZvV\nPxzQcxIKwhcmDxW4EMqNMvgC0wnLWM+O4mjJxCwrAa0AKfCjk2XNO0iwY9kg\nECK9Y959kar8K68EWQyqmlnTn8C9sK8LAztiFFZ1dbWqLtgXfDMPHajJxSUe\nLX8kUglYHgbxVhnH5gfMn4feKgkYkcOD7DRg63KoajHw/XTagiTGS02nYxYZ\nkZ44\r\n=oIKb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD7mZ06zKL8rYDRIvLivdCDFhcgvkqI9P38iz+FQnRQJQIhANe1oh5psrMBG5dYetbpt7FknA0UdzGoW7HIcjgYG5pc"}]},"maintainers":[{"name":"ap-mitch","email":"mitch@artprocessors.net"}],"_npmUser":{"name":"ap-mitch","email":"mitch@artprocessors.net"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pcsclite_0.5.3_1565070290356_0.6964349663162792"},"_hasShrinkwrap":false}},"time":{"created":"2019-07-01T01:02:39.610Z","0.5.2":"2019-07-01T01:02:39.798Z","modified":"2022-04-04T14:30:32.573Z","0.5.3":"2019-08-06T05:44:50.565Z"},"maintainers":[{"name":"ap-mitch","email":"mitch@artprocessors.net"}],"description":"Bindings over PC/SC to access Smart Cards","homepage":"https://github.com/ap-mitch/node-pcsclite#readme","keywords":["nfc","pcsc","pcsclite","smartcards"],"repository":{"type":"git","url":"git+https://github.com/ap-mitch/node-pcsclite.git"},"contributors":[{"name":"Martin Endler","url":"https://github.com/pokusew"},{"name":"Mitch McCaffrey","url":"https://github.com/ap-mitch"}],"author":{"name":"Santiago Gimeno","email":"santiago.gimeno@gmail.com","url":"https://github.com/santigimeno"},"bugs":{"url":"https://github.com/ap-mitch/node-pcsclite/issues"},"license":"ISC","readme":"# node-pcsclite\n\n[![npm](https://img.shields.io/npm/v/@pokusew/pcsclite.svg)](https://www.npmjs.com/package/@pokusew/pcsclite)\n[![node-pcsclite channel on discord](https://img.shields.io/badge/discord-join%20chat-61dafb.svg)](https://discord.gg/bg3yazg)\n\nBindings over pcsclite to access Smart Cards. It works in **Linux**, **macOS** and **Windows**.\n\n> **Looking for library to work easy with NFC tags?**  \ntake a look at [nfc-pcsc](https://github.com/pokusew/nfc-pcsc) which offers easy to use high level API for detecting / reading and writing NFC tags and cards\n\n\n## Content\n\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n\n\n- [Installation](#installation)\n- [Example](#example)\n- [Behavior on different OS](#behavior-on-different-os)\n- [API](#api)\n  - [Class: PCSCLite](#class-pcsclite)\n    - [Event:  'error'](#event--error)\n    - [Event:  'reader'](#event--reader)\n    - [pcsclite.close()](#pcscliteclose)\n  - [Class: CardReader](#class-cardreader)\n    - [Event:  'error'](#event--error-1)\n    - [Event:  'end'](#event--end)\n    - [Event:  'status'](#event--status)\n    - [reader.connect([options], callback)](#readerconnectoptions-callback)\n    - [reader.disconnect(disposition, callback)](#readerdisconnectdisposition-callback)\n    - [reader.transmit(input, res_len, protocol, callback)](#readertransmitinput-res_len-protocol-callback)\n    - [reader.control(input, control_code, res_len, callback)](#readercontrolinput-control_code-res_len-callback)\n    - [reader.close()](#readerclose)\n- [FAQ](#faq)\n  - [Can I use this library in my Electron app?](#can-i-use-this-library-in-my-electron-app)\n- [License](#license)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n\n## Installation\n\nIn order to install the package you need to **have installed in the system the\npcsclite libraries**.\n\nIn **macOS** and **Windows** you **don't have to install** anything.\n\n> For example, in Debian/Ubuntu:\n> ```bash\n> apt-get install libpcsclite1 libpcsclite-dev\n> ```\n> To run any code you will also need to have installed the pcsc daemon:\n> ```bash\n> apt-get install pcscd\n> ```\n\nOnce you have all needed libraries, you can install using npm:\n\n```bash\nnpm install @pokusew/pcsclite --save\n```\n\n## Example\n\n```javascript\nconst pcsclite = require('@pokusew/pcsclite');\n\nconst pcsc = pcsclite();\n\npcsc.on('reader', (reader) => {\n\n    console.log('New reader detected', reader.name);\n\n    reader.on('error', err => {\n        console.log('Error(', reader.name, '):', err.message);\n    });\n\n    reader.on('status', (status) => {\n\n        console.log('Status(', reader.name, '):', status);\n\n        // check what has changed\n        const changes = reader.state ^ status.state;\n\n        if (!changes) {\n            return;\n        }\n\n\t\t// noinspection JSBitwiseOperatorUsage\n        if ((changes & reader.SCARD_STATE_EMPTY) && (status.state & reader.SCARD_STATE_EMPTY)) {\n\n            console.log(\"card removed\");\n\n            reader.disconnect(reader.SCARD_LEAVE_CARD, err => {\n\n                if (err) {\n                    console.log(err);\n                    return;\n                }\n\n                console.log('Disconnected');\n\n            });\n\n            return;\n\n        }\n\n\t\t// noinspection JSBitwiseOperatorUsage\n        if ((changes & reader.SCARD_STATE_EMPTY) && (status.state & reader.SCARD_STATE_EMPTY)) {\n\n            console.log(\"card inserted\");\n\n            reader.connect({ share_mode: reader.SCARD_SHARE_SHARED }, (err, protocol) => {\n\n                if (err) {\n                    console.log(err);\n                    return;\n                }\n\n                console.log('Protocol(', reader.name, '):', protocol);\n\n                reader.transmit(Buffer.from([0x00, 0xB0, 0x00, 0x00, 0x20]), 40, protocol, (err, data) => {\n\n                    if (err) {\n                        console.log(err);\n                        return;\n                    }\n\n                    console.log('Data received', data);\n                    reader.close();\n                    pcsc.close();\n\n                });\n\n            });\n\n            // noinspection UnnecessaryReturnStatementJS\n            return;\n        }\n\n    });\n\n    reader.on('end', () => {\n        console.log('Reader', reader.name, 'removed');\n    });\n\n});\n\npcsc.on('error', err => {\n    console.log('PCSC error', err.message);\n});\n```\n\n## Behavior on different OS\n\nTODO document\n\n\n## API\n\n### Class: PCSCLite\n\nThe PCSCLite object is an EventEmitter that notifies the existence of Card Readers.\n\n#### Event:  'error'\n\n* *err* `Error Object`. The error.\n\n#### Event:  'reader'\n\n* *reader* `CardReader`. A CardReader object associated to the card reader detected\n\nEmitted whenever a new card reader is detected.\n\n#### pcsclite.close()\n\nIt frees the resources associated with this PCSCLite instance. At a low level it calls [`SCardCancel`](https://pcsclite.alioth.debian.org/api/group__API.html#gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6) so it stops watching for new readers.\n\n#### pcsclite.readers\n\nAn object containing all detected readers by name. Updated as readers are attached and removed.\n\n### Class: CardReader\n\nThe CardReader object is an EventEmitter that allows to manipulate a card reader.\n\n#### Event:  'error'\n\n* *err* `Error Object`. The error.\n\n#### Event:  'end'\n\nEmitted when the card reader has been removed.\n\n#### Event:  'status'\n\n* *status* `Object`.\n    * *state* The current status of the card reader as returned by [`SCardGetStatusChange`](https://pcsclite.alioth.debian.org/api/group__API.html#ga33247d5d1257d59e55647c3bb717db24)\n    * *atr* ATR of the card inserted (if any)\n\nEmitted whenever the status of the reader changes.\n\n#### reader.connect([options], callback)\n\n* *options* `Object` Optional\n    * *share_mode* `Number` Shared mode. Defaults to `SCARD_SHARE_EXCLUSIVE`\n    * *protocol* `Number` Preferred protocol. Defaults to `SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1`\n* *callback* `Function` called when connection operation ends\n    * *error* `Error`\n    * *protocol* `Number` Established protocol to this connection.\n\nWrapper around [`SCardConnect`](https://pcsclite.alioth.debian.org/api/group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5).\nEstablishes a connection to the reader.\n\n#### reader.disconnect(disposition, callback)\n\n* *disposition* `Number`. Reader function to execute. Defaults to `SCARD_UNPOWER_CARD`\n* *callback* `Function` called when disconnection operation ends\n    * *error* `Error`\n\nWrapper around [`SCardDisconnect`](https://pcsclite.alioth.debian.org/api/group__API.html#ga4be198045c73ec0deb79e66c0ca1738a).\nTerminates a connection to the reader.\n\n#### reader.transmit(input, res_len, protocol, callback)\n\n* *input* `Buffer` input data to be transmitted\n* *res_len* `Number`. Max. expected length of the response\n* *protocol* `Number`. Protocol to be used in the transmission\n* *callback* `Function` called when transmit operation ends\n    * *error* `Error`\n    * *output* `Buffer`\n\nWrapper around [`SCardTransmit`](https://pcsclite.alioth.debian.org/api/group__API.html#ga9a2d77242a271310269065e64633ab99).\nSends an APDU to the smart card contained in the reader connected to.\n\n#### reader.control(input, control_code, res_len, callback)\n\n* *input* `Buffer` input data to be transmitted\n* *control_code* `Number`. Control code for the operation\n* *res_len* `Number`. Max. expected length of the response\n* *callback* `Function` called when control operation ends\n    * *error* `Error`\n    * *output* `Buffer`\n\nWrapper around [`SCardControl`](https://pcsclite.alioth.debian.org/api/group__API.html#gac3454d4657110fd7f753b2d3d8f4e32f).\nSends a command directly to the IFD Handler (reader driver) to be processed by the reader.\n\n#### reader.close()\n\nIt frees the resources associated with this CardReader instance.\nAt a low level it calls [`SCardCancel`](https://pcsclite.alioth.debian.org/api/group__API.html#gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6) so it stops watching for the reader status changes.\n\n\n## FAQ\n\n### Can I use this library in my [Electron](https://electron.atom.io/) app?\n\n**Yes, you can!** It works well.\n\nBut please read carefully [Using Native Node Modules](https://electron.atom.io/docs/tutorial/using-native-node-modules/) guide in Electron documentation to fully understand the problematic.\n\n**Note**, that because of Node Native Modules, you must build your app on target platform (you must run Windows build on Windows machine, etc.).  \nYou can use CI/CD server to build your app for certain platforms.  \nFor Windows, I recommend you to use [AppVeyor](https://appveyor.com/).  \nFor macOS and Linux build, there are plenty of services to choose from, for example [CircleCI](https://circleci.com/), [Travis CI](https://travis-ci.com/) [CodeShip](https://codeship.com/).\n\n## License\n\n[ISC](/LICENSE.md)\n","readmeFilename":"README.md"}