1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-24 04:04:34 +00:00

PM-4404 Added CreationDate to Fido2Credential objects and updated the UI bindings accordingly (#2832)

This commit is contained in:
Federico Maccaroni
2023-10-19 17:46:26 -03:00
committed by GitHub
parent 72de17bd1d
commit 142c3145f0
8 changed files with 52 additions and 14 deletions

View File

@@ -1,4 +1,5 @@
using Bit.Core.Models.Domain;
using System;
using Bit.Core.Models.Domain;
namespace Bit.Core.Models.Api
{
@@ -21,6 +22,7 @@ namespace Bit.Core.Models.Api
UserHandle = fido2Key.UserHandle?.EncryptedString;
UserName = fido2Key.UserName?.EncryptedString;
Counter = fido2Key.Counter?.EncryptedString;
CreationDate = fido2Key.CreationDate;
}
public string CredentialId { get; set; }
@@ -34,5 +36,6 @@ namespace Bit.Core.Models.Api
public string UserHandle { get; set; }
public string UserName { get; set; }
public string Counter { get; set; }
public DateTime CreationDate { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Bit.Core.Models.Api;
using System;
using Bit.Core.Models.Api;
namespace Bit.Core.Models.Data
{
@@ -19,6 +20,7 @@ namespace Bit.Core.Models.Data
UserHandle = apiData.UserHandle;
UserName = apiData.UserName;
Counter = apiData.Counter;
CreationDate = apiData.CreationDate;
}
public string CredentialId { get; set; }
@@ -32,5 +34,6 @@ namespace Bit.Core.Models.Data
public string UserHandle { get; set; }
public string UserName { get; set; }
public string Counter { get; set; }
public DateTime CreationDate { get; set; }
}
}

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Bit.Core.Models.Data;
using Bit.Core.Models.View;
@@ -7,7 +9,7 @@ namespace Bit.Core.Models.Domain
{
public class Fido2Credential : Domain
{
public static HashSet<string> EncryptableProperties => new HashSet<string>
public static HashSet<string> EncryptablePropertiesToMap => new HashSet<string>
{
nameof(CredentialId),
nameof(Discoverable),
@@ -22,11 +24,18 @@ namespace Bit.Core.Models.Domain
nameof(Counter)
};
public static HashSet<string> NonEncryptablePropertiesToMap => new HashSet<string>
{
nameof(CreationDate)
};
public static HashSet<string> AllPropertiesToMap => new HashSet<string>(EncryptablePropertiesToMap.Concat(NonEncryptablePropertiesToMap));
public Fido2Credential() { }
public Fido2Credential(Fido2CredentialData data, bool alreadyEncrypted = false)
{
BuildDomainModel(this, data, EncryptableProperties, alreadyEncrypted);
BuildDomainModel(this, data, AllPropertiesToMap, alreadyEncrypted, NonEncryptablePropertiesToMap);
}
public EncString CredentialId { get; set; }
@@ -40,16 +49,17 @@ namespace Bit.Core.Models.Domain
public EncString UserHandle { get; set; }
public EncString UserName { get; set; }
public EncString Counter { get; set; }
public DateTime CreationDate { get; set; }
public async Task<Fido2CredentialView> DecryptAsync(string orgId, SymmetricCryptoKey key = null)
{
return await DecryptObjAsync(new Fido2CredentialView(), this, EncryptableProperties, orgId, key);
return await DecryptObjAsync(new Fido2CredentialView(this), this, EncryptablePropertiesToMap, orgId, key);
}
public Fido2CredentialData ToFido2CredentialData()
{
var data = new Fido2CredentialData();
BuildDataModel(this, data, EncryptableProperties);
BuildDataModel(this, data, AllPropertiesToMap, NonEncryptablePropertiesToMap);
return data;
}
}

View File

@@ -1,10 +1,21 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Bit.Core.Enums;
using Bit.Core.Models.Domain;
namespace Bit.Core.Models.View
{
public class Fido2CredentialView : ItemView, ILaunchableView
{
public Fido2CredentialView()
{
}
public Fido2CredentialView(Fido2Credential fido2Credential)
{
CreationDate = fido2Credential.CreationDate;
}
public string CredentialId { get; set; }
public string Discoverable { get; set; }
public string KeyType { get; set; } = Constants.DefaultFido2CredentialType;
@@ -16,6 +27,7 @@ namespace Bit.Core.Models.View
public string UserHandle { get; set; }
public string UserName { get; set; }
public string Counter { get; set; }
public DateTime CreationDate { get; set; }
public override string SubTitle => UserName;
public override List<KeyValuePair<string, LinkedIdType>> LinkedFieldOptions => new List<KeyValuePair<string, LinkedIdType>>();