arrow_back Return to Posts

Biometric Fingerprint Enrolment With NodeJS Using U.are.U Devices
By Godwin Udofia in October 2022 ~ NodeJS

Scanners tested

This was tested with the U.are.U 4000B and 4500 scanners.

The DPFJ and DPFPDD libraries

I stumbled upon this library, that aims to allow communication between a nodejs application and the DLL/SO of the DPFJ and DPFPDD libraries created by DigitalPersona/HID Global.

Initializing the reader

Once the fingerprint reader is connected, it must first be initialized.

const { UareU, CONSTANTS } = require("uareu-node");

const uareu = UareU.getInstance();

let reader;

const initializeScanner = async () => {
  return await uareu
    .loadLibs("./bin/dpfpdd.dll", "./bin/dpfj.dll")
    .then(() => {
      uareu.dpfpddInit();
    })
    .then(async () => {
      const devices = await uareu.dpfpddQueryDevices();

      if (devices.devicesNumber > 0) {
        return devices;
      }
    })
    .then((res) => res && uareu.dpfpddOpen(res.devicesList[0]))
    .then((res) => res && (reader = res))
    .catch((err) => {
      throw err;
    });
};

The DLL files at .loadLibs("./bin/dpfpdd.dll", "./bin/dpfj.dll") are provided by DigitalPersona/HID Global

Fingerprint enrolment

The application: an ElectronJS application that captures fingerprints to record staff attendance.

const identifyForEnrolment = async (staff) => {
  NEW_STAFF = staff;

  await uareu.dpfpddCancel(reader);

  return await uareu.dpfpddCaptureAsync(
    reader,
    CONSTANTS.DPFPDD_IMAGE_FMT.DPFPDD_IMG_FMT_ANSI381,
    CONSTANTS.DPFPDD_IMAGE_PROC.DPFPDD_IMG_PROC_DEFAULT,
    identifyForEnrolmentCallback
  );
};

let NEW_STAFF;

const identifyForEnrolmentCallback = async (data) => {
  uareu
    .dpfjCreateFmdFromFid(
      data,
      CONSTANTS.DPFJ_FMD_FORMAT.DPFJ_FMD_ANSI_378_2004
    )
    .then(async (res) => {
      let FMD_LIST = await AllFingerprints();

      if (FMD_LIST.length > 0) {
        let result = await uareu.dpfjIdentify(res, FMD_LIST);

        if (result.resultMessage === "Finger found.") {
          ipcMain.emit("enrolment:failed", "Finger already registered.");
          return;
        }
      }

      ipcMain.emit("enrolment:inform", "Fingerprint captured.");

      NEW_STAFF &&
        EnrolStaff(NEW_STAFF, res)
          .then((staff) => {
            ipcMain.emit("enrolment:completed");

            ipcMain.emit(
              "enrolment:inform",
              `Enrolment completed for ${staff.firstName} ${staff.lastName} (${staff.employeeNumber})`
            );
          })
          .catch((error) => {
            ipcMain.emit(
              "enrolment:failed",
              error.message ? error.message : error
            );
          });
    })
    .catch((error) => {
      console.log(error);
    });
};

Fingerprint identification

See this article to learn how to identify enrolled fingerprints.


Comments