Skip to content

Commit

Permalink
feat: Add email address in the email pass issued by vcsdjwt #3110
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Dec 4, 2024
1 parent a8321d3 commit c314017
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/lang/lang.dart';
import 'package:altme/selective_disclosure/selective_disclosure.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:oidc4vc/oidc4vc.dart';

class EmailPassWidget extends StatelessWidget {
const EmailPassWidget({super.key, required this.credentialModel});
Expand All @@ -11,11 +15,38 @@ class EmailPassWidget extends StatelessWidget {
Widget build(BuildContext context) {
final emailPassModel = credentialModel
.credentialPreview.credentialSubjectModel as EmailPassModel;

var emailAddress = emailPassModel.email;

if (credentialModel.getFormat == VCFormatType.vcSdJWT.vcValue &&
(emailAddress == null || emailAddress.isEmpty)) {
final languageCode = context.read<LangCubit>().state.locale.languageCode;
final mapToDisplay = SelectiveDisclosureDisplayMap(
credentialModel: credentialModel,
claims: null,
isPresentation: false,
languageCode: languageCode,
limitDisclosure: '',
filters: <String, dynamic>{},
isDeveloperMode:
context.read<ProfileCubit>().state.model.isDeveloperMode,
selectedClaimsKeyIds: <SelectedClaimsKeyIds>[],
onPressed: null,
).buildMap;

final email = mapToDisplay['Email'];
if (email != null && email is Map<String, dynamic>) {
final value = email['value'];

if (value != null) emailAddress = value.toString();
}
}

return CredentialBaseWidget(
cardBackgroundImagePath: ImageStrings.emailProof,
issuerName: credentialModel
.credentialPreview.credentialSubjectModel.issuedBy?.name,
value: emailPassModel.email,
value: emailAddress,
issuanceDate: UiDate.formatDateForCredentialCard(
credentialModel.credentialPreview.issuanceDate,
),
Expand Down
2 changes: 2 additions & 0 deletions lib/selective_disclosure/selective_disclosure.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:altme/selective_disclosure/selective_disclosure.dart';
import 'package:json_path/json_path.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:oidc4vc/oidc4vc.dart';

export 'helper_functions/selective_disclosure_display_map.dart';
export 'model/model.dart';

class SelectiveDisclosure {
Expand Down

0 comments on commit c314017

Please sign in to comment.