NFC Agent

Configuration

Flags, environment variables, ports and files.

The shipped agent's flags, environment variables, ports and files.

Flags

FlagDefaultEnvironmentDescription
-device-port9470The agent port: clients, devices, pairing, the Control Center and the health check
-bootstrap-port9472The cleartext setup port, serving the phone setup page and the local CA. 0 turns it off, and with it the pairing QR in the log
-deviceThe PC/SC reader to use, by name, such as "ACS ACR122U". Detected when empty
-api-secretgeneratedThe API secret. When empty, the agent uses the one in api-secret.txt, creating it on first start
-allowed-originsDAVI_NFC_ALLOWED_ORIGINSComma-separated browser origins to allow, as host:port or full URLs. Saved to allowed-origins.json. * turns the origin check off until the agent exits
-require-paired-devicesfalseDAVI_NFC_REQUIRE_PAIRED_DEVICES=1Admit only devices that have paired. The shared API secret and the loopback bypass stop admitting devices. Clients are unaffected
-allow-loopback-bypassfalseDAVI_NFC_ALLOW_LOOPBACK_BYPASS=1Admit connections from this host without a credential. See Security
-allow-raw-apdufalseDAVI_NFC_ALLOW_RAW_APDU=1Open the raw APDU channel, so clients can send transceiveRequest and transceiveSequenceRequest
-keysDAVI_NFC_KEYSA JSON key file for MIFARE Classic, DESFire and NTAG 424 DNA. See Card keys. The flag wins when both are set
-auto-tlstrueGenerate and manage a self-signed certificate. If that fails, the agent logs a warning and serves cleartext
-cert, -keyServe this certificate and key instead
-install-cafalseCreate a local certificate authority and install it in the system trust store, so browsers trust the agent. See Connect from a browser
-config-dirper OSThe config directory
-versionPrint the version and exit

A boolean environment variable takes effect when set to 1. DAVI_NFC_APDU_TRACE=1 has no flag: it logs every APDU sent to a reader and its reply.

Settings changed from the tray or the Control Center while the agent runs, such as the selected reader, read-only mode or the raw APDU channel, last until it exits. Use the flags for what it should start with.

Signals

On Linux and macOS, SIGHUP reloads the key file given with -keys.

Ports

PortSchemeServes
9470HTTPS / WSS/ws (clients), /ws?mode=device (devices), /pair, /health, /api/v1/health, and the Control Center at /
9472HTTPThe phone setup page, /ca.pem and /ca.crt (PIN-gated)

The agent also advertises port 9470 over mDNS as _nfc-device._tcp. See Device API.

Files

The config directory is davi-nfc-agent inside the OS's user config directory:

OSConfig directory
Linux~/.config/davi-nfc-agent
macOS~/Library/Application Support/davi-nfc-agent
Windows%AppData%\davi-nfc-agent
FileHolds
api-secret.txtThe API secret. Copy it from the tray with Copy API Secret
allowed-origins.jsonThe browser origin allowlist, as a JSON array of host:port strings. Created with davi.social, shop.davi.social, localhost:3000 and localhost:3002
paired-devices.jsonPaired devices, with token hashes
tls/server.crt, tls/server.keyThe certificate the agent serves, reissued when the host's addresses change
tls/agent.keyThe long-lived key the certificate is issued for. Its pin is what devices store. Deleting it means every device pairs again
tls/hosts.txtThe names and addresses the certificate covers
ca/rootCA.pem, ca/rootCA-key.pemThe local certificate authority, with -install-ca

The agent restricts these files to the account it runs as.