1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-16 07:07:32 -05:00

PM-11123: Device Type mapping (#4768)

* PM-11123: Device Type mapping

* PM-11123: Moving ClientType out of NotificationCenter, naming clash with Identity ClientType

* PM-11123: Rename ClientType in ICurrentContext to match the type
This commit is contained in:
Maciej Zieniuk
2024-09-23 23:02:32 +02:00
committed by GitHub
parent e1bf8a9206
commit 9a5c6fe527
20 changed files with 89 additions and 52 deletions

View File

@ -4,21 +4,56 @@ namespace Bit.Core.Utilities;
public static class DeviceTypes
{
public static IReadOnlyCollection<DeviceType> MobileTypes { get; } = new[]
{
public static IReadOnlyCollection<DeviceType> MobileTypes { get; } =
[
DeviceType.Android,
DeviceType.iOS,
DeviceType.AndroidAmazon,
};
DeviceType.AndroidAmazon
];
public static IReadOnlyCollection<DeviceType> DesktopTypes { get; } = new[]
{
public static IReadOnlyCollection<DeviceType> DesktopTypes { get; } =
[
DeviceType.LinuxDesktop,
DeviceType.MacOsDesktop,
DeviceType.WindowsDesktop,
DeviceType.UWP,
DeviceType.WindowsCLI,
DeviceType.MacOsCLI,
DeviceType.LinuxCLI,
};
DeviceType.LinuxCLI
];
public static IReadOnlyCollection<DeviceType> BrowserExtensionTypes { get; } =
[
DeviceType.ChromeExtension,
DeviceType.FirefoxExtension,
DeviceType.OperaExtension,
DeviceType.EdgeExtension,
DeviceType.VivaldiExtension,
DeviceType.SafariExtension
];
public static IReadOnlyCollection<DeviceType> BrowserTypes { get; } =
[
DeviceType.ChromeBrowser,
DeviceType.FirefoxBrowser,
DeviceType.OperaBrowser,
DeviceType.EdgeBrowser,
DeviceType.IEBrowser,
DeviceType.SafariBrowser,
DeviceType.VivaldiBrowser,
DeviceType.UnknownBrowser
];
private static ClientType ToClientType(DeviceType? deviceType)
{
return deviceType switch
{
not null when MobileTypes.Contains(deviceType.Value) => ClientType.Mobile,
not null when DesktopTypes.Contains(deviceType.Value) => ClientType.Desktop,
not null when BrowserExtensionTypes.Contains(deviceType.Value) => ClientType.Browser,
not null when BrowserTypes.Contains(deviceType.Value) => ClientType.Web,
_ => ClientType.All
};
}
}