From 6c1e23a3d205877e6686b9e8aea43f200d0ac3a2 Mon Sep 17 00:00:00 2001 From: KiruthikaJeyashankar Date: Fri, 3 Oct 2025 11:57:25 +0530 Subject: [PATCH] [INJIMOB-3453] fix share-with-selfie not coming with vc with face (#2095) * [INJIMOB-3453] fix share-with-selfie not coming with vc with face and remove mosip vc hardcoding Signed-off-by: Abhishek Paul * [INJIMOB-3453] pass issuerHost instead of issuer name in activitylogs Signed-off-by: Abhishek Paul * [INJIMOB-3453] exclude processed credentialdata data in ble share Signed-off-by: Abhishek Paul * [INJIMOB-3453] refactor: rename vcHasImage to getFaceAtribute Signed-off-by: KiruthikaJeyashankar * [INJIMOB-3453] refactor: modify fallback for face in VC Signed-off-by: KiruthikaJeyashankar * [INJIMOB-3453] fix: inexisting function import Signed-off-by: KiruthikaJeyashankar --------- Signed-off-by: Abhishek Paul Signed-off-by: KiruthikaJeyashankar Co-authored-by: Abhishek Paul --- components/VC/common/VCUtils.tsx | 31 ++++- components/kebabMenuUtils.ts | 4 +- .../VCItemMachine/VCItemActions.ts | 8 +- .../VCItemMachine/VCItemSelectors.ts | 26 +---- .../VCMetaMachine/VCMetaMachine.typegen.ts | 64 +++++++++++ machines/activityLog.ts | 3 +- machines/bleShare/request/requestMachine.ts | 2 +- machines/bleShare/scan/scanActions.ts | 6 +- machines/bleShare/scan/scanSelectors.ts | 10 +- machines/bleShare/scan/scanServices.ts | 8 +- machines/openID4VP/openID4VPGuards.ts | 3 +- .../openID4VP/openID4VPMachine.typegen.ts | 104 +++++++++++++++++ machines/store.typegen.ts | 107 ++++++++++++++++++ screens/Scan/SendVPScreenController.ts | 9 +- screens/Scan/SendVcScreen.tsx | 4 +- screens/Scan/SendVcScreenController.ts | 1 + 16 files changed, 336 insertions(+), 54 deletions(-) diff --git a/components/VC/common/VCUtils.tsx b/components/VC/common/VCUtils.tsx index 5945bf47..37efb9d5 100644 --- a/components/VC/common/VCUtils.tsx +++ b/components/VC/common/VCUtils.tsx @@ -152,7 +152,7 @@ export const getFieldValue = ( return null; } return getLocalizedField(value?.toString()); - } + } } } }; @@ -715,3 +715,32 @@ const ProtectedCurve = { const PROOF_TYPE_ALGORITHM_MAP = { [-7]: 'ES256', }; + +export function getFaceAttribute(verifiableCredential, format) { + let credentialSubject = {}; + if (format === VCFormat.ldp_vc) { + credentialSubject = + verifiableCredential?.credential?.credentialSubject ?? + verifiableCredential?.verifiableCredential.credential.credentialSubject ?? {}; + } else if (format === VCFormat.mso_mdoc) { + const nameSpaces = + verifiableCredential?.processedCredential?.issuerSigned?.nameSpaces ?? + verifiableCredential?.processedCredential?.nameSpaces ?? + {}; + credentialSubject = Object.values(nameSpaces) + .flat() + .reduce((acc, item) => { + const key = item.elementIdentifier; + const value = item.elementValue; + acc[key] = value; + return acc; + }, {} as Record); + } else if (format === VCFormat.vc_sd_jwt || format === VCFormat.dc_sd_jwt) { + credentialSubject = + verifiableCredential?.processedCredential?.fullResolvedPayload ?? {}; + } + const faceField = + getFaceField(credentialSubject) + + return faceField +} \ No newline at end of file diff --git a/components/kebabMenuUtils.ts b/components/kebabMenuUtils.ts index 1a94fd88..2b47567f 100644 --- a/components/kebabMenuUtils.ts +++ b/components/kebabMenuUtils.ts @@ -2,7 +2,7 @@ import {useTranslation} from 'react-i18next'; import {SvgImage} from './ui/svg'; import {useKebabPopUp} from './KebabPopUpController'; import {isActivationNeeded} from '../shared/openId4VCI/Utils'; -import {isMosipVC, VCShareFlowType} from '../shared/Utils'; +import {VCShareFlowType} from '../shared/Utils'; export const getKebabMenuOptions = props => { const controller = useKebabPopUp(props); @@ -68,7 +68,7 @@ export const getKebabMenuOptions = props => { if (props.vcMetadata.isVerified) { vcActionsList.splice(1, 0, share); - if (isMosipVC(props.vcMetadata.issuer)) { + if (props.vcHasImage) { vcActionsList.splice(2, 0, shareWithSelfieOption, VCActivationOption); } if (props.vcMetadata.isExpired) { diff --git a/machines/VerifiableCredential/VCItemMachine/VCItemActions.ts b/machines/VerifiableCredential/VCItemMachine/VCItemActions.ts index 9a6a532f..92c988f5 100644 --- a/machines/VerifiableCredential/VCItemMachine/VCItemActions.ts +++ b/machines/VerifiableCredential/VCItemMachine/VCItemActions.ts @@ -462,7 +462,7 @@ export const VCItemActions = model => { VCActivityLog.getLogFromObject({ _vcKey: context.vcMetadata.getVcKey(), type: 'VC_DOWNLOADED', - issuer: context.vcMetadata.issuer!!, + issuer: context.vcMetadata.issuerHost!!, credentialConfigurationId: context.verifiableCredential.credentialConfigurationId, timestamp: Date.now(), @@ -481,7 +481,7 @@ export const VCItemActions = model => { VCActivityLog.getLogFromObject({ credentialConfigurationId: context.verifiableCredential.credentialConfigurationId, - issuer: vcMetadata.issuer!!, + issuer: vcMetadata.issuerHost!!, _vcKey: vcMetadata.getVcKey(), type: 'VC_REMOVED', timestamp: Date.now(), @@ -502,7 +502,7 @@ export const VCItemActions = model => { type: 'WALLET_BINDING_SUCCESSFULL', credentialConfigurationId: context.verifiableCredential.credentialConfigurationId, - issuer: vcMetadata.issuer!!, + issuer: vcMetadata.issuerHost!!, timestamp: Date.now(), deviceName: '', }), @@ -522,7 +522,7 @@ export const VCItemActions = model => { type: 'WALLET_BINDING_FAILURE', credentialConfigurationId: context.verifiableCredential.credentialConfigurationId, - issuer: vcMetadata.issuer!!, + issuer: vcMetadata.issuerHost!!, timestamp: Date.now(), deviceName: '', }), diff --git a/machines/VerifiableCredential/VCItemMachine/VCItemSelectors.ts b/machines/VerifiableCredential/VCItemMachine/VCItemSelectors.ts index b9bdfaa2..ab2344ad 100644 --- a/machines/VerifiableCredential/VCItemMachine/VCItemSelectors.ts +++ b/machines/VerifiableCredential/VCItemMachine/VCItemSelectors.ts @@ -2,8 +2,8 @@ import {StateFrom} from 'xstate'; import {VCMetadata} from '../../../shared/VCMetadata'; import {VCItemMachine} from './VCItemMachine'; import { - getFaceField, getMosipLogo, + getFaceAttribute, } from '../../../components/VC/common/VCUtils'; import { Credential, @@ -48,30 +48,8 @@ export function selectVerifiableCredentialData( state: State, ): VerifiableCredentialData { const vcMetadata = new VCMetadata(state.context.vcMetadata); - const verifiableCredential = state.context.verifiableCredential; - let credentialSubject = {}; - if (state.context?.format === VCFormat.ldp_vc) { - credentialSubject = - verifiableCredential?.credential?.credentialSubject ?? {}; - } else if (state.context?.format === VCFormat.mso_mdoc) { - const nameSpaces = - verifiableCredential?.processedCredential?.issuerSigned?.nameSpaces ?? - verifiableCredential?.processedCredential?.nameSpaces ?? - {}; - credentialSubject = Object.values(nameSpaces) - .flat() - .reduce((acc, item) => { - const key = item.elementIdentifier; - const value = item.elementValue; - acc[key] = value; - return acc; - }, {} as Record); - } else if (state.context?.format === VCFormat.vc_sd_jwt || state.context?.format === VCFormat.dc_sd_jwt) { - credentialSubject = - verifiableCredential?.processedCredential?.fullResolvedPayload ?? {}; - } const faceField = - getFaceField(credentialSubject) ?? + getFaceAttribute(state.context.verifiableCredential,state.context.format) ?? state.context.credential?.biometrics?.face; return { diff --git a/machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.typegen.ts b/machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.typegen.ts index e69de29b..30b972a0 100644 --- a/machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.typegen.ts +++ b/machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.typegen.ts @@ -0,0 +1,64 @@ + + // This file was automatically generated. Edits will be overwritten + + export interface Typegen0 { + '@@xstate/typegen': true; + internalEvents: { + "done.invoke.vcMeta.ready.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]": { type: "done.invoke.vcMeta.ready.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"xstate.init": { type: "xstate.init" }; + }; + invokeSrcNameMap: { + "isUserSignedAlready": "done.invoke.vcMeta.ready.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]"; + }; + missingImplementations: { + actions: "addVcToInProgressDownloads" | "getVcItemResponse" | "loadMyVcs" | "loadReceivedVcs" | "logTamperedVCsremoved" | "prependToMyVcsMetadata" | "removeDownloadFailedVcsFromStorage" | "removeDownloadingFailedVcsFromMyVcs" | "removeVcFromInProgressDownlods" | "removeVcFromMyVcsMetadata" | "resetDownloadCreadentialsFailed" | "resetDownloadCredentialsSuccess" | "resetDownloadFailedVcs" | "resetInProgressVcsDownloaded" | "resetTamperedVcs" | "resetVerificationErrorMessage" | "resetVerificationStatus" | "resetWalletBindingSuccess" | "sendBackupEvent" | "setDownloadCreadentialsFailed" | "setDownloadCredentialsSuccess" | "setDownloadedVc" | "setDownloadingFailedVcs" | "setMyVcs" | "setReceivedVcs" | "setUpdatedVcMetadatas" | "setVerificationErrorMessage" | "setVerificationStatus" | "setWalletBindingSuccess" | "updateMyVcsMetadata"; + delays: never; + guards: "isAnyVcTampered" | "isSignedIn"; + services: "isUserSignedAlready"; + }; + eventsCausingActions: { + "addVcToInProgressDownloads": "ADD_VC_TO_IN_PROGRESS_DOWNLOADS"; +"getVcItemResponse": "GET_VC_ITEM"; +"loadMyVcs": "REFRESH_MY_VCS" | "REFRESH_RECEIVED_VCS" | "STORE_RESPONSE" | "VERIFY_VC_FAILED" | "xstate.init"; +"loadReceivedVcs": "REFRESH_RECEIVED_VCS" | "STORE_RESPONSE"; +"logTamperedVCsremoved": "done.invoke.vcMeta.ready.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]"; +"prependToMyVcsMetadata": "VC_ADDED"; +"removeDownloadFailedVcsFromStorage": "DELETE_VC"; +"removeDownloadingFailedVcsFromMyVcs": "STORE_RESPONSE"; +"removeVcFromInProgressDownlods": "DOWNLOAD_LIMIT_EXPIRED" | "REMOVE_VC_FROM_IN_PROGRESS_DOWNLOADS" | "VERIFY_VC_FAILED"; +"removeVcFromMyVcsMetadata": "REMOVE_VC_FROM_CONTEXT"; +"resetDownloadCreadentialsFailed": "RESET_DOWNLOADING_FAILED"; +"resetDownloadCredentialsSuccess": "RESET_DOWNLOADING_SUCCESS"; +"resetDownloadFailedVcs": "STORE_RESPONSE"; +"resetInProgressVcsDownloaded": "RESET_IN_PROGRESS_VCS_DOWNLOADED"; +"resetTamperedVcs": "REMOVE_TAMPERED_VCS"; +"resetVerificationErrorMessage": "RESET_VERIFY_ERROR"; +"resetVerificationStatus": "RESET_VERIFICATION_STATUS"; +"resetWalletBindingSuccess": "RESET_WALLET_BINDING_SUCCESS"; +"sendBackupEvent": "done.invoke.vcMeta.ready.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]"; +"setDownloadCreadentialsFailed": "VC_DOWNLOADING_FAILED"; +"setDownloadCredentialsSuccess": "VC_DOWNLOADED"; +"setDownloadedVc": "VC_DOWNLOADED"; +"setDownloadingFailedVcs": "DOWNLOAD_LIMIT_EXPIRED"; +"setMyVcs": "STORE_RESPONSE"; +"setReceivedVcs": "STORE_RESPONSE"; +"setUpdatedVcMetadatas": "VC_METADATA_UPDATED"; +"setVerificationErrorMessage": "VERIFY_VC_FAILED"; +"setVerificationStatus": "SET_VERIFICATION_STATUS"; +"setWalletBindingSuccess": "WALLET_BINDING_SUCCESS"; +"updateMyVcsMetadata": "VC_METADATA_UPDATED"; + }; + eventsCausingDelays: { + + }; + eventsCausingGuards: { + "isAnyVcTampered": "SHOW_TAMPERED_POPUP"; +"isSignedIn": "done.invoke.vcMeta.ready.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]"; + }; + eventsCausingServices: { + "isUserSignedAlready": "REMOVE_TAMPERED_VCS"; + }; + matchesStates: "deletingFailedVcs" | "ready" | "ready.myVcs" | "ready.receivedVcs" | "ready.showTamperedPopup" | "ready.tamperedVCs" | "ready.tamperedVCs.idle" | "ready.tamperedVCs.triggerAutoBackupForTamperedVcDeletion" | { "ready"?: "myVcs" | "receivedVcs" | "showTamperedPopup" | "tamperedVCs" | { "tamperedVCs"?: "idle" | "triggerAutoBackupForTamperedVcDeletion"; }; }; + tags: never; + } + \ No newline at end of file diff --git a/machines/activityLog.ts b/machines/activityLog.ts index 161d0245..970ec00b 100644 --- a/machines/activityLog.ts +++ b/machines/activityLog.ts @@ -115,7 +115,8 @@ export const activityLogMachine = }), setActivities: model.assign({ - activities: (_, event) => (event.response || []) as VCActivityLog[], + activities: (_, event) => { + return (event.response || []) as VCActivityLog[]}, }), storeActivity: send( diff --git a/machines/bleShare/request/requestMachine.ts b/machines/bleShare/request/requestMachine.ts index 5a5491f2..0c8a2cff 100644 --- a/machines/bleShare/request/requestMachine.ts +++ b/machines/bleShare/request/requestMachine.ts @@ -623,7 +623,7 @@ export const requestMachine = credentialConfigurationId: context.incomingVc.verifiableCredential .credentialConfigurationId, - issuer: vcMetadata.issuer!!, + issuer: vcMetadata.issuerHost!!, timestamp: Date.now(), deviceName: context.senderInfo.name || context.senderInfo.deviceName, diff --git a/machines/bleShare/scan/scanActions.ts b/machines/bleShare/scan/scanActions.ts index db23f737..795e88e5 100644 --- a/machines/bleShare/scan/scanActions.ts +++ b/machines/bleShare/scan/scanActions.ts @@ -254,7 +254,7 @@ export const ScanActions = (model: any) => { : 'VC_SHARED_WITH_VERIFICATION_CONSENT', credentialConfigurationId: context.selectedVc.verifiableCredential.credentialConfigurationId, - issuer: vcMetadata.issuer!!, + issuer: vcMetadata.issuerHost!!, timestamp: Date.now(), deviceName: context.receiverInfo.name || context.receiverInfo.deviceName, @@ -274,7 +274,7 @@ export const ScanActions = (model: any) => { timestamp: Date.now(), credentialConfigurationId: context.selectedVc.verifiableCredential.credentialConfigurationId, - issuer: vcMetadata.issuer!!, + issuer: vcMetadata.issuerHost!!, deviceName: context.receiverInfo.name || context.receiverInfo.deviceName, }), @@ -362,7 +362,7 @@ export const ScanActions = (model: any) => { return ActivityLogEvents.LOG_ACTIVITY( VCActivityLog.getLogFromObject({ _vcKey: vcMetadata.getVcKey(), - issuer: vcMetadata.issuer!!, + issuer: vcMetadata.issuerHost!!, credentialConfigurationId: selectedVc.verifiableCredential.credentialConfigurationId, type: 'QRLOGIN_SUCCESFULL', diff --git a/machines/bleShare/scan/scanSelectors.ts b/machines/bleShare/scan/scanSelectors.ts index ea62250a..82d4c92b 100644 --- a/machines/bleShare/scan/scanSelectors.ts +++ b/machines/bleShare/scan/scanSelectors.ts @@ -1,7 +1,7 @@ import {StateFrom} from 'xstate'; import {scanMachine} from './scanMachine'; import {VCMetadata} from '../../../shared/VCMetadata'; -import {getMosipLogo} from '../../../components/VC/common/VCUtils'; +import {getMosipLogo, getFaceAttribute} from '../../../components/VC/common/VCUtils'; type State = StateFrom; @@ -30,6 +30,9 @@ export function selectCredential(state: State) { export function selectVerifiableCredentialData(state: State) { const vcMetadata = new VCMetadata(state.context.selectedVc?.vcMetadata); + const faceField = + getFaceAttribute(state.context.selectedVc,state.context.selectedVc?.format) ?? + state.context.selectedVc?.credential?.biometrics?.face; return [ { vcMetadata: vcMetadata, @@ -37,10 +40,7 @@ export function selectVerifiableCredentialData(state: State) { issuerLogo: state.context.selectedVc?.verifiableCredential?.issuerLogo || getMosipLogo(), - face: - state.context.selectedVc?.verifiableCredential?.credential - ?.credentialSubject?.face || - state.context.selectedVc?.credential?.biometrics?.face, + face:faceField, wellKnown: state.context.selectedVc?.verifiableCredential?.wellKnown, }, ]; diff --git a/machines/bleShare/scan/scanServices.ts b/machines/bleShare/scan/scanServices.ts index 3aa21665..4dd157f1 100644 --- a/machines/bleShare/scan/scanServices.ts +++ b/machines/bleShare/scan/scanServices.ts @@ -1,5 +1,5 @@ import {isLocationEnabled} from 'react-native-device-info'; -import Storage, { isMinimumStorageLimitReached } from '../../../shared/storage'; +import { isMinimumStorageLimitReached } from '../../../shared/storage'; import BluetoothStateManager from 'react-native-bluetooth-state-manager'; import { check, @@ -169,10 +169,10 @@ export const ScanServices = (model: any) => { }); } }; + const { processedCredential, ...rest } = context.selectedVc; + const payload = JSON.stringify(rest); wallet.sendData( - JSON.stringify({ - ...context.selectedVc, - }), + payload ); const subscription = subscribe(statusCallback); return () => subscription?.remove(); diff --git a/machines/openID4VP/openID4VPGuards.ts b/machines/openID4VP/openID4VPGuards.ts index 9290451f..4cfa74cf 100644 --- a/machines/openID4VP/openID4VPGuards.ts +++ b/machines/openID4VP/openID4VPGuards.ts @@ -1,3 +1,4 @@ +import { getFaceAttribute } from '../../components/VC/common/VCUtils'; import {VCShareFlowType} from '../../shared/Utils'; export const openID4VPGuards = () => { @@ -25,7 +26,7 @@ export const openID4VPGuards = () => { const hasImage = Object.values(context.selectedVCs) .flatMap(vc => vc) .some( - vc => vc.verifiableCredential?.credential?.credentialSubject?.face, + vc => getFaceAttribute(vc.verifiableCredential,vc.format) != null, ); return !!hasImage; }, diff --git a/machines/openID4VP/openID4VPMachine.typegen.ts b/machines/openID4VP/openID4VPMachine.typegen.ts index e69de29b..20bd448f 100644 --- a/machines/openID4VP/openID4VPMachine.typegen.ts +++ b/machines/openID4VP/openID4VPMachine.typegen.ts @@ -0,0 +1,104 @@ + + // This file was automatically generated. Edits will be overwritten + + export interface Typegen0 { + '@@xstate/typegen': true; + internalEvents: { + "done.invoke.OpenID4VP.authenticateVerifier:invocation[0]": { type: "done.invoke.OpenID4VP.authenticateVerifier:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"done.invoke.OpenID4VP.checkIfClientValidationIsRequired:invocation[0]": { type: "done.invoke.OpenID4VP.checkIfClientValidationIsRequired:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"done.invoke.OpenID4VP.checkKeyPair:invocation[0]": { type: "done.invoke.OpenID4VP.checkKeyPair:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"done.invoke.OpenID4VP.checkVerifierTrust:invocation[0]": { type: "done.invoke.OpenID4VP.checkVerifierTrust:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"done.invoke.OpenID4VP.getKeyPairFromKeystore:invocation[0]": { type: "done.invoke.OpenID4VP.getKeyPairFromKeystore:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"done.invoke.OpenID4VP.getTrustedVerifiersList:invocation[0]": { type: "done.invoke.OpenID4VP.getTrustedVerifiersList:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"done.invoke.OpenID4VP.sendingVP:invocation[0]": { type: "done.invoke.OpenID4VP.sendingVP:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"done.invoke.OpenID4VP.storeTrustedVerifier:invocation[0]": { type: "done.invoke.OpenID4VP.storeTrustedVerifier:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"error.platform.OpenID4VP.authenticateVerifier:invocation[0]": { type: "error.platform.OpenID4VP.authenticateVerifier:invocation[0]"; data: unknown }; +"error.platform.OpenID4VP.checkKeyPair:invocation[0]": { type: "error.platform.OpenID4VP.checkKeyPair:invocation[0]"; data: unknown }; +"error.platform.OpenID4VP.checkVerifierTrust:invocation[0]": { type: "error.platform.OpenID4VP.checkVerifierTrust:invocation[0]"; data: unknown }; +"error.platform.OpenID4VP.getKeyPairFromKeystore:invocation[0]": { type: "error.platform.OpenID4VP.getKeyPairFromKeystore:invocation[0]"; data: unknown }; +"error.platform.OpenID4VP.getTrustedVerifiersList:invocation[0]": { type: "error.platform.OpenID4VP.getTrustedVerifiersList:invocation[0]"; data: unknown }; +"error.platform.OpenID4VP.sendingVP:invocation[0]": { type: "error.platform.OpenID4VP.sendingVP:invocation[0]"; data: unknown }; +"xstate.after(200)#OpenID4VP.delayBeforeDismissToParent": { type: "xstate.after(200)#OpenID4VP.delayBeforeDismissToParent" }; +"xstate.init": { type: "xstate.init" }; +"xstate.stop": { type: "xstate.stop" }; + }; + invokeSrcNameMap: { + "fetchTrustedVerifiers": "done.invoke.OpenID4VP.getTrustedVerifiersList:invocation[0]"; +"getAuthenticationResponse": "done.invoke.OpenID4VP.authenticateVerifier:invocation[0]"; +"getKeyPair": "done.invoke.OpenID4VP.getKeyPairFromKeystore:invocation[0]"; +"getSelectedKey": "done.invoke.OpenID4VP.checkKeyPair:invocation[0]"; +"isVerifierTrusted": "done.invoke.OpenID4VP.checkVerifierTrust:invocation[0]"; +"sendVP": "done.invoke.OpenID4VP.sendingVP:invocation[0]"; +"shouldValidateClient": "done.invoke.OpenID4VP.checkIfClientValidationIsRequired:invocation[0]"; +"storeTrustedVerifier": "done.invoke.OpenID4VP.storeTrustedVerifier:invocation[0]"; + }; + missingImplementations: { + actions: "compareAndStoreSelectedVC" | "dismissTrustModal" | "forwardToParent" | "getFaceAuthConsent" | "getVcsMatchingAuthRequest" | "incrementOpenID4VPRetryCount" | "loadKeyPair" | "logActivity" | "resetError" | "resetFaceCaptureBannerStatus" | "resetIsFaceVerificationRetryAttempt" | "resetIsShareWithSelfie" | "resetIsShowLoadingScreen" | "resetOpenID4VPRetryCount" | "setAuthenticationError" | "setAuthenticationResponse" | "setError" | "setFlowType" | "setIsFaceVerificationRetryAttempt" | "setIsOVPViaDeepLink" | "setIsShareWithSelfie" | "setIsShowLoadingScreen" | "setMiniViewShareSelectedVC" | "setSelectedVCs" | "setSendVPShareError" | "setShareLogTypeUnverified" | "setShowFaceAuthConsent" | "setTrustedVerifiers" | "setTrustedVerifiersApiCallError" | "setUrlEncodedAuthorizationRequest" | "shareDeclineStatus" | "showTrustConsentModal" | "storeShowFaceAuthConsent" | "updateFaceCaptureBannerStatus" | "updateShowFaceAuthConsent"; + delays: never; + guards: "hasKeyPair" | "isAnyVCHasImage" | "isClientValidationRequred" | "isFaceVerificationRetryAttempt" | "isSelectedVCMatchingRequest" | "isShareWithSelfie" | "isSimpleOpenID4VPShare" | "showFaceAuthConsentScreen"; + services: "fetchTrustedVerifiers" | "getAuthenticationResponse" | "getKeyPair" | "getSelectedKey" | "isVerifierTrusted" | "sendVP" | "shouldValidateClient" | "storeTrustedVerifier"; + }; + eventsCausingActions: { + "compareAndStoreSelectedVC": "SET_SELECTED_VC"; +"dismissTrustModal": "CANCEL" | "VERIFIER_TRUST_CONSENT_GIVEN" | "done.invoke.OpenID4VP.checkVerifierTrust:invocation[0]" | "done.invoke.OpenID4VP.storeTrustedVerifier:invocation[0]"; +"forwardToParent": "CANCEL" | "DISMISS_POPUP"; +"getFaceAuthConsent": "AUTHENTICATE"; +"getVcsMatchingAuthRequest": "DOWNLOADED_VCS"; +"incrementOpenID4VPRetryCount": "RETRY"; +"loadKeyPair": "done.invoke.OpenID4VP.getKeyPairFromKeystore:invocation[0]"; +"logActivity": "LOG_ACTIVITY"; +"resetError": "RESET_ERROR" | "RESET_RETRY_COUNT" | "RETRY"; +"resetFaceCaptureBannerStatus": "ACCEPT_REQUEST" | "CLOSE_BANNER"; +"resetIsFaceVerificationRetryAttempt": "DISMISS"; +"resetIsShareWithSelfie": "CANCEL" | "DISMISS_POPUP"; +"resetIsShowLoadingScreen": "DISMISS_POPUP" | "done.invoke.OpenID4VP.authenticateVerifier:invocation[0]" | "error.platform.OpenID4VP.authenticateVerifier:invocation[0]" | "xstate.stop"; +"resetOpenID4VPRetryCount": "RESET_RETRY_COUNT"; +"setAuthenticationError": "error.platform.OpenID4VP.authenticateVerifier:invocation[0]"; +"setAuthenticationResponse": "done.invoke.OpenID4VP.authenticateVerifier:invocation[0]"; +"setError": "error.platform.OpenID4VP.checkKeyPair:invocation[0]" | "error.platform.OpenID4VP.getKeyPairFromKeystore:invocation[0]"; +"setFlowType": "AUTHENTICATE"; +"setIsFaceVerificationRetryAttempt": "FACE_INVALID"; +"setIsOVPViaDeepLink": "AUTHENTICATE"; +"setIsShareWithSelfie": "AUTHENTICATE"; +"setIsShowLoadingScreen": "AUTHENTICATE"; +"setMiniViewShareSelectedVC": "AUTHENTICATE"; +"setSelectedVCs": "ACCEPT_REQUEST" | "VERIFY_AND_ACCEPT_REQUEST"; +"setSendVPShareError": "error.platform.OpenID4VP.sendingVP:invocation[0]"; +"setShareLogTypeUnverified": "ACCEPT_REQUEST"; +"setShowFaceAuthConsent": "FACE_VERIFICATION_CONSENT"; +"setTrustedVerifiers": "done.invoke.OpenID4VP.getTrustedVerifiersList:invocation[0]"; +"setTrustedVerifiersApiCallError": "error.platform.OpenID4VP.getTrustedVerifiersList:invocation[0]"; +"setUrlEncodedAuthorizationRequest": "AUTHENTICATE"; +"shareDeclineStatus": "CONFIRM"; +"showTrustConsentModal": "done.invoke.OpenID4VP.checkVerifierTrust:invocation[0]" | "error.platform.OpenID4VP.checkVerifierTrust:invocation[0]"; +"storeShowFaceAuthConsent": "FACE_VERIFICATION_CONSENT"; +"updateFaceCaptureBannerStatus": "FACE_VALID"; +"updateShowFaceAuthConsent": "done.invoke.OpenID4VP.checkIfClientValidationIsRequired:invocation[0]"; + }; + eventsCausingDelays: { + "SHARING_TIMEOUT": "CONFIRM" | "FACE_VALID" | "RETRY"; + }; + eventsCausingGuards: { + "hasKeyPair": "FACE_VALID" | "done.invoke.OpenID4VP.checkKeyPair:invocation[0]"; +"isAnyVCHasImage": "CHECK_FOR_IMAGE"; +"isClientValidationRequred": "done.invoke.OpenID4VP.checkIfClientValidationIsRequired:invocation[0]"; +"isFaceVerificationRetryAttempt": "FACE_INVALID"; +"isSelectedVCMatchingRequest": "CHECK_SELECTED_VC"; +"isShareWithSelfie": "CONFIRM" | "done.invoke.OpenID4VP.sendingVP:invocation[0]"; +"isSimpleOpenID4VPShare": "CANCEL" | "DISMISS" | "DISMISS_POPUP" | "DOWNLOADED_VCS" | "FACE_VERIFICATION_CONSENT"; +"showFaceAuthConsentScreen": "CONFIRM"; + }; + eventsCausingServices: { + "fetchTrustedVerifiers": "done.invoke.OpenID4VP.checkIfClientValidationIsRequired:invocation[0]"; +"getAuthenticationResponse": "done.invoke.OpenID4VP.checkKeyPair:invocation[0]"; +"getKeyPair": "done.invoke.OpenID4VP.checkIfClientValidationIsRequired:invocation[0]" | "done.invoke.OpenID4VP.getTrustedVerifiersList:invocation[0]"; +"getSelectedKey": "FACE_VALID" | "done.invoke.OpenID4VP.getKeyPairFromKeystore:invocation[0]"; +"isVerifierTrusted": "done.invoke.OpenID4VP.authenticateVerifier:invocation[0]"; +"sendVP": "CONFIRM" | "FACE_VALID" | "RETRY"; +"shouldValidateClient": "STORE_RESPONSE"; +"storeTrustedVerifier": "VERIFIER_TRUST_CONSENT_GIVEN"; + }; + matchesStates: "authenticateVerifier" | "checkFaceAuthConsent" | "checkIfAnySelectedVCHasImage" | "checkIfClientValidationIsRequired" | "checkIfMatchingVCsHasSelectedVC" | "checkKeyPair" | "checkVerifierTrust" | "delayBeforeDismissToParent" | "faceVerificationConsent" | "getConsentForVPSharing" | "getKeyPairFromKeystore" | "getTrustedVerifiersList" | "getVCsSatisfyingAuthRequest" | "invalidIdentity" | "requestVerifierConsent" | "selectingVCs" | "sendDismissToParent" | "sendingVP" | "setSelectedVC" | "shareVPDeclineStatusToVerifier" | "showConfirmationPopup" | "showError" | "storeTrustedVerifier" | "success" | "verifyingIdentity" | "waitingForData"; + tags: never; + } + \ No newline at end of file diff --git a/machines/store.typegen.ts b/machines/store.typegen.ts index e69de29b..7005e0df 100644 --- a/machines/store.typegen.ts +++ b/machines/store.typegen.ts @@ -0,0 +1,107 @@ + + // This file was automatically generated. Edits will be overwritten + + export interface Typegen0 { + '@@xstate/typegen': true; + internalEvents: { + "done.invoke._store": { type: "done.invoke._store"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"done.invoke.store.checkFreshInstall:invocation[0]": { type: "done.invoke.store.checkFreshInstall:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"done.invoke.store.resettingStorage:invocation[0]": { type: "done.invoke.store.resettingStorage:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"error.platform._store": { type: "error.platform._store"; data: unknown }; +"xstate.init": { type: "xstate.init" }; + }; + invokeSrcNameMap: { + "checkFreshInstall": "done.invoke.store.checkFreshInstall:invocation[0]"; +"checkStorageInitialisedOrNot": "done.invoke.store.checkStorageInitialisation:invocation[0]"; +"clear": "done.invoke.store.resettingStorage:invocation[0]"; +"clearKeys": "done.invoke.store.clearIosKeys:invocation[0]"; +"generateEncryptionKey": "done.invoke.store.generatingEncryptionKey:invocation[0]"; +"getEncryptionKey": "done.invoke.store.gettingEncryptionKey:invocation[0]"; +"hasEncryptionKey": "done.invoke.store.checkEncryptionKey:invocation[0]"; +"store": "done.invoke._store"; + }; + missingImplementations: { + actions: never; + delays: never; + guards: never; + services: never; + }; + eventsCausingActions: { + "forwardStoreRequest": "APPEND" | "CLEAR" | "EXPORT" | "FETCH_ALL_WELLKNOWN_CONFIG" | "GET" | "GET_VCS_DATA" | "PREPEND" | "REMOVE" | "REMOVE_ITEMS" | "REMOVE_VC_METADATA" | "RESTORE_BACKUP" | "SET" | "UPDATE"; +"notifyParent": "KEY_RECEIVED" | "READY" | "done.invoke.store.resettingStorage:invocation[0]"; +"setEncryptionKey": "KEY_RECEIVED"; + }; + eventsCausingDelays: { + + }; + eventsCausingGuards: { + "hasData": "done.invoke.store.checkFreshInstall:invocation[0]"; +"isCustomSecureKeystore": "KEY_RECEIVED"; + }; + eventsCausingServices: { + "checkFreshInstall": "BIOMETRIC_CANCELLED" | "xstate.init"; +"checkStorageInitialisedOrNot": "ERROR"; +"clear": "KEY_RECEIVED"; +"clearKeys": "done.invoke.store.checkFreshInstall:invocation[0]"; +"generateEncryptionKey": "ERROR" | "IGNORE" | "READY"; +"getEncryptionKey": "TRY_AGAIN"; +"hasEncryptionKey": never; +"store": "KEY_RECEIVED" | "READY" | "done.invoke.store.resettingStorage:invocation[0]"; + }; + matchesStates: "checkEncryptionKey" | "checkFreshInstall" | "checkStorageInitialisation" | "clearIosKeys" | "failedReadingKey" | "generatingEncryptionKey" | "gettingEncryptionKey" | "ready" | "resettingStorage"; + tags: never; + } + + // This file was automatically generated. Edits will be overwritten + + export interface Typegen0 { + '@@xstate/typegen': true; + internalEvents: { + "done.invoke._store": { type: "done.invoke._store"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"done.invoke.store.checkFreshInstall:invocation[0]": { type: "done.invoke.store.checkFreshInstall:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"done.invoke.store.resettingStorage:invocation[0]": { type: "done.invoke.store.resettingStorage:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; +"error.platform._store": { type: "error.platform._store"; data: unknown }; +"xstate.init": { type: "xstate.init" }; + }; + invokeSrcNameMap: { + "checkFreshInstall": "done.invoke.store.checkFreshInstall:invocation[0]"; +"checkStorageInitialisedOrNot": "done.invoke.store.checkStorageInitialisation:invocation[0]"; +"clear": "done.invoke.store.resettingStorage:invocation[0]"; +"clearKeys": "done.invoke.store.clearIosKeys:invocation[0]"; +"generateEncryptionKey": "done.invoke.store.generatingEncryptionKey:invocation[0]"; +"getEncryptionKey": "done.invoke.store.gettingEncryptionKey:invocation[0]"; +"hasEncryptionKey": "done.invoke.store.checkEncryptionKey:invocation[0]"; +"store": "done.invoke._store"; + }; + missingImplementations: { + actions: never; + delays: never; + guards: never; + services: never; + }; + eventsCausingActions: { + "forwardStoreRequest": "APPEND" | "CLEAR" | "EXPORT" | "FETCH_ALL_WELLKNOWN_CONFIG" | "GET" | "GET_VCS_DATA" | "PREPEND" | "REMOVE" | "REMOVE_ITEMS" | "REMOVE_VC_METADATA" | "RESTORE_BACKUP" | "SET" | "UPDATE"; +"notifyParent": "KEY_RECEIVED" | "READY" | "done.invoke.store.resettingStorage:invocation[0]"; +"setEncryptionKey": "KEY_RECEIVED"; + }; + eventsCausingDelays: { + + }; + eventsCausingGuards: { + "hasData": "done.invoke.store.checkFreshInstall:invocation[0]"; +"isCustomSecureKeystore": "KEY_RECEIVED"; + }; + eventsCausingServices: { + "checkFreshInstall": "BIOMETRIC_CANCELLED" | "xstate.init"; +"checkStorageInitialisedOrNot": "ERROR"; +"clear": "KEY_RECEIVED"; +"clearKeys": "done.invoke.store.checkFreshInstall:invocation[0]"; +"generateEncryptionKey": "ERROR" | "IGNORE" | "READY"; +"getEncryptionKey": "TRY_AGAIN"; +"hasEncryptionKey": never; +"store": "KEY_RECEIVED" | "READY" | "done.invoke.store.resettingStorage:invocation[0]"; + }; + matchesStates: "checkEncryptionKey" | "checkFreshInstall" | "checkStorageInitialisation" | "clearIosKeys" | "failedReadingKey" | "generatingEncryptionKey" | "gettingEncryptionKey" | "ready" | "resettingStorage"; + tags: never; + } + \ No newline at end of file diff --git a/screens/Scan/SendVPScreenController.ts b/screens/Scan/SendVPScreenController.ts index 06ac7be3..1e857e00 100644 --- a/screens/Scan/SendVPScreenController.ts +++ b/screens/Scan/SendVPScreenController.ts @@ -42,14 +42,13 @@ import {selectShareableVcs} from '../../machines/VerifiableCredential/VCMetaMach import {RootRouteProps} from '../../routes'; import {BOTTOM_TAB_ROUTES} from '../../routes/routesConstants'; import {GlobalContext} from '../../shared/GlobalContext'; -import {formatTextWithGivenLimit, isMosipVC} from '../../shared/Utils'; +import {formatTextWithGivenLimit} from '../../shared/Utils'; import {VCMetadata} from '../../shared/VCMetadata'; import {VPShareOverlayProps} from './VPShareOverlay'; import {ActivityLogEvents} from '../../machines/activityLog'; import {VPShareActivityLog} from '../../components/VPShareActivityLogEvent'; -import {SelectedCredentialsForVPSharing} from '../../machines/VerifiableCredential/VCMetaMachine/vc'; import {isIOS} from '../../shared/constants'; -import { verifier } from '../../shared/tuvali'; +import { getFaceAttribute } from '../../components/VC/common/VCUtils'; type MyVcsTabNavigation = NavigationProp; @@ -98,14 +97,14 @@ export function useSendVPScreen() { return Object.values(vcs) .flatMap(vc => vc) .some(vc => { - return isMosipVC(vc.vcMetadata?.issuer); + return getFaceAttribute(vc.verifiableCredential,vc.format) != null; }); }; const checkIfAllVCsHasImage = vcs => { return Object.values(vcs) .flatMap(vc => vc) - .every(vc => isMosipVC(vc.vcMetadata.issuer)); + .every(vc => getFaceAttribute(vc.verifiableCredential,vc.format) != null); }; const getSelectedVCs = (): Record => { diff --git a/screens/Scan/SendVcScreen.tsx b/screens/Scan/SendVcScreen.tsx index 971c7088..3329f23c 100644 --- a/screens/Scan/SendVcScreen.tsx +++ b/screens/Scan/SendVcScreen.tsx @@ -17,7 +17,6 @@ import { import {TelemetryConstants} from '../../shared/telemetry/TelemetryConstants'; import { getVCsOrderedByPinStatus, - isMosipVC, VCItemContainerFlowType, } from '../../shared/Utils'; import {FaceVerificationAlertOverlay} from './FaceVerificationAlertOverlay'; @@ -33,7 +32,6 @@ export const SendVcScreen: React.FC = () => { controller.shareableVcsMetadata, ); let service; - if (shareableVcsMetadataOrderedByPinStatus?.length > 0) { const vcMetadata = shareableVcsMetadataOrderedByPinStatus[0]; const firstVCMachine = useRef( @@ -102,7 +100,7 @@ export const SendVcScreen: React.FC = () => { - {isMosipVC(controller.verifiableCredentialData[0].issuer) && ( + {controller.verifiableCredentialData[0].face && (