Readers manipulation¶
Obtaining readers¶
The smart card readers (whether virtual of physical) can be obtained through the following means:
-
SCWS.
readers
¶ Maintains the list of all known smart card readers in the system, as an array of
SCWS.Reader()
objects. This list is initially empty when the page loads, until the environment is established usingSCWS.createEnvironment()
.
-
SCWS.
updateReaderList
()¶ Fills in or forces the update of the
SCWS.readers
array.If updates are made to the reader list within the processing, the appropriate event callbacks are called.
- Returns
A
Promise
resolved when the operation is complete. The resulting value is the updatedSCWS.readers
array itself.
-
SCWS.
getReader
(name)¶ Returns the reader with the given name.
- Arguments
name – The reader name, as a string.
- Returns
The requested
SCWS.Reader()
object (the result is returned immediately, not through aPromise
).
Reader events¶
Reader events can be monitored by providing the following callback functions:
-
SCWS.
onreaderadded
¶ Callback (can be assigned to a user function) used to receive notifications when a reader is plugged in the computer.
The new
SCWS.Reader()
object is given as a parameter to the callback function.
-
SCWS.
onreaderremoved
¶ Callback (can be assigned to a user function) used to receive notifications when a reader is unplugged from the computer.
The removed
SCWS.Reader()
object is given as a parameter to the callback function.
-
SCWS.
onreaderstatechanged
¶ Callback (can be assigned to a user function) used to receive notifications when the state of a reader changes (e.g. insertion or withdrawal of a card, …).
The affected
SCWS.Reader()
object is given as a parameter to the callback function. Its properties can be consulted (e.g.Reader.status
,Reader.cardPresent
, …) to obtain more information about the event.
Readers attributes¶
The Reader
class is described below:
-
class
SCWS.
Reader
()¶ SCWS.Reader Represents a smart card reader (either a physical, hardware reader, or a virtual smart card reader).
-
Reader.
name
¶ The name of the reader.
-
Reader.
cardPresent
¶ Boolean indicating if a card is inserted in the reader.
-
Reader.
status
¶ Status of the reader, as a string. The following status strings can be returned:
"unavailable"
: Indicates the reader has been removed (unplugged from the computer)."mute"
: The inserted card is mute (no answer on reset), the connection is therefore impossible."exclusive"
: The reader is being used in exclusive mode by another process, the connection is impossible yet."ok"
: The reader is in a normal state (whether a card is inserted or not).Any other value indicates a problem with an indeterminate cause (driver problem, or malfunction).
-
Reader.
dongle
¶ Boolean indicating if the reader is known as a USB dongle type (as opposed to a standard ID-1 format card reader). Note that this is indicative, and based on an internal registry of reader names.
-
Reader.
virtual
¶ Boolean indicating if the reader is a virtual smart card.
-
Reader.
connect
()¶ Connects to the card inserted in the reader. This method succeeds only if the card is supported by the middleware.
- Returns
A
Promise
resolving to theSCWS.Token()
object resulting from the operation.
-
Reader.
requiresNfcTagReaderSession
()¶ Boolean indicating if the device supports iOS NFC Tag Reader Session.