<commit_before># nfc-pcsc

[![npm](https://img.shields.io/npm/v/nfc-pcsc.svg?maxAge=2592000)](https://www.npmjs.com/package/nfc-pcsc)
[![nfc-pcsc channel on discord](https://img.shields.io/badge/discord-join%20chat-61dafb.svg)](https://discord.gg/bg3yazg)

Easy **reading and writing NFC tags and cards** in Node.js

Built-in support for auto-reading **card UIDs** and reading tags emulated with [**Android HCE**](https://developer.android.com/guide/topics/connectivity/nfc/hce.html).

> **NOTE:** Reading tag UID and methods for writing and reading tag content **depend on NFC reader commands support**.
It is tested to work with **ACR122 USB reader** but it should work with **all PC/SC compliant devices**.  
When detecting tags does not work see [Alternative usage](#alternative-usage).

This library uses pscslite native bindings [pokusew/node-pcsclite](https://github.com/pokusew/node-pcsclite) under the hood.

**Psst!** Problems upgrading to 0.6.0? Check out [this migration note](#migration-from-older-versions-to-060).


<!-- _**Psst!** You are browsing the documentation for the master branch, [look here](https://github.com/pokusew/nfc-pcsc/tree/v0.6.0) to see the usage of latest published version._ -->

## Content

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Installation](#installation)
- [Flow of handling tags](#flow-of-handling-tags)
- [Basic usage](#basic-usage)
	- [Running examples locally](#running-examples-locally)
- [Alternative usage](#alternative-usage)
- [Reading and writing data](#reading-and-writing-data)
- [More examples](#more-examples)
- [FAQ](#faq)
  - [Migration from older versions to 0.6.0](#migration-from-older-versions-to-060)
  - [Can I use this library in my Electron app?](#can-i-use-this-library-in-my-electron-app)
  - [Do I have to use Babel in my app too?](#do-i-have-to-use-babel-in-my-app-too)
  - [How do I require/import this library?](#how-do-i-requireimport-this-library)
  - [Can I read a NDEF formatted tag?](#can-i-read-a-ndef-formatted-tag)
- [Frequent errors](#frequent-errors)
  - [TypeError: NFC is not a constructor](#typeerror-nfc-is-not-a-constructor)
  - [Transaction failed error when using `CONNECT_MODE_DIRECT`](#transaction-failed-error-when-using-connect_mode_direct)
  - [Mifare Classic: Authentication Error after Multiple Writes](#mifare-classic-authentication-error-after-multiple-writes)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->


## Installation

> **Requirements:** **Node.js 7+** (it might work under 6.x but it is not tested)

> **Note:** This library uses system PC/SC API. On **Windows and macOS** it works out of the box, but on Linux you have to do some steps as described [here](https://github.com/pokusew/node-pcsclite#installation)

Using npm:

```bash
npm install nfc-pcsc --save
```

or with yarn:
<commit_msg>Update table of contents in README<commit_after># nfc-pcsc

[![npm](https://img.shields.io/npm/v/nfc-pcsc.svg?maxAge=2592000)](https://www.npmjs.com/package/nfc-pcsc)
[![nfc-pcsc channel on discord](https://img.shields.io/badge/discord-join%20chat-61dafb.svg)](https://discord.gg/bg3yazg)

Easy **reading and writing NFC tags and cards** in Node.js

Built-in support for auto-reading **card UIDs** and reading tags emulated with [**Android HCE**](https://developer.android.com/guide/topics/connectivity/nfc/hce.html).

> **NOTE:** Reading tag UID and methods for writing and reading tag content **depend on NFC reader commands support**.
It is tested to work with **ACR122 USB reader** but it should work with **all PC/SC compliant devices**.  
When detecting tags does not work see [Alternative usage](#alternative-usage).

This library uses pscslite native bindings [pokusew/node-pcsclite](https://github.com/pokusew/node-pcsclite) under the hood.

**Psst!** Problems upgrading to 0.6.0? Check out [this migration note](#migration-from-older-versions-to-060).


<!-- _**Psst!** You are browsing the documentation for the master branch, [look here](https://github.com/pokusew/nfc-pcsc/tree/v0.6.0) to see the usage of latest published version._ -->

## Content

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Installation](#installation)
- [Flow of handling tags](#flow-of-handling-tags)
- [Basic usage](#basic-usage)
	- [Running examples locally](#running-examples-locally)
- [Alternative usage](#alternative-usage)
- [Reading and writing data](#reading-and-writing-data)
- [More examples](#more-examples)
- [FAQ](#faq)
  - [Migration from older versions to 0.6.0](#migration-from-older-versions-to-060)
  - [Can I use this library in my Electron app?](#can-i-use-this-library-in-my-electron-app)
  - [Can I use this library in my angular-electron app?](#can-i-use-this-library-in-my-angular-electron-app)
  - [Do I have to use Babel in my app too?](#do-i-have-to-use-babel-in-my-app-too)
  - [How do I require/import this library?](#how-do-i-requireimport-this-library)
  - [Can I read a NDEF formatted tag?](#can-i-read-a-ndef-formatted-tag)
- [Frequent errors](#frequent-errors)
  - [TypeError: NFC is not a constructor](#typeerror-nfc-is-not-a-constructor)
  - [Transaction failed error when using `CONNECT_MODE_DIRECT`](#transaction-failed-error-when-using-connect_mode_direct)
  - [Mifare Classic: Authentication Error after Multiple Writes](#mifare-classic-authentication-error-after-multiple-writes)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->


## Installation

> **Requirements:** **Node.js 7+** (it might work under 6.x but it is not tested)

> **Note:** This library uses system PC/SC API. On **Windows and macOS** it works out of the box, but on Linux you have to do some steps as described [here](https://github.com/pokusew/node-pcsclite#installation)

Using npm:

```bash
npm install nfc-pcsc --save
```

or with yarn:

{'fraction_non_alphanumeric': 0.14772727272727273, 'fraction_numerical': 0.010540184453227932, 'mean_word_length': 4.456424079065589, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 16, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1105225', 'n_tokens_mistral': 2133, 'n_tokens_neox': 1943, 'n_words': 576}