Skip to content

Commit

Permalink
feat: Add wallet attestation status list data #2583
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Apr 10, 2024
1 parent 39bf11f commit d0b34be
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ class _CredentialsDetailsViewState extends State<CredentialsDetailsView> {
/// credential manifest details
if (credentialManifestSupport &&
outputDescriptors != null) ...[
const SizedBox(height: 10),
CredentialManifestDetails(
outputDescriptor: outputDescriptors.firstOrNull,
credentialModel: widget.credentialModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,13 @@ class CredentialSubjectData extends StatelessWidget {

if (title == null || data == null) return Container();

return Padding(
return CredentialField(
padding: const EdgeInsets.only(top: 10),
child: CredentialField(
padding: EdgeInsets.zero,
title: title,
value: data,
titleColor: Theme.of(context).colorScheme.titleColor,
valueColor: Theme.of(context).colorScheme.valueColor,
showVertically: showVertically,
),
title: title,
value: data,
titleColor: Theme.of(context).colorScheme.titleColor,
valueColor: Theme.of(context).colorScheme.valueColor,
showVertically: showVertically,
);
}).toList(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@ class DeferredCredentialData extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 10),
CredentialField(
padding: EdgeInsets.zero,
padding: const EdgeInsets.only(top: 10),
title: l10n.issuer,
value: credentialModel.pendingInfo!.issuer ?? '',
titleColor: Theme.of(context).colorScheme.titleColor,
valueColor: Theme.of(context).colorScheme.valueColor,
showVertically: showVertically,
),
const SizedBox(height: 10),
CredentialField(
padding: EdgeInsets.zero,
padding: const EdgeInsets.only(top: 10),
title: l10n.dateOfRequest,
value: UiDate.formatDate(
credentialModel.pendingInfo!.requestedAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,16 @@ class DeveloperDetails extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 10),
CredentialField(
padding: EdgeInsets.zero,
padding: const EdgeInsets.only(top: 10),
title: l10n.format,
value: credentialModel.getFormat,
titleColor: Theme.of(context).colorScheme.titleColor,
valueColor: Theme.of(context).colorScheme.valueColor,
showVertically: showVertically,
),
const SizedBox(height: 10),
CredentialField(
padding: EdgeInsets.zero,
padding: const EdgeInsets.only(top: 10),
title: l10n.issuerDID,
value: issuerDid,
titleColor: Theme.of(context).colorScheme.titleColor,
Expand All @@ -46,20 +44,17 @@ class DeveloperDetails extends StatelessWidget {
),
if (credentialModel.credentialPreview.credentialSubjectModel
is! WalletCredentialModel &&
subjectDid.isNotEmpty) ...[
const SizedBox(height: 10),
subjectDid.isNotEmpty)
CredentialField(
padding: EdgeInsets.zero,
padding: const EdgeInsets.only(top: 10),
title: l10n.subjectDID,
value: subjectDid,
titleColor: Theme.of(context).colorScheme.titleColor,
valueColor: Theme.of(context).colorScheme.valueColor,
showVertically: showVertically,
),
],
const SizedBox(height: 10),
CredentialField(
padding: EdgeInsets.zero,
padding: const EdgeInsets.only(top: 10),
title: l10n.type,
value: type,
titleColor: Theme.of(context).colorScheme.titleColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:altme/l10n/l10n.dart';
import 'package:altme/theme/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:jwt_decode/jwt_decode.dart';

class WalletCredentialWidget extends StatelessWidget {
const WalletCredentialWidget({
Expand Down Expand Up @@ -43,37 +44,51 @@ class WalletCredentialetailsWidget extends StatelessWidget {
final titleColor = Theme.of(context).colorScheme.titleColor;
final valueColor = Theme.of(context).colorScheme.valueColor;

final isDeveloperMode =
context.read<ProfileCubit>().state.model.isDeveloperMode;

final walletCredential = credentialModel
.credentialPreview.credentialSubjectModel as WalletCredentialModel;

final walletAttestationData = credentialModel.jwt;

dynamic uri;
dynamic idx;

if (isDeveloperMode && walletAttestationData != null) {
final payload = JWTDecode().parseJwt(walletAttestationData);
final status = payload['status'];
if (status != null && status is Map<String, dynamic>) {
final statusList = status['status_list'];
if (statusList != null && statusList is Map<String, dynamic>) {
uri = statusList['uri'];
idx = statusList['idx'];
}
}
}

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (context.read<ProfileCubit>().state.model.isDeveloperMode) ...[
const SizedBox(height: 10),
if (isDeveloperMode)
CredentialField(
padding: EdgeInsets.zero,
padding: const EdgeInsets.only(top: 10),
title: l10n.publicKeyOfWalletInstance,
value: walletCredential.publicKey ?? '',
titleColor: titleColor,
valueColor: valueColor,
showVertically: false,
),
const SizedBox(height: 10),
] else ...[
const SizedBox(height: 10),
],
CredentialField(
padding: EdgeInsets.zero,
padding: const EdgeInsets.only(top: 10),
title: l10n.walletInstanceKey,
value: walletCredential.walletInstanceKey ?? '',
titleColor: titleColor,
valueColor: valueColor,
showVertically: false,
),
const SizedBox(height: 10),
CredentialField(
padding: EdgeInsets.zero,
padding: const EdgeInsets.only(top: 10),
title: l10n.issuanceDate,
value: UiDate.formatDateForCredentialCard(
credentialModel.credentialPreview.issuanceDate,
Expand All @@ -82,9 +97,8 @@ class WalletCredentialetailsWidget extends StatelessWidget {
valueColor: valueColor,
showVertically: false,
),
const SizedBox(height: 10),
CredentialField(
padding: EdgeInsets.zero,
padding: const EdgeInsets.only(top: 10),
title: l10n.expirationDate,
value: UiDate.formatDateForCredentialCard(
credentialModel.credentialPreview.expirationDate,
Expand All @@ -93,6 +107,28 @@ class WalletCredentialetailsWidget extends StatelessWidget {
valueColor: valueColor,
showVertically: false,
),
if (context.read<ProfileCubit>().state.model.isDeveloperMode) ...[
if (uri != null) ...[
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.statusList,
value: uri.toString(),
titleColor: titleColor,
valueColor: valueColor,
showVertically: false,
),
],
if (idx != null) ...[
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.statusListIndex,
value: idx.toString(),
titleColor: titleColor,
valueColor: valueColor,
showVertically: false,
),
],
],
],
);
}
Expand Down
6 changes: 2 additions & 4 deletions lib/enterprise/cubit/enterprise_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,8 @@ class EnterpriseCubit extends Cubit<EnterpriseState> {
}
}

await profileCubit.secureStorageProvider.set(
SecureStorageKeys.walletAttestationData,
jwtVc,
);
await profileCubit.secureStorageProvider
.set(SecureStorageKeys.walletAttestationData, jwtVc);

return jwtVc;
}
Expand Down
4 changes: 3 additions & 1 deletion lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1053,5 +1053,7 @@
"walletMetadataForIssuers": "Wallet metadata for issuers",
"walletMetadataForVerifiers": "Wallet metadata for verifiers",
"statusListCachingTitle": "StatusList caching",
"statusListCachingSubTitle": "Default: On\nSwitch off to reload StatusList when needed"
"statusListCachingSubTitle": "Default: On\nSwitch off to reload StatusList when needed",
"statusList": "Status list",
"statusListIndex": "Status list index"
}
12 changes: 9 additions & 3 deletions lib/l10n/untranslated.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"walletMetadataForIssuers",
"walletMetadataForVerifiers",
"statusListCachingTitle",
"statusListCachingSubTitle"
"statusListCachingSubTitle",
"statusList",
"statusListIndex"
],

"es": [
Expand All @@ -44,7 +46,9 @@
"walletMetadataForIssuers",
"walletMetadataForVerifiers",
"statusListCachingTitle",
"statusListCachingSubTitle"
"statusListCachingSubTitle",
"statusList",
"statusListIndex"
],

"fr": [
Expand All @@ -58,6 +62,8 @@
"walletMetadataForIssuers",
"walletMetadataForVerifiers",
"statusListCachingTitle",
"statusListCachingSubTitle"
"statusListCachingSubTitle",
"statusList",
"statusListIndex"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,13 @@ class DisplaySelectiveDisclosure extends StatelessWidget {
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Padding(
CredentialField(
padding: EdgeInsets.only(top: isFirstElement ? 10 : 0),
child: CredentialField(
padding: EdgeInsets.zero,
title: title,
value: claims.data,
titleColor: Theme.of(context).colorScheme.titleColor,
valueColor: Theme.of(context).colorScheme.valueColor,
showVertically: showVertically,
),
title: title,
value: claims.data,
titleColor: Theme.of(context).colorScheme.titleColor,
valueColor: Theme.of(context).colorScheme.valueColor,
showVertically: showVertically,
),
if (selectedClaimsKeyIds != null &&
claims.isfromDisclosureOfJWT) ...[
Expand Down

0 comments on commit d0b34be

Please sign in to comment.