Thai National ID card reader for nodeJS.
Credits. ADPU Command from ThaiNationalIDCard and HexString convertion from thai-smartcard-reader
$ npm install --save @privageapp/thai-national-id-reader
$ yarn add @privageapp/thai-national-id-reader
const { ThaiCardReader, EVENTS, MODE } = require('@privageapp/thai-national-id-reader')
const reader = new ThaiCardReader()
reader.readMode = MODE.PERSONAL_PHOTO
reader.autoRecreate = true
reader.startListener()
reader.on(EVENTS.READING_COMPLETE, (obj) => {
console.log(obj)
})
The ThaiCardReader
object emits the following events
Emitted when a listener is started.
Emitted when a PCSC device is detached.
Emitted when a smart card reader is disconnected from host. (Only auto re-create is set to true
).
Emitted when a smart card reader is ready to read.
Emitted when a smart card reader is error.
Emitted when a smart card reader is detached from host.
Emitted when a smart card is inserted.
Emitted when a smart card is removed.
Emitted when a device prepare to reading data.
Emitted when a device start to reading data.
Emitted while a device reading data. This event return progress.
Returns Object
:
{
step: 1, // Current reading segment
of: 25, // All segment
message: '' // Section name
}
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;....'
}
Emitted when reading data fail
Read only personal data
Read both personal data and photo
You can use for free with MIT License