Skip to content

Commit

Permalink
feat: Update error responses #2573
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Jul 25, 2024
1 parent 558624c commit a6e18ef
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,8 @@ enum ResponseString {
RESPONSE_STRING_statusListInvalidSignature,
RESPONSE_STRING_theWalletIsSuspended,
RESPONSE_STRING_couldNotFindTheAccountWithThisAddress,
RESPONSE_STRING_invalidRequestErrorDescription,
RESPONSE_STRING_invalidClientErrorDescription,
RESPONSE_STRING_vpFormatsNotSupportedErrorDescription,
RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription,
}
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,21 @@ extension ResponseStringX on ResponseString {
.RESPONSE_STRING_couldNotFindTheAccountWithThisAddress(
injectedMessage ?? '',
);
;

case ResponseString.RESPONSE_STRING_invalidRequestErrorDescription:
return globalMessage.RESPONSE_STRING_invalidRequestErrorDescription;

case ResponseString.RESPONSE_STRING_invalidClientErrorDescription:
return globalMessage.RESPONSE_STRING_invalidClientErrorDescription;

case ResponseString.RESPONSE_STRING_vpFormatsNotSupportedErrorDescription:
return globalMessage
.RESPONSE_STRING_vpFormatsNotSupportedErrorDescription;

case ResponseString
.RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription:
return globalMessage
.RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription;
}
}
}
16 changes: 14 additions & 2 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,6 @@ MessageHandler getMessageHandler(dynamic e) {

ResponseString getErrorResponseString(String errorString) {
switch (errorString) {
case 'invalid_request':
case 'invalid_request_uri':
case 'invalid_request_object':
return ResponseString.RESPONSE_STRING_invalidRequest;
Expand Down Expand Up @@ -1282,7 +1281,6 @@ ResponseString getErrorResponseString(String errorString) {
return ResponseString.RESPONSE_STRING_theWalletIsNotRegistered;

case 'invalid_grant':
case 'invalid_client':
case 'invalid_token':
return ResponseString.RESPONSE_STRING_credentialIssuanceDenied;

Expand All @@ -1302,6 +1300,20 @@ ResponseString getErrorResponseString(String errorString) {
return ResponseString
.RESPONSE_STRING_theIssuanceOfThisCredentialIsPending;

case 'invalid_request':
return ResponseString.RESPONSE_STRING_invalidRequestErrorDescription;

case 'invalid_client':
return ResponseString.RESPONSE_STRING_invalidClientErrorDescription;

case 'vp_formats_not_supported':
return ResponseString
.RESPONSE_STRING_vpFormatsNotSupportedErrorDescription;

case 'invalid_presentation_definition_uri':
return ResponseString
.RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription;

default:
return ResponseString.RESPONSE_STRING_thisRequestIsNotSupported;
}
Expand Down
12 changes: 12 additions & 0 deletions lib/app/shared/message_handler/global_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,16 @@ class GlobalMessage {
String get RESPONSE_STRING_theWalletIsSuspended => l10n.theWalletIsSuspended;
String RESPONSE_STRING_couldNotFindTheAccountWithThisAddress(String value) =>
l10n.couldNotFindTheAccountWithThisAddress(value);

String get RESPONSE_STRING_invalidRequestErrorDescription =>
l10n.invalidRequestErrorDescription;

String get RESPONSE_STRING_invalidClientErrorDescription =>
l10n.invalidClientErrorDescription;

String get RESPONSE_STRING_vpFormatsNotSupportedErrorDescription =>
l10n.vpFormatsNotSupportedErrorDescription;

String get RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription =>
l10n.invalidPresentationDefinitionUriErrorDescription;
}
27 changes: 27 additions & 0 deletions lib/app/shared/message_handler/response_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,33 @@ class ResponseMessage with MessageHandler {
context,
injectedMessage: injectedMessage,
);

case ResponseString.RESPONSE_STRING_invalidRequestErrorDescription:
return ResponseString.RESPONSE_STRING_invalidRequestErrorDescription
.localise(
context,
);

case ResponseString.RESPONSE_STRING_invalidClientErrorDescription:
return ResponseString.RESPONSE_STRING_invalidClientErrorDescription
.localise(
context,
);

case ResponseString
.RESPONSE_STRING_vpFormatsNotSupportedErrorDescription:
return ResponseString
.RESPONSE_STRING_vpFormatsNotSupportedErrorDescription.localise(
context,
);

case ResponseString
.RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription:
return ResponseString
.RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription
.localise(
context,
);
}
}
return '';
Expand Down
6 changes: 5 additions & 1 deletion lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1053,5 +1053,9 @@
"account": {}
}
},
"cannotDeleteCurrentAccount": "Sorrry, you cannot delete current account"
"cannotDeleteCurrentAccount": "Sorrry, you cannot delete current account",
"invalidRequestErrorDescription": "The request contains more than one out of the following three options to communicate a requested Credential: a presentation_definition parameter, a presentation_definition_uri parameter, or a scope value representing a Presentation Definition. Requested Presentation Definition does not conform the specs.The Wallet does not support the client_id_scheme value passed in the Authorization Request.The Client Identifier passed in the request did not belong to the Client Identifier scheme indicated in the Authorization Request, or requirements of a certain scheme was violated.",
"invalidClientErrorDescription": "client_id is not conformed to client_id_scheme",
"vpFormatsNotSupportedErrorDescription": "The Wallet does not support any of the formats requested by the Verifier, such as those included in the vp_formats registration parameter.",
"invalidPresentationDefinitionUriErrorDescription": "The Presentation Definition URL cannot be reached."
}
18 changes: 15 additions & 3 deletions lib/l10n/untranslated.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
"themeSettingsDescription",
"couldNotFindTheAccountWithThisAddress",
"deleteAccountMessage",
"cannotDeleteCurrentAccount"
"cannotDeleteCurrentAccount",
"invalidRequestErrorDescription",
"invalidClientErrorDescription",
"vpFormatsNotSupportedErrorDescription",
"invalidPresentationDefinitionUriErrorDescription"
],

"es": [
Expand All @@ -46,7 +50,11 @@
"themeSettingsDescription",
"couldNotFindTheAccountWithThisAddress",
"deleteAccountMessage",
"cannotDeleteCurrentAccount"
"cannotDeleteCurrentAccount",
"invalidRequestErrorDescription",
"invalidClientErrorDescription",
"vpFormatsNotSupportedErrorDescription",
"invalidPresentationDefinitionUriErrorDescription"
],

"fr": [
Expand Down Expand Up @@ -76,6 +84,10 @@
"themeSettingsDescription",
"couldNotFindTheAccountWithThisAddress",
"deleteAccountMessage",
"cannotDeleteCurrentAccount"
"cannotDeleteCurrentAccount",
"invalidRequestErrorDescription",
"invalidClientErrorDescription",
"vpFormatsNotSupportedErrorDescription",
"invalidPresentationDefinitionUriErrorDescription"
]
}

0 comments on commit a6e18ef

Please sign in to comment.