diff --git a/lib/app/shared/enum/message/response_string/response_string.dart b/lib/app/shared/enum/message/response_string/response_string.dart index ed860bafc..ab69a0bbb 100644 --- a/lib/app/shared/enum/message/response_string/response_string.dart +++ b/lib/app/shared/enum/message/response_string/response_string.dart @@ -165,5 +165,9 @@ enum ResponseString { RESPONSE_STRING_accessDenied, RESPONSE_STRING_thisRequestIsNotSupported, RESPONSE_STRING_unsupportedCredential, - RESPONSE_STRING_credentialIssuanceNotAllowedToTheWallet, + RESPONSE_STRING_aloginIsRequired, + RESPONSE_STRING_userConsentIsRequired, + RESPONSE_STRING_theWalletIsNotRegistered, + RESPONSE_STRING_credentialIssuanceDenied, + RESPONSE_STRING_thisCredentialFormatIsNotSupported, } diff --git a/lib/app/shared/enum/message/response_string/response_string_extension.dart b/lib/app/shared/enum/message/response_string/response_string_extension.dart index 47e40e593..a585fdbeb 100644 --- a/lib/app/shared/enum/message/response_string/response_string_extension.dart +++ b/lib/app/shared/enum/message/response_string/response_string_extension.dart @@ -520,10 +520,20 @@ extension ResponseStringX on ResponseString { case ResponseString.RESPONSE_STRING_unsupportedCredential: return globalMessage.RESPONSE_STRING_unsupportedCredential; - case ResponseString - .RESPONSE_STRING_credentialIssuanceNotAllowedToTheWallet: - return globalMessage - .RESPONSE_STRING_credentialIssuanceNotAllowedToTheWallet; + case ResponseString.RESPONSE_STRING_aloginIsRequired: + return globalMessage.RESPONSE_STRING_aloginIsRequired; + + case ResponseString.RESPONSE_STRING_userConsentIsRequired: + return globalMessage.RESPONSE_STRING_userConsentIsRequired; + + case ResponseString.RESPONSE_STRING_theWalletIsNotRegistered: + return globalMessage.RESPONSE_STRING_theWalletIsNotRegistered; + + case ResponseString.RESPONSE_STRING_credentialIssuanceDenied: + return globalMessage.RESPONSE_STRING_credentialIssuanceDenied; + + case ResponseString.RESPONSE_STRING_thisCredentialFormatIsNotSupported: + return globalMessage.RESPONSE_STRING_thisCredentialFormatIsNotSupported; } } } diff --git a/lib/app/shared/helper_functions/helper_functions.dart b/lib/app/shared/helper_functions/helper_functions.dart index 2c3ad70d3..d073e9b96 100644 --- a/lib/app/shared/helper_functions/helper_functions.dart +++ b/lib/app/shared/helper_functions/helper_functions.dart @@ -742,8 +742,10 @@ int getIndexValue({required bool isEBSIV3}) { (MessageHandler messageHandler, String? erroDescription, String? errorUrl) getOIDC4VCError(dynamic e) { + ResponseString responseString = + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported; MessageHandler messageHandler = ResponseMessage( - ResponseString.RESPONSE_STRING_SOMETHING_WENT_WRONG_TRY_AGAIN_LATER, + responseString, ); String? erroDescription; @@ -755,39 +757,60 @@ int getIndexValue({required bool isEBSIV3}) { final data = error.data; if (data != null && data is Map) { - ///error if (data.containsKey('error')) { - if (data['error'] == 'invalid_grant') { - messageHandler = - ResponseMessage(ResponseString.RESPONSE_STRING_invalidRequest); - } else if (data['error'] == 'unauthorized_client') { - messageHandler = - ResponseMessage(ResponseString.RESPONSE_STRING_accessDenied); - } else if (data['error'] == 'access_denied') { - messageHandler = - ResponseMessage(ResponseString.RESPONSE_STRING_accessDenied); - } else if (data['error'] == 'unsupported_response_type') { - messageHandler = ResponseMessage( - ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, - ); - } else if (data['error'] == 'invalid_scope') { - messageHandler = ResponseMessage( - ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, - ); - } else if (data['error'] == 'invalid_token') { - messageHandler = - ResponseMessage(ResponseString.RESPONSE_STRING_accessDenied); - } else if (data['error'] == 'unsupported_credential_type') { - messageHandler = ResponseMessage( - ResponseString.RESPONSE_STRING_unsupportedCredential); - } else if (data['error'] == 'invalid_or_missing_proof') { - messageHandler = ResponseMessage( - ResponseString - .RESPONSE_STRING_credentialIssuanceNotAllowedToTheWallet, - ); + switch (data['error']) { + case 'invalid_request': + case 'invalid_request_uri': + case 'invalid_request_object': + responseString = ResponseString.RESPONSE_STRING_invalidRequest; + + case 'unauthorized_client': + case 'access_denied': + case 'invalid_or_missing_proof': + case 'interaction_required': + responseString = ResponseString.RESPONSE_STRING_accessDenied; + + case 'unsupported_response_type': + case 'invalid_scope': + case 'request_not_supported': + case 'request_uri_not_supported': + responseString = + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported; + + case 'unsupported_credential_type': + responseString = + ResponseString.RESPONSE_STRING_unsupportedCredential; + case 'login_required': + case 'account_selection_required': + responseString = ResponseString.RESPONSE_STRING_aloginIsRequired; + + case 'consent_required': + responseString = + ResponseString.RESPONSE_STRING_userConsentIsRequired; + + case 'registration_not_supported': + responseString = + ResponseString.RESPONSE_STRING_theWalletIsNotRegistered; + + case 'invalid_grant': + case 'invalid_client': + case 'invalid_token': + responseString = + ResponseString.RESPONSE_STRING_credentialIssuanceDenied; + + case 'unsupported_credential_format': + responseString = ResponseString + .RESPONSE_STRING_thisCredentialFormatIsNotSupported; + + default: + responseString = + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported; } } + ///error + messageHandler = ResponseMessage(responseString); + ///error_description if (data.containsKey('error_description')) { erroDescription = data['error_description'].toString(); diff --git a/lib/app/shared/message_handler/global_message.dart b/lib/app/shared/message_handler/global_message.dart index 1c82bfed5..0aed24d98 100644 --- a/lib/app/shared/message_handler/global_message.dart +++ b/lib/app/shared/message_handler/global_message.dart @@ -408,6 +408,13 @@ class GlobalMessage { l10n.thisRequestIsNotSupported; String get RESPONSE_STRING_unsupportedCredential => l10n.unsupportedCredential; - String get RESPONSE_STRING_credentialIssuanceNotAllowedToTheWallet => - l10n.credentialIssuanceNotAllowedToTheWallet; + String get RESPONSE_STRING_aloginIsRequired => l10n.aloginIsRequired; + String get RESPONSE_STRING_userConsentIsRequired => + l10n.userConsentIsRequired; + String get RESPONSE_STRING_theWalletIsNotRegistered => + l10n.theWalletIsNotRegistered; + String get RESPONSE_STRING_credentialIssuanceDenied => + l10n.credentialIssuanceDenied; + String get RESPONSE_STRING_thisCredentialFormatIsNotSupported => + l10n.thisCredentialFormatIsNotSupported; } diff --git a/lib/app/shared/message_handler/response_message.dart b/lib/app/shared/message_handler/response_message.dart index c1377da1f..29eec280f 100644 --- a/lib/app/shared/message_handler/response_message.dart +++ b/lib/app/shared/message_handler/response_message.dart @@ -781,10 +781,31 @@ class ResponseMessage with MessageHandler { context, ); - case ResponseString - .RESPONSE_STRING_credentialIssuanceNotAllowedToTheWallet: + case ResponseString.RESPONSE_STRING_aloginIsRequired: + return ResponseString.RESPONSE_STRING_aloginIsRequired.localise( + context, + ); + + case ResponseString.RESPONSE_STRING_userConsentIsRequired: + return ResponseString.RESPONSE_STRING_userConsentIsRequired.localise( + context, + ); + + case ResponseString.RESPONSE_STRING_theWalletIsNotRegistered: + return ResponseString.RESPONSE_STRING_theWalletIsNotRegistered + .localise( + context, + ); + + case ResponseString.RESPONSE_STRING_credentialIssuanceDenied: + return ResponseString.RESPONSE_STRING_credentialIssuanceDenied + .localise( + context, + ); + + case ResponseString.RESPONSE_STRING_thisCredentialFormatIsNotSupported: return ResponseString - .RESPONSE_STRING_credentialIssuanceNotAllowedToTheWallet.localise( + .RESPONSE_STRING_thisCredentialFormatIsNotSupported.localise( context, ); } diff --git a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart index cfe7c763f..dde574b7d 100644 --- a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart +++ b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart @@ -73,6 +73,7 @@ class QRCodeScanCubit extends Cubit { Future process({required String? scannedResponse}) async { log.i('processing scanned qr code - $scannedResponse'); + goBack(); emit(state.loading(isScan: true)); try { final isInternetAvailable = await isConnected(); @@ -477,7 +478,7 @@ class QRCodeScanCubit extends Cubit { isEBSIV3: isEBSIV3, ); } catch (e) { - log.e(e); + oidc4vcErrorHandling(e); } } diff --git a/lib/dashboard/qr_code/qr_code_scan/view/qr_code_scan_page.dart b/lib/dashboard/qr_code/qr_code_scan/view/qr_code_scan_page.dart index da56cebb3..a62e5b73f 100644 --- a/lib/dashboard/qr_code/qr_code_scan/view/qr_code_scan_page.dart +++ b/lib/dashboard/qr_code/qr_code_scan/view/qr_code_scan_page.dart @@ -40,12 +40,6 @@ class _QrCodeScanPageState extends State { listeners: [ BlocListener( listener: (context, state) async { - if (state.status == QrScanStatus.error) { - if (state.message != null) { - Navigator.of(context).pop(); - } - } - if (state.status == QrScanStatus.goBack) { Navigator.of(context).pop(); } diff --git a/lib/l10n/arb/app_en.arb b/lib/l10n/arb/app_en.arb index 565e86e97..0e2884ad0 100644 --- a/lib/l10n/arb/app_en.arb +++ b/lib/l10n/arb/app_en.arb @@ -970,7 +970,11 @@ "accessDenied": "Access denied.", "thisRequestIsNotSupported": "This request is not supported.", "unsupportedCredential": "Unsupported credential.", - "credentialIssuanceNotAllowedToTheWallet": "Credential issuance not allowed to the wallet.", + "aloginIsRequired": "A login is required.", + "userConsentIsRequired": "User consent is required.", + "theWalletIsNotRegistered": "The wallet is not registered.", + "credentialIssuanceDenied": "Credential issuance denied.", + "thisCredentialFormatIsNotSupported": "This credential format is not supported", "moreDetails": "More Details" } diff --git a/lib/l10n/untranslated.json b/lib/l10n/untranslated.json index 030bdec50..f518f132a 100644 --- a/lib/l10n/untranslated.json +++ b/lib/l10n/untranslated.json @@ -876,7 +876,11 @@ "accessDenied", "thisRequestIsNotSupported", "unsupportedCredential", - "credentialIssuanceNotAllowedToTheWallet", + "aloginIsRequired", + "userConsentIsRequired", + "theWalletIsNotRegistered", + "credentialIssuanceDenied", + "thisCredentialFormatIsNotSupported", "moreDetails" ], @@ -1757,7 +1761,11 @@ "accessDenied", "thisRequestIsNotSupported", "unsupportedCredential", - "credentialIssuanceNotAllowedToTheWallet", + "aloginIsRequired", + "userConsentIsRequired", + "theWalletIsNotRegistered", + "credentialIssuanceDenied", + "thisCredentialFormatIsNotSupported", "moreDetails" ], @@ -1941,7 +1949,11 @@ "accessDenied", "thisRequestIsNotSupported", "unsupportedCredential", - "credentialIssuanceNotAllowedToTheWallet", + "aloginIsRequired", + "userConsentIsRequired", + "theWalletIsNotRegistered", + "credentialIssuanceDenied", + "thisCredentialFormatIsNotSupported", "moreDetails" ], @@ -2822,7 +2834,11 @@ "accessDenied", "thisRequestIsNotSupported", "unsupportedCredential", - "credentialIssuanceNotAllowedToTheWallet", + "aloginIsRequired", + "userConsentIsRequired", + "theWalletIsNotRegistered", + "credentialIssuanceDenied", + "thisCredentialFormatIsNotSupported", "moreDetails" ] } diff --git a/lib/splash/bloclisteners/blocklisteners.dart b/lib/splash/bloclisteners/blocklisteners.dart index b42fb8573..5ba8f7fbe 100644 --- a/lib/splash/bloclisteners/blocklisteners.dart +++ b/lib/splash/bloclisteners/blocklisteners.dart @@ -304,12 +304,7 @@ final qrCodeBlocListener = BlocListener( if (state.status == QrScanStatus.success) { if (state.route != null) { - if (context.read().state == QRCODE_SCAN_PAGE) { - await Navigator.of(context) - .pushReplacement(state.route!); - } else { - await Navigator.of(context).push(state.route!); - } + await Navigator.of(context).push(state.route!); context.read().clearRoute(); } }