1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-09 20:13:18 +00:00

[PM-5731] feat: add support for counter

This commit is contained in:
Andreas Coroiu
2024-01-22 13:26:19 +01:00
parent ad80defa40
commit d0e0f0ecdb
4 changed files with 114 additions and 10 deletions

View File

@@ -27,6 +27,11 @@ namespace Bit.Core.Models.View
public string Counter { get; set; }
public DateTime CreationDate { get; set; }
public int CounterValue {
get => int.TryParse(Counter, out var counter) ? counter : 0;
set => Counter = value.ToString();
}
public override string SubTitle => UserName;
public override List<KeyValuePair<string, LinkedIdType>> LinkedFieldOptions => new List<KeyValuePair<string, LinkedIdType>>();
public bool IsDiscoverable => bool.TryParse(Discoverable, out var isDiscoverable) && isDiscoverable;

View File

@@ -68,17 +68,27 @@ namespace Bit.Core.Services
throw new NotAllowedError();
}
// if (
// !userVerified &&
// (params.requireUserVerification || selectedCipher.reprompt !== CipherRepromptType.None)
// ) {
// this.logService?.warning(
// `[Fido2Authenticator] Aborting because user verification was unsuccessful.`,
// );
// throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.NotAllowed);
// }
try {
var selectedFido2Credential = selectedCipher.Login.MainFido2Credential;
var selectedCredentialId = selectedFido2Credential.CredentialId;
if (selectedFido2Credential.CounterValue != 0) {
++selectedFido2Credential.CounterValue;
}
var encrypted = await _cipherService.EncryptAsync(selectedCipher);
await _cipherService.SaveWithServerAsync(encrypted);
} catch {
_logService.Info(
"[Fido2Authenticator] Aborting because no matching credentials were found in the vault."
);
throw new UnknownError();
}
// TODO: IMPLEMENT this
return new Fido2AuthenticatorGetAssertionResult
{

View File

@@ -13,4 +13,11 @@ namespace Bit.Core.Utilities.Fido2
{
}
}
public class UnknownError : Fido2AuthenticatorException
{
public UnknownError() : base("UnknownError")
{
}
}
}