Skip to content

Commit

Permalink
Merge pull request #3050 from TalaoDAO/october
Browse files Browse the repository at this point in the history
October
  • Loading branch information
hawkbee1 authored Nov 1, 2024
2 parents 8671546 + 61dc881 commit a29dd57
Show file tree
Hide file tree
Showing 18 changed files with 507 additions and 223 deletions.
11 changes: 11 additions & 0 deletions lib/app/shared/date/date.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,15 @@ class UiDate {
return null;
}
}

static DateTime parseExpirationDate(String input) {
if (RegExp(r'^\d+$').hasMatch(input)) {
// numeric date string
final int timestamp = int.parse(input);
return DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
} else {
// ISO 8601 formatted date string
return DateTime.parse(input);
}
}
}
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,21 +693,20 @@ 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,
VCFormatType.jwtVcJson,
VCFormatType.auto,
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 @@ -739,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 @@ -759,7 +770,10 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
var format = VCFormatType.ldpVc.urlValue;

if (vcFormatType == VCFormatType.auto && discoverCardsOptions != null) {
format = discoverCardsOptions.vcFormatTypeForAuto;
format = discoverCardsOptions.vcFormatTypeForAuto(
credentialSubjectType: this,
vcFormatType: assignedVCFormatType,
);
} else {
format = vcFormatType.urlValue;
}
Expand Down Expand Up @@ -911,14 +925,19 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
var type = 'verifiableid';
image = ImageStrings.dummyVerifiableIdCard;

if (vcFormatType == VCFormatType.vcSdJWT) {
final discoverCardsOptions = profileSetting.discoverCardsOptions;
if (discoverCardsOptions != null &&
discoverCardsOptions.displayVerifiableIdSdJwt) {
final discoverCardsOptions = profileSetting.discoverCardsOptions;

if (discoverCardsOptions != null) {
if (discoverCardsOptions.displayVerifiableIdSdJwt &&
assignedVCFormatType == VCFormatType.vcSdJWT) {
type = 'pid';
image = ImageStrings.dummyPIDCard;
} else {
type = 'identitycredential';
} else if (discoverCardsOptions.displayVerifiableIdJwt &&
assignedVCFormatType == VCFormatType.jwtVcJson) {
type = 'verifiableid';
} else if (discoverCardsOptions.displayVerifiableId &&
assignedVCFormatType == VCFormatType.ldpVc) {
type = 'verifiableid';
}
} else if (vcFormatType == VCFormatType.jwtVc) {
type = 'individualverifiableattestation';
Expand Down
14 changes: 6 additions & 8 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -754,14 +754,12 @@ Future<

Map<String, dynamic>? authorizationServerConfigurationData;

if (authorizationServer != null) {
authorizationServerConfigurationData = await oidc4vc.getOpenIdConfig(
baseUrl: authorizationServer,
isAuthorizationServer: true,
dio: client.dio,
useOAuthAuthorizationServerLink: useOAuthAuthorizationServerLink,
);
}
authorizationServerConfigurationData = await oidc4vc.getOpenIdConfig(
baseUrl: authorizationServer ?? issuer,
isAuthorizationServer: true,
dio: client.dio,
useOAuthAuthorizationServerLink: useOAuthAuthorizationServerLink,
);

final credentialsSupported = openIdConfiguration.credentialsSupported;
final credentialConfigurationsSupported =
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 a29dd57

Please sign in to comment.