diff --git a/locales/ara.json b/locales/ara.json index f9beec50eb..dffaf46f61 100644 --- a/locales/ara.json +++ b/locales/ara.json @@ -200,6 +200,10 @@ "technicalDifficulty": { "title": "حدث خطأ ما!", "message": "في الوقت الحالي، نواجه صعوبات تقنية. يرجى المحاولة مرة أخرى لاحقا." + }, + "credentialTypeListDownloadFailure": { + "title": "حدث خطأ!", + "message": "فشل تحميل قائمة بيانات الاعتماد. يرجى المحاولة مرة أخرى لاحقا" } } }, diff --git a/locales/en.json b/locales/en.json index f1ad4f12c5..a3b9e38417 100644 --- a/locales/en.json +++ b/locales/en.json @@ -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" } } }, diff --git a/locales/fil.json b/locales/fil.json index 9a674d387c..34b2c99be8 100644 --- a/locales/fil.json +++ b/locales/fil.json @@ -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" } } }, diff --git a/locales/hin.json b/locales/hin.json index eb3c9f23af..7c9b5ec0ba 100644 --- a/locales/hin.json +++ b/locales/hin.json @@ -201,6 +201,10 @@ "technicalDifficulty": { "title": "कुछ गलत हो गया!", "message": "वर्तमान में, हम तकनीकी कठिनाइयों का सामना कर रहे हैं। कृपया बाद में पुन: प्रयास करें।" + }, + "credentialTypeListDownloadFailure": { + "title": "एक त्रुटि हुई!", + "message": "क्रेडेंशियल सूची लोड होने में विफल रही. कृपया बाद में पुन: प्रयास करें" } } }, diff --git a/locales/kan.json b/locales/kan.json index e8bb91700f..beb486c71f 100644 --- a/locales/kan.json +++ b/locales/kan.json @@ -200,6 +200,10 @@ "technicalDifficulty": { "title": "ಏನೋ ತಪ್ಪಾಗಿದೆ!", "message": "ಪ್ರಸ್ತುತ, ನಾವು ತಾಂತ್ರಿಕ ತೊಂದರೆಗಳನ್ನು ಎದುರಿಸುತ್ತಿದ್ದೇವೆ. ದಯವಿಟ್ಟು ನಂತರ ಮತ್ತೆ ಪ್ರಯತ್ನಿಸಿ." + }, + "credentialTypeListDownloadFailure": { + "title": "ಒಂದು ದೋಷ ಸಂಭವಿಸಿದೆ!", + "message": "ರುಜುವಾತು ಪಟ್ಟಿಯನ್ನು ಲೋಡ್ ಮಾಡಲು ವಿಫಲವಾಗಿದೆ. ದಯವಿಟ್ಟು ನಂತರ ಮತ್ತೆ ಪ್ರಯತ್ನಿಸಿ" } } }, diff --git a/locales/tam.json b/locales/tam.json index 24fffcac28..b44b859140 100644 --- a/locales/tam.json +++ b/locales/tam.json @@ -200,6 +200,10 @@ "technicalDifficulty": { "title": "ஏதோ தவறு நடந்துவிட்டது!", "message": "தற்போது, ​​தொழில்நுட்ப சிக்கல்களை சந்தித்து வருகிறோம். பிறகு முயற்சிக்கவும்." + }, + "credentialTypeListDownloadFailure": { + "title": "ஒரு பிழை ஏற்பட்டது!", + "message": "நற்சான்றிதழ் பட்டியலை ஏற்ற முடியவில்லை. பிறகு முயற்சிக்கவும்" } } }, diff --git a/machines/Issuers/IssuersActions.ts b/machines/Issuers/IssuersActions.ts index 28d3c78ec9..7c29d15d9f 100644 --- a/machines/Issuers/IssuersActions.ts +++ b/machines/Issuers/IssuersActions.ts @@ -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); diff --git a/machines/Issuers/IssuersMachine.ts b/machines/Issuers/IssuersMachine.ts index 11ffda899c..d7a5cefe17 100644 --- a/machines/Issuers/IssuersMachine.ts +++ b/machines/Issuers/IssuersMachine.ts @@ -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: [ @@ -118,7 +124,10 @@ export const IssuersMachine = model.createMachine( }, ], onError: { - actions: ['setError', 'resetLoadingReason'], + actions: [ + 'setCredentialTypeListDownloadFailureError', + 'resetLoadingReason', + ], target: 'error', }, }, diff --git a/machines/Issuers/IssuersService.ts b/machines/Issuers/IssuersService.ts index 3715116458..c2109e5d9c 100644 --- a/machines/Issuers/IssuersService.ts +++ b/machines/Issuers/IssuersService.ts @@ -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) => { @@ -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(); diff --git a/screens/Issuers/IssuersScreen.tsx b/screens/Issuers/IssuersScreen.tsx index 06d528774f..b386744b9d 100644 --- a/screens/Issuers/IssuersScreen.tsx +++ b/screens/Issuers/IssuersScreen.tsx @@ -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 = () => { @@ -289,5 +293,3 @@ export const IssuersScreen: React.FC< ); }; - - diff --git a/shared/openId4VCI/Utils.ts b/shared/openId4VCI/Utils.ts index b36cf29073..7eed8d516a 100644 --- a/shared/openId4VCI/Utils.ts +++ b/shared/openId4VCI/Utils.ts @@ -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( @@ -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(