domains and view stubs
This commit is contained in:
parent
7c6c36b744
commit
8ade49c958
|
@ -7,19 +7,21 @@ namespace Bit.Core.Models.Domain
|
||||||
{
|
{
|
||||||
public class Attachment : Domain
|
public class Attachment : Domain
|
||||||
{
|
{
|
||||||
public Attachment() { }
|
private HashSet<string> _map = new HashSet<string>
|
||||||
|
|
||||||
public Attachment(AttachmentData obj, bool alreadyEncrypted = false)
|
|
||||||
{
|
|
||||||
Size = obj.Size;
|
|
||||||
BuildDomainModel(this, obj, new HashSet<string>
|
|
||||||
{
|
{
|
||||||
"Id",
|
"Id",
|
||||||
"Url",
|
"Url",
|
||||||
"SizeName",
|
"SizeName",
|
||||||
"FileName",
|
"FileName",
|
||||||
"Key"
|
"Key"
|
||||||
}, alreadyEncrypted, new HashSet<string> { "Id", "Url", "SizeName" });
|
};
|
||||||
|
|
||||||
|
public Attachment() { }
|
||||||
|
|
||||||
|
public Attachment(AttachmentData obj, bool alreadyEncrypted = false)
|
||||||
|
{
|
||||||
|
Size = obj.Size;
|
||||||
|
BuildDomainModel(this, obj, _map, alreadyEncrypted, new HashSet<string> { "Id", "Url", "SizeName" });
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
@ -45,14 +47,7 @@ namespace Bit.Core.Models.Domain
|
||||||
{
|
{
|
||||||
var a = new AttachmentData();
|
var a = new AttachmentData();
|
||||||
a.Size = Size;
|
a.Size = Size;
|
||||||
BuildDataModel(this, a, new HashSet<string>
|
BuildDataModel(this, a, _map, new HashSet<string> { "Id", "Url", "SizeName" });
|
||||||
{
|
|
||||||
"Id",
|
|
||||||
"Url",
|
|
||||||
"SizeName",
|
|
||||||
"FileName",
|
|
||||||
"Key"
|
|
||||||
}, new HashSet<string> { "Id", "Url", "SizeName" });
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
using Bit.Core.Models.Data;
|
||||||
|
using Bit.Core.Models.View;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Bit.Core.Models.Domain
|
||||||
|
{
|
||||||
|
public class Card : Domain
|
||||||
|
{
|
||||||
|
private HashSet<string> _map = new HashSet<string>
|
||||||
|
{
|
||||||
|
"CardholderName",
|
||||||
|
"Brand",
|
||||||
|
"Number",
|
||||||
|
"ExpMonth",
|
||||||
|
"ExpYear",
|
||||||
|
"Code"
|
||||||
|
};
|
||||||
|
|
||||||
|
public Card() { }
|
||||||
|
|
||||||
|
public Card(CardData obj, bool alreadyEncrypted = false)
|
||||||
|
{
|
||||||
|
BuildDomainModel(this, obj, _map, alreadyEncrypted);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CipherString CardholderName { get; set; }
|
||||||
|
public CipherString Brand { get; set; }
|
||||||
|
public CipherString Number { get; set; }
|
||||||
|
public CipherString ExpMonth { get; set; }
|
||||||
|
public CipherString ExpYear { get; set; }
|
||||||
|
public CipherString Code { get; set; }
|
||||||
|
|
||||||
|
public Task<CardView> DecryptAsync(string orgId)
|
||||||
|
{
|
||||||
|
return DecryptObjAsync(new CardView(this), this, _map, orgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CardData ToLoginUriData()
|
||||||
|
{
|
||||||
|
var c = new CardData();
|
||||||
|
BuildDataModel(this, c, _map);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
using Bit.Core.Models.Data;
|
||||||
|
using Bit.Core.Models.View;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Bit.Core.Models.Domain
|
||||||
|
{
|
||||||
|
public class Identity : Domain
|
||||||
|
{
|
||||||
|
private HashSet<string> _map = new HashSet<string>
|
||||||
|
{
|
||||||
|
"Title",
|
||||||
|
"FirstName",
|
||||||
|
"MiddleName",
|
||||||
|
"LastName",
|
||||||
|
"Address1",
|
||||||
|
"Address2",
|
||||||
|
"Address3",
|
||||||
|
"City",
|
||||||
|
"State",
|
||||||
|
"PostalCode",
|
||||||
|
"Country",
|
||||||
|
"Company",
|
||||||
|
"Email",
|
||||||
|
"Phone",
|
||||||
|
"SSN",
|
||||||
|
"Username",
|
||||||
|
"PassportNumber",
|
||||||
|
"LicenseNumber"
|
||||||
|
};
|
||||||
|
|
||||||
|
public Identity() { }
|
||||||
|
|
||||||
|
public Identity(IdentityData obj, bool alreadyEncrypted = false)
|
||||||
|
{
|
||||||
|
BuildDomainModel(this, obj, _map, alreadyEncrypted);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CipherString Title { get; set; }
|
||||||
|
public CipherString FirstName { get; set; }
|
||||||
|
public CipherString MiddleName { get; set; }
|
||||||
|
public CipherString LastName { get; set; }
|
||||||
|
public CipherString Address1 { get; set; }
|
||||||
|
public CipherString Address2 { get; set; }
|
||||||
|
public CipherString Address3 { get; set; }
|
||||||
|
public CipherString City { get; set; }
|
||||||
|
public CipherString State { get; set; }
|
||||||
|
public CipherString PostalCode { get; set; }
|
||||||
|
public CipherString Country { get; set; }
|
||||||
|
public CipherString Company { get; set; }
|
||||||
|
public CipherString Email { get; set; }
|
||||||
|
public CipherString Phone { get; set; }
|
||||||
|
public CipherString SSN { get; set; }
|
||||||
|
public CipherString Username { get; set; }
|
||||||
|
public CipherString PassportNumber { get; set; }
|
||||||
|
public CipherString LicenseNumber { get; set; }
|
||||||
|
|
||||||
|
public Task<IdentityView> DecryptAsync(string orgId)
|
||||||
|
{
|
||||||
|
return DecryptObjAsync(new IdentityView(this), this, _map, orgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IdentityData ToLoginUriData()
|
||||||
|
{
|
||||||
|
var i = new IdentityData();
|
||||||
|
BuildDataModel(this, i, _map);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,15 +1,68 @@
|
||||||
using System;
|
using Bit.Core.Models.Data;
|
||||||
|
using Bit.Core.Models.View;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Bit.Core.Models.Domain
|
namespace Bit.Core.Models.Domain
|
||||||
{
|
{
|
||||||
public class Login : Domain
|
public class Login : Domain
|
||||||
{
|
{
|
||||||
|
public Login() { }
|
||||||
|
|
||||||
|
public Login(LoginData obj, bool alreadyEncrypted = false)
|
||||||
|
{
|
||||||
|
PasswordRevisionDate = obj.PasswordRevisionDate;
|
||||||
|
Uris = obj.Uris?.Select(u => new LoginUri(u, alreadyEncrypted)).ToList();
|
||||||
|
BuildDomainModel(this, obj, new HashSet<string>
|
||||||
|
{
|
||||||
|
"Username",
|
||||||
|
"Password",
|
||||||
|
"Totp"
|
||||||
|
}, alreadyEncrypted);
|
||||||
|
}
|
||||||
|
|
||||||
public List<LoginUri> Uris { get; set; }
|
public List<LoginUri> Uris { get; set; }
|
||||||
public CipherString Username { get; set; }
|
public CipherString Username { get; set; }
|
||||||
public CipherString Password { get; set; }
|
public CipherString Password { get; set; }
|
||||||
public DateTime? PasswordRevisionDate { get; set; }
|
public DateTime? PasswordRevisionDate { get; set; }
|
||||||
public CipherString Totp { get; set; }
|
public CipherString Totp { get; set; }
|
||||||
|
|
||||||
|
public async Task<LoginView> DecryptAsync(string orgId)
|
||||||
|
{
|
||||||
|
var view = await DecryptObjAsync(new LoginView(this), this, new HashSet<string>
|
||||||
|
{
|
||||||
|
"Username",
|
||||||
|
"Password",
|
||||||
|
"Totp"
|
||||||
|
}, orgId);
|
||||||
|
if(Uris != null)
|
||||||
|
{
|
||||||
|
view.Uris = new List<LoginUriView>();
|
||||||
|
foreach(var uri in Uris)
|
||||||
|
{
|
||||||
|
view.Uris.Add(await uri.DecryptAsync(orgId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoginData ToLoginUriData()
|
||||||
|
{
|
||||||
|
var l = new LoginData();
|
||||||
|
l.PasswordRevisionDate = PasswordRevisionDate;
|
||||||
|
BuildDataModel(this, l, new HashSet<string>
|
||||||
|
{
|
||||||
|
"Username",
|
||||||
|
"Password",
|
||||||
|
"Totp"
|
||||||
|
});
|
||||||
|
if(Uris?.Any() ?? false)
|
||||||
|
{
|
||||||
|
l.Uris = Uris.Select(u => u.ToLoginUriData()).ToList();
|
||||||
|
}
|
||||||
|
return l;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,15 +8,17 @@ namespace Bit.Core.Models.Domain
|
||||||
{
|
{
|
||||||
public class LoginUri : Domain
|
public class LoginUri : Domain
|
||||||
{
|
{
|
||||||
|
private HashSet<string> _map = new HashSet<string>
|
||||||
|
{
|
||||||
|
"Uri"
|
||||||
|
};
|
||||||
|
|
||||||
public LoginUri() { }
|
public LoginUri() { }
|
||||||
|
|
||||||
public LoginUri(LoginUriData obj, bool alreadyEncrypted = false)
|
public LoginUri(LoginUriData obj, bool alreadyEncrypted = false)
|
||||||
{
|
{
|
||||||
Match = obj.Match;
|
Match = obj.Match;
|
||||||
BuildDomainModel(this, obj, new HashSet<string>
|
BuildDomainModel(this, obj, _map, alreadyEncrypted);
|
||||||
{
|
|
||||||
"Uri"
|
|
||||||
}, alreadyEncrypted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CipherString Uri { get; set; }
|
public CipherString Uri { get; set; }
|
||||||
|
@ -24,19 +26,13 @@ namespace Bit.Core.Models.Domain
|
||||||
|
|
||||||
public Task<LoginUriView> DecryptAsync(string orgId)
|
public Task<LoginUriView> DecryptAsync(string orgId)
|
||||||
{
|
{
|
||||||
return DecryptObjAsync(new LoginUriView(this), this, new HashSet<string>
|
return DecryptObjAsync(new LoginUriView(this), this, _map, orgId);
|
||||||
{
|
|
||||||
"Uri"
|
|
||||||
}, orgId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoginUriData ToLoginUriData()
|
public LoginUriData ToLoginUriData()
|
||||||
{
|
{
|
||||||
var u = new LoginUriData();
|
var u = new LoginUriData();
|
||||||
BuildDataModel(this, u, new HashSet<string>
|
BuildDataModel(this, u, _map, new HashSet<string> { "Match" });
|
||||||
{
|
|
||||||
"Uri"
|
|
||||||
}, new HashSet<string> { "Match" });
|
|
||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
using Bit.Core.Enums;
|
||||||
|
using Bit.Core.Models.Data;
|
||||||
|
using Bit.Core.Models.View;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Bit.Core.Models.Domain
|
||||||
|
{
|
||||||
|
public class SecureNote : Domain
|
||||||
|
{
|
||||||
|
public SecureNote() { }
|
||||||
|
|
||||||
|
public SecureNote(SecureNoteData obj, bool alreadyEncrypted = false)
|
||||||
|
{
|
||||||
|
Type = obj.Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecureNoteType Type { get; set; }
|
||||||
|
|
||||||
|
public Task<SecureNoteView> DecryptAsync(string orgId)
|
||||||
|
{
|
||||||
|
return Task.FromResult(new SecureNoteView(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecureNoteData ToLoginUriData()
|
||||||
|
{
|
||||||
|
return new SecureNoteData
|
||||||
|
{
|
||||||
|
Type = Type
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
using Bit.Core.Models.Domain;
|
||||||
|
|
||||||
|
namespace Bit.Core.Models.View
|
||||||
|
{
|
||||||
|
public class CardView : View
|
||||||
|
{
|
||||||
|
public CardView() { }
|
||||||
|
|
||||||
|
public CardView(Card c) { }
|
||||||
|
|
||||||
|
public string Id { get; set; }
|
||||||
|
public string Url { get; set; }
|
||||||
|
public string Size { get; set; }
|
||||||
|
public string SizeName { get; set; }
|
||||||
|
public string FileName { get; set; }
|
||||||
|
public SymmetricCryptoKey Key { get; set; }
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
using Bit.Core.Models.Domain;
|
||||||
|
|
||||||
|
namespace Bit.Core.Models.View
|
||||||
|
{
|
||||||
|
public class IdentityView : View
|
||||||
|
{
|
||||||
|
public IdentityView() { }
|
||||||
|
|
||||||
|
public IdentityView(Identity i) { }
|
||||||
|
|
||||||
|
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; }
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
using Bit.Core.Enums;
|
||||||
|
using Bit.Core.Models.Domain;
|
||||||
|
|
||||||
|
namespace Bit.Core.Models.View
|
||||||
|
{
|
||||||
|
public class SecureNoteView : View
|
||||||
|
{
|
||||||
|
public SecureNoteView() { }
|
||||||
|
|
||||||
|
public SecureNoteView(SecureNote n)
|
||||||
|
{
|
||||||
|
Type = n.Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecureNoteType Type { get; set; }
|
||||||
|
public string SubTitle => null;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue