1
0
mirror of https://github.com/bitwarden/mobile.git synced 2025-01-11 19:31:50 +01:00

refactor for cipher model changes and multi-uris

This commit is contained in:
Kyle Spearrin 2018-03-05 17:18:18 -05:00
parent 1f21a2ecc7
commit 83fd19784a
32 changed files with 491 additions and 223 deletions

View File

@ -0,0 +1,12 @@
namespace Bit.App.Enums
{
public enum UriMatchType : byte
{
Domain = 0,
Host = 1,
StartsWith = 2,
Exact = 3,
RegularExpression = 4,
Never = 5
}
}

View File

@ -1,12 +0,0 @@
namespace Bit.App.Models.Api
{
public class CardDataModel : CipherDataModel
{
public string CardholderName { get; set; }
public string Brand { get; set; }
public string Number { get; set; }
public string ExpMonth { get; set; }
public string ExpYear { get; set; }
public string Code { get; set; }
}
}

View File

@ -0,0 +1,24 @@
namespace Bit.App.Models.Api
{
public class CardType
{
public CardType() { }
public CardType(Cipher cipher)
{
CardholderName = cipher.Card.CardholderName?.EncryptedString;
Brand = cipher.Card.Brand?.EncryptedString;
Number = cipher.Card.Number?.EncryptedString;
ExpMonth = cipher.Card.ExpMonth?.EncryptedString;
ExpYear = cipher.Card.ExpYear?.EncryptedString;
Code = cipher.Card.Code?.EncryptedString;
}
public string CardholderName { get; set; }
public string Brand { get; set; }
public string Number { get; set; }
public string ExpMonth { get; set; }
public string ExpYear { get; set; }
public string Code { get; set; }
}
}

View File

@ -1,11 +0,0 @@
using System.Collections.Generic;
namespace Bit.App.Models.Api
{
public abstract class CipherDataModel
{
public string Name { get; set; }
public string Notes { get; set; }
public IEnumerable<FieldDataModel> Fields { get; set; }
}
}

View File

@ -1,11 +0,0 @@
using Bit.App.Enums;
namespace Bit.App.Models.Api
{
public class FieldDataModel
{
public FieldType Type { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
}

View File

@ -0,0 +1,18 @@
namespace Bit.App.Models.Api
{
public class FieldType
{
public FieldType() { }
public FieldType(Field field)
{
Type = field.Type;
Name = field.Name?.EncryptedString;
Value = field.Value?.EncryptedString;
}
public Enums.FieldType Type { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
}

View File

@ -1,24 +0,0 @@
namespace Bit.App.Models.Api
{
public class IdentityDataModel : CipherDataModel
{
public string Title { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string Address3 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
public string Company { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string SSN { get; set; }
public string Username { get; set; }
public string PassportNumber { get; set; }
public string LicenseNumber { get; set; }
}
}

View File

@ -0,0 +1,48 @@
namespace Bit.App.Models.Api
{
public class IdentityType
{
public IdentityType() { }
public IdentityType(Cipher cipher)
{
Title = cipher.Identity.Title?.EncryptedString;
FirstName = cipher.Identity.FirstName?.EncryptedString;
MiddleName = cipher.Identity.MiddleName?.EncryptedString;
LastName = cipher.Identity.LastName?.EncryptedString;
Address1 = cipher.Identity.Address1?.EncryptedString;
Address2 = cipher.Identity.Address2?.EncryptedString;
Address3 = cipher.Identity.Address3?.EncryptedString;
City = cipher.Identity.City?.EncryptedString;
State = cipher.Identity.State?.EncryptedString;
PostalCode = cipher.Identity.PostalCode?.EncryptedString;
Country = cipher.Identity.Country?.EncryptedString;
Company = cipher.Identity.Company?.EncryptedString;
Email = cipher.Identity.Email?.EncryptedString;
Phone = cipher.Identity.Phone?.EncryptedString;
SSN = cipher.Identity.SSN?.EncryptedString;
Username = cipher.Identity.Username?.EncryptedString;
PassportNumber = cipher.Identity.PassportNumber?.EncryptedString;
LicenseNumber = cipher.Identity.LicenseNumber?.EncryptedString;
}
public string Title { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string Address3 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
public string Company { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string SSN { get; set; }
public string Username { get; set; }
public string PassportNumber { get; set; }
public string LicenseNumber { get; set; }
}
}

View File

@ -1,10 +0,0 @@
namespace Bit.App.Models.Api
{
public class LoginDataModel : CipherDataModel
{
public string Uri { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Totp { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Bit.App.Models.Api
{
public class LoginType
{
public LoginType() { }
public LoginType(Cipher cipher)
{
Uris = cipher.Login.Uris.Select(u => new LoginUriType(u));
Username = cipher.Login.Username?.EncryptedString;
Password = cipher.Login.Password?.EncryptedString;
Totp = cipher.Login.Totp?.EncryptedString;
}
public IEnumerable<LoginUriType> Uris { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Totp { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using Bit.App.Enums;
namespace Bit.App.Models.Api
{
public class LoginUriType
{
public LoginUriType() { }
public LoginUriType(LoginUri u)
{
Uri = u.Uri?.EncryptedString;
Match = u.Match;
}
public string Uri { get; set; }
public UriMatchType? Match { get; set; }
}
}

View File

@ -17,12 +17,7 @@ namespace Bit.App.Models.Api
if(cipher.Fields != null)
{
Fields = cipher.Fields.Select(f => new FieldDataModel
{
Name = f.Name?.EncryptedString,
Value = f.Value?.EncryptedString,
Type = f.Type
});
Fields = cipher.Fields.Select(f => new FieldType(f));
}
switch(Type)
@ -50,101 +45,11 @@ namespace Bit.App.Models.Api
public bool Favorite { get; set; }
public string Name { get; set; }
public string Notes { get; set; }
public IEnumerable<FieldDataModel> Fields { get; set; }
public IEnumerable<FieldType> Fields { get; set; }
public LoginType Login { get; set; }
public CardType Card { get; set; }
public IdentityType Identity { get; set; }
public SecureNoteType SecureNote { get; set; }
public class LoginType
{
public LoginType(Cipher cipher)
{
Uri = cipher.Login.Uri?.EncryptedString;
Username = cipher.Login.Username?.EncryptedString;
Password = cipher.Login.Password?.EncryptedString;
Totp = cipher.Login.Totp?.EncryptedString;
}
public string Uri { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Totp { get; set; }
}
public class CardType
{
public CardType(Cipher cipher)
{
CardholderName = cipher.Card.CardholderName?.EncryptedString;
Brand = cipher.Card.Brand?.EncryptedString;
Number = cipher.Card.Number?.EncryptedString;
ExpMonth = cipher.Card.ExpMonth?.EncryptedString;
ExpYear = cipher.Card.ExpYear?.EncryptedString;
Code = cipher.Card.Code?.EncryptedString;
}
public string CardholderName { get; set; }
public string Brand { get; set; }
public string Number { get; set; }
public string ExpMonth { get; set; }
public string ExpYear { get; set; }
public string Code { get; set; }
}
public class IdentityType
{
public IdentityType(Cipher cipher)
{
Title = cipher.Identity.Title?.EncryptedString;
FirstName = cipher.Identity.FirstName?.EncryptedString;
MiddleName = cipher.Identity.MiddleName?.EncryptedString;
LastName = cipher.Identity.LastName?.EncryptedString;
Address1 = cipher.Identity.Address1?.EncryptedString;
Address2 = cipher.Identity.Address2?.EncryptedString;
Address3 = cipher.Identity.Address3?.EncryptedString;
City = cipher.Identity.City?.EncryptedString;
State = cipher.Identity.State?.EncryptedString;
PostalCode = cipher.Identity.PostalCode?.EncryptedString;
Country = cipher.Identity.Country?.EncryptedString;
Company = cipher.Identity.Company?.EncryptedString;
Email = cipher.Identity.Email?.EncryptedString;
Phone = cipher.Identity.Phone?.EncryptedString;
SSN = cipher.Identity.SSN?.EncryptedString;
Username = cipher.Identity.Username?.EncryptedString;
PassportNumber = cipher.Identity.PassportNumber?.EncryptedString;
LicenseNumber = cipher.Identity.LicenseNumber?.EncryptedString;
}
public string Title { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string Address3 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
public string Company { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string SSN { get; set; }
public string Username { get; set; }
public string PassportNumber { get; set; }
public string LicenseNumber { get; set; }
}
public class SecureNoteType
{
public SecureNoteType(Cipher cipher)
{
Type = cipher.SecureNote.Type;
}
public Enums.SecureNoteType Type { get; set; }
}
}
}

View File

@ -1,6 +1,5 @@
using Bit.App.Enums;
using System;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
namespace Bit.App.Models.Api
@ -15,7 +14,13 @@ namespace Bit.App.Models.Api
public bool Favorite { get; set; }
public bool Edit { get; set; }
public bool OrganizationUseTotp { get; set; }
public JObject Data { get; set; }
public string Name { get; set; }
public string Notes { get; set; }
public LoginType Login { get; set; }
public CardType Card { get; set; }
public IdentityType Identity { get; set; }
public SecureNoteType SecureNote { get; set; }
public IEnumerable<FieldType> Fields { get; set; }
public IEnumerable<AttachmentResponse> Attachments { get; set; }
public IEnumerable<string> CollectionIds { get; set; }
public DateTime RevisionDate { get; set; }

View File

@ -1,9 +0,0 @@
using Bit.App.Enums;
namespace Bit.App.Models.Api
{
public class SecureNoteDataModel : CipherDataModel
{
public SecureNoteType Type { get; set; }
}
}

View File

@ -0,0 +1,14 @@
namespace Bit.App.Models.Api
{
public class SecureNoteType
{
public SecureNoteType() { }
public SecureNoteType(Cipher cipher)
{
Type = cipher.SecureNote.Type;
}
public Enums.SecureNoteType Type { get; set; }
}
}

View File

@ -1,6 +1,6 @@
using Bit.App.Models.Api;
using Bit.App.Models.Data;
using Bit.App.Models.Data;
using Newtonsoft.Json;
using System;
namespace Bit.App.Models
{
@ -10,7 +10,19 @@ namespace Bit.App.Models
public Card(CipherData data)
{
var deserializedData = JsonConvert.DeserializeObject<CardDataModel>(data.Data);
CardDataModel deserializedData;
if(data.Card != null)
{
deserializedData = JsonConvert.DeserializeObject<CardDataModel>(data.Card);
}
else if(data.Data != null)
{
deserializedData = JsonConvert.DeserializeObject<CardDataModel>(data.Data);
}
else
{
throw new ArgumentNullException(nameof(data.Card));
}
CardholderName = deserializedData.CardholderName != null ?
new CipherString(deserializedData.CardholderName) : null;

View File

@ -1,5 +1,4 @@
using Bit.App.Enums;
using Bit.App.Models.Api;
using Bit.App.Models.Data;
using Newtonsoft.Json;
using System.Collections.Generic;

View File

@ -1,10 +1,10 @@
using System;
using SQLite;
using Bit.App.Abstractions;
using Bit.App.Models.Api;
using Newtonsoft.Json;
using System.Linq;
using Bit.App.Enums;
using Bit.App.Models.Api;
namespace Bit.App.Models.Data
{
@ -26,46 +26,38 @@ namespace Bit.App.Models.Data
OrganizationUseTotp = cipher.OrganizationUseTotp;
RevisionDateTime = cipher.RevisionDate;
Type = cipher.Type;
Data = JsonConvert.SerializeObject(cipher.Data);
Data = null;
CipherDataModel cipherData = null;
switch(cipher.Type)
{
case CipherType.Login:
var loginData = cipher.Data.ToObject<LoginDataModel>();
cipherData = loginData;
Uri = loginData.Uri;
Username = loginData.Username;
Password = loginData.Password;
Totp = loginData.Totp;
var loginData = new LoginDataModel(cipher);
Login = JsonConvert.SerializeObject(loginData);
break;
case CipherType.SecureNote:
var noteData = cipher.Data.ToObject<SecureNoteDataModel>();
cipherData = noteData;
SecureNoteType = noteData.Type;
var noteData = new SecureNoteDataModel(cipher);
SecureNote = JsonConvert.SerializeObject(noteData);
break;
case CipherType.Card:
var cardData = cipher.Data.ToObject<CardDataModel>();
cipherData = cardData;
var cardData = new CardDataModel(cipher);
Card = JsonConvert.SerializeObject(cardData);
break;
case CipherType.Identity:
var idData = cipher.Data.ToObject<IdentityDataModel>();
cipherData = idData;
var idData = new IdentityDataModel(cipher);
Identity = JsonConvert.SerializeObject(idData);
break;
default:
throw new ArgumentException(nameof(cipher.Type));
}
Name = cipherData.Name;
Notes = cipherData.Notes;
Name = cipher.Name;
Notes = cipher.Notes;
if(cipherData.Fields != null && cipherData.Fields.Any())
if(cipher.Fields != null && cipher.Fields.Any())
{
try
{
Fields = JsonConvert.SerializeObject(cipherData.Fields);
Fields = JsonConvert.SerializeObject(cipher.Fields.Select(f => new FieldDataModel(f)));
}
catch(JsonSerializationException) { }
}
@ -80,21 +72,17 @@ namespace Bit.App.Models.Data
public string Name { get; set; }
public string Notes { get; set; }
public string Fields { get; set; }
public string Login { get; set; }
public string Card { get; set; }
public string Identity { get; set; }
public string SecureNote { get; set; }
public bool Favorite { get; set; }
public bool Edit { get; set; }
public bool OrganizationUseTotp { get; set; }
public DateTime RevisionDateTime { get; set; } = DateTime.UtcNow;
[Indexed]
public CipherType Type { get; set; } = CipherType.Login;
[Obsolete]
public string Data { get; set; }
// Login metadata
public string Uri { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Totp { get; set; }
// Secure Note metadata
public SecureNoteType? SecureNoteType { get; set; }
}
}

View File

@ -0,0 +1,33 @@
using Bit.App.Models.Api;
using System;
namespace Bit.App.Models.Data
{
public class CardDataModel : CipherDataModel
{
public CardDataModel() { }
public CardDataModel(CipherResponse response)
: base(response)
{
if(response?.Card == null)
{
throw new ArgumentNullException(nameof(response.Card));
}
CardholderName = response.Card.CardholderName;
Brand = response.Card.Brand;
Number = response.Card.Number;
ExpMonth = response.Card.ExpMonth;
ExpYear = response.Card.ExpYear;
Code = response.Card.Code;
}
public string CardholderName { get; set; }
public string Brand { get; set; }
public string Number { get; set; }
public string ExpMonth { get; set; }
public string ExpYear { get; set; }
public string Code { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using Bit.App.Models.Api;
using System.Collections.Generic;
using System.Linq;
namespace Bit.App.Models.Data
{
public abstract class CipherDataModel
{
public CipherDataModel() { }
public CipherDataModel(CipherResponse cipher)
{
Name = cipher.Name;
Notes = cipher.Notes;
Fields = cipher.Fields.Select(f => new FieldDataModel(f));
}
public string Name { get; set; }
public string Notes { get; set; }
public IEnumerable<FieldDataModel> Fields { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using Bit.App.Models.Api;
namespace Bit.App.Models.Data
{
public class FieldDataModel
{
public FieldDataModel() { }
public FieldDataModel(FieldType f)
{
Type = f.Type;
Name = f.Name;
Value = f.Value;
}
public Enums.FieldType Type { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
}

View File

@ -0,0 +1,57 @@
using Bit.App.Models.Api;
using System;
namespace Bit.App.Models.Data
{
public class IdentityDataModel : CipherDataModel
{
public IdentityDataModel() { }
public IdentityDataModel(CipherResponse response)
: base(response)
{
if(response?.Identity == null)
{
throw new ArgumentNullException(nameof(response.Card));
}
Title = response.Identity.Title;
FirstName = response.Identity.FirstName;
MiddleName = response.Identity.MiddleName;
LastName = response.Identity.LastName;
Address1 = response.Identity.Address1;
Address2 = response.Identity.Address2;
Address3 = response.Identity.Address3;
City = response.Identity.City;
State = response.Identity.State;
PostalCode = response.Identity.PostalCode;
Country = response.Identity.Country;
Company = response.Identity.Company;
Email = response.Identity.Email;
Phone = response.Identity.Phone;
SSN = response.Identity.SSN;
Username = response.Identity.Username;
PassportNumber = response.Identity.PassportNumber;
LicenseNumber = response.Identity.LicenseNumber;
}
public string Title { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string Address3 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
public string Company { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string SSN { get; set; }
public string Username { get; set; }
public string PassportNumber { get; set; }
public string LicenseNumber { get; set; }
}
}

View File

@ -0,0 +1,38 @@
using Bit.App.Models.Api;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Bit.App.Models.Data
{
public class LoginDataModel : CipherDataModel
{
private string _uri;
public LoginDataModel() { }
public LoginDataModel(CipherResponse response)
: base(response)
{
if(response?.Login == null)
{
throw new ArgumentNullException(nameof(response.Card));
}
Uris = response.Login.Uris?.Where(u => u != null).Select(u => new LoginUriDataModel(u));
Username = response.Login.Username;
Password = response.Login.Password;
Totp = response.Login.Totp;
}
public string Uri
{
get => Uris?.FirstOrDefault()?.Uri ?? _uri;
set { _uri = value; }
}
public IEnumerable<LoginUriDataModel> Uris { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Totp { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using Bit.App.Enums;
using Bit.App.Models.Api;
namespace Bit.App.Models.Data
{
public class LoginUriDataModel
{
public LoginUriDataModel() { }
public LoginUriDataModel(LoginUriType u)
{
Uri = u.Uri;
Match = u.Match;
}
public string Uri { get; set; }
public UriMatchType? Match { get; set; }
}
}

View File

@ -0,0 +1,23 @@
using Bit.App.Models.Api;
using System;
namespace Bit.App.Models.Data
{
public class SecureNoteDataModel : CipherDataModel
{
public SecureNoteDataModel() { }
public SecureNoteDataModel(CipherResponse response)
: base(response)
{
if(response?.SecureNote == null)
{
throw new ArgumentNullException(nameof(response.SecureNote));
}
Type = response.SecureNote.Type;
}
public Enums.SecureNoteType Type { get; set; }
}
}

View File

@ -1,5 +1,5 @@
using Bit.App.Enums;
using Bit.App.Models.Api;
using Bit.App.Models.Data;
namespace Bit.App.Models
{

View File

@ -1,6 +1,6 @@
using Bit.App.Models.Api;
using Bit.App.Models.Data;
using Bit.App.Models.Data;
using Newtonsoft.Json;
using System;
namespace Bit.App.Models
{
@ -10,7 +10,19 @@ namespace Bit.App.Models
public Identity(CipherData data)
{
var deserializedData = JsonConvert.DeserializeObject<IdentityDataModel>(data.Data);
IdentityDataModel deserializedData;
if(data.Card != null)
{
deserializedData = JsonConvert.DeserializeObject<IdentityDataModel>(data.Card);
}
else if(data.Data != null)
{
deserializedData = JsonConvert.DeserializeObject<IdentityDataModel>(data.Data);
}
else
{
throw new ArgumentNullException(nameof(data.Identity));
}
Title = deserializedData.Title != null ? new CipherString(deserializedData.Title) : null;
FirstName = deserializedData.FirstName != null ? new CipherString(deserializedData.FirstName) : null;

View File

@ -1,4 +1,8 @@
using Bit.App.Models.Data;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Bit.App.Models
{
@ -8,13 +12,27 @@ namespace Bit.App.Models
public Login(CipherData data)
{
Uri = data.Uri != null ? new CipherString(data.Uri) : null;
Username = data.Username != null ? new CipherString(data.Username) : null;
Password = data.Password != null ? new CipherString(data.Password) : null;
Totp = data.Totp != null ? new CipherString(data.Totp) : null;
LoginDataModel deserializedData;
if(data.Login != null)
{
deserializedData = JsonConvert.DeserializeObject<LoginDataModel>(data.Login);
}
else if(data.Data != null)
{
deserializedData = JsonConvert.DeserializeObject<LoginDataModel>(data.Data);
}
else
{
throw new ArgumentNullException(nameof(data.Identity));
}
Username = deserializedData.Username != null ? new CipherString(deserializedData.Username) : null;
Password = deserializedData.Password != null ? new CipherString(deserializedData.Password) : null;
Totp = deserializedData.Totp != null ? new CipherString(deserializedData.Totp) : null;
Uris = deserializedData.Uris?.Select(u => new LoginUri(u));
}
public CipherString Uri { get; set; }
public IEnumerable<LoginUri> Uris { get; set; }
public CipherString Username { get; set; }
public CipherString Password { get; set; }
public CipherString Totp { get; set; }

View File

@ -0,0 +1,19 @@
using Bit.App.Enums;
using Bit.App.Models.Data;
namespace Bit.App.Models
{
public class LoginUri
{
public LoginUri() { }
public LoginUri(LoginUriDataModel data)
{
Uri = data.Uri != null ? new CipherString(data.Uri) : null;
Match = data.Match;
}
public CipherString Uri { get; set; }
public UriMatchType? Match { get; set; }
}
}

View File

@ -42,7 +42,7 @@ namespace Bit.App.Models.Page
{
case CipherType.Login:
LoginUsername = cipher.Login?.Username?.Decrypt(cipher.OrganizationId) ?? " ";
LoginUri = cipher.Login?.Uri?.Decrypt(cipher.OrganizationId) ?? " ";
LoginUri = cipher.Login.Uris?.FirstOrDefault()?.Uri?.Decrypt(cipher.OrganizationId) ?? " ";
LoginPassword = new Lazy<string>(() => cipher.Login?.Password?.Decrypt(cipher.OrganizationId));
LoginTotp = new Lazy<string>(() => cipher.Login?.Totp?.Decrypt(cipher.OrganizationId));

View File

@ -3,6 +3,7 @@ using System.ComponentModel;
using Xamarin.Forms;
using System.Collections.Generic;
using Bit.App.Enums;
using System.Linq;
namespace Bit.App.Models.Page
{
@ -600,7 +601,7 @@ namespace Bit.App.Models.Page
case CipherType.Login:
LoginUsername = cipher.Login.Username?.Decrypt(cipher.OrganizationId);
LoginPassword = cipher.Login.Password?.Decrypt(cipher.OrganizationId);
LoginUri = cipher.Login.Uri?.Decrypt(cipher.OrganizationId);
LoginUri = cipher.Login.Uris?.FirstOrDefault()?.Uri?.Decrypt(cipher.OrganizationId);
break;
case CipherType.Card:
CardName = cipher.Card.CardholderName?.Decrypt(cipher.OrganizationId);

View File

@ -1,5 +1,7 @@
using Bit.App.Enums;
using Bit.App.Models.Data;
using Newtonsoft.Json;
using System;
namespace Bit.App.Models
{
@ -9,7 +11,21 @@ namespace Bit.App.Models
public SecureNote(CipherData data)
{
Type = data.SecureNoteType.Value;
SecureNoteDataModel deserializedData;
if(data.SecureNote != null)
{
deserializedData = JsonConvert.DeserializeObject<SecureNoteDataModel>(data.SecureNote);
}
else if(data.Data != null)
{
deserializedData = JsonConvert.DeserializeObject<SecureNoteDataModel>(data.Data);
}
else
{
throw new ArgumentNullException(nameof(data.Identity));
}
Type = deserializedData.Type;
}
public SecureNoteType Type { get; set; }