mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-10 14:07:59 -05:00
Faceauth pending work
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { init } from 'mosip-inji-face-sdk';
|
||||
import { ContextFrom, EventFrom, send, StateFrom } from 'xstate';
|
||||
import { createModel } from 'xstate/lib/model';
|
||||
import getAllProperties from '../shared/commonprops/commonProps';
|
||||
import { AppServices } from '../shared/GlobalContext';
|
||||
import { StoreEvents, StoreResponseEvent } from './store';
|
||||
|
||||
@@ -9,6 +11,7 @@ const model = createModel(
|
||||
passcode: '',
|
||||
biometrics: '',
|
||||
canUseBiometrics: false,
|
||||
injiAppProperties: null,
|
||||
},
|
||||
{
|
||||
events: {
|
||||
@@ -82,6 +85,12 @@ export const authMachine = model.createMachine(
|
||||
},
|
||||
},
|
||||
authorized: {
|
||||
invoke: {
|
||||
src: 'downloadFaceSdkModel',
|
||||
onDone: {
|
||||
actions: ['setInjiAppProperties', 'storeContext'],
|
||||
},
|
||||
},
|
||||
on: {
|
||||
LOGOUT: 'unauthorized',
|
||||
SETUP_BIOMETRICS: {
|
||||
@@ -119,6 +128,31 @@ export const authMachine = model.createMachine(
|
||||
setBiometrics: model.assign({
|
||||
biometrics: (_, event: SetupBiometricsEvent) => event.biometrics,
|
||||
}),
|
||||
|
||||
setInjiAppProperties: model.assign({
|
||||
injiAppProperties: (_, event) => event.data as object,
|
||||
}),
|
||||
},
|
||||
|
||||
services: {
|
||||
downloadFaceSdkModel: (context) => async () => {
|
||||
var injiProp = null;
|
||||
try {
|
||||
if (context.injiAppProperties == null) {
|
||||
injiProp = await getAllProperties();
|
||||
} else {
|
||||
injiProp = context.injiAppProperties;
|
||||
}
|
||||
const resp: string =
|
||||
injiProp != null ? injiProp.faceSdkModelUrl : null;
|
||||
if (resp != null) {
|
||||
init(resp, false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
return injiProp;
|
||||
},
|
||||
},
|
||||
|
||||
guards: {
|
||||
|
||||
@@ -4,29 +4,43 @@ export interface Typegen0 {
|
||||
'@@xstate/typegen': true;
|
||||
'internalEvents': {
|
||||
'': { type: '' };
|
||||
'done.invoke.auth.authorized:invocation[0]': {
|
||||
type: 'done.invoke.auth.authorized:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'xstate.init': { type: 'xstate.init' };
|
||||
};
|
||||
'invokeSrcNameMap': {};
|
||||
'invokeSrcNameMap': {
|
||||
downloadFaceSdkModel: 'done.invoke.auth.authorized:invocation[0]';
|
||||
};
|
||||
'missingImplementations': {
|
||||
actions: never;
|
||||
services: never;
|
||||
guards: never;
|
||||
delays: never;
|
||||
guards: never;
|
||||
services: never;
|
||||
};
|
||||
'eventsCausingActions': {
|
||||
requestStoredContext: 'xstate.init';
|
||||
setBiometrics: 'SETUP_BIOMETRICS';
|
||||
setContext: 'STORE_RESPONSE';
|
||||
setInjiAppProperties: 'done.invoke.auth.authorized:invocation[0]';
|
||||
setPasscode: 'SETUP_PASSCODE';
|
||||
storeContext: 'SETUP_BIOMETRICS' | 'SETUP_PASSCODE' | 'STORE_RESPONSE';
|
||||
storeContext:
|
||||
| 'SETUP_BIOMETRICS'
|
||||
| 'SETUP_PASSCODE'
|
||||
| 'STORE_RESPONSE'
|
||||
| 'done.invoke.auth.authorized:invocation[0]';
|
||||
};
|
||||
'eventsCausingServices': {};
|
||||
'eventsCausingDelays': {};
|
||||
'eventsCausingGuards': {
|
||||
hasBiometricSet: '';
|
||||
hasData: 'STORE_RESPONSE';
|
||||
hasPasscodeSet: '';
|
||||
};
|
||||
'eventsCausingDelays': {};
|
||||
'eventsCausingServices': {
|
||||
downloadFaceSdkModel: 'LOGIN' | 'SETUP_PASSCODE';
|
||||
};
|
||||
'matchesStates':
|
||||
| 'authorized'
|
||||
| 'checkingAuth'
|
||||
|
||||
55
package-lock.json
generated
55
package-lock.json
generated
@@ -39,7 +39,7 @@
|
||||
"expo-status-bar": "~1.2.0",
|
||||
"expo-updates": "~0.11.6",
|
||||
"i18next": "^21.6.16",
|
||||
"mosip-inji-face-sdk": "^0.1.1",
|
||||
"mosip-inji-face-sdk": "^0.1.7",
|
||||
"react": "17.0.1",
|
||||
"react-i18next": "^11.16.6",
|
||||
"react-native": "0.64.4",
|
||||
@@ -49,6 +49,7 @@
|
||||
"react-native-device-info": "^8.4.8",
|
||||
"react-native-dotenv": "^3.3.1",
|
||||
"react-native-elements": "^3.4.2",
|
||||
"react-native-fs": "^2.20.0",
|
||||
"react-native-gesture-handler": "~2.1.0",
|
||||
"react-native-keychain": "^8.0.0",
|
||||
"react-native-location-enabler": "^4.1.0",
|
||||
@@ -17718,12 +17719,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/mosip-inji-face-sdk": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/mosip-inji-face-sdk/-/mosip-inji-face-sdk-0.1.1.tgz",
|
||||
"integrity": "sha512-KlveXfkY9VfATAZOaYfmGQ63voajslXqmbfjWKp0/xotKGEVwgkg8eGPJXDczBOIL/Af/sXhlchv6p9HNYQSZw==",
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/mosip-inji-face-sdk/-/mosip-inji-face-sdk-0.1.7.tgz",
|
||||
"integrity": "sha512-aVfYUs63M805xsk2+82nT4VHn5Ql7lb6j9qgTP/GKw/+qzd56Svu9U9GzNXbBz1wtaU5RGlV9gu0I0YpO2tXQQ==",
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
"react-native": "*",
|
||||
"react-native-fs": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/move-concurrently": {
|
||||
@@ -21121,6 +21123,24 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-fs": {
|
||||
"version": "2.20.0",
|
||||
"resolved": "https://registry.npmjs.org/react-native-fs/-/react-native-fs-2.20.0.tgz",
|
||||
"integrity": "sha512-VkTBzs7fIDUiy/XajOSNk0XazFE9l+QlMAce7lGuebZcag5CnjszB+u4BdqzwaQOdcYb5wsJIsqq4kxInIRpJQ==",
|
||||
"dependencies": {
|
||||
"base-64": "^0.1.0",
|
||||
"utf8": "^3.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react-native": "*",
|
||||
"react-native-windows": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react-native-windows": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-gesture-handler": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.1.3.tgz",
|
||||
@@ -25056,6 +25076,11 @@
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/utf8": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz",
|
||||
"integrity": "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ=="
|
||||
},
|
||||
"node_modules/util": {
|
||||
"version": "0.11.1",
|
||||
"resolved": "https://registry.npmjs.org/util/-/util-0.11.1.tgz",
|
||||
@@ -41299,9 +41324,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"mosip-inji-face-sdk": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/mosip-inji-face-sdk/-/mosip-inji-face-sdk-0.1.1.tgz",
|
||||
"integrity": "sha512-KlveXfkY9VfATAZOaYfmGQ63voajslXqmbfjWKp0/xotKGEVwgkg8eGPJXDczBOIL/Af/sXhlchv6p9HNYQSZw==",
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/mosip-inji-face-sdk/-/mosip-inji-face-sdk-0.1.7.tgz",
|
||||
"integrity": "sha512-aVfYUs63M805xsk2+82nT4VHn5Ql7lb6j9qgTP/GKw/+qzd56Svu9U9GzNXbBz1wtaU5RGlV9gu0I0YpO2tXQQ==",
|
||||
"requires": {}
|
||||
},
|
||||
"move-concurrently": {
|
||||
@@ -44038,6 +44063,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"react-native-fs": {
|
||||
"version": "2.20.0",
|
||||
"resolved": "https://registry.npmjs.org/react-native-fs/-/react-native-fs-2.20.0.tgz",
|
||||
"integrity": "sha512-VkTBzs7fIDUiy/XajOSNk0XazFE9l+QlMAce7lGuebZcag5CnjszB+u4BdqzwaQOdcYb5wsJIsqq4kxInIRpJQ==",
|
||||
"requires": {
|
||||
"base-64": "^0.1.0",
|
||||
"utf8": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"react-native-gesture-handler": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.1.3.tgz",
|
||||
@@ -47124,6 +47158,11 @@
|
||||
"integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==",
|
||||
"requires": {}
|
||||
},
|
||||
"utf8": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz",
|
||||
"integrity": "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ=="
|
||||
},
|
||||
"util": {
|
||||
"version": "0.11.1",
|
||||
"resolved": "https://registry.npmjs.org/util/-/util-0.11.1.tgz",
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
"expo-status-bar": "~1.2.0",
|
||||
"expo-updates": "~0.11.6",
|
||||
"i18next": "^21.6.16",
|
||||
"mosip-inji-face-sdk": "^0.1.1",
|
||||
"mosip-inji-face-sdk": "^0.1.7",
|
||||
"react": "17.0.1",
|
||||
"react-i18next": "^11.16.6",
|
||||
"react-native": "0.64.4",
|
||||
@@ -54,6 +54,7 @@
|
||||
"react-native-device-info": "^8.4.8",
|
||||
"react-native-dotenv": "^3.3.1",
|
||||
"react-native-elements": "^3.4.2",
|
||||
"react-native-fs": "^2.20.0",
|
||||
"react-native-gesture-handler": "~2.1.0",
|
||||
"react-native-keychain": "^8.0.0",
|
||||
"react-native-location-enabler": "^4.1.0",
|
||||
@@ -100,4 +101,4 @@
|
||||
"react": "17.0.1",
|
||||
"react-native": "0.64.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
shared/commonprops/commonProps.ts
Normal file
10
shared/commonprops/commonProps.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { request } from '../request';
|
||||
|
||||
export default async function getAllProperties() {
|
||||
try {
|
||||
const resp = await request('GET', '/allProperties');
|
||||
return resp.response;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user