santigimeno / node-pcsclite

Bindings over pcsclite to access Smart Cards
ISC License
170 stars 125 forks source link

Reliable connection on all platforms #71

Open martinpaljak opened 7 years ago

martinpaljak commented 7 years ago

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:

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.