1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-21 02:33:36 +00:00

Enable Encrypted json export of vaults (#1174)

* Enable Encrypted json export of vaults

* Match jslib export of non-org ciphers

* Clean up export

* Update src/App/Pages/Settings/ExportVaultPage.xaml.cs

Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com>

Co-authored-by: Matt Gibson <mdgibson@Matts-MBP.lan>
Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com>
This commit is contained in:
Matt Gibson
2020-12-14 11:56:13 -06:00
committed by GitHub
parent 6e40b7f25b
commit 3227daddaf
18 changed files with 242 additions and 54 deletions

View File

@@ -22,10 +22,12 @@ namespace Bit.App.Pages
private readonly IExportService _exportService;
private int _fileFormatSelectedIndex;
private string _exportWarningMessage;
private bool _showPassword;
private string _masterPassword;
private byte[] _exportResult;
private string _defaultFilename;
private bool _initialized = false;
public ExportVaultPageViewModel()
{
@@ -42,13 +44,16 @@ namespace Bit.App.Pages
FileFormatOptions = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("json", ".json"),
new KeyValuePair<string, string>("csv", ".csv")
new KeyValuePair<string, string>("csv", ".csv"),
new KeyValuePair<string, string>("encrypted_json", ".json (Encrypted)")
};
}
public async Task InitAsync()
{
_initialized = true;
FileFormatSelectedIndex = FileFormatOptions.FindIndex(k => k.Key == "json");
UpdateWarning();
}
public List<KeyValuePair<string, string>> FileFormatOptions { get; set; }
@@ -59,6 +64,12 @@ namespace Bit.App.Pages
set { SetProperty(ref _fileFormatSelectedIndex, value); }
}
public string ExportWarningMessage
{
get => _exportWarningMessage;
set { SetProperty(ref _exportWarningMessage, value); }
}
public bool ShowPassword
{
get => _showPassword;
@@ -140,6 +151,24 @@ namespace Bit.App.Pages
await _platformUtilsService.ShowDialogAsync(_i18nService.T("ExportVaultFailure"));
}
public void UpdateWarning()
{
if (!_initialized)
{
return;
}
switch (FileFormatOptions[FileFormatSelectedIndex].Key)
{
case "encrypted_json":
ExportWarningMessage = _i18nService.T("EncExportVaultWarning");
break;
default:
ExportWarningMessage = _i18nService.T("ExportVaultWarning");
break;
}
}
private void ClearResult()
{
_defaultFilename = null;