public GroupingsPageViewModel() { _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _folderService = ServiceContainer.Resolve <IFolderService>("folderService"); _collectionService = ServiceContainer.Resolve <ICollectionService>("collectionService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _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"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _passwordRepromptService = ServiceContainer.Resolve <IPasswordRepromptService>("passwordRepromptService"); Loading = true; PageTitle = AppResources.MyVault; GroupedItems = new ExtendedObservableCollection <GroupingsPageListGroup>(); RefreshCommand = new Command(async() => { Refreshing = true; await LoadAsync(); }); CipherOptionsCommand = new Command <CipherView>(CipherOptionsAsync); }
public SendGroupingsPage(bool mainPage, SendType?type = null, string pageTitle = null, PreviousPageInfo previousPage = null) { _pageName = string.Concat(nameof(GroupingsPage), "_", DateTime.UtcNow.Ticks); InitializeComponent(); ListView = _listView; _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _sendService = ServiceContainer.Resolve <ISendService>("sendService"); _vm = BindingContext as SendGroupingsPageViewModel; _vm.Page = this; _vm.MainPage = mainPage; _vm.Type = type; _previousPage = previousPage; if (pageTitle != null) { _vm.PageTitle = pageTitle; } if (Device.RuntimePlatform == Device.iOS) { _absLayout.Children.Remove(_fab); ToolbarItems.Add(_aboutIconItem); ToolbarItems.Add(_addItem); } else { ToolbarItems.Add(_syncItem); ToolbarItems.Add(_lockItem); ToolbarItems.Add(_aboutTextItem); } }
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"); _organizationService = ServiceContainer.Resolve <IOrganizationService>("organizationService"); _policyService = ServiceContainer.Resolve <IPolicyService>("policyService"); _logger = ServiceContainer.Resolve <ILogger>("logger"); Loading = true; 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 TwoFactorPage(bool?authingWithSso = false, AppOptions appOptions = null, string orgIdentifier = null) { InitializeComponent(); SetActivityIndicator(); _authingWithSso = authingWithSso ?? false; _appOptions = appOptions; _orgIdentifier = orgIdentifier; _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _vm = BindingContext as TwoFactorPageViewModel; _vm.Page = this; _vm.StartSetPasswordAction = () => Device.BeginInvokeOnMainThread(async() => await StartSetPasswordAsync()); _vm.TwoFactorAuthSuccessAction = () => Device.BeginInvokeOnMainThread(async() => await TwoFactorAuthSuccessAsync()); _vm.CloseAction = async() => await Navigation.PopModalAsync(); DuoWebView = _duoWebView; if (Device.RuntimePlatform == Device.Android) { ToolbarItems.Remove(_cancelItem); } }
public LoginSsoPage(AppOptions appOptions = null) { _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _messagingService.Send("showStatusBar", true); _appOptions = appOptions; InitializeComponent(); _vm = BindingContext as LoginSsoPageViewModel; _vm.Page = this; _vm.StartTwoFactorAction = () => Device.BeginInvokeOnMainThread(async() => await StartTwoFactorAsync()); _vm.StartSetPasswordAction = () => Device.BeginInvokeOnMainThread(async() => await StartSetPasswordAsync()); _vm.SsoAuthSuccessAction = () => Device.BeginInvokeOnMainThread(async() => await SsoAuthSuccessAsync()); _vm.UpdateTempPasswordAction = () => Device.BeginInvokeOnMainThread(async() => await UpdateTempPasswordAsync()); _vm.CloseAction = async() => { _messagingService.Send("showStatusBar", false); await Navigation.PopModalAsync(); }; if (Device.RuntimePlatform == Device.Android) { ToolbarItems.RemoveAt(0); } }
public override void ViewDidLoad() { _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _biometricService = ServiceContainer.Resolve <IBiometricService>("biometricService"); _pinSet = _vaultTimeoutService.IsPinLockSetAsync().GetAwaiter().GetResult(); _pinLock = (_pinSet.Item1 && _vaultTimeoutService.PinProtectedKey != null) || _pinSet.Item2; _biometricLock = _vaultTimeoutService.IsBiometricLockSetAsync().GetAwaiter().GetResult() && _cryptoService.HasKeyAsync().GetAwaiter().GetResult(); _biometricIntegrityValid = _biometricService.ValidateIntegrityAsync(BiometricIntegrityKey).GetAwaiter() .GetResult(); BaseNavItem.Title = _pinLock ? AppResources.VerifyPIN : AppResources.VerifyMasterPassword; BaseCancelButton.Title = AppResources.Cancel; BaseSubmitButton.Title = AppResources.Submit; var descriptor = UIFontDescriptor.PreferredBody; MasterPasswordCell.Label.Text = _pinLock ? AppResources.PIN : AppResources.MasterPassword; MasterPasswordCell.TextField.SecureTextEntry = true; MasterPasswordCell.TextField.ReturnKeyType = UIReturnKeyType.Go; MasterPasswordCell.TextField.ShouldReturn += (UITextField tf) => { CheckPasswordAsync().GetAwaiter().GetResult(); return(true); }; if (_pinLock) { MasterPasswordCell.TextField.KeyboardType = UIKeyboardType.NumberPad; } TableView.RowHeight = UITableView.AutomaticDimension; TableView.EstimatedRowHeight = 70; TableView.Source = new TableSource(this); TableView.AllowsSelection = true; base.ViewDidLoad(); if (_biometricLock) { if (!_biometricIntegrityValid) { return; } var tasks = Task.Run(async() => { await Task.Delay(500); NSRunLoop.Main.BeginInvokeOnMainThread(async() => await PromptBiometricAsync()); }); } }
public SendAddEditPage( AppOptions appOptions = null, string sendId = null, SendType?type = null) { _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _appOptions = appOptions; InitializeComponent(); _vm = BindingContext as SendAddEditPageViewModel; _vm.Page = this; _vm.SendId = sendId; _vm.Type = appOptions?.CreateSend?.Item1 ?? type; SetActivityIndicator(); if (Device.RuntimePlatform == Device.Android) { if (_vm.EditMode) { ToolbarItems.Add(_removePassword); ToolbarItems.Add(_copyLink); ToolbarItems.Add(_shareLink); ToolbarItems.Add(_deleteItem); } _vm.SegmentedButtonHeight = 36; _vm.SegmentedButtonFontSize = 13; _vm.SegmentedButtonMargins = new Thickness(0, 10, 0, 0); _vm.EditorMargins = new Thickness(0, 5, 0, 0); _btnOptions.WidthRequest = 70; _btnOptionsDown.WidthRequest = 30; _btnOptionsUp.WidthRequest = 30; } else if (Device.RuntimePlatform == Device.iOS) { ToolbarItems.Add(_closeItem); if (_vm.EditMode) { ToolbarItems.Add(_moreItem); } _vm.SegmentedButtonHeight = 30; _vm.SegmentedButtonFontSize = 15; _vm.SegmentedButtonMargins = new Thickness(0, 5, 0, 0); _vm.ShowEditorSeparators = true; _vm.EditorMargins = new Thickness(0, 10, 0, 5); _deletionDateTypePicker.On <iOS>().SetUpdateMode(UpdateMode.WhenFinished); _expirationDateTypePicker.On <iOS>().SetUpdateMode(UpdateMode.WhenFinished); } _deletionDateTypePicker.ItemDisplayBinding = new Binding("Key"); _expirationDateTypePicker.ItemDisplayBinding = new Binding("Key"); if (_vm.IsText) { _nameEntry.ReturnType = ReturnType.Next; _nameEntry.ReturnCommand = new Command(() => _textEditor.Focus()); } }
public AutofillCiphersPage(AppOptions appOptions) { _appOptions = appOptions; InitializeComponent(); _vm = BindingContext as AutofillCiphersPageViewModel; _vm.Page = this; _vm.Init(appOptions); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); }
public AttachmentsPageViewModel() { _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _timeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); Attachments = new ExtendedObservableCollection <AttachmentView>(); DeleteAttachmentCommand = new Command <AttachmentView>(DeleteAsync); PageTitle = AppResources.Attachments; }
public GroupingsPage(bool mainPage, CipherType?type = null, string folderId = null, string collectionId = null, string pageTitle = null, string vaultFilterSelection = null, PreviousPageInfo previousPage = null, bool deleted = false) { _pageName = string.Concat(nameof(GroupingsPage), "_", DateTime.UtcNow.Ticks); InitializeComponent(); SetActivityIndicator(_mainContent); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _pushNotificationService = ServiceContainer.Resolve <IPushNotificationService>("pushNotificationService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _vm = BindingContext as GroupingsPageViewModel; _vm.Page = this; _vm.MainPage = mainPage; _vm.Type = type; _vm.FolderId = folderId; _vm.CollectionId = collectionId; _vm.Deleted = deleted; _previousPage = previousPage; if (pageTitle != null) { _vm.PageTitle = pageTitle; } if (vaultFilterSelection != null) { _vm.VaultFilterDescription = vaultFilterSelection; } if (Device.RuntimePlatform == Device.iOS) { _absLayout.Children.Remove(_fab); ToolbarItems.Add(_addItem); } else { ToolbarItems.Add(_syncItem); ToolbarItems.Add(_lockItem); ToolbarItems.Add(_exitItem); } if (deleted) { _absLayout.Children.Remove(_fab); ToolbarItems.Remove(_addItem); } if (!mainPage) { ToolbarItems.Remove(_accountAvatar); } }
public async override void OnFillRequest(FillRequest request, CancellationSignal cancellationSignal, FillCallback callback) { var structure = request.FillContexts?.LastOrDefault()?.Structure; if (structure == null) { return; } var parser = new Parser(structure, ApplicationContext); parser.Parse(); if (_storageService == null) { _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); } var shouldAutofill = await parser.ShouldAutofillAsync(_storageService); if (!shouldAutofill) { return; } var inlineAutofillEnabled = await _storageService.GetAsync <bool?>(Constants.InlineAutofillEnabledKey) ?? true; if (_vaultTimeoutService == null) { _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); } List <FilledItem> items = null; await _vaultTimeoutService.CheckVaultTimeoutAsync(); var locked = await _vaultTimeoutService.IsLockedAsync(); if (!locked) { if (_cipherService == null) { _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); } items = await AutofillHelpers.GetFillItemsAsync(parser, _cipherService); } // build response var response = AutofillHelpers.BuildFillResponse(parser, items, locked, inlineAutofillEnabled, request); callback.OnSuccess(response); }
public AutofillCiphersPage(AppOptions appOptions) { _appOptions = appOptions; InitializeComponent(); SetActivityIndicator(_mainContent); _vm = BindingContext as AutofillCiphersPageViewModel; _vm.Page = this; _vm.Init(appOptions); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); }
public AccountsManager(IBroadcasterService broadcasterService, IVaultTimeoutService vaultTimeoutService, IStorageService secureStorageService, IStateService stateService, IPlatformUtilsService platformUtilsService, IAuthService authService) { _broadcasterService = broadcasterService; _vaultTimeoutService = vaultTimeoutService; _secureStorageService = secureStorageService; _stateService = stateService; _platformUtilsService = platformUtilsService; _authService = authService; }
public SettingsPageViewModel() { _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _environmentService = ServiceContainer.Resolve <IEnvironmentService>("environmentService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); GroupedItems = new ExtendedObservableCollection <SettingsPageListGroup>(); PageTitle = AppResources.Settings; }
public LockPageViewModel() { _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService"); _environmentService = ServiceContainer.Resolve <IEnvironmentService>("environmentService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); PageTitle = AppResources.VerifyMasterPassword; TogglePasswordCommand = new Command(TogglePassword); SubmitCommand = new Command(async() => await SubmitAsync()); }
public SettingsPageViewModel() { _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _environmentService = ServiceContainer.Resolve <IEnvironmentService>("environmentService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _biometricService = ServiceContainer.Resolve <IBiometricService>("biometricService"); _policyService = ServiceContainer.Resolve <IPolicyService>("policyService"); _localizeService = ServiceContainer.Resolve <ILocalizeService>("localizeService"); _keyConnectorService = ServiceContainer.Resolve <IKeyConnectorService>("keyConnectorService"); _clipboardService = ServiceContainer.Resolve <IClipboardService>("clipboardService"); GroupedItems = new ObservableRangeCollection <ISettingsPageListItem>(); PageTitle = AppResources.Settings; }
public SendGroupingsPageViewModel() { _sendService = ServiceContainer.Resolve <ISendService>("sendService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); Loading = true; PageTitle = AppResources.Send; GroupedSends = new ObservableRangeCollection <ISendGroupingsPageListItem>(); RefreshCommand = new Command(async() => { Refreshing = true; await LoadAsync(); }); SendOptionsCommand = new Command <SendView>(SendOptionsAsync); }
public SettingsPageViewModel() { _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _environmentService = ServiceContainer.Resolve <IEnvironmentService>("environmentService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _biometricService = ServiceContainer.Resolve <IBiometricService>("biometricService"); _policyService = ServiceContainer.Resolve <IPolicyService>("policyService"); _localizeService = ServiceContainer.Resolve <ILocalizeService>("localizeService"); _keyConnectorService = ServiceContainer.Resolve <IKeyConnectorService>("keyConnectorService"); _clipboardService = ServiceContainer.Resolve <IClipboardService>("clipboardService"); _loggerService = ServiceContainer.Resolve <ILogger>("logger"); GroupedItems = new ObservableRangeCollection <ISettingsPageListItem>(); PageTitle = AppResources.Settings; ExecuteSettingItemCommand = new AsyncCommand <SettingsPageListItem>(item => item.ExecuteAsync(), onException: _loggerService.Exception, allowsMultipleExecutions: false); }
public SendAddOnlyPage( AppOptions appOptions = null, string sendId = null, SendType?type = null) { if (appOptions?.IosExtension != true) { throw new InvalidOperationException(nameof(SendAddOnlyPage) + " is only prepared to be used in iOS share extension"); } _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _appOptions = appOptions; InitializeComponent(); _vm = BindingContext as SendAddEditPageViewModel; _vm.Page = this; _vm.SendId = sendId; _vm.Type = appOptions?.CreateSend?.Item1 ?? type; if (_vm.IsText) { _nameEntry.ReturnType = ReturnType.Next; _nameEntry.ReturnCommand = new Command(() => _textEditor.Focus()); } }
public LockPageViewModel() { _apiService = ServiceContainer.Resolve <IApiService>("apiService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _environmentService = ServiceContainer.Resolve <IEnvironmentService>("environmentService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _biometricService = ServiceContainer.Resolve <IBiometricService>("biometricService"); _keyConnectorService = ServiceContainer.Resolve <IKeyConnectorService>("keyConnectorService"); _logger = ServiceContainer.Resolve <ILogger>("logger"); PageTitle = AppResources.VerifyMasterPassword; TogglePasswordCommand = new Command(TogglePassword); SubmitCommand = new Command(async() => await SubmitAsync()); AccountSwitchingOverlayViewModel = new AccountSwitchingOverlayViewModel(_stateService, _messagingService, _logger) { AllowAddAccountRow = true, AllowActiveAccountSelection = true }; }
public AddEditPage( string cipherId = null, CipherType?type = null, string folderId = null, string collectionId = null, string name = null, string uri = null, bool fromAutofill = false, AppOptions appOptions = null, bool cloneMode = false, ViewPage viewPage = null) { _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _keyConnectorService = ServiceContainer.Resolve <IKeyConnectorService>("keyConnectorService"); _appOptions = appOptions; _fromAutofill = fromAutofill; FromAutofillFramework = _appOptions?.FromAutofillFramework ?? false; InitializeComponent(); _vm = BindingContext as AddEditPageViewModel; _vm.Page = this; _vm.CipherId = cipherId; _vm.FolderId = folderId == "none" ? null : folderId; _vm.CollectionIds = collectionId != null ? new HashSet <string>(new List <string> { collectionId }) : null; _vm.CollectionsRepeaterView = _collectionsRepeaterView; _vm.Type = type; _vm.DefaultName = name ?? appOptions?.SaveName; _vm.DefaultUri = uri ?? appOptions?.Uri; _vm.CloneMode = cloneMode; _vm.ViewPage = viewPage; _vm.Init(); SetActivityIndicator(); if (_vm.EditMode && !_vm.CloneMode && Device.RuntimePlatform == Device.Android) { ToolbarItems.Add(_attachmentsItem); ToolbarItems.Add(_deleteItem); } if (Device.RuntimePlatform == Device.iOS) { ToolbarItems.Add(_closeItem); if (_vm.EditMode && !_vm.CloneMode) { ToolbarItems.Add(_moreItem); } _vm.ShowNotesSeparator = true; _typePicker.On <iOS>().SetUpdateMode(UpdateMode.WhenFinished); _ownershipPicker.On <iOS>().SetUpdateMode(UpdateMode.WhenFinished); } _typePicker.ItemDisplayBinding = new Binding("Key"); _cardBrandPicker.ItemDisplayBinding = new Binding("Key"); _cardExpMonthPicker.ItemDisplayBinding = new Binding("Key"); _identityTitlePicker.ItemDisplayBinding = new Binding("Key"); _folderPicker.ItemDisplayBinding = new Binding("Key"); _ownershipPicker.ItemDisplayBinding = new Binding("Key"); _loginPasswordEntry.Keyboard = Keyboard.Create(KeyboardFlags.None); _nameEntry.ReturnType = ReturnType.Next; _nameEntry.ReturnCommand = new Command(() => { if (_vm.Cipher.Type == CipherType.Login) { _loginUsernameEntry.Focus(); } else if (_vm.Cipher.Type == CipherType.Card) { _cardholderNameEntry.Focus(); } }); _loginUsernameEntry.ReturnType = ReturnType.Next; _loginUsernameEntry.ReturnCommand = new Command(() => _loginPasswordEntry.Focus()); _loginPasswordEntry.ReturnType = ReturnType.Next; _loginPasswordEntry.ReturnCommand = new Command(() => _loginTotpEntry.Focus()); _cardholderNameEntry.ReturnType = ReturnType.Next; _cardholderNameEntry.ReturnCommand = new Command(() => _cardNumberEntry.Focus()); _cardExpYearEntry.ReturnType = ReturnType.Next; _cardExpYearEntry.ReturnCommand = new Command(() => _cardCodeEntry.Focus()); _identityFirstNameEntry.ReturnType = ReturnType.Next; _identityFirstNameEntry.ReturnCommand = new Command(() => _identityMiddleNameEntry.Focus()); _identityMiddleNameEntry.ReturnType = ReturnType.Next; _identityMiddleNameEntry.ReturnCommand = new Command(() => _identityLastNameEntry.Focus()); _identityLastNameEntry.ReturnType = ReturnType.Next; _identityLastNameEntry.ReturnCommand = new Command(() => _identityUsernameEntry.Focus()); _identityUsernameEntry.ReturnType = ReturnType.Next; _identityUsernameEntry.ReturnCommand = new Command(() => _identityCompanyEntry.Focus()); _identityCompanyEntry.ReturnType = ReturnType.Next; _identityCompanyEntry.ReturnCommand = new Command(() => _identitySsnEntry.Focus()); _identitySsnEntry.ReturnType = ReturnType.Next; _identitySsnEntry.ReturnCommand = new Command(() => _identityPassportNumberEntry.Focus()); _identityPassportNumberEntry.ReturnType = ReturnType.Next; _identityPassportNumberEntry.ReturnCommand = new Command(() => _identityLicenseNumberEntry.Focus()); _identityLicenseNumberEntry.ReturnType = ReturnType.Next; _identityLicenseNumberEntry.ReturnCommand = new Command(() => _identityEmailEntry.Focus()); _identityEmailEntry.ReturnType = ReturnType.Next; _identityEmailEntry.ReturnCommand = new Command(() => _identityPhoneEntry.Focus()); _identityPhoneEntry.ReturnType = ReturnType.Next; _identityPhoneEntry.ReturnCommand = new Command(() => _identityAddress1Entry.Focus()); _identityAddress1Entry.ReturnType = ReturnType.Next; _identityAddress1Entry.ReturnCommand = new Command(() => _identityAddress2Entry.Focus()); _identityAddress2Entry.ReturnType = ReturnType.Next; _identityAddress2Entry.ReturnCommand = new Command(() => _identityAddress3Entry.Focus()); _identityAddress3Entry.ReturnType = ReturnType.Next; _identityAddress3Entry.ReturnCommand = new Command(() => _identityCityEntry.Focus()); _identityCityEntry.ReturnType = ReturnType.Next; _identityCityEntry.ReturnCommand = new Command(() => _identityStateEntry.Focus()); _identityStateEntry.ReturnType = ReturnType.Next; _identityStateEntry.ReturnCommand = new Command(() => _identityPostalCodeEntry.Focus()); _identityPostalCodeEntry.ReturnType = ReturnType.Next; _identityPostalCodeEntry.ReturnCommand = new Command(() => _identityCountryEntry.Focus()); }
public AuthService( ICryptoService cryptoService, ICryptoFunctionService cryptoFunctionService, IApiService apiService, IStateService stateService, ITokenService tokenService, IAppIdService appIdService, II18nService i18nService, IPlatformUtilsService platformUtilsService, IMessagingService messagingService, IVaultTimeoutService vaultTimeoutService, IKeyConnectorService keyConnectorService, bool setCryptoKeys = true) { _cryptoService = cryptoService; _cryptoFunctionService = cryptoFunctionService; _apiService = apiService; _stateService = stateService; _tokenService = tokenService; _appIdService = appIdService; _i18nService = i18nService; _platformUtilsService = platformUtilsService; _messagingService = messagingService; _keyConnectorService = keyConnectorService; _setCryptoKeys = setCryptoKeys; TwoFactorProviders = new Dictionary <TwoFactorProviderType, TwoFactorProvider>(); TwoFactorProviders.Add(TwoFactorProviderType.Authenticator, new TwoFactorProvider { Type = TwoFactorProviderType.Authenticator, Priority = 1, Sort = 1 }); TwoFactorProviders.Add(TwoFactorProviderType.YubiKey, new TwoFactorProvider { Type = TwoFactorProviderType.YubiKey, Priority = 3, Sort = 2, Premium = true }); TwoFactorProviders.Add(TwoFactorProviderType.Duo, new TwoFactorProvider { Type = TwoFactorProviderType.Duo, Name = "Duo", Priority = 2, Sort = 3, Premium = true }); TwoFactorProviders.Add(TwoFactorProviderType.OrganizationDuo, new TwoFactorProvider { Type = TwoFactorProviderType.OrganizationDuo, Name = "Duo (Organization)", Priority = 10, Sort = 4 }); TwoFactorProviders.Add(TwoFactorProviderType.Fido2WebAuthn, new TwoFactorProvider { Type = TwoFactorProviderType.Fido2WebAuthn, Priority = 4, Sort = 5, Premium = true }); TwoFactorProviders.Add(TwoFactorProviderType.Email, new TwoFactorProvider { Type = TwoFactorProviderType.Email, Priority = 0, Sort = 6, }); }
public App(AppOptions appOptions) { Options = appOptions ?? new AppOptions(); if (Options.IosExtension) { Current = this; return; } _userService = ServiceContainer.Resolve <IUserService>("userService"); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _authService = ServiceContainer.Resolve <IAuthService>("authService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); Bootstrap(); _broadcasterService.Subscribe(nameof(App), async(message) => { if (message.Command == "showDialog") { var details = message.Data as DialogDetails; var confirmed = true; var confirmText = string.IsNullOrWhiteSpace(details.ConfirmText) ? AppResources.Ok : details.ConfirmText; Device.BeginInvokeOnMainThread(async() => { 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 <int, bool>(details.DialogId, confirmed)); }); } else if (message.Command == "locked") { await LockedAsync(!(message.Data as bool?).GetValueOrDefault()); } else if (message.Command == "lockVault") { await _vaultTimeoutService.LockAsync(true); } else if (message.Command == "logout") { Device.BeginInvokeOnMainThread(async() => await LogOutAsync((message.Data as bool?).GetValueOrDefault())); } else if (message.Command == "loggedOut") { // Clean up old migrated key if they ever log out. await _secureStorageService.RemoveAsync("oldKey"); } else if (message.Command == "resumed") { if (Device.RuntimePlatform == Device.iOS) { ResumedAsync(); } } else if (message.Command == "slept") { if (Device.RuntimePlatform == Device.iOS) { await SleptAsync(); } } else if (message.Command == "migrated") { await Task.Delay(1000); await SetMainPageAsync(); } else if (message.Command == "popAllAndGoToTabGenerator" || message.Command == "popAllAndGoToTabMyVault" || message.Command == "popAllAndGoToTabSend") { Device.BeginInvokeOnMainThread(async() => { if (Current.MainPage is TabsPage tabsPage) { while (tabsPage.Navigation.ModalStack.Count > 0) { await tabsPage.Navigation.PopModalAsync(false); } 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())); }); } }); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Forms.Init(); InitApp(); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _eventService = ServiceContainer.Resolve <IEventService>("eventService"); LoadApplication(new App.App(null)); iOSCoreHelpers.AppearanceAdjustments(); ZXing.Net.Mobile.Forms.iOS.Platform.Init(); _broadcasterService.Subscribe(nameof(AppDelegate), async(message) => { if (message.Command == "startEventTimer") { StartEventTimer(); } else if (message.Command == "stopEventTimer") { var task = StopEventTimerAsync(); } else if (message.Command == "updatedTheme") { Device.BeginInvokeOnMainThread(() => { iOSCoreHelpers.AppearanceAdjustments(); }); } else if (message.Command == "copiedToClipboard") { Device.BeginInvokeOnMainThread(() => { var task = ClearClipboardTimerAsync(message.Data as Tuple <string, int?, bool>); }); } else if (message.Command == "listenYubiKeyOTP") { iOSCoreHelpers.ListenYubiKey((bool)message.Data, _deviceActionService, _nfcSession, _nfcDelegate); } else if (message.Command == "unlocked") { var needsAutofillReplacement = await _storageService.GetAsync <bool?>( Core.Constants.AutofillNeedsIdentityReplacementKey); if (needsAutofillReplacement.GetValueOrDefault()) { await ASHelpers.ReplaceAllIdentities(); } } else if (message.Command == "showAppExtension") { Device.BeginInvokeOnMainThread(() => ShowAppExtension((ExtensionPageViewModel)message.Data)); } else if (message.Command == "showStatusBar") { Device.BeginInvokeOnMainThread(() => UIApplication.SharedApplication.SetStatusBarHidden(!(bool)message.Data, false)); } else if (message.Command == "syncCompleted") { if (message.Data is Dictionary <string, object> 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 == "loggedOut") { 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 _storageService.GetAsync <string>(Constants.VaultTimeoutActionKey); if (timeoutAction == "logOut") { await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync(); } else { await ASHelpers.ReplaceAllIdentities(); } } }); return(base.FinishedLaunching(app, options)); }
public App(AppOptions appOptions) { Options = appOptions ?? new AppOptions(); if (Options.IosExtension) { Current = this; return; } _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _authService = ServiceContainer.Resolve <IAuthService>("authService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _accountsManager = ServiceContainer.Resolve <IAccountsManager>("accountsManager"); _accountsManager.Init(() => Options, this); Bootstrap(); _broadcasterService.Subscribe(nameof(App), async(message) => { try { if (message.Command == "showDialog") { var details = message.Data as DialogDetails; var confirmed = true; var confirmText = string.IsNullOrWhiteSpace(details.ConfirmText) ? AppResources.Ok : details.ConfirmText; Device.BeginInvokeOnMainThread(async() => { 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 <int, bool>(details.DialogId, confirmed)); }); } else if (message.Command == "resumed") { 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())); }); } } catch (Exception ex) { LoggerHelper.LogEvenIfCantBeResolved(ex); } }); }
public AuthService( ICryptoService cryptoService, IApiService apiService, IUserService userService, ITokenService tokenService, IAppIdService appIdService, II18nService i18nService, IPlatformUtilsService platformUtilsService, IMessagingService messagingService, IVaultTimeoutService vaultTimeoutService, bool setCryptoKeys = true) { _cryptoService = cryptoService; _apiService = apiService; _userService = userService; _tokenService = tokenService; _appIdService = appIdService; _i18nService = i18nService; _platformUtilsService = platformUtilsService; _messagingService = messagingService; _vaultTimeoutService = vaultTimeoutService; _setCryptoKeys = setCryptoKeys; TwoFactorProviders = new Dictionary <TwoFactorProviderType, TwoFactorProvider>(); TwoFactorProviders.Add(TwoFactorProviderType.Authenticator, new TwoFactorProvider { Type = TwoFactorProviderType.Authenticator, Priority = 1, Sort = 1 }); TwoFactorProviders.Add(TwoFactorProviderType.YubiKey, new TwoFactorProvider { Type = TwoFactorProviderType.YubiKey, Priority = 3, Sort = 2, Premium = true }); TwoFactorProviders.Add(TwoFactorProviderType.Duo, new TwoFactorProvider { Type = TwoFactorProviderType.Duo, Name = "Duo", Priority = 2, Sort = 3, Premium = true }); TwoFactorProviders.Add(TwoFactorProviderType.OrganizationDuo, new TwoFactorProvider { Type = TwoFactorProviderType.OrganizationDuo, Name = "Duo (Organization)", Priority = 10, Sort = 4 }); TwoFactorProviders.Add(TwoFactorProviderType.U2f, new TwoFactorProvider { Type = TwoFactorProviderType.U2f, Priority = 4, Sort = 5, Premium = true }); TwoFactorProviders.Add(TwoFactorProviderType.Email, new TwoFactorProvider { Type = TwoFactorProviderType.Email, Priority = 0, Sort = 6, }); TwoFactorProviders.Add(TwoFactorProviderType.Fido2, new TwoFactorProvider { Type = TwoFactorProviderType.Fido2, Priority = 5, // give more priority than everyone else except the "OrganizationDuo" Sort = 7, Premium = true }); }
public override async void ViewDidLoad() { _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _biometricService = ServiceContainer.Resolve <IBiometricService>("biometricService"); _keyConnectorService = ServiceContainer.Resolve <IKeyConnectorService>("keyConnectorService"); // We re-use the lock screen for autofill extension to verify master password // when trying to access protected items. if (autofillExtension && await _storageService.GetAsync <bool>(Bit.Core.Constants.PasswordRepromptAutofillKey)) { _passwordReprompt = true; _pinSet = Tuple.Create(false, false); _pinLock = false; _biometricLock = false; } else { _pinSet = _vaultTimeoutService.IsPinLockSetAsync().GetAwaiter().GetResult(); _pinLock = (_pinSet.Item1 && _vaultTimeoutService.PinProtectedKey != null) || _pinSet.Item2; _biometricLock = _vaultTimeoutService.IsBiometricLockSetAsync().GetAwaiter().GetResult() && _cryptoService.HasKeyAsync().GetAwaiter().GetResult(); _biometricIntegrityValid = _biometricService.ValidateIntegrityAsync(BiometricIntegrityKey).GetAwaiter() .GetResult(); _usesKeyConnector = await _keyConnectorService.GetUsesKeyConnector(); _biometricUnlockOnly = _usesKeyConnector && _biometricLock && !_pinLock; } if (_pinLock) { BaseNavItem.Title = AppResources.VerifyPIN; } else if (_usesKeyConnector) { BaseNavItem.Title = AppResources.UnlockVault; } else { BaseNavItem.Title = AppResources.VerifyMasterPassword; } BaseCancelButton.Title = AppResources.Cancel; if (_biometricUnlockOnly) { BaseSubmitButton.Title = null; BaseSubmitButton.Enabled = false; } else { BaseSubmitButton.Title = AppResources.Submit; } var descriptor = UIFontDescriptor.PreferredBody; if (!_biometricUnlockOnly) { MasterPasswordCell.Label.Text = _pinLock ? AppResources.PIN : AppResources.MasterPassword; MasterPasswordCell.TextField.SecureTextEntry = true; MasterPasswordCell.TextField.ReturnKeyType = UIReturnKeyType.Go; MasterPasswordCell.TextField.ShouldReturn += (UITextField tf) => { CheckPasswordAsync().GetAwaiter().GetResult(); return(true); }; if (_pinLock) { MasterPasswordCell.TextField.KeyboardType = UIKeyboardType.NumberPad; } MasterPasswordCell.Button.TitleLabel.Font = UIFont.FromName("FontAwesome", 28f); MasterPasswordCell.Button.SetTitle("\uf06e", UIControlState.Normal); MasterPasswordCell.Button.TouchUpInside += (sender, e) => { MasterPasswordCell.TextField.SecureTextEntry = !MasterPasswordCell.TextField.SecureTextEntry; MasterPasswordCell.Button.SetTitle(MasterPasswordCell.TextField.SecureTextEntry ? "\uf06e" : "\uf070", UIControlState.Normal); }; } TableView.RowHeight = UITableView.AutomaticDimension; TableView.EstimatedRowHeight = 70; TableView.Source = new TableSource(this); TableView.AllowsSelection = true; base.ViewDidLoad(); if (_biometricLock) { if (!_biometricIntegrityValid) { return; } var tasks = Task.Run(async() => { await Task.Delay(500); NSRunLoop.Main.BeginInvokeOnMainThread(async() => await PromptBiometricAsync()); }); } }
public async override void OnFillRequest(FillRequest request, CancellationSignal cancellationSignal, FillCallback callback) { try { var structure = request.FillContexts?.LastOrDefault()?.Structure; if (structure == null) { return; } var parser = new Parser(structure, ApplicationContext); parser.Parse(); if (_storageService == null) { _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); } var shouldAutofill = await parser.ShouldAutofillAsync(_storageService); if (!shouldAutofill) { return; } var inlineAutofillEnabled = await _storageService.GetAsync <bool?>(Constants.InlineAutofillEnabledKey) ?? true; if (_vaultTimeoutService == null) { _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); } List <FilledItem> items = null; await _vaultTimeoutService.CheckVaultTimeoutAsync(); var locked = await _vaultTimeoutService.IsLockedAsync(); if (!locked) { if (_cipherService == null) { _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); } items = await AutofillHelpers.GetFillItemsAsync(parser, _cipherService); } // build response var response = AutofillHelpers.CreateFillResponse(parser, items, locked, inlineAutofillEnabled, request); var disableSavePrompt = await _storageService.GetAsync <bool?>(Constants.AutofillDisableSavePromptKey); if (!disableSavePrompt.GetValueOrDefault()) { AutofillHelpers.AddSaveInfo(parser, request, response, parser.FieldCollection); } callback.OnSuccess(response.Build()); } catch (Exception e) { #if !FDROID Crashes.TrackError(e); #endif } }
public override async void ViewDidLoad() { _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _biometricService = ServiceContainer.Resolve <IBiometricService>("biometricService"); _keyConnectorService = ServiceContainer.Resolve <IKeyConnectorService>("keyConnectorService"); _accountManager = ServiceContainer.Resolve <IAccountsManager>("accountsManager"); // We re-use the lock screen for autofill extension to verify master password // when trying to access protected items. if (autofillExtension && await _stateService.GetPasswordRepromptAutofillAsync()) { _passwordReprompt = true; _isPinProtected = false; _isPinProtectedWithKey = false; _pinLock = false; _biometricLock = false; } else { (_isPinProtected, _isPinProtectedWithKey) = await _vaultTimeoutService.IsPinLockSetAsync(); _pinLock = (_isPinProtected && await _stateService.GetPinProtectedKeyAsync() != null) || _isPinProtectedWithKey; _biometricLock = await _vaultTimeoutService.IsBiometricLockSetAsync() && await _cryptoService.HasKeyAsync(); _biometricIntegrityValid = await _biometricService.ValidateIntegrityAsync(BiometricIntegrityKey); _usesKeyConnector = await _keyConnectorService.GetUsesKeyConnector(); _biometricUnlockOnly = _usesKeyConnector && _biometricLock && !_pinLock; } if (_pinLock) { BaseNavItem.Title = AppResources.VerifyPIN; } else if (_usesKeyConnector) { BaseNavItem.Title = AppResources.UnlockVault; } else { BaseNavItem.Title = AppResources.VerifyMasterPassword; } BaseCancelButton.Title = AppResources.Cancel; if (_biometricUnlockOnly) { BaseSubmitButton.Title = null; BaseSubmitButton.Enabled = false; } else { BaseSubmitButton.Title = AppResources.Submit; } var descriptor = UIFontDescriptor.PreferredBody; if (!_biometricUnlockOnly) { MasterPasswordCell.Label.Text = _pinLock ? AppResources.PIN : AppResources.MasterPassword; MasterPasswordCell.TextField.SecureTextEntry = true; MasterPasswordCell.TextField.ReturnKeyType = UIReturnKeyType.Go; MasterPasswordCell.TextField.ShouldReturn += (UITextField tf) => { CheckPasswordAsync().GetAwaiter().GetResult(); return(true); }; if (_pinLock) { MasterPasswordCell.TextField.KeyboardType = UIKeyboardType.NumberPad; } MasterPasswordCell.Button.TitleLabel.Font = UIFont.FromName("bwi-font", 28f); MasterPasswordCell.Button.SetTitle(BitwardenIcons.Eye, UIControlState.Normal); MasterPasswordCell.Button.TouchUpInside += (sender, e) => { MasterPasswordCell.TextField.SecureTextEntry = !MasterPasswordCell.TextField.SecureTextEntry; MasterPasswordCell.Button.SetTitle(MasterPasswordCell.TextField.SecureTextEntry ? BitwardenIcons.Eye : BitwardenIcons.EyeSlash, UIControlState.Normal); }; } if (TableView != null) { TableView.BackgroundColor = ThemeHelpers.BackgroundColor; TableView.SeparatorColor = ThemeHelpers.SeparatorColor; TableView.RowHeight = UITableView.AutomaticDimension; TableView.EstimatedRowHeight = 70; TableView.Source = new TableSource(this); TableView.AllowsSelection = true; } base.ViewDidLoad(); if (_biometricLock) { if (!_biometricIntegrityValid) { return; } var tasks = Task.Run(async() => { await Task.Delay(500); NSRunLoop.Main.BeginInvokeOnMainThread(async() => await PromptBiometricAsync()); }); } }