Skip to content

Commit

Permalink
[INJIMOB-1814]: handle error scenarios on empty credentialType list (m…
Browse files Browse the repository at this point in the history
…osip#1586)

Signed-off-by: Alka Prasad <[email protected]>
  • Loading branch information
Alka1703 authored Aug 27, 2024
1 parent 2c9b0fc commit 1962684
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 26 deletions.
4 changes: 4 additions & 0 deletions locales/ara.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@
"technicalDifficulty": {
"title": "حدث خطأ ما!",
"message": "في الوقت الحالي، نواجه صعوبات تقنية. يرجى المحاولة مرة أخرى لاحقا."
},
"credentialTypeListDownloadFailure": {
"title": "حدث خطأ!",
"message": "فشل تحميل قائمة بيانات الاعتماد. يرجى المحاولة مرة أخرى لاحقا"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@
"technicalDifficulty": {
"title": "Something went wrong!",
"message": "Currently, we are experiencing technical difficulties. Please try again later."
},
"credentialTypeListDownloadFailure": {
"title": "An Error Occured!",
"message": "The credential list failed to load. Please try again later"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions locales/fil.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@
"technicalDifficulty": {
"title": "may nangyaring mali!",
"message": "Sa kasalukuyan, nakakaranas tayo ng mga teknikal na paghihirap. Pakisubukang muli mamaya."
},
"credentialTypeListDownloadFailure": {
"title": "Isang Error ang Naganap!",
"message": "Nabigong ma-load ang listahan ng kredensyal. Pakisubukang muli mamaya"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions locales/hin.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@
"technicalDifficulty": {
"title": "कुछ गलत हो गया!",
"message": "वर्तमान में, हम तकनीकी कठिनाइयों का सामना कर रहे हैं। कृपया बाद में पुन: प्रयास करें।"
},
"credentialTypeListDownloadFailure": {
"title": "एक त्रुटि हुई!",
"message": "क्रेडेंशियल सूची लोड होने में विफल रही. कृपया बाद में पुन: प्रयास करें"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions locales/kan.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@
"technicalDifficulty": {
"title": "ಏನೋ ತಪ್ಪಾಗಿದೆ!",
"message": "ಪ್ರಸ್ತುತ, ನಾವು ತಾಂತ್ರಿಕ ತೊಂದರೆಗಳನ್ನು ಎದುರಿಸುತ್ತಿದ್ದೇವೆ. ದಯವಿಟ್ಟು ನಂತರ ಮತ್ತೆ ಪ್ರಯತ್ನಿಸಿ."
},
"credentialTypeListDownloadFailure": {
"title": "ಒಂದು ದೋಷ ಸಂಭವಿಸಿದೆ!",
"message": "ರುಜುವಾತು ಪಟ್ಟಿಯನ್ನು ಲೋಡ್ ಮಾಡಲು ವಿಫಲವಾಗಿದೆ. ದಯವಿಟ್ಟು ನಂತರ ಮತ್ತೆ ಪ್ರಯತ್ನಿಸಿ"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions locales/tam.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@
"technicalDifficulty": {
"title": "ஏதோ தவறு நடந்துவிட்டது!",
"message": "தற்போது, ​​தொழில்நுட்ப சிக்கல்களை சந்தித்து வருகிறோம். பிறகு முயற்சிக்கவும்."
},
"credentialTypeListDownloadFailure": {
"title": "ஒரு பிழை ஏற்பட்டது!",
"message": "நற்சான்றிதழ் பட்டியலை ஏற்ற முடியவில்லை. பிறகு முயற்சிக்கவும்"
}
}
},
Expand Down
18 changes: 14 additions & 4 deletions machines/Issuers/IssuersActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,25 @@ export const IssuersActions = (model: any) => {
resetSelectedCredentialType: model.assign({
selectedCredentialType: {},
}),
setFetchWellknownError:model.assign({
errorMessage:(_: any, event: any)=>{
setFetchWellknownError: model.assign({
errorMessage: (_: any, event: any) => {
const error = event.data.message;
if (error.includes(NETWORK_REQUEST_FAILED)) {
return ErrorMessage.NO_INTERNET;
}
return ErrorMessage.TECHNICAL_DIFFICULTIES;
},
}),
setCredentialTypeListDownloadFailureError: model.assign({
errorMessage: (_: any, event: any) => {
const error = event.data.message;
if (error.includes(NETWORK_REQUEST_FAILED)) {
return ErrorMessage.NO_INTERNET;
}
return ErrorMessage.TECHNICAL_DIFFICULTIES
}
return ErrorMessage.CREDENTIAL_TYPE_DOWNLOAD_FAILURE;
},
}),

setError: model.assign({
errorMessage: (_: any, event: any) => {
console.error('Error occurred ', event.data.message);
Expand Down
11 changes: 10 additions & 1 deletion machines/Issuers/IssuersMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ export const IssuersMachine = model.createMachine(
downloadCredentialTypes: {
description:
'downloads the credentials supported from the selected issuer',
on: {
TRY_AGAIN: {
actions: ['downloadIssuerWellknown'],
target: 'idle',
},
},
invoke: {
src: 'downloadCredentialTypes',
onDone: [
Expand All @@ -118,7 +124,10 @@ export const IssuersMachine = model.createMachine(
},
],
onError: {
actions: ['setError', 'resetLoadingReason'],
actions: [
'setCredentialTypeListDownloadFailureError',
'resetLoadingReason',
],
target: 'error',
},
},
Expand Down
36 changes: 20 additions & 16 deletions machines/Issuers/IssuersService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,24 @@ export const IssuersService = () => {
checkInternet: async () => await NetInfo.fetch(),
downloadIssuerWellknown: async (context: any) => {
const wellknownResponse = await CACHED_API.fetchIssuerWellknownConfig(
context.selectedIssuerId,
);
return wellknownResponse;

context.selectedIssuerId,
);
return wellknownResponse;
},
downloadCredentialTypes: async (context: any) => {
const credentialTypes = [];
for (const key in context.selectedIssuer
.credential_configurations_supported) {
credentialTypes.push(
{id:key, ...context.selectedIssuer.credential_configurations_supported[key]},
);
credentialTypes.push({
id: key,
...context.selectedIssuer.credential_configurations_supported[key],
});
}
if (credentialTypes.length == 0)
throw new Error(
`No credential type found for issuer ${context.selectedIssuer.credential_issuer}`,
);

return credentialTypes;
},
downloadCredential: async (context: any) => {
Expand Down Expand Up @@ -87,15 +92,14 @@ export const IssuersService = () => {
TelemetryConstants.Screens.webViewPage,
),
);
return await authorize(
constructAuthorizationConfiguration(
context.selectedIssuer,
context.selectedCredentialType.scope,
),
);

},

return await authorize(
constructAuthorizationConfiguration(
context.selectedIssuer,
context.selectedCredentialType.scope,
),
);
},

generateKeyPair: async () => {
if (!isHardwareKeystoreExists) {
return await generateKeys();
Expand Down
8 changes: 5 additions & 3 deletions screens/Issuers/IssuersScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ export const IssuersScreen: React.FC<
};

function isBackendError(): boolean {
return controller.errorMessageType === ErrorMessage.TECHNICAL_DIFFICULTIES
return (
controller.errorMessageType === ErrorMessage.TECHNICAL_DIFFICULTIES ||
controller.errorMessageType ===
ErrorMessage.CREDENTIAL_TYPE_DOWNLOAD_FAILURE
);
}

const onFocusSearch = () => {
Expand Down Expand Up @@ -289,5 +293,3 @@ export const IssuersScreen: React.FC<
</React.Fragment>
);
};


8 changes: 6 additions & 2 deletions shared/openId4VCI/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ export const getCredentialIssuersWellKnownConfig = async (
response,
vcCredentialTypes!,
);
if (credentialDetails.order !== null && credentialDetails.order.length > 0) {
if (
credentialDetails.order !== null &&
credentialDetails.order.length > 0
) {
fields = credentialDetails.order;
} else {
fields = Object.keys(
Expand Down Expand Up @@ -272,7 +275,8 @@ export enum ErrorMessage {
GENERIC = 'generic',
REQUEST_TIMEDOUT = 'requestTimedOut',
BIOMETRIC_CANCELLED = 'biometricCancelled',
TECHNICAL_DIFFICULTIES = "technicalDifficulty"
TECHNICAL_DIFFICULTIES = 'technicalDifficulty',
CREDENTIAL_TYPE_DOWNLOAD_FAILURE = 'credentialTypeListDownloadFailure',
}

export async function constructProofJWT(
Expand Down

0 comments on commit 1962684

Please sign in to comment.