1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-20 10:13:42 +00:00
Files
mobile/src/Core/Models/Domain/UsernameGenerationOptions.cs
cubemike99 f98dfa6581 [PM-4800] Send item domain name to fastmail (#2867)
* Send item domain name to fastmail

- Added a metadata field (forDomain:) to the Fastmail Forwarder API
  request that's set to the domain name of the item being added to the
  vault, or to "" if the username generator is being used in standalone
  mode. This allows the user's Fastmail account to display the domain
  name for the username that was generated.

* Minor changes for readability

* dotnet format

---------

Co-authored-by:  Audrey  <ajensen@bitwarden.com>
2023-11-17 17:17:25 -05:00

70 lines
2.8 KiB
C#

using Bit.Core.Enums;
using Bit.Core.Services.EmailForwarders;
namespace Bit.Core.Models.Domain
{
public class UsernameGenerationOptions
{
public UsernameGenerationOptions()
{
ServiceType = ForwardedEmailServiceType.None;
}
public UsernameType Type { get; set; }
public ForwardedEmailServiceType ServiceType { get; set; }
public UsernameEmailType PlusAddressedEmailType { get; set; }
public UsernameEmailType CatchAllEmailType { get; set; }
public bool CapitalizeRandomWordUsername { get; set; }
public bool IncludeNumberRandomWordUsername { get; set; }
public string PlusAddressedEmail { get; set; }
public string CatchAllEmailDomain { get; set; }
public string FirefoxRelayApiAccessToken { get; set; }
public string SimpleLoginApiKey { get; set; }
public string DuckDuckGoApiKey { get; set; }
public string FastMailApiKey { get; set; }
public string AnonAddyApiAccessToken { get; set; }
public string AnonAddyDomainName { get; set; }
public string ForwardEmailApiAccessToken { get; set; }
public string ForwardEmailDomainName { get; set; }
public string EmailWebsite { get; set; }
public ForwarderOptions GetForwarderOptions()
{
if (Type != UsernameType.ForwardedEmailAlias)
{
return null;
}
switch (ServiceType)
{
case ForwardedEmailServiceType.AnonAddy:
return new AnonAddyForwarderOptions
{
ApiKey = AnonAddyApiAccessToken,
DomainName = AnonAddyDomainName
};
case ForwardedEmailServiceType.DuckDuckGo:
return new ForwarderOptions { ApiKey = DuckDuckGoApiKey };
case ForwardedEmailServiceType.Fastmail:
return new FastmailForwarderOptions
{
ApiKey = FastMailApiKey,
Website = EmailWebsite
};
case ForwardedEmailServiceType.FirefoxRelay:
return new ForwarderOptions { ApiKey = FirefoxRelayApiAccessToken };
case ForwardedEmailServiceType.SimpleLogin:
return new ForwarderOptions { ApiKey = SimpleLoginApiKey };
case ForwardedEmailServiceType.ForwardEmail:
return new ForwardEmailForwarderOptions
{
ApiKey = ForwardEmailApiAccessToken,
DomainName = ForwardEmailDomainName
};
default:
return null;
}
}
}
}