diff --git a/lib/dashboard/home/tab_bar/credentials/present/pick/credential_manifest/helpers/apply_submission_requirements.dart b/lib/dashboard/home/tab_bar/credentials/present/pick/credential_manifest/helpers/apply_submission_requirements.dart index 8b7cc690f..e6bfead72 100644 --- a/lib/dashboard/home/tab_bar/credentials/present/pick/credential_manifest/helpers/apply_submission_requirements.dart +++ b/lib/dashboard/home/tab_bar/credentials/present/pick/credential_manifest/helpers/apply_submission_requirements.dart @@ -1,7 +1,8 @@ import 'package:credential_manifest/credential_manifest.dart'; PresentationDefinition applySubmissionRequirements( - PresentationDefinition presentationDefinition) { + PresentationDefinition presentationDefinition, +) { if (presentationDefinition.submissionRequirements != null) { /// https://identity.foundation/presentation-exchange/#presentation-definition-extensions final inputDescriptors = List.of(presentationDefinition.inputDescriptors); 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 645142cf2..8ed719957 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 @@ -586,7 +586,7 @@ class QRCodeScanCubit extends Cubit { } /// contain id_token but may or may not contain vp_token - if (hasIDToken(responseType.toString())) { + if (hasIDToken(responseType)) { final scope = state.uri!.queryParameters['scope']; if (scope == null || scope != 'openid') { throw ResponseMessage( @@ -600,7 +600,7 @@ class QRCodeScanCubit extends Cubit { } /// contain vp_token but may or may not contain id_token - if (hasVPToken(responseType.toString())) { + if (hasVPToken(responseType)) { if (!keys.contains('nonce')) { throw ResponseMessage( data: { @@ -651,7 +651,7 @@ class QRCodeScanCubit extends Cubit { } /// contain vp_token or id_token - if (hasIDTokenOrVPToken(responseType.toString())) { + if (hasIDTokenOrVPToken(responseType)) { if (isSecurityHigh && redirectUri != null && isClientIdUrl && @@ -666,12 +666,12 @@ class QRCodeScanCubit extends Cubit { } log.i('responseType - $responseType'); - if (isIDTokenOnly(responseType.toString())) { + if (isIDTokenOnly(responseType)) { /// verifier side (siopv2) await completeSiopV2Flow(redirectUri: redirectUri!); - } else if (isVPTokenOnly(responseType.toString()) || - isIDTokenAndVPToken(responseType.toString())) { + } else if (isVPTokenOnly(responseType) || + isIDTokenAndVPToken(responseType)) { /// responseType == 'vp_token' => verifier side (oidc4vp) /// /// responseType == 'id_token vp_token' => verifier side (oidc4vp) diff --git a/lib/scan/cubit/scan_cubit.dart b/lib/scan/cubit/scan_cubit.dart index 437eb4e33..4bc30d1da 100644 --- a/lib/scan/cubit/scan_cubit.dart +++ b/lib/scan/cubit/scan_cubit.dart @@ -604,15 +604,28 @@ class ScanCubit extends Cubit { final inputDescriptors = >[]; - final presentLdpVc = presentationDefinition.format?.ldpVc != null; - final presentJwtVc = presentationDefinition.format?.jwtVc != null; + final ldpVc = presentationDefinition.format?.ldpVc != null; + final jwtVc = presentationDefinition.format?.jwtVc != null; - String? format; + String? vcFormat; - if (presentLdpVc) { - format = 'ldp_vc'; - } else if (presentJwtVc) { - format = 'jwt_vc'; + if (ldpVc) { + vcFormat = 'ldp_vc'; + } else if (jwtVc) { + vcFormat = 'jwt_vc'; + } else { + throw Exception(); + } + + final ldpVp = presentationDefinition.format?.ldpVp != null; + final jwtVp = presentationDefinition.format?.jwtVp != null; + + String? vpFormat; + + if (ldpVp) { + vpFormat = 'ldp_vp'; + } else if (jwtVp) { + vpFormat = 'jwt_vp'; } else { throw Exception(); } @@ -636,11 +649,11 @@ class ScanCubit extends Cubit { inputDescriptors.add({ 'id': descriptor.id, - 'format': 'jwt_vp', + 'format': vpFormat, 'path': r'$', 'path_nested': { 'id': descriptor.id, - 'format': format, + 'format': vcFormat, 'path': r'$.verifiableCredential', }, }); @@ -664,11 +677,11 @@ class ScanCubit extends Cubit { inputDescriptors.add({ 'id': descriptor.id, - 'format': 'jwt_vp', + 'format': vpFormat, 'path': r'$', 'path_nested': { 'id': descriptor.id, - 'format': format, + 'format': vcFormat, // ignore: prefer_interpolation_to_compose_strings 'path': r'$.verifiableCredential[' + i.toString() + ']', },