UNPKG

@biopassid/fingerprint-sdk-react-native

Version:
49 lines (48 loc) 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.takeFingerprint = takeFingerprint; var _reactNative = require("react-native"); var _Utils = require("./utils/Utils"); const LINKING_ERROR = `The package '@biopassid/fingerprint-sdk-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; const FingerprintSdkReactNative = _reactNative.NativeModules.FingerprintSdkReactNative ? _reactNative.NativeModules.FingerprintSdkReactNative : new Proxy({}, { get() { throw new Error(LINKING_ERROR); } }); const eventEmitter = new _reactNative.NativeEventEmitter(FingerprintSdkReactNative); const supportedEvents = ['fingerprint-sdk-react-native/onFingerCapture', 'fingerprint-sdk-react-native/onStatusChanged', 'fingerprint-sdk-react-native/onFingerDetected']; async function takeFingerprint(options) { try { const newConfig = (0, _Utils.mergeConfigs)(options.config); supportedEvents.map(eventName => { eventEmitter.removeAllListeners(eventName); const exactEventName = eventName.split('/')[1]; if (exactEventName === 'onFingerCapture') { eventEmitter.addListener(eventName, event => { options.onFingerCapture(event.images, event.error); }); } else if (exactEventName === 'onStatusChanged') { eventEmitter.addListener(eventName, event => { if (options.onStatusChanged) { options.onStatusChanged(event.state); } }); } else if (exactEventName === 'onFingerDetected') { eventEmitter.addListener(eventName, event => { if (options.onFingerDetected) { options.onFingerDetected(event.fingerRects); } }); } }); await FingerprintSdkReactNative.takeFingerprint(newConfig); } catch (error) { console.error(`Unknown error: ${error}`); } } //# sourceMappingURL=Fingerprint.js.map