Skip to content

Commit

Permalink
feat: Support multiple formats with different vcs in discover #3046
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Nov 1, 2024
1 parent c366d46 commit d4069d0
Show file tree
Hide file tree
Showing 9 changed files with 340 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions lib/app/shared/models/cred_info/cred_info.dart
Original file line number Diff line number Diff line change
@@ -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;
}
1 change: 1 addition & 0 deletions lib/app/shared/models/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Loading

0 comments on commit d4069d0

Please sign in to comment.