diff --git a/components/FaceScanner.tsx b/components/FaceScanner.tsx index 75e5226c..4b69b47c 100644 --- a/components/FaceScanner.tsx +++ b/components/FaceScanner.tsx @@ -1,7 +1,7 @@ import React, { useCallback, useContext, useEffect, useRef } from 'react'; import Icon from 'react-native-vector-icons/MaterialIcons'; import { Camera } from 'expo-camera'; -import { StyleSheet } from 'react-native'; +import { Platform, StyleSheet } from 'react-native'; import { Button, Centered, Column, Row, Text } from './ui'; import { useInterpret, useSelector } from '@xstate/react'; import { useTranslation } from 'react-i18next'; @@ -110,6 +110,12 @@ export const FaceScanner: React.FC = (props) => { /> )} + {/* TODO: remove warning when iOS SDK is ready */} + {Platform.OS === 'ios' && ( + + (face-matching in iOS is mocked) + + )} ); diff --git a/components/SingleVcItem.tsx b/components/SingleVcItem.tsx index ca4d7159..5eaed4f4 100644 --- a/components/SingleVcItem.tsx +++ b/components/SingleVcItem.tsx @@ -7,7 +7,6 @@ import { createVcItemMachine, selectVerifiableCredential, selectGeneratedOn, - selectTag, selectId, vcItemMachine, selectContext, diff --git a/components/VcItem.tsx b/components/VcItem.tsx index d5fe1d3a..f0af2740 100644 --- a/components/VcItem.tsx +++ b/components/VcItem.tsx @@ -7,7 +7,6 @@ import { createVcItemMachine, selectVerifiableCredential, selectGeneratedOn, - selectTag, vcItemMachine, selectContext, } from '../machines/vcItem'; diff --git a/components/VidItem.tsx b/components/VidItem.tsx index b88a4c95..03454bf9 100644 --- a/components/VidItem.tsx +++ b/components/VidItem.tsx @@ -8,7 +8,6 @@ import { createVcItemMachine, selectVerifiableCredential, selectGeneratedOn, - selectTag, selectId, vcItemMachine, } from '../machines/vcItem'; @@ -27,7 +26,6 @@ export const VidItem: React.FC = (props) => { ); const service = useInterpret(machine.current); const uin = useSelector(service, selectId); - const tag = useSelector(service, selectTag); const verifiableCredential = useSelector(service, selectVerifiableCredential); const generatedOn = useSelector(service, selectGeneratedOn); diff --git a/ios/Podfile.lock b/ios/Podfile.lock index ee3ff0a8..4aa2d55d 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -87,8 +87,6 @@ PODS: - DoubleConversion - glog - RCTRequired (0.64.4) - - RCTSystemSetting (1.7.6): - - React - RCTTypeSafety (0.64.4): - FBLazyVector (= 0.64.4) - RCT-Folly (= 2020.01.13.00) @@ -406,7 +404,6 @@ DEPENDENCIES: - Permission-LocationWhenInUse (from `../node_modules/react-native-permissions/ios/LocationWhenInUse`) - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) - - RCTSystemSetting (from `../node_modules/react-native-system-setting`) - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) - React (from `../node_modules/react-native/`) - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) @@ -518,8 +515,6 @@ EXTERNAL SOURCES: :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" RCTRequired: :path: "../node_modules/react-native/Libraries/RCTRequired" - RCTSystemSetting: - :path: "../node_modules/react-native-system-setting" RCTTypeSafety: :path: "../node_modules/react-native/Libraries/TypeSafety" React: @@ -618,7 +613,7 @@ SPEC CHECKSUMS: EXUpdates: a83e036243b0f6ece53a8c1cb883b6751c88a5f8 EXUpdatesInterface: a9814f422d3cd6e7cfd260d13c27786148ece20e FBLazyVector: fa8275d5086566e22a26ddc385ab5772e7f9b1bd - FBReactNativeSpec: 7ead992e0bbaf608b93d456361caa6ccf6745df5 + FBReactNativeSpec: c3dafd68550f3c95f009beee5c20ab07949ec4e4 glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62 GoogleInterchangeUtilities: d5bc4d88d5b661ab72f9d70c58d02ca8c27ad1f7 GoogleNetworkingUtilities: 3edd3a8161347494f2da60ea0deddc8a472d94cb @@ -632,7 +627,6 @@ SPEC CHECKSUMS: Permission-LocationWhenInUse: 3ba99e45c852763f730eabecec2870c2382b7bd4 RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c RCTRequired: f85fa00af016059cf88b90b8f8ff9a6af9e4b6c3 - RCTSystemSetting: 5107b7350d63b3f7b42a1277d07e4e5d9df879be RCTTypeSafety: 5279aaf0fb1ad715cbbbbee32d5c98c72598bc9c React: ff4e89fbcb05461c9533fd4da3c0f44cda6ab618 React-callinvoker: 4670ac7842699e4a39b19a08b4ede02573c1e5dd diff --git a/locales/en.json b/locales/en.json index 4cc1bf91..8bb08e78 100644 --- a/locales/en.json +++ b/locales/en.json @@ -239,7 +239,8 @@ "title": "Notice", "message": "Your {{vcLabel}} was rejected by {{receiver}}" } - } + }, + "consentToPhotoVerification": "I give consent to have my photo taken for authentication" }, "VerifyIdentityOverlay": { "status": { diff --git a/machines/request.ts b/machines/request.ts index 0c89f99d..1ca879c0 100644 --- a/machines/request.ts +++ b/machines/request.ts @@ -240,7 +240,9 @@ export const requestMachine = model.createMachine( verifyingIdentity: { on: { FACE_VALID: { - target: 'verifyingVp', + target: 'accepting', + actions: 'clearShouldVerifyPresence', + // target: 'verifyingVp', }, FACE_INVALID: { target: 'invalidIdentity', @@ -419,14 +421,14 @@ export const requestMachine = model.createMachine( console.log( getDeviceNameSync(), '', - JSON.stringify(event) + JSON.stringify(event).slice(0, 100) ); }), IdpassSmartshare.handleLogEvents((event) => { console.log( getDeviceNameSync(), '', - JSON.stringify(event) + JSON.stringify(event).slice(0, 100) ); }), ]; @@ -497,6 +499,13 @@ export const requestMachine = model.createMachine( }, { to: (context) => context.serviceRefs.vc } ), + + clearShouldVerifyPresence: assign({ + incomingVc: (context) => ({ + ...context.incomingVc, + shouldVerifyPresence: false, + }), + }), }, services: { diff --git a/machines/request.typegen.ts b/machines/request.typegen.ts index c23f72fa..82af52ee 100644 --- a/machines/request.typegen.ts +++ b/machines/request.typegen.ts @@ -38,6 +38,7 @@ export interface Typegen0 { delays: never; }; 'eventsCausingActions': { + clearShouldVerifyPresence: 'FACE_VALID'; disconnect: | '' | 'CANCEL' @@ -65,6 +66,7 @@ export interface Typegen0 { requestExistingVc: 'VC_RESPONSE'; requestReceivedVcs: | 'ACCEPT' + | 'FACE_VALID' | 'done.invoke.request.reviewing.verifyingVp:invocation[0]'; requestReceiverInfo: 'CONNECTED'; sendVcReceived: 'STORE_RESPONSE'; @@ -86,7 +88,7 @@ export interface Typegen0 { receiveVc: 'EXCHANGE_DONE'; requestBluetooth: 'BLUETOOTH_DISABLED'; sendVcResponse: 'CANCEL' | 'REJECT' | 'STORE_RESPONSE'; - verifyVp: 'FACE_VALID'; + verifyVp: never; }; 'eventsCausingGuards': { hasExistingVc: 'VC_RESPONSE'; diff --git a/machines/scan.ts b/machines/scan.ts index c15389dd..1eebc4e9 100644 --- a/machines/scan.ts +++ b/machines/scan.ts @@ -50,6 +50,7 @@ const model = createModel( verificationImage: {} as CameraCapturedPicture, sharingProtocol: 'OFFLINE' as SharingProtocol, scannedQrParams: {} as ConnectionParams, + shouldVerifySender: false, }, { events: { @@ -57,7 +58,10 @@ const model = createModel( RECEIVE_DEVICE_INFO: (info: DeviceInfo) => ({ info }), SELECT_VC: (vc: VC) => ({ vc }), SCAN: (params: string) => ({ params }), - ACCEPT_REQUEST: () => ({}), + ACCEPT_REQUEST: (shouldVerifySender: boolean) => ({ shouldVerifySender }), + VERIFY_AND_ACCEPT_REQUEST: (shouldVerifySender: boolean) => ({ + shouldVerifySender, + }), VC_ACCEPTED: () => ({}), VC_REJECTED: () => ({}), CANCEL: () => ({}), @@ -73,7 +77,6 @@ const model = createModel( UPDATE_VC_NAME: (vcName: string) => ({ vcName }), STORE_RESPONSE: (response: unknown) => ({ response }), APP_ACTIVE: () => ({}), - VERIFY_AND_SELECT_VC: (vc: VC) => ({ vc }), FACE_VALID: () => ({}), FACE_INVALID: () => ({}), RETRY_VERIFICATION: () => ({}), @@ -243,35 +246,34 @@ export const scanMachine = model.createMachine( }, }, reviewing: { - on: { - CANCEL: 'findingConnection', - DISMISS: 'findingConnection', - ACCEPT_REQUEST: '.selectingVc', - UPDATE_REASON: { - actions: ['setReason'], - }, - }, - initial: 'idle', + initial: 'selectingVc', states: { - idle: { - on: { - ACCEPT_REQUEST: 'selectingVc', - DISCONNECT: findingConnectionId, - CANCEL: 'cancelling', - }, - }, selectingVc: { on: { + UPDATE_REASON: { + actions: ['setReason'], + }, DISCONNECT: findingConnectionId, SELECT_VC: { - target: 'sendingVc', actions: ['setSelectedVc'], }, - VERIFY_AND_SELECT_VC: { - target: 'verifyingIdentity', - actions: ['setSelectedVc'], - }, - CANCEL: 'idle', + VERIFY_AND_ACCEPT_REQUEST: [ + { + cond: 'shouldVerifySender', + target: 'verifyingIdentity', + }, + { + target: 'verifyingIdentity', + }, + ], + ACCEPT_REQUEST: [ + { + cond: 'shouldVerifySender', + actions: 'setShouldVerifyPresence', + target: 'sendingVc', + }, + ], + CANCEL: 'cancelling', }, }, cancelling: { @@ -315,12 +317,17 @@ export const scanMachine = model.createMachine( DISMISS: 'navigatingToHome', }, }, - rejected: {}, + rejected: { + on: { + DISMISS: findingConnectionId, + }, + }, navigatingToHome: {}, verifyingIdentity: { on: { FACE_VALID: { - target: 'creatingVp', + target: 'sendingVc', + // target: 'creatingVp', }, FACE_INVALID: { target: 'invalidIdentity', @@ -435,14 +442,14 @@ export const scanMachine = model.createMachine( console.log( getDeviceNameSync(), '', - JSON.stringify(event) + JSON.stringify(event).slice(0, 100) ); }), IdpassSmartshare.handleLogEvents((event) => { console.log( getDeviceNameSync(), '', - JSON.stringify(event) + JSON.stringify(event).slice(0, 100) ); }), ]; @@ -473,6 +480,13 @@ export const scanMachine = model.createMachine( ), openSettings: () => Linking.openSettings(), + + setShouldVerifyPresence: assign({ + selectedVc: (context) => ({ + ...context.selectedVc, + shouldVerifyPresence: true, + }), + }), }, services: { @@ -665,6 +679,8 @@ export const scanMachine = model.createMachine( return false; } }, + + shouldVerifySender: (_context, event) => event.shouldVerifySender, }, delays: { diff --git a/machines/scan.typegen.ts b/machines/scan.typegen.ts index 204a1987..c92ad67c 100644 --- a/machines/scan.typegen.ts +++ b/machines/scan.typegen.ts @@ -55,7 +55,6 @@ export interface Typegen0 { | 'xstate.after(3000)#scan.reviewing.cancelling' | 'xstate.stop'; clearScannedQrParams: - | 'CANCEL' | 'DISCONNECT' | 'DISMISS' | 'xstate.after(3000)#scan.reviewing.cancelling' @@ -72,13 +71,11 @@ export interface Typegen0 { logShared: 'VC_ACCEPTED'; openSettings: 'LOCATION_REQUEST'; registerLoggers: - | 'CANCEL' | 'DISCONNECT' | 'DISMISS' | 'xstate.after(3000)#scan.reviewing.cancelling' | 'xstate.after(CLEAR_DELAY)#clearingConnection'; removeLoggers: - | 'CANCEL' | 'DISCONNECT' | 'DISMISS' | 'SCREEN_BLUR' @@ -93,29 +90,35 @@ export interface Typegen0 { setReason: 'UPDATE_REASON'; setReceiverInfo: 'EXCHANGE_DONE'; setScannedQrParams: 'SCAN'; - setSelectedVc: 'SELECT_VC' | 'VERIFY_AND_SELECT_VC'; + setSelectedVc: 'SELECT_VC'; setSenderInfo: 'RECEIVE_DEVICE_INFO'; + setShouldVerifyPresence: 'ACCEPT_REQUEST'; }; 'eventsCausingServices': { checkLocationPermission: 'APP_ACTIVE' | 'LOCATION_ENABLED'; checkLocationStatus: 'CANCEL' | 'SCREEN_FOCUS'; - createVp: 'FACE_VALID'; + createVp: never; discoverDevice: 'RECEIVE_DEVICE_INFO'; exchangeDeviceInfo: 'CONNECTED'; monitorConnection: 'SCREEN_BLUR' | 'SCREEN_FOCUS' | 'xstate.init'; sendDisconnect: 'CANCEL'; - sendVc: 'SELECT_VC' | 'done.invoke.scan.reviewing.creatingVp:invocation[0]'; + sendVc: + | 'ACCEPT_REQUEST' + | 'FACE_VALID' + | 'done.invoke.scan.reviewing.creatingVp:invocation[0]'; }; 'eventsCausingGuards': { isQrOffline: 'SCAN'; isQrOnline: 'SCAN'; + shouldVerifySender: 'ACCEPT_REQUEST' | 'VERIFY_AND_ACCEPT_REQUEST'; }; 'eventsCausingDelays': { CLEAR_DELAY: 'LOCATION_ENABLED'; CONNECTION_TIMEOUT: + | 'ACCEPT_REQUEST' | 'CONNECTED' + | 'FACE_VALID' | 'RECEIVE_DEVICE_INFO' - | 'SELECT_VC' | 'done.invoke.scan.reviewing.creatingVp:invocation[0]'; }; 'matchesStates': @@ -141,7 +144,6 @@ export interface Typegen0 { | 'reviewing.accepted' | 'reviewing.cancelling' | 'reviewing.creatingVp' - | 'reviewing.idle' | 'reviewing.invalidIdentity' | 'reviewing.navigatingToHome' | 'reviewing.rejected' @@ -163,7 +165,6 @@ export interface Typegen0 { | 'accepted' | 'cancelling' | 'creatingVp' - | 'idle' | 'invalidIdentity' | 'navigatingToHome' | 'rejected' diff --git a/machines/vcItem.ts b/machines/vcItem.ts index 21485dd6..57c988f0 100644 --- a/machines/vcItem.ts +++ b/machines/vcItem.ts @@ -195,7 +195,7 @@ export const vcItemMachine = ], onError: [ { - actions: 'logError', + actions: log((_, event) => (event.data as Error).message), target: 'idle', }, ], diff --git a/machines/vcItem.typegen.ts b/machines/vcItem.typegen.ts index e387aff9..d53f0cf7 100644 --- a/machines/vcItem.typegen.ts +++ b/machines/vcItem.typegen.ts @@ -69,7 +69,7 @@ export interface Typegen0 { verifyCredential: 'done.invoke.vc-item.verifyingCredential:invocation[0]'; }; 'missingImplementations': { - actions: 'logError'; + actions: never; services: never; guards: never; delays: never; @@ -92,7 +92,6 @@ export interface Typegen0 { | 'done.invoke.vc-item.verifyingCredential:invocation[0]' | 'error.platform.vc-item.verifyingCredential:invocation[0]'; logDownloaded: 'CREDENTIAL_DOWNLOADED'; - logError: 'error.platform.vc-item.verifyingCredential:invocation[0]'; logRevoked: 'STORE_RESPONSE'; markVcValid: 'done.invoke.vc-item.verifyingCredential:invocation[0]'; requestStoredContext: 'GET_VC_RESPONSE' | 'REFRESH'; diff --git a/screens/BiometricScreenController.ts b/screens/BiometricScreenController.ts index 1cac9a0a..abd8e785 100644 --- a/screens/BiometricScreenController.ts +++ b/screens/BiometricScreenController.ts @@ -20,7 +20,7 @@ export function useBiometricScreen(props: RootRouteProps) { const [error, setError] = useState(''); const [isReEnabling, setReEnabling] = useState(false); const [initAuthBio, updateInitAuthBio] = useState(true); - const [bioState, bioSend, bioService] = useMachine(biometricsMachine); + const [bioSend, bioService] = useMachine(biometricsMachine); const isAuthorized = useSelector(authService, selectAuthorized); const isAvailable = useSelector(bioService, selectIsAvailable); @@ -29,7 +29,6 @@ export function useBiometricScreen(props: RootRouteProps) { const isUnenrolled = useSelector(bioService, selectIsUnenrolled); useEffect(() => { - console.log('bioState', bioState); if (isAuthorized) { props.navigation.reset({ index: 0, diff --git a/screens/Request/ReceiveVcScreen.tsx b/screens/Request/ReceiveVcScreen.tsx index 8e7629c6..c91d6ad5 100644 --- a/screens/Request/ReceiveVcScreen.tsx +++ b/screens/Request/ReceiveVcScreen.tsx @@ -27,7 +27,7 @@ export const ReceiveVcScreen: React.FC = () => { - {controller.isIncomingVp ? ( + {controller.incomingVc.shouldVerifyPresence ? (