santigimeno / node-pcsclite Goto Github PK
View Code? Open in Web Editor NEWBindings over pcsclite to access Smart Cards
License: ISC License
Bindings over pcsclite to access Smart Cards
License: ISC License
Wrapper for SCardControl
I want to get a "reliable" connection to the smart card. Right now there is an option to specify either shared or exclusive access to a reader during connect(). Exclusive access is the best option, but it is not always possible in real life situations - some other system app keeps a an idle connection to the reader open, for example. For such situations SCard(Begin|End)Transaction
could be used, together with a shared connection.
This is sometimes worse than a plain shared connection, as Windows 8+ have a "5 second rule" for transactions (see Remarks in MSDN: https://msdn.microsoft.com/en-us/library/windows/desktop/aa379469(v=vs.85).aspx)
There are at least two paths to a solution:
SCard*Transaction
calls on JS API level. This leaves the burden of transaction management to the app developerconnect()
that would indicate "shared mode transactions", which would call SCardBeginTransaction on non-windows platforms, together with SCardConnect
. And give a synthesized SCARD_E_SHARING_VIOLATION error if this fails for some reason.From flexibility POV, the first option would be best, from ease of use and 'DWIM' interface POV, I would probably wrap the exposed transaction mechanism behind a connect() wrapper before use, anyway.
Hello,
We have some windows configuration where card events are not received after first card removal. This windows are dev PC with mixed middlewares installation (gemalto, charismathics, personnal, alladin, ...). Maybe it's related, or not. I try to investigate on this.
For now, I see that monitoring stopped when SCARD_STATE_UNAVAILABLE is set. On this PC this event is triggered on card removal, but reader is still connected. In first and very fast analyse I should remove the check on this flag, but I think there is good reason for it (On linux or mac OS maybe ?).
I do some more tests, and come back to you with more informations on our windows stations. (value of other flags and return code).
Thanks,
When I run the npm install pcsclite
, it doesnt work
> [email protected] install /home/barisvelioglu/Projects/test/node_modules/buffertools
> node-gyp rebuild
make: Entering directory '/home/barisvelioglu/Projects/test/node_modules/buffertools/build'
CXX(target) Release/obj.target/buffertools/buffertools.o
SOLINK_MODULE(target) Release/obj.target/buffertools.node
COPY Release/buffertools.node
make: Leaving directory '/home/barisvelioglu/Projects/test/node_modules/buffertools/build'
> [email protected] install /home/barisvelioglu/Projects/test/node_modules/pcsclite
> node-gyp rebuild
make: Entering directory '/home/barisvelioglu/Projects/test/node_modules/pcsclite/build'
CXX(target) Release/obj.target/pcsclite/src/addon.o
In file included from ../src/addon.cpp:1:0:
../src/pcsclite.h:9:22: fatal error: winscard.h: No such file or directory
compilation terminated.
pcsclite.target.mk:112: recipe for target 'Release/obj.target/pcsclite/src/addon.o' failed
make: *** [Release/obj.target/pcsclite/src/addon.o] Error 1
make: Leaving directory '/home/barisvelioglu/Projects/test/node_modules/pcsclite/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-62-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/barisvelioglu/Projects/test/node_modules/pcsclite
gyp ERR! node -v v6.9.5
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! Linux 4.4.0-62-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "pcsclite"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the pcsclite package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs pcsclite
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls pcsclite
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/barisvelioglu/Projects/test/npm-debug.log
Maybe you could just reuse an existing license text like MIT.
Proposed patch:
+++ package.json 2015-09-13 14:22:36.000000000 +0200
@@ -30,9 +30,6 @@
"smartcards"
],
"author": "Santiago Gimeno <[email protected]>",
- "license": {
- "type": "ISC",
- "url": "https://github.com/santigimeno/node-pcsclite/blob/master/LICENSE"
- },
+ "license": "MIT",
"gypfile": true
}
Some reader manufacturers provide closed API's to manage specific cards. Usually these API's need to access the SCARDHANDLE that references a specific connection. Exposing the handle allows to implement nodejs wrappers around these API's
Hello there
Is there any way we can simplify APDU sending and retrieving?
Working with the buffers seems to have quite a steep learning curve for folks who don't understand very much of the subject.
Hopefully a higher level API would be enough and more time saving for those who want this library to work.
The attached file below is an eID Belgian SDK doc, for example on how the APi could be structured
Below is an APDU.js file taken from the Open Smart Card Development Platform ( http://www.openscdp.org/index.html)
Best regards
Pedro
Hi there. I get the following error when I try to npm install pcsclite
> [email protected] install /home/pi/nodelock/node_modules/pcsclite
> node-gyp rebuild
make: Entering directory `/home/pi/nodelock/node_modules/pcsclite/build'
CXX(target) Release/obj.target/pcsclite/src/addon.o
CXX(target) Release/obj.target/pcsclite/src/pcsclite.o
../src/pcsclite.cpp: In static member function ‘static void* PCSCLite::HandlerFunction(void*)’:
../src/pcsclite.cpp:126:47: warning: missing initializer for member ‘SCARD_READERSTATE::pvUserData’ [-Wmissing-field-initializers]
../src/pcsclite.cpp:126:47: warning: missing initializer for member ‘SCARD_READERSTATE::dwCurrentState’ [-Wmissing-field-initializers]
../src/pcsclite.cpp:126:47: warning: missing initializer for member ‘SCARD_READERSTATE::dwEventState’ [-Wmissing-field-initializers]
../src/pcsclite.cpp:126:47: warning: missing initializer for member ‘SCARD_READERSTATE::cbAtr’ [-Wmissing-field-initializers]
../src/pcsclite.cpp:126:47: warning: missing initializer for member ‘SCARD_READERSTATE::rgbAtr’ [-Wmissing-field-initializers]
CXX(target) Release/obj.target/pcsclite/src/cardreader.o
../src/cardreader.cpp: In static member function ‘static v8::Handle<v8::Value> CardReader::Connect(const v8::Arguments&)’:
../src/cardreader.cpp:110:91: error: invalid conversion from ‘void (*)(uv_work_t*) {aka void (*)(uv_work_s*)}’ to ‘uv_after_work_cb {aka void (*)(uv_work_s*, int)}’ [-fpermissive]
/home/pi/.node-gyp/0.10.20/deps/uv/include/uv.h:1432:15: error: initializing argument 4 of ‘int uv_queue_work(uv_loop_t*, uv_work_t*, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
../src/cardreader.cpp: In static member function ‘static v8::Handle<v8::Value> CardReader::Disconnect(const v8::Arguments&)’:
../src/cardreader.cpp:136:97: error: invalid conversion from ‘void (*)(uv_work_t*) {aka void (*)(uv_work_s*)}’ to ‘uv_after_work_cb {aka void (*)(uv_work_s*, int)}’ [-fpermissive]
/home/pi/.node-gyp/0.10.20/deps/uv/include/uv.h:1432:15: error: initializing argument 4 of ‘int uv_queue_work(uv_loop_t*, uv_work_t*, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
../src/cardreader.cpp: In static member function ‘static v8::Handle<v8::Value> CardReader::Transmit(const v8::Arguments&)’:
../src/cardreader.cpp:192:93: error: invalid conversion from ‘void (*)(uv_work_t*) {aka void (*)(uv_work_s*)}’ to ‘uv_after_work_cb {aka void (*)(uv_work_s*, int)}’ [-fpermissive]
/home/pi/.node-gyp/0.10.20/deps/uv/include/uv.h:1432:15: error: initializing argument 4 of ‘int uv_queue_work(uv_loop_t*, uv_work_t*, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
../src/cardreader.cpp: In static member function ‘static void* CardReader::HandlerFunction(void*)’:
../src/cardreader.cpp:258:47: warning: missing initializer for member ‘SCARD_READERSTATE::pvUserData’ [-Wmissing-field-initializers]
../src/cardreader.cpp:258:47: warning: missing initializer for member ‘SCARD_READERSTATE::dwCurrentState’ [-Wmissing-field-initializers]
../src/cardreader.cpp:258:47: warning: missing initializer for member ‘SCARD_READERSTATE::dwEventState’ [-Wmissing-field-initializers]
../src/cardreader.cpp:258:47: warning: missing initializer for member ‘SCARD_READERSTATE::cbAtr’ [-Wmissing-field-initializers]
../src/cardreader.cpp:258:47: warning: missing initializer for member ‘SCARD_READERSTATE::rgbAtr’ [-Wmissing-field-initializers]
make: *** [Release/obj.target/pcsclite/src/cardreader.o] Error 1
make: Leaving directory `/home/pi/nodelock/node_modules/pcsclite/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/opt/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.6.11+
gyp ERR! command "node" "/opt/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/nodelock/node_modules/pcsclite
gyp ERR! node -v v0.10.20
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0
Any ideas?
Hi all,
I'm probably just being a noob here but getting a node-gyp error when trying to install.
versions:
node: 8.1.0
npm: 5.0.3
os x: 10.12.5
error:
In file included from ../src/addon.cpp:1:
In file included from ../src/pcsclite.h:6:
/usr/local/opt/pcsc-lite/include/PCSC/winscard.h:41:10: error: 'pcsclite.h' file not found with <angled> include; use "quotes" instead
#include <pcsclite.h>
^~~~~~~~~~~~
"pcsclite.h"
In file included from ../src/addon.cpp:1:
In file included from ../src/pcsclite.h:6:
In file included from /usr/local/opt/pcsc-lite/include/PCSC/winscard.h:41:
/usr/local/opt/pcsc-lite/include/PCSC/pcsclite.h:45:10: error: 'wintypes.h' file not found with <angled> include; use "quotes" instead
#include <wintypes.h>
^~~~~~~~~~~~
"wintypes.h"
2 errors generated.
This looks like it's an error not having libpcsclite-dev
package. But I'm not seeing that package available for osx (brew or macports)
Can anyone confirm this is the issue I have? Where I can install the pcsc dev packages? Anything helps, thanks!
Hello,
First of all thanks for providing this wrapper,
I am trying to use it in a node-webkit application, however app is crashing everytime node-pcsclite,
At the moment i've been trying basic code, and even with the example you provide on the project page I am getting the following error :
nwjs Helper(955,0x7fff716c8180) malloc: *** error for object 0x7f8649476058: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug
Right before getting this message, and on the first time usage, everything is working great. but then it crashs, and keep crashing until I purge computer memory.
As I say for the moment the app is just a basic try, the application is not doing anything else but testing the example code.
Not sure what can I do to help.
Thanks
Basically this is the example code i have used, other examples gives me the same result at the end.
`#!/usr/bin/env node
var pcsc = require('./lib/pcsclite');
var pcsc = pcsc();
pcsc.on('reader', function(reader) {
function exit() {
reader.close();
pcsc.close();
}
cmd_select = new Buffer([0x00, 0xA4, 0x04, 0x00, 0x0A, 0xA0, 0x00, 0x00, 0x00, 0x62, 0x03, 0x01, 0x0C, 0x06, 0x01]);
cmd_command = new Buffer([0x00, 0x00, 0x00, 0x00]);
console.log('Using:', reader.name);
reader.connect(function(err, protocol) {
if (err) {
console.log(err);
return exit();
}
reader.transmit(cmd_select, 255, protocol, function(err, data) {
if (err) {
console.log(err);
return exit();
}
console.log('Data received', data);
reader.transmit(cmd_command, 255, protocol, function(err, data) {
if (err) {
console.log(err);
} else {
console.log('Data received', data);
console.log('Data received', data.toString());
}
return exit();
});
});
});
});
pcsc.on('error', function(err) {
console.log('PCSC error', err.message);
});`
But no matter which card i used it gives the same response (Mifare Ultralight and Mifare 1k classic)
Using: ACS ACR122 0
Data received < Buffer >
Data received < Buffer >
Data received
I have not idea what is going on with this.
Im using Windows 10, everything seems to be builded successfully.
Running the examples/example.js
example I get:
Protocol( undefined ): 2
The corresponding source code is:
console.log('Protocol(', this.name, '):', protocol);
I guess the plan was to display "T=0" or "T=1" depending on the negociated protocol.
Hi Santi,
I'n trying to compile node-pcsclite on a Macosx (10.9.4) without any success so far. I'm not an expert on node-gyp much less on pcsc so forgive me in advance for any wrong or inaccurate information.
Looking at you binding.gyp file and comparing it with other related projects like node-pcsc I could manage a few things to aid in the process of making your lib properly compile in other platforms.
1- declare the proper conditions for other platforms similar to this binding.gyp.
2- Fixed references to winscard.h with the guidance of @LudovicRousseau to include PCSC/winsdcadr.h instead of just winscard.h
UPDATE:Now I'm stuck with the compiler not finding nan.h
in my platform. Any ideas?
3- Referenced Nan in all platforms.
Now I'm getting errors with due to calls using unsigned long pointers instead of to uint32_t. From here I'm not sure if is safe to just change the type or if I should be aware of any type incompatibility. Any ideas?
> node-gyp rebuild
CXX(target) Release/obj.target/pcsclite/src/addon.o
CXX(target) Release/obj.target/pcsclite/src/pcsclite.o
../src/pcsclite.cpp:169:14: error: no matching function for call to 'SCardListReaders'
result = SCardListReaders(pcsclite->m_card_context, NULL, NULL, &readers_name_length);
^~~~~~~~~~~~~~~~
/System/Library/Frameworks/PCSC.framework/Headers/winscard.h:109:19: note: candidate function not viable: no known conversion from 'unsigned long *' to 'uint32_t *'
(aka 'unsigned int *') for 4th argument
PCSC_API int32_t SCardListReaders(SCARDCONTEXT hContext,
^
../src/pcsclite.cpp:176:14: error: no matching function for call to 'SCardListReaders'
result = SCardListReaders(pcsclite->m_card_context, NULL, readers_name, &readers_name_length);
^~~~~~~~~~~~~~~~
/System/Library/Frameworks/PCSC.framework/Headers/winscard.h:109:19: note: candidate function not viable: no known conversion from 'unsigned long *' to 'uint32_t *'
(aka 'unsigned int *') for 4th argument
PCSC_API int32_t SCardListReaders(SCARDCONTEXT hContext,
^
2 errors generated.
Thanks!
$ npm install pcsclite
npm WARN install Refusing to install pcsclite as a dependency of itself
Maybe the documentation in README.md is not correct.
I am using Debian unstable (sid).
$ npm install
> [email protected] install /home/lroussea/Documents/github/node-pcsclite
> node-gyp rebuild
/bin/sh: 1: node: not found
gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:344:16)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 3.2.0-4-amd64
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/lroussea/Documents/github/node-pcsclite
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the pcsclite package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls pcsclite
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.2.0-4-amd64
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /home/lroussea/Documents/github/node-pcsclite
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/lroussea/Documents/github/node-pcsclite/npm-debug.log
npm ERR! not ok code 0
It looks like the problem is that on Debian the node
binary is nodejs
.
± cat npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'install' ]
2 info using [email protected]
3 info using [email protected]
4 verbose readDependencies using package.json deps
5 verbose install where, deps [ '/home/lroussea/Documents/github/node-pcsclite',
5 verbose install [ 'buffertools', 'bindings', 'nan', 'mocha', 'sinon', 'should' ] ]
6 info preinstall [email protected]
7 verbose readDependencies using package.json deps
8 verbose already installed skipping nan@^1.3.0 /home/lroussea/Documents/github/node-pcsclite
9 verbose already installed skipping buffertools@^2.1.2 /home/lroussea/Documents/github/node-pcsclite
10 verbose already installed skipping bindings@^1.1.0 /home/lroussea/Documents/github/node-pcsclite
11 verbose already installed skipping mocha@~1.11.0 /home/lroussea/Documents/github/node-pcsclite
12 verbose already installed skipping sinon@~1.3.4 /home/lroussea/Documents/github/node-pcsclite
13 verbose already installed skipping should@~1.2.2 /home/lroussea/Documents/github/node-pcsclite
14 silly resolved []
15 info build /home/lroussea/Documents/github/node-pcsclite
16 verbose linkStuff [ false, false, false, '/home/lroussea/Documents/github' ]
17 info linkStuff [email protected]
18 verbose linkBins [email protected]
19 verbose linkMans [email protected]
20 verbose rebuildBundles [email protected]
21 verbose rebuildBundles [ '.bin',
21 verbose rebuildBundles 'bindings',
21 verbose rebuildBundles 'buffertools',
21 verbose rebuildBundles 'mocha',
21 verbose rebuildBundles 'nan',
21 verbose rebuildBundles 'should',
21 verbose rebuildBundles 'sinon' ]
22 info install [email protected]
23 verbose unsafe-perm in lifecycle true
24 info [email protected] Failed to exec install script
25 error [email protected] install: `node-gyp rebuild`
25 error Exit status 1
26 error Failed at the [email protected] install script.
26 error This is most likely a problem with the pcsclite package,
26 error not with npm itself.
26 error Tell the author that this fails on your system:
26 error node-gyp rebuild
26 error You can get their info via:
26 error npm owner ls pcsclite
26 error There is likely additional logging output above.
27 error System Linux 3.2.0-4-amd64
28 error command "/usr/bin/nodejs" "/usr/bin/npm" "install"
29 error cwd /home/lroussea/Documents/github/node-pcsclite
30 error node -v v0.10.29
31 error npm -v 1.4.21
32 error code ELIFECYCLE
33 verbose exit [ 1, true ]
Environment:
OS : Mac OS X El Capitan
Node.js version : v6.3.0
pcsclite version : 0.4.9
Situation :
Following is the output when I was installing pcsclite.
kens-MacBook-Pro:node-pcsclite-master Ken$ npm install
npm WARN package.json [email protected] license should be a valid SPDX license expression
> [email protected] install /Users/ken/Documents/workspace/workspace_nodejs/node-pcsclite-master
> node-gyp rebuild
CXX(target) Release/obj.target/pcsclite/src/addon.o
CXX(target) Release/obj.target/pcsclite/src/pcsclite.o
../src/pcsclite.cpp:286:20: warning: comparison of integers of different signs: 'LONG' (aka 'int') and 'unsigned int' [-Wsign-compare]
if (result == SCARD_E_INSUFFICIENT_BUFFER) {
~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
CXX(target) Release/obj.target/pcsclite/src/cardreader.o
SOLINK_MODULE(target) Release/pcsclite.node
Can you help to solve it ?
Thank you ~
App threw an error during load
Error: Cannot find module './build/Debug/buffertools.node'
at Module._resolveFilename (module.js:455:15)
at Function.Module._resolveFilename (C:\Users\Igor\electron-quick-start\node_modules\electron\dist\resources\electron.asar\common\reset-search-paths.js:35:12)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object. (C:\Users\Igor\electron-quick-start\node_modules\buffertools\buffertools.js:26:20)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
Sorry if this is in the wrong place, this does not seem to be a pcscLite issue, but one with the example code for the node bindings, or perhaps my understanding of things. I'm pretty new to APDU and smart cards in general.
I have two different smart cards from (presumably) two vendors. I don't know for sure because there's no indication on either card, but they're issued by two different organizations, so I'm making an assumption that they're different. In any case, let's call them Card A and Card B.
Using the sample code provided in this module, Card A inserted into a card reader will receive the transmit buffer of [0x00,0xB0,0x00, 0x00, 0x20] and respond with its own buffer array. I haven't gotten to where I can make use of the response yet beyond printing the hex to the screen, but that's part of my learning curve and I accept it.
Card B, however, running the same code on the same host in the same card reader, responds with 'SCardTransmit error: Transaction failed. (0x80100016)'. Note that this card works fine with company-provided applications (e.g. signing & encrypting emails, etc), so it's not a faulty card.
Any thoughts on how to proceed?
I am not sure to love call backs so much. Sometimes a synchronous API is fine, especially when you want to send a sequence of APDU and have nothing better to do.
Do you plan to also provide a synchronous version like it is the case for File IO API?
http://www.daveeddy.com/2013/03/26/synchronous-file-io-in-nodejs/
Hi there nice project...
Is this project goal to enable client side javascript to access client-connected pcsc devices?
I mean, it runs on node.js at the server, but the javascript at local client would be able to connect to SmartCard readers connected to client computer (running browser) ?
Bruno
Does this work on windows?
Hello,
I try to use node-pcsclite with electron to make a desktop application.
if I use only node-pcsclite, it's works.
but as soon I add "var pcsc = require('pcsclite');" in the main.js of the electron main file, I get this error:
Error: Cannot find module './build/Debug/buffertools.node'
I find this issue, but I do not understand how to fix the problem, in my case it does not even work on the developement computer.
Can you help me,
I'm running Ubuntu 14.04 LTS 64
Hi,
I am trying to connect to the reader with direct mode to write on LCD. It works on Linux, but not on Windows. Are the drivers different?
var LCD_CONTRAST = new Buffer([0xFF, 0x00, 0x6C, 0x00, 0x00]);
clearScreen: function (reader) {
reader.connect({ share_mode: reader_object.SCARD_SHARE_DIRECT }, function (err, protocol) {
reader.transmit(LCD_CLEAR, 40, reader.SCARD_PROTOCOL_RAW, function (err, data) {
if (err) {
console.log('error clearing screen:', err);
}
});
});
}
I get [Error: SCardConnect error: Smart card was removed <0x8010069>] while trying to connect.
Cheers,
K
(taken from Open Smart Card Development Platform (www.openscdp.org))
(Implementation of ISO 7816-4 APDU processing )
APDU.INS_DEACTIVATE = 0x04;
APDU.INS_VERIFY = 0x20;
APDU.INS_MANAGE_SE = 0x22;
APDU.INS_CHANGE_REFERENCE_DATA = 0x24;
APDU.INS_PSO = 0x2A;
APDU.INS_RESET_RETRY_COUNTER = 0x2C;
APDU.INS_ACTIVATE = 0x44;
APDU.INS_GENERATE_KEY_PAIR = 0x46;
APDU.INS_EXTERNAL_AUTHENTICATE = 0x82;
APDU.INS_GET_CHALLENGE = 0x84;
APDU.INS_GENERAL_AUTHENTICATE = 0x86;
APDU.INS_COMPUTE_DIGITAL_SIGN = 0x9E;
APDU.INS_SELECT = 0xA4;
APDU.INS_READBINARY = 0xB0;
APDU.INS_READ_BINARY = 0xB0;
APDU.INS_READ_RECORD = 0xB2;
APDU.INS_VERIFY_CERTIFICATE = 0xBE;
APDU.INS_UPDATE_BINARY = 0xD6;
APDU.INS_TERMINATE = 0xE6;
APDU.SW_OK = 0x9000;
Process completed
APDU.SW_TIMEOUT = 0x6401;
Exec error: Command timeout
APDU.SW_OKMOREDATA = 0x6100;
Process completed, more data available
APDU.SW_WARNING = 0x6200;
Warning: NV-Ram not changed
APDU.SW_WARNING1 = 0x6201;
Warning: NV-Ram not changed 1
APDU.SW_DATAINV = 0x6281;
Warning: Part of data corrupted
APDU.SW_EOF = 0x6282;
Warning: End of file reached
APDU.SW_INVFILE = 0x6283;
Warning: Invalidated file
APDU.SW_INVFORMAT = 0x6284;
Warning: Invalid file control
APDU.SW_WARNINGNVCHG = 0x6300;
Warning: NV-Ram changed
APDU.SW_WARNINGCOUNT = 0x63C0;
Warning: Warning with counter
APDU.SW_WARNING0LEFT = 0x63C0;
Warning: Verify fail, no try left
APDU.SW_WARNING1LEFT = 0x63C1;
Warning: Verify fail, 1 try left
APDU.SW_WARNING2LEFT = 0x63C2;
Warning: Verify fail, 2 tries left
APDU.SW_WARNING3LEFT = 0x63C3;
Warning: Verify fail, 3 tries left
APDU.SW_EXECERR = 0x6400;
Exec error: NV-Ram not changed
APDU.SW_MEMERR = 0x6501;
Exec error: Memory failure
APDU.SW_MEMERRWRITE = 0x6581;
Exec error: Memory failure
APDU.SW_WRONGLENGTH = 0x6700;
Checking error: Wrong length
APDU.SW_CLANOTSUPPORTED = 0x6800;
Checking error: Function in CLA byte not supported
APDU.SW_LCNOTSUPPORTED = 0x6881;
Checking error: Logical channel not supported
APDU.SW_SMNOTSUPPORTED = 0x6882;
Checking error: Secure Messaging not supported
APDU.SW_LASTCMDEXPECTED = 0x6883;
Checking error: Last command of the chain expected
APDU.SW_CHAINNOTSUPPORTED = 0x6884;
Checking error: Command chaining not supported
APDU.SW_COMNOTALLOWED = 0x6900;
Checking error: Command not allowed
APDU.SW_COMINCOMPATIBLE = 0x6981;
Checking error: Command incompatible with file structure
APDU.SW_SECSTATNOTSAT = 0x6982;
Checking error: Security condition not satisfied
APDU.SW_AUTHMETHLOCKED = 0x6983;
Checking error: Authentication method locked
APDU.SW_REFDATANOTUSABLE = 0x6984;
Checking error: Reference data not usable
APDU.SW_CONDOFUSENOTSAT = 0x6985;
Checking error: Condition of use not satisfied
APDU.SW_COMNOTALLOWNOEF = 0x6986;
Checking error: Command not allowed (no current EF)
APDU.SW_SMOBJMISSING = 0x6987;
Checking error: Expected secure messaging object missing
APDU.SW_INCSMDATAOBJECT = 0x6988;
Checking error: Incorrect secure messaging data object
APDU.SW_INVPARA = 0x6A00;
Checking error: Wrong parameter P1-P2
APDU.SW_INVDATA = 0x6A80;
Checking error: Incorrect parameter in the command data field
APDU.SW_FUNCNOTSUPPORTED = 0x6A81;
Checking error: Function not supported
APDU.SW_NOAPPL = 0x6A82;
Checking error: File not found
APDU.SW_FILENOTFOUND = 0x6A82;
Checking error: File not found
APDU.SW_RECORDNOTFOUND = 0x6A83;
Checking error: Record not found
APDU.SW_OUTOFMEMORY = 0x6A84;
Checking error: Not enough memory space in the file
APDU.SW_INVLCTLV = 0x6A85;
Checking error: Nc inconsistent with TLV structure
APDU.SW_INVACC = 0x6A85;
Checking error: Access cond. n/f
APDU.SW_INCP1P2 = 0x6A86;
Checking error: Incorrect P1-P2
APDU.SW_INVLC = 0x6A87;
Checking error: Lc inconsistent with P1-P2
APDU.SW_RDNOTFOUND = 0x6A88;
Checking error: Reference data not found
APDU.SW_FILEEXISTS = 0x6A89;
Checking error: File already exists
APDU.SW_DFNAMEEXISTS = 0x6A8A;
Checking error: DF name already exists
APDU.SW_INVP1P2 = 0x6B00;
Checking error: Wrong parameter P1-P2
APDU.SW_INVLE = 0x6C00;
Checking error: Invalid Le
APDU.SW_INVINS = 0x6D00;
Checking error: Wrong instruction
APDU.SW_INVCLA = 0x6E00;
Checking error: Class not supported
APDU.SW_ACNOTSATISFIED = 0x9804;
Access conditions not satisfied
APDU.SW_NOMORESTORAGE = 0x9210;
No more storage available
APDU.SW_GENERALERROR = 0x6F00;
Checking error: No precise diagnosis
public setPin(int pin)
Send PIN for validation
Should return true or false
public setPuk(int puk)
Send PUK for validation
Should return true or false
public isVerified(string context)
Check if context is verified.
Should accept PIN or PUK as valid contextes.
Should return true or false
public getRetriesAvail(string context)
Check how many retries are available for a given context
Should accept PIN or PUK as valid contextes.
Should return true or false
public setCardType(string type)
Sets a SmartCard type ( EID, Credit Card, etc... )
public getCardType()
self explaining
Public getCardContents()
Gets all card contents for external storage. This method does imply legal issues for many cases like EID, Credit Cards, but for the sake of caching the data, I have added this method.
public getFS()
Gets the file system structure on the card.
This method should be ajusted for some spec for some CardTypes, since they may have different structs.
private sendAPDU(byte_array buffer)
self explaining
private decode(string data, string from, string to)
self explaining
decode a Hex to Ascii for example
private encode(string data, string from, string to)
self explaining
This describes an object to interact with a eID card.
Note: This was built on information I can read from the eID using my country's own middleware. Each country object should be able to provide more information, but I think these are most common
public setCountry(string country-code, string iso=’DEFAUL_ISO’)
sets a eID card profile for a given country and their card's ISO
public getPkiCert()
gets Public key certificate for Authentication purproses
public getSignCert()
gets Document Signing certificate.
public getName()
gets Name field
public getAddress()
gets Address field
public getID(string context);
get ID from a given context
Allowed values should be : Citizen, VAT, Voter, SocialSec, HealthCare
public getParentage();
get Mother and Father's names.
public getDateofBirth()
get date of birth
public getFingerPrints()
get fingerprint data
public getPhoto()
get photo
public getFreeField
Get the free text field available on the card
public setFreeField
Sets the free text field available on the card
Due to the use of pthreads, the project won't build on Windows.
Hello,
Do you plan a Raspberry Pi version?
bye,
Hervé
Hi,
I've noticed that whenever I disconnect my reader the library does emit end as intended to notify about reader removal. But once the reader is plugged back in the reader message is never emitted again?
Shouldn't there be a message when a reader is detected?
Using latest release 0.5.0 on Linux.
Thanks for your help.
Hi,
We will start a new project using your really nice library. Since we are going to use Typescript as our language of choice I sat down and wrote the typings. I asked myself if you would like to incorporate these typings in your project or if you would rather like to see them in the DefinitelyTyped-repository.
They may be not yet perfect but they work ;)
Just let me know if I should create a PR.
According to the "documentation" https://github.com/santigimeno/node-pcsclite#event--status the status event should be sent "whenever the status of the reader changes".
If I use the sample code I get:
$ node examples/example.js
New reader detected ACS ACR122U PICC Interface 00 00
Status( ACS ACR122U PICC Interface 00 00 ): { state: 34,
atr: <SlowBuffer 3b 8f 80 01 80 4f 0c a0 00 00 03 06 03 00 01 00 00 00 00 6a> }
card inserted
Protocol( undefined ): 2
Data received <SlowBuffer 63 00>
Here I remove the card
Status( ACS ACR122U PICC Interface 00 00 ): { state: 146, atr: <SlowBuffer > }
card removed
Status( ACS ACR122U PICC Interface 00 00 ): { state: 146, atr: <SlowBuffer > }
Disconnected
Status( ACS ACR122U PICC Interface 00 00 ): { state: 146, atr: <SlowBuffer > }
Status( ACS ACR122U PICC Interface 00 00 ): { state: 146, atr: <SlowBuffer > }
Status( ACS ACR122U PICC Interface 00 00 ): { state: 146, atr: <SlowBuffer > }
Status( ACS ACR122U PICC Interface 00 00 ): { state: 146, atr: <SlowBuffer > }
Here I get hundreds of duplicate log lines
Status( ACS ACR122U PICC Interface 00 00 ): { state: 146, atr: <SlowBuffer > }
Status( ACS ACR122U PICC Interface 00 00 ): { state: 18, atr: <SlowBuffer > }
Also the sample code should not have to use:
var changes = this.state ^ status.state;
if (changes) {
to detect a status change if the status event is sent only when the status changes.
I run the sample code on Mac OS X Mavericks.
npm install pcsclite..
throws the following error
C:\Desktop\BTReaderNode\node_modules\buffertools>if not defined npm_config_node_gyp (node "D:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
buffertools.cc
win_delay_load_hook.cc
c:\.node-gyp\9.3.0\include\node\v8.h(334): error C2988: unrecognizable template declaration/definition [C:\Desktop\BTReaderNode\node_modules\buffertools\build\buffertools.vcxproj]
c:\.node-gyp\9.3.0\include\node\v8.h(334): error C2059: syntax error : 'using' [C:\Desktop\BTReaderNode\node_modules\buffertools\build\buffertools.vcxproj]
c:\.node-gyp\9.3.0\include\node\v8.h(466): error C2332: 'enum' : missing tag name [C:\Desktop\BTReaderNode\node_modules\buffertools\build\buffertools.vcxproj]
c:\.node-gyp\9.3.0\include\node\v8.h(466): error C2236: unexpected 'class' 'v8::WeakCallbackType'. Did you forget a ';'? [C:\Desktop\BTReaderNode\node_modules\buffertools\build\buffertools.vcxproj]
......
c:\.node-gyp\9.3.0\include\node\v8.h(4046): fatal error C1003: error count exceeds 100; stopping compilation [C:\Desktop\BTReaderNode\node_modules\buffertools\build\buffertools.vcxproj]
....
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (D:\Program Files\nodejs\node_modules\
npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:159:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:209:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! node -v v9.3.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.
Windows 7 x86
reader.transmit(new Buffer([0x00, 0xB0, 0x00, 0x00, 0x20]), 200, protocol, function(err, data) {
if (err) {
console.log(err);
} else {
console.log('Data received', data);
reader.close();
pcsc.close();
}
});
I've got the error in the callback.
"SCardTransmit error: �������������� � ������� ���������� �� ��������.
(0x0000001f)"
My Windows is on Russian and this can be cause this strange "question marks"
Hello,
I have done some evaluation on you pcsc library and it looks perfectly suited for mine need from the functional point, but I have hit on one big issue.
I'm unable to build your pcsclite application on Windows 7 x64/ia32 when using nwjs v0.13.4 (the latest stable version). I have been playing quite long with this topic and have found that I'm able to build it for nwjs version v0.13.0-beta7.
I'm using Visual Studio 2013
On Mac is workign eveything fine.
Working command
cd node_modules\pcsclite
nw-gyp rebuild --target=0.13.0-beta7 --arch=ia32
Error command
cd node_modules\pcsclite
nw-gyp rebuild --target=0.13.4 --arch=ia32
Error message:
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe
failed with exit code: 1
Please can you advice ?
Thanks a lot.
Hello I'm trying to install pcsclite on Windows but I get an error with the node-gyp rebuild.
Do I need to install Python before?
Thank you for your answer.
Bruno
Here is the log from the command line.
PS C:\Windows\system32> npm install pcsclite
[email protected] install C:\Windows\system32\node_modules\pcsclite\node_modules\buffertools
node-gyp rebuild
C:\Windows\system32\node_modules\pcsclite\node_modules\buffertools>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-g
yp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:116:14)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:71:11
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Windows\system32\node_modules\pcsclite\node_modules\buffertools
gyp ERR! node -v v4.0.0
gyp ERR! node-gyp -v v3.0.1
gyp ERR! not ok
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "pcsclite"
npm ERR! node v4.0.0
npm ERR! npm v2.14.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the buffertools package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls buffertools
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Windows\system32\npm-debug.log
Mac OS X do not support Plug and Play.
So the algorithm used in PCSCLite::HandlerFunction to detect a request to exit do not work.
For example, allow reader.connect().then(...)
How can i get uid (unique ID) of NFC tag? Help me please!
I have a use case where I have to forward ADPU commands from one device to a remote card to perform an authentication procedure. During the authentication process I have to switch from T0 to T1 or from T1 to T0.
Problem is that if I try to change the protocol between two ADPU commands I get a protocol mismatch exception. Any thoughts on this would be highly appreciated !
Hey,
node-pcsclite
was working on monday with NaN 1.4.1, today it's not working anymore with NaN 1.5.1.
I suggest setting the exact dependency in the package.json ;)
Hi,
I'm just starting to learn smartcards systems and run into a problem. I have an HID Omikey 5321 CR on OSX El capitan. I installed the drivers from HID for osx. and try to run the exemple code from the node node-pcsclite.
The reader is recognized, and I can read the atr :
card inserted
Protocol( OMNIKEY CardMan (076B:5320) 5321 ): 2
Status( OMNIKEY CardMan (076B:5320) 5321 ): { state: 290,
atr: <Buffer 3b 8f 80 01 80 4f 0c a0 00 00 03 06 03 00 01 00 00 00 00 6a> }
but when it comes to send an APDU it keeps returning me
[Error: SCardTransmit error: Transaction failed.(0x80100016)]
From the HID device documentation :
Reading all 15 blocks from 0 to 14
Command APDU: ‘FFB0000000’
Response APDE: ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx9000’
Attempt to read 16 blocks
Command APDU: ‘FFB0000010’
Response APDE: ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx6282’
so I use
reader.transmit(new Buffer([0xFF, 0xB0, 0x00,0x00, 0x00]), 255, protocol, function(err, data) {
... }
But still the same error.
There is surely some steps i missed, so can anyone Help me ?
Thanks in advance
$ npm test
> [email protected] test /Users/rousseau/Documents/github/node-pcsclite
> mocha
․․․․․․․․
4 passing (13 ms)
4 failing
1) Testing CardReader private #_connect() #_connect() success:
Uncaught TypeError: number is not a function
at CardReader.<anonymous> (/Users/rousseau/Documents/github/node-pcsclite/test/test.js:81:21)
at Function.invoke (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:162:59)
at CardReader.proxy [as _connect] (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:132:34)
at CardReader.connect (/Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:81:14)
at PCSCLite.<anonymous> (/Users/rousseau/Documents/github/node-pcsclite/test/test.js:84:24)
at PCSCLite.emit (events.js:95:17)
at /Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:62:19
at Array.forEach (native)
at /Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:45:23
at PCSCLite.<anonymous> (/Users/rousseau/Documents/github/node-pcsclite/test/test.js:69:13)
at Function.invoke (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:162:59)
at PCSCLite.proxy (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:132:34)
at /Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:28:11
at process._tickCallback (node.js:419:13)
2) Testing CardReader private #_connect() #_connect() error:
Uncaught TypeError: number is not a function
at CardReader.<anonymous> (/Users/rousseau/Documents/github/node-pcsclite/test/test.js:97:21)
at Function.invoke (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:162:59)
at CardReader.proxy [as _connect] (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:132:34)
at CardReader.connect (/Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:81:14)
at PCSCLite.<anonymous> (/Users/rousseau/Documents/github/node-pcsclite/test/test.js:100:24)
at PCSCLite.emit (events.js:95:17)
at /Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:62:19
at Array.forEach (native)
at /Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:45:23
at PCSCLite.<anonymous> (/Users/rousseau/Documents/github/node-pcsclite/test/test.js:69:13)
at Function.invoke (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:162:59)
at PCSCLite.proxy (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:132:34)
at /Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:28:11
at process._tickCallback (node.js:419:13)
3) Testing CardReader private #_disconnect() #_disconnect() success:
Uncaught TypeError: number is not a function
at CardReader.<anonymous> (/Users/rousseau/Documents/github/node-pcsclite/test/test.js:128:21)
at Function.invoke (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:162:59)
at CardReader.proxy [as _disconnect] (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:132:34)
at CardReader.disconnect (/Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:98:14)
at PCSCLite.<anonymous> (/Users/rousseau/Documents/github/node-pcsclite/test/test.js:131:24)
at PCSCLite.emit (events.js:95:17)
at /Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:62:19
at Array.forEach (native)
at /Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:45:23
at PCSCLite.<anonymous> (/Users/rousseau/Documents/github/node-pcsclite/test/test.js:69:13)
at Function.invoke (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:162:59)
at PCSCLite.proxy (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:132:34)
at /Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:28:11
at process._tickCallback (node.js:419:13)
4) Testing CardReader private #_disconnect() #_disconnect() success:
Uncaught TypeError: number is not a function
at CardReader.<anonymous> (/Users/rousseau/Documents/github/node-pcsclite/test/test.js:128:21)
at Function.invoke (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:162:59)
at CardReader.proxy [as _disconnect] (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:132:34)
at CardReader.disconnect (/Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:98:14)
at PCSCLite.<anonymous> (/Users/rousseau/Documents/github/node-pcsclite/test/test.js:131:24)
at PCSCLite.emit (events.js:95:17)
at /Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:62:19
at Array.forEach (native)
at /Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:45:23
at PCSCLite.<anonymous> (/Users/rousseau/Documents/github/node-pcsclite/test/test.js:69:13)
at Function.invoke (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:162:59)
at PCSCLite.proxy (/Users/rousseau/Documents/github/node-pcsclite/node_modules/sinon/lib/sinon/spy.js:132:34)
at /Users/rousseau/Documents/github/node-pcsclite/lib/pcsclite.js:28:11
at process._tickCallback (node.js:419:13)
npm ERR! Test failed. See above for more details.
npm ERR! not ok code 0
The problematic code is like connect_cb(undefined, 1);
It looks like undefined
is not correct here. I do not know node-js enough to propose a patch.
One functionality smart card developers need to implement on top of PC/SC style "BIBO" (Bytes-In, Bytes-Out) interface is often ISO 7816-4 based T=0 response handling for 6CXX
(GET RESPONSE) and 61XX
(fixed Le) handling. So instead of making another 20 line npm module for the usability improvement, it would be great if the functionality was traight in node-pcsclite, for those small scritps that build straight on top of node-pcsclite
and do not want/need some heavier layer above it. Will make a PR if that sounds reasonable.
As commented by @jokesterfr at #2 (comment)
Error installing with nodejs on windows OS.
E.g. readers that are "never inserted" and therefore are not detected by on("reader")
.
I am a bit confused about cleanly closing the runtime after I am done with the reader I am interested in.
There is reader.disconnect()
which is a wrapper around SCardDisconnect()
, thus I obviously call it.
Then there is reader.close()
which is intended to call SCardCancel()
(for this specific reader?). I call it and get no errors.
Then there is pcsc.close()
which is intended to also call SCardCancel()
(for PnP reader tracking?). I call it and get an error event on pcsc: SCardGetStatusChange error: Command cancelled.(0x80100002)
. And the node process does not exit after this call. AFAIU SCardGetStatusChange
should never emit an error if it is cancelled (I suspect this is a bug)
Two questions:
process.exit()
?SCardGetStatusChange
should be sufficient, also for getting events for the pnp pseudo-reader as well as any connected readers, to be able to emit reade events (thus a pcsc.close()
should be sufficient, and should result in normal exit of nodejs runtime?)There seems to be a bunch of unused/closed/stale branches on Github, that could be cleaned up for those who run git branch -a
on their development boxes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.