Skip to content

Commit

Permalink
recursive selective disclosure issue #3136
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed Dec 3, 2024
1 parent cbbde3d commit e6fe189
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 53 deletions.
14 changes: 13 additions & 1 deletion lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,19 @@ Map<String, dynamic> createJsonByDecryptingSDValues({
final content = sh256HashToContent[sdValue];
if (content is Map) {
content.forEach((key, value) {
json[key.toString()] = value;
if (value is Map<String, dynamic>) {
if (value.containsKey('_sd')) {
final nestedJson = createJsonByDecryptingSDValues(
selectiveDisclosure: selectiveDisclosure,
encryptedJson: value,
);
json[key.toString()] = nestedJson;
} else {
json[key.toString()] = value;
}
} else {
json[key.toString()] = value;
}
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ class DeveloperDetails extends StatelessWidget {
Widget build(BuildContext context) {
final l10n = context.l10n;

// final String issuerDid = credentialModel.credentialPreview.issuer;
// final String subjectDid =
// credentialModel.credentialPreview.credentialSubjectModel.id ?? '';
// final String type = credentialModel.credentialPreview.type.toString();

final titleColor = Theme.of(context).colorScheme.onSurface;
final valueColor = Theme.of(context).colorScheme.onSurface;

Expand Down Expand Up @@ -80,51 +75,6 @@ class DeveloperDetails extends StatelessWidget {
valueColor: valueColor,
showVertically: showVertically,
),
// CredentialField(
// padding: const EdgeInsets.only(top: 10),
// title: l10n.issuerDID,
// value: issuerDid,
// titleColor: titleColor,
// valueColor: valueColor,
// showVertically: showVertically,
// ),
// if (credentialModel.credentialPreview.credentialSubjectModel
// is! WalletCredentialModel &&
// subjectDid.isNotEmpty)
// CredentialField(
// padding: const EdgeInsets.only(top: 10),
// title: l10n.subjectDID,
// value: subjectDid,
// titleColor: titleColor,
// valueColor: valueColor,
// showVertically: showVertically,
// ),
// CredentialField(
// padding: const EdgeInsets.only(top: 10),
// title: l10n.type,
// value: type,
// titleColor: titleColor,
// valueColor: valueColor,
// showVertically: showVertically,
// ),
// if (statusListUri != null)
// CredentialField(
// padding: const EdgeInsets.only(top: 10),
// title: l10n.statusList,
// value: statusListUri.toString(),
// titleColor: titleColor,
// valueColor: valueColor,
// showVertically: false,
// ),
// if (statusListIndex != null)
// CredentialField(
// padding: const EdgeInsets.only(top: 10),
// title: l10n.statusListIndex,
// value: statusListIndex.toString(),
// titleColor: titleColor,
// valueColor: valueColor,
// showVertically: false,
// ),
if (header != null)
CredentialField(
padding: const EdgeInsets.only(top: 10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ class SelectiveDisclosureDisplayMap {
String? title,
) {
final value = element.value as Map<String, dynamic>;
final valueWithoutSd = Map<String, dynamic>.from(value);
valueWithoutSd.remove('_sd');
final builtMap = <String, dynamic>{};
value.remove('_sd');
if (value.isEmpty) {
if (valueWithoutSd.isEmpty) {
final mapNestedSelectiveDisclosure = SelectiveDisclosureDisplayMap(
credentialModel: credentialModel,
claims: const {},
Expand Down Expand Up @@ -213,6 +214,23 @@ class SelectiveDisclosureDisplayMap {
(entry) => entry.value.toString().contains(element.key.toString()),
);
if (index == -1) isDisabled = true;
if (value['_sd'] != null) {
value.addAll(
SelectiveDisclosureDisplayMap(
credentialModel: credentialModel,
isPresentation: isPresentation,
languageCode: languageCode,
limitDisclosure: limitDisclosure,
filters: filters,
isDeveloperMode: isDeveloperMode,
claims: claims,
parentKeyId: element.key.toString(),
selectedClaimsKeyIds: selectedClaimsKeyIds,
onPressed: onPressed,
).buildMap,
);
}

builtMap[title ?? element.key.toString()] = {
'mapKey': element.key.toString(),
'claimKey': element.key.toString(),
Expand Down

0 comments on commit e6fe189

Please sign in to comment.