Skip to content

Commit c7164a4

Browse files
author
Rob
committed
PVW-1402: Render disclosure request in wallet_app
* Update LocalizedStrings import Use the fully quilified path instead of importing the LocalizedStrings to avoid ambiguity with LocalizedString. * Update reader_auth.json Country has been renamed to countryCode, updating the field here to make sure it's provided correctly when generating the certs. * Remove privacy_policy_url from Organization * Reduce cloning in flutter_api disclosure models * Resolve purpose based on activeLocale * Avoid excessive cloning of reader_registration * Add is_first_interaction_with_relying_party TODO Make it explicit that this value still needs to be filled with non-mock data at some point. * Make policy_url conversion more rusty * Remove RequestPolicy from RequestAttributesMissing * Make data_storage_duration_days optional On the flutter side the value was already converted to a (secretly) optional storage duration, so that field is now explicitly optional, meaning the section related to the storage duration is hidden when unset. Kept the i64 type as that is what duration.num_days() returns and want to avoid things silently overflowing as a negligible optimisation. * Make countryCode explicit To avoid any ambiguity when it comes to dealing with the country field inside the Organization object, it is now renamed to country_code, to make it explicit we are dealing with a (ISO-3166-1 alpha-2) country code. * Implement from for LocalizedString Instead of using a trait to go from LocalizedStrings to a Vec<LocalizedString> use a From implementation by defining a wrapper struct (RPLocalizedStrings) that we do own in this crate. * Update sample reader_auth - Add a kvk - Update purpose statement * Update COCOAPODS * Simplify RelyingParty Instead of having a RelyingPartyInfo struct this commit aligns the RelyingParty model to be more in line with the Organization model. It also makes it explicit what (required) attributes are still missing on the wallet_app side. * Fix incorrectly displayed location label * Refactor to .map over match Instead of using the match statement to map to the correct value, use the map function instead. * Align organization naming (legal/display) * Update wallet_app with for new RelyingParty Update the wallet_app so that it supports the new RelyingParty model which now includes more localized strings. * Update RelyingParty and From implementation Update the RelyingParty model in wallet_core with newly introduced fields and update the 'impl From<ReaderRegistration> for RelyingParty' so that these fields are actually passed on to the wallet_app. * Add missing RelyingParty fields * Extract LocalizedText Since the LocalizedText is used in other classes besides the Attribute the typealias is now extracted to a separate class. * Introduce RelyingPartyInfo & Localizations Make some of the RelyingParty(Info) fields translatable and add the missing RelyingParty fields as part of the new RelyingPartyInfo class. * Maintain purpose onBackPressed * Pass policy and purpose to the UI Update the DisclosureResult model and the corresponding UI state so that the policy and purpose coming from the core can be rendered in the UI. * Refactor hasPreviouslyInteractedWithOrganization Rename hasPreviouslyInteractedWithOrganization to isFirstInteractionWithOrganization so we use more consistent naming everywhere and thus don't have to flip the boolean value in the organization_detail_bloc. * Pass organization to OrganizationDetailScreen * Expand DisclosureResult model Expand the DisclosureResult and RelyingParty models to include more metadata as required by the UI.
1 parent 3ea1cae commit c7164a4

File tree

68 files changed

+808
-303
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+808
-303
lines changed

scripts/devenv/reader_auth.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"en": "My Service Name"
66
},
77
"purposeStatement": {
8-
"nl": "Beschrijving van mijn dienst",
9-
"en": "My Service Description"
8+
"nl": "Reden voor dit verzoek",
9+
"en": "Purpose of this request"
1010
},
1111
"retentionPolicy": {
1212
"intentToRetain": true,
@@ -36,7 +36,8 @@
3636
"nl": "Den Haag",
3737
"en": "The Hague"
3838
},
39-
"country": "nl",
39+
"countryCode": "nl",
40+
"kvk": "5684 6846",
4041
"privacyPolicyUrl": "https://example.com/privacy"
4142
},
4243
"attributes": {

wallet_app/lib/bridge_generated.dart

Lines changed: 82 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,36 @@ enum PinValidationResult {
203203
}
204204

205205
class RelyingParty {
206-
final String name;
206+
final List<LocalizedString> legalName;
207+
final List<LocalizedString> displayName;
208+
final List<LocalizedString> description;
209+
final String? webUrl;
210+
final String? kvk;
211+
final List<LocalizedString>? city;
212+
final String? countryCode;
207213

208214
const RelyingParty({
209-
required this.name,
215+
required this.legalName,
216+
required this.displayName,
217+
required this.description,
218+
this.webUrl,
219+
this.kvk,
220+
this.city,
221+
this.countryCode,
222+
});
223+
}
224+
225+
class RequestPolicy {
226+
final int? dataStorageDurationDays;
227+
final bool dataSharedWithThirdParties;
228+
final bool dataDeletionPossible;
229+
final String policyUrl;
230+
231+
const RequestPolicy({
232+
this.dataStorageDurationDays,
233+
required this.dataSharedWithThirdParties,
234+
required this.dataDeletionPossible,
235+
required this.policyUrl,
210236
});
211237
}
212238

@@ -224,11 +250,16 @@ class RequestedCard {
224250
class StartDisclosureResult with _$StartDisclosureResult {
225251
const factory StartDisclosureResult.request({
226252
required RelyingParty relyingParty,
253+
required RequestPolicy policy,
227254
required List<RequestedCard> requestedCards,
255+
required bool isFirstInteractionWithRelyingParty,
256+
required List<LocalizedString> requestPurpose,
228257
}) = StartDisclosureResult_Request;
229258
const factory StartDisclosureResult.requestAttributesMissing({
230259
required RelyingParty relyingParty,
231260
required List<MissingAttribute> missingAttributes,
261+
required bool isFirstInteractionWithRelyingParty,
262+
required List<LocalizedString> requestPurpose,
232263
}) = StartDisclosureResult_RequestAttributesMissing;
233264
}
234265

@@ -645,10 +676,18 @@ class WalletCoreImpl implements WalletCore {
645676
return raw as bool;
646677
}
647678

679+
int _wire2api_box_autoadd_i64(dynamic raw) {
680+
return _wire2api_i64(raw);
681+
}
682+
648683
RelyingParty _wire2api_box_autoadd_relying_party(dynamic raw) {
649684
return _wire2api_relying_party(raw);
650685
}
651686

687+
RequestPolicy _wire2api_box_autoadd_request_policy(dynamic raw) {
688+
return _wire2api_request_policy(raw);
689+
}
690+
652691
Card _wire2api_card(dynamic raw) {
653692
final arr = raw as List<dynamic>;
654693
if (arr.length != 3) throw Exception('unexpected arr length: expect 3 but see ${arr.length}');
@@ -722,6 +761,10 @@ class WalletCoreImpl implements WalletCore {
722761
return raw as int;
723762
}
724763

764+
int _wire2api_i64(dynamic raw) {
765+
return castInt(raw);
766+
}
767+
725768
IdentifyUriResult _wire2api_identify_uri_result(dynamic raw) {
726769
return IdentifyUriResult.values[raw as int];
727770
}
@@ -763,15 +806,44 @@ class WalletCoreImpl implements WalletCore {
763806
);
764807
}
765808

809+
String? _wire2api_opt_String(dynamic raw) {
810+
return raw == null ? null : _wire2api_String(raw);
811+
}
812+
813+
int? _wire2api_opt_box_autoadd_i64(dynamic raw) {
814+
return raw == null ? null : _wire2api_box_autoadd_i64(raw);
815+
}
816+
817+
List<LocalizedString>? _wire2api_opt_list_localized_string(dynamic raw) {
818+
return raw == null ? null : _wire2api_list_localized_string(raw);
819+
}
820+
766821
PinValidationResult _wire2api_pin_validation_result(dynamic raw) {
767822
return PinValidationResult.values[raw as int];
768823
}
769824

770825
RelyingParty _wire2api_relying_party(dynamic raw) {
771826
final arr = raw as List<dynamic>;
772-
if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}');
827+
if (arr.length != 7) throw Exception('unexpected arr length: expect 7 but see ${arr.length}');
773828
return RelyingParty(
774-
name: _wire2api_String(arr[0]),
829+
legalName: _wire2api_list_localized_string(arr[0]),
830+
displayName: _wire2api_list_localized_string(arr[1]),
831+
description: _wire2api_list_localized_string(arr[2]),
832+
webUrl: _wire2api_opt_String(arr[3]),
833+
kvk: _wire2api_opt_String(arr[4]),
834+
city: _wire2api_opt_list_localized_string(arr[5]),
835+
countryCode: _wire2api_opt_String(arr[6]),
836+
);
837+
}
838+
839+
RequestPolicy _wire2api_request_policy(dynamic raw) {
840+
final arr = raw as List<dynamic>;
841+
if (arr.length != 4) throw Exception('unexpected arr length: expect 4 but see ${arr.length}');
842+
return RequestPolicy(
843+
dataStorageDurationDays: _wire2api_opt_box_autoadd_i64(arr[0]),
844+
dataSharedWithThirdParties: _wire2api_bool(arr[1]),
845+
dataDeletionPossible: _wire2api_bool(arr[2]),
846+
policyUrl: _wire2api_String(arr[3]),
775847
);
776848
}
777849

@@ -789,12 +861,17 @@ class WalletCoreImpl implements WalletCore {
789861
case 0:
790862
return StartDisclosureResult_Request(
791863
relyingParty: _wire2api_box_autoadd_relying_party(raw[1]),
792-
requestedCards: _wire2api_list_requested_card(raw[2]),
864+
policy: _wire2api_box_autoadd_request_policy(raw[2]),
865+
requestedCards: _wire2api_list_requested_card(raw[3]),
866+
isFirstInteractionWithRelyingParty: _wire2api_bool(raw[4]),
867+
requestPurpose: _wire2api_list_localized_string(raw[5]),
793868
);
794869
case 1:
795870
return StartDisclosureResult_RequestAttributesMissing(
796871
relyingParty: _wire2api_box_autoadd_relying_party(raw[1]),
797872
missingAttributes: _wire2api_list_missing_attribute(raw[2]),
873+
isFirstInteractionWithRelyingParty: _wire2api_bool(raw[3]),
874+
requestPurpose: _wire2api_list_localized_string(raw[4]),
798875
);
799876
default:
800877
throw Exception("unreachable");

0 commit comments

Comments
 (0)