From fc32f3d3f8d402797007039a63fad43b74ab787d Mon Sep 17 00:00:00 2001 From: nmoschos Date: Mon, 7 Oct 2024 17:17:07 +0300 Subject: [PATCH 1/9] Change wallet creation info messages --- src/BolWallet/Pages/WalletCreationInfo.razor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BolWallet/Pages/WalletCreationInfo.razor b/src/BolWallet/Pages/WalletCreationInfo.razor index 64e394e..2eeef63 100644 --- a/src/BolWallet/Pages/WalletCreationInfo.razor +++ b/src/BolWallet/Pages/WalletCreationInfo.razor @@ -30,10 +30,10 @@ - + - + From 460907175b9e54230a310b4d255105f0b7deb381 Mon Sep 17 00:00:00 2001 From: nmoschos Date: Mon, 7 Oct 2024 17:20:56 +0300 Subject: [PATCH 2/9] Fix default hash in EncryptedCitizenshipForm --- src/BolWallet/Constants.cs | 3 ++- src/BolWallet/Pages/EcryptedCitizenshipPage.razor | 9 ++++----- src/BolWallet/ViewModels/SubmitCitizenshipViewModel.cs | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/BolWallet/Constants.cs b/src/BolWallet/Constants.cs index 6949b78..3f11d6c 100644 --- a/src/BolWallet/Constants.cs +++ b/src/BolWallet/Constants.cs @@ -9,7 +9,8 @@ internal class Constants public const string BirthDateFormat = "yyyy-MM-dd"; public const string MainNet = "mainnet"; public const string TestNet = "testnet"; - + public const string DefaultHash = "0000000000000000000000000000000000000000000000000000000000000000"; + // Preferences Keys public const string TargetNet = "target-net"; diff --git a/src/BolWallet/Pages/EcryptedCitizenshipPage.razor b/src/BolWallet/Pages/EcryptedCitizenshipPage.razor index e0b7b7c..e634a89 100644 --- a/src/BolWallet/Pages/EcryptedCitizenshipPage.razor +++ b/src/BolWallet/Pages/EcryptedCitizenshipPage.razor @@ -339,13 +339,12 @@ { var submittedForm = context.Model as EncryptedCitizenshipForm; - if(false){ - await ViewModel.SubmitFormCommand.ExecuteAsync(submittedForm); - + if (ViewModel.IsSha256InputMode) + { + await ViewModel.SubmitHashFormCommand.ExecuteAsync(submittedForm); } else{ - await ViewModel.SubmitHashFormCommand.ExecuteAsync(submittedForm); - + await ViewModel.SubmitFormCommand.ExecuteAsync(submittedForm); } } catch (Exception ex) diff --git a/src/BolWallet/ViewModels/SubmitCitizenshipViewModel.cs b/src/BolWallet/ViewModels/SubmitCitizenshipViewModel.cs index fc0a6e3..02e0c02 100644 --- a/src/BolWallet/ViewModels/SubmitCitizenshipViewModel.cs +++ b/src/BolWallet/ViewModels/SubmitCitizenshipViewModel.cs @@ -318,11 +318,11 @@ await Task.Run((Func)(async () => var citizenshipHashes = new CitizenshipHashTable { - IdentityCard = form.IdentityCardSha256?.ToUpper() ?? null, - IdentityCardBack = form.IdentityCardBackSha256?.ToUpper() ?? null, - Passport = form.PassportSha256?.ToUpper() ?? null, - ProofOfNin = form.ProofOfNinSha256?.ToUpper() ?? null, - BirthCertificate = form.BirthCertificateSha256?.ToUpper() ?? null + IdentityCard = form.IdentityCardSha256?.ToUpper() ?? Constants.DefaultHash, + IdentityCardBack = form.IdentityCardBackSha256?.ToUpper() ?? Constants.DefaultHash, + Passport = form.PassportSha256?.ToUpper() ?? Constants.DefaultHash, + ProofOfNin = form.ProofOfNinSha256?.ToUpper() ?? Constants.DefaultHash, + BirthCertificate = form.BirthCertificateSha256?.ToUpper() ?? Constants.DefaultHash }; var encryptedCitizenshipData = new EncryptedCitizenshipData From 916ac257f252b378ca793790ab021607c060d849 Mon Sep 17 00:00:00 2001 From: nmoschos Date: Mon, 7 Oct 2024 17:21:04 +0300 Subject: [PATCH 3/9] Only capital letters and numbers validation for sha256 --- .../Models/EncryptedCitizenshipForm.cs | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/src/BolWallet/Models/EncryptedCitizenshipForm.cs b/src/BolWallet/Models/EncryptedCitizenshipForm.cs index 33b96e4..43bf08f 100644 --- a/src/BolWallet/Models/EncryptedCitizenshipForm.cs +++ b/src/BolWallet/Models/EncryptedCitizenshipForm.cs @@ -47,20 +47,55 @@ public string ThirdName set => _thirdName = value?.ToUpper() ?? ""; } + private string _identityCardSha256; + + [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] - public string IdentityCardSha256 { get; set; } + public string IdentityCardSha256 + { + get => _identityCardSha256; + set => _identityCardSha256 = value?.ToUpper() ?? ""; + } + + private string _identityCardBackSha256; + [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] - public string IdentityCardBackSha256 { get; set; } + public string IdentityCardBackSha256 + { + get => _identityCardBackSha256; + set => _identityCardBackSha256 = value?.ToUpper() ?? ""; + } + private string _passportSha256; + + [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] - public string PassportSha256 { get; set; } + public string PassportSha256 + { + get => _passportSha256; + set => _passportSha256 = value?.ToUpper() ?? ""; + } + + private string _proofOfNinSha256; + [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] - public string ProofOfNinSha256 { get; set; } + public string ProofOfNinSha256 + { + get => _proofOfNinSha256; + set => _proofOfNinSha256 = value?.ToUpper() ?? ""; + } + private string _birthCertificateSha256; + + [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] - public string BirthCertificateSha256 { get; set; } + public string BirthCertificateSha256 + { + get => _birthCertificateSha256; + set => _birthCertificateSha256 = value?.ToUpper() ?? ""; + } } public class EncryptedCitizenshipData From 7b27c4a89cf214404558d4cc37aae52c1606d3f9 Mon Sep 17 00:00:00 2001 From: nmoschos Date: Tue, 8 Oct 2024 16:36:21 +0300 Subject: [PATCH 4/9] Integrate SHA256 input form on GenericHashTableForm --- src/BolWallet/Models/GenericHashTableForm.cs | 67 ++++++++- src/BolWallet/Pages/CreateEdiPage.razor | 127 +++++++++++++----- .../ViewModels/CreateEdiViewModel.cs | 23 ++++ 3 files changed, 186 insertions(+), 31 deletions(-) diff --git a/src/BolWallet/Models/GenericHashTableForm.cs b/src/BolWallet/Models/GenericHashTableForm.cs index 869b76d..a0c99c8 100644 --- a/src/BolWallet/Models/GenericHashTableForm.cs +++ b/src/BolWallet/Models/GenericHashTableForm.cs @@ -1,4 +1,6 @@ -namespace BolWallet.Models +using System.ComponentModel.DataAnnotations; + +namespace BolWallet.Models { public partial class GenericHashTableForm : ObservableObject { @@ -13,5 +15,68 @@ public partial class GenericHashTableForm : ObservableObject public string PersonalVoice { get; set; } public string ProofOfCommunication { get; set; } public string ProofOfResidence { get; set; } + } + + public class GenericSHA256TableForm : ObservableObject + { + private string _drivingLicense; + + [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] + public string DrivingLicense + { + get => _drivingLicense; + set => _drivingLicense = value?.ToUpper() ?? ""; + } + + private string _otherIdentity; + + [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] + public string OtherIdentity + { + get => _otherIdentity; + set => _otherIdentity = value?.ToUpper() ?? ""; + } + + private string _facePhoto; + + [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] + public string FacePhoto + { + get => _facePhoto; + set => _facePhoto = value?.ToUpper() ?? ""; + } + + private string _personalVoice; + + [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] + public string PersonalVoice + { + get => _personalVoice; + set => _personalVoice = value?.ToUpper() ?? ""; + } + + private string _proofOfCommunication; + + [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] + public string ProofOfCommunication + { + get => _proofOfCommunication; + set => _proofOfCommunication = value?.ToUpper() ?? ""; + } + + private string _proofOfResidence; + + [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] + public string ProofOfResidence + { + get => _proofOfResidence; + set => _proofOfResidence = value?.ToUpper() ?? ""; + } } } diff --git a/src/BolWallet/Pages/CreateEdiPage.razor b/src/BolWallet/Pages/CreateEdiPage.razor index 2bb0923..9feefcb 100644 --- a/src/BolWallet/Pages/CreateEdiPage.razor +++ b/src/BolWallet/Pages/CreateEdiPage.razor @@ -11,32 +11,91 @@ - + + + @if (ViewModel.IsSha256InputMode) + { - - @edi.Item4 - @if (edi.Item1 == "PersonalVoice") - { - - - } - else - { - - - - } - + + + + + + + + + + + + + + + + +
+ Submit +
+
+
+
-
- -
- Submit -
-
+ + } + else + { + + + + @edi.Item4 + @if (edi.Item1 == "PersonalVoice") + { + + + } + else + { + + + + } + + + + +
+ Submit +
+
+ }
@if (ViewModel.IsRecording) @@ -54,7 +113,7 @@ .text-center { text-align: center; } - + .recording-overlay { position: fixed; top: 0; @@ -67,7 +126,7 @@ align-items: center; justify-content: center; } - + .recording-dialog { background-color: white; padding: 20px; @@ -78,6 +137,7 @@ } + @code { CreateEdiViewModel createEdiViewModel; @@ -112,8 +172,15 @@ ViewModel.IsLoading = true; StateHasChanged(); }); - - await createEdiViewModel.SubmitCommand.ExecuteAsync(null); + + if (ViewModel.IsSha256InputMode) + { + await createEdiViewModel.SubmitHashFormCommand.ExecuteAsync(null); + } + else + { + await createEdiViewModel.SubmitCommand.ExecuteAsync(null); + } await InvokeAsync(() => { @@ -149,7 +216,7 @@ ViewModel.IsLoading = true; StateHasChanged(); }); - + await UpdateIdentificationDocumentsList(property); } catch (Exception e) @@ -179,7 +246,7 @@ ViewModel.IsLoading = true; StateHasChanged(); }); - + await UpdateIdentificationDocumentsList(property); } catch (Exception e) diff --git a/src/BolWallet/ViewModels/CreateEdiViewModel.cs b/src/BolWallet/ViewModels/CreateEdiViewModel.cs index 59374dc..1e1fbd5 100644 --- a/src/BolWallet/ViewModels/CreateEdiViewModel.cs +++ b/src/BolWallet/ViewModels/CreateEdiViewModel.cs @@ -30,6 +30,7 @@ public CreateEdiViewModel( _mediaService = mediaService; _certificationMatrix = new CertificationMatrix { Hashes = new GenericHashTable() }; GenericHashTableForm = new GenericHashTableForm(); + GenericSHA256TableForm = new GenericSHA256TableForm(); EdiFiles = new GenericHashTableFiles(); } @@ -37,10 +38,19 @@ public CreateEdiViewModel( [ObservableProperty] private GenericHashTableForm _genericHashTableForm; + [ObservableProperty] private GenericSHA256TableForm _genericSHA256TableForm; + [ObservableProperty] private bool _isLoading = false; [ObservableProperty] private bool _isRecording = false; + [ObservableProperty] private bool _isSha256InputMode; + + public void OnKnownHashInputModeChange(bool newValue) + { + IsSha256InputMode = newValue; + } + [RelayCommand] private async Task PickFileAsync(string propertyName) { @@ -160,6 +170,19 @@ private async Task Submit() } } + [RelayCommand] + private async Task SubmitHashForm() + { + _certificationMatrix.Hashes.FacePhoto = GenericSHA256TableForm.FacePhoto?.ToUpper() ?? Constants.DefaultHash; + _certificationMatrix.Hashes.PersonalVoice = GenericSHA256TableForm.PersonalVoice?.ToUpper() ?? Constants.DefaultHash; + _certificationMatrix.Hashes.DrivingLicense = GenericSHA256TableForm.DrivingLicense?.ToUpper() ?? Constants.DefaultHash; + _certificationMatrix.Hashes.OtherIdentity = GenericSHA256TableForm.OtherIdentity?.ToUpper() ?? Constants.DefaultHash; + _certificationMatrix.Hashes.ProofOfCommunication = GenericSHA256TableForm.ProofOfCommunication?.ToUpper() ?? Constants.DefaultHash; + _certificationMatrix.Hashes.ProofOfResidence = GenericSHA256TableForm.ProofOfResidence?.ToUpper() ?? Constants.DefaultHash; + + await Submit(); + } + private async Task PathPerImport(PropertyInfo propertyNameInfo, FileResult fileResult) { if (fileResult == null) return; From 4eebe00f9741330aea5ea5c31a0c683d5420ca2c Mon Sep 17 00:00:00 2001 From: nmoschos Date: Tue, 8 Oct 2024 21:42:51 +0300 Subject: [PATCH 5/9] Replace A-Z TO A-F regex --- src/BolWallet/Models/EncryptedCitizenshipForm.cs | 10 +++++----- src/BolWallet/Models/GenericHashTableForm.cs | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/BolWallet/Models/EncryptedCitizenshipForm.cs b/src/BolWallet/Models/EncryptedCitizenshipForm.cs index 43bf08f..0dd33d0 100644 --- a/src/BolWallet/Models/EncryptedCitizenshipForm.cs +++ b/src/BolWallet/Models/EncryptedCitizenshipForm.cs @@ -49,7 +49,7 @@ public string ThirdName private string _identityCardSha256; - [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [RegularExpression("^[A-F0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] public string IdentityCardSha256 { @@ -59,7 +59,7 @@ public string IdentityCardSha256 private string _identityCardBackSha256; - [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [RegularExpression("^[A-F0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] public string IdentityCardBackSha256 { @@ -69,7 +69,7 @@ public string IdentityCardBackSha256 private string _passportSha256; - [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [RegularExpression("^[A-F0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] public string PassportSha256 { @@ -79,7 +79,7 @@ public string PassportSha256 private string _proofOfNinSha256; - [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [RegularExpression("^[A-F0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] public string ProofOfNinSha256 { @@ -89,7 +89,7 @@ public string ProofOfNinSha256 private string _birthCertificateSha256; - [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [RegularExpression("^[A-F0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] public string BirthCertificateSha256 { diff --git a/src/BolWallet/Models/GenericHashTableForm.cs b/src/BolWallet/Models/GenericHashTableForm.cs index a0c99c8..fa2545a 100644 --- a/src/BolWallet/Models/GenericHashTableForm.cs +++ b/src/BolWallet/Models/GenericHashTableForm.cs @@ -21,7 +21,7 @@ public class GenericSHA256TableForm : ObservableObject { private string _drivingLicense; - [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [RegularExpression("^[A-F0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] public string DrivingLicense { @@ -31,7 +31,7 @@ public string DrivingLicense private string _otherIdentity; - [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [RegularExpression("^[A-F0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] public string OtherIdentity { @@ -41,7 +41,7 @@ public string OtherIdentity private string _facePhoto; - [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [RegularExpression("^[A-F0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] public string FacePhoto { @@ -51,7 +51,7 @@ public string FacePhoto private string _personalVoice; - [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [RegularExpression("^[A-F0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] public string PersonalVoice { @@ -61,7 +61,7 @@ public string PersonalVoice private string _proofOfCommunication; - [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [RegularExpression("^[A-F0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] public string ProofOfCommunication { @@ -71,7 +71,7 @@ public string ProofOfCommunication private string _proofOfResidence; - [RegularExpression("^[A-Z0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] + [RegularExpression("^[A-F0-9]*$", ErrorMessage = "Only capital letters and numbers are allowed.")] [StringLength(64, MinimumLength = 64, ErrorMessage = "The SHA-256 hash must be exactly 64 characters.")] public string ProofOfResidence { From d0cceb22d0a3b768847694df45fb3384d5aeef28 Mon Sep 17 00:00:00 2001 From: Theofanis Tokas Date: Tue, 8 Oct 2024 23:00:09 +0300 Subject: [PATCH 6/9] Send a message about wallet creation so BolService can be disposed before re-use This will ensure that instances needed after wallet creation will properly get access to the new wallet data. This is needed because an IBolService instance is already created to be used to validate the new codename during wallet creation, thus it cannot be re-used after wallet creation, since it uses an IOptions instance that doesn't contain the new wallet data, so the service needs to be re-initialized. --- src/BolWallet/Constants.cs | 1 + .../Models/Messages/WalletCreatedMessage.cs | 3 +++ src/BolWallet/Services/BolServiceFactory.cs | 12 ++++++++++-- .../GenerateWalletWithPasswordViewModel.cs | 11 +++++++---- 4 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 src/BolWallet/Models/Messages/WalletCreatedMessage.cs diff --git a/src/BolWallet/Constants.cs b/src/BolWallet/Constants.cs index 6949b78..680ca95 100644 --- a/src/BolWallet/Constants.cs +++ b/src/BolWallet/Constants.cs @@ -16,6 +16,7 @@ internal class Constants // Static messages to re-use public static readonly TargetNetworkChangedMessage TargetNetworkChangedMessage = new(); public static readonly WalletClosedMessage WalletClosedMessage = new(); + public static readonly WalletCreatedMessage WalletCreatedMessage = new(); public static readonly JsonSerializerOptions WalletJsonSerializerDefaultOptions = new() { diff --git a/src/BolWallet/Models/Messages/WalletCreatedMessage.cs b/src/BolWallet/Models/Messages/WalletCreatedMessage.cs new file mode 100644 index 0000000..67d695c --- /dev/null +++ b/src/BolWallet/Models/Messages/WalletCreatedMessage.cs @@ -0,0 +1,3 @@ +namespace BolWallet.Models.Messages; + +public record WalletCreatedMessage; diff --git a/src/BolWallet/Services/BolServiceFactory.cs b/src/BolWallet/Services/BolServiceFactory.cs index de8b7e9..894f09e 100644 --- a/src/BolWallet/Services/BolServiceFactory.cs +++ b/src/BolWallet/Services/BolServiceFactory.cs @@ -6,7 +6,7 @@ namespace BolWallet.Services; -public class BolServiceFactory : IRecipient +public class BolServiceFactory : IRecipient, IRecipient { private IServiceScope _serviceScope; private readonly IServiceScopeFactory _serviceScopeFactory; @@ -18,7 +18,8 @@ public BolServiceFactory( { _serviceScopeFactory = serviceScopeFactory; _logger = logger; - WeakReferenceMessenger.Default.Register(this); + WeakReferenceMessenger.Default.Register(this); + WeakReferenceMessenger.Default.Register(this); } public IBolService Create() @@ -33,4 +34,11 @@ public void Receive(WalletClosedMessage message) _serviceScope?.Dispose(); _serviceScope = null; } + + public void Receive(WalletCreatedMessage message) + { + _logger.LogInformation("Received {Message}, disposing BOL services so new instances get access to new wallet...", message.GetType().Name); + _serviceScope?.Dispose(); + _serviceScope = null; + } } diff --git a/src/BolWallet/ViewModels/GenerateWalletWithPasswordViewModel.cs b/src/BolWallet/ViewModels/GenerateWalletWithPasswordViewModel.cs index 1a54e8a..c2c4af9 100644 --- a/src/BolWallet/ViewModels/GenerateWalletWithPasswordViewModel.cs +++ b/src/BolWallet/ViewModels/GenerateWalletWithPasswordViewModel.cs @@ -1,8 +1,6 @@ using Bol.Core.Abstractions; -using Bol.Cryptography; using CommunityToolkit.Maui.Alerts; -using CommunityToolkit.Maui.Storage; -using System.Text; +using CommunityToolkit.Mvvm.Messaging; namespace BolWallet.ViewModels; @@ -12,19 +10,22 @@ public partial class GenerateWalletWithPasswordViewModel : BaseViewModel private readonly ISecureRepository _secureRepository; private readonly IFileDownloadService _fileDownloadService; private readonly IDeviceDisplay _deviceDisplay; + private readonly IMessenger _messenger; public GenerateWalletWithPasswordViewModel( INavigationService navigationService, IWalletService walletService, ISecureRepository secureRepository, IFileDownloadService fileDownloadService, - IDeviceDisplay deviceDisplay) + IDeviceDisplay deviceDisplay, + IMessenger messenger) : base(navigationService) { _walletService = walletService; _secureRepository = secureRepository; _fileDownloadService = fileDownloadService; _deviceDisplay = deviceDisplay; + _messenger = messenger; } [ObservableProperty] @@ -76,6 +77,8 @@ private async Task Submit() await DownloadWalletAsync(bolWallet); + _messenger.Send(Constants.WalletCreatedMessage); + await NavigationService.NavigateTo(); } catch (Exception ex) From e502167f4320d1ff8e45b2f9bcd5bd423a3c1a1a Mon Sep 17 00:00:00 2001 From: Theofanis Tokas Date: Tue, 8 Oct 2024 23:03:55 +0300 Subject: [PATCH 7/9] Use injected messenger instead of directly accessing the static instance --- src/BolWallet/Services/BolServiceFactory.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BolWallet/Services/BolServiceFactory.cs b/src/BolWallet/Services/BolServiceFactory.cs index 894f09e..91c4feb 100644 --- a/src/BolWallet/Services/BolServiceFactory.cs +++ b/src/BolWallet/Services/BolServiceFactory.cs @@ -14,12 +14,13 @@ public class BolServiceFactory : IRecipient, IRecipient logger) { _serviceScopeFactory = serviceScopeFactory; _logger = logger; - WeakReferenceMessenger.Default.Register(this); - WeakReferenceMessenger.Default.Register(this); + messenger.Register(this); + messenger.Register(this); } public IBolService Create() From 7633ea09c07c07874f164b2c12ac537725d45716 Mon Sep 17 00:00:00 2001 From: nmoschos Date: Wed, 9 Oct 2024 13:10:12 +0300 Subject: [PATCH 8/9] Refactor sha256 documents setter to exclude empty strings --- src/BolWallet/Models/EncryptedCitizenshipForm.cs | 10 +++++----- src/BolWallet/Models/GenericHashTableForm.cs | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/BolWallet/Models/EncryptedCitizenshipForm.cs b/src/BolWallet/Models/EncryptedCitizenshipForm.cs index 0dd33d0..78efe28 100644 --- a/src/BolWallet/Models/EncryptedCitizenshipForm.cs +++ b/src/BolWallet/Models/EncryptedCitizenshipForm.cs @@ -54,7 +54,7 @@ public string ThirdName public string IdentityCardSha256 { get => _identityCardSha256; - set => _identityCardSha256 = value?.ToUpper() ?? ""; + set => _identityCardSha256 = value?.ToUpper(); } private string _identityCardBackSha256; @@ -64,7 +64,7 @@ public string IdentityCardSha256 public string IdentityCardBackSha256 { get => _identityCardBackSha256; - set => _identityCardBackSha256 = value?.ToUpper() ?? ""; + set => _identityCardBackSha256 = value?.ToUpper(); } private string _passportSha256; @@ -74,7 +74,7 @@ public string IdentityCardBackSha256 public string PassportSha256 { get => _passportSha256; - set => _passportSha256 = value?.ToUpper() ?? ""; + set => _passportSha256 = value?.ToUpper(); } private string _proofOfNinSha256; @@ -84,7 +84,7 @@ public string PassportSha256 public string ProofOfNinSha256 { get => _proofOfNinSha256; - set => _proofOfNinSha256 = value?.ToUpper() ?? ""; + set => _proofOfNinSha256 = value?.ToUpper(); } private string _birthCertificateSha256; @@ -94,7 +94,7 @@ public string ProofOfNinSha256 public string BirthCertificateSha256 { get => _birthCertificateSha256; - set => _birthCertificateSha256 = value?.ToUpper() ?? ""; + set => _birthCertificateSha256 = value?.ToUpper(); } } diff --git a/src/BolWallet/Models/GenericHashTableForm.cs b/src/BolWallet/Models/GenericHashTableForm.cs index fa2545a..777ee7f 100644 --- a/src/BolWallet/Models/GenericHashTableForm.cs +++ b/src/BolWallet/Models/GenericHashTableForm.cs @@ -26,7 +26,7 @@ public class GenericSHA256TableForm : ObservableObject public string DrivingLicense { get => _drivingLicense; - set => _drivingLicense = value?.ToUpper() ?? ""; + set => _drivingLicense = value?.ToUpper(); } private string _otherIdentity; @@ -36,7 +36,7 @@ public string DrivingLicense public string OtherIdentity { get => _otherIdentity; - set => _otherIdentity = value?.ToUpper() ?? ""; + set => _otherIdentity = value?.ToUpper(); } private string _facePhoto; @@ -46,7 +46,7 @@ public string OtherIdentity public string FacePhoto { get => _facePhoto; - set => _facePhoto = value?.ToUpper() ?? ""; + set => _facePhoto = value?.ToUpper(); } private string _personalVoice; @@ -56,7 +56,7 @@ public string FacePhoto public string PersonalVoice { get => _personalVoice; - set => _personalVoice = value?.ToUpper() ?? ""; + set => _personalVoice = value?.ToUpper(); } private string _proofOfCommunication; @@ -66,7 +66,7 @@ public string PersonalVoice public string ProofOfCommunication { get => _proofOfCommunication; - set => _proofOfCommunication = value?.ToUpper() ?? ""; + set => _proofOfCommunication = value?.ToUpper(); } private string _proofOfResidence; @@ -76,7 +76,7 @@ public string ProofOfCommunication public string ProofOfResidence { get => _proofOfResidence; - set => _proofOfResidence = value?.ToUpper() ?? ""; + set => _proofOfResidence = value?.ToUpper(); } } } From 270c3a152f1dac24a98f5b27860fa850b5ce4ae0 Mon Sep 17 00:00:00 2001 From: Theofanis Tokas Date: Wed, 9 Oct 2024 14:24:01 +0300 Subject: [PATCH 9/9] Bump iOS/MacCatalyst version to 2.2.0 (2024.1009.1430) --- src/BolWallet/Platforms/MacCatalyst/Info.plist | 4 ++-- src/BolWallet/Platforms/iOS/Info.plist | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/BolWallet/Platforms/MacCatalyst/Info.plist b/src/BolWallet/Platforms/MacCatalyst/Info.plist index cdf745a..6ea50bd 100644 --- a/src/BolWallet/Platforms/MacCatalyst/Info.plist +++ b/src/BolWallet/Platforms/MacCatalyst/Info.plist @@ -31,9 +31,9 @@ processing CFBundleVersion - 2024.1004.1800 + 2024.1009.1430 CFBundleShortVersionString - 2.1.0 + 2.2.0 CFBundleDevelopmentRegion en NSHumanReadableCopyright diff --git a/src/BolWallet/Platforms/iOS/Info.plist b/src/BolWallet/Platforms/iOS/Info.plist index ca3f6c0..fb14a36 100644 --- a/src/BolWallet/Platforms/iOS/Info.plist +++ b/src/BolWallet/Platforms/iOS/Info.plist @@ -35,9 +35,9 @@ NSPhotoLibraryUsageDescription The app can use the photo library to select photos from your library and use them when creating a new wallet. CFBundleVersion - 2024.1004.1800 + 2024.1009.1430 CFBundleShortVersionString - 2.1.0 + 2.2.0 CFBundleDevelopmentRegion en NSHumanReadableCopyright