From ddcf2d0d6f258cc0b03dc0f3c5a8df3e3c6bed80 Mon Sep 17 00:00:00 2001 From: adityankannan-tw Date: Tue, 12 Dec 2023 11:24:04 +0530 Subject: [PATCH] [INJI-610]: use npm module for iris scan sdk Signed-off-by: adityankannan-tw --- ios/Podfile.lock | 20 +++++++++--------- machines/faceScanner.ts | 4 ++-- package-lock.json | 35 ++++++++++++++++--------------- package.json | 2 +- shared/commonprops/commonProps.ts | 23 ++++++++++++++++++-- 5 files changed, 52 insertions(+), 32 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 3408933aa5..fc41db2f47 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -6,7 +6,10 @@ PODS: - AppAuth/ExternalUserAgent (1.6.2): - AppAuth/Core - ASN1Decoder (1.8.0) - - BiometricSdk (0.5.4): + - biometric-sdk-react-native (0.2.4): + - BiometricSdk (= 0.5.9) + - React-Core + - BiometricSdk (0.5.9): - TensorFlowLiteObjC (= 2.12.0) - boost (1.76.0) - BVLinearGradient (2.8.2): @@ -80,9 +83,6 @@ PODS: - MMKV (1.2.13): - MMKVCore (~> 1.2.13) - MMKVCore (1.2.16) - - mosip-mobileid-sdk (0.1.0): - - BiometricSdk (= 0.5.4) - - React-Core - Permission-BluetoothPeripheral (3.8.4): - RNPermissions - Permission-Camera (3.8.4): @@ -499,6 +499,7 @@ PODS: - ZXingObjC/Core DEPENDENCIES: + - "biometric-sdk-react-native (from `../node_modules/@iriscan/biometric-sdk-react-native`)" - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) - BVLinearGradient (from `../node_modules/react-native-linear-gradient`) - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) @@ -526,7 +527,6 @@ DEPENDENCIES: - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) - hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`) - libevent (~> 2.1.12) - - mosip-mobileid-sdk (from `../node_modules/mosip-mobileid-sdk`) - Permission-BluetoothPeripheral (from `../node_modules/react-native-permissions/ios/BluetoothPeripheral`) - Permission-Camera (from `../node_modules/react-native-permissions/ios/Camera`) - Permission-LocationAccuracy (from `../node_modules/react-native-permissions/ios/LocationAccuracy`) @@ -602,6 +602,8 @@ SPEC REPOS: - ZXingObjC EXTERNAL SOURCES: + biometric-sdk-react-native: + :path: "../node_modules/@iriscan/biometric-sdk-react-native" boost: :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec" BVLinearGradient: @@ -654,8 +656,6 @@ EXTERNAL SOURCES: :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" hermes-engine: :podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec" - mosip-mobileid-sdk: - :path: "../node_modules/mosip-mobileid-sdk" Permission-BluetoothPeripheral: :path: "../node_modules/react-native-permissions/ios/BluetoothPeripheral" Permission-Camera: @@ -772,7 +772,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570 ASN1Decoder: 6110fdeacfdb41559b1481457a1645be716610aa - BiometricSdk: 1d16c395413164d92a280b78006abba4307063e6 + biometric-sdk-react-native: 5d1207e0d9ee34788cb4ccb59cfc205022d7e3f1 + BiometricSdk: 303e7329404ea4d922dc14108449d10d21574f77 boost: 57d2868c099736d80fcd648bf211b4431e51a558 BVLinearGradient: 916632041121a658c704df89d99f04acb038de0f CatCrypto: a477899b6be4954e75be4897e732da098cc0a5a8 @@ -806,7 +807,6 @@ SPEC CHECKSUMS: libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 MMKV: aac95d817a100479445633f2b3ed8961b4ac5043 MMKVCore: 9cfef4c48c6c46f66226fc2e4634d78490206a48 - mosip-mobileid-sdk: 6b8182276896194fdcacdde148b02d5d2d16b02a Permission-BluetoothPeripheral: 2b88a131074edafd8a46a5cda4ba610ec986d2fb Permission-Camera: 7ec9ee99704766ff9b90198183387a7f5d82b0c1 Permission-LocationAccuracy: a38ddb5c5d0b8e656f3c86e4a500f9bb88bc099d @@ -869,4 +869,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 01f58b130fa221dabb14b2d82d981ef24dcaba53 -COCOAPODS: 1.12.1 +COCOAPODS: 1.13.0 diff --git a/machines/faceScanner.ts b/machines/faceScanner.ts index 7d18996b5c..d1b50dc057 100644 --- a/machines/faceScanner.ts +++ b/machines/faceScanner.ts @@ -4,7 +4,7 @@ import {Linking} from 'react-native'; import {assign, EventFrom, StateFrom} from 'xstate'; import {createModel} from 'xstate/lib/model'; -import {faceAuth} from 'mosip-mobileid-sdk'; +import {faceCompare} from '@iriscan/biometric-sdk-react-native'; const model = createModel( { @@ -220,7 +220,7 @@ export const createFaceScannerMachine = (vcImage: string) => const rxDataURI = /data:(?[\w/\-.]+);(?\w+),(?.*)/; const matches = rxDataURI.exec(vcImage).groups; - return faceAuth(context.capturedImage.base64, matches.data); + return faceCompare(context.capturedImage.base64, matches.data); }, }, diff --git a/package-lock.json b/package-lock.json index a36522e5ac..c72ead4d45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@expo-google-fonts/inter": "^0.2.3", "@expo-google-fonts/poppins": "^0.2.0", "@expo/metro-config": "~0.10.0", + "@iriscan/biometric-sdk-react-native": "^0.2.4", "@react-native-clipboard/clipboard": "^1.10.0", "@react-native-community/netinfo": "9.3.7", "@react-native-picker/picker": "2.4.8", @@ -42,7 +43,6 @@ "i18next": "^21.6.16", "iso-639-3": "^3.0.1", "jwt-decode": "^3.1.2", - "mosip-mobileid-sdk": "git://github.com/mosip/mosip-mobileid-sdk.git#IrisScan", "node-forge": "^1.3.1", "node-jose": "^2.2.0", "patch-package": "^6.5.1", @@ -4906,6 +4906,18 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, + "node_modules/@iriscan/biometric-sdk-react-native": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@iriscan/biometric-sdk-react-native/-/biometric-sdk-react-native-0.2.4.tgz", + "integrity": "sha512-gRDUoTDmWdCzNEP00dnOBaFQy1LRKTTIXZTiwErYomxDOIR3vTejFiWvxtWGCARloMjUXRB+zEeb5YDuaybwjg==", + "engines": { + "node": ">= 16.0.0" + }, + "peerDependencies": { + "react": "*", + "react-native": "*" + } + }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -24420,18 +24432,6 @@ "mkdirp": "bin/cmd.js" } }, - "node_modules/mosip-mobileid-sdk": { - "version": "0.1.0", - "resolved": "git+ssh://git@github.com/mosip/mosip-mobileid-sdk.git#ff4647a6c949b0acf8f36ae968dcbd407df7fb83", - "license": "MIT", - "engines": { - "node": ">= 16.0.0" - }, - "peerDependencies": { - "react": "*", - "react-native": "*" - } - }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -34723,6 +34723,11 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, + "@iriscan/biometric-sdk-react-native": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@iriscan/biometric-sdk-react-native/-/biometric-sdk-react-native-0.2.4.tgz", + "integrity": "sha512-gRDUoTDmWdCzNEP00dnOBaFQy1LRKTTIXZTiwErYomxDOIR3vTejFiWvxtWGCARloMjUXRB+zEeb5YDuaybwjg==" + }, "@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -49544,10 +49549,6 @@ "minimist": "^1.2.6" } }, - "mosip-mobileid-sdk": { - "version": "git+ssh://git@github.com/mosip/mosip-mobileid-sdk.git#ff4647a6c949b0acf8f36ae968dcbd407df7fb83", - "from": "mosip-mobileid-sdk@git://github.com/mosip/mosip-mobileid-sdk.git#IrisScan" - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", diff --git a/package.json b/package.json index 708bdab578..94d8e83f1f 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@expo-google-fonts/inter": "^0.2.3", "@expo-google-fonts/poppins": "^0.2.0", "@expo/metro-config": "~0.10.0", + "@iriscan/biometric-sdk-react-native": "^0.2.4", "@react-native-clipboard/clipboard": "^1.10.0", "@react-native-community/netinfo": "9.3.7", "@react-native-picker/picker": "2.4.8", @@ -44,7 +45,6 @@ "i18next": "^21.6.16", "iso-639-3": "^3.0.1", "jwt-decode": "^3.1.2", - "mosip-mobileid-sdk": "git://github.com/mosip/mosip-mobileid-sdk.git#IrisScan", "node-forge": "^1.3.1", "node-jose": "^2.2.0", "patch-package": "^6.5.1", diff --git a/shared/commonprops/commonProps.ts b/shared/commonprops/commonProps.ts index 9764e0a348..6065eb480c 100644 --- a/shared/commonprops/commonProps.ts +++ b/shared/commonprops/commonProps.ts @@ -1,4 +1,4 @@ -import {init} from 'mosip-mobileid-sdk'; +import {configure} from '@iriscan/biometric-sdk-react-native'; import {changeCrendetialRegistry} from '../constants'; import {CACHED_API} from '../api'; @@ -16,9 +16,28 @@ export async function downloadModel() { const maxRetryStr = injiProp.modelDownloadMaxRetry; const maxRetry = parseInt(maxRetryStr); const resp: string = injiProp != null ? injiProp.faceSdkModelUrl : null; + + const config = { + withFace: { + encoder: { + tfModel: { + path: resp + '/model.tflite', + inputWidth: 160, + inputHeight: 160, + outputLength: 512, + modelChecksum: + '797b4d99794965749635352d55da38d4748c28c659ee1502338badee4614ed06', + }, + }, + matcher: { + threshold: 0.8, + }, + }, + }; + if (resp != null) { for (let counter = 0; counter < maxRetry; counter++) { - var result = await init(resp + '/model.tflite', false); + var result = await configure(config); console.log('model download result is = ' + result); if (result) { break;