Skip to content

Commit

Permalink
[INJIMOB-1214]: Send error events on CRC failure during VC transfer (m…
Browse files Browse the repository at this point in the history
…osip#1419)

* [INJIMOB-1214]: add logic to send error events whenever we receive CRC failure during VC transfer

Signed-off-by: Alka Prasad <[email protected]>

* [INJIMOB-1214]: updated tuvali version

Signed-off-by: Alka Prasad <[email protected]>

* [INJIMOB-1214]: changeing some variable declaration from let to const

Signed-off-by: Alka Prasad <[email protected]>

---------

Signed-off-by: Alka Prasad <[email protected]>
  • Loading branch information
Alka1703 authored May 7, 2024
1 parent 94ae9f1 commit edd1eb6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
33 changes: 31 additions & 2 deletions machines/bleShare/request/requestMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

Expand All @@ -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)});
}
};
Expand Down
13 changes: 7 additions & 6 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions shared/telemetry/TelemetryConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const TelemetryConstants = {
vcsAreTampered: 'VC_TAMPERED',
updatePrivateKey: 'UPDATE_PRIVATE_KEY',
vcVerificationFailed: 'VC_VERIFICATION_FAILED',
crcFailure: 'CRC_FAILURE',
}),

Screens: Object.freeze({
Expand Down

0 comments on commit edd1eb6

Please sign in to comment.