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 Mar 21, 2024
2 parents 63e6d27 + e09ece8 commit 884798d
Show file tree
Hide file tree
Showing 42 changed files with 614 additions and 279 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ enum CredentialSubjectType {
civicPassCredential,
employeeCredential,
legalPersonalCredential,
identityCredential,
eudiPid,
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
case CredentialSubjectType.civicPassCredential:
case CredentialSubjectType.employeeCredential:
case CredentialSubjectType.legalPersonalCredential:
case CredentialSubjectType.identityCredential:
case CredentialSubjectType.eudiPid:
return Colors.white;
}
}
Expand Down Expand Up @@ -203,6 +205,10 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
return 'ProofOfTwitterStats';
case CredentialSubjectType.civicPassCredential:
return 'CivicPassCredential';
case CredentialSubjectType.identityCredential:
return 'IdentityCredential';
case CredentialSubjectType.eudiPid:
return 'EudiPid';
case CredentialSubjectType.defaultCredential:
return '';
}
Expand Down Expand Up @@ -240,8 +246,6 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
return BinanceAssociatedAddressModel.fromJson(json);
case CredentialSubjectType.certificateOfEmployment:
return CertificateOfEmploymentModel.fromJson(json);
case CredentialSubjectType.defaultCredential:
return DefaultCredentialSubjectModel.fromJson(json);
case CredentialSubjectType.emailPass:
return EmailPassModel.fromJson(json);
case CredentialSubjectType.identityPass:
Expand Down Expand Up @@ -324,6 +328,12 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
return EmployeeCredentialModel.fromJson(json);
case CredentialSubjectType.legalPersonalCredential:
return LegalPersonCredentialModel.fromJson(json);
case CredentialSubjectType.defaultCredential:
return DefaultCredentialSubjectModel.fromJson(json);
case CredentialSubjectType.identityCredential:
return IdentityCredentialSubjectModel.fromJson(json);
case CredentialSubjectType.eudiPid:
return EudipidSubjectModel.fromJson(json);
}
}

Expand Down Expand Up @@ -555,6 +565,10 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
return 'Employee Credential';
case CredentialSubjectType.legalPersonalCredential:
return 'Legal Person Credential';
case CredentialSubjectType.identityCredential:
return 'Identity Credential';
case CredentialSubjectType.eudiPid:
return 'EudiPid';
case CredentialSubjectType.defaultCredential:
return '';
}
Expand Down Expand Up @@ -620,6 +634,8 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
case CredentialSubjectType.civicPassCredential:
case CredentialSubjectType.employeeCredential:
case CredentialSubjectType.legalPersonalCredential:
case CredentialSubjectType.identityCredential:
case CredentialSubjectType.eudiPid:
return false;
}
}
Expand Down Expand Up @@ -652,6 +668,10 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
VCFormatType.vcSdJWT,
];

case CredentialSubjectType.identityCredential:
case CredentialSubjectType.eudiPid:
return [VCFormatType.vcSdJWT];

case CredentialSubjectType.over18:
case CredentialSubjectType.phonePass:
case CredentialSubjectType.livenessCard:
Expand Down Expand Up @@ -996,6 +1016,8 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
case CredentialSubjectType.civicPassCredential:
case CredentialSubjectType.legalPersonalCredential:
case CredentialSubjectType.walletCredential:
case CredentialSubjectType.identityCredential:
case CredentialSubjectType.eudiPid:
break;
}

Expand Down Expand Up @@ -1130,6 +1152,8 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
case CredentialSubjectType.civicPassCredential:
case CredentialSubjectType.employeeCredential:
case CredentialSubjectType.legalPersonalCredential:
case CredentialSubjectType.identityCredential:
case CredentialSubjectType.eudiPid:
return 0;
}
}
Expand Down
147 changes: 75 additions & 72 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import 'dart:io';
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/oidc4vc/oidc4vc.dart';
import 'package:altme/selective_disclosure/selective_disclosure.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:convert/convert.dart';
import 'package:credential_manifest/credential_manifest.dart';
import 'package:crypto/crypto.dart';

import 'package:dartez/dartez.dart';
Expand Down Expand Up @@ -1594,77 +1594,6 @@ Future<(String?, String?, String?, String?)> getClientDetails({
return (display, credentialSupported);
}

String? getClaimsData({
required Map<String, dynamic> uncryptedDatas,
required CredentialModel credentialModel,
required String key,
required bool selectFromSelectiveDisclosure,
}) {
String? data;

final JsonPath dataPath = JsonPath(
// ignore: prefer_interpolation_to_compose_strings
r'$..' + key,
);

try {
final uncryptedDataPath = dataPath.read(uncryptedDatas).first;
data = uncryptedDataPath.value.toString();
} catch (e) {
if (!selectFromSelectiveDisclosure) {
try {
final credentialModelPath = dataPath.read(credentialModel.data).first;
data = credentialModelPath.value.toString();
} catch (e) {
data = null;
}
}
}

return data;
}

String? getPicture({
required CredentialModel credentialModel,
}) {
if (credentialModel.format.toString() != VCFormatType.vcSdJWT.value) {
return null;
}

final credentialSupported = credentialModel.credentialSupported;
if (credentialSupported == null) return null;

final claims = credentialSupported['claims'];
if (claims is! Map<String, dynamic>) return null;

final picture = claims['picture'];
if (picture == null) return null;
if (picture is! Map<String, dynamic>) return null;

if (picture.containsKey('mandatory')) {
final mandatory = picture['mandatory'];
if (mandatory is! bool) return null;
}

final valueType = picture['value_type'];
if (valueType == null) return null;

if (valueType == 'image/jpeg') {
final selectiveDisclosure = SelectiveDisclosure(credentialModel);

final data = getClaimsData(
uncryptedDatas: selectiveDisclosure.values,
credentialModel: credentialModel,
key: 'picture',
selectFromSelectiveDisclosure: false,
);

return data;
} else {
return null;
}
}

List<String> getStringCredentialsForToken({
required List<CredentialModel> credentialsToBePresented,
required ProfileCubit profileCubit,
Expand All @@ -1688,3 +1617,77 @@ String hash(String text) {
final digest = sha256.convert(bytes);
return base64Url.encode(digest.bytes).replaceAll('=', '');
}

//(presentLdpVc, presentJwtVc, presentJwtVcJson, presentVcSdJwt)
(bool, bool, bool, bool) getPresentVCDetails({
required VCFormatType vcFormatType,
required PresentationDefinition presentationDefinition,
required Map<String, dynamic>? clientMetaData,
}) {
bool presentLdpVc = false;
bool presentJwtVc = false;
bool presentJwtVcJson = false;
bool presentVcSdJwt = false;

if (presentationDefinition.format != null) {
/// ldp_vc
presentLdpVc = presentationDefinition.format?.ldpVc != null;

/// jwt_vc
presentJwtVc = presentationDefinition.format?.jwtVc != null;

/// jwt_vc_json
presentJwtVcJson = presentationDefinition.format?.jwtVcJson != null;

/// vc+sd-jwt
presentVcSdJwt = presentationDefinition.format?.vcSdJwt != null;
} else {
if (clientMetaData == null) {
/// credential manifest case
if (vcFormatType == VCFormatType.ldpVc) {
presentLdpVc = true;
} else if (vcFormatType == VCFormatType.jwtVc) {
presentJwtVc = true;
} else if (vcFormatType == VCFormatType.jwtVcJson) {
presentJwtVcJson = true;
} else if (vcFormatType == VCFormatType.vcSdJWT) {
presentVcSdJwt = true;
}
} else {
final vpFormats = clientMetaData['vp_formats'] as Map<String, dynamic>;

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

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

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

/// vc+sd-jwt
presentVcSdJwt = vpFormats.containsKey('vc+sd-jwt');
}

if (!presentLdpVc && vcFormatType == VCFormatType.ldpVc) {
presentLdpVc = true;
} else if (!presentJwtVc && (vcFormatType == VCFormatType.jwtVc)) {
presentJwtVc = true;
} else if (!presentJwtVcJson && (vcFormatType == VCFormatType.jwtVcJson)) {
presentJwtVcJson = true;
} else if (!presentJwtVc && vcFormatType == VCFormatType.vcSdJWT) {
presentVcSdJwt = true;
}
}

if (!presentLdpVc && !presentJwtVc && !presentJwtVcJson && !presentVcSdJwt) {
throw ResponseMessage(
data: {
'error': 'invalid_request',
'error_description': 'VC format is missing',
},
);
}

return (presentLdpVc, presentJwtVc, presentJwtVcJson, presentVcSdJwt);
}
30 changes: 16 additions & 14 deletions lib/app/shared/widget/base/credential_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class CredentialField extends StatelessWidget {
const CredentialField({
super.key,
required this.value,
required this.showVertically,
this.title,
this.titleColor,
this.valueColor,
Expand All @@ -16,6 +17,7 @@ class CredentialField extends StatelessWidget {
final Color? titleColor;
final Color? valueColor;
final EdgeInsetsGeometry padding;
final bool showVertically;

@override
Widget build(BuildContext context) {
Expand All @@ -27,6 +29,7 @@ class CredentialField extends StatelessWidget {
titleColor: titleColor,
valueColor: valueColor,
padding: padding,
showVertically: showVertically,
),
);
}
Expand All @@ -40,40 +43,39 @@ class DisplayCredentialField extends StatelessWidget {
this.titleColor,
this.valueColor,
required this.padding,
required this.showVertically,
});

final String? title;
final String value;
final Color? titleColor;
final Color? valueColor;
final EdgeInsetsGeometry padding;
final bool showVertically;

@override
Widget build(BuildContext context) {
final textTheme = Theme.of(context).textTheme;

return Padding(
padding: padding,
child: SelectableText.rich(
textAlign: TextAlign.left,
TextSpan(
children: <InlineSpan>[
if (title != null)
if (title != null) ...[
TextSpan(
text: '$title: ',
style: titleColor == null
? Theme.of(context).textTheme.credentialFieldTitle
: Theme.of(context)
.textTheme
.credentialFieldTitle
.copyWith(color: titleColor),
text: showVertically ? title : '$title: ',
style: textTheme.credentialFieldTitle.copyWith(
color: titleColor,
),
),
if (showVertically) const TextSpan(text: ' \n'),
],
TextSpan(
text: value,
style: valueColor == null
? Theme.of(context).textTheme.credentialFieldDescription
: Theme.of(context)
.textTheme
.credentialFieldDescription
.copyWith(color: valueColor),
style: textTheme.credentialFieldDescription
.copyWith(color: valueColor),
),
],
),
Expand Down
15 changes: 13 additions & 2 deletions lib/chat_room/view/chat_room_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,19 @@ class _ChatRoomViewState<B extends ChatRoomCubit> extends State<ChatRoomView> {
(_) async {
liveChatCubit = context.read<B>();

if (context.read<ProfileCubit>().state.model.walletType ==
WalletType.enterprise) {
final displayChatSupport = context
.read<ProfileCubit>()
.state
.model
.profileSetting
.helpCenterOptions
.displayChatSupport;

final isEnterprise =
context.read<ProfileCubit>().state.model.walletType ==
WalletType.enterprise;

if (displayChatSupport || isEnterprise) {
// for enterprise we are initialisation at start
await context.read<AltmeChatSupportCubit>().init();
}
Expand Down
4 changes: 4 additions & 0 deletions lib/dashboard/drawer/ssi/manage_did/view/did_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class DidView extends StatelessWidget {
itemBuilder: (context, index) {
final didKeyType = DidKeyType.values[index];

if (didKeyType == DidKeyType.jwtClientAttestation) {
return Container();
}

final title = didKeyType.getTitle(l10n);
return DrawerItem(
title: title,
Expand Down
Loading

0 comments on commit 884798d

Please sign in to comment.