From b32c634ea9ef6c7f7743435b9fcc5f49c541e63d Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 10 Apr 2024 18:58:22 +0545 Subject: [PATCH] Solve test 10 issue #2576 --- .../shared/helper_functions/helper_functions.dart | 15 ++++++++++++++- .../qr_code_scan/cubit/qr_code_scan_cubit.dart | 13 +------------ lib/scan/cubit/scan_cubit.dart | 12 ++---------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/lib/app/shared/helper_functions/helper_functions.dart b/lib/app/shared/helper_functions/helper_functions.dart index 6c7beb106..9e22d9cd2 100644 --- a/lib/app/shared/helper_functions/helper_functions.dart +++ b/lib/app/shared/helper_functions/helper_functions.dart @@ -1881,9 +1881,22 @@ Future?> checkX509({ Future?> checkVerifierAttestation({ required String clientId, - required Map payload, required Map header, + required JWTDecode jwtDecode, }) async { + final jwt = header['jwt']; + + if (jwt == null) { + throw ResponseMessage( + data: { + 'error': 'invalid_format', + 'error_description': 'verifier_attestation scheme error', + }, + ); + } + + final payload = jwtDecode.parseJwt(jwt.toString()); + final sub = payload['sub']; final cnf = payload['cnf']; 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 3604fbf98..186e4a808 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 @@ -1101,21 +1101,10 @@ class QRCodeScanCubit extends Cubit { header: header, ); } else if (clientIdScheme == 'verifier_attestation') { - final jwt = header['jwt']; - - if (jwt == null) { - throw ResponseMessage( - data: { - 'error': 'invalid_format', - 'error_description': 'verifier_attestation scheme error', - }, - ); - } - publicKeyJwk = await checkVerifierAttestation( clientId: clientId, - payload: payload, header: header, + jwtDecode: jwtDecode, ); } } diff --git a/lib/scan/cubit/scan_cubit.dart b/lib/scan/cubit/scan_cubit.dart index cacd7c70a..35e1c3966 100644 --- a/lib/scan/cubit/scan_cubit.dart +++ b/lib/scan/cubit/scan_cubit.dart @@ -761,17 +761,9 @@ class ScanCubit extends Cubit { final vcFormatType = profileSetting .selfSovereignIdentityOptions.customOidc4vcProfile.vcFormatType; - if (vcFormat == null) { - if (vcFormatType == VCFormatType.ldpVc) { - vcFormat = 'ldp_vc'; - } else if (vcFormatType == VCFormatType.jwtVc) { - vcFormat = 'jwt_vc'; - } else if (vcFormatType == VCFormatType.jwtVcJson) { - vcFormat = 'jwt_vc_json'; - } - } + vcFormat ??= vcFormatType.value; - if (vcFormat == null && vpFormat == null) { + if (vpFormat == null) { throw ResponseMessage( data: { 'error': 'invalid_request',