hdm-card-events
v0.4.0
Published
Kenya Personal ID Card reader for NodeJS (PCSClite)
Downloads
2
Readme
Huduma-id-reader
Hudumacard reader for nodeJS.
Credits. ADPU Command from ThaiNationalIDCard and HexString convertion from thai-smartcard-reader
Installation
Using npm
$ npm install --save hdm-card-events
Using yarn
$ yarn add hdm-card-events
Example
const { KenyaCardReader, EVENTS, MODE } = require('hdm-card-events')
const reader = new KenyaCardReader()
reader.readMode = MODE.PERSONAL_PHOTO
reader.autoRecreate = true
reader.startListener()
reader.on(EVENTS.READING_COMPLETE, (obj) => {
console.log(obj)
})
API
EVENTS
The KenyaCardReader
object emits the following events
Event: PCSC_INITIAL
Emitted when a listener is started.
Event: PCSC_CLOSE
Emitted when a PCSC device is detached.
Event: DEVICE_WAITING
Emitted when a smart card reader is disconnected from host. (Only auto re-create is set to true
).
Event: DEVICE_CONNECTED
Emitted when a smart card reader is ready to read.
Event: DEVICE_ERROR
Emitted when a smart card reader is error.
Event: DEVICE_DISCONNECTED
Emitted when a smart card reader is detached from host.
Event: CARD_INSERTED
Emitted when a smart card is inserted.
Event: CARD_REMOVED
Emitted when a smart card is removed.
Event: READING_INIT
Emitted when a device prepare to reading data.
Event: READING_START
Emitted when a device start to reading data.
Event: READING_PROGRESS
Emitted while a device reading data. This event return progress.
Returns Object
:
{
step: 1, // Current reading segment
of: 25, // All segment
message: '' // Section name
}
Event: READING_COMPLETE
Emitted when a device finish reading data.
Returns Object
:
{
citizenId: '1999999999999',
titleTH: 'นาย',
firstNameTH: '',
lastNameTH: '',
titleEN: 'Mr.',
firstNameEN: '',
lastNameEN: '',
birthday: '1900-01-01',
gender: 'male',
address: 'address',
issue: '2000-01-01',
expire: '2010-01-01',
photo: 'data:image/jpeg;....'
}
Event: READING_FAIL
Emitted when reading data fail
MODE
Mode: PERSONAL
Read only personal data
Mode: PERSONAL_PHOTO
Read both personal data and photo
License
You can use for free with MIT License