From 74baf8c4c0a03002eb23ff5c7b8c74d383295d23 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 22 May 2024 17:16:09 +0545 Subject: [PATCH] Bypas clientmetadata check when clientype is jwkthumprint and when vcformat is null then ignore nested_data --- .../cubit/qr_code_scan_cubit.dart | 35 ++++++---- lib/scan/cubit/scan_cubit.dart | 69 ++++++++++--------- 2 files changed, 58 insertions(+), 46 deletions(-) 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 ee2a864c7..ee81113eb 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 @@ -627,21 +627,26 @@ class QRCodeScanCubit extends Cubit { } } } - - final clientMetadata = state.uri!.queryParameters['client_metadata']; - if (clientMetadata != null) { - final clientMetadataMap = - jsonDecode(clientMetadata) as Map; - final data = - clientMetadataMap['subject_syntax_types_supported'] as List; - if (!data.contains('did:key')) { - if (isSecurityHigh) { - throw ResponseMessage( - data: { - 'error': 'unsupported_response_type', - 'error_description': 'The subject syntax type is not supported.', - }, - ); + final clientType = profileCubit.state.model.profileSetting + .selfSovereignIdentityOptions.customOidc4vcProfile.clientType; + + if (clientType != ClientType.p256JWKThumprint) { + final clientMetadata = state.uri!.queryParameters['client_metadata']; + if (clientMetadata != null) { + final clientMetadataMap = + jsonDecode(clientMetadata) as Map; + final data = clientMetadataMap['subject_syntax_types_supported'] + as List; + if (!data.contains('did:key')) { + if (isSecurityHigh) { + throw ResponseMessage( + data: { + 'error': 'unsupported_response_type', + 'error_description': + 'The subject syntax type is not supported.', + }, + ); + } } } } diff --git a/lib/scan/cubit/scan_cubit.dart b/lib/scan/cubit/scan_cubit.dart index 4a93e0f7e..ed099301a 100644 --- a/lib/scan/cubit/scan_cubit.dart +++ b/lib/scan/cubit/scan_cubit.dart @@ -798,44 +798,51 @@ class ScanCubit extends Cubit { credentialList: [credentialsToBePresented[i]], ); - final pathNested = {'id': inputDescriptor.id, 'format': vcFormat}; + Map? pathNested; + + if (!(inputDescriptor.id == null || vcFormat == null)) { + pathNested = { + 'id': inputDescriptor.id, + 'format': vcFormat, + }; + } if (credential.isNotEmpty) { - if (credentialsToBePresented.length == 1) { - if (vpFormat == 'ldp_vp') { - pathNested['path'] = r'$.verifiableCredential'; - } else if (vpFormat == 'vc+sd-jwt') { - pathNested['path'] = r'$'; - } else { - pathNested['path'] = r'$.vp.verifiableCredential[0]'; - } + final Map descriptor = { + 'id': inputDescriptor.id, + 'format': vpFormat, + 'path': r'$', + }; - inputDescriptors.add({ - 'id': inputDescriptor.id, - 'format': vpFormat, - 'path': r'$', - 'path_nested': pathNested, - }); - } else { - if (vpFormat == 'ldp_vp') { - pathNested['path'] = - // ignore: prefer_interpolation_to_compose_strings - r'$.verifiableCredential[' + i.toString() + ']'; - } else if (vpFormat == 'vc+sd-jwt') { - pathNested['path'] = r'$'; + if (pathNested != null) { + if (credentialsToBePresented.length == 1) { + if (vpFormat == 'ldp_vp') { + pathNested['path'] = r'$.verifiableCredential'; + } else if (vpFormat == 'vc+sd-jwt') { + pathNested['path'] = r'$'; + } else { + pathNested['path'] = r'$.vp.verifiableCredential[0]'; + } } else { - pathNested['path'] = - // ignore: prefer_interpolation_to_compose_strings - r'$.vp.verifiableCredential[' + i.toString() + ']'; + if (vpFormat == 'ldp_vp') { + pathNested['path'] = + // ignore: prefer_interpolation_to_compose_strings + r'$.verifiableCredential[' + i.toString() + ']'; + } else if (vpFormat == 'vc+sd-jwt') { + pathNested['path'] = r'$'; + } else { + pathNested['path'] = + // ignore: prefer_interpolation_to_compose_strings + r'$.vp.verifiableCredential[' + i.toString() + ']'; + } } + } - inputDescriptors.add({ - 'id': inputDescriptor.id, - 'format': vpFormat, - 'path': r'$', - 'path_nested': pathNested, - }); + if (pathNested != null) { + descriptor['path_nested'] = pathNested; } + + inputDescriptors.add(descriptor); } } }