NodeJS binding of Freefare to access Mifare cards (classic, Ultralight and DESfire) via libNFC
npm install freefare
NodeJS binding of LibFreefare. LibFreefare is a library to manipulate Mifare NFC smart cards (Classic, DESFire, Ultralight, etc) over LibNFC. Your reader has to be compatible with LibNFC to work with this Library (Check out the compatibility matrix to know if your device is compatible)
Due to lack of time and testing material, the binding is not complete :
* Mifare Ultralight : fully Supported
* Mifare Classic 1K/4K : Partially supported (enough to authenticate, write and read a data block)
* Mifare DESFire : Partially supported (enough to select an application, authenticate in DES/3DES and read/write on a file)
If you need Freefare function which are currently not bound, submit an issue, a pull request or contact me by email.
You need at least NodeJS v6. Go to NodeJs website to know how to get it for your system.
You also need LibFreefare. Under debian you can do
```
apt-get install libfreefare0 libfreefare-dev
Finally use npm. to install this package
``
npm install freefare
You can find examples under the examples/ directory
#### Freefare.listDevices()
Give a list of available NFC devices
Returns: Promise., A promise to the Device list.
method have to be executed before any other.#### Device.open()
Open device for further communication
Returns:
Promise, A promise to the end of the action.#### Device.close()
Close device to release memory and device
Returns:
Promise, A promise to the end of the action.#### Device.listTags()
List of detected tags
Returns:
Promise., A promise to the list of Tag#### Device.abort()
Abort command blocking the device like open().
Returns:
Promise, A promise to the end of the action.$3
A Freefare compatible NFC tag#### Tag.getType()
Get Tag type
Returns:
string, The tag type between MIFARE_CLASSIC_1K, MIFARE_CLASSIC_4K, MIFARE_DESFIRE, MIFARE_ULTRALIGHT, MIFARE_ULTRALIGHT_C#### Tag.getFriendlyName()
Get Tag friendly name
Returns:
string, The tag friendly name#### Tag.getUID()
Get Tag UID
Returns:
string, The tag UID
$3
A MIFARE Ultralight tagExtends:
Tag#### MifareUltralightTag.open()
Open tag for further communication
Returns:
Promise, A promise to the end of the action.#### MifareUltralightTag.close()
Close tag to release memory and device
Returns:
Promise, A promise to the end of the action.#### MifareUltralightTag.read(page)
Read a page on the tag
Parameters
* page:
Number, The page number between 0 and 11Returns:
Promise., A promise to the read data (in a 4 bytes buffer)#### MifareUltralightTag.write(page, buf)
Write a page on the tag
Parameters
* page:
Number, The page number between 0 and 11
* buf: Buffer, A buffer of 4 bytes to be written on the pageReturns:
Promise, A promise to the end of the action.
$3
A MIFARE Classic tagExtends:
Tag
#### MifareClassicTag.open()
Open tag for further communication
Returns:
Promise, A promise to the end of the action.#### MifareClassicTag.close()
Close tag to release memory and device
Returns:
Promise, A promise to the end of the action.#### MifareClassicTag.authenticate(block, key, keyType)
After openning the tag, an authentication is required for further operation.
Parameters
* block:
Number, The block number between 0 and 63 (for 1k)
* key: Buffer, The key
* keyType: String, "A" or "B"Returns:
Promise, A promise to the end of the action.#### MifareClassicTag.read(block)
Read the given block
Parameters
* block:
Number, The block number between 0 and 63 (for 1k)Returns:
Promise., A promise to the read data (in a 16 bytes buffer)#### MifareClassicTag.write(block, data)
Write on the given block
Parameters
* block:
Number, The block number between 0 and 63 (for 1k)
* data: Buffer, A 16 byte buffer (for 1k)Returns:
Promise, A promise to the end of the action.#### MifareClassicTag.initValue(block, value, adr)
Initialize a value block, with the given value and address
Parameters
* block:
Number, The block number between 0 and 63 (for 1k)
* value: Number, The Int32 value that will be stored
* adr: String, A 1 byte address which can be used to save the storage address of a block, when implementing a powerful backup managementReturns:
Promise, A promise to the end of the action.#### MifareClassicTag.readValue(block)
Read a value block
Parameters
* block:
Number, The block number between 0 and 63 (for 1k)Returns:
Promise.