Skip to content

Commit

Permalink
feat: Assign specific format if auto is assigned #2887
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Sep 18, 2024
1 parent 618569b commit 8fd7324
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,16 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
final oidc4vcDraftType = profileSetting
.selfSovereignIdentityOptions.customOidc4vcProfile.oidc4vciDraft;

final discoverCardsOptions = profileSetting.discoverCardsOptions;

var format = VCFormatType.ldpVc.urlValue;

if (vcFormatType == VCFormatType.auto && discoverCardsOptions != null) {
format = discoverCardsOptions.vcFormatTypeForAuto;
} else {
format = vcFormatType.urlValue;
}

switch (this) {
case CredentialSubjectType.defiCompliance:
image = ImageStrings.dummyDefiComplianceCard;
Expand Down Expand Up @@ -793,7 +803,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

link = '${Urls.emailPassUrl}'
'?draft=${oidc4vcDraftType.numbering}'
'&format=${vcFormatType.urlValue}';
'&format=$format';

whyGetThisCard = ResponseString.RESPONSE_STRING_emailPassWhyGetThisCard;
expirationDateDetails =
Expand All @@ -805,7 +815,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

link = '${Urls.id360Url}'
'?draft=${oidc4vcDraftType.numbering}'
'&format=${vcFormatType.urlValue}'
'&format=$format'
'&type=over13';

whyGetThisCard = ResponseString.RESPONSE_STRING_over13WhyGetThisCard;
Expand All @@ -818,7 +828,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

link = '${Urls.id360Url}'
'?draft=${oidc4vcDraftType.numbering}'
'&format=${vcFormatType.urlValue}'
'&format=$format'
'&type=over15';

whyGetThisCard = ResponseString.RESPONSE_STRING_over15WhyGetThisCard;
Expand All @@ -831,7 +841,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

link = '${Urls.id360Url}'
'?draft=${oidc4vcDraftType.numbering}'
'&format=${vcFormatType.urlValue}'
'&format=$format'
'&type=over18';

whyGetThisCard = ResponseString.RESPONSE_STRING_over18WhyGetThisCard;
Expand All @@ -844,7 +854,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

link = '${Urls.id360Url}'
'?draft=${oidc4vcDraftType.numbering}'
'&format=${vcFormatType.urlValue}'
'&format=$format'
'&type=over21';

whyGetThisCard = ResponseString.RESPONSE_STRING_over18WhyGetThisCard;
Expand All @@ -857,7 +867,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

link = '${Urls.id360Url}'
'?draft=${oidc4vcDraftType.numbering}'
'&format=${vcFormatType.urlValue}'
'&format=$format'
'&type=over50';

whyGetThisCard = ResponseString.RESPONSE_STRING_over18WhyGetThisCard;
Expand All @@ -870,7 +880,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

link = '${Urls.id360Url}'
'?draft=${oidc4vcDraftType.numbering}'
'&format=${vcFormatType.urlValue}'
'&format=$format'
'&type=over65';

whyGetThisCard = ResponseString.RESPONSE_STRING_over18WhyGetThisCard;
Expand Down Expand Up @@ -916,7 +926,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

link = '${Urls.id360Url}'
'?draft=${oidc4vcDraftType.numbering}'
'&format=${vcFormatType.urlValue}'
'&format=$format'
'&type=$type';

whyGetThisCard =
Expand Down Expand Up @@ -963,7 +973,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

link = '${Urls.phonePassUrl}'
'?draft=${oidc4vcDraftType.numbering}'
'&format=${vcFormatType.urlValue}';
'&format=$format';

whyGetThisCard =
ResponseString.RESPONSE_STRING_phoneProofWhyGetThisCard;
Expand All @@ -976,7 +986,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

link = '${Urls.id360Url}'
'?draft=${oidc4vcDraftType.numbering}'
'&format=${vcFormatType.urlValue}'
'&format=$format'
'&type=liveness';

whyGetThisCard =
Expand Down
27 changes: 27 additions & 0 deletions lib/dashboard/profile/models/profile_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,33 @@ class DiscoverCardsOptions extends Equatable {
);
}

String get vcFormatTypeForAuto {
if (displayDefi ||
displayEmailPass ||
displayGender ||
displayHumanity ||
displayOver13 ||
displayOver15 ||
displayOver18 ||
displayOver21 ||
displayOver50 ||
displayOver65 ||
displayPhonePass ||
displayVerifiableId) {
return VCFormatType.ldpVc.urlValue;
} else if (displayPhonePassJwt ||
displayOver18Jwt ||
displayEmailPassJwt ||
displayVerifiableIdJwt ||
displayHumanityJwt) {
return VCFormatType.jwtVcJson.urlValue;
} else if (displayVerifiableIdSdJwt) {
return VCFormatType.vcSdJWT.urlValue;
}

return VCFormatType.ldpVc.urlValue;
}

@override
List<Object?> get props => [
displayDefi,
Expand Down

0 comments on commit 8fd7324

Please sign in to comment.