eid
The common ground of electronic identity cards, in pure Dart: commands, file
reading, card insertion and the values national cards share. Document
packages such as eid_belgium and eid_icao read the cards themselves.
Install
dependencies:
eid: ^0.1.0
Transports
A CardTransport carries bytes to a card. Adapters:
| eid_ccid | A USB or PC/SC card reader |
| eid_nfc | The NFC of an Android phone or an iPhone |
Any other is one method:
final class MyTransport implements CardTransport {
@override
Future<Uint8List> transmit(Uint8List command) async {
// Return the response, status bytes included.
}
}
Read a file
final channel = CardChannel(transport, onApdu: print);
await channel.selectPath([0x3F00, 0xDF01, 0x4031]);
final file = await channel.readTransparentFile();
A refused command throws a CardException, an unreachable card a
CardTransportException. onApdu never sees a PIN. Commands longer than
255 bytes, or expecting more than 256 back, go in extended length; files
larger than 32 KB are read with READ BINARY B1.
Cards going in and out
final watcher = CardWatcher(AnyCardTerminal(listTerminals))..start();
watcher.events.listen((event) {
switch (event) {
case CardInserted inserted:
read(inserted.connection);
case CardRemoved _:
clear();
}
});
AnyCardTerminal watches every terminal, those plugged in later included.
The watcher checks the card is still there with a harmless command, sent
when the card is idle. Commands that must follow one another, such as a
secure messaging session, go in exclusive:
await channel.exclusive(() async {
// No probe reaches the card until this ends.
});
Shared values
PartialDate is a birth date whose day or month may be unknown, with
ageOn and minimumAgeOn. Sex holds the three values of ICAO 9303.
Documents
| eid_belgium | The Belgian eID, Kids ID and residence cards |
| eid_icao | Passports and identity cards with an ICAO 9303 chip |
License
Released under the MIT licence.
More from COMAPPS
Every package COMAPPS publishes is listed at packages.comapps.be.
Libraries
- eid
- Talks to electronic identity cards over any transport.