Skip to content

Commit

Permalink
Merge branch 'main' into TALAO
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed Nov 1, 2024
2 parents 8702cf7 + b6e82a3 commit a6a585c
Show file tree
Hide file tree
Showing 28 changed files with 543 additions and 294 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
26 changes: 14 additions & 12 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 Expand Up @@ -1883,16 +1881,20 @@ List<VCFormatType> getPresentVCDetails({
final vpFormats = clientMetaData['vp_formats'] as Map<String, dynamic>;

/// ldp_vc
presentLdpVc = vpFormats.containsKey('ldp_vc');
presentLdpVc =
vpFormats.containsKey('ldp_vc') || vpFormats.containsKey('ldp_vp');

/// jwt_vc
presentJwtVc = vpFormats.containsKey('jwt_vc');
presentJwtVc =
vpFormats.containsKey('jwt_vc') || vpFormats.containsKey('jwt_vp');

/// jwt_vc_json
presentJwtVcJson = vpFormats.containsKey('jwt_vc_json');
presentJwtVcJson = vpFormats.containsKey('jwt_vc_json') ||
vpFormats.containsKey('jwt_vp_json');

/// jwt_vc_json-ld
presentJwtVcJsonLd = vpFormats.containsKey('jwt_vc_json-ld');
presentJwtVcJsonLd = vpFormats.containsKey('jwt_vc_json-ld') ||
vpFormats.containsKey('jwt_vp_json-ld');

/// vc+sd-jwt
presentVcSdJwt = vpFormats.containsKey('vc+sd-jwt');
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 a6a585c

Please sign in to comment.