Gathering detailed insights and metrics for @pokusew/pcsclite
Gathering detailed insights and metrics for @pokusew/pcsclite
Gathering detailed insights and metrics for @pokusew/pcsclite
Gathering detailed insights and metrics for @pokusew/pcsclite
npm install @pokusew/pcsclite
Typescript
Module System
Node Version
NPM Version
72.3
Supply Chain
98.8
Quality
75.6
Maintenance
100
Vulnerability
100
License
C++ (83.34%)
JavaScript (14.77%)
Python (1.89%)
Total Downloads
155,405
Last Day
30
Last Week
403
Last Month
1,436
Last Year
29,898
62 Stars
209 Commits
55 Forks
4 Watching
21 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
0.6.0
Package Id
@pokusew/pcsclite@0.6.0
Unpacked Size
66.01 kB
Size
14.90 kB
File Count
15
NPM Version
6.13.6
Node Version
10.18.1
Cumulative downloads
Total Downloads
Last day
-47.4%
30
Compared to previous day
Last week
6.9%
403
Compared to previous week
Last month
-11.5%
1,436
Compared to previous month
Last year
-35.8%
29,898
Compared to previous year
Bindings over pcsclite to access Smart Cards. It works in Linux, macOS and Windows.
📌 Looking for library to work easy with NFC tags?
Then take a look at nfc-pcsc which offers an easy to use high level API for detecting / reading and writing NFC tags and cards.
Requirements: at least Node.js 8 or newer (see this FAQ for more info)
Node Native Modules build tools
Because this library uses Node Native Modules (C++ Addons), which are automatically built (using node-gyp) when installing via npm or yarn, you need to have installed C/C++ compiler toolchain and some other tools depending on your OS.
Please refer to the node-gyp > Installation for the list of required tools depending on your OS and steps how to install them.
PC/SC API in your OS
On macOS and Windows you don't have to install anything, pcsclite API is provided by the OS.
On Linux/UNIX you'd probably need to install pcsclite library and deamon**.
For example, in Debian/Ubuntu:
1apt-get install libpcsclite1 libpcsclite-dev
To run any code you will also need to have installed the pcsc daemon:
1apt-get install pcscd
Once you have all needed libraries, you can install node-pcsclite using npm:
1npm install @pokusew/pcsclite --save
or using Yarn:
1yarn add @pokusew/pcsclite
👉 If you'd prefer an easy to use high level API for detecting / reading and writing NFC tags and cards, take a look at nfc-pcsc.
1const pcsclite = require('@pokusew/pcsclite'); 2 3const pcsc = pcsclite(); 4 5pcsc.on('reader', (reader) => { 6 7 console.log('New reader detected', reader.name); 8 9 reader.on('error', err => { 10 console.log('Error(', reader.name, '):', err.message); 11 }); 12 13 reader.on('status', (status) => { 14 15 console.log('Status(', reader.name, '):', status); 16 17 // check what has changed 18 const changes = reader.state ^ status.state; 19 20 if (!changes) { 21 return; 22 } 23 24 if ((changes & reader.SCARD_STATE_EMPTY) && (status.state & reader.SCARD_STATE_EMPTY)) { 25 26 console.log("card removed"); 27 28 reader.disconnect(reader.SCARD_LEAVE_CARD, err => { 29 30 if (err) { 31 console.log(err); 32 return; 33 } 34 35 console.log('Disconnected'); 36 37 }); 38 39 } 40 else if ((changes & reader.SCARD_STATE_PRESENT) && (status.state & reader.SCARD_STATE_PRESENT)) { 41 42 console.log("card inserted"); 43 44 reader.connect({ share_mode: reader.SCARD_SHARE_SHARED }, (err, protocol) => { 45 46 if (err) { 47 console.log(err); 48 return; 49 } 50 51 console.log('Protocol(', reader.name, '):', protocol); 52 53 reader.transmit(Buffer.from([0x00, 0xB0, 0x00, 0x00, 0x20]), 40, protocol, (err, data) => { 54 55 if (err) { 56 console.log(err); 57 return; 58 } 59 60 console.log('Data received', data); 61 reader.close(); 62 pcsc.close(); 63 64 }); 65 66 }); 67 68 } 69 70 }); 71 72 reader.on('end', () => { 73 console.log('Reader', reader.name, 'removed'); 74 }); 75 76}); 77 78pcsc.on('error', err => { 79 console.log('PCSC error', err.message); 80});
TODO document
The PCSCLite object is an EventEmitter that notifies the existence of Card Readers.
error
Error Object
. The error.reader
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.
An object containing all detected readers by name. Updated as readers are attached and removed.
The CardReader object is an EventEmitter that allows to manipulate a card reader.
error
Error Object
. The error.end
Emitted when the card reader has been removed.
status
Object
.
SCardGetStatusChange
Emitted whenever the status of the reader changes.
Object
Optional
Number
Shared mode. Defaults to SCARD_SHARE_EXCLUSIVE
Number
Preferred protocol. Defaults to SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1
Function
called when connection operation ends
Error
Number
Established protocol to this connection.Wrapper around SCardConnect
.
Establishes a connection to the reader.
Number
. Reader function to execute. Defaults to SCARD_UNPOWER_CARD
Function
called when disconnection operation ends
Error
Wrapper 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
Error
Buffer
Wrapper 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
Error
Buffer
Wrapper 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.
No, because it brings more problems than it solves. The C++ code (Node Native Modules, C++ Addons) is built automatically during installation (using node-gyp).
That means that cross-compilation is not possible by default. If you want to use this library in your Electron or NW.js, see Can I use this library in my Electron app?.
TODO document
in the meantime see #10
@pokusew/pcsclite officially supports the following Node.js versions: 8.x, 9.x, 10.x, 11.x, 12.x, 13.x.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
3 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
Found 2/27 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-13
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More