From edd1eb6af951adafa8cd8f9df11ee65be8b37220 Mon Sep 17 00:00:00 2001 From: Alka Prasad Date: Tue, 7 May 2024 20:09:28 +0530 Subject: [PATCH] [INJIMOB-1214]: Send error events on CRC failure during VC transfer (#1419) * [INJIMOB-1214]: add logic to send error events whenever we receive CRC failure during VC transfer Signed-off-by: Alka Prasad * [INJIMOB-1214]: updated tuvali version Signed-off-by: Alka Prasad * [INJIMOB-1214]: changeing some variable declaration from let to const Signed-off-by: Alka Prasad --------- Signed-off-by: Alka Prasad --- machines/bleShare/request/requestMachine.ts | 33 +++++++++++++++++++-- package-lock.json | 13 ++++---- package.json | 2 +- shared/telemetry/TelemetryConstants.js | 1 + 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/machines/bleShare/request/requestMachine.ts b/machines/bleShare/request/requestMachine.ts index ca8082e959..8d64dfa796 100644 --- a/machines/bleShare/request/requestMachine.ts +++ b/machines/bleShare/request/requestMachine.ts @@ -826,11 +826,31 @@ export const requestMachine = event.type === EventTypes.onError && event.code.includes(verifierErrorCodePrefix) ) { + let errorMessage = event.message; + if (event.message.includes('CRCFailureCount')) { + const eventMessageList = event.message.split(' '); + const crcFailureCount = parseInt( + eventMessageList[0].split(':')[1], + ); + const totalChunkCount = parseInt( + eventMessageList[1].split(':')[1], + ); + if (crcFailureCount > 0) { + sendErrorEvent( + getErrorEventData( + TelemetryConstants.FlowType.receiverVcShare, + TelemetryConstants.ErrorId.crcFailure, + `Total Chunk Count: ${totalChunkCount} CRC Failure count: ${crcFailureCount}`, + ), + ); + } + errorMessage = event.message.split('-')[1]; + } callback({ type: 'BLE_ERROR', - bleError: {message: event.message, code: event.code}, + bleError: {message: errorMessage, code: event.code}, }); - console.error('BLE Exception: ' + event.message); + console.error('BLE Exception: ' + errorMessage); } }); @@ -840,6 +860,15 @@ export const requestMachine = receiveVc: () => callback => { const statusCallback = (event: VerifierDataEvent) => { if (event.type === EventTypes.onDataReceived) { + if (event.crcFailureCount > 0) { + sendErrorEvent( + getErrorEventData( + TelemetryConstants.FlowType.receiverVcShare, + TelemetryConstants.ErrorId.crcFailure, + `Total Chunk Count: ${event.totalChunkCount} CRC Failure count: ${event.crcFailureCount}`, + ), + ); + } callback({type: 'VC_RECEIVED', vc: JSON.parse(event.data)}); } }; diff --git a/package-lock.json b/package-lock.json index d3a80c45c7..d2c05b529e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@iriscan/biometric-sdk-react-native": "0.2.6", "@mosip/pixelpass": "^0.1.5", "@mosip/secure-keystore": "^0.1.7", - "@mosip/tuvali": "^0.4.9", + "@mosip/tuvali": "git://github.com/mosip/tuvali.git#develop", "@react-native-clipboard/clipboard": "^1.10.0", "@react-native-community/netinfo": "9.3.7", "@react-native-google-signin/google-signin": "^10.1.1", @@ -5689,8 +5689,9 @@ }, "node_modules/@mosip/tuvali": { "version": "0.4.9", - "resolved": "https://registry.npmjs.org/@mosip/tuvali/-/tuvali-0.4.9.tgz", - "integrity": "sha512-WnpnM9EAJKEBdZ71DPSeh2va5LDy01iWFI3Ngtc4KfJ4XHWyQbRQA/1T4QPDgofMTP8wy9wehD7w4m8K8YJdhw==", + "resolved": "git+ssh://git@github.com/mosip/tuvali.git#1b7fb2575bead357da73f971aceb317e384be543", + "integrity": "sha512-220+zbZ3m9LOp2f3upeu500mOr3uxEdnnHvbHayzaZMsBEvK8D7/5UoXSF3OLRJZlZ/f4VKD7GKxMVlZ1thP3Q==", + "license": "MIT", "peerDependencies": { "react": "*", "react-native": "*" @@ -33596,9 +33597,9 @@ "requires": {} }, "@mosip/tuvali": { - "version": "0.4.9", - "resolved": "https://registry.npmjs.org/@mosip/tuvali/-/tuvali-0.4.9.tgz", - "integrity": "sha512-WnpnM9EAJKEBdZ71DPSeh2va5LDy01iWFI3Ngtc4KfJ4XHWyQbRQA/1T4QPDgofMTP8wy9wehD7w4m8K8YJdhw==", + "version": "git+ssh://git@github.com/mosip/tuvali.git#1b7fb2575bead357da73f971aceb317e384be543", + "integrity": "sha512-220+zbZ3m9LOp2f3upeu500mOr3uxEdnnHvbHayzaZMsBEvK8D7/5UoXSF3OLRJZlZ/f4VKD7GKxMVlZ1thP3Q==", + "from": "@mosip/tuvali@git://github.com/mosip/tuvali.git#develop", "requires": {} }, "@nicolo-ribaudo/eslint-scope-5-internals": { diff --git a/package.json b/package.json index ee8bc07964..a5cb035dc7 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "@iriscan/biometric-sdk-react-native": "0.2.6", "@mosip/pixelpass": "^0.1.5", "@mosip/secure-keystore": "^0.1.7", - "@mosip/tuvali": "^0.4.9", + "@mosip/tuvali": "git://github.com/mosip/tuvali.git#develop", "@react-native-clipboard/clipboard": "^1.10.0", "@react-native-community/netinfo": "9.3.7", "@react-native-google-signin/google-signin": "^10.1.1", diff --git a/shared/telemetry/TelemetryConstants.js b/shared/telemetry/TelemetryConstants.js index 8014155bca..308639cdb3 100644 --- a/shared/telemetry/TelemetryConstants.js +++ b/shared/telemetry/TelemetryConstants.js @@ -60,6 +60,7 @@ export const TelemetryConstants = { vcsAreTampered: 'VC_TAMPERED', updatePrivateKey: 'UPDATE_PRIVATE_KEY', vcVerificationFailed: 'VC_VERIFICATION_FAILED', + crcFailure: 'CRC_FAILURE', }), Screens: Object.freeze({