public GroupingsPageViewModel() { _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _folderService = ServiceContainer.Resolve <IFolderService>("folderService"); _collectionService = ServiceContainer.Resolve <ICollectionService>("collectionService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _passwordRepromptService = ServiceContainer.Resolve <IPasswordRepromptService>("passwordRepromptService"); _logger = ServiceContainer.Resolve <ILogger>("logger"); Loading = true; PageTitle = AppResources.MyVault; GroupedItems = new ObservableRangeCollection <IGroupingsPageListItem>(); RefreshCommand = new Command(async() => { Refreshing = true; await LoadAsync(); }); CipherOptionsCommand = new Command <CipherView>(CipherOptionsAsync); AccountSwitchingOverlayViewModel = new AccountSwitchingOverlayViewModel(_stateService, _messagingService, _logger) { AllowAddAccountRow = true }; }
public VerificationActionsFlowHelper(IKeyConnectorService keyConnectorService, IPasswordRepromptService passwordRepromptService, ICryptoService cryptoService) { _keyConnectorService = keyConnectorService; _passwordRepromptService = passwordRepromptService; _cryptoService = cryptoService; _actionExecutionerDictionary.Add(VerificationFlowAction.DeleteAccount, ServiceContainer.Resolve <IDeleteAccountActionFlowExecutioner>("deleteAccountActionFlowExecutioner")); }
public AutofillCiphersPageViewModel() { _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _passwordRepromptService = ServiceContainer.Resolve <IPasswordRepromptService>("passwordRepromptService"); GroupedItems = new ExtendedObservableCollection <GroupingsPageListGroup>(); CipherOptionsCommand = new Command <CipherView>(CipherOptionsAsync); }
public DeleteAccountViewModel() { _apiService = ServiceContainer.Resolve <IApiService>("apiService"); _passwordRepromptService = ServiceContainer.Resolve <IPasswordRepromptService>("passwordRepromptService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); PageTitle = AppResources.DeleteAccount; }
public CiphersPageViewModel() { _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _searchService = ServiceContainer.Resolve <ISearchService>("searchService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _passwordRepromptService = ServiceContainer.Resolve <IPasswordRepromptService>("passwordRepromptService"); Ciphers = new ExtendedObservableCollection <CipherView>(); CipherOptionsCommand = new Command <CipherView>(CipherOptionsAsync); }
public AutofillCiphersPageViewModel() { _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _passwordRepromptService = ServiceContainer.Resolve <IPasswordRepromptService>("passwordRepromptService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _logger = ServiceContainer.Resolve <ILogger>("logger"); GroupedItems = new ObservableRangeCollection <IGroupingsPageListItem>(); CipherOptionsCommand = new Command <CipherView>(CipherOptionsAsync); AccountSwitchingOverlayViewModel = new AccountSwitchingOverlayViewModel(_stateService, _messagingService, _logger) { AllowAddAccountRow = false }; }
public CipherDetailsPageViewModel() { _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _totpService = ServiceContainer.Resolve <ITotpService>("totpService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _eventService = ServiceContainer.Resolve <IEventService>("eventService"); _passwordRepromptService = ServiceContainer.Resolve <IPasswordRepromptService>("passwordRepromptService"); _localizeService = ServiceContainer.Resolve <ILocalizeService>("localizeService"); _clipboardService = ServiceContainer.Resolve <IClipboardService>("clipboardService"); CopyCommand = new AsyncCommand <string>((id) => CopyAsync(id, null), onException: ex => _logger.Exception(ex), allowsMultipleExecutions: false); CopyUriCommand = new AsyncCommand <LoginUriView>(uriView => CopyAsync("LoginUri", uriView.Uri), onException: ex => _logger.Exception(ex), allowsMultipleExecutions: false); CopyFieldCommand = new AsyncCommand <FieldView>(field => CopyAsync(field.Type == FieldType.Hidden ? "H_FieldValue" : "FieldValue", field.Value), onException: ex => _logger.Exception(ex), allowsMultipleExecutions: false); LaunchUriCommand = new Command <LoginUriView>(LaunchUri); TogglePasswordCommand = new Command(TogglePassword); ToggleCardNumberCommand = new Command(ToggleCardNumber); ToggleCardCodeCommand = new Command(ToggleCardCode); DownloadAttachmentCommand = new AsyncCommand <AttachmentView>(DownloadAttachmentAsync, allowsMultipleExecutions: false); PageTitle = AppResources.ViewItem; }
public ViewPageViewModel() { _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _totpService = ServiceContainer.Resolve <ITotpService>("totpService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _auditService = ServiceContainer.Resolve <IAuditService>("auditService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _eventService = ServiceContainer.Resolve <IEventService>("eventService"); _passwordRepromptService = ServiceContainer.Resolve <IPasswordRepromptService>("passwordRepromptService"); CopyCommand = new Command <string>((id) => CopyAsync(id, null)); CopyUriCommand = new Command <LoginUriView>(CopyUri); CopyFieldCommand = new Command <FieldView>(CopyField); LaunchUriCommand = new Command <LoginUriView>(LaunchUri); TogglePasswordCommand = new Command(TogglePassword); ToggleCardNumberCommand = new Command(ToggleCardNumber); ToggleCardCodeCommand = new Command(ToggleCardCode); CheckPasswordCommand = new Command(CheckPasswordAsync); DownloadAttachmentCommand = new Command <AttachmentView>(DownloadAttachmentAsync); PageTitle = AppResources.ViewItem; }
public static async Task <string> CipherListOptions(ContentPage page, CipherView cipher, IPasswordRepromptService passwordRepromptService) { var platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); var eventService = ServiceContainer.Resolve <IEventService>("eventService"); var vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); var options = new List <string> { AppResources.View }; if (!cipher.IsDeleted) { options.Add(AppResources.Edit); } if (cipher.Type == Core.Enums.CipherType.Login) { if (!string.IsNullOrWhiteSpace(cipher.Login.Username)) { options.Add(AppResources.CopyUsername); } if (!string.IsNullOrWhiteSpace(cipher.Login.Password) && cipher.ViewPassword) { options.Add(AppResources.CopyPassword); } if (!string.IsNullOrWhiteSpace(cipher.Login.Totp)) { var userService = ServiceContainer.Resolve <IUserService>("userService"); var canAccessPremium = await userService.CanAccessPremiumAsync(); if (canAccessPremium || cipher.OrganizationUseTotp) { options.Add(AppResources.CopyTotp); } } if (cipher.Login.CanLaunch) { options.Add(AppResources.Launch); } } else if (cipher.Type == Core.Enums.CipherType.Card) { if (!string.IsNullOrWhiteSpace(cipher.Card.Number)) { options.Add(AppResources.CopyNumber); } if (!string.IsNullOrWhiteSpace(cipher.Card.Code)) { options.Add(AppResources.CopySecurityCode); } } else if (cipher.Type == Core.Enums.CipherType.SecureNote) { if (!string.IsNullOrWhiteSpace(cipher.Notes)) { options.Add(AppResources.CopyNotes); } } var selection = await page.DisplayActionSheet(cipher.Name, AppResources.Cancel, null, options.ToArray()); if (await vaultTimeoutService.IsLockedAsync()) { platformUtilsService.ShowToast("info", null, AppResources.VaultIsLocked); } else if (selection == AppResources.View) { await page.Navigation.PushModalAsync(new NavigationPage(new ViewPage(cipher.Id))); } else if (selection == AppResources.Edit) { if (cipher.Reprompt == CipherRepromptType.None || await passwordRepromptService.ShowPasswordPromptAsync()) { await page.Navigation.PushModalAsync(new NavigationPage(new AddEditPage(cipher.Id))); } } else if (selection == AppResources.CopyUsername) { await platformUtilsService.CopyToClipboardAsync(cipher.Login.Username); platformUtilsService.ShowToast("info", null, string.Format(AppResources.ValueHasBeenCopied, AppResources.Username)); } else if (selection == AppResources.CopyPassword) { if (cipher.Reprompt == CipherRepromptType.None || await passwordRepromptService.ShowPasswordPromptAsync()) { await platformUtilsService.CopyToClipboardAsync(cipher.Login.Password); platformUtilsService.ShowToast("info", null, string.Format(AppResources.ValueHasBeenCopied, AppResources.Password)); var task = eventService.CollectAsync(Core.Enums.EventType.Cipher_ClientCopiedPassword, cipher.Id); } } else if (selection == AppResources.CopyTotp) { if (cipher.Reprompt == CipherRepromptType.None || await passwordRepromptService.ShowPasswordPromptAsync()) { var totpService = ServiceContainer.Resolve <ITotpService>("totpService"); var totp = await totpService.GetCodeAsync(cipher.Login.Totp); if (!string.IsNullOrWhiteSpace(totp)) { await platformUtilsService.CopyToClipboardAsync(totp); platformUtilsService.ShowToast("info", null, string.Format(AppResources.ValueHasBeenCopied, AppResources.VerificationCodeTotp)); } } } else if (selection == AppResources.Launch) { platformUtilsService.LaunchUri(cipher.Login.LaunchUri); } else if (selection == AppResources.CopyNumber) { if (cipher.Reprompt == CipherRepromptType.None || await passwordRepromptService.ShowPasswordPromptAsync()) { await platformUtilsService.CopyToClipboardAsync(cipher.Card.Number); platformUtilsService.ShowToast("info", null, string.Format(AppResources.ValueHasBeenCopied, AppResources.Number)); } } else if (selection == AppResources.CopySecurityCode) { if (cipher.Reprompt == CipherRepromptType.None || await passwordRepromptService.ShowPasswordPromptAsync()) { await platformUtilsService.CopyToClipboardAsync(cipher.Card.Code); platformUtilsService.ShowToast("info", null, string.Format(AppResources.ValueHasBeenCopied, AppResources.SecurityCode)); var task = eventService.CollectAsync(Core.Enums.EventType.Cipher_ClientCopiedCardCode, cipher.Id); } } else if (selection == AppResources.CopyNotes) { await platformUtilsService.CopyToClipboardAsync(cipher.Notes); platformUtilsService.ShowToast("info", null, string.Format(AppResources.ValueHasBeenCopied, AppResources.Notes)); } return(selection); }
public async static Task TableRowSelectedAsync(UITableView tableView, NSIndexPath indexPath, ExtensionTableSource tableSource, CredentialProviderViewController cpViewController, UIViewController controller, IPasswordRepromptService passwordRepromptService, string loginAddSegue) { tableView.DeselectRow(indexPath, true); tableView.EndEditing(true); if (tableSource.Items == null || tableSource.Items.Count() == 0) { controller.PerformSegue(loginAddSegue, tableSource); return; } var item = tableSource.Items.ElementAt(indexPath.Row); if (item == null) { cpViewController.CompleteRequest(); return; } if (item.Reprompt != Bit.Core.Enums.CipherRepromptType.None && !await passwordRepromptService.ShowPasswordPromptAsync()) { return; } if (!string.IsNullOrWhiteSpace(item.Username) && !string.IsNullOrWhiteSpace(item.Password)) { string totp = null; var stateService = ServiceContainer.Resolve <IStateService>("stateService"); var disableTotpCopy = await stateService.GetDisableAutoTotpCopyAsync(); if (!disableTotpCopy.GetValueOrDefault(false)) { var canAccessPremiumAsync = await stateService.CanAccessPremiumAsync(); if (!string.IsNullOrWhiteSpace(item.Totp) && (canAccessPremiumAsync || item.CipherView.OrganizationUseTotp)) { var totpService = ServiceContainer.Resolve <ITotpService>("totpService"); totp = await totpService.GetCodeAsync(item.Totp); } } cpViewController.CompleteRequest(item.Id, item.Username, item.Password, totp); } else if (!string.IsNullOrWhiteSpace(item.Username) || !string.IsNullOrWhiteSpace(item.Password) || !string.IsNullOrWhiteSpace(item.Totp)) { var sheet = Dialogs.CreateActionSheet(item.Name, controller); if (!string.IsNullOrWhiteSpace(item.Username)) { sheet.AddAction(UIAlertAction.Create(AppResources.CopyUsername, UIAlertActionStyle.Default, a => { UIPasteboard clipboard = UIPasteboard.General; clipboard.String = item.Username; var alert = Dialogs.CreateMessageAlert(AppResources.CopyUsername); controller.PresentViewController(alert, true, () => { controller.DismissViewController(true, null); }); })); } if (!string.IsNullOrWhiteSpace(item.Password)) { sheet.AddAction(UIAlertAction.Create(AppResources.CopyPassword, UIAlertActionStyle.Default, a => { UIPasteboard clipboard = UIPasteboard.General; clipboard.String = item.Password; var alert = Dialogs.CreateMessageAlert( string.Format(AppResources.ValueHasBeenCopied, AppResources.Password)); controller.PresentViewController(alert, true, () => { controller.DismissViewController(true, null); }); })); } if (!string.IsNullOrWhiteSpace(item.Totp)) { sheet.AddAction(UIAlertAction.Create(AppResources.CopyTotp, UIAlertActionStyle.Default, async a => { var totp = await tableSource.GetTotpAsync(item); if (string.IsNullOrWhiteSpace(totp)) { return; } UIPasteboard clipboard = UIPasteboard.General; clipboard.String = totp; var alert = Dialogs.CreateMessageAlert( string.Format(AppResources.ValueHasBeenCopied, AppResources.VerificationCodeTotp)); controller.PresentViewController(alert, true, () => { controller.DismissViewController(true, null); }); })); } sheet.AddAction(UIAlertAction.Create(AppResources.Cancel, UIAlertActionStyle.Cancel, null)); controller.PresentViewController(sheet, true, null); } else { var alert = Dialogs.CreateAlert(null, AppResources.NoUsernamePasswordConfigured, AppResources.Ok); controller.PresentViewController(alert, true, null); } }