Skip to content

Commit

Permalink
Merge pull request #1098 from tw-mosip/INJI-624
Browse files Browse the repository at this point in the history
[INJI-624] - add support for face verification
  • Loading branch information
vijay151096 authored Dec 15, 2023
2 parents ef32fef + bd37dc6 commit 92021ef
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 71 deletions.
5 changes: 1 addition & 4 deletions machines/auth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {assign, ContextFrom, EventFrom, send, StateFrom} from 'xstate';
import {createModel} from 'xstate/lib/model';
import getAllConfigurations, {
downloadModel,
} from '../shared/commonprops/commonProps';
import {AppServices} from '../shared/GlobalContext';
import {StoreEvents, StoreResponseEvent} from './store';
import {generateSecureRandom} from 'react-native-securerandom';
Expand Down Expand Up @@ -169,7 +166,7 @@ export const authMachine = model.createMachine(

services: {
downloadFaceSdkModel: () => () => {
downloadModel();
// ToDo - support to download model for face match
},
generatePasscodeSalt: () => async context => {
const randomBytes = await generateSecureRandom(16);
Expand Down
5 changes: 2 additions & 3 deletions machines/faceScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {Linking} from 'react-native';
import {assign, EventFrom, StateFrom} from 'xstate';
import {createModel} from 'xstate/lib/model';

import {faceCompare} from '@iriscan/biometric-sdk-react-native';

const model = createModel(
{
cameraRef: {} as Camera,
Expand Down Expand Up @@ -220,7 +218,8 @@ export const createFaceScannerMachine = (vcImage: string) =>
const rxDataURI =
/data:(?<mime>[\w/\-.]+);(?<encoding>\w+),(?<data>.*)/;
const matches = rxDataURI.exec(vcImage).groups;
return faceCompare(context.capturedImage.base64, matches.data);
// ToDo - compare faces to do face match and return the match response
return true;
},
},

Expand Down
19 changes: 0 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"@react-navigation/native": "^6.0.8",
"@react-navigation/native-stack": "^6.1.0",
"@xstate/react": "^3.0.1",
"@iriscan/biometric-sdk-react-native": "^0.2.6",
"base64url-universal": "^1.1.0",
"buffer": "^6.0.3",
"crypto-js": "^3.3.0",
Expand Down
20 changes: 0 additions & 20 deletions shared/commonUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,3 @@ export function logState(state: AnyState) {
export const getMaskedText = (id: string): string => {
return '*'.repeat(id.length - 4) + id.slice(-4);
};

export const faceMatchConfig = (resp: string) => {
return {
withFace: {
encoder: {
tfModel: {
path: resp + '/model.tflite',
inputWidth: 160,
inputHeight: 160,
outputLength: 512,
modelChecksum:
'797b4d99794965749635352d55da38d4748c28c659ee1502338badee4614ed06',
},
},
matcher: {
threshold: 0.8,
},
},
};
};
24 changes: 0 additions & 24 deletions shared/commonprops/commonProps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {configure} from '@iriscan/biometric-sdk-react-native';
import {changeCrendetialRegistry} from '../constants';
import {CACHED_API} from '../api';
import {faceMatchConfig} from '../commonUtil';

export const COMMON_PROPS_KEY: string =
'CommonPropsKey-' + '6964d04a-9268-11ed-a1eb-0242ac120002';
Expand All @@ -11,28 +9,6 @@ export default async function getAllConfigurations(host = undefined) {
return await CACHED_API.getAllProperties();
}

export async function downloadModel() {
try {
var injiProp = await getAllConfigurations();
const maxRetryStr = injiProp.modelDownloadMaxRetry;
const maxRetry = parseInt(maxRetryStr);
const resp: string = injiProp != null ? injiProp.faceSdkModelUrl : null;

if (resp != null) {
for (let counter = 0; counter < maxRetry; counter++) {
let config = faceMatchConfig(resp);
var result = await configure(config);
console.log('model download result is = ' + result);
if (result) {
break;
}
}
}
} catch (error) {
console.log(error);
}
}

export interface DownloadProps {
maxDownloadLimit: number;
downloadInterval: number;
Expand Down

0 comments on commit 92021ef

Please sign in to comment.