Skip to content

Commit

Permalink
recursive build of SD lists
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed Mar 14, 2024
1 parent 112830e commit 11699ff
Show file tree
Hide file tree
Showing 13 changed files with 301 additions and 191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/dashboard/home/tab_bar/credentials/models/activity/activity.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:altme/polygon_id/polygon_id.dart';
import 'package:altme/selective_disclosure/widget/display_selective_disclosure.dart';
import 'package:altme/theme/theme.dart';
import 'package:altme/wallet/cubit/wallet_cubit.dart';
import 'package:did_kit/did_kit.dart';
Expand Down Expand Up @@ -307,8 +308,9 @@ class _CredentialsDetailsViewState extends State<CredentialsDetailsView> {
null &&
widget.credentialModel.credentialSupported!
.containsKey('claims')) ...[
ClaimsData(
DisplaySelectiveDisclosure(
credentialModel: widget.credentialModel,
claims: null,
),
],

Expand Down
148 changes: 0 additions & 148 deletions lib/dashboard/home/tab_bar/credentials/detail/widgets/claims_data.dart

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export 'claims_data.dart';
export 'credential_active_status.dart';
export 'credential_subject_data.dart';
export 'deferred_credential_data.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:altme/credentials/credentials.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:altme/scan/cubit/scan_cubit.dart';
import 'package:altme/selective_disclosure/widget/select_selective_disclosure.dart';
import 'package:credential_manifest/credential_manifest.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand Down Expand Up @@ -107,15 +108,16 @@ class SelectiveDisclosurePickView extends StatelessWidget {
child: credentialManifestState.filteredCredentialList.isEmpty
? const RequiredCredentialNotFound()
: BasePage(
title: l10n.credentialPickTitle,
title: l10n.thisOrganisationRequestsThisInformation,
titleAlignment: Alignment.topCenter,
titleTrailing: const WhiteCloseButton(),
padding: const EdgeInsets.symmetric(
vertical: 24,
horizontal: 16,
),
body: ClaimsData(
body: SelectSelectiveDisclosure(
credentialModel: credentialToBePresented,
claims: null,
),
navigation: SafeArea(
child: Container(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,30 @@ Widget vcSdJwtCredentialPickButton({
final l10n = context.l10n;

final button = SafeArea(
child: Container(
padding: const EdgeInsets.all(16),
child: Tooltip(
message: l10n.credentialPickPresent,
child: MyGradientButton(
onPressed: !credentialManifestState.isButtonEnabled
? null
: () => Navigator.of(context).pushReplacement<void, void>(
SelectiveDisclosurePickPage.route(
uri: uri,
issuer: issuer,
credential: credential,
credentialToBePresented:
credentialManifestState.filteredCredentialList[
credentialManifestState.selected.first],
child: Container(
padding: const EdgeInsets.all(16),
child: Tooltip(
message: l10n.credentialPickPresent,
child: MyGradientButton(
onPressed: !credentialManifestState.isButtonEnabled
? null
: () => Navigator.of(context).pushReplacement<void, void>(
SelectiveDisclosurePickPage.route(
uri: uri,
issuer: issuer,
credential: credential,
credentialToBePresented:
credentialManifestState.filteredCredentialList[
credentialManifestState.selected.first],
),
),
),

/// next button because we will now choose the claims we will present
/// from the selected credential
text: l10n.next,
/// next button because we will now choose the claims we will present
/// from the selected credential
text: l10n.next,
),
),
),
));
);
return button;
}
2 changes: 1 addition & 1 deletion lib/l10n/arb/app_ca.arb
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@
"createWalletMessage": "Crea una cartera primer.",
"successfullyGeneratingProof": "Prova generada correctament",
"wouldYouLikeToAcceptThisCredentialsFromThisOrganisation": "Vols acceptar aquesta/es credencial/s d’aquesta organització?",
"thisOrganisationRequestsThisInformation": "L’organització demana aquesta informació",
"thisOrganisationRequestsThisInformation": "L’organització demana",
"iS": "és",
"isSmallerThan": "és inferior a",
"isBiggerThan": "és superior a",
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@
"createWalletMessage": "Please create your wallet first.",
"successfullyGeneratingProof": "Successfully Generated Proof",
"wouldYouLikeToAcceptThisCredentialsFromThisOrganisation": "Would you like to accept this credential(s) from this organisation?",
"thisOrganisationRequestsThisInformation": "This organisation requests this information",
"thisOrganisationRequestsThisInformation": "This organisation requests",
"iS": "is",
"isSmallerThan": "is smaller than",
"isBiggerThan": "is bigger than",
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/arb/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@
"createWalletMessage": "Primero cree su cartera.",
"successfullyGeneratingProof": "Prueba generada",
"wouldYouLikeToAcceptThisCredentialsFromThisOrganisation": "¿Desea aceptar esta(s) credencial(es) de esta organización?",
"thisOrganisationRequestsThisInformation": "Esta organización solicita esta información",
"thisOrganisationRequestsThisInformation": "Esta organización solicita",
"iS": "es",
"isSmallerThan": "es menor que",
"isBiggerThan": "es mayor que",
Expand Down
4 changes: 2 additions & 2 deletions lib/l10n/arb/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"credentialPresentRequiredCredential": "Quelqu'un demande votre",
"credentialPresentConfirm": "Sélectionnez les documents",
"credentialPresentCancel": "Rejeter",
"credentialPickPresent": "Présent",
"credentialPickPresent": "Présente",
"credentialPickTitle": "Sélectionnez les documents",
"selectYourTezosAssociatedWallet": "Sélectionnez votre portefeuille associé Tezos",
"credentialPickSelect": "Sélectionnez votre identifiant",
Expand Down Expand Up @@ -887,7 +887,7 @@
"createWalletMessage": "Veuillez d'abord créer votre portefeuille.",
"successfullyGeneratingProof": "Preuve générée avec Succès",
"wouldYouLikeToAcceptThisCredentialsFromThisOrganisation": "Souhaitez-vous accepter ce(s) document(s) ?",
"thisOrganisationRequestsThisInformation": "Cette organisation demande cette information",
"thisOrganisationRequestsThisInformation": "Cette organisation demande",
"iS": "est",
"isSmallerThan": "est inférieur à",
"isBiggerThan": "est supérieur à",
Expand Down
51 changes: 51 additions & 0 deletions lib/selective_disclosure/selective_disclosure.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'dart:convert';

import 'package:altme/dashboard/home/tab_bar/credentials/models/credential_model/credential_model.dart';

class SelectiveDisclosure {
SelectiveDisclosure(this.credentialModel);
final CredentialModel credentialModel;

Map<String, dynamic> get claims {
final credentialSupported = credentialModel.credentialSupported;

final claims = credentialSupported!['claims'];

if (claims is! Map<String, dynamic>) {
return <String, dynamic>{};
}

return claims;
}

Map<String, dynamic> get values {
final encryptedValues = credentialModel.jwt?.split('~');
final extractedValues = <String, dynamic>{};
if (encryptedValues != null) {
encryptedValues.removeAt(0);

for (var element in encryptedValues) {
try {
while (element.length % 4 != 0) {
element += '=';
}

final decryptedData = utf8.decode(base64Decode(element));

if (decryptedData.isNotEmpty) {
final lisString = jsonDecode(decryptedData);
if (lisString is List) {
if (lisString.length == 3) {
extractedValues[lisString[1].toString()] = lisString[2];
}
}
}
} catch (e) {
//
}
}
}
return extractedValues;

}
}
Loading

0 comments on commit 11699ff

Please sign in to comment.