mirror of
https://github.com/bitwarden/mobile
synced 2026-01-08 11:33:31 +00:00
PM-1575 Added discoverable passkeys and WIP non-discoverable ones
This commit is contained in:
@@ -114,5 +114,6 @@
|
||||
public const string ViewCellMenu = "\xe5d3";
|
||||
public const string Device = "\xe986";
|
||||
public const string Suitcase = "\xe98c";
|
||||
public const string Passkey = "\xe99f";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace Bit.Core.Models.Data
|
||||
OrganizationUseTotp = response.OrganizationUseTotp;
|
||||
Favorite = response.Favorite;
|
||||
RevisionDate = response.RevisionDate;
|
||||
CreationDate = response.CreationDate;
|
||||
DeletedDate = response.DeletedDate;
|
||||
Type = response.Type;
|
||||
Name = response.Name;
|
||||
Notes = response.Notes;
|
||||
@@ -64,7 +66,6 @@ namespace Bit.Core.Models.Data
|
||||
Fields = response.Fields?.Select(f => new FieldData(f)).ToList();
|
||||
Attachments = response.Attachments?.Select(a => new AttachmentData(a)).ToList();
|
||||
PasswordHistory = response.PasswordHistory?.Select(ph => new PasswordHistoryData(ph)).ToList();
|
||||
DeletedDate = response.DeletedDate;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
@@ -76,6 +77,8 @@ namespace Bit.Core.Models.Data
|
||||
public bool OrganizationUseTotp { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public Enums.CipherType Type { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Notes { get; set; }
|
||||
@@ -88,7 +91,6 @@ namespace Bit.Core.Models.Data
|
||||
public List<AttachmentData> Attachments { get; set; }
|
||||
public List<PasswordHistoryData> PasswordHistory { get; set; }
|
||||
public List<string> CollectionIds { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public Enums.CipherRepromptType Reprompt { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace Bit.Core.Models.Domain
|
||||
Edit = obj.Edit;
|
||||
ViewPassword = obj.ViewPassword;
|
||||
RevisionDate = obj.RevisionDate;
|
||||
CreationDate = obj.CreationDate;
|
||||
CollectionIds = obj.CollectionIds != null ? new HashSet<string>(obj.CollectionIds) : null;
|
||||
LocalData = localData;
|
||||
Reprompt = obj.Reprompt;
|
||||
@@ -71,6 +72,8 @@ namespace Bit.Core.Models.Domain
|
||||
public bool Edit { get; set; }
|
||||
public bool ViewPassword { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public Dictionary<string, object> LocalData { get; set; }
|
||||
public Login Login { get; set; }
|
||||
public Identity Identity { get; set; }
|
||||
@@ -81,7 +84,6 @@ namespace Bit.Core.Models.Domain
|
||||
public List<Field> Fields { get; set; }
|
||||
public List<PasswordHistory> PasswordHistory { get; set; }
|
||||
public HashSet<string> CollectionIds { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public CipherRepromptType Reprompt { get; set; }
|
||||
|
||||
public async Task<CipherView> DecryptAsync()
|
||||
@@ -174,6 +176,7 @@ namespace Bit.Core.Models.Domain
|
||||
OrganizationUseTotp = OrganizationUseTotp,
|
||||
Favorite = Favorite,
|
||||
RevisionDate = RevisionDate,
|
||||
CreationDate = CreationDate,
|
||||
Type = Type,
|
||||
CollectionIds = CollectionIds.ToList(),
|
||||
DeletedDate = DeletedDate,
|
||||
|
||||
@@ -73,6 +73,21 @@ namespace Bit.Core.Models.Request
|
||||
Type = cipher.SecureNote.Type
|
||||
};
|
||||
break;
|
||||
case CipherType.Fido2Key:
|
||||
Fido2Key = new Fido2KeyApi
|
||||
{
|
||||
NonDiscoverableId = cipher.Fido2Key.NonDiscoverableId?.EncryptedString,
|
||||
KeyType = cipher.Fido2Key.KeyType?.EncryptedString,
|
||||
KeyAlgorithm = cipher.Fido2Key.KeyAlgorithm?.EncryptedString,
|
||||
KeyCurve = cipher.Fido2Key.KeyCurve?.EncryptedString,
|
||||
KeyValue = cipher.Fido2Key.KeyValue?.EncryptedString,
|
||||
RpId = cipher.Fido2Key.RpId?.EncryptedString,
|
||||
RpName = cipher.Fido2Key.RpName?.EncryptedString,
|
||||
UserHandle = cipher.Fido2Key.UserHandle?.EncryptedString,
|
||||
UserName = cipher.Fido2Key.UserName?.EncryptedString,
|
||||
Counter = cipher.Fido2Key.Counter?.EncryptedString
|
||||
};
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -118,6 +133,7 @@ namespace Bit.Core.Models.Request
|
||||
public SecureNoteApi SecureNote { get; set; }
|
||||
public CardApi Card { get; set; }
|
||||
public IdentityApi Identity { get; set; }
|
||||
public Fido2KeyApi Fido2Key { get; set; }
|
||||
public List<FieldApi> Fields { get; set; }
|
||||
public List<PasswordHistoryRequest> PasswordHistory { get; set; }
|
||||
public Dictionary<string, string> Attachments { get; set; }
|
||||
|
||||
@@ -29,5 +29,6 @@ namespace Bit.Core.Models.Response
|
||||
public List<string> CollectionIds { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public CipherRepromptType Reprompt { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using Bit.Core.Models.Domain;
|
||||
|
||||
namespace Bit.Core.Models.View
|
||||
{
|
||||
public class CipherView : View
|
||||
public class CipherView : View, ILaunchableView
|
||||
{
|
||||
public CipherView() { }
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Bit.Core.Models.View
|
||||
LocalData = c.LocalData;
|
||||
CollectionIds = c.CollectionIds;
|
||||
RevisionDate = c.RevisionDate;
|
||||
CreationDate = c.CreationDate;
|
||||
DeletedDate = c.DeletedDate;
|
||||
Reprompt = c.Reprompt;
|
||||
}
|
||||
@@ -48,6 +49,7 @@ namespace Bit.Core.Models.View
|
||||
public List<PasswordHistoryView> PasswordHistory { get; set; }
|
||||
public HashSet<string> CollectionIds { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public CipherRepromptType Reprompt { get; set; }
|
||||
|
||||
@@ -112,5 +114,11 @@ namespace Bit.Core.Models.View
|
||||
{
|
||||
return LinkedFieldOptions.Find(lfo => lfo.Value == id).Key;
|
||||
}
|
||||
|
||||
public string ComparableName => Name + Login?.Username + Fido2Key?.UserName;
|
||||
|
||||
public bool CanLaunch => Login?.CanLaunch == true || Fido2Key?.CanLaunch == true;
|
||||
|
||||
public string LaunchUri => Login?.LaunchUri ?? Fido2Key?.LaunchUri;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Bit.Core.Enums;
|
||||
|
||||
namespace Bit.Core.Models.View
|
||||
{
|
||||
public class Fido2KeyView : ItemView
|
||||
public class Fido2KeyView : ItemView, ILaunchableView
|
||||
{
|
||||
public string NonDiscoverableId { get; set; }
|
||||
public string KeyType { get; set; } = Constants.DefaultFido2KeyType;
|
||||
@@ -17,7 +18,8 @@ namespace Bit.Core.Models.View
|
||||
public string Counter { get; set; }
|
||||
|
||||
public override string SubTitle => UserName;
|
||||
|
||||
public override List<KeyValuePair<string, LinkedIdType>> LinkedFieldOptions => new List<KeyValuePair<string, LinkedIdType>>();
|
||||
public bool CanLaunch => !string.IsNullOrEmpty(RpId);
|
||||
public string LaunchUri => $"https://{RpId}";
|
||||
}
|
||||
}
|
||||
|
||||
8
src/Core/Models/View/ILaunchableView.cs
Normal file
8
src/Core/Models/View/ILaunchableView.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Bit.Core.Models.View
|
||||
{
|
||||
public interface ILaunchableView
|
||||
{
|
||||
bool CanLaunch { get; }
|
||||
string LaunchUri { get; }
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.View
|
||||
{
|
||||
public class LoginUriView : View
|
||||
public class LoginUriView : View, ILaunchableView
|
||||
{
|
||||
private HashSet<string> _canLaunchWhitelist = new HashSet<string>
|
||||
{
|
||||
|
||||
@@ -176,6 +176,7 @@ namespace Bit.Core.Services
|
||||
OrganizationId = model.OrganizationId,
|
||||
Type = model.Type,
|
||||
CollectionIds = model.CollectionIds,
|
||||
CreationDate = model.CreationDate,
|
||||
RevisionDate = model.RevisionDate,
|
||||
Reprompt = model.Reprompt
|
||||
};
|
||||
@@ -1147,6 +1148,22 @@ namespace Bit.Core.Services
|
||||
"LicenseNumber"
|
||||
}, key);
|
||||
break;
|
||||
case CipherType.Fido2Key:
|
||||
cipher.Fido2Key = new Fido2Key();
|
||||
await EncryptObjPropertyAsync(model.Fido2Key, cipher.Fido2Key, new HashSet<string>
|
||||
{
|
||||
nameof(Fido2Key.NonDiscoverableId),
|
||||
nameof(Fido2Key.KeyType),
|
||||
nameof(Fido2Key.KeyAlgorithm),
|
||||
nameof(Fido2Key.KeyCurve),
|
||||
nameof(Fido2Key.KeyValue),
|
||||
nameof(Fido2Key.RpId),
|
||||
nameof(Fido2Key.RpName),
|
||||
nameof(Fido2Key.UserHandle),
|
||||
nameof(Fido2Key.UserName),
|
||||
nameof(Fido2Key.Counter)
|
||||
}, key);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Unknown cipher type.");
|
||||
}
|
||||
@@ -1229,8 +1246,8 @@ namespace Bit.Core.Services
|
||||
|
||||
public int Compare(CipherView a, CipherView b)
|
||||
{
|
||||
var aName = a?.Name;
|
||||
var bName = b?.Name;
|
||||
var aName = a?.ComparableName;
|
||||
var bName = b?.ComparableName;
|
||||
if (aName == null && bName != null)
|
||||
{
|
||||
return -1;
|
||||
@@ -1243,19 +1260,6 @@ namespace Bit.Core.Services
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var result = _i18nService.StringComparer.Compare(aName, bName);
|
||||
if (result != 0 || a.Type != CipherType.Login || b.Type != CipherType.Login)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if (a.Login.Username != null)
|
||||
{
|
||||
aName += a.Login.Username;
|
||||
}
|
||||
if (b.Login.Username != null)
|
||||
{
|
||||
bName += b.Login.Username;
|
||||
}
|
||||
return _i18nService.StringComparer.Compare(aName, bName);
|
||||
}
|
||||
}
|
||||
|
||||
14
src/Core/Utilities/CipherTypeExtensions.cs
Normal file
14
src/Core/Utilities/CipherTypeExtensions.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Bit.Core.Enums;
|
||||
|
||||
namespace Bit.Core.Utilities
|
||||
{
|
||||
public static class CipherTypeExtensions
|
||||
{
|
||||
public static bool IsEqualToOrCanSignIn(this CipherType type, CipherType type2)
|
||||
{
|
||||
return type == type2
|
||||
||
|
||||
(type == CipherType.Login && type2 == CipherType.Fido2Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user