@pos-360/touch-id
Version:
The Touch ID API is used to interface with fingerprint scanning hardware.
176 lines (173 loc) • 7.6 kB
TypeScript
declare const SecugenErrors: {
readonly ERROR_NONE: "Function Success";
readonly ERROR_CREATION_FAILED: "Failed to create SGFPM instance";
readonly ERROR_FUNCTION_FAILED: "Function failed to call for unknown reason";
readonly ERROR_INVALID_PARAM: "Invalid parameter";
readonly ERROR_NOT_USED: "Function is not used or not supported";
readonly ERROR_DLLLOAD_FAILED: "Failed to load sgfplib.dll. Make sure that sgfplib.dll is located at node's path";
readonly ERROR_DLLLOAD_FAILED_DRV: "Cannot load device driver";
readonly ERROR_DLLLOAD_FAILED_ALGO: "Cannot load matching module";
readonly ERROR_NO_LONGER_SUPPORTED: "Function is no longer supported";
readonly ERROR_DLLLOAD_FAILED_WSQ: "Sgwsqlib.dll not loaded";
readonly ERROR_SYSLOAD_FAILED: "Failed to load driver sys file";
readonly ERROR_INITIALIZE_FAILED: "Failed to initialize device";
readonly ERROR_LINE_DROPPED: "Image data loss occurred during capture";
readonly ERROR_TIME_OUT: "Timeout occurred during capture";
readonly ERROR_DEVICE_NOT_FOUND: "Device not found";
readonly ERROR_WRONG_IMAGE: "Wrong image - not recognized as a fingerprint image";
readonly ERROR_LACK_OF_BANDWIDTH: "USB Bandwidth is not sufficient for image transfer";
readonly ERROR_DEV_ALREADY_OPEN: "Device is already in use";
readonly ERROR_GETSN_FAILED: "Failed to get serial number of the device";
readonly ERROR_UNSUPPORTED_DEV: "Cannot determine device type";
readonly ERROR_FAKE_FINGER: "Fake finger detected";
readonly ERROR_FAKE_INITIALIZED: "Initialization of fake module failed";
readonly ERROR_FEAT_NUMBER: "Not enough minutiae features";
readonly ERROR_INVALID_TEMPLATE_TYPE: "Template type is invalid";
readonly ERROR_INVALID_TEMPLATE1: "1st template is invalid";
readonly ERROR_INVALID_TEMPLATE2: "2nd template is invalid";
readonly ERROR_EXTRACT_FAIL: "Failed to extract template";
readonly ERROR_MATCH_FAIL: "Cannot find matched template";
readonly ERROR_LICENSE_LOAD: "Failed to load license";
readonly ERROR_LICENSE_KEY: "Invalid license key";
readonly ERROR_LICENSE_EXPIRED: "License expired";
readonly ERROR_NO_IMAGE: "Invalid image";
readonly AUTO_ON_ACTIVE: "Auto-On is currently active. Please turn off before executing this function.";
readonly AUTO_ON_NOT_ACTIVE: "Auto-On is not active. Please turn on before executing this function.";
readonly DEVICE_NOT_OPENED: "Device is not opened";
readonly CAPTURE_LOW_QUALITY: "Capture image quality is too low";
readonly CAPTURE_TIMEOUT: "Capture timeout";
readonly CAPTURE_CANCELLED: "Capture was cancelled";
readonly MISC_ERROR: "Miscellaneous error";
readonly FAILURE_TO_INIT: "Module not initialized";
};
declare const UnsupportedPlatformPayload: {
readonly ok: false;
readonly code: "FAILURE_TO_INIT";
readonly message: "Module not initialized";
};
type SecugenErrorCodes = keyof typeof SecugenErrors;
type SecugenErrorMessages = (typeof SecugenErrors)[keyof typeof SecugenErrors];
type SecugenErrorMessage<T extends SecugenErrorCodes> = (typeof SecugenErrors)[T];
type GoodResult = {
ok: true;
};
type BadResult = {
ok: false;
code: SecugenErrorCodes;
message: SecugenErrorMessages;
};
type DefaultResponse = GoodResult | BadResult;
type GoodCaptureResult = GoodResult & {
raw_image: {
base64: string;
width: number;
height: number;
};
template: {
base64: string;
quality: number;
};
};
type CaptureResult = GoodCaptureResult | BadResult;
type GoodDeviceInfoResult = GoodResult & {
deviceId: number;
imageWidth: number;
imageHeight: number;
contrast: number;
brightness: number;
gain: number;
imageDpi: number;
};
type DeviceInfoResult = GoodDeviceInfoResult | BadResult;
declare const AutoOnEvent: {
readonly FingerOn: "fingerOn";
readonly FingerOff: "fingerOff";
readonly Capture: "capture";
readonly SystemError: "error";
};
type AutoOnEvent = (typeof AutoOnEvent)[keyof typeof AutoOnEvent];
type AutoOnEventPayloads = {
[AutoOnEvent.FingerOn]: void;
[AutoOnEvent.FingerOff]: void;
[AutoOnEvent.Capture]: CaptureResult | BadResult;
[AutoOnEvent.SystemError]: BadResult;
};
type AutoOnEventPayload<T extends AutoOnEvent> = AutoOnEventPayloads[T];
type GoodCompareResult = GoodResult & {
isMatch: boolean;
};
type CompareResult = GoodCompareResult | BadResult;
declare class SecugenHandler {
constructor();
/**
* @description
* Start the auto-on mode of the fingerprint scanner, thus allowing the
* scanner to capture fingerprints automatically and emit events.
*/
startAutoOn(): Promise<DefaultResponse>;
/**
* @description
* Stop the auto-on mode of the fingerprint scanner, thus stopping the
* scanner from capturing fingerprints automatically and emitting events.
*/
stopAutoOn(): DefaultResponse;
/**
* @description
* Subscribe to an auto-on event emitted by the fingerprint scanner.
*/
subscribeToAutoOnEvent<T extends AutoOnEvent>(event: T, listener: (payload: AutoOnEventPayload<T>) => void): DefaultResponse;
/**
* @description
* Unsubscribe from an auto-on event emitted by the fingerprint
* scanner.
*/
unsubscribeFromAutoOnEvent<T extends AutoOnEvent>(event: T, listener: (payload: AutoOnEventPayload<T>) => void): DefaultResponse;
/**
* @description
* Get the device information of the fingerprint scanner.
*/
getDeviceInfo(): DeviceInfoResult;
/**
* @description
* Open the fingerprint scanner device.
*/
open(): DefaultResponse;
/**
* @description
* Capture and create a template from the fingerprint scanner.
*
* @param {number} timeout The timeout in milliseconds.
*/
captureAndCreateTemplate(timeout: number): Promise<CaptureResult>;
/**
* @description
* Capture a fingerprint from the auto-on mode of the fingerprint scanner.
* This method will return a promise that resolves with the captured
* fingerprint data. Accepts an optional timeout parameter that will reject
* the promise if the timeout is reached.
*
* @param {number} [timeout] The timeout in milliseconds.
*/
captureFromAutoOn(timeout?: number): Promise<CaptureResult>;
/**
* @description
* Cancel the capture from the auto-on mode of the fingerprint scanner.
* This method will reject the promise returned by the `captureFromAutoOn`
*/
cancelCaptureFromAutoOn(): Promise<DefaultResponse>;
/**
* @description
* Close the fingerprint scanner device. This method will also clear the
* promise returned by the `captureFromAutoOn` method.
*/
close(): Promise<DefaultResponse>;
/**
* @description
* Compare two fingerprint templates and return the result.
* @param template1 - Base64 encoded template 1
* @param template2 - Base64 encoded template 2
*/
compareTemplates(template1: string, template2: string): CompareResult;
private clearAutoOnCapturePromise;
}
export { AutoOnEvent, type AutoOnEventPayload, type AutoOnEventPayloads, type BadResult, type CaptureResult, type CompareResult, type DefaultResponse, type DeviceInfoResult, type GoodCaptureResult, type GoodCompareResult, type GoodDeviceInfoResult, type GoodResult, type SecugenErrorCodes, type SecugenErrorMessage, type SecugenErrorMessages, SecugenErrors, UnsupportedPlatformPayload, SecugenHandler as default };