mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 13:38:01 -05:00
feat(INJI-560): add error events at multiple places to catch the error scenarios (#1012)
Signed-off-by: Alka <prasadalka1998@gmail.com>
This commit is contained in:
@@ -3,6 +3,11 @@ import {useTranslation} from 'react-i18next';
|
||||
import {PinInput} from './PinInput';
|
||||
import {hashData} from '../shared/commonUtil';
|
||||
import {argon2iConfig} from '../shared/constants';
|
||||
import {
|
||||
getErrorEventData,
|
||||
sendErrorEvent,
|
||||
} from '../shared/telemetry/TelemetryUtils';
|
||||
import {TelemetryConstants} from '../shared/telemetry/TelemetryConstants';
|
||||
|
||||
export const MAX_PIN = 6;
|
||||
|
||||
@@ -32,6 +37,13 @@ export const PasscodeVerify: React.FC<PasscodeVerifyProps> = props => {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
sendErrorEvent(
|
||||
getErrorEventData(
|
||||
TelemetryConstants.FlowType.appLogin,
|
||||
TelemetryConstants.ErrorId.mismatch,
|
||||
error,
|
||||
),
|
||||
);
|
||||
console.log('error:', error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,6 +284,8 @@ export const storeMachine =
|
||||
'Dummy',
|
||||
);
|
||||
} catch (e) {
|
||||
sendErrorEvent(getErrorEventData('ENCRYPTION', '', e));
|
||||
|
||||
if (e.message.includes(keyinvalidatedString)) {
|
||||
await clear();
|
||||
callback(model.events.KEY_INVALIDATE_ERROR());
|
||||
@@ -294,6 +296,13 @@ export const storeMachine =
|
||||
}
|
||||
callback(model.events.READY());
|
||||
} else {
|
||||
sendErrorEvent(
|
||||
getErrorEventData(
|
||||
'ENCRYPTION',
|
||||
'',
|
||||
'Could not get the android Key alias',
|
||||
),
|
||||
);
|
||||
callback(
|
||||
model.events.ERROR(
|
||||
new Error('Could not get the android Key alias'),
|
||||
@@ -400,6 +409,14 @@ export const storeMachine =
|
||||
}
|
||||
callback(model.events.STORE_RESPONSE(response, event.requester));
|
||||
} catch (e) {
|
||||
sendErrorEvent(
|
||||
getErrorEventData(
|
||||
TelemetryConstants.FlowType.fetchData,
|
||||
'',
|
||||
e.message,
|
||||
{e},
|
||||
),
|
||||
);
|
||||
if (e.message.includes(keyinvalidatedString)) {
|
||||
await clear();
|
||||
callback(model.events.KEY_INVALIDATE_ERROR());
|
||||
@@ -432,6 +449,13 @@ export const storeMachine =
|
||||
console.log('Credentials successfully loaded for user');
|
||||
callback(model.events.KEY_RECEIVED(existingCredentials.password));
|
||||
} else {
|
||||
sendErrorEvent(
|
||||
getErrorEventData(
|
||||
TelemetryConstants.FlowType.fetchData,
|
||||
'',
|
||||
'Could not get keychain credentials',
|
||||
),
|
||||
);
|
||||
console.log('Credentials failed to load for user');
|
||||
callback(
|
||||
model.events.ERROR(
|
||||
@@ -452,6 +476,13 @@ export const storeMachine =
|
||||
if (hasSetCredentials) {
|
||||
callback(model.events.KEY_RECEIVED(randomBytesString));
|
||||
} else {
|
||||
sendErrorEvent(
|
||||
getErrorEventData(
|
||||
TelemetryConstants.FlowType.fetchData,
|
||||
'',
|
||||
'Could not generate keychain credentials',
|
||||
),
|
||||
);
|
||||
callback(
|
||||
model.events.ERROR(
|
||||
new Error('Could not generate keychain credentials.'),
|
||||
@@ -532,6 +563,13 @@ export async function getItem(
|
||||
}
|
||||
if (data === null && VCMetadata.isVCKey(key)) {
|
||||
await removeItem(key, data, encryptionKey);
|
||||
sendErrorEvent(
|
||||
getErrorEventData(
|
||||
TelemetryConstants.FlowType.fetchData,
|
||||
TelemetryConstants.ErrorId.tampered,
|
||||
tamperedErrorMessageString,
|
||||
),
|
||||
);
|
||||
throw new Error(tamperedErrorMessageString);
|
||||
} else {
|
||||
return defaultValue;
|
||||
@@ -544,8 +582,22 @@ export async function getItem(
|
||||
e instanceof BiometricCancellationError ||
|
||||
e.message.includes('Key not found') // this error happens when previous get Item calls failed due to key invalidation and data and keys are deleted
|
||||
) {
|
||||
sendErrorEvent(
|
||||
getErrorEventData(
|
||||
TelemetryConstants.FlowType.fetchData,
|
||||
TelemetryConstants.ErrorId.tampered,
|
||||
e.message,
|
||||
),
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
sendErrorEvent(
|
||||
getErrorEventData(
|
||||
TelemetryConstants.FlowType.fetchData,
|
||||
TelemetryConstants.ErrorId.tampered,
|
||||
`Exception in getting item for ${key}: ${e}`,
|
||||
),
|
||||
);
|
||||
console.error(`Exception in getting item for ${key}: ${e}`);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@@ -330,11 +330,21 @@ export const AddVcModalMachine =
|
||||
'OTP is invalid': 'invalidOtp',
|
||||
'OTP has expired': 'expiredOtp',
|
||||
};
|
||||
return OTP_ERRORS_MAP[message]
|
||||
|
||||
const otpErrorMessage = OTP_ERRORS_MAP[message]
|
||||
? i18n.t(`errors.backend.${OTP_ERRORS_MAP[message]}`, {
|
||||
ns: 'AddVcModal',
|
||||
})
|
||||
: message;
|
||||
|
||||
sendErrorEvent(
|
||||
getErrorEventData(
|
||||
TelemetryConstants.FlowType.vcDownload,
|
||||
message,
|
||||
otpErrorMessage,
|
||||
),
|
||||
);
|
||||
return otpErrorMessage;
|
||||
},
|
||||
}),
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ import {
|
||||
} from './constants';
|
||||
import FileStorage, {getFilePath, vcDirectoryPath} from './fileStorage';
|
||||
import {__AppId} from './GlobalVariables';
|
||||
import {getErrorEventData, sendErrorEvent} from './telemetry/TelemetryUtils';
|
||||
import {TelemetryConstants} from './telemetry/TelemetryConstants';
|
||||
|
||||
export const MMKV = new MMKVLoader().initialize();
|
||||
|
||||
@@ -80,6 +82,13 @@ class Storage {
|
||||
const isCorrupted = await this.isCorruptedVC(key, encryptionKey, data);
|
||||
|
||||
if (isCorrupted) {
|
||||
sendErrorEvent(
|
||||
getErrorEventData(
|
||||
TelemetryConstants.FlowType.fetchData,
|
||||
TelemetryConstants.ErrorId.tampered,
|
||||
'VC is corrupted and will be deleted from storage',
|
||||
),
|
||||
);
|
||||
console.debug(
|
||||
'[Inji-406]: VC is corrupted and will be deleted from storage',
|
||||
);
|
||||
@@ -110,9 +119,23 @@ class Storage {
|
||||
);
|
||||
|
||||
if (isDownloaded && error.message.includes(ENOENT)) {
|
||||
sendErrorEvent(
|
||||
getErrorEventData(
|
||||
TelemetryConstants.FlowType.fetchData,
|
||||
TelemetryConstants.ErrorId.dataRetrieval,
|
||||
error.message,
|
||||
),
|
||||
);
|
||||
throw new Error(ENOENT);
|
||||
}
|
||||
}
|
||||
sendErrorEvent(
|
||||
getErrorEventData(
|
||||
TelemetryConstants.FlowType.fetchData,
|
||||
TelemetryConstants.ErrorId.dataRetrieval,
|
||||
'Error Occurred while retriving from Storage',
|
||||
),
|
||||
);
|
||||
|
||||
console.log('Error Occurred while retriving from Storage.', error);
|
||||
throw error;
|
||||
|
||||
@@ -10,6 +10,7 @@ export const TelemetryConstants = {
|
||||
appLogin: 'App Login',
|
||||
vcLockOrRevoke: 'VC Lock / VC Revoke',
|
||||
getVcUsingAid: 'Get VC using AID',
|
||||
fetchData: 'Fetch Data',
|
||||
}),
|
||||
|
||||
EndEventStatus: Object.freeze({
|
||||
@@ -37,6 +38,8 @@ export const TelemetryConstants = {
|
||||
userCancel: 'USER_CANCEL',
|
||||
resend: 'RESEND',
|
||||
activationFailed: 'ACTIVATION_FAILED',
|
||||
tampered: 'TAMPERED',
|
||||
dataRetrieval: 'DATA_RETRIEVAL',
|
||||
}),
|
||||
|
||||
Screens: Object.freeze({
|
||||
|
||||
Reference in New Issue
Block a user