From d4069d0e9e639861ee8438e98aff1ff58551c9b7 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Fri, 1 Nov 2024 14:53:50 +0545 Subject: [PATCH] feat: Support multiple formats with different vcs in discover #3046 --- .../credential_subject_type_extension.dart | 39 +- .../shared/models/cred_info/cred_info.dart | 12 + lib/app/shared/models/model.dart | 1 + lib/credentials/cubit/credentials_cubit.dart | 395 +++++++++++------- .../view/oid4c4vc_credential_pick_page.dart | 9 +- .../widgets/credential_display.dart | 6 +- .../cubit/missing_credentials_cubit.dart | 16 +- lib/dashboard/profile/models/profile.dart | 3 +- .../profile/models/profile_setting.dart | 53 ++- 9 files changed, 340 insertions(+), 194 deletions(-) create mode 100644 lib/app/shared/models/cred_info/cred_info.dart diff --git a/lib/app/shared/enum/type/credential_subject_type/credential_subject_type_extension.dart b/lib/app/shared/enum/type/credential_subject_type/credential_subject_type_extension.dart index bc4c83e91..9e4107f7c 100644 --- a/lib/app/shared/enum/type/credential_subject_type/credential_subject_type_extension.dart +++ b/lib/app/shared/enum/type/credential_subject_type/credential_subject_type_extension.dart @@ -668,13 +668,22 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType { case CredentialSubjectType.over21: case CredentialSubjectType.over50: case CredentialSubjectType.over65: - case CredentialSubjectType.gender: case CredentialSubjectType.ageRange: - case CredentialSubjectType.defiCompliance: - case CredentialSubjectType.tezotopiaMembership: + case CredentialSubjectType.gender: case CredentialSubjectType.chainbornMembership: + case CredentialSubjectType.tezotopiaMembership: + case CredentialSubjectType.defiCompliance: return [VCFormatType.ldpVc, VCFormatType.auto]; + case CredentialSubjectType.over18: + case CredentialSubjectType.livenessCard: + case CredentialSubjectType.phonePass: + return [ + VCFormatType.ldpVc, + VCFormatType.jwtVcJson, + VCFormatType.auto, + ]; + case CredentialSubjectType.verifiableIdCard: return [ VCFormatType.ldpVc, @@ -684,14 +693,6 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType { VCFormatType.auto, ]; - case CredentialSubjectType.identityCredential: - case CredentialSubjectType.eudiPid: - case CredentialSubjectType.pid: - return [VCFormatType.vcSdJWT, VCFormatType.auto]; - - case CredentialSubjectType.over18: - case CredentialSubjectType.phonePass: - case CredentialSubjectType.livenessCard: case CredentialSubjectType.emailPass: return [ VCFormatType.ldpVc, @@ -700,6 +701,12 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType { VCFormatType.vcSdJWT, ]; + /// Exceptions + case CredentialSubjectType.identityCredential: + case CredentialSubjectType.eudiPid: + case CredentialSubjectType.pid: + return [VCFormatType.vcSdJWT, VCFormatType.auto]; + case CredentialSubjectType.nationality: case CredentialSubjectType.identityPass: case CredentialSubjectType.passportFootprint: @@ -740,7 +747,10 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType { } } - DiscoverDummyCredential dummyCredential(ProfileSetting profileSetting) { + DiscoverDummyCredential dummyCredential({ + required ProfileSetting profileSetting, + required VCFormatType assignedVCFormatType, + }) { String? image; String? link; String? websiteLink; @@ -760,7 +770,10 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType { var format = VCFormatType.ldpVc.urlValue; if (vcFormatType == VCFormatType.auto && discoverCardsOptions != null) { - format = discoverCardsOptions.vcFormatTypeForAuto(this); + format = discoverCardsOptions.vcFormatTypeForAuto( + credentialSubjectType: this, + vcFormatType: assignedVCFormatType, + ); } else { format = vcFormatType.urlValue; } diff --git a/lib/app/shared/models/cred_info/cred_info.dart b/lib/app/shared/models/cred_info/cred_info.dart new file mode 100644 index 000000000..04cc0d516 --- /dev/null +++ b/lib/app/shared/models/cred_info/cred_info.dart @@ -0,0 +1,12 @@ +import 'package:altme/app/app.dart'; +import 'package:oidc4vc/oidc4vc.dart'; + +class CredInfo { + CredInfo({ + required this.credentialType, + required this.formatType, + }); + + final CredentialSubjectType credentialType; + final VCFormatType formatType; +} diff --git a/lib/app/shared/models/model.dart b/lib/app/shared/models/model.dart index 5b30d0971..3a26d9a5d 100644 --- a/lib/app/shared/models/model.dart +++ b/lib/app/shared/models/model.dart @@ -5,6 +5,7 @@ export 'blockchain_network/etherlink_network.dart'; export 'blockchain_network/fantom_network.dart'; export 'blockchain_network/polygon_network.dart'; export 'blockchain_network/tezos_network.dart'; +export 'cred_info/cred_info.dart'; export 'state_message/state_message.dart'; export 'translation/translation.dart'; export 'xtz_data/xtz_data.dart'; diff --git a/lib/credentials/cubit/credentials_cubit.dart b/lib/credentials/cubit/credentials_cubit.dart index 83ea2cc16..f3a0ed2dc 100644 --- a/lib/credentials/cubit/credentials_cubit.dart +++ b/lib/credentials/cubit/credentials_cubit.dart @@ -688,144 +688,198 @@ class CredentialsCubit extends Cubit { final vcFormatType = profileSetting .selfSovereignIdentityOptions.customOidc4vcProfile.vcFormatType; - final isDiipv2point1hProfile = - profileModel.profileType == ProfileType.diipv2point1; - final isDiipv3Profile = profileModel.profileType == ProfileType.diipv3; - final discoverCardsOptions = profileSetting.discoverCardsOptions; // entreprise user may have a list of external issuer final externalIssuers = profileSetting.discoverCardsOptions?.displayExternalIssuer; for (final CredentialCategory category in getCredentialCategorySorted) { - final allSubjectTypeForCategory = []; + final allCategoryVC = []; - /// tezVoucher is available only on Android platform - if (isIOS) { - allSubjectTypeForCategory.remove(CredentialSubjectType.tezVoucher); - } + // /// tezVoucher is available only on Android platform + // if (isIOS) { + // allCategoryVC.remove(CredentialSubjectType.tezVoucher); + // } // remove cards in discover based on profile if (discoverCardsOptions != null) { // add cards in discover based on profile + + final ldpVcType = vcFormatType == VCFormatType.ldpVc || + vcFormatType == VCFormatType.auto; + final jwtVcJsonType = vcFormatType == VCFormatType.jwtVcJson || + vcFormatType == VCFormatType.auto; + final jwtVcType = vcFormatType == VCFormatType.jwtVc || + vcFormatType == VCFormatType.auto; + final vcSdJWType = vcFormatType == VCFormatType.vcSdJWT || + vcFormatType == VCFormatType.auto; + switch (category) { case CredentialCategory.identityCards: - if (discoverCardsOptions.displayOver13 && - !allSubjectTypeForCategory - .contains(CredentialSubjectType.over13)) { - allSubjectTypeForCategory.add(CredentialSubjectType.over13); + + /// over 13 + if (ldpVcType && discoverCardsOptions.displayOver13) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.over13, + formatType: VCFormatType.ldpVc, + ), + ); } - if (discoverCardsOptions.displayOver15 && - !allSubjectTypeForCategory - .contains(CredentialSubjectType.over15)) { - allSubjectTypeForCategory.add(CredentialSubjectType.over15); + /// Over 15 + if (ldpVcType && discoverCardsOptions.displayOver15) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.over15, + formatType: VCFormatType.ldpVc, + ), + ); } - if (!allSubjectTypeForCategory - .contains(CredentialSubjectType.over18)) { - final displayOver18 = (vcFormatType == VCFormatType.ldpVc || - vcFormatType == VCFormatType.auto) && - discoverCardsOptions.displayOver18; - final displayOver18Jwt = - (vcFormatType == VCFormatType.jwtVcJson || - vcFormatType == VCFormatType.auto) && - discoverCardsOptions.displayOver18Jwt; - - if (isDiipv2point1hProfile || displayOver18 || displayOver18Jwt) { - allSubjectTypeForCategory.add(CredentialSubjectType.over18); - } + /// Over 18 + if (ldpVcType && discoverCardsOptions.displayOver18) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.over18, + formatType: VCFormatType.ldpVc, + ), + ); + } + if (jwtVcJsonType && discoverCardsOptions.displayOver18Jwt) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.over18, + formatType: VCFormatType.jwtVcJson, + ), + ); } - if (discoverCardsOptions.displayOver21 && - !allSubjectTypeForCategory - .contains(CredentialSubjectType.over21)) { - allSubjectTypeForCategory.add(CredentialSubjectType.over21); + /// Over 21 + if (ldpVcType && discoverCardsOptions.displayOver21) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.over21, + formatType: VCFormatType.ldpVc, + ), + ); } - if (discoverCardsOptions.displayOver50 && - !allSubjectTypeForCategory - .contains(CredentialSubjectType.over50)) { - allSubjectTypeForCategory.add(CredentialSubjectType.over50); + + /// Over 50 + if (ldpVcType && discoverCardsOptions.displayOver50) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.over50, + formatType: VCFormatType.ldpVc, + ), + ); } - if (discoverCardsOptions.displayOver65 && - !allSubjectTypeForCategory - .contains(CredentialSubjectType.over65)) { - allSubjectTypeForCategory.add(CredentialSubjectType.over65); + + /// Over 65 + if (ldpVcType && discoverCardsOptions.displayOver65) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.over65, + formatType: VCFormatType.ldpVc, + ), + ); } - if (!allSubjectTypeForCategory - .contains(CredentialSubjectType.verifiableIdCard)) { - final displayVerifiableId = (vcFormatType == VCFormatType.ldpVc || - vcFormatType == VCFormatType.auto) && - discoverCardsOptions.displayVerifiableId; - final displayVerifiableIdJwt = - (vcFormatType == VCFormatType.jwtVc || - vcFormatType == VCFormatType.jwtVcJson || - vcFormatType == VCFormatType.auto) && - discoverCardsOptions.displayVerifiableIdJwt; - final displayVerifiableIdSdJwt = - (vcFormatType == VCFormatType.vcSdJWT || - vcFormatType == VCFormatType.auto) && - discoverCardsOptions.displayVerifiableIdSdJwt; - - if (displayVerifiableId || - displayVerifiableIdJwt || - displayVerifiableIdSdJwt) { - allSubjectTypeForCategory - .add(CredentialSubjectType.verifiableIdCard); - } + /// verifiableIdCard + if (ldpVcType && discoverCardsOptions.displayVerifiableId) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.verifiableIdCard, + formatType: VCFormatType.ldpVc, + ), + ); + } + if (jwtVcType && discoverCardsOptions.displayVerifiableIdJwt) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.verifiableIdCard, + formatType: VCFormatType.jwtVc, + ), + ); + } + if (jwtVcJsonType && discoverCardsOptions.displayVerifiableIdJwt) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.verifiableIdCard, + formatType: VCFormatType.jwtVcJson, + ), + ); + } + if (vcSdJWType && discoverCardsOptions.displayVerifiableIdSdJwt) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.verifiableIdCard, + formatType: VCFormatType.vcSdJWT, + ), + ); } - if (discoverCardsOptions.displayAgeRange && - !allSubjectTypeForCategory - .contains(CredentialSubjectType.ageRange)) { - allSubjectTypeForCategory.add(CredentialSubjectType.ageRange); + /// age range + if (ldpVcType && discoverCardsOptions.displayAgeRange) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.ageRange, + formatType: VCFormatType.ldpVc, + ), + ); } - if (discoverCardsOptions.displayHumanity && - !allSubjectTypeForCategory - .contains(CredentialSubjectType.livenessCard)) { - allSubjectTypeForCategory.add(CredentialSubjectType.livenessCard); + /// livenessCard + if (ldpVcType && discoverCardsOptions.displayHumanity) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.livenessCard, + formatType: VCFormatType.ldpVc, + ), + ); } - if (!allSubjectTypeForCategory - .contains(CredentialSubjectType.livenessCard)) { - final displayHumanity = (vcFormatType == VCFormatType.ldpVc || - vcFormatType == VCFormatType.auto) && - discoverCardsOptions.displayHumanity; - final displayHumanityJwt = - (vcFormatType == VCFormatType.jwtVcJson || - vcFormatType == VCFormatType.auto) && - discoverCardsOptions.displayHumanityJwt; - - if (displayHumanity || displayHumanityJwt) { - allSubjectTypeForCategory - .add(CredentialSubjectType.livenessCard); - } + if (jwtVcJsonType && discoverCardsOptions.displayHumanityJwt) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.livenessCard, + formatType: VCFormatType.jwtVcJson, + ), + ); } - if (discoverCardsOptions.displayGender && - !allSubjectTypeForCategory - .contains(CredentialSubjectType.gender)) { - allSubjectTypeForCategory.add(CredentialSubjectType.gender); + /// gender + if (ldpVcType && discoverCardsOptions.displayGender) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.gender, + formatType: VCFormatType.ldpVc, + ), + ); } + case CredentialCategory.advantagesCards: + + /// chainbornMembership if (Parameters.showChainbornCard) { - if (discoverCardsOptions.displayChainborn && - !allSubjectTypeForCategory - .contains(CredentialSubjectType.chainbornMembership)) { - allSubjectTypeForCategory.add( - CredentialSubjectType.chainbornMembership, + if (ldpVcType && discoverCardsOptions.displayChainborn) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.chainbornMembership, + formatType: VCFormatType.ldpVc, + ), ); } } + /// tezotopiaMembership if (Parameters.showTezotopiaCard) { - if (discoverCardsOptions.displayTezotopia && - !allSubjectTypeForCategory - .contains(CredentialSubjectType.tezotopiaMembership)) { - allSubjectTypeForCategory.add( - CredentialSubjectType.tezotopiaMembership, + if (ldpVcType && discoverCardsOptions.displayTezotopia) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.tezotopiaMembership, + formatType: VCFormatType.ldpVc, + ), ); } } @@ -834,45 +888,62 @@ class CredentialsCubit extends Cubit { break; case CredentialCategory.contactInfoCredentials: - if (!allSubjectTypeForCategory - .contains(CredentialSubjectType.emailPass)) { - final displayEmailPass = (vcFormatType == VCFormatType.ldpVc || - vcFormatType == VCFormatType.auto) && - discoverCardsOptions.displayEmailPass; - final displayEmailPassJwt = - (vcFormatType == VCFormatType.jwtVcJson || - vcFormatType == VCFormatType.auto) && - discoverCardsOptions.displayEmailPassJwt; - - if (isDiipv3Profile || displayEmailPass || displayEmailPassJwt) { - allSubjectTypeForCategory.add(CredentialSubjectType.emailPass); - } + + /// Email Pass + if (ldpVcType && discoverCardsOptions.displayEmailPass) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.emailPass, + formatType: VCFormatType.ldpVc, + ), + ); + } + if (jwtVcJsonType && discoverCardsOptions.displayEmailPassJwt) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.emailPass, + formatType: VCFormatType.jwtVcJson, + ), + ); + } + if (vcSdJWType && discoverCardsOptions.displayEmailPassSdJwt) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.emailPass, + formatType: VCFormatType.vcSdJWT, + ), + ); } - if (!allSubjectTypeForCategory - .contains(CredentialSubjectType.phonePass)) { - final displayPhonePass = (vcFormatType == VCFormatType.ldpVc || - vcFormatType == VCFormatType.auto) && - discoverCardsOptions.displayPhonePass; - final displayPhonePassJwt = - (vcFormatType == VCFormatType.jwtVcJson || - vcFormatType == VCFormatType.auto) && - discoverCardsOptions.displayPhonePassJwt; - - if (displayPhonePass || displayPhonePassJwt) { - allSubjectTypeForCategory.add(CredentialSubjectType.phonePass); - } + /// Phone Pass + if (ldpVcType && discoverCardsOptions.displayPhonePass) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.phonePass, + formatType: VCFormatType.ldpVc, + ), + ); + } + if (jwtVcJsonType && discoverCardsOptions.displayPhonePassJwt) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.phonePass, + formatType: VCFormatType.jwtVcJson, + ), + ); } case CredentialCategory.educationCards: break; case CredentialCategory.financeCards: if (Parameters.supportDefiCompliance) { - if (discoverCardsOptions.displayDefi && - !allSubjectTypeForCategory - .contains(CredentialSubjectType.defiCompliance)) { - allSubjectTypeForCategory - .add(CredentialSubjectType.defiCompliance); + if (ldpVcType && discoverCardsOptions.displayDefi) { + allCategoryVC.add( + CredInfo( + credentialType: CredentialSubjectType.defiCompliance, + formatType: VCFormatType.ldpVc, + ), + ); } } @@ -884,13 +955,33 @@ class CredentialsCubit extends Cubit { break; case CredentialCategory.blockchainAccountsCards: if (Parameters.walletHandlesCrypto) { - allSubjectTypeForCategory.addAll([ - CredentialSubjectType.tezosAssociatedWallet, - CredentialSubjectType.ethereumAssociatedWallet, - CredentialSubjectType.fantomAssociatedWallet, - CredentialSubjectType.binanceAssociatedWallet, - CredentialSubjectType.polygonAssociatedWallet, - CredentialSubjectType.etherlinkAssociatedWallet, + allCategoryVC.addAll([ + CredInfo( + credentialType: CredentialSubjectType.tezosAssociatedWallet, + formatType: VCFormatType.ldpVc, + ), + CredInfo( + credentialType: + CredentialSubjectType.ethereumAssociatedWallet, + formatType: VCFormatType.ldpVc, + ), + CredInfo( + credentialType: CredentialSubjectType.fantomAssociatedWallet, + formatType: VCFormatType.ldpVc, + ), + CredInfo( + credentialType: CredentialSubjectType.binanceAssociatedWallet, + formatType: VCFormatType.ldpVc, + ), + CredInfo( + credentialType: CredentialSubjectType.polygonAssociatedWallet, + formatType: VCFormatType.ldpVc, + ), + CredInfo( + credentialType: + CredentialSubjectType.etherlinkAssociatedWallet, + formatType: VCFormatType.ldpVc, + ), ]); } @@ -903,15 +994,15 @@ class CredentialsCubit extends Cubit { } } - final List requiredDummySubjects = []; + final List requiredCreds = []; - for (final subjectType in allSubjectTypeForCategory) { + for (final credInfo in allCategoryVC) { /// remove if format is not matching - if (!subjectType.getVCFormatType.contains(vcFormatType)) { + if (!credInfo.credentialType.getVCFormatType.contains(vcFormatType)) { continue; } - final isBlockchainAccount = subjectType.isBlockchainAccount; + final isBlockchainAccount = credInfo.credentialType.isBlockchainAccount; final supportAssociatedCredential = supportCryptoCredential(profileModel); @@ -935,18 +1026,19 @@ class CredentialsCubit extends Cubit { }; final isCurrentBlockchainAccount = - blockchainToSubjectType[blockchainType] == subjectType; + blockchainToSubjectType[blockchainType] == credInfo.credentialType; final credentialsOfSameType = credentials .where( (element) => element.credentialPreview.credentialSubjectModel .credentialSubjectType == - subjectType, + credInfo.credentialType, ) .toList(); - if (credentialsOfSameType.isNotEmpty && subjectType.supportSingleOnly) { + if (credentialsOfSameType.isNotEmpty && + credInfo.credentialType.supportSingleOnly) { /// credential available case for (final credential in credentialsOfSameType) { if (isBlockchainAccount && supportAssociatedCredential) { @@ -960,8 +1052,8 @@ class CredentialsCubit extends Cubit { if (isCurrentBlockchainAccount) { /// if already added do not add - if (!requiredDummySubjects.contains(subjectType)) { - requiredDummySubjects.add(subjectType); + if (!requiredCreds.contains(credInfo)) { + requiredCreds.add(credInfo); } } @@ -971,7 +1063,7 @@ class CredentialsCubit extends Cubit { /// do not add if format matched /// there can be same credentials with different format } else { - requiredDummySubjects.add(subjectType); + requiredCreds.add(credInfo); } } } @@ -983,7 +1075,7 @@ class CredentialsCubit extends Cubit { !isCurrentBlockchainAccount) { /// do not add if current blockchain acccount does not match } else { - requiredDummySubjects.add(subjectType); + requiredCreds.add(credInfo); } } } @@ -994,8 +1086,11 @@ class CredentialsCubit extends Cubit { /// add dummies from the category dummies[category]?.addAll( - requiredDummySubjects - .map((item) => item.dummyCredential(profileSetting)) + requiredCreds + .map((item) => item.credentialType.dummyCredential( + profileSetting: profileSetting, + assignedVCFormatType: item.formatType, + )) .toList(), ); } diff --git a/lib/dashboard/home/tab_bar/credentials/oid4c4vc_pick/oid4c4vc_credential_pick/view/oid4c4vc_credential_pick_page.dart b/lib/dashboard/home/tab_bar/credentials/oid4c4vc_pick/oid4c4vc_credential_pick/view/oid4c4vc_credential_pick_page.dart index 1aba69219..fff935853 100644 --- a/lib/dashboard/home/tab_bar/credentials/oid4c4vc_pick/oid4c4vc_credential_pick/view/oid4c4vc_credential_pick_page.dart +++ b/lib/dashboard/home/tab_bar/credentials/oid4c4vc_pick/oid4c4vc_credential_pick/view/oid4c4vc_credential_pick_page.dart @@ -118,9 +118,16 @@ class Oidc4vcCredentialPickView extends StatelessWidget { final profileSetting = context.read().state.model.profileSetting; + final formatType = profileSetting + .selfSovereignIdentityOptions + .customOidc4vcProfile + .vcFormatType; final DiscoverDummyCredential discoverDummyCredential = - credentialSubjectType.dummyCredential(profileSetting); + credentialSubjectType.dummyCredential( + profileSetting: profileSetting, + assignedVCFormatType: formatType, + ); // fetch for displaying the image final (Display? display, _) = fetchDisplay( diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/credential_display.dart b/lib/dashboard/home/tab_bar/credentials/widgets/credential_display.dart index aae52d53e..8559c1030 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/credential_display.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/credential_display.dart @@ -1,6 +1,7 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:flutter/material.dart'; +import 'package:oidc4vc/oidc4vc.dart'; class CredentialDisplay extends StatelessWidget { const CredentialDisplay({ @@ -69,7 +70,10 @@ class CredentialDisplay extends StatelessWidget { CredentialSubjectType.defaultCredential; final DiscoverDummyCredential discoverDummyCredential = - credentialSubjectType.dummyCredential(profileSetting); + credentialSubjectType.dummyCredential( + profileSetting: profileSetting, + assignedVCFormatType: VCFormatType.ldpVc, // just assigning + ); return Opacity( opacity: 0.5, diff --git a/lib/dashboard/missing_creentials/cubit/missing_credentials_cubit.dart b/lib/dashboard/missing_creentials/cubit/missing_credentials_cubit.dart index eb5e6dee1..a3bafae29 100644 --- a/lib/dashboard/missing_creentials/cubit/missing_credentials_cubit.dart +++ b/lib/dashboard/missing_creentials/cubit/missing_credentials_cubit.dart @@ -36,6 +36,8 @@ class MissingCredentialsCubit extends Cubit { final List dummyCredentials = []; final profileSetting = profileCubit.state.model.profileSetting; + final formatType = profileSetting + .selfSovereignIdentityOptions.customOidc4vcProfile.vcFormatType; if (credentialManifest != null) { final PresentationDefinition? presentationDefinition = @@ -76,14 +78,16 @@ class MissingCredentialsCubit extends Cubit { final isPresentable = await isCredentialPresentable( credentialSubjectType: credentialSubjectType, - vcFormatType: profileSetting - .selfSovereignIdentityOptions.customOidc4vcProfile.vcFormatType, + vcFormatType: formatType, ); if (!isPresentable) { if (credentialSubjectType != null) { dummyCredentials.add( - credentialSubjectType.dummyCredential(profileSetting), + credentialSubjectType.dummyCredential( + profileSetting: profileSetting, + assignedVCFormatType: formatType, + ), ); } } @@ -109,8 +113,10 @@ class MissingCredentialsCubit extends Cubit { if (!isPresentable) { if (credentialSubjectType != null) { - dummyCredentials - .add(credentialSubjectType.dummyCredential(profileSetting)); + dummyCredentials.add(credentialSubjectType.dummyCredential( + profileSetting: profileSetting, + assignedVCFormatType: formatType, + )); } } } diff --git a/lib/dashboard/profile/models/profile.dart b/lib/dashboard/profile/models/profile.dart index 2c8130134..8d2737169 100644 --- a/lib/dashboard/profile/models/profile.dart +++ b/lib/dashboard/profile/models/profile.dart @@ -257,7 +257,7 @@ class ProfileModel extends Equatable { displayOver13: false, displayOver15: false, displayOver18: false, - displayOver18Jwt: false, + displayOver18Jwt: true, displayOver21: false, displayOver50: false, displayChainborn: false, @@ -347,6 +347,7 @@ class ProfileModel extends Equatable { displayGender: false, displayExternalIssuer: [], displayEmailPassSdJwt: true, + displayVerifiableIdSdJwt: true, ), selfSovereignIdentityOptions: SelfSovereignIdentityOptions( displayManageDecentralizedId: true, diff --git a/lib/dashboard/profile/models/profile_setting.dart b/lib/dashboard/profile/models/profile_setting.dart index 1fdc1f898..8e0e1e470 100644 --- a/lib/dashboard/profile/models/profile_setting.dart +++ b/lib/dashboard/profile/models/profile_setting.dart @@ -321,44 +321,51 @@ class DiscoverCardsOptions extends Equatable { ); } - String vcFormatTypeForAuto(CredentialSubjectType credentialSubjectType) { - final ldpVc = VCFormatType.ldpVc.urlValue; - final jwtVcJson = VCFormatType.jwtVcJson.urlValue; - final vcSdJWT = VCFormatType.vcSdJWT.urlValue; + String vcFormatTypeForAuto({ + required CredentialSubjectType credentialSubjectType, + required VCFormatType vcFormatType, + }) { + final ldpVcValue = VCFormatType.ldpVc.urlValue; + final jwtVcJsonValue = VCFormatType.jwtVcJson.urlValue; + final vcSdJWTValue = VCFormatType.vcSdJWT.urlValue; + + final isLdpVc = vcFormatType == VCFormatType.ldpVc; + final isJwtVcJson = vcFormatType == VCFormatType.jwtVcJson; + final isVcSdJWT = vcFormatType == VCFormatType.vcSdJWT; switch (credentialSubjectType) { case CredentialSubjectType.defiCompliance: - if (displayDefi) return ldpVc; + if (isLdpVc && displayDefi) return ldpVcValue; case CredentialSubjectType.livenessCard: - if (displayHumanity) return ldpVc; - if (displayHumanityJwt) return vcSdJWT; + if (isLdpVc && displayHumanity) return ldpVcValue; + if (isJwtVcJson && displayHumanityJwt) return vcSdJWTValue; case CredentialSubjectType.gender: - if (displayGender) return ldpVc; + if (isLdpVc && displayGender) return ldpVcValue; case CredentialSubjectType.verifiableIdCard: - if (displayVerifiableId) return ldpVc; - if (displayVerifiableIdJwt) return jwtVcJson; - if (displayVerifiableIdSdJwt) return vcSdJWT; + if (isLdpVc && displayVerifiableId) return ldpVcValue; + if (isJwtVcJson && displayVerifiableIdJwt) return jwtVcJsonValue; + if (isVcSdJWT && displayVerifiableIdSdJwt) return vcSdJWTValue; case CredentialSubjectType.over13: - if (displayOver13) return ldpVc; + if (isLdpVc && displayOver13) return ldpVcValue; case CredentialSubjectType.over15: - if (displayOver15) return ldpVc; + if (isLdpVc && displayOver15) return ldpVcValue; case CredentialSubjectType.over18: - if (displayOver18) return ldpVc; - if (displayOver18Jwt) return jwtVcJson; + if (isLdpVc && displayOver18) return ldpVcValue; + if (isJwtVcJson && displayOver18Jwt) return jwtVcJsonValue; case CredentialSubjectType.over21: - if (displayOver21) return ldpVc; + if (isLdpVc && displayOver21) return ldpVcValue; case CredentialSubjectType.over50: - if (displayOver50) return ldpVc; + if (isLdpVc && displayOver50) return ldpVcValue; case CredentialSubjectType.over65: - if (displayOver65) return ldpVc; + if (isLdpVc && displayOver65) return ldpVcValue; case CredentialSubjectType.emailPass: - if (displayEmailPass) return ldpVc; - if (displayEmailPassJwt) return jwtVcJson; - if (displayEmailPassSdJwt) return vcSdJWT; + if (isLdpVc && displayEmailPass) return ldpVcValue; + if (isJwtVcJson && displayEmailPassJwt) return jwtVcJsonValue; + if (isVcSdJWT && displayEmailPassSdJwt) return vcSdJWTValue; case CredentialSubjectType.learningAchievement: case CredentialSubjectType.phonePass: - if (displayPhonePass) return ldpVc; - if (displayPhonePassJwt) return jwtVcJson; + if (isLdpVc && displayPhonePass) return ldpVcValue; + if (isJwtVcJson && displayPhonePassJwt) return jwtVcJsonValue; case CredentialSubjectType.identityPass: case CredentialSubjectType.tezotopiaMembership: case CredentialSubjectType.chainbornMembership: