Skip to content
21 changes: 19 additions & 2 deletions example/Dashlane/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@

namespace PasswordManagerAccess.Example.Dashlane
{
class TextUi : Ui
class TextUi(string totpSecret) : Ui
{
public override Passcode ProvideGoogleAuthPasscode(int attempt)
{
if (attempt > 0)
Bad("Google Authenticator code is invalid, try again");

if (!string.IsNullOrEmpty(totpSecret))
{
var totp = Util.CalculateGoogleAuthTotp(totpSecret);
Console.WriteLine($"Auto-generated TOTP: {totp}");
return new Passcode(totp, false);
}

return GetPasscode($"Please enter Google Authenticator code {ToCancel}");
}

Expand All @@ -35,6 +42,15 @@ public override Passcode ProvideEmailPasscode(int attempt)
}
}

public override bool OpenInBrowser(string url, int attempt)
{
Console.WriteLine("Please open the following URL in your browser to trigger the email token:");
Console.WriteLine(url);
Console.WriteLine("Press ENTER when you're done or type 'c' to cancel");

return Console.ReadLine()?.Trim().ToLower() != "c";
}

//
// Private
//
Expand Down Expand Up @@ -83,12 +99,13 @@ static void Main(string[] args)

var username = config["username"];
var password = config["password"];
config.TryGetValue("google-auth-totp-secret", out var totpSecret);

try
{
// Fetch and parse first.
Console.WriteLine("Fetching and parsing the remote vault");
var vault = Vault.Open(username, password, new TextUi(), new PlainStorage());
var vault = Vault.Open(username, password, new TextUi(totpSecret), new PlainStorage());

// And then dump the accounts.
Console.WriteLine("The vault has {0} account(s) in it:", vault.Accounts.Length);
Expand Down
23 changes: 2 additions & 21 deletions src/Dashlane/Account.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
// Copyright (C) Dmitry Yakimenko (detunized@gmail.com).
// Licensed under the terms of the MIT license. See LICENCE for details.

namespace PasswordManagerAccess.Dashlane
{
public class Account
{
public Account(string id, string name, string username, string password, string url, string note)
{
Id = id;
Name = name;
Username = username;
Password = password;
Url = url;
Note = note;
}
namespace PasswordManagerAccess.Dashlane;

public string Id { get; private set; }
public string Name { get; private set; }
public string Username { get; private set; }
public string Password { get; private set; }
public string Url { get; private set; }
public string Note { get; private set; }
}
}
public record Account(string Id, string Name, string Username, string Password, string Url, string Note);
Loading
Loading