Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/october'
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed Feb 15, 2024
2 parents 9830e29 + 394037e commit 94a52f6
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 41 deletions.
4 changes: 2 additions & 2 deletions lib/app/shared/enum/type/profile/profile_type.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'package:altme/l10n/l10n.dart';

enum ProfileType {
custom,
defaultOne,
ebsiV3,
dutch,
enterprise,
owfBaselineProfile,
defaultOne
custom,
}

extension ProfileTypeX on ProfileType {
Expand Down
6 changes: 4 additions & 2 deletions lib/dashboard/drawer/src/view/drawer_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ class DrawerView extends StatelessWidget {
],

if (profileModel
.profileSetting.settingsMenu.displayDeveloperMode) ...[
.profileSetting.settingsMenu.displayDeveloperMode &&
profileModel.profileType != ProfileType.defaultOne) ...[
DrawerCategoryItem(
title: l10n.developerMode,
subTitle: l10n.developerModeSubtitle,
Expand Down Expand Up @@ -152,7 +153,8 @@ class DrawerView extends StatelessWidget {
//const SizedBox(height: Sizes.spaceSmall),

if (profileModel
.profileSetting.settingsMenu.displayHelpCenter) ...[
.profileSetting.settingsMenu.displayHelpCenter &&
profileModel.profileType != ProfileType.defaultOne) ...[
DrawerCategoryItem(
title: l10n.helpCenter,
subTitle: l10n.helpCenterDescription,
Expand Down
35 changes: 24 additions & 11 deletions lib/scan/cubit/scan_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -719,29 +719,42 @@ class ScanCubit extends Cubit<ScanState> {
filterList: filterList,
credentialList: [credentialsToBePresented[i]],
);

final pathNested = {
'id': inputDescriptor.id,
'format': vcFormat,
};

if (credential.isNotEmpty) {
if (credentialsToBePresented.length == 1) {
if (vpFormat == 'ldp_vp') {
pathNested['path'] = r'$.verifiableCredential';
} else {
pathNested['path'] = r'$.vp.verifiableCredential[0]';
}

inputDescriptors.add({
'id': inputDescriptor.id,
'format': vpFormat,
'path': r'$',
'path_nested': {
'id': inputDescriptor.id,
'format': vcFormat,
'path': r'$.verifiableCredential',
},
'path_nested': pathNested,
});
} else {
if (vpFormat == 'ldp_vp') {
pathNested['path'] =
// ignore: prefer_interpolation_to_compose_strings
r'$.verifiableCredential[' + i.toString() + ']';
} else {
pathNested['path'] =
// ignore: prefer_interpolation_to_compose_strings
r'$.vp.verifiableCredential[' + i.toString() + ']';
}

inputDescriptors.add({
'id': inputDescriptor.id,
'format': vpFormat,
'path': r'$',
'path_nested': {
'id': inputDescriptor.id,
'format': vcFormat,
// ignore: prefer_interpolation_to_compose_strings
'path': r'$.verifiableCredential[' + i.toString() + ']',
},
'path_nested': pathNested,
});
}
}
Expand Down
88 changes: 63 additions & 25 deletions packages/oidc4vc/lib/src/oidc4vc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,38 +203,76 @@ class OIDC4VC {
for (final credential in selectedCredentials) {
late Map<String, dynamic> data;
if (credential is String) {
//
final credentialsSupported = openIdConfiguration.credentialsSupported;
if (openIdConfiguration.credentialsSupported != null) {
final credentialsSupported = openIdConfiguration.credentialsSupported;

dynamic credentailData;

for (final dynamic cred in credentialsSupported!) {
if (cred is Map<String, dynamic> &&
((cred.containsKey('scope') &&
cred['scope'].toString() == credential) ||
(cred.containsKey('id') &&
cred['id'].toString() == credential))) {
credentailData = cred;
break;
}
}

if (credentialsSupported == null) {
throw Exception();
}
if (credentailData == null) {
throw Exception('CREDENTIAL_SUPPORT_DATA_ERROR');
}

data = {
'type': 'openid_credential',
'locations': [issuer],
'format': credentailData['format'],
'types': credentailData['types'],
};

credentials.add((credentailData['types'] as List<dynamic>).last);
} else if (openIdConfiguration.credentialConfigurationsSupported !=
null) {
// draft 13 case
final credentialsSupported =
openIdConfiguration.credentialConfigurationsSupported;

if (credentialsSupported is! Map<String, dynamic>) {
throw Exception('CREDENTIAL_SUPPORT_DATA_ERROR');
}

final credentialSupportedMapEntry =
credentialsSupported.entries.where(
(entry) {
final dynamic ele = entry.key;

if (ele == credential) return true;

dynamic credentailData;
return false;
},
).firstOrNull;

for (final dynamic cred in credentialsSupported) {
if (cred is Map<String, dynamic> &&
((cred.containsKey('scope') &&
cred['scope'].toString() == credential) ||
(cred.containsKey('id') &&
cred['id'].toString() == credential))) {
credentailData = cred;
break;
if (credentialSupportedMapEntry == null) {
throw Exception('CREDENTIAL_SUPPORT_DATA_ERROR');
}
}

if (credentailData == null) {
throw Exception();
}
final credentialSupported = credentialSupportedMapEntry.value;

data = {
'type': 'openid_credential',
'locations': [issuer],
'format': credentailData['format'],
'types': credentailData['types'],
};
data = {
'type': 'openid_credential',
'credential_configuration_id': credential,
};

credentials.add((credentailData['types'] as List<dynamic>).last);
final scope = credentialSupported['scope'];

if (scope == null) {
throw Exception('CREDENTIAL_SUPPORT_DATA_ERROR');
}

credentials.add(scope);
} else {
throw Exception('CREDENTIAL_SUPPORT_DATA_ERROR');
}
} else if (credential is Map<String, dynamic>) {
data = {
'type': 'openid_credential',
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: altme
description: AltMe Flutter App
version: 2.2.24+386
version: 2.2.25+387

environment:
sdk: ">=3.1.0 <4.0.0"
Expand Down

0 comments on commit 94a52f6

Please sign in to comment.