diff --git a/lib/app/shared/helper_functions/helper_functions.dart b/lib/app/shared/helper_functions/helper_functions.dart index c027aa460..98a60a567 100644 --- a/lib/app/shared/helper_functions/helper_functions.dart +++ b/lib/app/shared/helper_functions/helper_functions.dart @@ -1802,7 +1802,7 @@ List getStringCredentialsForToken({ } //(presentLdpVc, presentJwtVc, presentJwtVcJson, presentVcSdJwt) -(bool, bool, bool, bool) getPresentVCDetails({ +List getPresentVCDetails({ required VCFormatType vcFormatType, required PresentationDefinition presentationDefinition, required Map? clientMetaData, @@ -1811,154 +1811,70 @@ List getStringCredentialsForToken({ bool presentLdpVc = false; bool presentJwtVc = false; bool presentJwtVcJson = false; + bool presentJwtVcJsonLd = false; bool presentVcSdJwt = false; - if (vcFormatType == VCFormatType.auto) { - final credential = credentialsToBePresented.firstOrNull; + final supportingFormats = []; - if (credential == null) { - throw ResponseMessage( - data: { - 'error': 'invalid_request', - 'error_description': 'VC format is missing', - }, - ); - } + if (presentationDefinition.format != null) { + final format = presentationDefinition.format; + + /// ldp_vc + presentLdpVc = format?.ldpVc != null || format?.ldpVp != null; - final credentialFormat = credential.getFormat; + /// jwt_vc + presentJwtVc = format?.jwtVc != null || format?.jwtVp != null; - if (credentialFormat == VCFormatType.ldpVc.vcValue) { + /// jwt_vc_json + presentJwtVcJson = format?.jwtVcJson != null || format?.jwtVpJson != null; + + /// vc+sd-jwt + presentVcSdJwt = format?.vcSdJwt != null; + } else { + if (clientMetaData == null) { + /// credential manifest case presentLdpVc = true; - presentJwtVc = false; - presentJwtVcJson = false; - presentVcSdJwt = false; - } else if (credentialFormat == VCFormatType.jwtVc.vcValue) { - presentLdpVc = false; presentJwtVc = true; - presentJwtVcJson = false; - presentVcSdJwt = false; - } else if (credentialFormat == VCFormatType.jwtVcJson.vcValue) { - presentLdpVc = false; - presentJwtVc = false; presentJwtVcJson = true; - presentVcSdJwt = false; - } else if (credentialFormat == VCFormatType.vcSdJWT.vcValue) { - presentLdpVc = false; - presentJwtVc = false; - presentJwtVcJson = false; + presentJwtVcJsonLd = true; presentVcSdJwt = true; - } - } else { - final supportingFormats = []; - - if (presentationDefinition.format != null) { - final format = presentationDefinition.format; + } else { + final vpFormats = clientMetaData['vp_formats'] as Map; /// ldp_vc - presentLdpVc = format?.ldpVc != null || format?.ldpVp != null; + presentLdpVc = vpFormats.containsKey('ldp_vc'); /// jwt_vc - presentJwtVc = format?.jwtVc != null || format?.jwtVp != null; + presentJwtVc = vpFormats.containsKey('jwt_vc'); /// jwt_vc_json - presentJwtVcJson = format?.jwtVcJson != null || format?.jwtVpJson != null; - - /// vc+sd-jwt - presentVcSdJwt = format?.vcSdJwt != null; - } else { - if (clientMetaData == null) { - /// credential manifest case - if (vcFormatType == VCFormatType.ldpVc) { - presentLdpVc = true; - } else if (vcFormatType == VCFormatType.jwtVc) { - presentJwtVc = true; - } else if (vcFormatType == VCFormatType.jwtVcJson) { - presentJwtVcJson = true; - } else if (vcFormatType == VCFormatType.vcSdJWT) { - presentVcSdJwt = true; - } - } else { - final vpFormats = clientMetaData['vp_formats'] as Map; - - /// ldp_vc - presentLdpVc = vpFormats.containsKey('ldp_vc'); - - /// jwt_vc - presentJwtVc = vpFormats.containsKey('jwt_vc'); - - /// jwt_vc_json - presentJwtVcJson = vpFormats.containsKey('jwt_vc_json'); - - /// vc+sd-jwt - presentVcSdJwt = vpFormats.containsKey('vc+sd-jwt'); - } - if (!presentLdpVc && vcFormatType == VCFormatType.ldpVc) { - presentLdpVc = true; - } else if (!presentJwtVc && vcFormatType == VCFormatType.jwtVc) { - presentJwtVc = true; - } else if (!presentJwtVcJson && vcFormatType == VCFormatType.jwtVcJson) { - presentJwtVcJson = true; - } else if (!presentVcSdJwt && vcFormatType == VCFormatType.vcSdJWT) { - presentVcSdJwt = true; - } - } + presentJwtVcJson = vpFormats.containsKey('jwt_vc_json'); - if (!presentLdpVc && - !presentJwtVc && - !presentJwtVcJson && - !presentVcSdJwt) { - throw ResponseMessage( - data: { - 'error': 'invalid_request', - 'error_description': 'VC format is missing', - }, - ); - } - - /// create list of supported formats - if (presentLdpVc) supportingFormats.add(VCFormatType.ldpVc.vcValue); - if (presentJwtVc) supportingFormats.add(VCFormatType.jwtVc.vcValue); - if (presentJwtVcJson) supportingFormats.add(VCFormatType.jwtVcJson.vcValue); - if (presentVcSdJwt) supportingFormats.add(VCFormatType.vcSdJWT.vcValue); + /// jwt_vc_json-ld + presentJwtVcJson = vpFormats.containsKey('jwt_vc_json-ld'); - /// make sure only one of all are true - if (presentLdpVc && vcFormatType == VCFormatType.ldpVc) { - presentLdpVc = true; - presentJwtVc = false; - presentJwtVcJson = false; - presentVcSdJwt = false; - } else if (presentJwtVc && vcFormatType == VCFormatType.jwtVc) { - presentLdpVc = false; - presentJwtVc = true; - presentJwtVcJson = false; - presentVcSdJwt = false; - } else if (presentJwtVcJson && vcFormatType == VCFormatType.jwtVcJson) { - presentLdpVc = false; - presentJwtVc = false; - presentJwtVcJson = true; - presentVcSdJwt = false; - } else if (presentVcSdJwt && vcFormatType == VCFormatType.vcSdJWT) { - presentLdpVc = false; - presentJwtVc = false; - presentJwtVcJson = false; - presentVcSdJwt = true; + /// vc+sd-jwt + presentVcSdJwt = vpFormats.containsKey('vc+sd-jwt'); } + } - if ((presentLdpVc && vcFormatType != VCFormatType.ldpVc) || - (presentJwtVc && vcFormatType != VCFormatType.jwtVc) || - presentJwtVcJson && vcFormatType != VCFormatType.jwtVcJson || - presentVcSdJwt && vcFormatType != VCFormatType.vcSdJWT) { - throw ResponseMessage( - data: { - 'error': 'invalid_request', - 'error_description': 'Please switch to profile that supports format ' - '${supportingFormats.join('/')}.', - }, - ); - } + if (!presentLdpVc && !presentJwtVc && !presentJwtVcJson && !presentVcSdJwt) { + throw ResponseMessage( + data: { + 'error': 'invalid_request', + 'error_description': 'VC format is missing', + }, + ); } - return (presentLdpVc, presentJwtVc, presentJwtVcJson, presentVcSdJwt); + /// create list of supported formats + if (presentLdpVc) supportingFormats.add(VCFormatType.ldpVc); + if (presentJwtVc) supportingFormats.add(VCFormatType.jwtVc); + if (presentJwtVcJson) supportingFormats.add(VCFormatType.jwtVcJson); + if (presentJwtVcJsonLd) supportingFormats.add(VCFormatType.jwtVcJsonLd); + if (presentVcSdJwt) supportingFormats.add(VCFormatType.vcSdJWT); + + return supportingFormats; } List collectSdValues(Map data) { diff --git a/lib/app/shared/message_handler/response_message.dart b/lib/app/shared/message_handler/response_message.dart index 25cb0243f..fe07063d8 100644 --- a/lib/app/shared/message_handler/response_message.dart +++ b/lib/app/shared/message_handler/response_message.dart @@ -786,6 +786,7 @@ class ResponseMessage with MessageHandler { case ResponseString .RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription: return ResponseString + // ignore: lines_longer_than_80_chars .RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription .localise( context, diff --git a/lib/dashboard/home/tab_bar/credentials/detail/widgets/credential_subject_data.dart b/lib/dashboard/home/tab_bar/credentials/detail/widgets/credential_subject_data.dart index 914ba8d20..bbb1ed1a7 100644 --- a/lib/dashboard/home/tab_bar/credentials/detail/widgets/credential_subject_data.dart +++ b/lib/dashboard/home/tab_bar/credentials/detail/widgets/credential_subject_data.dart @@ -134,56 +134,130 @@ class DisplayCredentialField extends StatelessWidget { @override Widget build(BuildContext context) { - late Widget widget; + Widget? widget; try { final json = jsonDecode(data.toString()); if (json is Map) { - widget = Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - title ?? '', - style: Theme.of(context).textTheme.bodyMedium!.copyWith( - color: Theme.of(context).colorScheme.onSurface, - fontWeight: FontWeight.bold, - ), - ), - Padding( - padding: const EdgeInsets.only(left: 8), - child: DisplayCredentialFieldMap( - showVertically: showVertically, - data: data, - type: type, - ), - ), - ], + widget = IndentedCredentialFields( + title: title, + children: DisplayCredentialFieldMap( + showVertically: showVertically, + data: json, + type: type, + ), + ); + } + + if (json is List) { + widget = IndentedCredentialFields( + title: title, + children: DisplayCredentialFieldList( + showVertically: showVertically, + data: json, + type: type, + ), ); } } catch (e) { - widget = CredentialField( - padding: const EdgeInsets.only(top: 10), - title: title, - value: data.toString(), - titleColor: Theme.of(context).colorScheme.onSurface, - valueColor: Theme.of(context).colorScheme.onSurface, - showVertically: showVertically, - type: type, + /// Empty catch because data is not a valid json and + /// the return of the function will take care of + /// this usecase (widget is null) + } + + return widget ?? + CredentialField( + padding: const EdgeInsets.only(top: 10), + title: title, + value: data.toString(), + titleColor: Theme.of(context).colorScheme.onSurface, + valueColor: Theme.of(context).colorScheme.onSurface, + showVertically: showVertically, + type: type, + ); + } + + List DisplayCredentialFieldMap({ + required bool showVertically, + required Map data, + required String type, + }) { + final List column = []; + + /// for each element in Map data, call DisplayCredentialField + for (final element in data.entries) { + column.add( + DisplayCredentialField( + title: element.key, + data: element.value is String + ? element.value + : jsonEncode(element.value), + type: type, + showVertically: showVertically, + ), ); } - return CredentialField( - padding: const EdgeInsets.only(top: 10), - title: title, - value: data.toString(), - titleColor: Theme.of(context).colorScheme.onSurface, - valueColor: Theme.of(context).colorScheme.onSurface, - showVertically: showVertically, - type: type, - ); + return column; + } + + List DisplayCredentialFieldList({ + required bool showVertically, + required List data, + required String type, + }) { + final List column = []; + + /// for each element in Map data, call DisplayCredentialField + for (final element in data) { + column.add( + DisplayCredentialField( + title: null, + data: element is String ? element : jsonEncode(element), + type: type, + showVertically: showVertically, + ), + ); + } + + return column; } +} + +class IndentedCredentialFields extends StatelessWidget { + const IndentedCredentialFields({ + super.key, + required this.children, + this.title, + }); - Widget DisplayCredentialFieldMap( - {required bool showVertically, required data, required String type}) { - return Text('DisplayCredentialFieldMap'); + final List children; + final String? title; + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (title != null) + Padding( + padding: const EdgeInsets.only(top: 10), + child: Text( + title!, + style: Theme.of(context).textTheme.bodyMedium!.copyWith( + color: Theme.of(context).colorScheme.onSurface, + fontWeight: FontWeight.bold, + ), + ), + ) + else + const SizedBox.shrink(), + Padding( + padding: const EdgeInsets.only(left: 8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: children, + ), + ), + ], + ); } } diff --git a/lib/dashboard/home/tab_bar/credentials/present/pick/credential_manifest/helpers/filter_credential_list_by_format.dart b/lib/dashboard/home/tab_bar/credentials/present/pick/credential_manifest/helpers/filter_credential_list_by_format.dart index c9c891da8..afad99e4f 100644 --- a/lib/dashboard/home/tab_bar/credentials/present/pick/credential_manifest/helpers/filter_credential_list_by_format.dart +++ b/lib/dashboard/home/tab_bar/credentials/present/pick/credential_manifest/helpers/filter_credential_list_by_format.dart @@ -10,51 +10,24 @@ List filterCredenialListByFormat({ required PresentationDefinition presentationDefinition, required List filterList, }) { - if (vcFormatType == VCFormatType.auto) { - return credentialList; - } - final credentials = List.from(credentialList); if (filterList.isNotEmpty) { - final isJwtVpInJwtVCRequired = presentationDefinition.format?.jwtVp != null; - - if (isJwtVpInJwtVCRequired) { - credentials.removeWhere( - (CredentialModel credentialModel) => credentialModel.jwt == null, - ); - } - - final (presentLdpVc, presentJwtVc, presentJwtVcJson, presentVcSdJwt) = - getPresentVCDetails( + final supportingFormats = getPresentVCDetails( clientMetaData: clientMetaData, presentationDefinition: presentationDefinition, vcFormatType: vcFormatType, credentialsToBePresented: credentials, ); - credentials.removeWhere( (CredentialModel credentialModel) { - /// remove ldpVc - if (presentLdpVc) { - return credentialModel.getFormat != VCFormatType.ldpVc.vcValue; - } - - /// remove jwtVc - if (presentJwtVc) { - return credentialModel.getFormat != VCFormatType.jwtVc.vcValue; - } - - /// remove JwtVcJson - if (presentJwtVcJson) { - return credentialModel.getFormat != VCFormatType.jwtVcJson.vcValue; + /// we keep credential whose format are supported + bool remove = true; + for (final supportingFormat in supportingFormats) { + if (credentialModel.getFormat == supportingFormat.vcValue) { + remove = false; + } } - - /// remove vcSdJwt - if (presentVcSdJwt) { - return credentialModel.getFormat != VCFormatType.vcSdJWT.vcValue; - } - - return false; + return remove; }, ); } diff --git a/lib/scan/cubit/scan_cubit.dart b/lib/scan/cubit/scan_cubit.dart index ec1c6e509..aa8dc46fa 100644 --- a/lib/scan/cubit/scan_cubit.dart +++ b/lib/scan/cubit/scan_cubit.dart @@ -524,7 +524,18 @@ class ScanCubit extends Cubit { if (presentationDefinition.format == null) { clientMetaData = await getClientMetada(client: client, uri: uri); } + // final String vpFormat = getVpFormat( + // presentationDefinition: presentationDefinition, + // clientMetaData: clientMetaData, + // ); + final (presentationSubmission, formatFromPresentationSubmission) = + await getPresentationSubmission( + credentialsToBePresented: credentialsToBePresented, + presentationDefinition: presentationDefinition, + clientMetaData: clientMetaData, + profileSetting: qrCodeScanCubit.profileCubit.state.model.profileSetting, + ); final String vpToken = await createVpToken( credentialsToBePresented: credentialsToBePresented, did: did, @@ -535,13 +546,7 @@ class ScanCubit extends Cubit { uri: uri, clientMetaData: clientMetaData, profileSetting: qrCodeScanCubit.profileCubit.state.model.profileSetting, - ); - - final presentationSubmission = await getPresentationSubmission( - credentialsToBePresented: credentialsToBePresented, - presentationDefinition: presentationDefinition, - clientMetaData: clientMetaData, - profileSetting: qrCodeScanCubit.profileCubit.state.model.profileSetting, + formatFromPresentationSubmission: formatFromPresentationSubmission, ); Map body; @@ -701,7 +706,7 @@ class ScanCubit extends Cubit { } } - Future> getPresentationSubmission({ + Future<(Map, VCFormatType)> getPresentationSubmission({ required List credentialsToBePresented, required PresentationDefinition presentationDefinition, required Map? clientMetaData, @@ -714,70 +719,11 @@ class ScanCubit extends Cubit { 'definition_id': presentationDefinition.id, }; - final vcFormatType = profileSetting - .selfSovereignIdentityOptions.customOidc4vcProfile.vcFormatType; + // final vcFormatType = profileSetting + // .selfSovereignIdentityOptions.customOidc4vcProfile.vcFormatType; final inputDescriptors = >[]; - - String? vcFormat; - String? vpFormat; - - if (presentationDefinition.format != null) { - final ldpVc = presentationDefinition.format?.ldpVc != null; - final jwtVc = presentationDefinition.format?.jwtVc != null; - final jwtVcJson = presentationDefinition.format?.jwtVcJson != null; - - if (ldpVc) { - vcFormat = 'ldp_vc'; - } else if (jwtVc) { - vcFormat = 'jwt_vc'; - } else if (jwtVcJson) { - vcFormat = 'jwt_vc_json'; - } - - final ldpVp = presentationDefinition.format?.ldpVp != null; - final jwtVp = presentationDefinition.format?.jwtVp != null; - final jwtVpJson = presentationDefinition.format?.jwtVpJson != null; - final vcSdJwt = presentationDefinition.format?.vcSdJwt != null; - - if (ldpVp) { - vpFormat = 'ldp_vp'; - } else if (jwtVp) { - vpFormat = 'jwt_vp'; - } else if (jwtVpJson) { - vpFormat = 'jwt_vp_json'; - } else if (vcSdJwt) { - vpFormat = 'vc+sd-jwt'; - vcFormat = 'vc+sd-jwt'; - } - } else { - if (clientMetaData == null) { - vcFormat = vcFormatType.vcValue; - vpFormat = vcFormatType.vpValue; - } else { - final vpFormats = clientMetaData['vp_formats'] as Map; - - if (vpFormats.containsKey('ldp_vc')) { - vcFormat = 'ldp_vc'; - } else if (vpFormats.containsKey('jwt_vc')) { - vcFormat = 'jwt_vc'; - } else if (vpFormats.containsKey('jwt_vc_json')) { - vcFormat = 'jwt_vc_json'; - } - - if (vpFormats.containsKey('ldp_vp')) { - vpFormat = 'ldp_vp'; - } else if (vpFormats.containsKey('jwt_vp')) { - vpFormat = 'jwt_vp'; - } else if (vpFormats.containsKey('jwt_vp_json')) { - vpFormat = 'jwt_vp_json'; - } else if (vpFormats.containsKey('vc+sd-jwt')) { - vpFormat = 'vc+sd-jwt'; - vcFormat = 'vc+sd-jwt'; - } - } - } - + VCFormatType formatFromPresentationSubmission = VCFormatType.vcSdJWT; for (int i = 0; i < credentialsToBePresented.length; i++) { for (final InputDescriptor inputDescriptor in presentationDefinition.inputDescriptors) { @@ -787,38 +733,35 @@ class ScanCubit extends Cubit { filterList: filterList, credentialList: [credentialsToBePresented[i]], ); - + final format = getVcFormatType(credential[0].getFormat); Map? pathNested; - if (vcFormatType != VCFormatType.vcSdJWT) { - pathNested = { - 'id': inputDescriptor.id, - 'format': vcFormat, - }; - } - if (credential.isNotEmpty) { final Map descriptor = { 'id': inputDescriptor.id, - 'format': vpFormat, + 'format': format.vpValue, 'path': r'$', }; - if (vcFormatType != VCFormatType.vcSdJWT && pathNested != null) { + if (format != VCFormatType.vcSdJWT) { + pathNested = { + 'id': inputDescriptor.id, + 'format': format.vpValue, + }; if (credentialsToBePresented.length == 1) { - if (vpFormat == 'ldp_vp') { + if (format == VCFormatType.ldpVc) { pathNested['path'] = r'$.verifiableCredential'; - } else if (vpFormat == 'vc+sd-jwt') { + } else if (format == VCFormatType.vcSdJWT) { pathNested['path'] = r'$'; } else { pathNested['path'] = r'$.vp.verifiableCredential[0]'; } } else { - if (vpFormat == 'ldp_vp') { + if (format == VCFormatType.ldpVc) { pathNested['path'] = // ignore: prefer_interpolation_to_compose_strings r'$.verifiableCredential[' + i.toString() + ']'; - } else if (vpFormat == 'vc+sd-jwt') { + } else if (format == VCFormatType.vcSdJWT) { pathNested['path'] = r'$'; } else { pathNested['path'] = @@ -826,18 +769,19 @@ class ScanCubit extends Cubit { r'$.vp.verifiableCredential[' + i.toString() + ']'; } } - pathNested['format'] = vcFormat ?? vcFormatType.vcValue; + pathNested['format'] = format.vcValue; descriptor['path_nested'] = pathNested; } inputDescriptors.add(descriptor); + formatFromPresentationSubmission = format; } } } presentationSubmission['descriptor_map'] = inputDescriptors; - return presentationSubmission; + return (presentationSubmission, formatFromPresentationSubmission); } Future askPermissionDIDAuthCHAPI({ @@ -868,6 +812,7 @@ class ScanCubit extends Cubit { required Uri uri, required Map? clientMetaData, required ProfileSetting profileSetting, + VCFormatType? formatFromPresentationSubmission, }) async { final nonce = uri.queryParameters['nonce'] ?? ''; final clientId = uri.queryParameters['client_id'] ?? ''; @@ -877,15 +822,48 @@ class ScanCubit extends Cubit { final vcFormatType = customOidc4vcProfile.vcFormatType; - final (presentLdpVc, presentJwtVc, presentJwtVcJson, presentVcSdJwt) = - getPresentVCDetails( + final supportingFormats = getPresentVCDetails( clientMetaData: clientMetaData, presentationDefinition: presentationDefinition, vcFormatType: vcFormatType, credentialsToBePresented: credentialsToBePresented, ); - if (presentLdpVc) { + // if (supportingFormats.contains(VCFormatType.vcSdJWT)) { + if (formatFromPresentationSubmission == VCFormatType.vcSdJWT) { + final credentialList = getStringCredentialsForToken( + credentialsToBePresented: credentialsToBePresented, + profileCubit: profileCubit, + ); + + final vpToken = credentialList.first; + // considering only one + + return vpToken; + // } else if (supportingFormats.contains(VCFormatType.jwtVc) || + // supportingFormats.contains(VCFormatType.jwtVcJson) || + // supportingFormats.contains(VCFormatType.jwtVcJsonLd)) { + } else if (formatFromPresentationSubmission == VCFormatType.jwtVc || + formatFromPresentationSubmission == VCFormatType.jwtVcJson || + formatFromPresentationSubmission == VCFormatType.jwtVcJsonLd) { + final credentialList = getStringCredentialsForToken( + credentialsToBePresented: credentialsToBePresented, + profileCubit: profileCubit, + ); + + final vpToken = await oidc4vc.extractVpToken( + clientId: clientId, + credentialsToBePresented: credentialList, + did: did, + kid: kid, + privateKey: privateKey, + nonce: nonce, + proofHeaderType: customOidc4vcProfile.proofHeader, + ); + + return vpToken; + // } else if (supportingFormats.contains(VCFormatType.ldpVc)) { + } else if (formatFromPresentationSubmission == VCFormatType.ldpVc) { /// proof is done with a creation date 20 seconds in the past to avoid /// proof check to fail because of time difference on server final options = jsonEncode({ @@ -913,33 +891,6 @@ class ScanCubit extends Cubit { options, privateKey, ); - return vpToken; - } else if (presentJwtVc || presentJwtVcJson) { - final credentialList = getStringCredentialsForToken( - credentialsToBePresented: credentialsToBePresented, - profileCubit: profileCubit, - ); - - final vpToken = await oidc4vc.extractVpToken( - clientId: clientId, - credentialsToBePresented: credentialList, - did: did, - kid: kid, - privateKey: privateKey, - nonce: nonce, - proofHeaderType: customOidc4vcProfile.proofHeader, - ); - - return vpToken; - } else if (presentVcSdJwt) { - final credentialList = getStringCredentialsForToken( - credentialsToBePresented: credentialsToBePresented, - profileCubit: profileCubit, - ); - - final vpToken = credentialList.first; - // considering only one - return vpToken; } else { throw ResponseMessage( @@ -1023,4 +974,11 @@ class ScanCubit extends Cubit { ); } } + + String getVpFormat({ + required PresentationDefinition presentationDefinition, + Map? clientMetaData, + }) { + return 'vc+sd-jwt'; + } } diff --git a/packages/oidc4vc/lib/src/vc_format_type.dart b/packages/oidc4vc/lib/src/vc_format_type.dart index 210ea3fc3..f9675b18f 100644 --- a/packages/oidc4vc/lib/src/vc_format_type.dart +++ b/packages/oidc4vc/lib/src/vc_format_type.dart @@ -80,3 +80,12 @@ extension VCFormatTypeX on VCFormatType { } } } + +VCFormatType getVcFormatType(String formatString) { + for (final element in VCFormatType.values) { + if (element.vcValue == formatString) { + return element; + } + } + throw Exception('Invalid VCFormatType'); +}