Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
update libs. support favs, extras, and skipping shared
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Feb 22, 2023
1 parent d02fe9a commit bc5b795
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Importer/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected override Window CreateWindow(IActivationState activationState)
{
var window = base.CreateWindow(activationState);
window.Width = 650;
window.Height = 1100;
window.Height = 1150;
window.Title = "Bitwarden Importer";
return window;
}
Expand Down
2 changes: 1 addition & 1 deletion Importer/Importer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<ItemGroup>
<PackageReference Include="CsvHelper" Version="30.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="PasswordManagerAccess" Version="10.2.1" />
<PackageReference Include="PasswordManagerAccess" Version="10.3.0" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions Importer/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@
x:Name="LastPassPassword"
IsPassword="True" />
</VerticalStackLayout>

<HorizontalStackLayout>
<CheckBox
x:Name="LastPassSkipShared"
VerticalOptions="Center" />
<Label
x:Name="LastPassSkipSharedLabel"
Text="Skip items from shared folders"
VerticalOptions="Center" />
</HorizontalStackLayout>
</VerticalStackLayout>

<HorizontalStackLayout
Expand Down
35 changes: 24 additions & 11 deletions Importer/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,14 @@ private async Task<(bool, string)> CreateLastpassCsvAsync()
PasswordManagerAccess.LastPass.Platform.Desktop,
Guid.NewGuid().ToString().ToLower(),
"Importer");
var vault = Vault.Open(LastPassEmail?.Text, LastPassPassword?.Text, clientInfo, ui);
var vault = Vault.Open(LastPassEmail?.Text, LastPassPassword?.Text, clientInfo, ui,
new ParserOptions { ParseSecureNotesToAccount = false });

// Filter accounts
var filteredAccounts = vault.Accounts.Where(a => !a.IsShared || (a.IsShared && !LastPassSkipShared.IsChecked));

// Massage it to expected CSV format
var exportAccounts = vault.Accounts.Select(a => new Services.LastPass.ExportedAccount(a));
var exportAccounts = filteredAccounts.Select(a => new Services.LastPass.ExportedAccount(a));

// Create CSV string
using var writer = new StringWriter();
Expand Down Expand Up @@ -350,26 +354,29 @@ public static void ExecBash(string cmd)

private void ClearInputs()
{
BitwardenServerUrl.Text = string.Empty;
BitwardenApiKeyClientId.Text = string.Empty;
BitwardenApiKeySecret.Text = string.Empty;
BitwardenKeyConnector.IsChecked = false;
BitwardenPassword.Text = string.Empty;
LastPassEmail.Text = string.Empty;
LastPassPassword.Text = string.Empty;
Dispatcher.Dispatch(() =>
{
BitwardenServerUrl.Text = string.Empty;
BitwardenApiKeyClientId.Text = string.Empty;
BitwardenApiKeySecret.Text = string.Empty;
BitwardenKeyConnector.IsChecked = false;
BitwardenPassword.Text = string.Empty;
LastPassEmail.Text = string.Empty;
LastPassPassword.Text = string.Empty;
});
}

private void ParseCommandlineDefaults()
{
var args = Environment.GetCommandLineArgs();
foreach (var arg in args)
{
if (!arg.Contains("="))
if (!arg.Contains('='))
{
continue;
}

var argParts = arg.Split('=');
var argParts = arg.Split(new[] { '=' }, 2);
if (argParts.Length < 2)
{
continue;
Expand Down Expand Up @@ -416,6 +423,12 @@ private void ParseCommandlineDefaults()
LastPassPassword.Text = argParts[1];
continue;
}

if (argParts[0] == "lastpassSkipShared")
{
LastPassSkipShared.IsChecked = argParts[1] == "1";
continue;
}
}
}
}
4 changes: 2 additions & 2 deletions Importer/Services/LastPass/ExportedAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public ExportedAccount(Account account)
Username = account.Username;
Password = account.Password;
// Totp not supported
// Extra = account.Notes;
Extra = account.Notes;
Name = account.Name;
Grouping = account.Path == "(none)" ? null : account.Path;
// Fav = account.Favorite == "1" ? 1 : 0;
Fav = account.IsFavorite ? 1 : 0;
}

[Name("url")]
Expand Down

0 comments on commit bc5b795

Please sign in to comment.