Skip to content

About

Belgische eID inlezen in Next.js / Read Belgian eID cards in Next.js

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ProjectX eID

English · Nederlands

A small Next.js app that reads a Belgian eID card, in the browser and from the command line. Built on @dafkedd/eid, which lives in this repo too.

How it works

A browser cannot talk to a card reader. A small program runs on the PC, dafke-eid (the bridge), which talks to the reader via PC/SC and serves the card to allowed websites on 127.0.0.1:47820. This app shows what the bridge reads.

Getting started

Requires Node 20 or newer and a card reader with an eID (or the virtual card).

npm install
npm run eid:bridge      # starts the bridge and allows http://localhost:3000
npm run dev             # in a second terminal: http://localhost:3000

No card reader at hand? Open http://localhost:3000/?mock=1 (virtual card, no bridge needed), or run npm run eid:bridge:mock for a virtual reader through the real bridge.

Reading from the command line

Command What
npm run eid:readers List card readers
npm run eid:read Read the card (personal data masked)
npm run eid:read -- --full Show everything
npm run eid:read:json Everything as JSON (photo in base64)
npm run eid:read:mock Virtual card
npm run eid:diag Diagnostics for support

Structure

Path What
app/page.tsx The page
components/eid-section.tsx Loads the reader in the browser only
components/eid-provider.tsx ProjectEidProvider around EidProvider
components/eid-reader.tsx Status and card data (useEid())
lib/eid-client.ts Picks the real bridge or the virtual card (?mock=1)
lib/eid-view.ts Turns card data into what the page shows, with masking
app/download/page.tsx Download page for the Windows setup (/download)
lib/releasenotes.ts Release notes per version, in Dutch and French
installer/eid-installer.json Websites baked into the setup
scripts/build-exe.mjs Builds the eID program (npm run build:exe)
scripts/build-installer.mjs Builds the Windows setup (npm run build:installer)
installer/dafke-eid.iss Inno Setup script for the eID program
tests/ Vitest tests with the virtual card
packages/eid/ The @dafkedd/eid package: source, tests and docs (npm workspace)

Installer for end users (Windows)

End users need the eID program. One command builds a setup with ProjectX's websites already baked in: double-clicking is enough, no admin rights needed, and the program then starts automatically when the user signs in to Windows.

  1. ProjectX's websites (local, QA, ACC, production) are in installer/eid-installer.json (origins, and authOrigins if you use PIN login).

  2. Once: winget install JRSoftware.InnoSetup.

  3. Build (on Windows, Node 22 or 24):

    npm run build:installer

Everything is in this repo: the program is built from the bundled @dafkedd/eid package (npm run build:exe, works on any platform) and the setup from installer/dafke-eid.iss. You usually don't need to build the setup yourself: CI builds and tests it on Windows for every PR, and every GitHub release contains projectx-eid-setup-<version>.exe.

Result: public/downloads/projectx-eid-setup.exe (+ .sha256). The app automatically shows an "eID-programma installeren" button when the program is not running, pointing to this file (other address: NEXT_PUBLIC_EID_SETUP_URL).

Download page. /download (e.g. https://prod.dafkedd.be/download) offers the setup with version, size, SHA-256 and release notes, with an NL/FR language switch (also via ?lang=fr). Version and setup come from the same image, so QA, ACC and production each show their own version. Release notes live in lib/releasenotes.ts; a test fails if the version in package.json is missing there in either language.

IT can deploy the setup silently: projectx-eid-setup.exe /VERYSILENT /SUPPRESSMSGBOXES (see packages/eid/docs/uitrollen.md, in Dutch, for Intune and extra parameters).

No token in the setup. Anything inside a program people download can be extracted, so a baked-in token is not secret. build:installer therefore refuses a token in eid-installer.json. If you do want a token, pass it per PC during silent install (/TOKEN=…) and deliver it to the web app over a secure channel. For plain reading, the list of allowed websites is enough.

Signing. The setup is not signed, so Windows SmartScreen shows a warning ("More info" → "Run anyway"). A code signing certificate is recommended for end users.

Using it in another repo

  1. Install the package: npm install @dafkedd/eid (npmjs.com). From GitHub Packages instead: put @dafkedd:registry=https://npm.pkg.github.com in .npmrc.
  2. Copy components/ and lib/ (or just what you need) and put <EidSection /> on a page.
  3. Allow your website in the bridge: npx dafke-eid serve --origin https://your-site.be. End users install the dafke-eid program (see the @dafkedd/eid docs).
  4. Claude Code: npm install puts a skill in .claude/skills/dafkedd-eid/ that explains the whole package to Claude. Not there (pnpm, bun, --ignore-scripts)? Run npx dafke-eid skill. See packages/eid/README.md.

PIN login and server-side token validation are also possible: see packages/eid/docs/aan-de-slag.md (in Dutch).

Settings

Variable Default What
NEXT_PUBLIC_EID_BRIDGE_URL http://127.0.0.1:47820 Bridge address

Development

npm run typecheck
npm test
npm run build
npm run check          # all three

Releasing (QA → ACC → Release)

Branches: developer (work) → main (via PR) → release (via PR). On developer, main and every PR only the tests run (ci.yml). Only a push to release starts the release pipeline (release.yml), like in Azure DevOps:

Step Environment What
CI — Typecheck, tests and build on Linux and Windows; build and test the Windows setup; build the Docker image
Image — Docker image (with the Windows setup inside) to ghcr.io
QA qa Deploy that image to https://qa.dafkedd.be
ACC acc Deploy the same image to https://acc.dafkedd.be
Release production Same image to https://prod.dafkedd.be, then tag v<version> + GitHub release with the Windows setup, zip and sha256

Our own Debian server with Docker and Caddy fetches each new version itself (no inbound SSH needed). Setup: deploy/README.md.

Making a release:

npm run version:patch   # or version:minor / version:major, on developer

Then add the release notes for the new version to lib/releasenotes.ts (Dutch and French).

Commit, PR developer → main, then PR main → release. After the merge the pipeline runs. If the tag already exists, no release is made.

The package @dafkedd/eid has its own version (packages/eid/package.json). The Release step publishes it to npmjs.com and GitHub Packages when that version is not there yet; bump it with npm version patch -w @dafkedd/eid.

npmjs.com (set up once). Create the free organisation dafkedd on npmjs.com, make a token under Access Tokens → Generate New Token → Granular (package scope @dafkedd, Read and write) and add it in this repo under Settings → Secrets and variables → Actions as NPM_TOKEN. Without that secret the pipeline skips npmjs.com with a warning. GitHub Packages needs nothing extra.

Approval buttons (set up once). Go to Settings → Environments and open acc and production (they appear after the first run, or create them with New environment). Tick Required reviewers, add yourself and click Save protection rules. That step then waits in the Actions tab for a Review deployments → Approve and deploy button. Optionally set Deployment branches and tags to Selected branches: release so only release can deploy there.

Privacy

Personal data stays in the browser: the app sends nothing to a server and stores nothing. National number and street are masked by default ("Toon alles" shows them).

About

Belgische eID inlezen in Next.js / Read Belgian eID cards in Next.js

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages