diff --git a/src/Android/MainApplication.cs b/src/Android/MainApplication.cs index ecb9ca277..991aea474 100644 --- a/src/Android/MainApplication.cs +++ b/src/Android/MainApplication.cs @@ -99,12 +99,13 @@ namespace Bit.Droid { ServiceContainer.Register("nativeLogService", new AndroidLogService()); #if FDROID - ServiceContainer.Register("logger", new StubLogger()); + var logger = new StubLogger(); #elif DEBUG - ServiceContainer.Register("logger", DebugLogger.Instance); + var logger = DebugLogger.Instance; #else - ServiceContainer.Register("logger", Logger.Instance); + var logger = Logger.Instance; #endif + ServiceContainer.Register("logger", logger); // Note: This might cause a race condition. Investigate more. Task.Run(() => @@ -124,7 +125,7 @@ namespace Bit.Droid var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); var localizeService = new LocalizeService(); - var broadcasterService = new BroadcasterService(); + var broadcasterService = new BroadcasterService(logger); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index 9e534cd72..3415fd7e9 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -10,6 +10,7 @@ using Bit.App.Utilities.AccountManagement; using Bit.Core.Abstractions; using Bit.Core.Enums; using Bit.Core.Models.Data; +using Bit.Core.Services; using Bit.Core.Utilities; using Xamarin.Forms; using Xamarin.Forms.Xaml; @@ -56,86 +57,93 @@ namespace Bit.App Bootstrap(); _broadcasterService.Subscribe(nameof(App), async (message) => { - if (message.Command == "showDialog") + try { - var details = message.Data as DialogDetails; - var confirmed = true; - var confirmText = string.IsNullOrWhiteSpace(details.ConfirmText) ? - AppResources.Ok : details.ConfirmText; - Device.BeginInvokeOnMainThread(async () => + if (message.Command == "showDialog") { - if (!string.IsNullOrWhiteSpace(details.CancelText)) + var details = message.Data as DialogDetails; + var confirmed = true; + var confirmText = string.IsNullOrWhiteSpace(details.ConfirmText) ? + AppResources.Ok : details.ConfirmText; + Device.BeginInvokeOnMainThread(async () => { - confirmed = await Current.MainPage.DisplayAlert(details.Title, details.Text, confirmText, - details.CancelText); - } - else - { - await Current.MainPage.DisplayAlert(details.Title, details.Text, confirmText); - } - _messagingService.Send("showDialogResolve", new Tuple(details.DialogId, confirmed)); - }); - } - else if (message.Command == "resumed") - { - if (Device.RuntimePlatform == Device.iOS) + if (!string.IsNullOrWhiteSpace(details.CancelText)) + { + confirmed = await Current.MainPage.DisplayAlert(details.Title, details.Text, confirmText, + details.CancelText); + } + else + { + await Current.MainPage.DisplayAlert(details.Title, details.Text, confirmText); + } + _messagingService.Send("showDialogResolve", new Tuple(details.DialogId, confirmed)); + }); + } + else if (message.Command == "resumed") { - ResumedAsync().FireAndForget(); + if (Device.RuntimePlatform == Device.iOS) + { + ResumedAsync().FireAndForget(); + } + } + else if (message.Command == "slept") + { + if (Device.RuntimePlatform == Device.iOS) + { + await SleptAsync(); + } + } + else if (message.Command == "migrated") + { + await Task.Delay(1000); + await _accountsManager.NavigateOnAccountChangeAsync(); + } + else if (message.Command == "popAllAndGoToTabGenerator" || + message.Command == "popAllAndGoToTabMyVault" || + message.Command == "popAllAndGoToTabSend" || + message.Command == "popAllAndGoToAutofillCiphers") + { + Device.BeginInvokeOnMainThread(async () => + { + if (Current.MainPage is TabsPage tabsPage) + { + while (tabsPage.Navigation.ModalStack.Count > 0) + { + await tabsPage.Navigation.PopModalAsync(false); + } + if (message.Command == "popAllAndGoToAutofillCiphers") + { + Current.MainPage = new NavigationPage(new AutofillCiphersPage(Options)); + } + else if (message.Command == "popAllAndGoToTabMyVault") + { + Options.MyVaultTile = false; + tabsPage.ResetToVaultPage(); + } + else if (message.Command == "popAllAndGoToTabGenerator") + { + Options.GeneratorTile = false; + tabsPage.ResetToGeneratorPage(); + } + else if (message.Command == "popAllAndGoToTabSend") + { + tabsPage.ResetToSendPage(); + } + } + }); + } + else if (message.Command == "convertAccountToKeyConnector") + { + Device.BeginInvokeOnMainThread(async () => + { + await Application.Current.MainPage.Navigation.PushModalAsync( + new NavigationPage(new RemoveMasterPasswordPage())); + }); } } - else if (message.Command == "slept") + catch (Exception ex) { - if (Device.RuntimePlatform == Device.iOS) - { - await SleptAsync(); - } - } - else if (message.Command == "migrated") - { - await Task.Delay(1000); - await _accountsManager.NavigateOnAccountChangeAsync(); - } - else if (message.Command == "popAllAndGoToTabGenerator" || - message.Command == "popAllAndGoToTabMyVault" || - message.Command == "popAllAndGoToTabSend" || - message.Command == "popAllAndGoToAutofillCiphers") - { - Device.BeginInvokeOnMainThread(async () => - { - if (Current.MainPage is TabsPage tabsPage) - { - while (tabsPage.Navigation.ModalStack.Count > 0) - { - await tabsPage.Navigation.PopModalAsync(false); - } - if (message.Command == "popAllAndGoToAutofillCiphers") - { - Current.MainPage = new NavigationPage(new AutofillCiphersPage(Options)); - } - else if (message.Command == "popAllAndGoToTabMyVault") - { - Options.MyVaultTile = false; - tabsPage.ResetToVaultPage(); - } - else if (message.Command == "popAllAndGoToTabGenerator") - { - Options.GeneratorTile = false; - tabsPage.ResetToGeneratorPage(); - } - else if (message.Command == "popAllAndGoToTabSend") - { - tabsPage.ResetToSendPage(); - } - } - }); - } - else if (message.Command == "convertAccountToKeyConnector") - { - Device.BeginInvokeOnMainThread(async () => - { - await Application.Current.MainPage.Navigation.PushModalAsync( - new NavigationPage(new RemoveMasterPasswordPage())); - }); + LoggerHelper.LogEvenIfCantBeResolved(ex); } }); } diff --git a/src/App/Pages/Accounts/HomePage.xaml.cs b/src/App/Pages/Accounts/HomePage.xaml.cs index d63413216..f01fccef0 100644 --- a/src/App/Pages/Accounts/HomePage.xaml.cs +++ b/src/App/Pages/Accounts/HomePage.xaml.cs @@ -54,7 +54,7 @@ namespace Bit.App.Pages { _vm.AvatarImageSource = await GetAvatarImageSourceAsync(); } - _broadcasterService.Subscribe(nameof(HomePage), async (message) => + _broadcasterService.Subscribe(nameof(HomePage), (message) => { if (message.Command == "updatedTheme") { diff --git a/src/App/Pages/Send/SendGroupingsPage/SendGroupingsPage.xaml.cs b/src/App/Pages/Send/SendGroupingsPage/SendGroupingsPage.xaml.cs index 183a832d8..6e8acc1ca 100644 --- a/src/App/Pages/Send/SendGroupingsPage/SendGroupingsPage.xaml.cs +++ b/src/App/Pages/Send/SendGroupingsPage/SendGroupingsPage.xaml.cs @@ -5,6 +5,7 @@ using Bit.App.Controls; using Bit.App.Models; using Bit.Core.Abstractions; using Bit.Core.Enums; +using Bit.Core.Services; using Bit.Core.Utilities; using Xamarin.Forms; @@ -68,21 +69,28 @@ namespace Bit.App.Pages _broadcasterService.Subscribe(_pageName, async (message) => { - if (message.Command == "syncStarted") + try { - Device.BeginInvokeOnMainThread(() => IsBusy = true); - } - else if (message.Command == "syncCompleted" || message.Command == "sendUpdated") - { - await Task.Delay(500); - Device.BeginInvokeOnMainThread(() => + if (message.Command == "syncStarted") { - IsBusy = false; - if (_vm.LoadedOnce) + Device.BeginInvokeOnMainThread(() => IsBusy = true); + } + else if (message.Command == "syncCompleted" || message.Command == "sendUpdated") + { + await Task.Delay(500); + Device.BeginInvokeOnMainThread(() => { - var task = _vm.LoadAsync(); - } - }); + IsBusy = false; + if (_vm.LoadedOnce) + { + var task = _vm.LoadAsync(); + } + }); + } + } + catch (Exception ex) + { + LoggerHelper.LogEvenIfCantBeResolved(ex); } }); diff --git a/src/App/Pages/Vault/AutofillCiphersPage.xaml.cs b/src/App/Pages/Vault/AutofillCiphersPage.xaml.cs index aed80316f..35b85fc9c 100644 --- a/src/App/Pages/Vault/AutofillCiphersPage.xaml.cs +++ b/src/App/Pages/Vault/AutofillCiphersPage.xaml.cs @@ -6,6 +6,7 @@ using Bit.App.Models; using Bit.App.Utilities; using Bit.Core.Abstractions; using Bit.Core.Enums; +using Bit.Core.Services; using Bit.Core.Utilities; using Xamarin.Forms; @@ -55,21 +56,28 @@ namespace Bit.App.Pages _broadcasterService.Subscribe(nameof(AutofillCiphersPage), async (message) => { - if (message.Command == "syncStarted") + try { - Device.BeginInvokeOnMainThread(() => IsBusy = true); - } - else if (message.Command == "syncCompleted") - { - await Task.Delay(500); - Device.BeginInvokeOnMainThread(() => + if (message.Command == "syncStarted") { - IsBusy = false; - if (_vm.LoadedOnce) + Device.BeginInvokeOnMainThread(() => IsBusy = true); + } + else if (message.Command == "syncCompleted") + { + await Task.Delay(500); + Device.BeginInvokeOnMainThread(() => { - var task = _vm.LoadAsync(); - } - }); + IsBusy = false; + if (_vm.LoadedOnce) + { + var task = _vm.LoadAsync(); + } + }); + } + } + catch (Exception ex) + { + LoggerHelper.LogEvenIfCantBeResolved(ex); } }); diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs index aa9fb56a7..29ae16989 100644 --- a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs +++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs @@ -7,6 +7,7 @@ using Bit.App.Resources; using Bit.Core.Abstractions; using Bit.Core.Enums; using Bit.Core.Models.Data; +using Bit.Core.Services; using Bit.Core.Utilities; using Xamarin.Forms; @@ -95,21 +96,28 @@ namespace Bit.App.Pages _broadcasterService.Subscribe(_pageName, async (message) => { - if (message.Command == "syncStarted") + try { - Device.BeginInvokeOnMainThread(() => IsBusy = true); - } - else if (message.Command == "syncCompleted") - { - await Task.Delay(500); - Device.BeginInvokeOnMainThread(() => + if (message.Command == "syncStarted") { - IsBusy = false; - if (_vm.LoadedOnce) + Device.BeginInvokeOnMainThread(() => IsBusy = true); + } + else if (message.Command == "syncCompleted") + { + await Task.Delay(500); + Device.BeginInvokeOnMainThread(() => { - var task = _vm.LoadAsync(); - } - }); + IsBusy = false; + if (_vm.LoadedOnce) + { + var task = _vm.LoadAsync(); + } + }); + } + } + catch (Exception ex) + { + LoggerHelper.LogEvenIfCantBeResolved(ex); } }); diff --git a/src/App/Pages/Vault/ViewPage.xaml.cs b/src/App/Pages/Vault/ViewPage.xaml.cs index eb03551f1..93e8b5eff 100644 --- a/src/App/Pages/Vault/ViewPage.xaml.cs +++ b/src/App/Pages/Vault/ViewPage.xaml.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Bit.App.Resources; using Bit.Core.Abstractions; +using Bit.Core.Services; using Bit.Core.Utilities; using Xamarin.Forms; @@ -56,37 +57,44 @@ namespace Bit.App.Pages _broadcasterService.Subscribe(nameof(ViewPage), async (message) => { - if (message.Command == "syncStarted") + try { - Device.BeginInvokeOnMainThread(() => IsBusy = true); - } - else if (message.Command == "syncCompleted") - { - await Task.Delay(500); - Device.BeginInvokeOnMainThread(() => + if (message.Command == "syncStarted") { - IsBusy = false; - if (message.Data is Dictionary data && data.ContainsKey("successfully")) + Device.BeginInvokeOnMainThread(() => IsBusy = true); + } + else if (message.Command == "syncCompleted") + { + await Task.Delay(500); + Device.BeginInvokeOnMainThread(() => { - var success = data["successfully"] as bool?; - if (success.GetValueOrDefault()) + IsBusy = false; + if (message.Data is Dictionary data && data.ContainsKey("successfully")) { - var task = _vm.LoadAsync(() => AdjustToolbar()); + var success = data["successfully"] as bool?; + if (success.GetValueOrDefault()) + { + var task = _vm.LoadAsync(() => AdjustToolbar()); + } } - } - }); - } - else if (message.Command == "selectSaveFileResult") - { - Device.BeginInvokeOnMainThread(() => + }); + } + else if (message.Command == "selectSaveFileResult") { - var data = message.Data as Tuple; - if (data == null) + Device.BeginInvokeOnMainThread(() => { - return; - } - _vm.SaveFileSelected(data.Item1, data.Item2); - }); + var data = message.Data as Tuple; + if (data == null) + { + return; + } + _vm.SaveFileSelected(data.Item1, data.Item2); + }); + } + } + catch (Exception ex) + { + LoggerHelper.LogEvenIfCantBeResolved(ex); } }); await LoadOnAppearedAsync(_scrollView, true, async () => diff --git a/src/Core/Abstractions/IBroadcasterService.cs b/src/Core/Abstractions/IBroadcasterService.cs index ac481b53d..0675aad18 100644 --- a/src/Core/Abstractions/IBroadcasterService.cs +++ b/src/Core/Abstractions/IBroadcasterService.cs @@ -5,7 +5,8 @@ namespace Bit.Core.Abstractions { public interface IBroadcasterService { - void Send(Message message, string id = null); + void Send(Message message); + void Send(Message message, string id); void Subscribe(string id, Action messageCallback); void Unsubscribe(string id); } diff --git a/src/Core/Services/BroadcasterService.cs b/src/Core/Services/BroadcasterService.cs index 553ec49c9..782529335 100644 --- a/src/Core/Services/BroadcasterService.cs +++ b/src/Core/Services/BroadcasterService.cs @@ -8,24 +8,58 @@ namespace Bit.App.Services { public class BroadcasterService : IBroadcasterService { + private readonly ILogger _logger; private readonly Dictionary> _subscribers = new Dictionary>(); private object _myLock = new object(); - public void Send(Message message, string id = null) + public BroadcasterService(ILogger logger) + { + _logger = logger; + } + + public void Send(Message message) { lock (_myLock) { - if (!string.IsNullOrWhiteSpace(id)) - { - if (_subscribers.ContainsKey(id)) - { - Task.Run(() => _subscribers[id].Invoke(message)); - } - return; - } foreach (var sub in _subscribers) { - Task.Run(() => sub.Value.Invoke(message)); + Task.Run(() => + { + try + { + sub.Value(message); + } + catch (Exception ex) + { + _logger.Exception(ex); + } + }); + } + } + } + + public void Send(Message message, string id) + { + if (string.IsNullOrWhiteSpace(id)) + { + return; + } + + lock (_myLock) + { + if (_subscribers.TryGetValue(id, out var action)) + { + Task.Run(() => + { + try + { + action(message); + } + catch (Exception ex) + { + _logger.Exception(ex); + } + }); } } } @@ -34,14 +68,7 @@ namespace Bit.App.Services { lock (_myLock) { - if (_subscribers.ContainsKey(id)) - { - _subscribers[id] = messageCallback; - } - else - { - _subscribers.Add(id, messageCallback); - } + _subscribers[id] = messageCallback; } } diff --git a/src/iOS.Core/Renderers/CustomTabbedRenderer.cs b/src/iOS.Core/Renderers/CustomTabbedRenderer.cs index a8904ef6b..60e59ba23 100644 --- a/src/iOS.Core/Renderers/CustomTabbedRenderer.cs +++ b/src/iOS.Core/Renderers/CustomTabbedRenderer.cs @@ -21,7 +21,7 @@ namespace Bit.iOS.Core.Renderers public CustomTabbedRenderer() { _broadcasterService = ServiceContainer.Resolve("broadcasterService"); - _broadcasterService.Subscribe(nameof(CustomTabbedRenderer), async (message) => + _broadcasterService.Subscribe(nameof(CustomTabbedRenderer), (message) => { if (message.Command == "updatedTheme") { diff --git a/src/iOS.Core/Utilities/iOSCoreHelpers.cs b/src/iOS.Core/Utilities/iOSCoreHelpers.cs index cfd0bf1bb..21321803e 100644 --- a/src/iOS.Core/Utilities/iOSCoreHelpers.cs +++ b/src/iOS.Core/Utilities/iOSCoreHelpers.cs @@ -38,13 +38,15 @@ namespace Bit.iOS.Core.Utilities ServiceContainer.Register("nativeLogService", new ConsoleLogService()); } + ILogger logger = null; if (ServiceContainer.Resolve("logger", true) == null) { #if DEBUG - ServiceContainer.Register("logger", DebugLogger.Instance); + logger = DebugLogger.Instance; #else - ServiceContainer.Register("logger", Logger.Instance); + logger = Logger.Instance; #endif + ServiceContainer.Register("logger", logger); } var preferencesStorage = new PreferencesStorageService(AppGroupId); @@ -52,7 +54,7 @@ namespace Bit.iOS.Core.Utilities var liteDbStorage = new LiteDbStorageService( Path.Combine(appGroupContainer.Path, "Library", "bitwarden.db")); var localizeService = new LocalizeService(); - var broadcasterService = new BroadcasterService(); + var broadcasterService = new BroadcasterService(logger); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new KeyChainStorageService(AppId, AccessGroup, diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index 020a3803b..9686c8071 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -59,114 +59,121 @@ namespace Bit.iOS _broadcasterService.Subscribe(nameof(AppDelegate), async (message) => { - if (message.Command == "startEventTimer") + try { - StartEventTimer(); - } - else if (message.Command == "stopEventTimer") - { - var task = StopEventTimerAsync(); - } - else if (message.Command == "updatedTheme") - { - Device.BeginInvokeOnMainThread(() => + if (message.Command == "startEventTimer") { - iOSCoreHelpers.AppearanceAdjustments(); - }); - } - else if (message.Command == "listenYubiKeyOTP") - { - iOSCoreHelpers.ListenYubiKey((bool)message.Data, _deviceActionService, _nfcSession, _nfcDelegate); - } - else if (message.Command == "unlocked") - { - var needsAutofillReplacement = await _storageService.GetAsync( - Core.Constants.AutofillNeedsIdentityReplacementKey); - if (needsAutofillReplacement.GetValueOrDefault()) + StartEventTimer(); + } + else if (message.Command == "stopEventTimer") + { + var task = StopEventTimerAsync(); + } + else if (message.Command == "updatedTheme") + { + Device.BeginInvokeOnMainThread(() => + { + iOSCoreHelpers.AppearanceAdjustments(); + }); + } + else if (message.Command == "listenYubiKeyOTP") + { + iOSCoreHelpers.ListenYubiKey((bool)message.Data, _deviceActionService, _nfcSession, _nfcDelegate); + } + else if (message.Command == "unlocked") + { + var needsAutofillReplacement = await _storageService.GetAsync( + Core.Constants.AutofillNeedsIdentityReplacementKey); + if (needsAutofillReplacement.GetValueOrDefault()) + { + await ASHelpers.ReplaceAllIdentities(); + } + } + else if (message.Command == "showAppExtension") + { + Device.BeginInvokeOnMainThread(() => ShowAppExtension((ExtensionPageViewModel)message.Data)); + } + else if (message.Command == "syncCompleted") + { + if (message.Data is Dictionary data && data.ContainsKey("successfully")) + { + var success = data["successfully"] as bool?; + if (success.GetValueOrDefault() && _deviceActionService.SystemMajorVersion() >= 12) + { + await ASHelpers.ReplaceAllIdentities(); + } + } + } + else if (message.Command == "addedCipher" || message.Command == "editedCipher" || + message.Command == "restoredCipher") + { + if (_deviceActionService.SystemMajorVersion() >= 12) + { + if (await ASHelpers.IdentitiesCanIncremental()) + { + var cipherId = message.Data as string; + if (message.Command == "addedCipher" && !string.IsNullOrWhiteSpace(cipherId)) + { + var identity = await ASHelpers.GetCipherIdentityAsync(cipherId); + if (identity == null) + { + return; + } + await ASCredentialIdentityStore.SharedStore?.SaveCredentialIdentitiesAsync( + new ASPasswordCredentialIdentity[] { identity }); + return; + } + } + await ASHelpers.ReplaceAllIdentities(); + } + } + else if (message.Command == "deletedCipher" || message.Command == "softDeletedCipher") + { + if (_deviceActionService.SystemMajorVersion() >= 12) + { + if (await ASHelpers.IdentitiesCanIncremental()) + { + var identity = ASHelpers.ToCredentialIdentity( + message.Data as Bit.Core.Models.View.CipherView); + if (identity == null) + { + return; + } + await ASCredentialIdentityStore.SharedStore?.RemoveCredentialIdentitiesAsync( + new ASPasswordCredentialIdentity[] { identity }); + return; + } + await ASHelpers.ReplaceAllIdentities(); + } + } + else if (message.Command == "logout") + { + if (_deviceActionService.SystemMajorVersion() >= 12) + { + await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync(); + } + } + else if ((message.Command == "softDeletedCipher" || message.Command == "restoredCipher") + && _deviceActionService.SystemMajorVersion() >= 12) { await ASHelpers.ReplaceAllIdentities(); } - } - else if (message.Command == "showAppExtension") - { - Device.BeginInvokeOnMainThread(() => ShowAppExtension((ExtensionPageViewModel)message.Data)); - } - else if (message.Command == "syncCompleted") - { - if (message.Data is Dictionary data && data.ContainsKey("successfully")) + else if (message.Command == "vaultTimeoutActionChanged") { - var success = data["successfully"] as bool?; - if (success.GetValueOrDefault() && _deviceActionService.SystemMajorVersion() >= 12) + var timeoutAction = await _stateService.GetVaultTimeoutActionAsync(); + if (timeoutAction == VaultTimeoutAction.Logout) + { + await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync(); + } + else { await ASHelpers.ReplaceAllIdentities(); } } } - else if (message.Command == "addedCipher" || message.Command == "editedCipher" || - message.Command == "restoredCipher") + catch (Exception ex) { - if (_deviceActionService.SystemMajorVersion() >= 12) - { - if (await ASHelpers.IdentitiesCanIncremental()) - { - var cipherId = message.Data as string; - if (message.Command == "addedCipher" && !string.IsNullOrWhiteSpace(cipherId)) - { - var identity = await ASHelpers.GetCipherIdentityAsync(cipherId); - if (identity == null) - { - return; - } - await ASCredentialIdentityStore.SharedStore?.SaveCredentialIdentitiesAsync( - new ASPasswordCredentialIdentity[] { identity }); - return; - } - } - await ASHelpers.ReplaceAllIdentities(); - } - } - else if (message.Command == "deletedCipher" || message.Command == "softDeletedCipher") - { - if (_deviceActionService.SystemMajorVersion() >= 12) - { - if (await ASHelpers.IdentitiesCanIncremental()) - { - var identity = ASHelpers.ToCredentialIdentity( - message.Data as Bit.Core.Models.View.CipherView); - if (identity == null) - { - return; - } - await ASCredentialIdentityStore.SharedStore?.RemoveCredentialIdentitiesAsync( - new ASPasswordCredentialIdentity[] { identity }); - return; - } - await ASHelpers.ReplaceAllIdentities(); - } - } - else if (message.Command == "logout") - { - if (_deviceActionService.SystemMajorVersion() >= 12) - { - await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync(); - } - } - else if ((message.Command == "softDeletedCipher" || message.Command == "restoredCipher") - && _deviceActionService.SystemMajorVersion() >= 12) - { - await ASHelpers.ReplaceAllIdentities(); - } - else if (message.Command == "vaultTimeoutActionChanged") - { - var timeoutAction = await _stateService.GetVaultTimeoutActionAsync(); - if (timeoutAction == VaultTimeoutAction.Logout) - { - await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync(); - } - else - { - await ASHelpers.ReplaceAllIdentities(); - } + LoggerHelper.LogEvenIfCantBeResolved(ex); } });