Skip to content

Commit

Permalink
Show crypto associated credential based on vcformat and didkey type
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Feb 27, 2024
1 parent 6b8355a commit cac3cff
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -626,18 +626,20 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

List<VCFormatType> get getVCFormatType {
switch (this) {
case CredentialSubjectType.ethereumAssociatedWallet:
case CredentialSubjectType.fantomAssociatedWallet:
case CredentialSubjectType.polygonAssociatedWallet:
case CredentialSubjectType.binanceAssociatedWallet:
case CredentialSubjectType.tezosAssociatedWallet:
return VCFormatType.values;

case CredentialSubjectType.over13:
case CredentialSubjectType.over15:
case CredentialSubjectType.over21:
case CredentialSubjectType.over50:
case CredentialSubjectType.over65:
case CredentialSubjectType.gender:
case CredentialSubjectType.ageRange:
case CredentialSubjectType.ethereumAssociatedWallet:
case CredentialSubjectType.fantomAssociatedWallet:
case CredentialSubjectType.polygonAssociatedWallet:
case CredentialSubjectType.binanceAssociatedWallet:
case CredentialSubjectType.tezosAssociatedWallet:
case CredentialSubjectType.defiCompliance:
case CredentialSubjectType.tezotopiaMembership:
case CredentialSubjectType.phonePass:
Expand Down
12 changes: 12 additions & 0 deletions lib/app/shared/enum/type/profile/did_key_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,16 @@ extension DidKeyTypeX on DidKeyType {
return l10n.jwkDecentralizedIDP256;
}
}

bool get supportCryptoCredential {
switch (this) {
case DidKeyType.secp256k1:
case DidKeyType.p256:
return true;
case DidKeyType.edDSA:
case DidKeyType.ebsiv3:
case DidKeyType.jwkP256:
return false;
}
}
}
13 changes: 0 additions & 13 deletions lib/app/shared/enum/type/profile/profile_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,4 @@ extension ProfileTypeX on ProfileType {
return true;
}
}

bool get supportAssociatedCredential {
switch (this) {
case ProfileType.custom:
case ProfileType.owfBaselineProfile:
return false;
case ProfileType.defaultOne:
case ProfileType.dutch:
case ProfileType.ebsiV3:
case ProfileType.enterprise:
return true;
}
}
}
17 changes: 17 additions & 0 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io';

import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/dashboard/home/home.dart';
import 'package:altme/oidc4vc/oidc4vc.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
Expand Down Expand Up @@ -1334,3 +1335,19 @@ String getUpdatedUrlForSIOPV2OIC4VP({
final String newUrl = '$uri&$queryString';
return newUrl;
}

bool supportCryptoCredential(ProfileSetting profileSetting) {
final customOidc4vcProfile =
profileSetting.selfSovereignIdentityOptions.customOidc4vcProfile;

final supportCryptoCredentialByVCFormat =
customOidc4vcProfile.vcFormatType.supportCryptoCredential;

final supportCryptoCredentialByDidKey =
customOidc4vcProfile.defaultDid.supportCryptoCredential;

final supportAssociatedCredential =
supportCryptoCredentialByVCFormat && supportCryptoCredentialByDidKey;

return supportAssociatedCredential;
}
10 changes: 6 additions & 4 deletions lib/credentials/cubit/credentials_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,10 @@ class CredentialsCubit extends Cubit<CredentialsState> {
Future<void> insertAssociatedWalletCredential({
required CryptoAccountData cryptoAccountData,
}) async {
if (!profileCubit.state.model.profileType.supportAssociatedCredential) {
throw Exception();
}
final supportAssociatedCredential =
supportCryptoCredential(profileCubit.state.model.profileSetting);

if (!supportAssociatedCredential) throw Exception();

final didKeyType = profileCubit.state.model.profileSetting
.selfSovereignIdentityOptions.customOidc4vcProfile.defaultDid;
Expand Down Expand Up @@ -841,8 +842,9 @@ class CredentialsCubit extends Cubit<CredentialsState> {
final isCurrentBlockchainAccount =
blockchainToSubjectType[blockchainType] == subjectType;
final isBlockchainAccount = subjectType.isBlockchainAccount;

final supportAssociatedCredential =
profileCubit.state.model.profileType.supportAssociatedCredential;
supportCryptoCredential(profileCubit.state.model.profileSetting);

/// remove if credential is blockchain account and
/// profile do not support
Expand Down
12 changes: 12 additions & 0 deletions packages/oidc4vc/lib/src/vc_format_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,16 @@ extension VCFormatTypeX on VCFormatType {
return 'vcsd-jwt';
}
}

bool get supportCryptoCredential {
switch (this) {
case VCFormatType.ldpVc:
case VCFormatType.jwtVcJson:
return true;
case VCFormatType.jwtVc:
case VCFormatType.jwtVcJsonLd:
case VCFormatType.vcSdJWT:
return false;
}
}
}

0 comments on commit cac3cff

Please sign in to comment.