diff --git a/demo/app/android/app/src/main/kotlin/walletsdk/flutter/app/MainActivity.kt b/demo/app/android/app/src/main/kotlin/walletsdk/flutter/app/MainActivity.kt index 38cf05f9f..af226f63f 100644 --- a/demo/app/android/app/src/main/kotlin/walletsdk/flutter/app/MainActivity.kt +++ b/demo/app/android/app/src/main/kotlin/walletsdk/flutter/app/MainActivity.kt @@ -186,7 +186,7 @@ class MainActivity : FlutterActivity() { "processAuthorizationRequest" -> { try { - val creds = processAuthorizationRequest(call) + val creds = processAuthorizationRequest(call, result) result.success(creds) } catch (e: Exception) { @@ -755,8 +755,7 @@ class MainActivity : FlutterActivity() { for (cred in vcCredentials) { val parsedVC = Verifiable.parseCredential(cred, opts) - var issuerID = parsedVC.issuerID() - return issuerID + return parsedVC.issuerID() } return "" } @@ -802,7 +801,7 @@ class MainActivity : FlutterActivity() { /** This method invoke processAuthorizationRequest defined in OpenID4Vp.kt file. */ - private fun processAuthorizationRequest(call: MethodCall): List { + private fun processAuthorizationRequest(call: MethodCall, result: MethodChannel.Result): List { val walletSDK = this.walletSDK ?: throw java.lang.Exception("walletSDK not initiated. Call initSDK().") val authorizationRequest = call.argument("authorizationRequest") @@ -821,9 +820,13 @@ class MainActivity : FlutterActivity() { val matchedReq = openID4VP.getMatchedSubmissionRequirements( convertToVerifiableCredentialsArray(storedCredentials) ) - return convertVerifiableCredentialsArray( + var resp = convertVerifiableCredentialsArray( matchedReq.atIndex(0).descriptorAtIndex(0).matchedVCs ) + if (resp.isEmpty()) { + var typeConstraint = matchedReq.atIndex(0).descriptorAtIndex(0).typeConstraint() + result.error("NATIVE_ERR", "No credentials of type $typeConstraint were found", "Required credential $typeConstraint is missing from the wallet"); + } } return listOf() } diff --git a/demo/app/ios/Runner/flutterPlugin.swift b/demo/app/ios/Runner/flutterPlugin.swift index ec6749f2d..8f4094c9b 100644 --- a/demo/app/ios/Runner/flutterPlugin.swift +++ b/demo/app/ios/Runner/flutterPlugin.swift @@ -174,11 +174,13 @@ public class SwiftWalletSDKPlugin: NSObject, FlutterPlugin { credentials: storedCredentials!)) var resp = convertVerifiableCredentialsArray(arr: matchedReq.atIndex(0)!.descriptor(at:0)!.matchedVCs!) if (resp.isEmpty) { + var typeConstraint = matchedReq.atIndex(0)!.descriptor(at:0)!.typeConstraint() return result(FlutterError.init(code: "NATIVE_ERR", - message: "error while process authorization request", - details: "no matching submission requirement is found")) - + message: "No credentials of type \(typeConstraint) were found", + details: "Required credential \(typeConstraint) is missing from the wallet")) + } + result(resp) } return result(Array()) diff --git a/demo/app/lib/scenarios/handle_openid_vp_flow.dart b/demo/app/lib/scenarios/handle_openid_vp_flow.dart index 2ddc9e41a..04d5449b6 100644 --- a/demo/app/lib/scenarios/handle_openid_vp_flow.dart +++ b/demo/app/lib/scenarios/handle_openid_vp_flow.dart @@ -15,6 +15,7 @@ import 'package:app/services/storage_service.dart'; import 'package:app/views/presentation_preview.dart'; import 'package:app/views/presentation_preview_multi_cred.dart'; import 'package:app/views/presentation_preview_multi_cred_radio.dart'; +import 'package:flutter/services.dart'; import 'package:jwt_decode/jwt_decode.dart'; void handleOpenIDVpFlow(BuildContext context, String qrCodeURL) async { @@ -42,13 +43,14 @@ void handleOpenIDVpFlow(BuildContext context, String qrCodeURL) async { } try { - await walletSDKPlugin.processAuthorizationRequest(authorizationRequest: qrCodeURL, storedCredentials: credentials); - } catch (error) { + var resp = await walletSDKPlugin.processAuthorizationRequest( + authorizationRequest: qrCodeURL, storedCredentials: credentials); + } on PlatformException catch (error) { Navigator.push( context, MaterialPageRoute( - builder: (context) => CustomError( - requestErrorTitleMsg: "No matching credential found", requestErrorSubTitleMsg: error.toString()))); + builder: (context) => + CustomError(requestErrorTitleMsg: error.message!, requestErrorSubTitleMsg: error.details))); } // Get the matched VCIDs from the submission request. var getSubmissionRequest = await walletSDKPlugin.getSubmissionRequirements(storedCredentials: credentials);